test.js 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931
  1. var Qv=Math.pow;var wn=(wo,tt,te)=>new Promise((ct,Fp)=>{var Op=na=>{try{th(te.next(na))}catch(nh){Fp(nh)}},eh=na=>{try{th(te.throw(na))}catch(nh){Fp(nh)}},th=na=>na.done?ct(na.value):Promise.resolve(na.value).then(Op,eh);th((te=te.apply(wo,tt)).next())});var test=function(wo,tt,te,ct,Fp){var Op=document.createElement("style");Op.textContent=`.heading[data-v-9bd7093d]{font-size:1.5em;margin-bottom:12px}.card[data-v-9bd7093d]{background:#fff;color:#000;background-image:linear-gradient(48deg,#fff 0%,#e5efe9 100%);border-top-right-radius:16px;border-bottom-left-radius:16px;box-shadow:-20px 20px 35px 1px #0a31562e;display:flex;flex-direction:column;padding:32px;margin:40px;max-width:400px;width:100%}.content-wrapper[data-v-9bd7093d]{font-size:1.1em;margin-bottom:44px}.content-wrapper[data-v-9bd7093d]:last-child{margin-bottom:0}.button[data-v-9bd7093d]{align-items:center;background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;color:#121943;cursor:pointer;display:flex;font-size:1em;font-weight:700;height:40px;justify-content:center;width:180px}.button[data-v-9bd7093d]:focus{border:2px solid transparent;box-shadow:0 0 0 2px #121943;outline:solid 4px transparent}.link[data-v-9bd7093d]{color:#121943}.link[data-v-9bd7093d]:focus{box-shadow:0 0 0 2px #121943}.input-wrapper[data-v-9bd7093d]{display:flex;flex-direction:column}.input-wrapper .label[data-v-9bd7093d]{align-items:baseline;display:flex;font-weight:700;justify-content:space-between;margin-bottom:8px}.input-wrapper .optional[data-v-9bd7093d]{color:#5a72b5;font-size:.9em}.input-wrapper .input[data-v-9bd7093d]{border:1px solid #5a72b5;border-radius:4px;height:40px;padding:8px}code[data-v-9bd7093d]{background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;padding:2px 4px}.modal-header[data-v-9bd7093d]{align-items:baseline;display:flex;justify-content:space-between}.close[data-v-9bd7093d]{background:none;border:none;cursor:pointer;display:flex;height:16px;text-decoration:none;width:16px}.close svg[data-v-9bd7093d]{width:16px}.modal-wrapper[data-v-9bd7093d]{align-items:center;background:rgba(0,0,0,.7);display:flex;justify-content:center;inset:0;position:fixed}#modal[data-v-9bd7093d]{transition:opacity .25s ease-in-out}#modal .modal-body[data-v-9bd7093d]{max-width:830px;opacity:1;transform:translateY(-100px);transition:opacity .25s ease-in-out;width:100%;z-index:1}.outside-trigger[data-v-9bd7093d]{cursor:default;inset:0;position:fixed}.button__link[data-v-9bd7093d]{text-decoration:none}.button[data-v-9bd7093d]{background-color:#4caf50;border:none;color:#fff;text-align:center;text-decoration:none;display:inline-block;font-size:16px;margin:4px 2px;-webkit-transition-duration:.4s;transition-duration:.4s;cursor:pointer}.button1[data-v-9bd7093d]{background-color:#fff;color:#000;border:2px solid #4caf50}.button1[data-v-9bd7093d]:hover{background-color:#4caf50;color:#fff}.button2[data-v-9bd7093d]{background-color:#fff;color:#000;border:2px solid #008cba}.button2[data-v-9bd7093d]:hover{background-color:#008cba;color:#fff}.btn_box[data-v-9bd7093d]{width:100%;display:flex;justify-items:center;justify-content:start;align-items:start}
  2. `,document.head.appendChild(Op);const eh=ct.ref(!1),th=e=>{eh.value=!0,Ug.value=Object.assign(Ug.value,e||{})},na=()=>{eh.value=!1},nh={title:"Modal",text:"",oncancel:na,onsubmit:na,ongetallentity:na,ondrawline:na,docommand:e=>{}},Ug=ct.ref(nh),e0=()=>({isModalVisible:eh,showModal:th,hideModal:na,modalOptions:Ug}),tM=e=>(ct.pushScopeId("data-v-9bd7093d"),e=e(),ct.popScopeId(),e),nM={key:0,class:"modal-wrapper",id:"modal"},iM={class:"modal-body card"},rM={class:"modal-header"},aM={class:"heading"},oM=[tM(()=>ct.createElementVNode("svg",{viewBox:"0 0 24 24"},[ct.createElementVNode("path",{d:"M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z"})],-1))],sM={style:{"overflow-y":"auto",height:"500px"}},lM={class:"btn_box"},cM={class:"btn_box"},uM={class:"btn_box"},hM={class:"btn_box"},dM={class:"btn_box"},pM={class:"btn_box"},fM={class:"btn_box"},mM={class:"btn_box"},gM={class:"btn_box"},_M={class:"btn_box"},yM={class:"btn_box"},vM={class:"btn_box"},xM={class:"btn_box"},bM={class:"btn_box"},wM=ct.defineComponent({__name:"Modal",setup(e){const{isModalVisible:n,hideModal:i,modalOptions:l}=e0();return i(),(h,p)=>(ct.openBlock(),ct.createBlock(ct.Teleport,{to:"body"},[ct.createTextVNode(" 2356788909-80976564578697809-090897867 "),ct.unref(n)?(ct.openBlock(),ct.createElementBlock("div",nM,[ct.createElementVNode("div",iM,[ct.createElementVNode("div",rM,[ct.createElementVNode("h2",aM,ct.toDisplayString(ct.unref(l).title),1),ct.createElementVNode("a",{href:"#!",onClick:p[0]||(p[0]=(..._)=>ct.unref(i)&&ct.unref(i)(..._)),role:"button",class:"close","aria-label":"close this modal"},oM)]),ct.createElementVNode("div",sM,[ct.createElementVNode("div",lM,[ct.createElementVNode("button",{class:"button button2",onClick:p[1]||(p[1]=_=>ct.unref(l).docommand("Mx_Open_DemoCode"))}," 下载开Demo代码 "),ct.createElementVNode("button",{class:"button button2",onClick:p[2]||(p[2]=_=>ct.unref(l).docommand("Mx_Open_DevInstall"))}," 下载开发包 "),ct.createElementVNode("button",{class:"button button2",onClick:p[3]||(p[3]=(..._)=>ct.unref(l).ondrawline&&ct.unref(l).ondrawline(..._))}," 调用画圆线命令 "),ct.createElementVNode("button",{class:"button button2",onClick:p[4]||(p[4]=_=>ct.unref(l).docommand("MxTest_DrawLine"))}," 交互画直线 ")]),ct.createElementVNode("div",cM,[ct.createElementVNode("button",{class:"button button2",onClick:p[5]||(p[5]=_=>ct.unref(l).docommand("MxTest_AddLayer"))}," 添加图层 "),ct.createElementVNode("button",{class:"button button2",onClick:p[6]||(p[6]=_=>ct.unref(l).docommand("MxTest_GetAllLayer"))}," 得到所有图层 "),ct.createElementVNode("button",{class:"button button2",onClick:p[7]||(p[7]=_=>ct.unref(l).docommand("MxTest_GetAllTextStyle"))}," 得到所有文字样式 "),ct.createElementVNode("button",{class:"button button2",onClick:p[8]||(p[8]=_=>ct.unref(l).docommand("MxTest_GetAllBlock"))}," 得到所有图块 ")]),ct.createElementVNode("div",uM,[ct.createElementVNode("button",{class:"button button2",onClick:p[9]||(p[9]=_=>ct.unref(l).docommand("MxTest_GetAllLinetype"))}," 得到所有线型 "),ct.createElementVNode("button",{class:"button button2",onClick:p[10]||(p[10]=_=>ct.unref(l).docommand("MxTest_WritexData"))}," 写扩展数据 "),ct.createElementVNode("button",{class:"button button2",onClick:p[11]||(p[11]=_=>ct.unref(l).docommand("MxTest_ReadxData"))}," 读扩展数据 "),ct.createElementVNode("button",{class:"button button2",onClick:p[12]||(p[12]=_=>ct.unref(l).docommand("MxTest_InsertBlock"))}," 测试插入一个图块 ")]),ct.createElementVNode("div",hM,[ct.createElementVNode("button",{class:"button button2",onClick:p[13]||(p[13]=_=>ct.unref(l).docommand("Mx_Test_DrawLine"))}," 绘直线 "),ct.createElementVNode("button",{class:"button button2",onClick:p[14]||(p[14]=_=>ct.unref(l).docommand("Mx_Test_DrawArc"))}," 绘圆弧 "),ct.createElementVNode("button",{class:"button button2",onClick:p[15]||(p[15]=_=>ct.unref(l).docommand("Mx_Test_DrawCircle"))}," 绘圆 "),ct.createElementVNode("button",{class:"button button2",onClick:p[16]||(p[16]=_=>ct.unref(l).docommand("Mx_Test_DrawPolyline"))}," 绘PL线 ")]),ct.createElementVNode("div",dM,[ct.createElementVNode("button",{class:"button button2",onClick:p[17]||(p[17]=_=>ct.unref(l).docommand("Mx_Test_DrawHatch"))}," 绘填充 "),ct.createElementVNode("button",{class:"button button2",onClick:p[18]||(p[18]=_=>ct.unref(l).docommand("Mx_Test_DrawText"))}," 绘文字 "),ct.createElementVNode("button",{class:"button button2",onClick:p[19]||(p[19]=_=>ct.unref(l).docommand("Mx_Test_Ellipse"))}," 绘椭圆 "),ct.createElementVNode("button",{class:"button button2",onClick:p[20]||(p[20]=_=>ct.unref(l).docommand("Mx_Test_EllipseArc"))}," 绘椭圆弧 ")]),ct.createElementVNode("div",pM,[ct.createElementVNode("button",{class:"button button2",onClick:p[21]||(p[21]=_=>ct.unref(l).docommand("Mx_Test_MText"))}," 绘制多行文字 "),ct.createElementVNode("button",{class:"button button2",onClick:p[22]||(p[22]=_=>ct.unref(l).docommand("Mx_Test_DrawTable"))}," 绘制表格 "),ct.createElementVNode("button",{class:"button button2",onClick:p[23]||(p[23]=_=>ct.unref(l).docommand("Mx_Test_QRCode"))}," 绘制二维码 "),ct.createElementVNode("button",{class:"button button2",onClick:p[24]||(p[24]=_=>ct.unref(l).docommand("MxTest_InsertStamp"))}," 插入图章 ")]),ct.createElementVNode("div",fM,[ct.createElementVNode("button",{class:"button button2",onClick:p[25]||(p[25]=(..._)=>ct.unref(l).ongetallentity&&ct.unref(l).ongetallentity(..._))}," 得到所有对象 "),ct.createElementVNode("button",{class:"button button2",onClick:p[26]||(p[26]=_=>ct.unref(l).docommand("MxTest_SelectEntity"))}," 交互选择对象 "),ct.createElementVNode("button",{class:"button button2",onClick:p[27]||(p[27]=_=>ct.unref(l).docommand("Mx_Export_MxWeb"))}," 保存mxweb到服务器 "),ct.createElementVNode("button",{class:"button button2",onClick:p[28]||(p[28]=_=>ct.unref(l).docommand("MxTest_GetSysVars"))}," 得到系统变量 ")]),ct.createElementVNode("div",mM,[ct.createElementVNode("button",{class:"button button2",onClick:p[29]||(p[29]=_=>ct.unref(l).docommand("MxTest_NewFile"))}," 新建图纸 "),ct.createElementVNode("button",{class:"button button2",onClick:p[30]||(p[30]=_=>ct.unref(l).docommand("Mx_ViewBackgroundColor"))}," 白色背景色 "),ct.createElementVNode("button",{class:"button button2",onClick:p[31]||(p[31]=_=>ct.unref(l).docommand("MxTest_FindText"))}," 文字查找定位 "),ct.createElementVNode("button",{class:"button button2",onClick:p[32]||(p[32]=_=>ct.unref(l).docommand("MxTest_SelectEntitysToBlock"))}," 选择实体做块 ")]),ct.createElementVNode("div",gM,[ct.createElementVNode("button",{class:"button button2",onClick:p[33]||(p[33]=_=>ct.unref(l).docommand("Mx_Test_Text"))}," 绘制单行文字 "),ct.createElementVNode("button",{class:"button button2",onClick:p[34]||(p[34]=_=>ct.unref(l).docommand("MxTest_DrawHatchFormPoint"))}," 选点填充 "),ct.createElementVNode("button",{class:"button button2",onClick:p[35]||(p[35]=_=>ct.unref(l).docommand("Mx_TestExProp"))}," 设置扩展属性 "),ct.createElementVNode("button",{class:"button button2",onClick:p[36]||(p[36]=_=>ct.unref(l).docommand("Mx_Test_DimAligned"))}," 绘制对齐标注 ")]),ct.createElementVNode("div",_M,[ct.createElementVNode("button",{class:"button button2",onClick:p[37]||(p[37]=_=>ct.unref(l).docommand("Mx_Test_DrawDimRotated"))}," 绘性线标注 "),ct.createElementVNode("button",{class:"button button2",onClick:p[38]||(p[38]=_=>ct.unref(l).docommand("Mx_Test_DrawDimAngular"))}," 角度标注 "),ct.createElementVNode("button",{class:"button button2",onClick:p[39]||(p[39]=_=>ct.unref(l).docommand("MxTest_LineTypeTest"))}," 修改对象线型 "),ct.createElementVNode("button",{class:"button button2",onClick:p[40]||(p[40]=_=>ct.unref(l).docommand("Mx_SelectEntitHideLayer"))}," 选择隐藏对象层 ")]),ct.createElementVNode("div",yM,[ct.createElementVNode("button",{class:"button button2",onClick:p[41]||(p[41]=_=>ct.unref(l).docommand("MxTest_TestAddCurrentSelect"))}," 添加到当前选择 "),ct.createElementVNode("button",{class:"button button2",onClick:p[42]||(p[42]=_=>ct.unref(l).docommand("MxTest_TestSetViewAngle"))}," 视区旋转 "),ct.createElementVNode("button",{class:"button button2",onClick:p[43]||(p[43]=_=>ct.unref(l).docommand("MxTest_WriteXRecord"))}," 写扩展记录 "),ct.createElementVNode("button",{class:"button button2",onClick:p[44]||(p[44]=_=>ct.unref(l).docommand("MxTest_GetNamedObjectsDictionary"))}," 得到命名字典 ")]),ct.createElementVNode("div",vM,[ct.createElementVNode("button",{class:"button button2",onClick:p[45]||(p[45]=_=>ct.unref(l).docommand("MxTest_AddTextStyleTable"))}," 添加文字样式 "),ct.createElementVNode("button",{class:"button button2",onClick:p[46]||(p[46]=_=>ct.unref(l).docommand("MxTest_DrawCustomEntity"))}," 绘自定义实体 "),ct.createElementVNode("button",{class:"button button2",onClick:p[47]||(p[47]=_=>ct.unref(l).docommand("Mx_Test_ChangeColor"))}," 修改对象颜色 "),ct.createElementVNode("button",{class:"button button2",onClick:p[48]||(p[48]=_=>ct.unref(l).docommand("Mx_Test_ChangeVisible"))}," 修改对象不可见 ")]),ct.createElementVNode("div",xM,[ct.createElementVNode("button",{class:"button button2",onClick:p[49]||(p[49]=_=>ct.unref(l).docommand("Mx_Test_ChangeEntityLayer"))}," 修改对象层 "),ct.createElementVNode("button",{class:"button button2",onClick:p[50]||(p[50]=_=>ct.unref(l).docommand("Mx_ChaneEntityDrawOrder"))}," 修改对象显示顺序 "),ct.createElementVNode("button",{class:"button button2",onClick:p[51]||(p[51]=_=>ct.unref(l).docommand("Mx_Export_Pdf"))}," 指定范围输出pdf "),ct.createElementVNode("button",{class:"button button2",onClick:p[52]||(p[52]=_=>ct.unref(l).docommand("Mx_Test_DrawImage"))}," 绘制image ")]),ct.createElementVNode("div",bM,[ct.createElementVNode("button",{class:"button button2",onClick:p[53]||(p[53]=_=>ct.unref(l).docommand("MxTest_GetObjectExDictionaryData"))}," 读取对象扩展字典 ")])])])])):ct.createCommentVNode("",!0)]))}}),iR="",t0=(e,n)=>{const i=e.__vccOpts||e;for(const[l,h]of n)i[l]=h;return i},MM=t0(wM,[["__scopeId","data-v-9bd7093d"],["__file","Modal.vue"]]),TM=t0(ct.defineComponent({__name:"Test",setup(e){return(n,i)=>(ct.openBlock(),ct.createElementBlock("div",null,[ct.createVNode(MM)]))}}),[["__file","Test.vue"]]),EM={init(){tt.MxFun.setPostMessageToParentFrameFunction(function(e){top.postMessage(e,"*")}),window.addEventListener("message",function(e){e.data.type==="sendStringToExecute"?tt.MxFun.sendStringToExecute(e.data.cmd,e.data):(console.log("mx:unprocessed message:"),console.log(e.data))},!1)}};function SM(){EM.init()}function AM(){return wn(this,null,function*(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(`
  3. 指定第一点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new tt.MxDbLeadComment;l.point1=i.clone(),l.textHeight=tt.MxFun.screenCoordLong2Doc(50),l.text="测试Test1",l.textWidth=tt.MxFun.screenCoordLong2Doc(300),l.fixedSize=!0,l.fixedSize&&(l.textHeight=50,l.textWidth=250),l.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const h=new tt.McEdGetPointWorldDrawObject;h.setDraw((p,_)=>{l.point2=p,_.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(h),e.setMessage(`
  4. 指定第二点:`),e.go(p=>{if(p!=0){console.log(p);return}const _=e.value();l.point2=_,tt.MxFun.addToCurrentSpace(l)})})})}function CM(){tt.MxFun.getCurrentDraw().createCanvasImageData(e=>{const n=window.open();n!=null&&(n.document.write('<img src="'+e+'"/>'),setTimeout(()=>{n.print()},300))},{width:349,height:536})}function PM(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const n=new tt.MrxDbgUiPrPoint,i=tt.MxFun.getCurrentDraw(),l=new tt.McEdGetPointWorldDrawObject,h=new tt.MxDbRectBoxLeadComment;h.color=e.getHex(),h.color==0&&(h.color=65793),h.radius=tt.MxFun.screenCoordLong2Doc(8),h.setLineWidth(3),h.setLineWidthByPixels(!0),n.setMessage(`
  5. 云线框起始点:`),n.go(p=>{p==tt.MrxDbgUiPrBaseReturn.kOk&&(h.point1=n.value(),l.setDraw(_=>{h.point2=_,l.drawCustomEntity(h)}),n.setUserDraw(l),n.setMessage(`
  6. 云线框结束点:`),n.go(_=>{_==tt.MrxDbgUiPrBaseReturn.kOk&&(h.point2=n.value(),l.setDraw(s=>{h.point3=s,l.drawCustomEntity(h)}),h.text="审图批注XXXXXXXXXX",h.textWidth=tt.MxFun.screenCoordLong2Doc(200),h.textHeight=tt.MxFun.screenCoordLong2Doc(50),h.fixedSize=!0,h.fixedSize&&(h.textHeight=20,h.textWidth=230),n.setMessage(`
  7. 审图标注点:`),n.go(s=>{s==tt.MrxDbgUiPrBaseReturn.kOk&&(h.point3=n.value(),i.addMxEntity(h))}))}))})})}function Vg(e,n){let i=tt.MxFun.screenCoordLong2World(n?e:e-e/3);return i=tt.MxFun.worldCoordLong2Doc(i),i}function LM(){const e=new tt.McEdGetPointWorldDrawObject,n=new tt.MxDbArrow,i=tt.MxFun.getCurrentDraw(),l=new tt.MrxDbgUiPrPoint;l.setUserDraw(e),n.setLineWidth(10),n.innerOffset=Vg(10),n.outerOffset=Vg(22),n.topOffset=Vg(36),n.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),l.go(()=>{n.startPoint=l.value(),e.setDraw(h=>{n.endPoint=h,e.drawCustomEntity(n)}),l.go(h=>wn(this,null,function*(){n.endPoint=l.value(),i.addMxEntity(n)}))})}function DM(){const e=new tt.MrxDbgUiPrPoint,n=tt.MxFun.getCurrentDraw(),i=new tt.McEdGetPointWorldDrawObject,l=tt.MxFun.screenCoordLong2Doc(16);e.setMessage(`
  8. 点击开启绘制云线:`),e.go(()=>{let h=e.value();const p=new tt.MxDbCloudLine;p.setRadius(l),p.addPoint(h),p.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),i.setDraw(_=>{h.distanceTo(_)>l&&(h=_.clone(),p.addPoint(_,!0)),i.drawCustomEntity(p)}),e.setUserDraw(i),e.setMessage(`
  9. 再次点击结束绘制云线:`),e.go(()=>{n.addMxEntity(p)})})}let Np="";function IM(){Np=tt.MxFun.getCurrentDraw().saveMxEntityToJson(),console.log(Np)}function RM(){return wn(this,null,function*(){if(Np.length==0)return;let e=tt.MxFun.getCurrentDraw();yield e.loadMxEntityFromJson(Np,["models/svg/mark.svg"]),e.updateDisplay()})}function zM(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(`
  10. 指定第一点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new tt.MxDbArea;l.addPoint(i),l.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const h=new tt.McEdGetPointWorldDrawObject;h.setDraw((p,_)=>{let s=l.clone();s.addPoint(p),h.drawCustomEntity(s)}),e.setUserDraw(h),e.setMessage(`
  11. 指定下一点:`),e.goWhile(p=>{if(p==0){const _=e.value();l.addPoint(_)}},p=>{l.isFill=!0,l.fillOpacity=.7,l.fillColor=6697540,tt.MxFun.getCurrentDraw().addMxEntity(l)})})}function kM(){tt.MxFun.addCommand("BR_Comment",AM),tt.MxFun.addCommand("BR_CheckDraw",PM),tt.MxFun.addCommand("BR_Arrow",LM),tt.MxFun.addCommand("BR_CloudLine",DM),tt.MxFun.addCommand("BR_Print",CM),tt.MxFun.addCommand("BR_SaveAllMxEntity",IM),tt.MxFun.addCommand("BR_LoadAllMxEntity",RM),tt.MxFun.addCommand("BR_Area",zM)}function BM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("LineLayer"),e.drawLayer="LineLayer",e.drawLine(0,0,100,0),e.drawLine(200,0,300,100),e.addLinetype("MyLineType","6,-10"),e.drawLinetype="MyLineType",e.drawLine(0,30,100,30),e.drawLine(200,30,300,130),e.drawColor=new te.McCmColor(0,0,255),e.drawLine(0,60,100,60),e.drawLine(200,60,300,160),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=4,e.drawLine(0,90,100,90),e.drawLine(200,90,300,190),e.addLinetype("MyLineType2","10,-2,3,-2"),e.drawLinetype="MyLineType2",e.drawColor=new te.McCmColor(255,0,0),e.drawLine(0,120,100,120),e.drawLine(200,120,300,220),e.addTextStyle("MyLineTypeTextStyle","txt.shx","hztxt.shx",1),e.addLinetypeEx("MyLineType3",'(12.7,("T=MxDraw","S=2.54","L=-5.08","R=0.0","X=-2.54","Y=-1.27"),-10.08)',"MyLineTypeTextStyle"),e.drawLinetype="MyLineType3",e.drawLineWidth=0,e.drawLine(350,120,600,120),e.drawColorIndex=0,e.drawLineWidth=4,e.drawLine(350,220,600,220),e.zoomAll(),e.updateDisplay()}function FM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("ArcLayer"),e.drawLayer="ArcLayer",e.drawArc(0,1e3,100,30,200),e.addLinetype("ArcLineType","30,-5,7,-7"),e.drawLinetype="ArcLineType",e.drawColor=new te.McCmColor(255,25,0),e.drawArc(300,1e3,100,30,200),e.drawLineWidth=15,e.drawColorIndex=255,e.drawArc(600,1e3,100,30,200),e.drawArc2(800,1e3,900,1200,1e3,900),e.drawLinetype="",e.drawLineWidth=40,e.drawArc3(1200,1e3,1400,1e3,.6),e.zoomAll(),e.regen(),e.updateDisplay()}function OM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("CircleLayer"),e.drawLayer="CircleLayer",e.drawCircle(0,800,120),e.addLinetype("CircleLineType","30,-5,7,-7"),e.drawLinetype="CircleLineType",e.drawColor=new te.McCmColor(0,25,255),e.drawCircle(300,800,120),e.addLinetype("CircleLineType","30,-5,7,-7"),e.drawLinetype="CircleLineType",e.drawLineWidth=40,e.drawCircle(600,800,120),e.zoomAll(),e.regen(),e.updateDisplay()}function NM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("PolylineLayer"),e.drawLayer="PolylineLayer",e.pathMoveTo(0,300),e.pathLineTo(100,300),e.pathLineTo(100,400),e.pathLineTo(0,400),e.pathMakeClosed(),e.drawPathToPolyline(),e.pathMoveTo(200,300),e.pathLineTo(300,300),e.pathLineTo(300,400),e.pathLineTo(200,400),e.pathMakeClosed(),e.addLinetype("MyLineType3","30,-10"),e.drawLinetype="MyLineType3",e.drawColorIndex=255,e.drawLineWidth=5,e.drawPathToPolyline(),e.pathMoveTo(400,300),e.pathLineTo(500,300),e.pathLineTo(500,400),e.pathLineTo(400,400),e.pathMakeClosed(),e.drawLinetype="",e.drawColor=new te.McCmColor(0,25,255),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveTo(400,300),e.pathLineTo(500,300),e.pathLineTo(500,400),e.pathLineTo(400,400),e.pathMakeClosed(),e.drawLinetype="",e.drawColor=new te.McCmColor(255,25,0),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveTo(600,300),e.pathLineTo(700,300),e.pathLineTo(700,400),e.pathLineTo(600,400),e.drawLinetype="",e.drawColor=new te.McCmColor(0,255,0),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveTo(800,300),e.pathLineTo(900,300),e.pathLineTo(900,400),e.pathMakeClosed(),e.drawLinetype="",e.drawColor=new te.McCmColor(25,255,0),e.drawLineWidth=10,e.drawPathToPolyline(),e.pathMoveToEx(1e3,300,10,10,0),e.pathLineToEx(1e3,500,30,0,0),e.pathLineTo(1e3,580),e.drawPathToPolyline(),e.pathMoveToEx(1200,300,10,10,0),e.pathLineToEx(1200,500,30,0,0),e.pathLineTo(1200,580),e.drawColor=new te.McCmColor(25,255,0),e.drawLinetype="MyLineType3",e.drawPathToPolyline(),e.pathMoveToEx(1400,300,10,10,-.34),e.pathLineToEx(1400,500,30,0,.34),e.pathLineTo(1400,600),e.drawColor=new te.McCmColor(255,255,25),e.drawLinetype="MyLineType3",e.drawPathToPolyline(),e.zoomAll(),e.regen(),e.updateDisplay()}function UM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("HatchLayer"),e.drawLayer="HatchLayer",e.pathMoveToEx(200,3300,0,0,.3),e.pathLineTo(300,3300),e.pathLineTo(300,3400),e.pathLineTo(200,3300),e.drawColor=new te.McCmColor(25,255,0),e.drawPathToHatch(1),e.pathMoveTo(150,3300),e.pathLineTo(250,3300),e.pathLineTo(250,3400),e.pathLineTo(150,3300),e.drawColor=new te.McCmColor(255,0,0),e.drawPathToHatch(1),e.pathMoveToEx(440,3310,0,0,0),e.pathLineTo(480,3310),e.pathLineTo(480,3360),e.pathLineTo(450,3340),e.pathMakeExclude(!0),e.pathMoveToEx(400,3300,0,0,.3),e.pathLineTo(500,3300),e.pathLineTo(500,3400),e.pathLineTo(400,3300),e.drawColor=new te.McCmColor(255,25,0),e.drawPathToHatch(1),e.addPatternDefinition("MyHatchPattern1","((45, 0,0, 0,0.125))"),e.drawPatternDefinition="MyHatchPattern1",e.pathMoveToEx(600,3300,0,0,.3),e.pathLineTo(700,3300),e.pathLineTo(700,3400),e.pathLineTo(600,3300),e.drawPathToHatch(100),e.addPatternDefinition("MyHatchPattern2","((45, 0,0, 0,0.25) (45, 0.176776695,0, 0,0.25, 0.125,-0.0625))"),e.drawPatternDefinition="MyHatchPattern2",e.pathMoveToEx(800,3300,0,0,.3),e.pathLineTo(900,3300),e.pathLineTo(900,3400),e.pathLineTo(800,3300),e.drawPathToHatch(100),e.zoomAll(),e.regen(),e.updateDisplay()}function VM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.addLayer("TextLayer"),e.drawLayer="TextLayer",e.drawText(0,1900,"绘图控件文字测试",100,0,0,1),e.drawColor=new te.McCmColor(255,25,0),e.drawText(3e3,2100,"绘图控件文字测试",100,-20,2,1),e.addTextStyle("MyTextStyle","italicc.shx","gbcbig.shx",.7),e.drawTextStyle="MyTextStyle",e.drawColor=new te.McCmColor(255,0,0),e.drawText(0,3e3,"绘图控件文字测试",100,0,0,1),e.AddTureTypeTextStyle("MyTrueTypeTextStyle"),e.drawTextStyle="MyTrueTypeTextStyle",e.drawColor=new te.McCmColor(200,255,50),e.drawText(0,3500,"绘图控件TrueType文字测试",100,0,0,1),e.zoomAll(),e.regen(),e.updateDisplay()}function GM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.addLayer("LineLayer"),e.drawLayer="LineLayer",e.drawEllipse(0,1400,100,0,.7),e.addLinetype("MyEllipseType","6,-10"),e.drawLinetype="MyEllipseType",e.drawColor=new te.McCmColor(200,0,0),e.drawEllipse(200,1400,80,30,.5),e.zoomAll(),e.regen(),e.updateDisplay()}function HM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.drawLineWidth=0,e.addLayer("EllipseArcLayer"),e.drawLayer="EllipseArcLayer",e.drawEllipseArc(0,1600,80,30,.4,30,200),e.addLinetype("MyEllipseArcType","6,-10"),e.drawLinetype="MyEllipseArcType",e.drawColor=new te.McCmColor(200,200,0),e.drawEllipseArc(200,1600,-80,30,.5,60,300),e.drawLinetype="",e.zoomAll(),e.regen(),e.updateDisplay()}function WM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.addLayer("MtextLayer"),e.drawLayer="MtextLayer",e.drawTextStyle="",e.drawMText(0,-100,"控件:\\P多行文字测试",50,400,0,1),e.zoomAll(),e.regen(),e.updateDisplay()}function jM(e){if(!e||!e.param)return;let n=te.MxCpp.getCurrentMxCAD();n.newFile(),n.drawColorIndex=0,n.drawLinetype="",n.drawLineWidth=0,n.addLayer("LineLayer"),n.drawLayer="LineLayer",n.drawLine(e.param.x1,e.param.y1,e.param.x2,e.param.y2),n.zoomAll(),n.updateDisplay(),tt.MxFun.postMessageToParentFrame({cmd:"Mx_ParamDrawLine",message:"ok"})}function qM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.drawText(350831.77,1940511845e-2,"1.034",10,0,te.McDb.TextHorzMode.kTextLeft,te.McDb.TextVertMode.kTextVertMid),e.zoomAll(),e.regen(100)}function ZM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",""),e.drawDimStyle="MyDimStyle",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.drawDimAligned(0,4e3,300,4500,150,4600),e.zoomAll(),e.updateDisplay()}function XM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",""),e.drawDimStyle="MyDimStyle",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.drawDimRotated(0,7e3,600,7e3,250,7050,0),e.drawDimRotated(0,7200,0,7600,150,7300,.771),e.zoomAll(),e.updateDisplay()}function YM(){let e=te.MxCpp.getCurrentMxCAD();e.newFile(),e.addDimStyle("MyDimStyle2","41,0.18,141,0.09,40,200","77,1,271,3","",""),e.drawDimStyle="MyDimStyle2",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0,e.drawDimAngular(500,5e3,0,5500,1e3,5500,500,5500),e.zoomAll(),e.updateDisplay()}function $M(){tt.MxFun.addCommand("Mx_Test_DrawLine",BM),tt.MxFun.addCommand("Mx_Test_DrawArc",FM),tt.MxFun.addCommand("Mx_Test_DrawCircle",OM),tt.MxFun.addCommand("Mx_Test_DrawPolyline",NM),tt.MxFun.addCommand("Mx_Test_DrawHatch",UM),tt.MxFun.addCommand("Mx_Test_DrawText",VM),tt.MxFun.addCommand("Mx_Test_Ellipse",GM),tt.MxFun.addCommand("Mx_Test_EllipseArc",HM),tt.MxFun.addCommand("Mx_Test_MText",WM),tt.MxFun.addCommand("Mx_Test_Text",qM),tt.MxFun.addCommand("Mx_ParamDrawLine",jM),tt.MxFun.addCommand("Mx_Test_DimAligned",ZM),tt.MxFun.addCommand("Mx_Test_DrawDimRotated",XM),tt.MxFun.addCommand("Mx_Test_DrawDimAngular",YM)}Number.EPSILON===void 0&&(Number.EPSILON=Math.pow(2,-52)),Number.isInteger===void 0&&(Number.isInteger=function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e}),Math.sign===void 0&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),"name"in Function.prototype||Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),Object.assign===void 0&&(Object.assign=function(e){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),i=1;i<arguments.length;i++){var l=arguments[i];if(l!=null)for(var h in l)Object.prototype.hasOwnProperty.call(l,h)&&(n[h]=l[h])}return n});var JM="113",KM=0,n0=1,QM=2,i0=1,eT=2,ih=3,Jl=0,tr=1,rh=2,r0=1,a0=0,tT=1,Kl=2,Qo=0,ah=1,o0=2,s0=3,l0=4,nT=5,Ql=100,iT=101,rT=102,c0=103,u0=104,aT=200,oT=201,sT=202,lT=203,h0=204,d0=205,cT=206,uT=207,hT=208,dT=209,pT=210,fT=0,mT=1,gT=2,Gg=3,_T=4,yT=5,vT=6,xT=7,Up=0,bT=1,wT=2,Vp=0,Hg=1,MT=2,TT=3,ET=4,ST=5,Wg=300,jg=301,qg=302,p0=303,Zg=304,f0=305,oh=306,Xg=307,Zs=1e3,wr=1001,sh=1002,Ui=1003,Gp=1004,Hp=1005,qi=1006,Yg=1007,ec=1008,Wp=1009,AT=1010,CT=1011,jp=1012,PT=1013,m0=1014,lh=1015,$g=1016,LT=1017,DT=1018,IT=1019,qp=1020,RT=1021,Mo=1022,Aa=1023,zT=1024,kT=1025,BT=Aa,tc=1026,ch=1027,FT=1028,OT=1029,NT=1030,UT=1031,VT=1032,GT=1033,g0=33776,_0=33777,y0=33778,v0=33779,x0=35840,b0=35841,w0=35842,M0=35843,HT=36196,WT=37808,jT=37809,qT=37810,ZT=37811,XT=37812,YT=37813,$T=37814,JT=37815,KT=37816,QT=37817,e2=37818,t2=37819,n2=37820,i2=37821,r2=2200,a2=2201,o2=2202,uh=2300,nc=2301,Jg=2302,ic=2400,rc=2401,Zp=2402,s2=0,l2=1,T0=2,ia=3e3,hh=3001,E0=3007,Kg=3002,c2=3003,S0=3004,A0=3005,C0=3006,u2=3200,h2=3201,Xs=0,d2=1,Qg=7680,p2=519,Xp=35044,dh=35048;function To(){}Object.assign(To.prototype,{addEventListener:function(e,n){this._listeners===void 0&&(this._listeners={});var i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(n)===-1&&i[e].push(n)},hasEventListener:function(e,n){if(this._listeners===void 0)return!1;var i=this._listeners;return i[e]!==void 0&&i[e].indexOf(n)!==-1},removeEventListener:function(e,n){if(this._listeners!==void 0){var i=this._listeners,l=i[e];if(l!==void 0){var h=l.indexOf(n);h!==-1&&l.splice(h,1)}}},dispatchEvent:function(e){if(this._listeners!==void 0){var n=this._listeners,i=n[e.type];if(i!==void 0){e.target=this;for(var l=i.slice(0),h=0,p=l.length;h<p;h++)l[h].call(this,e)}}}});for(var or=[],ph=0;ph<256;ph++)or[ph]=(ph<16?"0":"")+ph.toString(16);var Wn={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0,l=Math.random()*4294967295|0,h=or[e&255]+or[e>>8&255]+or[e>>16&255]+or[e>>24&255]+"-"+or[n&255]+or[n>>8&255]+"-"+or[n>>16&15|64]+or[n>>24&255]+"-"+or[i&63|128]+or[i>>8&255]+"-"+or[i>>16&255]+or[i>>24&255]+or[l&255]+or[l>>8&255]+or[l>>16&255]+or[l>>24&255];return h.toUpperCase()},clamp:function(e,n,i){return Math.max(n,Math.min(i,e))},euclideanModulo:function(e,n){return(e%n+n)%n},mapLinear:function(e,n,i,l,h){return l+(e-n)*(h-l)/(i-n)},lerp:function(e,n,i){return(1-i)*e+i*n},smoothstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n),e*e*(3-2*e))},smootherstep:function(e,n,i){return e<=n?0:e>=i?1:(e=(e-n)/(i-n),e*e*e*(e*(e*6-15)+10))},randInt:function(e,n){return e+Math.floor(Math.random()*(n-e+1))},randFloat:function(e,n){return e+Math.random()*(n-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*Wn.DEG2RAD},radToDeg:function(e){return e*Wn.RAD2DEG},isPowerOfTwo:function(e){return(e&e-1)===0&&e!==0},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,n,i,l,h){var p=Math.cos,_=Math.sin,s=p(i/2),M=_(i/2),T=p((n+l)/2),C=_((n+l)/2),E=p((n-l)/2),L=_((n-l)/2),I=p((l-n)/2),B=_((l-n)/2);h==="XYX"?e.set(s*C,M*E,M*L,s*T):h==="YZY"?e.set(M*L,s*C,M*E,s*T):h==="ZXZ"?e.set(M*E,M*L,s*C,s*T):h==="XZX"?e.set(s*C,M*B,M*I,s*T):h==="YXY"?e.set(M*I,s*C,M*B,s*T):h==="ZYZ"?e.set(M*B,M*I,s*C,s*T):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}};function Lt(e,n){this.x=e||0,this.y=n||0}Object.defineProperties(Lt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(Lt.prototype,{isVector2:!0,set:function(e,n){return this.x=e,this.y=n,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,n){return n!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this},addScaledVector:function(e,n){return this.x+=e.x*n,this.y+=e.y*n,this},sub:function(e,n){return n!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var n=this.x,i=this.y,l=e.elements;return this.x=l[0]*n+l[3]*i+l[6],this.y=l[1]*n+l[4]*i+l[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this},clampScalar:function(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this},clampLength:function(e,n){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var n=this.x-e.x,i=this.y-e.y;return n*n+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this},lerpVectors:function(e,n,i){return this.subVectors(n,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,n){return n===void 0&&(n=0),this.x=e[n],this.y=e[n+1],this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this.x,e[n+1]=this.y,e},fromBufferAttribute:function(e,n,i){return i!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this},rotateAround:function(e,n){var i=Math.cos(n),l=Math.sin(n),h=this.x-e.x,p=this.y-e.y;return this.x=h*i-p*l+e.x,this.y=h*l+p*i+e.y,this}});function dr(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.assign(dr.prototype,{isMatrix3:!0,set:function(e,n,i,l,h,p,_,s,M){var T=this.elements;return T[0]=e,T[1]=l,T[2]=_,T[3]=n,T[4]=h,T[5]=s,T[6]=i,T[7]=p,T[8]=M,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return new this.constructor().fromArray(this.elements)},copy:function(e){var n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this},setFromMatrix4:function(e){var n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,n){var i=e.elements,l=n.elements,h=this.elements,p=i[0],_=i[3],s=i[6],M=i[1],T=i[4],C=i[7],E=i[2],L=i[5],I=i[8],B=l[0],O=l[3],U=l[6],q=l[1],ee=l[4],he=l[7],Ce=l[2],K=l[5],ie=l[8];return h[0]=p*B+_*q+s*Ce,h[3]=p*O+_*ee+s*K,h[6]=p*U+_*he+s*ie,h[1]=M*B+T*q+C*Ce,h[4]=M*O+T*ee+C*K,h[7]=M*U+T*he+C*ie,h[2]=E*B+L*q+I*Ce,h[5]=E*O+L*ee+I*K,h[8]=E*U+L*he+I*ie,this},multiplyScalar:function(e){var n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this},determinant:function(){var e=this.elements,n=e[0],i=e[1],l=e[2],h=e[3],p=e[4],_=e[5],s=e[6],M=e[7],T=e[8];return n*p*T-n*_*M-i*h*T+i*_*s+l*h*M-l*p*s},getInverse:function(e,n){e&&e.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=e.elements,l=this.elements,h=i[0],p=i[1],_=i[2],s=i[3],M=i[4],T=i[5],C=i[6],E=i[7],L=i[8],I=L*M-T*E,B=T*C-L*s,O=E*s-M*C,U=h*I+p*B+_*O;if(U===0){var q="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(n===!0)throw new Error(q);return console.warn(q),this.identity()}var ee=1/U;return l[0]=I*ee,l[1]=(_*E-L*p)*ee,l[2]=(T*p-_*M)*ee,l[3]=B*ee,l[4]=(L*h-_*C)*ee,l[5]=(_*s-T*h)*ee,l[6]=O*ee,l[7]=(p*C-E*h)*ee,l[8]=(M*h-p*s)*ee,this},transpose:function(){var e,n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this},setUvTransform:function(e,n,i,l,h,p,_){var s=Math.cos(h),M=Math.sin(h);this.set(i*s,i*M,-i*(s*p+M*_)+p+e,-l*M,l*s,-l*(-M*p+s*_)+_+n,0,0,1)},scale:function(e,n){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=n,i[4]*=n,i[7]*=n,this},rotate:function(e){var n=Math.cos(e),i=Math.sin(e),l=this.elements,h=l[0],p=l[3],_=l[6],s=l[1],M=l[4],T=l[7];return l[0]=n*h+i*s,l[3]=n*p+i*M,l[6]=n*_+i*T,l[1]=-i*h+n*s,l[4]=-i*p+n*M,l[7]=-i*_+n*T,this},translate:function(e,n){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=n*i[2],i[4]+=n*i[5],i[7]+=n*i[8],this},equals:function(e){for(var n=this.elements,i=e.elements,l=0;l<9;l++)if(n[l]!==i[l])return!1;return!0},fromArray:function(e,n){n===void 0&&(n=0);for(var i=0;i<9;i++)this.elements[i]=e[i+n];return this},toArray:function(e,n){e===void 0&&(e=[]),n===void 0&&(n=0);var i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}});var ac,Ys={getDataURL:function(e){var n;if(typeof HTMLCanvasElement=="undefined")return e.src;if(e instanceof HTMLCanvasElement)n=e;else{ac===void 0&&(ac=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),ac.width=e.width,ac.height=e.height;var i=ac.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=ac}return n.width>2048||n.height>2048?n.toDataURL("image/jpeg",.6):n.toDataURL("image/png")}},f2=0;function mi(e,n,i,l,h,p,_,s,M,T){Object.defineProperty(this,"id",{value:f2++}),this.uuid=Wn.generateUUID(),this.name="",this.image=e!==void 0?e:mi.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=n!==void 0?n:mi.DEFAULT_MAPPING,this.wrapS=i!==void 0?i:wr,this.wrapT=l!==void 0?l:wr,this.magFilter=h!==void 0?h:qi,this.minFilter=p!==void 0?p:ec,this.anisotropy=M!==void 0?M:1,this.format=_!==void 0?_:Aa,this.internalFormat=null,this.type=s!==void 0?s:Wp,this.offset=new Lt(0,0),this.repeat=new Lt(1,1),this.center=new Lt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=T!==void 0?T:ia,this.version=0,this.onUpdate=null}mi.DEFAULT_IMAGE=void 0,mi.DEFAULT_MAPPING=Wg,mi.prototype=Object.assign(Object.create(To.prototype),{constructor:mi,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){var l=this.image;if(l.uuid===void 0&&(l.uuid=Wn.generateUUID()),!n&&e.images[l.uuid]===void 0){var h;if(Array.isArray(l)){h=[];for(var p=0,_=l.length;p<_;p++)h.push(Ys.getDataURL(l[p]))}else h=Ys.getDataURL(l);e.images[l.uuid]={uuid:l.uuid,url:h}}i.image=l.uuid}return n||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==Wg)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zs:e.x=e.x-Math.floor(e.x);break;case wr:e.x=e.x<0?0:1;break;case sh:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Zs:e.y=e.y-Math.floor(e.y);break;case wr:e.y=e.y<0?0:1;break;case sh:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(mi.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function gi(e,n,i,l){this.x=e||0,this.y=n||0,this.z=i||0,this.w=l!==void 0?l:1}Object.defineProperties(gi.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(gi.prototype,{isVector4:!0,set:function(e,n,i,l){return this.x=e,this.y=n,this.z=i,this.w=l,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this},add:function(e,n){return n!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this},addScaledVector:function(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this},sub:function(e,n){return n!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var n=this.x,i=this.y,l=this.z,h=this.w,p=e.elements;return this.x=p[0]*n+p[4]*i+p[8]*l+p[12]*h,this.y=p[1]*n+p[5]*i+p[9]*l+p[13]*h,this.z=p[2]*n+p[6]*i+p[10]*l+p[14]*h,this.w=p[3]*n+p[7]*i+p[11]*l+p[15]*h,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this},setAxisAngleFromRotationMatrix:function(e){var n,i,l,h,p=.01,_=.1,s=e.elements,M=s[0],T=s[4],C=s[8],E=s[1],L=s[5],I=s[9],B=s[2],O=s[6],U=s[10];if(Math.abs(T-E)<p&&Math.abs(C-B)<p&&Math.abs(I-O)<p){if(Math.abs(T+E)<_&&Math.abs(C+B)<_&&Math.abs(I+O)<_&&Math.abs(M+L+U-3)<_)return this.set(1,0,0,0),this;n=Math.PI;var q=(M+1)/2,ee=(L+1)/2,he=(U+1)/2,Ce=(T+E)/4,K=(C+B)/4,ie=(I+O)/4;return q>ee&&q>he?q<p?(i=0,l=.707106781,h=.707106781):(i=Math.sqrt(q),l=Ce/i,h=K/i):ee>he?ee<p?(i=.707106781,l=0,h=.707106781):(l=Math.sqrt(ee),i=Ce/l,h=ie/l):he<p?(i=.707106781,l=.707106781,h=0):(h=Math.sqrt(he),i=K/h,l=ie/h),this.set(i,l,h,n),this}var ue=Math.sqrt((O-I)*(O-I)+(C-B)*(C-B)+(E-T)*(E-T));return Math.abs(ue)<.001&&(ue=1),this.x=(O-I)/ue,this.y=(C-B)/ue,this.z=(E-T)/ue,this.w=Math.acos((M+L+U-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this},clampScalar:function(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this},clampLength:function(e,n){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this},lerpVectors:function(e,n,i){return this.subVectors(n,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,n){return n===void 0&&(n=0),this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e},fromBufferAttribute:function(e,n,i){return i!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}});function Mr(e,n,i){this.width=e,this.height=n,this.scissor=new gi(0,0,e,n),this.scissorTest=!1,this.viewport=new gi(0,0,e,n),i=i||{},this.texture=new mi(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=n,this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:qi,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!0,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null}Mr.prototype=Object.assign(Object.create(To.prototype),{constructor:Mr,isWebGLRenderTarget:!0,setSize:function(e,n){(this.width!==e||this.height!==n)&&(this.width=e,this.height=n,this.texture.image.width=e,this.texture.image.height=n,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});function P0(e,n,i){Mr.call(this,e,n,i),this.samples=4}P0.prototype=Object.assign(Object.create(Mr.prototype),{constructor:P0,isWebGLMultisampleRenderTarget:!0,copy:function(e){return Mr.prototype.copy.call(this,e),this.samples=e.samples,this}});function Or(e,n,i,l){this._x=e||0,this._y=n||0,this._z=i||0,this._w=l!==void 0?l:1}Object.assign(Or,{slerp:function(e,n,i,l){return i.copy(e).slerp(n,l)},slerpFlat:function(e,n,i,l,h,p,_){var s=i[l+0],M=i[l+1],T=i[l+2],C=i[l+3],E=h[p+0],L=h[p+1],I=h[p+2],B=h[p+3];if(C!==B||s!==E||M!==L||T!==I){var O=1-_,U=s*E+M*L+T*I+C*B,q=U>=0?1:-1,ee=1-U*U;if(ee>Number.EPSILON){var he=Math.sqrt(ee),Ce=Math.atan2(he,U*q);O=Math.sin(O*Ce)/he,_=Math.sin(_*Ce)/he}var K=_*q;if(s=s*O+E*K,M=M*O+L*K,T=T*O+I*K,C=C*O+B*K,O===1-_){var ie=1/Math.sqrt(s*s+M*M+T*T+C*C);s*=ie,M*=ie,T*=ie,C*=ie}}e[n]=s,e[n+1]=M,e[n+2]=T,e[n+3]=C}}),Object.defineProperties(Or.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(Or.prototype,{isQuaternion:!0,set:function(e,n,i,l){return this._x=e,this._y=n,this._z=i,this._w=l,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,n){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,l=e._y,h=e._z,p=e.order,_=Math.cos,s=Math.sin,M=_(i/2),T=_(l/2),C=_(h/2),E=s(i/2),L=s(l/2),I=s(h/2);return p==="XYZ"?(this._x=E*T*C+M*L*I,this._y=M*L*C-E*T*I,this._z=M*T*I+E*L*C,this._w=M*T*C-E*L*I):p==="YXZ"?(this._x=E*T*C+M*L*I,this._y=M*L*C-E*T*I,this._z=M*T*I-E*L*C,this._w=M*T*C+E*L*I):p==="ZXY"?(this._x=E*T*C-M*L*I,this._y=M*L*C+E*T*I,this._z=M*T*I+E*L*C,this._w=M*T*C-E*L*I):p==="ZYX"?(this._x=E*T*C-M*L*I,this._y=M*L*C+E*T*I,this._z=M*T*I-E*L*C,this._w=M*T*C+E*L*I):p==="YZX"?(this._x=E*T*C+M*L*I,this._y=M*L*C+E*T*I,this._z=M*T*I-E*L*C,this._w=M*T*C-E*L*I):p==="XZY"&&(this._x=E*T*C-M*L*I,this._y=M*L*C-E*T*I,this._z=M*T*I+E*L*C,this._w=M*T*C+E*L*I),n!==!1&&this._onChangeCallback(),this},setFromAxisAngle:function(e,n){var i=n/2,l=Math.sin(i);return this._x=e.x*l,this._y=e.y*l,this._z=e.z*l,this._w=Math.cos(i),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var n=e.elements,i=n[0],l=n[4],h=n[8],p=n[1],_=n[5],s=n[9],M=n[2],T=n[6],C=n[10],E=i+_+C,L;return E>0?(L=.5/Math.sqrt(E+1),this._w=.25/L,this._x=(T-s)*L,this._y=(h-M)*L,this._z=(p-l)*L):i>_&&i>C?(L=2*Math.sqrt(1+i-_-C),this._w=(T-s)/L,this._x=.25*L,this._y=(l+p)/L,this._z=(h+M)/L):_>C?(L=2*Math.sqrt(1+_-i-C),this._w=(h-M)/L,this._x=(l+p)/L,this._y=.25*L,this._z=(s+T)/L):(L=2*Math.sqrt(1+C-i-_),this._w=(p-l)/L,this._x=(h+M)/L,this._y=(s+T)/L,this._z=.25*L),this._onChangeCallback(),this},setFromUnitVectors:function(e,n){var i=1e-6,l=e.dot(n)+1;return l<i?(l=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=l):(this._x=0,this._y=-e.z,this._z=e.y,this._w=l)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=l),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(Wn.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,n){var i=this.angleTo(e);if(i===0)return this;var l=Math.min(1,n/i);return this.slerp(e,l),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},multiply:function(e,n){return n!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,n)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,n){var i=e._x,l=e._y,h=e._z,p=e._w,_=n._x,s=n._y,M=n._z,T=n._w;return this._x=i*T+p*_+l*M-h*s,this._y=l*T+p*s+h*_-i*M,this._z=h*T+p*M+i*s-l*_,this._w=p*T-i*_-l*s-h*M,this._onChangeCallback(),this},slerp:function(e,n){if(n===0)return this;if(n===1)return this.copy(e);var i=this._x,l=this._y,h=this._z,p=this._w,_=p*e._w+i*e._x+l*e._y+h*e._z;if(_<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,_=-_):this.copy(e),_>=1)return this._w=p,this._x=i,this._y=l,this._z=h,this;var s=1-_*_;if(s<=Number.EPSILON){var M=1-n;return this._w=M*p+n*this._w,this._x=M*i+n*this._x,this._y=M*l+n*this._y,this._z=M*h+n*this._z,this.normalize(),this._onChangeCallback(),this}var T=Math.sqrt(s),C=Math.atan2(T,_),E=Math.sin((1-n)*C)/T,L=Math.sin(n*C)/T;return this._w=p*E+this._w*L,this._x=i*E+this._x*L,this._y=l*E+this._y*L,this._z=h*E+this._z*L,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,n){return n===void 0&&(n=0),this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var e_=new Ee,L0=new Or;function Ee(e,n,i){this.x=e||0,this.y=n||0,this.z=i||0}Object.assign(Ee.prototype,{isVector3:!0,set:function(e,n,i){return this.x=e,this.y=n,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this},addScaledVector:function(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this},sub:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this},multiply:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,n)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(L0.setFromEuler(e))},applyAxisAngle:function(e,n){return this.applyQuaternion(L0.setFromAxisAngle(e,n))},applyMatrix3:function(e){var n=this.x,i=this.y,l=this.z,h=e.elements;return this.x=h[0]*n+h[3]*i+h[6]*l,this.y=h[1]*n+h[4]*i+h[7]*l,this.z=h[2]*n+h[5]*i+h[8]*l,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var n=this.x,i=this.y,l=this.z,h=e.elements,p=1/(h[3]*n+h[7]*i+h[11]*l+h[15]);return this.x=(h[0]*n+h[4]*i+h[8]*l+h[12])*p,this.y=(h[1]*n+h[5]*i+h[9]*l+h[13])*p,this.z=(h[2]*n+h[6]*i+h[10]*l+h[14])*p,this},applyQuaternion:function(e){var n=this.x,i=this.y,l=this.z,h=e.x,p=e.y,_=e.z,s=e.w,M=s*n+p*l-_*i,T=s*i+_*n-h*l,C=s*l+h*i-p*n,E=-h*n-p*i-_*l;return this.x=M*s+E*-h+T*-_-C*-p,this.y=T*s+E*-p+C*-h-M*-_,this.z=C*s+E*-_+M*-p-T*-h,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var n=this.x,i=this.y,l=this.z,h=e.elements;return this.x=h[0]*n+h[4]*i+h[8]*l,this.y=h[1]*n+h[5]*i+h[9]*l,this.z=h[2]*n+h[6]*i+h[10]*l,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this},clampScalar:function(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this},clampLength:function(e,n){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this},lerpVectors:function(e,n,i){return this.subVectors(n,e).multiplyScalar(i).add(e)},cross:function(e,n){return n!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,n)):this.crossVectors(this,e)},crossVectors:function(e,n){var i=e.x,l=e.y,h=e.z,p=n.x,_=n.y,s=n.z;return this.x=l*s-h*_,this.y=h*p-i*s,this.z=i*_-l*p,this},projectOnVector:function(e){var n=e.lengthSq();if(n===0)return this.set(0,0,0);var i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)},projectOnPlane:function(e){return e_.copy(this).projectOnVector(e),this.sub(e_)},reflect:function(e){return this.sub(e_.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;var i=this.dot(e)/n;return Math.acos(Wn.clamp(i,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var n=this.x-e.x,i=this.y-e.y,l=this.z-e.z;return n*n+i*i+l*l},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,n,i){var l=Math.sin(n)*e;return this.x=l*Math.sin(i),this.y=Math.cos(n)*e,this.z=l*Math.cos(i),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,n,i){return this.x=e*Math.sin(n),this.y=i,this.z=e*Math.cos(n),this},setFromMatrixPosition:function(e){var n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this},setFromMatrixScale:function(e){var n=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=l,this},setFromMatrixColumn:function(e,n){return this.fromArray(e.elements,n*4)},setFromMatrix3Column:function(e,n){return this.fromArray(e.elements,n*3)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,n){return n===void 0&&(n=0),this.x=e[n],this.y=e[n+1],this.z=e[n+2],this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e},fromBufferAttribute:function(e,n,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}});var oc=new Ee,Ca=new jn,m2=new Ee(0,0,0),g2=new Ee(1,1,1),es=new Ee,Yp=new Ee,ra=new Ee;function jn(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(jn.prototype,{isMatrix4:!0,set:function(e,n,i,l,h,p,_,s,M,T,C,E,L,I,B,O){var U=this.elements;return U[0]=e,U[4]=n,U[8]=i,U[12]=l,U[1]=h,U[5]=p,U[9]=_,U[13]=s,U[2]=M,U[6]=T,U[10]=C,U[14]=E,U[3]=L,U[7]=I,U[11]=B,U[15]=O,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return new jn().fromArray(this.elements)},copy:function(e){var n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this},copyPosition:function(e){var n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this},extractBasis:function(e,n,i){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this},extractRotation:function(e){var n=this.elements,i=e.elements,l=1/oc.setFromMatrixColumn(e,0).length(),h=1/oc.setFromMatrixColumn(e,1).length(),p=1/oc.setFromMatrixColumn(e,2).length();return n[0]=i[0]*l,n[1]=i[1]*l,n[2]=i[2]*l,n[3]=0,n[4]=i[4]*h,n[5]=i[5]*h,n[6]=i[6]*h,n[7]=0,n[8]=i[8]*p,n[9]=i[9]*p,n[10]=i[10]*p,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var n=this.elements,i=e.x,l=e.y,h=e.z,p=Math.cos(i),_=Math.sin(i),s=Math.cos(l),M=Math.sin(l),T=Math.cos(h),C=Math.sin(h);if(e.order==="XYZ"){var E=p*T,L=p*C,I=_*T,B=_*C;n[0]=s*T,n[4]=-s*C,n[8]=M,n[1]=L+I*M,n[5]=E-B*M,n[9]=-_*s,n[2]=B-E*M,n[6]=I+L*M,n[10]=p*s}else if(e.order==="YXZ"){var O=s*T,U=s*C,q=M*T,ee=M*C;n[0]=O+ee*_,n[4]=q*_-U,n[8]=p*M,n[1]=p*C,n[5]=p*T,n[9]=-_,n[2]=U*_-q,n[6]=ee+O*_,n[10]=p*s}else if(e.order==="ZXY"){var O=s*T,U=s*C,q=M*T,ee=M*C;n[0]=O-ee*_,n[4]=-p*C,n[8]=q+U*_,n[1]=U+q*_,n[5]=p*T,n[9]=ee-O*_,n[2]=-p*M,n[6]=_,n[10]=p*s}else if(e.order==="ZYX"){var E=p*T,L=p*C,I=_*T,B=_*C;n[0]=s*T,n[4]=I*M-L,n[8]=E*M+B,n[1]=s*C,n[5]=B*M+E,n[9]=L*M-I,n[2]=-M,n[6]=_*s,n[10]=p*s}else if(e.order==="YZX"){var he=p*s,Ce=p*M,K=_*s,ie=_*M;n[0]=s*T,n[4]=ie-he*C,n[8]=K*C+Ce,n[1]=C,n[5]=p*T,n[9]=-_*T,n[2]=-M*T,n[6]=Ce*C+K,n[10]=he-ie*C}else if(e.order==="XZY"){var he=p*s,Ce=p*M,K=_*s,ie=_*M;n[0]=s*T,n[4]=-C,n[8]=M*T,n[1]=he*C+ie,n[5]=p*T,n[9]=Ce*C-K,n[2]=K*C-Ce,n[6]=_*T,n[10]=ie*C+he}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(m2,e,g2)},lookAt:function(e,n,i){var l=this.elements;return ra.subVectors(e,n),ra.lengthSq()===0&&(ra.z=1),ra.normalize(),es.crossVectors(i,ra),es.lengthSq()===0&&(Math.abs(i.z)===1?ra.x+=1e-4:ra.z+=1e-4,ra.normalize(),es.crossVectors(i,ra)),es.normalize(),Yp.crossVectors(ra,es),l[0]=es.x,l[4]=Yp.x,l[8]=ra.x,l[1]=es.y,l[5]=Yp.y,l[9]=ra.y,l[2]=es.z,l[6]=Yp.z,l[10]=ra.z,this},multiply:function(e,n){return n!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,n)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,n){var i=e.elements,l=n.elements,h=this.elements,p=i[0],_=i[4],s=i[8],M=i[12],T=i[1],C=i[5],E=i[9],L=i[13],I=i[2],B=i[6],O=i[10],U=i[14],q=i[3],ee=i[7],he=i[11],Ce=i[15],K=l[0],ie=l[4],ue=l[8],ae=l[12],le=l[1],De=l[5],ye=l[9],se=l[13],Ue=l[2],Oe=l[6],We=l[10],st=l[14],St=l[3],gt=l[7],At=l[11],Dt=l[15];return h[0]=p*K+_*le+s*Ue+M*St,h[4]=p*ie+_*De+s*Oe+M*gt,h[8]=p*ue+_*ye+s*We+M*At,h[12]=p*ae+_*se+s*st+M*Dt,h[1]=T*K+C*le+E*Ue+L*St,h[5]=T*ie+C*De+E*Oe+L*gt,h[9]=T*ue+C*ye+E*We+L*At,h[13]=T*ae+C*se+E*st+L*Dt,h[2]=I*K+B*le+O*Ue+U*St,h[6]=I*ie+B*De+O*Oe+U*gt,h[10]=I*ue+B*ye+O*We+U*At,h[14]=I*ae+B*se+O*st+U*Dt,h[3]=q*K+ee*le+he*Ue+Ce*St,h[7]=q*ie+ee*De+he*Oe+Ce*gt,h[11]=q*ue+ee*ye+he*We+Ce*At,h[15]=q*ae+ee*se+he*st+Ce*Dt,this},multiplyScalar:function(e){var n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this},determinant:function(){var e=this.elements,n=e[0],i=e[4],l=e[8],h=e[12],p=e[1],_=e[5],s=e[9],M=e[13],T=e[2],C=e[6],E=e[10],L=e[14],I=e[3],B=e[7],O=e[11],U=e[15];return I*(+h*s*C-l*M*C-h*_*E+i*M*E+l*_*L-i*s*L)+B*(+n*s*L-n*M*E+h*p*E-l*p*L+l*M*T-h*s*T)+O*(+n*M*C-n*_*L-h*p*C+i*p*L+h*_*T-i*M*T)+U*(-l*_*T-n*s*C+n*_*E+l*p*C-i*p*E+i*s*T)},transpose:function(){var e=this.elements,n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this},setPosition:function(e,n,i){var l=this.elements;return e.isVector3?(l[12]=e.x,l[13]=e.y,l[14]=e.z):(l[12]=e,l[13]=n,l[14]=i),this},getInverse:function(e,n){var i=this.elements,l=e.elements,h=l[0],p=l[1],_=l[2],s=l[3],M=l[4],T=l[5],C=l[6],E=l[7],L=l[8],I=l[9],B=l[10],O=l[11],U=l[12],q=l[13],ee=l[14],he=l[15],Ce=I*ee*E-q*B*E+q*C*O-T*ee*O-I*C*he+T*B*he,K=U*B*E-L*ee*E-U*C*O+M*ee*O+L*C*he-M*B*he,ie=L*q*E-U*I*E+U*T*O-M*q*O-L*T*he+M*I*he,ue=U*I*C-L*q*C-U*T*B+M*q*B+L*T*ee-M*I*ee,ae=h*Ce+p*K+_*ie+s*ue;if(ae===0){var le="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(n===!0)throw new Error(le);return console.warn(le),this.identity()}var De=1/ae;return i[0]=Ce*De,i[1]=(q*B*s-I*ee*s-q*_*O+p*ee*O+I*_*he-p*B*he)*De,i[2]=(T*ee*s-q*C*s+q*_*E-p*ee*E-T*_*he+p*C*he)*De,i[3]=(I*C*s-T*B*s-I*_*E+p*B*E+T*_*O-p*C*O)*De,i[4]=K*De,i[5]=(L*ee*s-U*B*s+U*_*O-h*ee*O-L*_*he+h*B*he)*De,i[6]=(U*C*s-M*ee*s-U*_*E+h*ee*E+M*_*he-h*C*he)*De,i[7]=(M*B*s-L*C*s+L*_*E-h*B*E-M*_*O+h*C*O)*De,i[8]=ie*De,i[9]=(U*I*s-L*q*s-U*p*O+h*q*O+L*p*he-h*I*he)*De,i[10]=(M*q*s-U*T*s+U*p*E-h*q*E-M*p*he+h*T*he)*De,i[11]=(L*T*s-M*I*s-L*p*E+h*I*E+M*p*O-h*T*O)*De,i[12]=ue*De,i[13]=(L*q*_-U*I*_+U*p*B-h*q*B-L*p*ee+h*I*ee)*De,i[14]=(U*T*_-M*q*_-U*p*C+h*q*C+M*p*ee-h*T*ee)*De,i[15]=(M*I*_-L*T*_+L*p*C-h*I*C-M*p*B+h*T*B)*De,this},scale:function(e){var n=this.elements,i=e.x,l=e.y,h=e.z;return n[0]*=i,n[4]*=l,n[8]*=h,n[1]*=i,n[5]*=l,n[9]*=h,n[2]*=i,n[6]*=l,n[10]*=h,n[3]*=i,n[7]*=l,n[11]*=h,this},getMaxScaleOnAxis:function(){var e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],l=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,l))},makeTranslation:function(e,n,i){return this.set(1,0,0,e,0,1,0,n,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this},makeRotationY:function(e){var n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this},makeRotationZ:function(e){var n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,n){var i=Math.cos(n),l=Math.sin(n),h=1-i,p=e.x,_=e.y,s=e.z,M=h*p,T=h*_;return this.set(M*p+i,M*_-l*s,M*s+l*_,0,M*_+l*s,T*_+i,T*s-l*p,0,M*s-l*_,T*s+l*p,h*s*s+i,0,0,0,0,1),this},makeScale:function(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,n,i){return this.set(1,n,i,0,e,1,i,0,e,n,1,0,0,0,0,1),this},compose:function(e,n,i){var l=this.elements,h=n._x,p=n._y,_=n._z,s=n._w,M=h+h,T=p+p,C=_+_,E=h*M,L=h*T,I=h*C,B=p*T,O=p*C,U=_*C,q=s*M,ee=s*T,he=s*C,Ce=i.x,K=i.y,ie=i.z;return l[0]=(1-(B+U))*Ce,l[1]=(L+he)*Ce,l[2]=(I-ee)*Ce,l[3]=0,l[4]=(L-he)*K,l[5]=(1-(E+U))*K,l[6]=(O+q)*K,l[7]=0,l[8]=(I+ee)*ie,l[9]=(O-q)*ie,l[10]=(1-(E+B))*ie,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this},decompose:function(e,n,i){var l=this.elements,h=oc.set(l[0],l[1],l[2]).length(),p=oc.set(l[4],l[5],l[6]).length(),_=oc.set(l[8],l[9],l[10]).length(),s=this.determinant();s<0&&(h=-h),e.x=l[12],e.y=l[13],e.z=l[14],Ca.copy(this);var M=1/h,T=1/p,C=1/_;return Ca.elements[0]*=M,Ca.elements[1]*=M,Ca.elements[2]*=M,Ca.elements[4]*=T,Ca.elements[5]*=T,Ca.elements[6]*=T,Ca.elements[8]*=C,Ca.elements[9]*=C,Ca.elements[10]*=C,n.setFromRotationMatrix(Ca),i.x=h,i.y=p,i.z=_,this},makePerspective:function(e,n,i,l,h,p){p===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var _=this.elements,s=2*h/(n-e),M=2*h/(i-l),T=(n+e)/(n-e),C=(i+l)/(i-l),E=-(p+h)/(p-h),L=-2*p*h/(p-h);return _[0]=s,_[4]=0,_[8]=T,_[12]=0,_[1]=0,_[5]=M,_[9]=C,_[13]=0,_[2]=0,_[6]=0,_[10]=E,_[14]=L,_[3]=0,_[7]=0,_[11]=-1,_[15]=0,this},makeOrthographic:function(e,n,i,l,h,p){var _=this.elements,s=1/(n-e),M=1/(i-l),T=1/(p-h),C=(n+e)*s,E=(i+l)*M,L=(p+h)*T;return _[0]=2*s,_[4]=0,_[8]=0,_[12]=-C,_[1]=0,_[5]=2*M,_[9]=0,_[13]=-E,_[2]=0,_[6]=0,_[10]=-2*T,_[14]=-L,_[3]=0,_[7]=0,_[11]=0,_[15]=1,this},equals:function(e){for(var n=this.elements,i=e.elements,l=0;l<16;l++)if(n[l]!==i[l])return!1;return!0},fromArray:function(e,n){n===void 0&&(n=0);for(var i=0;i<16;i++)this.elements[i]=e[i+n];return this},toArray:function(e,n){e===void 0&&(e=[]),n===void 0&&(n=0);var i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}});var D0=new jn,I0=new Or;function sc(e,n,i,l){this._x=e||0,this._y=n||0,this._z=i||0,this._order=l||sc.DefaultOrder}sc.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],sc.DefaultOrder="XYZ",Object.defineProperties(sc.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this._onChangeCallback()}}}),Object.assign(sc.prototype,{isEuler:!0,set:function(e,n,i,l){return this._x=e,this._y=n,this._z=i,this._order=l||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this},setFromRotationMatrix:function(e,n,i){var l=Wn.clamp,h=e.elements,p=h[0],_=h[4],s=h[8],M=h[1],T=h[5],C=h[9],E=h[2],L=h[6],I=h[10];return n=n||this._order,n==="XYZ"?(this._y=Math.asin(l(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-C,I),this._z=Math.atan2(-_,p)):(this._x=Math.atan2(L,T),this._z=0)):n==="YXZ"?(this._x=Math.asin(-l(C,-1,1)),Math.abs(C)<.9999999?(this._y=Math.atan2(s,I),this._z=Math.atan2(M,T)):(this._y=Math.atan2(-E,p),this._z=0)):n==="ZXY"?(this._x=Math.asin(l(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-E,I),this._z=Math.atan2(-_,T)):(this._y=0,this._z=Math.atan2(M,p))):n==="ZYX"?(this._y=Math.asin(-l(E,-1,1)),Math.abs(E)<.9999999?(this._x=Math.atan2(L,I),this._z=Math.atan2(M,p)):(this._x=0,this._z=Math.atan2(-_,T))):n==="YZX"?(this._z=Math.asin(l(M,-1,1)),Math.abs(M)<.9999999?(this._x=Math.atan2(-C,T),this._y=Math.atan2(-E,p)):(this._x=0,this._y=Math.atan2(s,I))):n==="XZY"?(this._z=Math.asin(-l(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(L,T),this._y=Math.atan2(s,p)):(this._x=Math.atan2(-C,I),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+n),this._order=n,i!==!1&&this._onChangeCallback(),this},setFromQuaternion:function(e,n,i){return D0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(D0,n,i)},setFromVector3:function(e,n){return this.set(e.x,e.y,e.z,n||this._order)},reorder:function(e){return I0.setFromEuler(this),this.setFromQuaternion(I0,e)},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new Ee(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});function R0(){this.mask=1}Object.assign(R0.prototype,{set:function(e){this.mask=1<<e|0},enable:function(e){this.mask|=1<<e|0},enableAll:function(){this.mask=-1},toggle:function(e){this.mask^=1<<e|0},disable:function(e){this.mask&=~(1<<e|0)},disableAll:function(){this.mask=0},test:function(e){return(this.mask&e.mask)!==0}});var _2=0,z0=new Ee,lc=new Or,Eo=new jn,$p=new Ee,fh=new Ee,y2=new Ee,v2=new Or,k0=new Ee(1,0,0),B0=new Ee(0,1,0),F0=new Ee(0,0,1),x2={type:"added"},b2={type:"removed"};function rn(){Object.defineProperty(this,"id",{value:_2++}),this.uuid=Wn.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=rn.DefaultUp.clone();var e=new Ee,n=new sc,i=new Or,l=new Ee(1,1,1);function h(){i.setFromEuler(n,!1)}function p(){n.setFromQuaternion(i,void 0,!1)}n._onChange(h),i._onChange(p),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:l},modelViewMatrix:{value:new jn},normalMatrix:{value:new dr}}),this.matrix=new jn,this.matrixWorld=new jn,this.matrixAutoUpdate=rn.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new R0,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}rn.DefaultUp=new Ee(0,1,0),rn.DefaultMatrixAutoUpdate=!0,rn.prototype=Object.assign(Object.create(To.prototype),{constructor:rn,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,n){this.quaternion.setFromAxisAngle(e,n)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,n){return lc.setFromAxisAngle(e,n),this.quaternion.multiply(lc),this},rotateOnWorldAxis:function(e,n){return lc.setFromAxisAngle(e,n),this.quaternion.premultiply(lc),this},rotateX:function(e){return this.rotateOnAxis(k0,e)},rotateY:function(e){return this.rotateOnAxis(B0,e)},rotateZ:function(e){return this.rotateOnAxis(F0,e)},translateOnAxis:function(e,n){return z0.copy(e).applyQuaternion(this.quaternion),this.position.add(z0.multiplyScalar(n)),this},translateX:function(e){return this.translateOnAxis(k0,e)},translateY:function(e){return this.translateOnAxis(B0,e)},translateZ:function(e){return this.translateOnAxis(F0,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(Eo.getInverse(this.matrixWorld))},lookAt:function(e,n,i){e.isVector3?$p.copy(e):$p.set(e,n,i);var l=this.parent;this.updateWorldMatrix(!0,!1),fh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Eo.lookAt(fh,$p,this.up):Eo.lookAt($p,fh,this.up),this.quaternion.setFromRotationMatrix(Eo),l&&(Eo.extractRotation(l.matrixWorld),lc.setFromRotationMatrix(Eo),this.quaternion.premultiply(lc.inverse()))},add:function(e){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(x2)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}var i=this.children.indexOf(e);return i!==-1&&(e.parent=null,this.children.splice(i,1),e.dispatchEvent(b2)),this},attach:function(e){return this.updateWorldMatrix(!0,!1),Eo.getInverse(this.matrixWorld),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Eo.multiply(e.parent.matrixWorld)),e.applyMatrix4(Eo),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,n){if(this[e]===n)return this;for(var i=0,l=this.children.length;i<l;i++){var h=this.children[i],p=h.getObjectByProperty(e,n);if(p!==void 0)return p}},getWorldPosition:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),e=new Ee),this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),e=new Or),this.updateMatrixWorld(!0),this.matrixWorld.decompose(fh,e,y2),e},getWorldScale:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),e=new Ee),this.updateMatrixWorld(!0),this.matrixWorld.decompose(fh,v2,e),e},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),e=new Ee),this.updateMatrixWorld(!0);var n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()},raycast:function(){},traverse:function(e){e(this);for(var n=this.children,i=0,l=n.length;i<l;i++)n[i].traverse(e)},traverseVisible:function(e){if(this.visible!==!1){e(this);for(var n=this.children,i=0,l=n.length;i<l;i++)n[i].traverseVisible(e)}},traverseAncestors:function(e){var n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var n=this.children,i=0,l=n.length;i<l;i++)n[i].updateMatrixWorld(e)},updateWorldMatrix:function(e,n){var i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0)for(var l=this.children,h=0,p=l.length;h<p;h++)l[h].updateWorldMatrix(!1,!0)},toJSON:function(e){var n=e===void 0||typeof e=="string",i={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var l={};l.uuid=this.uuid,l.type=this.type,this.name!==""&&(l.name=this.name),this.castShadow===!0&&(l.castShadow=!0),this.receiveShadow===!0&&(l.receiveShadow=!0),this.visible===!1&&(l.visible=!1),this.frustumCulled===!1&&(l.frustumCulled=!1),this.renderOrder!==0&&(l.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(l.userData=this.userData),l.layers=this.layers.mask,l.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(l.matrixAutoUpdate=!1),this.isInstancedMesh&&(l.type="InstancedMesh",l.count=this.count,l.instanceMatrix=this.instanceMatrix.toJSON());function h(U,q){return U[q.uuid]===void 0&&(U[q.uuid]=q.toJSON(e)),q.uuid}if(this.isMesh||this.isLine||this.isPoints){l.geometry=h(e.geometries,this.geometry);var p=this.geometry.parameters;if(p!==void 0&&p.shapes!==void 0){var _=p.shapes;if(Array.isArray(_))for(var s=0,M=_.length;s<M;s++){var T=_[s];h(e.shapes,T)}else h(e.shapes,_)}}if(this.material!==void 0)if(Array.isArray(this.material)){for(var C=[],s=0,M=this.material.length;s<M;s++)C.push(h(e.materials,this.material[s]));l.material=C}else l.material=h(e.materials,this.material);if(this.children.length>0){l.children=[];for(var s=0;s<this.children.length;s++)l.children.push(this.children[s].toJSON(e).object)}if(n){var E=O(e.geometries),L=O(e.materials),I=O(e.textures),B=O(e.images),_=O(e.shapes);E.length>0&&(i.geometries=E),L.length>0&&(i.materials=L),I.length>0&&(i.textures=I),B.length>0&&(i.images=B),_.length>0&&(i.shapes=_)}return i.object=l,i;function O(U){var q=[];for(var ee in U){var he=U[ee];delete he.metadata,q.push(he)}return q}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(e,n){if(n===void 0&&(n=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(var i=0;i<e.children.length;i++){var l=e.children[i];this.add(l.clone())}return this}});function So(){rn.call(this),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}So.prototype=Object.assign(Object.create(rn.prototype),{constructor:So,isScene:!0,copy:function(e,n){return rn.prototype.copy.call(this,e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},toJSON:function(e){var n=rn.prototype.toJSON.call(this,e);return this.background!==null&&(n.object.background=this.background.toJSON(e)),this.environment!==null&&(n.object.environment=this.environment.toJSON(e)),this.fog!==null&&(n.object.fog=this.fog.toJSON()),n},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Ao=[new Ee,new Ee,new Ee,new Ee,new Ee,new Ee,new Ee,new Ee],mh=new Ee,Jp=new Pa,cc=new Ee,uc=new Ee,hc=new Ee,ts=new Ee,ns=new Ee,$s=new Ee,gh=new Ee,Kp=new Ee,Qp=new Ee,Js=new Ee;function Pa(e,n){this.min=e!==void 0?e:new Ee(1/0,1/0,1/0),this.max=n!==void 0?n:new Ee(-1/0,-1/0,-1/0)}Object.assign(Pa.prototype,{isBox3:!0,set:function(e,n){return this.min.copy(e),this.max.copy(n),this},setFromArray:function(e){for(var n=1/0,i=1/0,l=1/0,h=-1/0,p=-1/0,_=-1/0,s=0,M=e.length;s<M;s+=3){var T=e[s],C=e[s+1],E=e[s+2];T<n&&(n=T),C<i&&(i=C),E<l&&(l=E),T>h&&(h=T),C>p&&(p=C),E>_&&(_=E)}return this.min.set(n,i,l),this.max.set(h,p,_),this},setFromBufferAttribute:function(e){for(var n=1/0,i=1/0,l=1/0,h=-1/0,p=-1/0,_=-1/0,s=0,M=e.count;s<M;s++){var T=e.getX(s),C=e.getY(s),E=e.getZ(s);T<n&&(n=T),C<i&&(i=C),E<l&&(l=E),T>h&&(h=T),C>p&&(p=C),E>_&&(_=E)}return this.min.set(n,i,l),this.max.set(h,p,_),this},setFromPoints:function(e){this.makeEmpty();for(var n=0,i=e.length;n<i;n++)this.expandByPoint(e[n]);return this},setFromCenterAndSize:function(e,n){var i=mh.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this},setFromObject:function(e){return this.makeEmpty(),this.expandByObject(e)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(e){return e===void 0&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new Ee),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return e===void 0&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new Ee),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByObject:function(e){e.updateWorldMatrix(!1,!1);var n=e.geometry;n!==void 0&&(n.boundingBox===null&&n.computeBoundingBox(),Jp.copy(n.boundingBox),Jp.applyMatrix4(e.matrixWorld),this.expandByPoint(Jp.min),this.expandByPoint(Jp.max));for(var i=e.children,l=0,h=i.length;l<h;l++)this.expandByObject(i[l]);return this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,n){return n===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),n=new Ee),n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,mh),mh.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(gh),Kp.subVectors(this.max,gh),cc.subVectors(e.a,gh),uc.subVectors(e.b,gh),hc.subVectors(e.c,gh),ts.subVectors(uc,cc),ns.subVectors(hc,uc),$s.subVectors(cc,hc);var n=[0,-ts.z,ts.y,0,-ns.z,ns.y,0,-$s.z,$s.y,ts.z,0,-ts.x,ns.z,0,-ns.x,$s.z,0,-$s.x,-ts.y,ts.x,0,-ns.y,ns.x,0,-$s.y,$s.x,0];return!t_(n,cc,uc,hc,Kp)||(n=[1,0,0,0,1,0,0,0,1],!t_(n,cc,uc,hc,Kp))?!1:(Qp.crossVectors(ts,ns),n=[Qp.x,Qp.y,Qp.z],t_(n,cc,uc,hc,Kp))},clampPoint:function(e,n){return n===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),n=new Ee),n.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var n=mh.copy(e).clamp(this.min,this.max);return n.sub(e).length()},getBoundingSphere:function(e){return e===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=this.getSize(mh).length()*.5,e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()?this:(Ao[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ao[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ao[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ao[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ao[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ao[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ao[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ao[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ao),this)},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});function t_(e,n,i,l,h){var p,_;for(p=0,_=e.length-3;p<=_;p+=3){Js.fromArray(e,p);var s=h.x*Math.abs(Js.x)+h.y*Math.abs(Js.y)+h.z*Math.abs(Js.z),M=n.dot(Js),T=i.dot(Js),C=l.dot(Js);if(Math.max(-Math.max(M,T,C),Math.min(M,T,C))>s)return!1}return!0}var w2=new Pa;function Co(e,n){this.center=e!==void 0?e:new Ee,this.radius=n!==void 0?n:0}Object.assign(Co.prototype,{set:function(e,n){return this.center.copy(e),this.radius=n,this},setFromPoints:function(e,n){var i=this.center;n!==void 0?i.copy(n):w2.setFromPoints(e).getCenter(i);for(var l=0,h=0,p=e.length;h<p;h++)l=Math.max(l,i.distanceToSquared(e[h]));return this.radius=Math.sqrt(l),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return this.radius<=0},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius},clampPoint:function(e,n){var i=this.center.distanceToSquared(e);return n===void 0&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),n=new Ee),n.copy(e),i>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(e){return e===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Pa),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});var Po=new Ee,n_=new Ee,ef=new Ee,is=new Ee,i_=new Ee,tf=new Ee,r_=new Ee;function dc(e,n){this.origin=e!==void 0?e:new Ee,this.direction=n!==void 0?n:new Ee(0,0,-1)}Object.assign(dc.prototype,{set:function(e,n){return this.origin.copy(e),this.direction.copy(n),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,n){return n===void 0&&(console.warn("THREE.Ray: .at() target is now required"),n=new Ee),n.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,Po)),this},closestPointToPoint:function(e,n){n===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),n=new Ee),n.subVectors(e,this.origin);var i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var n=Po.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Po.copy(this.direction).multiplyScalar(n).add(this.origin),Po.distanceToSquared(e))},distanceSqToSegment:function(e,n,i,l){n_.copy(e).add(n).multiplyScalar(.5),ef.copy(n).sub(e).normalize(),is.copy(this.origin).sub(n_);var h=e.distanceTo(n)*.5,p=-this.direction.dot(ef),_=is.dot(this.direction),s=-is.dot(ef),M=is.lengthSq(),T=Math.abs(1-p*p),C,E,L,I;if(T>0)if(C=p*s-_,E=p*_-s,I=h*T,C>=0)if(E>=-I)if(E<=I){var B=1/T;C*=B,E*=B,L=C*(C+p*E+2*_)+E*(p*C+E+2*s)+M}else E=h,C=Math.max(0,-(p*E+_)),L=-C*C+E*(E+2*s)+M;else E=-h,C=Math.max(0,-(p*E+_)),L=-C*C+E*(E+2*s)+M;else E<=-I?(C=Math.max(0,-(-p*h+_)),E=C>0?-h:Math.min(Math.max(-h,-s),h),L=-C*C+E*(E+2*s)+M):E<=I?(C=0,E=Math.min(Math.max(-h,-s),h),L=E*(E+2*s)+M):(C=Math.max(0,-(p*h+_)),E=C>0?h:Math.min(Math.max(-h,-s),h),L=-C*C+E*(E+2*s)+M);else E=p>0?-h:h,C=Math.max(0,-(p*E+_)),L=-C*C+E*(E+2*s)+M;return i&&i.copy(this.direction).multiplyScalar(C).add(this.origin),l&&l.copy(ef).multiplyScalar(E).add(n_),L},intersectSphere:function(e,n){Po.subVectors(e.center,this.origin);var i=Po.dot(this.direction),l=Po.dot(Po)-i*i,h=e.radius*e.radius;if(l>h)return null;var p=Math.sqrt(h-l),_=i-p,s=i+p;return _<0&&s<0?null:_<0?this.at(s,n):this.at(_,n)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null},intersectPlane:function(e,n){var i=this.distanceToPlane(e);return i===null?null:this.at(i,n)},intersectsPlane:function(e){var n=e.distanceToPoint(this.origin);if(n===0)return!0;var i=e.normal.dot(this.direction);return i*n<0},intersectBox:function(e,n){var i,l,h,p,_,s,M=1/this.direction.x,T=1/this.direction.y,C=1/this.direction.z,E=this.origin;return M>=0?(i=(e.min.x-E.x)*M,l=(e.max.x-E.x)*M):(i=(e.max.x-E.x)*M,l=(e.min.x-E.x)*M),T>=0?(h=(e.min.y-E.y)*T,p=(e.max.y-E.y)*T):(h=(e.max.y-E.y)*T,p=(e.min.y-E.y)*T),i>p||h>l||((h>i||i!==i)&&(i=h),(p<l||l!==l)&&(l=p),C>=0?(_=(e.min.z-E.z)*C,s=(e.max.z-E.z)*C):(_=(e.max.z-E.z)*C,s=(e.min.z-E.z)*C),i>s||_>l)||((_>i||i!==i)&&(i=_),(s<l||l!==l)&&(l=s),l<0)?null:this.at(i>=0?i:l,n)},intersectsBox:function(e){return this.intersectBox(e,Po)!==null},intersectTriangle:function(e,n,i,l,h){i_.subVectors(n,e),tf.subVectors(i,e),r_.crossVectors(i_,tf);var p=this.direction.dot(r_),_;if(p>0){if(l)return null;_=1}else if(p<0)_=-1,p=-p;else return null;is.subVectors(this.origin,e);var s=_*this.direction.dot(tf.crossVectors(is,tf));if(s<0)return null;var M=_*this.direction.dot(i_.cross(is));if(M<0||s+M>p)return null;var T=-_*is.dot(r_);return T<0?null:this.at(T/p,h)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var a_=new Ee,M2=new Ee,T2=new dr;function ja(e,n){this.normal=e!==void 0?e:new Ee(1,0,0),this.constant=n!==void 0?n:0}Object.assign(ja.prototype,{isPlane:!0,set:function(e,n){return this.normal.copy(e),this.constant=n,this},setComponents:function(e,n,i,l){return this.normal.set(e,n,i),this.constant=l,this},setFromNormalAndCoplanarPoint:function(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this},setFromCoplanarPoints:function(e,n,i){var l=a_.subVectors(i,n).cross(M2.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(l,e),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,n){return n===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),n=new Ee),n.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,n){n===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new Ee);var i=e.delta(a_),l=this.normal.dot(i);if(l===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):void 0;var h=-(e.start.dot(this.normal)+this.constant)/l;if(!(h<0||h>1))return n.copy(i).multiplyScalar(h).add(e.start)},intersectsLine:function(e){var n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<0&&n>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return e===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new Ee),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,n){var i=n||T2.getNormalMatrix(e),l=this.coplanarPoint(a_).applyMatrix4(e),h=this.normal.applyMatrix3(i).normalize();return this.constant=-l.dot(h),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var La=new Ee,Lo=new Ee,o_=new Ee,Do=new Ee,pc=new Ee,fc=new Ee,O0=new Ee,s_=new Ee,l_=new Ee,c_=new Ee;function sr(e,n,i){this.a=e!==void 0?e:new Ee,this.b=n!==void 0?n:new Ee,this.c=i!==void 0?i:new Ee}Object.assign(sr,{getNormal:function(e,n,i,l){l===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),l=new Ee),l.subVectors(i,n),La.subVectors(e,n),l.cross(La);var h=l.lengthSq();return h>0?l.multiplyScalar(1/Math.sqrt(h)):l.set(0,0,0)},getBarycoord:function(e,n,i,l,h){La.subVectors(l,n),Lo.subVectors(i,n),o_.subVectors(e,n);var p=La.dot(La),_=La.dot(Lo),s=La.dot(o_),M=Lo.dot(Lo),T=Lo.dot(o_),C=p*M-_*_;if(h===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),h=new Ee),C===0)return h.set(-2,-1,-1);var E=1/C,L=(M*s-_*T)*E,I=(p*T-_*s)*E;return h.set(1-L-I,I,L)},containsPoint:function(e,n,i,l){return sr.getBarycoord(e,n,i,l,Do),Do.x>=0&&Do.y>=0&&Do.x+Do.y<=1},getUV:function(e,n,i,l,h,p,_,s){return this.getBarycoord(e,n,i,l,Do),s.set(0,0),s.addScaledVector(h,Do.x),s.addScaledVector(p,Do.y),s.addScaledVector(_,Do.z),s},isFrontFacing:function(e,n,i,l){return La.subVectors(i,n),Lo.subVectors(e,n),La.cross(Lo).dot(l)<0}}),Object.assign(sr.prototype,{set:function(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this},setFromPointsAndIndices:function(e,n,i,l){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[l]),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return La.subVectors(this.c,this.b),Lo.subVectors(this.a,this.b),La.cross(Lo).length()*.5},getMidpoint:function(e){return e===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Ee),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(.3333333333333333)},getNormal:function(e){return sr.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return e===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new ja),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,n){return sr.getBarycoord(e,this.a,this.b,this.c,n)},getUV:function(e,n,i,l,h){return sr.getUV(e,this.a,this.b,this.c,n,i,l,h)},containsPoint:function(e){return sr.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return sr.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,n){n===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),n=new Ee);var i=this.a,l=this.b,h=this.c,p,_;pc.subVectors(l,i),fc.subVectors(h,i),s_.subVectors(e,i);var s=pc.dot(s_),M=fc.dot(s_);if(s<=0&&M<=0)return n.copy(i);l_.subVectors(e,l);var T=pc.dot(l_),C=fc.dot(l_);if(T>=0&&C<=T)return n.copy(l);var E=s*C-T*M;if(E<=0&&s>=0&&T<=0)return p=s/(s-T),n.copy(i).addScaledVector(pc,p);c_.subVectors(e,h);var L=pc.dot(c_),I=fc.dot(c_);if(I>=0&&L<=I)return n.copy(h);var B=L*M-s*I;if(B<=0&&M>=0&&I<=0)return _=M/(M-I),n.copy(i).addScaledVector(fc,_);var O=T*I-L*C;if(O<=0&&C-T>=0&&L-I>=0)return O0.subVectors(h,l),_=(C-T)/(C-T+(L-I)),n.copy(l).addScaledVector(O0,_);var U=1/(O+B+E);return p=B*U,_=E*U,n.copy(i).addScaledVector(pc,p).addScaledVector(fc,_)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var N0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Da={h:0,s:0,l:0},nf={h:0,s:0,l:0};function en(e,n,i){return n===void 0&&i===void 0?this.set(e):this.setRGB(e,n,i)}function u_(e,n,i){return i<0&&(i+=1),i>1&&(i-=1),i<.16666666666666666?e+(n-e)*6*i:i<.5?n:i<.6666666666666666?e+(n-e)*6*(.6666666666666666-i):e}function h_(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function d_(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}Object.assign(en.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this},setRGB:function(e,n,i){return this.r=e,this.g=n,this.b=i,this},setHSL:function(e,n,i){if(e=Wn.euclideanModulo(e,1),n=Wn.clamp(n,0,1),i=Wn.clamp(i,0,1),n===0)this.r=this.g=this.b=i;else{var l=i<=.5?i*(1+n):i+n-i*n,h=2*i-l;this.r=u_(h,l,e+.3333333333333333),this.g=u_(h,l,e),this.b=u_(h,l,e-.3333333333333333)}return this},setStyle:function(e){function n(E){E!==void 0&&parseFloat(E)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var l,h=i[1],p=i[2];switch(h){case"rgb":case"rgba":if(l=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(p))return this.r=Math.min(255,parseInt(l[1],10))/255,this.g=Math.min(255,parseInt(l[2],10))/255,this.b=Math.min(255,parseInt(l[3],10))/255,n(l[5]),this;if(l=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(p))return this.r=Math.min(100,parseInt(l[1],10))/100,this.g=Math.min(100,parseInt(l[2],10))/100,this.b=Math.min(100,parseInt(l[3],10))/100,n(l[5]),this;break;case"hsl":case"hsla":if(l=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(p)){var _=parseFloat(l[1])/360,s=parseInt(l[2],10)/100,M=parseInt(l[3],10)/100;return n(l[5]),this.setHSL(_,s,M)}break}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var T=i[1],C=T.length;if(C===3)return this.r=parseInt(T.charAt(0)+T.charAt(0),16)/255,this.g=parseInt(T.charAt(1)+T.charAt(1),16)/255,this.b=parseInt(T.charAt(2)+T.charAt(2),16)/255,this;if(C===6)return this.r=parseInt(T.charAt(0)+T.charAt(1),16)/255,this.g=parseInt(T.charAt(2)+T.charAt(3),16)/255,this.b=parseInt(T.charAt(4)+T.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var n=N0[e];return n!==void 0?this.setHex(n):console.warn("THREE.Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,n){return n===void 0&&(n=2),this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},copyLinearToGamma:function(e,n){n===void 0&&(n=2);var i=n>0?1/n:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=h_(e.r),this.g=h_(e.g),this.b=h_(e.b),this},copyLinearToSRGB:function(e){return this.r=d_(e.r),this.g=d_(e.g),this.b=d_(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return this.r*255<<16^this.g*255<<8^this.b*255<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){e===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var n=this.r,i=this.g,l=this.b,h=Math.max(n,i,l),p=Math.min(n,i,l),_,s,M=(p+h)/2;if(p===h)_=0,s=0;else{var T=h-p;switch(s=M<=.5?T/(h+p):T/(2-h-p),h){case n:_=(i-l)/T+(i<l?6:0);break;case i:_=(l-n)/T+2;break;case l:_=(n-i)/T+4;break}_/=6}return e.h=_,e.s=s,e.l=M,e},getStyle:function(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"},offsetHSL:function(e,n,i){return this.getHSL(Da),Da.h+=e,Da.s+=n,Da.l+=i,this.setHSL(Da.h,Da.s,Da.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},sub:function(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this},lerpHSL:function(e,n){this.getHSL(Da),e.getHSL(nf);var i=Wn.lerp(Da.h,nf.h,n),l=Wn.lerp(Da.s,nf.s,n),h=Wn.lerp(Da.l,nf.l,n);return this.setHSL(i,l,h),this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,n){return n===void 0&&(n=0),this.r=e[n],this.g=e[n+1],this.b=e[n+2],this},toArray:function(e,n){return e===void 0&&(e=[]),n===void 0&&(n=0),e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e},toJSON:function(){return this.getHex()}}),en.NAMES=N0;function rf(e,n,i,l,h,p){this.a=e,this.b=n,this.c=i,this.normal=l&&l.isVector3?l:new Ee,this.vertexNormals=Array.isArray(l)?l:[],this.color=h&&h.isColor?h:new en,this.vertexColors=Array.isArray(h)?h:[],this.materialIndex=p!==void 0?p:0}Object.assign(rf.prototype,{clone:function(){return new this.constructor().copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var n=0,i=e.vertexNormals.length;n<i;n++)this.vertexNormals[n]=e.vertexNormals[n].clone();for(var n=0,i=e.vertexColors.length;n<i;n++)this.vertexColors[n]=e.vertexColors[n].clone();return this}});var E2=0;function Rn(){Object.defineProperty(this,"id",{value:E2++}),this.uuid=Wn.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=ah,this.side=Jl,this.flatShading=!1,this.vertexTangents=!1,this.vertexColors=a0,this.opacity=1,this.transparent=!1,this.blendSrc=h0,this.blendDst=d0,this.blendEquation=Ql,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Gg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=p2,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qg,this.stencilZFail=Qg,this.stencilZPass=Qg,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Rn.prototype=Object.assign(Object.create(To.prototype),{constructor:Rn,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(e!==void 0)for(var n in e){var i=e[n];if(i===void 0){console.warn("THREE.Material: '"+n+"' parameter is undefined.");continue}if(n==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=i===r0;continue}var l=this[n];if(l===void 0){console.warn("THREE."+this.type+": '"+n+"' is not a property of this material.");continue}l&&l.isColor?l.set(i):l&&l.isVector3&&i&&i.isVector3?l.copy(i):this[n]=i}},toJSON:function(e){var n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,this.combine!==void 0&&(i.combine=this.combine),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ah&&(i.blending=this.blending),this.flatShading===!0&&(i.flatShading=this.flatShading),this.side!==Jl&&(i.side=this.side),this.vertexColors!==a0&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(i.morphTargets=!0),this.morphNormals===!0&&(i.morphNormals=!0),this.skinning===!0&&(i.skinning=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData);function l(_){var s=[];for(var M in _){var T=_[M];delete T.metadata,s.push(T)}return s}if(n){var h=l(e.textures),p=l(e.images);h.length>0&&(i.textures=h),p.length>0&&(i.images=p)}return i},clone:function(){return new this.constructor().copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var n=e.clippingPlanes,i=null;if(n!==null){var l=n.length;i=new Array(l);for(var h=0;h!==l;++h)i[h]=n[h].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Rn.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function lr(e){Rn.call(this),this.type="MeshBasicMaterial",this.color=new en(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Up,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}lr.prototype=Object.create(Rn.prototype),lr.prototype.constructor=lr,lr.prototype.isMeshBasicMaterial=!0,lr.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this};var pi=new Ee;function zn(e,n,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i===!0,this.usage=Xp,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(zn.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(zn.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,n,i){e*=this.itemSize,i*=n.itemSize;for(var l=0,h=this.itemSize;l<h;l++)this.array[e+l]=n.array[i+l];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var n=this.array,i=0,l=0,h=e.length;l<h;l++){var p=e[l];p===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",l),p=new en),n[i++]=p.r,n[i++]=p.g,n[i++]=p.b}return this},copyVector2sArray:function(e){for(var n=this.array,i=0,l=0,h=e.length;l<h;l++){var p=e[l];p===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",l),p=new Lt),n[i++]=p.x,n[i++]=p.y}return this},copyVector3sArray:function(e){for(var n=this.array,i=0,l=0,h=e.length;l<h;l++){var p=e[l];p===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",l),p=new Ee),n[i++]=p.x,n[i++]=p.y,n[i++]=p.z}return this},copyVector4sArray:function(e){for(var n=this.array,i=0,l=0,h=e.length;l<h;l++){var p=e[l];p===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",l),p=new gi),n[i++]=p.x,n[i++]=p.y,n[i++]=p.z,n[i++]=p.w}return this},applyMatrix3:function(e){for(var n=0,i=this.count;n<i;n++)pi.x=this.getX(n),pi.y=this.getY(n),pi.z=this.getZ(n),pi.applyMatrix3(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this},applyMatrix4:function(e){for(var n=0,i=this.count;n<i;n++)pi.x=this.getX(n),pi.y=this.getY(n),pi.z=this.getZ(n),pi.applyMatrix4(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this},applyNormalMatrix:function(e){for(var n=0,i=this.count;n<i;n++)pi.x=this.getX(n),pi.y=this.getY(n),pi.z=this.getZ(n),pi.applyNormalMatrix(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this},transformDirection:function(e){for(var n=0,i=this.count;n<i;n++)pi.x=this.getX(n),pi.y=this.getY(n),pi.z=this.getZ(n),pi.transformDirection(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this},set:function(e,n){return n===void 0&&(n=0),this.array.set(e,n),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,n){return this.array[e*this.itemSize]=n,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,n){return this.array[e*this.itemSize+1]=n,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,n){return this.array[e*this.itemSize+2]=n,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,n){return this.array[e*this.itemSize+3]=n,this},setXY:function(e,n,i){return e*=this.itemSize,this.array[e+0]=n,this.array[e+1]=i,this},setXYZ:function(e,n,i,l){return e*=this.itemSize,this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=l,this},setXYZW:function(e,n,i,l,h){return e*=this.itemSize,this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=l,this.array[e+3]=h,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});function p_(e,n,i){zn.call(this,new Int8Array(e),n,i)}p_.prototype=Object.create(zn.prototype),p_.prototype.constructor=p_;function f_(e,n,i){zn.call(this,new Uint8Array(e),n,i)}f_.prototype=Object.create(zn.prototype),f_.prototype.constructor=f_;function m_(e,n,i){zn.call(this,new Uint8ClampedArray(e),n,i)}m_.prototype=Object.create(zn.prototype),m_.prototype.constructor=m_;function g_(e,n,i){zn.call(this,new Int16Array(e),n,i)}g_.prototype=Object.create(zn.prototype),g_.prototype.constructor=g_;function _h(e,n,i){zn.call(this,new Uint16Array(e),n,i)}_h.prototype=Object.create(zn.prototype),_h.prototype.constructor=_h;function __(e,n,i){zn.call(this,new Int32Array(e),n,i)}__.prototype=Object.create(zn.prototype),__.prototype.constructor=__;function yh(e,n,i){zn.call(this,new Uint32Array(e),n,i)}yh.prototype=Object.create(zn.prototype),yh.prototype.constructor=yh;function sn(e,n,i){zn.call(this,new Float32Array(e),n,i)}sn.prototype=Object.create(zn.prototype),sn.prototype.constructor=sn;function y_(e,n,i){zn.call(this,new Float64Array(e),n,i)}y_.prototype=Object.create(zn.prototype),y_.prototype.constructor=y_;function U0(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}Object.assign(U0.prototype,{computeGroups:function(e){for(var n,i=[],l=void 0,h=e.faces,p=0;p<h.length;p++){var _=h[p];_.materialIndex!==l&&(l=_.materialIndex,n!==void 0&&(n.count=p*3-n.start,i.push(n)),n={start:p*3,materialIndex:l})}n!==void 0&&(n.count=p*3-n.start,i.push(n)),this.groups=i},fromGeometry:function(e){var n=e.faces,i=e.vertices,l=e.faceVertexUvs,h=l[0]&&l[0].length>0,p=l[1]&&l[1].length>0,_=e.morphTargets,s=_.length,M;if(s>0){M=[];for(var T=0;T<s;T++)M[T]={name:_[T].name,data:[]};this.morphTargets.position=M}var C=e.morphNormals,E=C.length,L;if(E>0){L=[];for(var T=0;T<E;T++)L[T]={name:C[T].name,data:[]};this.morphTargets.normal=L}var I=e.skinIndices,B=e.skinWeights,O=I.length===i.length,U=B.length===i.length;i.length>0&&n.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var T=0;T<n.length;T++){var q=n[T];this.vertices.push(i[q.a],i[q.b],i[q.c]);var ee=q.vertexNormals;if(ee.length===3)this.normals.push(ee[0],ee[1],ee[2]);else{var he=q.normal;this.normals.push(he,he,he)}var Ce=q.vertexColors;if(Ce.length===3)this.colors.push(Ce[0],Ce[1],Ce[2]);else{var K=q.color;this.colors.push(K,K,K)}if(h===!0){var ie=l[0][T];ie!==void 0?this.uvs.push(ie[0],ie[1],ie[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",T),this.uvs.push(new Lt,new Lt,new Lt))}if(p===!0){var ie=l[1][T];ie!==void 0?this.uvs2.push(ie[0],ie[1],ie[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",T),this.uvs2.push(new Lt,new Lt,new Lt))}for(var ue=0;ue<s;ue++){var ae=_[ue].vertices;M[ue].data.push(ae[q.a],ae[q.b],ae[q.c])}for(var ue=0;ue<E;ue++){var le=C[ue].vertexNormals[T];L[ue].data.push(le.a,le.b,le.c)}O&&this.skinIndices.push(I[q.a],I[q.b],I[q.c]),U&&this.skinWeights.push(B[q.a],B[q.b],B[q.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}});function V0(e){if(e.length===0)return-1/0;for(var n=e[0],i=1,l=e.length;i<l;++i)e[i]>n&&(n=e[i]);return n}var S2=1,qa=new jn,v_=new rn,mc=new Ee,aa=new Pa,vh=new Pa,Zi=new Ee;function yn(){Object.defineProperty(this,"id",{value:S2+=2}),this.uuid=Wn.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}yn.prototype=Object.assign(Object.create(To.prototype),{constructor:yn,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(V0(e)>65535?yh:_h)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,n){return this.attributes[e]=n,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,n,i){this.groups.push({start:e,count:n,materialIndex:i!==void 0?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,n){this.drawRange.start=e,this.drawRange.count=n},applyMatrix4:function(e){var n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);var i=this.attributes.normal;if(i!==void 0){var l=new dr().getNormalMatrix(e);i.applyNormalMatrix(l),i.needsUpdate=!0}var h=this.attributes.tangent;return h!==void 0&&(h.transformDirection(e),h.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return qa.makeRotationX(e),this.applyMatrix4(qa),this},rotateY:function(e){return qa.makeRotationY(e),this.applyMatrix4(qa),this},rotateZ:function(e){return qa.makeRotationZ(e),this.applyMatrix4(qa),this},translate:function(e,n,i){return qa.makeTranslation(e,n,i),this.applyMatrix4(qa),this},scale:function(e,n,i){return qa.makeScale(e,n,i),this.applyMatrix4(qa),this},lookAt:function(e){return v_.lookAt(e),v_.updateMatrix(),this.applyMatrix4(v_.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(mc).negate(),this.translate(mc.x,mc.y,mc.z),this},setFromObject:function(e){var n=e.geometry;if(e.isPoints||e.isLine){var i=new sn(n.vertices.length*3,3),l=new sn(n.colors.length*3,3);if(this.setAttribute("position",i.copyVector3sArray(n.vertices)),this.setAttribute("color",l.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){var h=new sn(n.lineDistances.length,1);this.setAttribute("lineDistance",h.copyArray(n.lineDistances))}n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone())}else e.isMesh&&n&&n.isGeometry&&this.fromGeometry(n);return this},setFromPoints:function(e){for(var n=[],i=0,l=e.length;i<l;i++){var h=e[i];n.push(h.x,h.y,h.z||0)}return this.setAttribute("position",new sn(n,3)),this},updateFromObject:function(e){var n=e.geometry;if(e.isMesh){var i=n.__directGeometry;if(n.elementsNeedUpdate===!0&&(i=void 0,n.elementsNeedUpdate=!1),i===void 0)return this.fromGeometry(n);i.verticesNeedUpdate=n.verticesNeedUpdate,i.normalsNeedUpdate=n.normalsNeedUpdate,i.colorsNeedUpdate=n.colorsNeedUpdate,i.uvsNeedUpdate=n.uvsNeedUpdate,i.groupsNeedUpdate=n.groupsNeedUpdate,n.verticesNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.groupsNeedUpdate=!1,n=i}var l;return n.verticesNeedUpdate===!0&&(l=this.attributes.position,l!==void 0&&(l.copyVector3sArray(n.vertices),l.needsUpdate=!0),n.verticesNeedUpdate=!1),n.normalsNeedUpdate===!0&&(l=this.attributes.normal,l!==void 0&&(l.copyVector3sArray(n.normals),l.needsUpdate=!0),n.normalsNeedUpdate=!1),n.colorsNeedUpdate===!0&&(l=this.attributes.color,l!==void 0&&(l.copyColorsArray(n.colors),l.needsUpdate=!0),n.colorsNeedUpdate=!1),n.uvsNeedUpdate&&(l=this.attributes.uv,l!==void 0&&(l.copyVector2sArray(n.uvs),l.needsUpdate=!0),n.uvsNeedUpdate=!1),n.lineDistancesNeedUpdate&&(l=this.attributes.lineDistance,l!==void 0&&(l.copyArray(n.lineDistances),l.needsUpdate=!0),n.lineDistancesNeedUpdate=!1),n.groupsNeedUpdate&&(n.computeGroups(e.geometry),this.groups=n.groups,n.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=new U0().fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var n=new Float32Array(e.vertices.length*3);if(this.setAttribute("position",new zn(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){var i=new Float32Array(e.normals.length*3);this.setAttribute("normal",new zn(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var l=new Float32Array(e.colors.length*3);this.setAttribute("color",new zn(l,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var h=new Float32Array(e.uvs.length*2);this.setAttribute("uv",new zn(h,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var p=new Float32Array(e.uvs2.length*2);this.setAttribute("uv2",new zn(p,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var _ in e.morphTargets){for(var s=[],M=e.morphTargets[_],T=0,C=M.length;T<C;T++){var E=M[T],L=new sn(E.data.length*3,3);L.name=E.name,s.push(L.copyVector3sArray(E.data))}this.morphAttributes[_]=s}if(e.skinIndices.length>0){var I=new sn(e.skinIndices.length*4,4);this.setAttribute("skinIndex",I.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var B=new sn(e.skinWeights.length*4,4);this.setAttribute("skinWeight",B.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new Pa);var e=this.attributes.position,n=this.morphAttributes.position;if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(var i=0,l=n.length;i<l;i++){var h=n[i];aa.setFromBufferAttribute(h),this.morphTargetsRelative?(Zi.addVectors(this.boundingBox.min,aa.min),this.boundingBox.expandByPoint(Zi),Zi.addVectors(this.boundingBox.max,aa.max),this.boundingBox.expandByPoint(Zi)):(this.boundingBox.expandByPoint(aa.min),this.boundingBox.expandByPoint(aa.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new Co);var e=this.attributes.position,n=this.morphAttributes.position;if(e){var i=this.boundingSphere.center;if(aa.setFromBufferAttribute(e),n)for(var l=0,h=n.length;l<h;l++){var p=n[l];vh.setFromBufferAttribute(p),this.morphTargetsRelative?(Zi.addVectors(aa.min,vh.min),aa.expandByPoint(Zi),Zi.addVectors(aa.max,vh.max),aa.expandByPoint(Zi)):(aa.expandByPoint(vh.min),aa.expandByPoint(vh.max))}aa.getCenter(i);for(var _=0,l=0,h=e.count;l<h;l++)Zi.fromBufferAttribute(e,l),_=Math.max(_,i.distanceToSquared(Zi));if(n)for(var l=0,h=n.length;l<h;l++)for(var p=n[l],s=this.morphTargetsRelative,M=0,T=p.count;M<T;M++)Zi.fromBufferAttribute(p,M),s&&(mc.fromBufferAttribute(e,M),Zi.add(mc)),_=Math.max(_,i.distanceToSquared(Zi));this.boundingSphere.radius=Math.sqrt(_),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,n=this.attributes;if(n.position){var i=n.position.array;if(n.normal===void 0)this.setAttribute("normal",new zn(new Float32Array(i.length),3));else for(var l=n.normal.array,h=0,p=l.length;h<p;h++)l[h]=0;var _=n.normal.array,s,M,T,C=new Ee,E=new Ee,L=new Ee,I=new Ee,B=new Ee;if(e)for(var O=e.array,h=0,p=e.count;h<p;h+=3)s=O[h+0]*3,M=O[h+1]*3,T=O[h+2]*3,C.fromArray(i,s),E.fromArray(i,M),L.fromArray(i,T),I.subVectors(L,E),B.subVectors(C,E),I.cross(B),_[s]+=I.x,_[s+1]+=I.y,_[s+2]+=I.z,_[M]+=I.x,_[M+1]+=I.y,_[M+2]+=I.z,_[T]+=I.x,_[T+1]+=I.y,_[T+2]+=I.z;else for(var h=0,p=i.length;h<p;h+=9)C.fromArray(i,h),E.fromArray(i,h+3),L.fromArray(i,h+6),I.subVectors(L,E),B.subVectors(C,E),I.cross(B),_[h]=I.x,_[h+1]=I.y,_[h+2]=I.z,_[h+3]=I.x,_[h+4]=I.y,_[h+5]=I.z,_[h+6]=I.x,_[h+7]=I.y,_[h+8]=I.z;this.normalizeNormals(),n.normal.needsUpdate=!0}},merge:function(e,n){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}n===void 0&&(n=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var i=this.attributes;for(var l in i)if(e.attributes[l]!==void 0)for(var h=i[l],p=h.array,_=e.attributes[l],s=_.array,M=_.itemSize*n,T=Math.min(s.length,p.length-M),C=0,E=M;C<T;C++,E++)p[E]=s[C];return this},normalizeNormals:function(){for(var e=this.attributes.normal,n=0,i=e.count;n<i;n++)Zi.x=e.getX(n),Zi.y=e.getY(n),Zi.z=e.getZ(n),Zi.normalize(),e.setXYZ(n,Zi.x,Zi.y,Zi.z)},toNonIndexed:function(){function e(O,U){for(var q=O.array,ee=O.itemSize,he=new q.constructor(U.length*ee),Ce=0,K=0,ie=0,ue=U.length;ie<ue;ie++){Ce=U[ie]*ee;for(var ae=0;ae<ee;ae++)he[K++]=q[Ce++]}return new zn(he,ee)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var n=new yn,i=this.index.array,l=this.attributes;for(var h in l){var p=l[h],_=e(p,i);n.setAttribute(h,_)}var s=this.morphAttributes;for(h in s){for(var M=[],T=s[h],C=0,E=T.length;C<E;C++){var p=T[C],_=e(p,i);M.push(_)}n.morphAttributes[h]=M}n.morphTargetsRelative=this.morphTargetsRelative;for(var L=this.groups,C=0,I=L.length;C<I;C++){var B=L[C];n.addGroup(B.start,B.count,B.materialIndex)}return n},toJSON:function(){var e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){var n=this.parameters;for(var i in n)n[i]!==void 0&&(e[i]=n[i]);return e}e.data={attributes:{}};var l=this.index;l!==null&&(e.data.index={type:l.array.constructor.name,array:Array.prototype.slice.call(l.array)});var h=this.attributes;for(var i in h){var p=h[i],_=p.toJSON();p.name!==""&&(_.name=p.name),e.data.attributes[i]=_}var s={},M=!1;for(var i in this.morphAttributes){for(var T=this.morphAttributes[i],C=[],E=0,L=T.length;E<L;E++){var p=T[E],_=p.toJSON();p.name!==""&&(_.name=p.name),C.push(_)}C.length>0&&(s[i]=C,M=!0)}M&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);var I=this.groups;I.length>0&&(e.data.groups=JSON.parse(JSON.stringify(I)));var B=this.boundingSphere;return B!==null&&(e.data.boundingSphere={center:B.center.toArray(),radius:B.radius}),e},clone:function(){return new yn().copy(this)},copy:function(e){var n,i,l;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var h=e.index;h!==null&&this.setIndex(h.clone());var p=e.attributes;for(n in p){var _=p[n];this.setAttribute(n,_.clone())}var s=e.morphAttributes;for(n in s){var M=[],T=s[n];for(i=0,l=T.length;i<l;i++)M.push(T[i].clone());this.morphAttributes[n]=M}this.morphTargetsRelative=e.morphTargetsRelative;var C=e.groups;for(i=0,l=C.length;i<l;i++){var E=C[i];this.addGroup(E.start,E.count,E.materialIndex)}var L=e.boundingBox;L!==null&&(this.boundingBox=L.clone());var I=e.boundingSphere;return I!==null&&(this.boundingSphere=I.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var G0=new jn,Ks=new dc,x_=new Co,Qs=new Ee,el=new Ee,tl=new Ee,b_=new Ee,w_=new Ee,M_=new Ee,af=new Ee,of=new Ee,sf=new Ee,gc=new Lt,_c=new Lt,yc=new Lt,xh=new Ee,lf=new Ee;function Ai(e,n){rn.call(this),this.type="Mesh",this.geometry=e!==void 0?e:new yn,this.material=n!==void 0?n:new lr,this.updateMorphTargets()}Ai.prototype=Object.assign(Object.create(rn.prototype),{constructor:Ai,isMesh:!0,copy:function(e){return rn.prototype.copy.call(this,e),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e=this.geometry,n,i,l;if(e.isBufferGeometry){var h=e.morphAttributes,p=Object.keys(h);if(p.length>0){var _=h[p[0]];if(_!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},n=0,i=_.length;n<i;n++)l=_[n].name||String(n),this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=n}}else{var s=e.morphTargets;s!==void 0&&s.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,n){var i=this.geometry,l=this.material,h=this.matrixWorld;if(l!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),x_.copy(i.boundingSphere),x_.applyMatrix4(h),e.ray.intersectsSphere(x_)!==!1&&(G0.getInverse(h),Ks.copy(e.ray).applyMatrix4(G0),!(i.boundingBox!==null&&Ks.intersectsBox(i.boundingBox)===!1)))){var p;if(i.isBufferGeometry){var _,s,M,T=i.index,C=i.attributes.position,E=i.morphAttributes.position,L=i.morphTargetsRelative,I=i.attributes.uv,B=i.attributes.uv2,O=i.groups,U=i.drawRange,q,ee,he,Ce,K,ie,ue,ae;if(T!==null)if(Array.isArray(l))for(q=0,he=O.length;q<he;q++)for(K=O[q],ie=l[K.materialIndex],ue=Math.max(K.start,U.start),ae=Math.min(K.start+K.count,U.start+U.count),ee=ue,Ce=ae;ee<Ce;ee+=3)_=T.getX(ee),s=T.getX(ee+1),M=T.getX(ee+2),p=cf(this,ie,e,Ks,C,E,L,I,B,_,s,M),p&&(p.faceIndex=Math.floor(ee/3),p.face.materialIndex=K.materialIndex,n.push(p));else for(ue=Math.max(0,U.start),ae=Math.min(T.count,U.start+U.count),q=ue,he=ae;q<he;q+=3)_=T.getX(q),s=T.getX(q+1),M=T.getX(q+2),p=cf(this,l,e,Ks,C,E,L,I,B,_,s,M),p&&(p.faceIndex=Math.floor(q/3),n.push(p));else if(C!==void 0)if(Array.isArray(l))for(q=0,he=O.length;q<he;q++)for(K=O[q],ie=l[K.materialIndex],ue=Math.max(K.start,U.start),ae=Math.min(K.start+K.count,U.start+U.count),ee=ue,Ce=ae;ee<Ce;ee+=3)_=ee,s=ee+1,M=ee+2,p=cf(this,ie,e,Ks,C,E,L,I,B,_,s,M),p&&(p.faceIndex=Math.floor(ee/3),p.face.materialIndex=K.materialIndex,n.push(p));else for(ue=Math.max(0,U.start),ae=Math.min(C.count,U.start+U.count),q=ue,he=ae;q<he;q+=3)_=q,s=q+1,M=q+2,p=cf(this,l,e,Ks,C,E,L,I,B,_,s,M),p&&(p.faceIndex=Math.floor(q/3),n.push(p))}else if(i.isGeometry){var le,De,ye,se=Array.isArray(l),Ue=i.vertices,Oe=i.faces,We,st=i.faceVertexUvs[0];st.length>0&&(We=st);for(var St=0,gt=Oe.length;St<gt;St++){var At=Oe[St],Dt=se?l[At.materialIndex]:l;if(Dt!==void 0&&(le=Ue[At.a],De=Ue[At.b],ye=Ue[At.c],p=H0(this,Dt,e,Ks,le,De,ye,xh),p)){if(We&&We[St]){var Ot=We[St];gc.copy(Ot[0]),_c.copy(Ot[1]),yc.copy(Ot[2]),p.uv=sr.getUV(xh,le,De,ye,gc,_c,yc,new Lt)}p.face=At,p.faceIndex=St,n.push(p)}}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});function H0(e,n,i,l,h,p,_,s){var M;if(n.side===tr?M=l.intersectTriangle(_,p,h,!0,s):M=l.intersectTriangle(h,p,_,n.side!==rh,s),M===null)return null;lf.copy(s),lf.applyMatrix4(e.matrixWorld);var T=i.ray.origin.distanceTo(lf);return T<i.near||T>i.far?null:{distance:T,point:lf.clone(),object:e}}function cf(e,n,i,l,h,p,_,s,M,T,C,E){Qs.fromBufferAttribute(h,T),el.fromBufferAttribute(h,C),tl.fromBufferAttribute(h,E);var L=e.morphTargetInfluences;if(n.morphTargets&&p&&L){af.set(0,0,0),of.set(0,0,0),sf.set(0,0,0);for(var I=0,B=p.length;I<B;I++){var O=L[I],U=p[I];O!==0&&(b_.fromBufferAttribute(U,T),w_.fromBufferAttribute(U,C),M_.fromBufferAttribute(U,E),_?(af.addScaledVector(b_,O),of.addScaledVector(w_,O),sf.addScaledVector(M_,O)):(af.addScaledVector(b_.sub(Qs),O),of.addScaledVector(w_.sub(el),O),sf.addScaledVector(M_.sub(tl),O)))}Qs.add(af),el.add(of),tl.add(sf)}var q=H0(e,n,i,l,Qs,el,tl,xh);if(q){s&&(gc.fromBufferAttribute(s,T),_c.fromBufferAttribute(s,C),yc.fromBufferAttribute(s,E),q.uv=sr.getUV(xh,Qs,el,tl,gc,_c,yc,new Lt)),M&&(gc.fromBufferAttribute(M,T),_c.fromBufferAttribute(M,C),yc.fromBufferAttribute(M,E),q.uv2=sr.getUV(xh,Qs,el,tl,gc,_c,yc,new Lt));var ee=new rf(T,C,E);sr.getNormal(Qs,el,tl,ee.normal),q.face=ee}return q}var A2=0,Za=new jn,T_=new rn,uf=new Ee;function Fn(){Object.defineProperty(this,"id",{value:A2+=2}),this.uuid=Wn.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Fn.prototype=Object.assign(Object.create(To.prototype),{constructor:Fn,isGeometry:!0,applyMatrix4:function(e){for(var n=new dr().getNormalMatrix(e),i=0,l=this.vertices.length;i<l;i++){var h=this.vertices[i];h.applyMatrix4(e)}for(var i=0,l=this.faces.length;i<l;i++){var p=this.faces[i];p.normal.applyMatrix3(n).normalize();for(var _=0,s=p.vertexNormals.length;_<s;_++)p.vertexNormals[_].applyMatrix3(n).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return Za.makeRotationX(e),this.applyMatrix4(Za),this},rotateY:function(e){return Za.makeRotationY(e),this.applyMatrix4(Za),this},rotateZ:function(e){return Za.makeRotationZ(e),this.applyMatrix4(Za),this},translate:function(e,n,i){return Za.makeTranslation(e,n,i),this.applyMatrix4(Za),this},scale:function(e,n,i){return Za.makeScale(e,n,i),this.applyMatrix4(Za),this},lookAt:function(e){return T_.lookAt(e),T_.updateMatrix(),this.applyMatrix4(T_.matrix),this},fromBufferGeometry:function(e){var n=this,i=e.index!==null?e.index.array:void 0,l=e.attributes;if(l.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var h=l.position.array,p=l.normal!==void 0?l.normal.array:void 0,_=l.color!==void 0?l.color.array:void 0,s=l.uv!==void 0?l.uv.array:void 0,M=l.uv2!==void 0?l.uv2.array:void 0;M!==void 0&&(this.faceVertexUvs[1]=[]);for(var T=0;T<h.length;T+=3)n.vertices.push(new Ee().fromArray(h,T)),_!==void 0&&n.colors.push(new en().fromArray(_,T));function C(q,ee,he,Ce){var K=_===void 0?[]:[n.colors[q].clone(),n.colors[ee].clone(),n.colors[he].clone()],ie=p===void 0?[]:[new Ee().fromArray(p,q*3),new Ee().fromArray(p,ee*3),new Ee().fromArray(p,he*3)],ue=new rf(q,ee,he,ie,K,Ce);n.faces.push(ue),s!==void 0&&n.faceVertexUvs[0].push([new Lt().fromArray(s,q*2),new Lt().fromArray(s,ee*2),new Lt().fromArray(s,he*2)]),M!==void 0&&n.faceVertexUvs[1].push([new Lt().fromArray(M,q*2),new Lt().fromArray(M,ee*2),new Lt().fromArray(M,he*2)])}var E=e.groups;if(E.length>0)for(var T=0;T<E.length;T++)for(var L=E[T],I=L.start,B=L.count,O=I,U=I+B;O<U;O+=3)i!==void 0?C(i[O],i[O+1],i[O+2],L.materialIndex):C(O,O+1,O+2,L.materialIndex);else if(i!==void 0)for(var T=0;T<i.length;T+=3)C(i[T],i[T+1],i[T+2]);else for(var T=0;T<h.length/3;T+=3)C(T,T+1,T+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(uf).negate(),this.translate(uf.x,uf.y,uf.z),this},normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,n=this.boundingSphere.radius,i=n===0?1:1/n,l=new jn;return l.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(l),this},computeFaceNormals:function(){for(var e=new Ee,n=new Ee,i=0,l=this.faces.length;i<l;i++){var h=this.faces[i],p=this.vertices[h.a],_=this.vertices[h.b],s=this.vertices[h.c];e.subVectors(s,_),n.subVectors(p,_),e.cross(n),e.normalize(),h.normal.copy(e)}},computeVertexNormals:function(e){e===void 0&&(e=!0);var n,i,l,h,p,_;for(_=new Array(this.vertices.length),n=0,i=this.vertices.length;n<i;n++)_[n]=new Ee;if(e){var s,M,T,C=new Ee,E=new Ee;for(l=0,h=this.faces.length;l<h;l++)p=this.faces[l],s=this.vertices[p.a],M=this.vertices[p.b],T=this.vertices[p.c],C.subVectors(T,M),E.subVectors(s,M),C.cross(E),_[p.a].add(C),_[p.b].add(C),_[p.c].add(C)}else for(this.computeFaceNormals(),l=0,h=this.faces.length;l<h;l++)p=this.faces[l],_[p.a].add(p.normal),_[p.b].add(p.normal),_[p.c].add(p.normal);for(n=0,i=this.vertices.length;n<i;n++)_[n].normalize();for(l=0,h=this.faces.length;l<h;l++){p=this.faces[l];var L=p.vertexNormals;L.length===3?(L[0].copy(_[p.a]),L[1].copy(_[p.b]),L[2].copy(_[p.c])):(L[0]=_[p.a].clone(),L[1]=_[p.b].clone(),L[2]=_[p.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,n,i;for(this.computeFaceNormals(),e=0,n=this.faces.length;e<n;e++){i=this.faces[e];var l=i.vertexNormals;l.length===3?(l[0].copy(i.normal),l[1].copy(i.normal),l[2].copy(i.normal)):(l[0]=i.normal.clone(),l[1]=i.normal.clone(),l[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,n,i,l,h;for(i=0,l=this.faces.length;i<l;i++)for(h=this.faces[i],h.__originalFaceNormal?h.__originalFaceNormal.copy(h.normal):h.__originalFaceNormal=h.normal.clone(),h.__originalVertexNormals||(h.__originalVertexNormals=[]),e=0,n=h.vertexNormals.length;e<n;e++)h.__originalVertexNormals[e]?h.__originalVertexNormals[e].copy(h.vertexNormals[e]):h.__originalVertexNormals[e]=h.vertexNormals[e].clone();var p=new Fn;for(p.faces=this.faces,e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];var _=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals,T,C;for(i=0,l=this.faces.length;i<l;i++)T=new Ee,C={a:new Ee,b:new Ee,c:new Ee},_.push(T),s.push(C)}var M=this.morphNormals[e];p.vertices=this.morphTargets[e].vertices,p.computeFaceNormals(),p.computeVertexNormals();var T,C;for(i=0,l=this.faces.length;i<l;i++)h=this.faces[i],T=M.faceNormals[i],C=M.vertexNormals[i],T.copy(h.normal),C.a.copy(h.vertexNormals[0]),C.b.copy(h.vertexNormals[1]),C.c.copy(h.vertexNormals[2])}for(i=0,l=this.faces.length;i<l;i++)h=this.faces[i],h.normal=h.__originalFaceNormal,h.vertexNormals=h.__originalVertexNormals},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new Pa),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new Co),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,n,i){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}var l,h=this.vertices.length,p=this.vertices,_=e.vertices,s=this.faces,M=e.faces,T=this.colors,C=e.colors;i===void 0&&(i=0),n!==void 0&&(l=new dr().getNormalMatrix(n));for(var E=0,L=_.length;E<L;E++){var I=_[E],B=I.clone();n!==void 0&&B.applyMatrix4(n),p.push(B)}for(var E=0,L=C.length;E<L;E++)T.push(C[E].clone());for(E=0,L=M.length;E<L;E++){var O=M[E],U,q,ee,he=O.vertexNormals,Ce=O.vertexColors;U=new rf(O.a+h,O.b+h,O.c+h),U.normal.copy(O.normal),l!==void 0&&U.normal.applyMatrix3(l).normalize();for(var K=0,ie=he.length;K<ie;K++)q=he[K].clone(),l!==void 0&&q.applyMatrix3(l).normalize(),U.vertexNormals.push(q);U.color.copy(O.color);for(var K=0,ie=Ce.length;K<ie;K++)ee=Ce[K],U.vertexColors.push(ee.clone());U.materialIndex=O.materialIndex+i,s.push(U)}for(var E=0,L=e.faceVertexUvs.length;E<L;E++){var ue=e.faceVertexUvs[E];this.faceVertexUvs[E]===void 0&&(this.faceVertexUvs[E]=[]);for(var K=0,ie=ue.length;K<ie;K++){for(var ae=ue[K],le=[],De=0,ye=ae.length;De<ye;De++)le.push(ae[De].clone());this.faceVertexUvs[E].push(le)}}},mergeMesh:function(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)},mergeVertices:function(){var e={},n=[],i=[],l,h,p=4,_=Math.pow(10,p),s,M,T,C,E,L;for(s=0,M=this.vertices.length;s<M;s++)l=this.vertices[s],h=Math.round(l.x*_)+"_"+Math.round(l.y*_)+"_"+Math.round(l.z*_),e[h]===void 0?(e[h]=s,n.push(this.vertices[s]),i[s]=n.length-1):i[s]=i[e[h]];var I=[];for(s=0,M=this.faces.length;s<M;s++){T=this.faces[s],T.a=i[T.a],T.b=i[T.b],T.c=i[T.c],C=[T.a,T.b,T.c];for(var B=0;B<3;B++)if(C[B]===C[(B+1)%3]){I.push(s);break}}for(s=I.length-1;s>=0;s--){var O=I[s];for(this.faces.splice(O,1),E=0,L=this.faceVertexUvs.length;E<L;E++)this.faceVertexUvs[E].splice(O,1)}var U=this.vertices.length-n.length;return this.vertices=n,U},setFromPoints:function(e){this.vertices=[];for(var n=0,i=e.length;n<i;n++){var l=e[n];this.vertices.push(new Ee(l.x,l.y,l.z||0))}return this},sortFacesByMaterialIndex:function(){for(var e=this.faces,n=e.length,i=0;i<n;i++)e[i]._id=i;function l(T,C){return T.materialIndex-C.materialIndex}e.sort(l);var h=this.faceVertexUvs[0],p=this.faceVertexUvs[1],_,s;h&&h.length===n&&(_=[]),p&&p.length===n&&(s=[]);for(var i=0;i<n;i++){var M=e[i]._id;_&&_.push(h[M]),s&&s.push(p[M])}_&&(this.faceVertexUvs[0]=_),s&&(this.faceVertexUvs[1]=s)},toJSON:function(){var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){var n=this.parameters;for(var i in n)n[i]!==void 0&&(e[i]=n[i]);return e}for(var l=[],h=0;h<this.vertices.length;h++){var p=this.vertices[h];l.push(p.x,p.y,p.z)}for(var _=[],s=[],M={},T=[],C={},E=[],L={},h=0;h<this.faces.length;h++){var I=this.faces[h],B=!0,O=!1,U=this.faceVertexUvs[0][h]!==void 0,q=I.normal.length()>0,ee=I.vertexNormals.length>0,he=I.color.r!==1||I.color.g!==1||I.color.b!==1,Ce=I.vertexColors.length>0,K=0;if(K=le(K,0,0),K=le(K,1,B),K=le(K,2,O),K=le(K,3,U),K=le(K,4,q),K=le(K,5,ee),K=le(K,6,he),K=le(K,7,Ce),_.push(K),_.push(I.a,I.b,I.c),_.push(I.materialIndex),U){var ie=this.faceVertexUvs[0][h];_.push(se(ie[0]),se(ie[1]),se(ie[2]))}if(q&&_.push(De(I.normal)),ee){var ue=I.vertexNormals;_.push(De(ue[0]),De(ue[1]),De(ue[2]))}if(he&&_.push(ye(I.color)),Ce){var ae=I.vertexColors;_.push(ye(ae[0]),ye(ae[1]),ye(ae[2]))}}function le(Ue,Oe,We){return We?Ue|1<<Oe:Ue&~(1<<Oe)}function De(Ue){var Oe=Ue.x.toString()+Ue.y.toString()+Ue.z.toString();return M[Oe]!==void 0||(M[Oe]=s.length/3,s.push(Ue.x,Ue.y,Ue.z)),M[Oe]}function ye(Ue){var Oe=Ue.r.toString()+Ue.g.toString()+Ue.b.toString();return C[Oe]!==void 0||(C[Oe]=T.length,T.push(Ue.getHex())),C[Oe]}function se(Ue){var Oe=Ue.x.toString()+Ue.y.toString();return L[Oe]!==void 0||(L[Oe]=E.length/2,E.push(Ue.x,Ue.y)),L[Oe]}return e.data={},e.data.vertices=l,e.data.normals=s,T.length>0&&(e.data.colors=T),E.length>0&&(e.data.uvs=[E]),e.data.faces=_,e},clone:function(){return new Fn().copy(this)},copy:function(e){var n,i,l,h,p,_;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(n=0,i=s.length;n<i;n++)this.vertices.push(s[n].clone());var M=e.colors;for(n=0,i=M.length;n<i;n++)this.colors.push(M[n].clone());var T=e.faces;for(n=0,i=T.length;n<i;n++)this.faces.push(T[n].clone());for(n=0,i=e.faceVertexUvs.length;n<i;n++){var C=e.faceVertexUvs[n];for(this.faceVertexUvs[n]===void 0&&(this.faceVertexUvs[n]=[]),l=0,h=C.length;l<h;l++){var E=C[l],L=[];for(p=0,_=E.length;p<_;p++){var I=E[p];L.push(I.clone())}this.faceVertexUvs[n].push(L)}}var B=e.morphTargets;for(n=0,i=B.length;n<i;n++){var O={};if(O.name=B[n].name,B[n].vertices!==void 0)for(O.vertices=[],l=0,h=B[n].vertices.length;l<h;l++)O.vertices.push(B[n].vertices[l].clone());if(B[n].normals!==void 0)for(O.normals=[],l=0,h=B[n].normals.length;l<h;l++)O.normals.push(B[n].normals[l].clone());this.morphTargets.push(O)}var U=e.morphNormals;for(n=0,i=U.length;n<i;n++){var q={};if(U[n].vertexNormals!==void 0)for(q.vertexNormals=[],l=0,h=U[n].vertexNormals.length;l<h;l++){var ee=U[n].vertexNormals[l],he={};he.a=ee.a.clone(),he.b=ee.b.clone(),he.c=ee.c.clone(),q.vertexNormals.push(he)}if(U[n].faceNormals!==void 0)for(q.faceNormals=[],l=0,h=U[n].faceNormals.length;l<h;l++)q.faceNormals.push(U[n].faceNormals[l].clone());this.morphNormals.push(q)}var Ce=e.skinWeights;for(n=0,i=Ce.length;n<i;n++)this.skinWeights.push(Ce[n].clone());var K=e.skinIndices;for(n=0,i=K.length;n<i;n++)this.skinIndices.push(K[n].clone());var ie=e.lineDistances;for(n=0,i=ie.length;n<i;n++)this.lineDistances.push(ie[n]);var ue=e.boundingBox;ue!==null&&(this.boundingBox=ue.clone());var ae=e.boundingSphere;return ae!==null&&(this.boundingSphere=ae.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});class C2 extends Fn{constructor(n,i,l,h,p,_){super(),this.type="BoxGeometry",this.parameters={width:n,height:i,depth:l,widthSegments:h,heightSegments:p,depthSegments:_},this.fromBufferGeometry(new hf(n,i,l,h,p,_)),this.mergeVertices()}}class hf extends yn{constructor(n,i,l,h,p,_){super(),this.type="BoxBufferGeometry",this.parameters={width:n,height:i,depth:l,widthSegments:h,heightSegments:p,depthSegments:_};var s=this;n=n||1,i=i||1,l=l||1,h=Math.floor(h)||1,p=Math.floor(p)||1,_=Math.floor(_)||1;var M=[],T=[],C=[],E=[],L=0,I=0;B("z","y","x",-1,-1,l,i,n,_,p,0),B("z","y","x",1,-1,l,i,-n,_,p,1),B("x","z","y",1,1,n,l,i,h,_,2),B("x","z","y",1,-1,n,l,-i,h,_,3),B("x","y","z",1,-1,n,i,l,h,p,4),B("x","y","z",-1,-1,n,i,-l,h,p,5),this.setIndex(M),this.setAttribute("position",new sn(T,3)),this.setAttribute("normal",new sn(C,3)),this.setAttribute("uv",new sn(E,2));function B(O,U,q,ee,he,Ce,K,ie,ue,ae,le){var De=Ce/ue,ye=K/ae,se=Ce/2,Ue=K/2,Oe=ie/2,We=ue+1,st=ae+1,St=0,gt=0,At,Dt,Ot=new Ee;for(Dt=0;Dt<st;Dt++){var Pe=Dt*ye-Ue;for(At=0;At<We;At++){var ge=At*De-se;Ot[O]=ge*ee,Ot[U]=Pe*he,Ot[q]=Oe,T.push(Ot.x,Ot.y,Ot.z),Ot[O]=0,Ot[U]=0,Ot[q]=ie>0?1:-1,C.push(Ot.x,Ot.y,Ot.z),E.push(At/ue),E.push(1-Dt/ae),St+=1}}for(Dt=0;Dt<ae;Dt++)for(At=0;At<ue;At++){var Ve=L+At+We*Dt,Ne=L+At+We*(Dt+1),Ie=L+(At+1)+We*(Dt+1),it=L+(At+1)+We*Dt;M.push(Ve,Ne,it),M.push(Ne,Ie,it),gt+=6}s.addGroup(I,gt,le),I+=gt,L+=St}}}function vc(e){var n={};for(var i in e){n[i]={};for(var l in e[i]){var h=e[i][l];h&&(h.isColor||h.isMatrix3||h.isMatrix4||h.isVector2||h.isVector3||h.isVector4||h.isTexture)?n[i][l]=h.clone():Array.isArray(h)?n[i][l]=h.slice():n[i][l]=h}}return n}function pr(e){for(var n={},i=0;i<e.length;i++){var l=vc(e[i]);for(var h in l)n[h]=l[h]}return n}var P2={clone:vc,merge:pr},L2=`void main() {
  12. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  13. }`,D2=`void main() {
  14. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  15. }`;function Nr(e){Rn.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=L2,this.fragmentShader=D2,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}Nr.prototype=Object.create(Rn.prototype),Nr.prototype.constructor=Nr,Nr.prototype.isShaderMaterial=!0,Nr.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=vc(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},Nr.prototype.toJSON=function(e){var n=Rn.prototype.toJSON.call(this,e);n.uniforms={};for(var i in this.uniforms){var l=this.uniforms[i],h=l.value;h&&h.isTexture?n.uniforms[i]={type:"t",value:h.toJSON(e).uuid}:h&&h.isColor?n.uniforms[i]={type:"c",value:h.getHex()}:h&&h.isVector2?n.uniforms[i]={type:"v2",value:h.toArray()}:h&&h.isVector3?n.uniforms[i]={type:"v3",value:h.toArray()}:h&&h.isVector4?n.uniforms[i]={type:"v4",value:h.toArray()}:h&&h.isMatrix3?n.uniforms[i]={type:"m3",value:h.toArray()}:h&&h.isMatrix4?n.uniforms[i]={type:"m4",value:h.toArray()}:n.uniforms[i]={value:h}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader;var p={};for(var _ in this.extensions)this.extensions[_]===!0&&(p[_]=!0);return Object.keys(p).length>0&&(n.extensions=p),n};function Io(){rn.call(this),this.type="Camera",this.matrixWorldInverse=new jn,this.projectionMatrix=new jn,this.projectionMatrixInverse=new jn}Io.prototype=Object.assign(Object.create(rn.prototype),{constructor:Io,isCamera:!0,copy:function(e,n){return rn.prototype.copy.call(this,e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new Ee),this.updateMatrixWorld(!0);var n=this.matrixWorld.elements;return e.set(-n[8],-n[9],-n[10]).normalize()},updateMatrixWorld:function(e){rn.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,n){rn.prototype.updateWorldMatrix.call(this,e,n),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function Xi(e,n,i,l){Io.call(this),this.type="PerspectiveCamera",this.fov=e!==void 0?e:50,this.zoom=1,this.near=i!==void 0?i:.1,this.far=l!==void 0?l:2e3,this.focus=10,this.aspect=n!==void 0?n:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Xi.prototype=Object.assign(Object.create(Io.prototype),{constructor:Xi,isPerspectiveCamera:!0,copy:function(e,n){return Io.prototype.copy.call(this,e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var n=.5*this.getFilmHeight()/e;this.fov=Wn.RAD2DEG*2*Math.atan(n),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(Wn.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return Wn.RAD2DEG*2*Math.atan(Math.tan(Wn.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,n,i,l,h,p){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=l,this.view.width=h,this.view.height=p,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,n=e*Math.tan(Wn.DEG2RAD*.5*this.fov)/this.zoom,i=2*n,l=this.aspect*i,h=-.5*l,p=this.view;if(this.view!==null&&this.view.enabled){var _=p.fullWidth,s=p.fullHeight;h+=p.offsetX*l/_,n-=p.offsetY*i/s,l*=p.width/_,i*=p.height/s}var M=this.filmOffset;M!==0&&(h+=e*M/this.getFilmWidth()),this.projectionMatrix.makePerspective(h,h+l,n,n-i,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var n=rn.prototype.toJSON.call(this,e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}});var xc=90,bc=1;function bh(e,n,i,l){rn.call(this),this.type="CubeCamera";var h=new Xi(xc,bc,e,n);h.up.set(0,-1,0),h.lookAt(new Ee(1,0,0)),this.add(h);var p=new Xi(xc,bc,e,n);p.up.set(0,-1,0),p.lookAt(new Ee(-1,0,0)),this.add(p);var _=new Xi(xc,bc,e,n);_.up.set(0,0,1),_.lookAt(new Ee(0,1,0)),this.add(_);var s=new Xi(xc,bc,e,n);s.up.set(0,0,-1),s.lookAt(new Ee(0,-1,0)),this.add(s);var M=new Xi(xc,bc,e,n);M.up.set(0,-1,0),M.lookAt(new Ee(0,0,1)),this.add(M);var T=new Xi(xc,bc,e,n);T.up.set(0,-1,0),T.lookAt(new Ee(0,0,-1)),this.add(T),l=l||{format:Mo,magFilter:qi,minFilter:qi},this.renderTarget=new wc(i,l),this.renderTarget.texture.name="CubeCamera",this.update=function(C,E){this.parent===null&&this.updateMatrixWorld();var L=C.getRenderTarget(),I=this.renderTarget,B=I.texture.generateMipmaps;I.texture.generateMipmaps=!1,C.setRenderTarget(I,0),C.render(E,h),C.setRenderTarget(I,1),C.render(E,p),C.setRenderTarget(I,2),C.render(E,_),C.setRenderTarget(I,3),C.render(E,s),C.setRenderTarget(I,4),C.render(E,M),I.texture.generateMipmaps=B,C.setRenderTarget(I,5),C.render(E,T),C.setRenderTarget(L)},this.clear=function(C,E,L,I){for(var B=C.getRenderTarget(),O=this.renderTarget,U=0;U<6;U++)C.setRenderTarget(O,U),C.clear(E,L,I);C.setRenderTarget(B)}}bh.prototype=Object.create(rn.prototype),bh.prototype.constructor=bh;function wc(e,n,i){Number.isInteger(n)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),n=i),Mr.call(this,e,e,n)}wc.prototype=Object.create(Mr.prototype),wc.prototype.constructor=wc,wc.prototype.isWebGLCubeRenderTarget=!0,wc.prototype.fromEquirectangularTexture=function(e,n){this.texture.type=n.type,this.texture.format=n.format,this.texture.encoding=n.encoding;var i=new So,l={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {"," return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {"," vWorldDirection = transformDirection( position, modelMatrix );"," #include <begin_vertex>"," #include <project_vertex>","}"].join(`
  16. `),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {"," vec3 direction = normalize( vWorldDirection );"," vec2 sampleUV;"," sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;"," sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;"," gl_FragColor = texture2D( tEquirect, sampleUV );","}"].join(`
  17. `)},h=new Nr({type:"CubemapFromEquirect",uniforms:vc(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,side:tr,blending:Qo});h.uniforms.tEquirect.value=n;var p=new Ai(new hf(5,5,5),h);i.add(p);var _=new bh(1,10,1);return _.renderTarget=this,_.renderTarget.texture.name="CubeCameraTexture",_.update(e,i),p.geometry.dispose(),p.material.dispose(),this};function Mc(e,n,i,l,h,p,_,s,M,T,C,E){mi.call(this,null,p,_,s,M,T,l,h,C,E),this.image={data:e||null,width:n||1,height:i||1},this.magFilter=M!==void 0?M:Ui,this.minFilter=T!==void 0?T:Ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Mc.prototype=Object.create(mi.prototype),Mc.prototype.constructor=Mc,Mc.prototype.isDataTexture=!0;var Tc=new Co,df=new Ee;function wh(e,n,i,l,h,p){this.planes=[e!==void 0?e:new ja,n!==void 0?n:new ja,i!==void 0?i:new ja,l!==void 0?l:new ja,h!==void 0?h:new ja,p!==void 0?p:new ja]}Object.assign(wh.prototype,{set:function(e,n,i,l,h,p){var _=this.planes;return _[0].copy(e),_[1].copy(n),_[2].copy(i),_[3].copy(l),_[4].copy(h),_[5].copy(p),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){for(var n=this.planes,i=0;i<6;i++)n[i].copy(e.planes[i]);return this},setFromProjectionMatrix:function(e){var n=this.planes,i=e.elements,l=i[0],h=i[1],p=i[2],_=i[3],s=i[4],M=i[5],T=i[6],C=i[7],E=i[8],L=i[9],I=i[10],B=i[11],O=i[12],U=i[13],q=i[14],ee=i[15];return n[0].setComponents(_-l,C-s,B-E,ee-O).normalize(),n[1].setComponents(_+l,C+s,B+E,ee+O).normalize(),n[2].setComponents(_+h,C+M,B+L,ee+U).normalize(),n[3].setComponents(_-h,C-M,B-L,ee-U).normalize(),n[4].setComponents(_-p,C-T,B-I,ee-q).normalize(),n[5].setComponents(_+p,C+T,B+I,ee+q).normalize(),this},intersectsObject:function(e){var n=e.geometry;return n.boundingSphere===null&&n.computeBoundingSphere(),Tc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Tc)},intersectsSprite:function(e){return Tc.center.set(0,0,0),Tc.radius=.7071067811865476,Tc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Tc)},intersectsSphere:function(e){for(var n=this.planes,i=e.center,l=-e.radius,h=0;h<6;h++){var p=n[h].distanceToPoint(i);if(p<l)return!1}return!0},intersectsBox:function(e){for(var n=this.planes,i=0;i<6;i++){var l=n[i];if(df.x=l.normal.x>0?e.max.x:e.min.x,df.y=l.normal.y>0?e.max.y:e.min.y,df.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(df)<0)return!1}return!0},containsPoint:function(e){for(var n=this.planes,i=0;i<6;i++)if(n[i].distanceToPoint(e)<0)return!1;return!0}});var an={common:{diffuse:{value:new en(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new dr},uv2Transform:{value:new dr},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Lt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new en(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new en(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new dr}},sprite:{diffuse:{value:new en(15658734)},opacity:{value:1},center:{value:new Lt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new dr}}};function W0(){var e=null,n=!1,i=null;function l(h,p){n!==!1&&(i(h,p),e.requestAnimationFrame(l))}return{start:function(){n!==!0&&i!==null&&(e.requestAnimationFrame(l),n=!0)},stop:function(){n=!1},setAnimationLoop:function(h){i=h},setContext:function(h){e=h}}}function I2(e,n){var i=n.isWebGL2,l=new WeakMap;function h(T,C){var E=T.array,L=T.usage,I=e.createBuffer();e.bindBuffer(C,I),e.bufferData(C,E,L),T.onUploadCallback();var B=5126;return E instanceof Float32Array?B=5126:E instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):E instanceof Uint16Array?B=5123:E instanceof Int16Array?B=5122:E instanceof Uint32Array?B=5125:E instanceof Int32Array?B=5124:E instanceof Int8Array?B=5120:E instanceof Uint8Array&&(B=5121),{buffer:I,type:B,bytesPerElement:E.BYTES_PER_ELEMENT,version:T.version}}function p(T,C,E){var L=C.array,I=C.updateRange;e.bindBuffer(E,T),I.count===-1?e.bufferSubData(E,0,L):(i?e.bufferSubData(E,I.offset*L.BYTES_PER_ELEMENT,L,I.offset,I.count):e.bufferSubData(E,I.offset*L.BYTES_PER_ELEMENT,L.subarray(I.offset,I.offset+I.count)),I.count=-1)}function _(T){return T.isInterleavedBufferAttribute&&(T=T.data),l.get(T)}function s(T){T.isInterleavedBufferAttribute&&(T=T.data);var C=l.get(T);C&&(e.deleteBuffer(C.buffer),l.delete(T))}function M(T,C){T.isInterleavedBufferAttribute&&(T=T.data);var E=l.get(T);E===void 0?l.set(T,h(T,C)):E.version<T.version&&(p(E.buffer,T,C),E.version=T.version)}return{get:_,remove:s,update:M}}function pf(e,n,i,l){Fn.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:i,heightSegments:l},this.fromBufferGeometry(new Ec(e,n,i,l)),this.mergeVertices()}pf.prototype=Object.create(Fn.prototype),pf.prototype.constructor=pf;function Ec(e,n,i,l){yn.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:n,widthSegments:i,heightSegments:l},e=e||1,n=n||1;var h=e/2,p=n/2,_=Math.floor(i)||1,s=Math.floor(l)||1,M=_+1,T=s+1,C=e/_,E=n/s,L,I,B=[],O=[],U=[],q=[];for(I=0;I<T;I++){var ee=I*E-p;for(L=0;L<M;L++){var he=L*C-h;O.push(he,-ee,0),U.push(0,0,1),q.push(L/_),q.push(1-I/s)}}for(I=0;I<s;I++)for(L=0;L<_;L++){var Ce=L+M*I,K=L+M*(I+1),ie=L+1+M*(I+1),ue=L+1+M*I;B.push(Ce,K,ue),B.push(K,ie,ue)}this.setIndex(B),this.setAttribute("position",new sn(O,3)),this.setAttribute("normal",new sn(U,3)),this.setAttribute("uv",new sn(q,2))}Ec.prototype=Object.create(yn.prototype),Ec.prototype.constructor=Ec;var R2=`#ifdef USE_ALPHAMAP
  18. diffuseColor.a *= texture2D( alphaMap, vUv ).g;
  19. #endif`,z2=`#ifdef USE_ALPHAMAP
  20. uniform sampler2D alphaMap;
  21. #endif`,k2=`#ifdef ALPHATEST
  22. if ( diffuseColor.a < ALPHATEST ) discard;
  23. #endif`,B2=`#ifdef USE_AOMAP
  24. float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
  25. reflectedLight.indirectDiffuse *= ambientOcclusion;
  26. #if defined( USE_ENVMAP ) && defined( STANDARD )
  27. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  28. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
  29. #endif
  30. #endif`,F2=`#ifdef USE_AOMAP
  31. uniform sampler2D aoMap;
  32. uniform float aoMapIntensity;
  33. #endif`,O2="vec3 transformed = vec3( position );",N2=`vec3 objectNormal = vec3( normal );
  34. #ifdef USE_TANGENT
  35. vec3 objectTangent = vec3( tangent.xyz );
  36. #endif`,U2=`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
  37. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  38. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  39. vec4 r = roughness * c0 + c1;
  40. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  41. return vec2( -1.04, 1.04 ) * a004 + r.zw;
  42. }
  43. float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  44. #if defined ( PHYSICALLY_CORRECT_LIGHTS )
  45. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  46. if( cutoffDistance > 0.0 ) {
  47. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  48. }
  49. return distanceFalloff;
  50. #else
  51. if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  52. return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
  53. }
  54. return 1.0;
  55. #endif
  56. }
  57. vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
  58. return RECIPROCAL_PI * diffuseColor;
  59. }
  60. vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
  61. float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
  62. return ( 1.0 - specularColor ) * fresnel + specularColor;
  63. }
  64. vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
  65. float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
  66. vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
  67. return Fr * fresnel + F0;
  68. }
  69. float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
  70. float a2 = pow2( alpha );
  71. float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  72. float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  73. return 1.0 / ( gl * gv );
  74. }
  75. float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  76. float a2 = pow2( alpha );
  77. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  78. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  79. return 0.5 / max( gv + gl, EPSILON );
  80. }
  81. float D_GGX( const in float alpha, const in float dotNH ) {
  82. float a2 = pow2( alpha );
  83. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  84. return RECIPROCAL_PI * a2 / pow2( denom );
  85. }
  86. vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
  87. float alpha = pow2( roughness );
  88. vec3 halfDir = normalize( incidentLight.direction + viewDir );
  89. float dotNL = saturate( dot( normal, incidentLight.direction ) );
  90. float dotNV = saturate( dot( normal, viewDir ) );
  91. float dotNH = saturate( dot( normal, halfDir ) );
  92. float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
  93. vec3 F = F_Schlick( specularColor, dotLH );
  94. float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  95. float D = D_GGX( alpha, dotNH );
  96. return F * ( G * D );
  97. }
  98. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  99. const float LUT_SIZE = 64.0;
  100. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  101. const float LUT_BIAS = 0.5 / LUT_SIZE;
  102. float dotNV = saturate( dot( N, V ) );
  103. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  104. uv = uv * LUT_SCALE + LUT_BIAS;
  105. return uv;
  106. }
  107. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  108. float l = length( f );
  109. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  110. }
  111. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  112. float x = dot( v1, v2 );
  113. float y = abs( x );
  114. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  115. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  116. float v = a / b;
  117. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  118. return cross( v1, v2 ) * theta_sintheta;
  119. }
  120. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  121. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  122. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  123. vec3 lightNormal = cross( v1, v2 );
  124. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  125. vec3 T1, T2;
  126. T1 = normalize( V - N * dot( V, N ) );
  127. T2 = - cross( N, T1 );
  128. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  129. vec3 coords[ 4 ];
  130. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  131. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  132. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  133. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  134. coords[ 0 ] = normalize( coords[ 0 ] );
  135. coords[ 1 ] = normalize( coords[ 1 ] );
  136. coords[ 2 ] = normalize( coords[ 2 ] );
  137. coords[ 3 ] = normalize( coords[ 3 ] );
  138. vec3 vectorFormFactor = vec3( 0.0 );
  139. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  140. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  141. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  142. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  143. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  144. return vec3( result );
  145. }
  146. vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
  147. float dotNV = saturate( dot( normal, viewDir ) );
  148. vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
  149. return specularColor * brdf.x + brdf.y;
  150. }
  151. void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  152. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  153. vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
  154. vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
  155. vec3 FssEss = F * brdf.x + brdf.y;
  156. float Ess = brdf.x + brdf.y;
  157. float Ems = 1.0 - Ess;
  158. vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  159. singleScatter += FssEss;
  160. multiScatter += Fms * Ems;
  161. }
  162. float G_BlinnPhong_Implicit( ) {
  163. return 0.25;
  164. }
  165. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  166. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  167. }
  168. vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
  169. vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
  170. float dotNH = saturate( dot( geometry.normal, halfDir ) );
  171. float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
  172. vec3 F = F_Schlick( specularColor, dotLH );
  173. float G = G_BlinnPhong_Implicit( );
  174. float D = D_BlinnPhong( shininess, dotNH );
  175. return F * ( G * D );
  176. }
  177. float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
  178. return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
  179. }
  180. float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
  181. return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
  182. }
  183. #if defined( USE_SHEEN )
  184. float D_Charlie(float roughness, float NoH) {
  185. float invAlpha = 1.0 / roughness;
  186. float cos2h = NoH * NoH;
  187. float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
  188. }
  189. float V_Neubelt(float NoV, float NoL) {
  190. return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
  191. }
  192. vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
  193. vec3 N = geometry.normal;
  194. vec3 V = geometry.viewDir;
  195. vec3 H = normalize( V + L );
  196. float dotNH = saturate( dot( N, H ) );
  197. return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
  198. }
  199. #endif`,V2=`#ifdef USE_BUMPMAP
  200. uniform sampler2D bumpMap;
  201. uniform float bumpScale;
  202. vec2 dHdxy_fwd() {
  203. vec2 dSTdx = dFdx( vUv );
  204. vec2 dSTdy = dFdy( vUv );
  205. float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
  206. float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
  207. float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
  208. return vec2( dBx, dBy );
  209. }
  210. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
  211. vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
  212. vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
  213. vec3 vN = surf_norm;
  214. vec3 R1 = cross( vSigmaY, vN );
  215. vec3 R2 = cross( vN, vSigmaX );
  216. float fDet = dot( vSigmaX, R1 );
  217. fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  218. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  219. return normalize( abs( fDet ) * surf_norm - vGrad );
  220. }
  221. #endif`,G2=`#if NUM_CLIPPING_PLANES > 0
  222. vec4 plane;
  223. #pragma unroll_loop
  224. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  225. plane = clippingPlanes[ i ];
  226. if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;
  227. }
  228. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  229. bool clipped = true;
  230. #pragma unroll_loop
  231. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  232. plane = clippingPlanes[ i ];
  233. clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;
  234. }
  235. if ( clipped ) discard;
  236. #endif
  237. #endif`,H2=`#if NUM_CLIPPING_PLANES > 0
  238. #if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
  239. varying vec3 vViewPosition;
  240. #endif
  241. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  242. #endif`,W2=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
  243. varying vec3 vViewPosition;
  244. #endif`,j2=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
  245. vViewPosition = - mvPosition.xyz;
  246. #endif`,q2=`#ifdef USE_COLOR
  247. diffuseColor.rgb *= vColor;
  248. #endif`,Z2=`#ifdef USE_COLOR
  249. varying vec3 vColor;
  250. #endif`,X2=`#ifdef USE_COLOR
  251. varying vec3 vColor;
  252. #endif`,Y2=`#ifdef USE_COLOR
  253. vColor.xyz = color.xyz;
  254. #endif`,$2=`#define PI 3.14159265359
  255. #define PI2 6.28318530718
  256. #define PI_HALF 1.5707963267949
  257. #define RECIPROCAL_PI 0.31830988618
  258. #define RECIPROCAL_PI2 0.15915494
  259. #define LOG2 1.442695
  260. #define EPSILON 1e-6
  261. #ifndef saturate
  262. #define saturate(a) clamp( a, 0.0, 1.0 )
  263. #endif
  264. #define whiteComplement(a) ( 1.0 - saturate( a ) )
  265. float pow2( const in float x ) { return x*x; }
  266. float pow3( const in float x ) { return x*x*x; }
  267. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  268. float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
  269. highp float rand( const in vec2 uv ) {
  270. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  271. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  272. return fract(sin(sn) * c);
  273. }
  274. #ifdef HIGH_PRECISION
  275. float precisionSafeLength( vec3 v ) { return length( v ); }
  276. #else
  277. float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  278. float precisionSafeLength( vec3 v ) {
  279. float maxComponent = max3( abs( v ) );
  280. return length( v / maxComponent ) * maxComponent;
  281. }
  282. #endif
  283. struct IncidentLight {
  284. vec3 color;
  285. vec3 direction;
  286. bool visible;
  287. };
  288. struct ReflectedLight {
  289. vec3 directDiffuse;
  290. vec3 directSpecular;
  291. vec3 indirectDiffuse;
  292. vec3 indirectSpecular;
  293. };
  294. struct GeometricContext {
  295. vec3 position;
  296. vec3 normal;
  297. vec3 viewDir;
  298. #ifdef CLEARCOAT
  299. vec3 clearcoatNormal;
  300. #endif
  301. };
  302. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  303. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  304. }
  305. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  306. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  307. }
  308. vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
  309. float distance = dot( planeNormal, point - pointOnPlane );
  310. return - distance * planeNormal + point;
  311. }
  312. float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
  313. return sign( dot( point - pointOnPlane, planeNormal ) );
  314. }
  315. vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
  316. return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
  317. }
  318. mat3 transposeMat3( const in mat3 m ) {
  319. mat3 tmp;
  320. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  321. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  322. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  323. return tmp;
  324. }
  325. float linearToRelativeLuminance( const in vec3 color ) {
  326. vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
  327. return dot( weights, color.rgb );
  328. }
  329. bool isPerspectiveMatrix( mat4 m ) {
  330. return m[ 2 ][ 3 ] == - 1.0;
  331. }`,J2=`#ifdef ENVMAP_TYPE_CUBE_UV
  332. #define cubeUV_maxMipLevel 8.0
  333. #define cubeUV_minMipLevel 4.0
  334. #define cubeUV_maxTileSize 256.0
  335. #define cubeUV_minTileSize 16.0
  336. float getFace(vec3 direction) {
  337. vec3 absDirection = abs(direction);
  338. float face = -1.0;
  339. if (absDirection.x > absDirection.z) {
  340. if (absDirection.x > absDirection.y)
  341. face = direction.x > 0.0 ? 0.0 : 3.0;
  342. else
  343. face = direction.y > 0.0 ? 1.0 : 4.0;
  344. } else {
  345. if (absDirection.z > absDirection.y)
  346. face = direction.z > 0.0 ? 2.0 : 5.0;
  347. else
  348. face = direction.y > 0.0 ? 1.0 : 4.0;
  349. }
  350. return face;
  351. }
  352. vec2 getUV(vec3 direction, float face) {
  353. vec2 uv;
  354. if (face == 0.0) {
  355. uv = vec2(-direction.z, direction.y) / abs(direction.x);
  356. } else if (face == 1.0) {
  357. uv = vec2(direction.x, -direction.z) / abs(direction.y);
  358. } else if (face == 2.0) {
  359. uv = direction.xy / abs(direction.z);
  360. } else if (face == 3.0) {
  361. uv = vec2(direction.z, direction.y) / abs(direction.x);
  362. } else if (face == 4.0) {
  363. uv = direction.xz / abs(direction.y);
  364. } else {
  365. uv = vec2(-direction.x, direction.y) / abs(direction.z);
  366. }
  367. return 0.5 * (uv + 1.0);
  368. }
  369. vec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
  370. float face = getFace(direction);
  371. float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
  372. mipInt = max(mipInt, cubeUV_minMipLevel);
  373. float faceSize = exp2(mipInt);
  374. float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
  375. vec2 uv = getUV(direction, face) * (faceSize - 1.0);
  376. vec2 f = fract(uv);
  377. uv += 0.5 - f;
  378. if (face > 2.0) {
  379. uv.y += faceSize;
  380. face -= 3.0;
  381. }
  382. uv.x += face * faceSize;
  383. if(mipInt < cubeUV_maxMipLevel){
  384. uv.y += 2.0 * cubeUV_maxTileSize;
  385. }
  386. uv.y += filterInt * 2.0 * cubeUV_minTileSize;
  387. uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
  388. uv *= texelSize;
  389. vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  390. uv.x += texelSize;
  391. vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  392. uv.y += texelSize;
  393. vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  394. uv.x -= texelSize;
  395. vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  396. vec3 tm = mix(tl, tr, f.x);
  397. vec3 bm = mix(bl, br, f.x);
  398. return mix(tm, bm, f.y);
  399. }
  400. #define r0 1.0
  401. #define v0 0.339
  402. #define m0 -2.0
  403. #define r1 0.8
  404. #define v1 0.276
  405. #define m1 -1.0
  406. #define r4 0.4
  407. #define v4 0.046
  408. #define m4 2.0
  409. #define r5 0.305
  410. #define v5 0.016
  411. #define m5 3.0
  412. #define r6 0.21
  413. #define v6 0.0038
  414. #define m6 4.0
  415. float roughnessToMip(float roughness) {
  416. float mip = 0.0;
  417. if (roughness >= r1) {
  418. mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
  419. } else if (roughness >= r4) {
  420. mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
  421. } else if (roughness >= r5) {
  422. mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
  423. } else if (roughness >= r6) {
  424. mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
  425. } else {
  426. mip = -2.0 * log2(1.16 * roughness); }
  427. return mip;
  428. }
  429. vec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {
  430. float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);
  431. float mipF = fract(mip);
  432. float mipInt = floor(mip);
  433. vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);
  434. if (mipF == 0.0) {
  435. return vec4(color0, 1.0);
  436. } else {
  437. vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);
  438. return vec4(mix(color0, color1, mipF), 1.0);
  439. }
  440. }
  441. #endif`,K2=`vec3 transformedNormal = objectNormal;
  442. #ifdef USE_INSTANCING
  443. transformedNormal = mat3( instanceMatrix ) * transformedNormal;
  444. #endif
  445. transformedNormal = normalMatrix * transformedNormal;
  446. #ifdef FLIP_SIDED
  447. transformedNormal = - transformedNormal;
  448. #endif
  449. #ifdef USE_TANGENT
  450. vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  451. #ifdef FLIP_SIDED
  452. transformedTangent = - transformedTangent;
  453. #endif
  454. #endif`,Q2=`#ifdef USE_DISPLACEMENTMAP
  455. uniform sampler2D displacementMap;
  456. uniform float displacementScale;
  457. uniform float displacementBias;
  458. #endif`,eE=`#ifdef USE_DISPLACEMENTMAP
  459. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
  460. #endif`,tE=`#ifdef USE_EMISSIVEMAP
  461. vec4 emissiveColor = texture2D( emissiveMap, vUv );
  462. emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
  463. totalEmissiveRadiance *= emissiveColor.rgb;
  464. #endif`,nE=`#ifdef USE_EMISSIVEMAP
  465. uniform sampler2D emissiveMap;
  466. #endif`,iE="gl_FragColor = linearToOutputTexel( gl_FragColor );",rE=`
  467. vec4 LinearToLinear( in vec4 value ) {
  468. return value;
  469. }
  470. vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
  471. return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
  472. }
  473. vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
  474. return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
  475. }
  476. vec4 sRGBToLinear( in vec4 value ) {
  477. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  478. }
  479. vec4 LinearTosRGB( in vec4 value ) {
  480. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  481. }
  482. vec4 RGBEToLinear( in vec4 value ) {
  483. return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
  484. }
  485. vec4 LinearToRGBE( in vec4 value ) {
  486. float maxComponent = max( max( value.r, value.g ), value.b );
  487. float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
  488. return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
  489. }
  490. vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
  491. return vec4( value.rgb * value.a * maxRange, 1.0 );
  492. }
  493. vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
  494. float maxRGB = max( value.r, max( value.g, value.b ) );
  495. float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
  496. M = ceil( M * 255.0 ) / 255.0;
  497. return vec4( value.rgb / ( M * maxRange ), M );
  498. }
  499. vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
  500. return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
  501. }
  502. vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
  503. float maxRGB = max( value.r, max( value.g, value.b ) );
  504. float D = max( maxRange / maxRGB, 1.0 );
  505. D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
  506. return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
  507. }
  508. const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
  509. vec4 LinearToLogLuv( in vec4 value ) {
  510. vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
  511. Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
  512. vec4 vResult;
  513. vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
  514. float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
  515. vResult.w = fract( Le );
  516. vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
  517. return vResult;
  518. }
  519. const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
  520. vec4 LogLuvToLinear( in vec4 value ) {
  521. float Le = value.z * 255.0 + value.w;
  522. vec3 Xp_Y_XYZp;
  523. Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
  524. Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
  525. Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
  526. vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
  527. return vec4( max( vRGB, 0.0 ), 1.0 );
  528. }`,aE=`#ifdef USE_ENVMAP
  529. #ifdef ENV_WORLDPOS
  530. vec3 cameraToFrag;
  531. if ( isOrthographic ) {
  532. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  533. } else {
  534. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  535. }
  536. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  537. #ifdef ENVMAP_MODE_REFLECTION
  538. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  539. #else
  540. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  541. #endif
  542. #else
  543. vec3 reflectVec = vReflect;
  544. #endif
  545. #ifdef ENVMAP_TYPE_CUBE
  546. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  548. vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
  549. #elif defined( ENVMAP_TYPE_EQUIREC )
  550. vec2 sampleUV;
  551. reflectVec = normalize( reflectVec );
  552. sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  553. sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
  554. vec4 envColor = texture2D( envMap, sampleUV );
  555. #elif defined( ENVMAP_TYPE_SPHERE )
  556. reflectVec = normalize( reflectVec );
  557. vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );
  558. vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
  559. #else
  560. vec4 envColor = vec4( 0.0 );
  561. #endif
  562. #ifndef ENVMAP_TYPE_CUBE_UV
  563. envColor = envMapTexelToLinear( envColor );
  564. #endif
  565. #ifdef ENVMAP_BLENDING_MULTIPLY
  566. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  567. #elif defined( ENVMAP_BLENDING_MIX )
  568. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  569. #elif defined( ENVMAP_BLENDING_ADD )
  570. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  571. #endif
  572. #endif`,oE=`#ifdef USE_ENVMAP
  573. uniform float envMapIntensity;
  574. uniform float flipEnvMap;
  575. uniform int maxMipLevel;
  576. #ifdef ENVMAP_TYPE_CUBE
  577. uniform samplerCube envMap;
  578. #else
  579. uniform sampler2D envMap;
  580. #endif
  581. #endif`,sE=`#ifdef USE_ENVMAP
  582. uniform float reflectivity;
  583. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
  584. #define ENV_WORLDPOS
  585. #endif
  586. #ifdef ENV_WORLDPOS
  587. varying vec3 vWorldPosition;
  588. uniform float refractionRatio;
  589. #else
  590. varying vec3 vReflect;
  591. #endif
  592. #endif`,lE=`#ifdef USE_ENVMAP
  593. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
  594. #define ENV_WORLDPOS
  595. #endif
  596. #ifdef ENV_WORLDPOS
  597. varying vec3 vWorldPosition;
  598. #else
  599. varying vec3 vReflect;
  600. uniform float refractionRatio;
  601. #endif
  602. #endif`,cE=`#ifdef USE_ENVMAP
  603. #ifdef ENV_WORLDPOS
  604. vWorldPosition = worldPosition.xyz;
  605. #else
  606. vec3 cameraToVertex;
  607. if ( isOrthographic ) {
  608. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  609. } else {
  610. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  611. }
  612. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  613. #ifdef ENVMAP_MODE_REFLECTION
  614. vReflect = reflect( cameraToVertex, worldNormal );
  615. #else
  616. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  617. #endif
  618. #endif
  619. #endif`,uE=`#ifdef USE_FOG
  620. fogDepth = -mvPosition.z;
  621. #endif`,hE=`#ifdef USE_FOG
  622. varying float fogDepth;
  623. #endif`,dE=`#ifdef USE_FOG
  624. #ifdef FOG_EXP2
  625. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
  626. #else
  627. float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
  628. #endif
  629. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  630. #endif`,pE=`#ifdef USE_FOG
  631. uniform vec3 fogColor;
  632. varying float fogDepth;
  633. #ifdef FOG_EXP2
  634. uniform float fogDensity;
  635. #else
  636. uniform float fogNear;
  637. uniform float fogFar;
  638. #endif
  639. #endif`,fE=`#ifdef USE_GRADIENTMAP
  640. uniform sampler2D gradientMap;
  641. #endif
  642. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  643. float dotNL = dot( normal, lightDirection );
  644. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  645. #ifdef USE_GRADIENTMAP
  646. return texture2D( gradientMap, coord ).rgb;
  647. #else
  648. return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
  649. #endif
  650. }`,mE=`#ifdef USE_LIGHTMAP
  651. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  652. reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  653. #endif`,gE=`#ifdef USE_LIGHTMAP
  654. uniform sampler2D lightMap;
  655. uniform float lightMapIntensity;
  656. #endif`,_E=`vec3 diffuse = vec3( 1.0 );
  657. GeometricContext geometry;
  658. geometry.position = mvPosition.xyz;
  659. geometry.normal = normalize( transformedNormal );
  660. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
  661. GeometricContext backGeometry;
  662. backGeometry.position = geometry.position;
  663. backGeometry.normal = -geometry.normal;
  664. backGeometry.viewDir = geometry.viewDir;
  665. vLightFront = vec3( 0.0 );
  666. vIndirectFront = vec3( 0.0 );
  667. #ifdef DOUBLE_SIDED
  668. vLightBack = vec3( 0.0 );
  669. vIndirectBack = vec3( 0.0 );
  670. #endif
  671. IncidentLight directLight;
  672. float dotNL;
  673. vec3 directLightColor_Diffuse;
  674. #if NUM_POINT_LIGHTS > 0
  675. #pragma unroll_loop
  676. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  677. getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
  678. dotNL = dot( geometry.normal, directLight.direction );
  679. directLightColor_Diffuse = PI * directLight.color;
  680. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  681. #ifdef DOUBLE_SIDED
  682. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  683. #endif
  684. }
  685. #endif
  686. #if NUM_SPOT_LIGHTS > 0
  687. #pragma unroll_loop
  688. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  689. getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
  690. dotNL = dot( geometry.normal, directLight.direction );
  691. directLightColor_Diffuse = PI * directLight.color;
  692. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  693. #ifdef DOUBLE_SIDED
  694. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  695. #endif
  696. }
  697. #endif
  698. #if NUM_DIR_LIGHTS > 0
  699. #pragma unroll_loop
  700. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  701. getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
  702. dotNL = dot( geometry.normal, directLight.direction );
  703. directLightColor_Diffuse = PI * directLight.color;
  704. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  705. #ifdef DOUBLE_SIDED
  706. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  707. #endif
  708. }
  709. #endif
  710. #if NUM_HEMI_LIGHTS > 0
  711. #pragma unroll_loop
  712. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  713. vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
  714. #ifdef DOUBLE_SIDED
  715. vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
  716. #endif
  717. }
  718. #endif`,yE=`uniform bool receiveShadow;
  719. uniform vec3 ambientLightColor;
  720. uniform vec3 lightProbe[ 9 ];
  721. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  722. float x = normal.x, y = normal.y, z = normal.z;
  723. vec3 result = shCoefficients[ 0 ] * 0.886227;
  724. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  725. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  726. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  727. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  728. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  729. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  730. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  731. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  732. return result;
  733. }
  734. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
  735. vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
  736. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  737. return irradiance;
  738. }
  739. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  740. vec3 irradiance = ambientLightColor;
  741. #ifndef PHYSICALLY_CORRECT_LIGHTS
  742. irradiance *= PI;
  743. #endif
  744. return irradiance;
  745. }
  746. #if NUM_DIR_LIGHTS > 0
  747. struct DirectionalLight {
  748. vec3 direction;
  749. vec3 color;
  750. int shadow;
  751. float shadowBias;
  752. float shadowRadius;
  753. vec2 shadowMapSize;
  754. };
  755. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  756. void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  757. directLight.color = directionalLight.color;
  758. directLight.direction = directionalLight.direction;
  759. directLight.visible = true;
  760. }
  761. #endif
  762. #if NUM_POINT_LIGHTS > 0
  763. struct PointLight {
  764. vec3 position;
  765. vec3 color;
  766. float distance;
  767. float decay;
  768. int shadow;
  769. float shadowBias;
  770. float shadowRadius;
  771. vec2 shadowMapSize;
  772. float shadowCameraNear;
  773. float shadowCameraFar;
  774. };
  775. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  776. void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  777. vec3 lVector = pointLight.position - geometry.position;
  778. directLight.direction = normalize( lVector );
  779. float lightDistance = length( lVector );
  780. directLight.color = pointLight.color;
  781. directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
  782. directLight.visible = ( directLight.color != vec3( 0.0 ) );
  783. }
  784. #endif
  785. #if NUM_SPOT_LIGHTS > 0
  786. struct SpotLight {
  787. vec3 position;
  788. vec3 direction;
  789. vec3 color;
  790. float distance;
  791. float decay;
  792. float coneCos;
  793. float penumbraCos;
  794. int shadow;
  795. float shadowBias;
  796. float shadowRadius;
  797. vec2 shadowMapSize;
  798. };
  799. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  800. void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  801. vec3 lVector = spotLight.position - geometry.position;
  802. directLight.direction = normalize( lVector );
  803. float lightDistance = length( lVector );
  804. float angleCos = dot( directLight.direction, spotLight.direction );
  805. if ( angleCos > spotLight.coneCos ) {
  806. float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  807. directLight.color = spotLight.color;
  808. directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
  809. directLight.visible = true;
  810. } else {
  811. directLight.color = vec3( 0.0 );
  812. directLight.visible = false;
  813. }
  814. }
  815. #endif
  816. #if NUM_RECT_AREA_LIGHTS > 0
  817. struct RectAreaLight {
  818. vec3 color;
  819. vec3 position;
  820. vec3 halfWidth;
  821. vec3 halfHeight;
  822. };
  823. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  824. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  825. #endif
  826. #if NUM_HEMI_LIGHTS > 0
  827. struct HemisphereLight {
  828. vec3 direction;
  829. vec3 skyColor;
  830. vec3 groundColor;
  831. };
  832. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  833. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
  834. float dotNL = dot( geometry.normal, hemiLight.direction );
  835. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  836. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  837. #ifndef PHYSICALLY_CORRECT_LIGHTS
  838. irradiance *= PI;
  839. #endif
  840. return irradiance;
  841. }
  842. #endif`,vE=`#if defined( USE_ENVMAP )
  843. #ifdef ENVMAP_MODE_REFRACTION
  844. uniform float refractionRatio;
  845. #endif
  846. vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
  847. vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
  848. #ifdef ENVMAP_TYPE_CUBE
  849. vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
  850. #ifdef TEXTURE_LOD_EXT
  851. vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
  852. #else
  853. vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
  854. #endif
  855. envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
  856. #elif defined( ENVMAP_TYPE_CUBE_UV )
  857. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  858. #else
  859. vec4 envMapColor = vec4( 0.0 );
  860. #endif
  861. return PI * envMapColor.rgb * envMapIntensity;
  862. }
  863. float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
  864. float maxMIPLevelScalar = float( maxMIPLevel );
  865. float sigma = PI * roughness * roughness / ( 1.0 + roughness );
  866. float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
  867. return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
  868. }
  869. vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
  870. #ifdef ENVMAP_MODE_REFLECTION
  871. vec3 reflectVec = reflect( -viewDir, normal );
  872. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  873. #else
  874. vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
  875. #endif
  876. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  877. float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
  878. #ifdef ENVMAP_TYPE_CUBE
  879. vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
  880. #ifdef TEXTURE_LOD_EXT
  881. vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
  882. #else
  883. vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
  884. #endif
  885. envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
  886. #elif defined( ENVMAP_TYPE_CUBE_UV )
  887. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  888. #elif defined( ENVMAP_TYPE_EQUIREC )
  889. vec2 sampleUV;
  890. sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  891. sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
  892. #ifdef TEXTURE_LOD_EXT
  893. vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );
  894. #else
  895. vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );
  896. #endif
  897. envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
  898. #elif defined( ENVMAP_TYPE_SPHERE )
  899. vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );
  900. #ifdef TEXTURE_LOD_EXT
  901. vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
  902. #else
  903. vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
  904. #endif
  905. envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
  906. #endif
  907. return envMapColor.rgb * envMapIntensity;
  908. }
  909. #endif`,xE=`ToonMaterial material;
  910. material.diffuseColor = diffuseColor.rgb;
  911. material.specularColor = specular;
  912. material.specularShininess = shininess;
  913. material.specularStrength = specularStrength;`,bE=`varying vec3 vViewPosition;
  914. #ifndef FLAT_SHADED
  915. varying vec3 vNormal;
  916. #endif
  917. struct ToonMaterial {
  918. vec3 diffuseColor;
  919. vec3 specularColor;
  920. float specularShininess;
  921. float specularStrength;
  922. };
  923. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  924. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  925. #ifndef PHYSICALLY_CORRECT_LIGHTS
  926. irradiance *= PI;
  927. #endif
  928. reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  929. reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
  930. }
  931. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  932. reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  933. }
  934. #define RE_Direct RE_Direct_Toon
  935. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
  936. #define Material_LightProbeLOD( material ) (0)`,wE=`BlinnPhongMaterial material;
  937. material.diffuseColor = diffuseColor.rgb;
  938. material.specularColor = specular;
  939. material.specularShininess = shininess;
  940. material.specularStrength = specularStrength;`,ME=`varying vec3 vViewPosition;
  941. #ifndef FLAT_SHADED
  942. varying vec3 vNormal;
  943. #endif
  944. struct BlinnPhongMaterial {
  945. vec3 diffuseColor;
  946. vec3 specularColor;
  947. float specularShininess;
  948. float specularStrength;
  949. };
  950. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  951. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  952. vec3 irradiance = dotNL * directLight.color;
  953. #ifndef PHYSICALLY_CORRECT_LIGHTS
  954. irradiance *= PI;
  955. #endif
  956. reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  957. reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
  958. }
  959. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  960. reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  961. }
  962. #define RE_Direct RE_Direct_BlinnPhong
  963. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
  964. #define Material_LightProbeLOD( material ) (0)`,TE=`PhysicalMaterial material;
  965. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  966. vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
  967. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  968. material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
  969. material.specularRoughness = min( material.specularRoughness, 1.0 );
  970. #ifdef REFLECTIVITY
  971. material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
  972. #else
  973. material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
  974. #endif
  975. #ifdef CLEARCOAT
  976. material.clearcoat = saturate( clearcoat ); material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );
  977. material.clearcoatRoughness += geometryRoughness;
  978. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  979. #endif
  980. #ifdef USE_SHEEN
  981. material.sheenColor = sheen;
  982. #endif`,EE=`struct PhysicalMaterial {
  983. vec3 diffuseColor;
  984. float specularRoughness;
  985. vec3 specularColor;
  986. #ifdef CLEARCOAT
  987. float clearcoat;
  988. float clearcoatRoughness;
  989. #endif
  990. #ifdef USE_SHEEN
  991. vec3 sheenColor;
  992. #endif
  993. };
  994. #define MAXIMUM_SPECULAR_COEFFICIENT 0.16
  995. #define DEFAULT_SPECULAR_COEFFICIENT 0.04
  996. float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
  997. return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
  998. }
  999. #if NUM_RECT_AREA_LIGHTS > 0
  1000. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1001. vec3 normal = geometry.normal;
  1002. vec3 viewDir = geometry.viewDir;
  1003. vec3 position = geometry.position;
  1004. vec3 lightPos = rectAreaLight.position;
  1005. vec3 halfWidth = rectAreaLight.halfWidth;
  1006. vec3 halfHeight = rectAreaLight.halfHeight;
  1007. vec3 lightColor = rectAreaLight.color;
  1008. float roughness = material.specularRoughness;
  1009. vec3 rectCoords[ 4 ];
  1010. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1011. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1012. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1013. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1014. vec4 t1 = texture2D( ltc_1, uv );
  1015. vec4 t2 = texture2D( ltc_2, uv );
  1016. mat3 mInv = mat3(
  1017. vec3( t1.x, 0, t1.y ),
  1018. vec3( 0, 1, 0 ),
  1019. vec3( t1.z, 0, t1.w )
  1020. );
  1021. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1022. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1023. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1024. }
  1025. #endif
  1026. void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1027. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  1028. vec3 irradiance = dotNL * directLight.color;
  1029. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1030. irradiance *= PI;
  1031. #endif
  1032. #ifdef CLEARCOAT
  1033. float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
  1034. vec3 ccIrradiance = ccDotNL * directLight.color;
  1035. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1036. ccIrradiance *= PI;
  1037. #endif
  1038. float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
  1039. reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
  1040. #else
  1041. float clearcoatDHR = 0.0;
  1042. #endif
  1043. #ifdef USE_SHEEN
  1044. reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
  1045. material.specularRoughness,
  1046. directLight.direction,
  1047. geometry,
  1048. material.sheenColor
  1049. );
  1050. #else
  1051. reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
  1052. #endif
  1053. reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  1054. }
  1055. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1056. reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  1057. }
  1058. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1059. #ifdef CLEARCOAT
  1060. float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
  1061. reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
  1062. float ccDotNL = ccDotNV;
  1063. float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
  1064. #else
  1065. float clearcoatDHR = 0.0;
  1066. #endif
  1067. float clearcoatInv = 1.0 - clearcoatDHR;
  1068. vec3 singleScattering = vec3( 0.0 );
  1069. vec3 multiScattering = vec3( 0.0 );
  1070. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1071. BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
  1072. vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
  1073. reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;
  1074. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1075. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1076. }
  1077. #define RE_Direct RE_Direct_Physical
  1078. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1079. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1080. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1081. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1082. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1083. }`,SE=`
  1084. GeometricContext geometry;
  1085. geometry.position = - vViewPosition;
  1086. geometry.normal = normal;
  1087. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1088. #ifdef CLEARCOAT
  1089. geometry.clearcoatNormal = clearcoatNormal;
  1090. #endif
  1091. IncidentLight directLight;
  1092. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1093. PointLight pointLight;
  1094. #pragma unroll_loop
  1095. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1096. pointLight = pointLights[ i ];
  1097. getPointDirectLightIrradiance( pointLight, geometry, directLight );
  1098. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1099. directLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1100. #endif
  1101. RE_Direct( directLight, geometry, material, reflectedLight );
  1102. }
  1103. #endif
  1104. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1105. SpotLight spotLight;
  1106. #pragma unroll_loop
  1107. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1108. spotLight = spotLights[ i ];
  1109. getSpotDirectLightIrradiance( spotLight, geometry, directLight );
  1110. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1111. directLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
  1112. #endif
  1113. RE_Direct( directLight, geometry, material, reflectedLight );
  1114. }
  1115. #endif
  1116. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1117. DirectionalLight directionalLight;
  1118. #pragma unroll_loop
  1119. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1120. directionalLight = directionalLights[ i ];
  1121. getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
  1122. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1123. directLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1124. #endif
  1125. RE_Direct( directLight, geometry, material, reflectedLight );
  1126. }
  1127. #endif
  1128. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1129. RectAreaLight rectAreaLight;
  1130. #pragma unroll_loop
  1131. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1132. rectAreaLight = rectAreaLights[ i ];
  1133. RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
  1134. }
  1135. #endif
  1136. #if defined( RE_IndirectDiffuse )
  1137. vec3 iblIrradiance = vec3( 0.0 );
  1138. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1139. irradiance += getLightProbeIrradiance( lightProbe, geometry );
  1140. #if ( NUM_HEMI_LIGHTS > 0 )
  1141. #pragma unroll_loop
  1142. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1143. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
  1144. }
  1145. #endif
  1146. #endif
  1147. #if defined( RE_IndirectSpecular )
  1148. vec3 radiance = vec3( 0.0 );
  1149. vec3 clearcoatRadiance = vec3( 0.0 );
  1150. #endif`,AE=`#if defined( RE_IndirectDiffuse )
  1151. #ifdef USE_LIGHTMAP
  1152. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  1153. vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  1154. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1155. lightMapIrradiance *= PI;
  1156. #endif
  1157. irradiance += lightMapIrradiance;
  1158. #endif
  1159. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1160. iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
  1161. #endif
  1162. #endif
  1163. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1164. radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
  1165. #ifdef CLEARCOAT
  1166. clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
  1167. #endif
  1168. #endif`,CE=`#if defined( RE_IndirectDiffuse )
  1169. RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
  1170. #endif
  1171. #if defined( RE_IndirectSpecular )
  1172. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
  1173. #endif`,PE=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1174. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1175. #endif`,LE=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1176. uniform float logDepthBufFC;
  1177. varying float vFragDepth;
  1178. varying float vIsPerspective;
  1179. #endif`,DE=`#ifdef USE_LOGDEPTHBUF
  1180. #ifdef USE_LOGDEPTHBUF_EXT
  1181. varying float vFragDepth;
  1182. varying float vIsPerspective;
  1183. #else
  1184. uniform float logDepthBufFC;
  1185. #endif
  1186. #endif`,IE=`#ifdef USE_LOGDEPTHBUF
  1187. #ifdef USE_LOGDEPTHBUF_EXT
  1188. vFragDepth = 1.0 + gl_Position.w;
  1189. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1190. #else
  1191. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  1192. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  1193. gl_Position.z *= gl_Position.w;
  1194. }
  1195. #endif
  1196. #endif`,RE=`#ifdef USE_MAP
  1197. vec4 texelColor = texture2D( map, vUv );
  1198. texelColor = mapTexelToLinear( texelColor );
  1199. diffuseColor *= texelColor;
  1200. #endif`,zE=`#ifdef USE_MAP
  1201. uniform sampler2D map;
  1202. #endif`,kE=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1203. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1204. #endif
  1205. #ifdef USE_MAP
  1206. vec4 mapTexel = texture2D( map, uv );
  1207. diffuseColor *= mapTexelToLinear( mapTexel );
  1208. #endif
  1209. #ifdef USE_ALPHAMAP
  1210. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1211. #endif`,BE=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1212. uniform mat3 uvTransform;
  1213. #endif
  1214. #ifdef USE_MAP
  1215. uniform sampler2D map;
  1216. #endif
  1217. #ifdef USE_ALPHAMAP
  1218. uniform sampler2D alphaMap;
  1219. #endif`,FE=`float metalnessFactor = metalness;
  1220. #ifdef USE_METALNESSMAP
  1221. vec4 texelMetalness = texture2D( metalnessMap, vUv );
  1222. metalnessFactor *= texelMetalness.b;
  1223. #endif`,OE=`#ifdef USE_METALNESSMAP
  1224. uniform sampler2D metalnessMap;
  1225. #endif`,NE=`#ifdef USE_MORPHNORMALS
  1226. objectNormal *= morphTargetBaseInfluence;
  1227. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  1228. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  1229. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  1230. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  1231. #endif`,UE=`#ifdef USE_MORPHTARGETS
  1232. uniform float morphTargetBaseInfluence;
  1233. #ifndef USE_MORPHNORMALS
  1234. uniform float morphTargetInfluences[ 8 ];
  1235. #else
  1236. uniform float morphTargetInfluences[ 4 ];
  1237. #endif
  1238. #endif`,VE=`#ifdef USE_MORPHTARGETS
  1239. transformed *= morphTargetBaseInfluence;
  1240. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  1241. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  1242. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  1243. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  1244. #ifndef USE_MORPHNORMALS
  1245. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  1246. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  1247. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  1248. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  1249. #endif
  1250. #endif`,GE=`#ifdef FLAT_SHADED
  1251. vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
  1252. vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
  1253. vec3 normal = normalize( cross( fdx, fdy ) );
  1254. #else
  1255. vec3 normal = normalize( vNormal );
  1256. #ifdef DOUBLE_SIDED
  1257. normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1258. #endif
  1259. #ifdef USE_TANGENT
  1260. vec3 tangent = normalize( vTangent );
  1261. vec3 bitangent = normalize( vBitangent );
  1262. #ifdef DOUBLE_SIDED
  1263. tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1264. bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1265. #endif
  1266. #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
  1267. mat3 vTBN = mat3( tangent, bitangent, normal );
  1268. #endif
  1269. #endif
  1270. #endif
  1271. vec3 geometryNormal = normal;`,HE=`#ifdef OBJECTSPACE_NORMALMAP
  1272. normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1273. #ifdef FLIP_SIDED
  1274. normal = - normal;
  1275. #endif
  1276. #ifdef DOUBLE_SIDED
  1277. normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1278. #endif
  1279. normal = normalize( normalMatrix * normal );
  1280. #elif defined( TANGENTSPACE_NORMALMAP )
  1281. vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1282. mapN.xy *= normalScale;
  1283. #ifdef USE_TANGENT
  1284. normal = normalize( vTBN * mapN );
  1285. #else
  1286. normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
  1287. #endif
  1288. #elif defined( USE_BUMPMAP )
  1289. normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
  1290. #endif`,WE=`#ifdef USE_NORMALMAP
  1291. uniform sampler2D normalMap;
  1292. uniform vec2 normalScale;
  1293. #endif
  1294. #ifdef OBJECTSPACE_NORMALMAP
  1295. uniform mat3 normalMatrix;
  1296. #endif
  1297. #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
  1298. vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
  1299. vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
  1300. vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
  1301. vec2 st0 = dFdx( vUv.st );
  1302. vec2 st1 = dFdy( vUv.st );
  1303. float scale = sign( st1.t * st0.s - st0.t * st1.s );
  1304. vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
  1305. vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
  1306. vec3 N = normalize( surf_norm );
  1307. mat3 tsn = mat3( S, T, N );
  1308. mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1309. return normalize( tsn * mapN );
  1310. }
  1311. #endif`,jE=`#ifdef CLEARCOAT
  1312. vec3 clearcoatNormal = geometryNormal;
  1313. #endif`,qE=`#ifdef USE_CLEARCOAT_NORMALMAP
  1314. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
  1315. clearcoatMapN.xy *= clearcoatNormalScale;
  1316. #ifdef USE_TANGENT
  1317. clearcoatNormal = normalize( vTBN * clearcoatMapN );
  1318. #else
  1319. clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
  1320. #endif
  1321. #endif`,ZE=`#ifdef USE_CLEARCOAT_NORMALMAP
  1322. uniform sampler2D clearcoatNormalMap;
  1323. uniform vec2 clearcoatNormalScale;
  1324. #endif`,XE=`vec3 packNormalToRGB( const in vec3 normal ) {
  1325. return normalize( normal ) * 0.5 + 0.5;
  1326. }
  1327. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1328. return 2.0 * rgb.xyz - 1.0;
  1329. }
  1330. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  1331. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  1332. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  1333. const float ShiftRight8 = 1. / 256.;
  1334. vec4 packDepthToRGBA( const in float v ) {
  1335. vec4 r = vec4( fract( v * PackFactors ), v );
  1336. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  1337. }
  1338. float unpackRGBAToDepth( const in vec4 v ) {
  1339. return dot( v, UnpackFactors );
  1340. }
  1341. vec4 pack2HalfToRGBA( vec2 v ) {
  1342. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
  1343. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
  1344. }
  1345. vec2 unpackRGBATo2Half( vec4 v ) {
  1346. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1347. }
  1348. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1349. return ( viewZ + near ) / ( near - far );
  1350. }
  1351. float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
  1352. return linearClipZ * ( near - far ) - near;
  1353. }
  1354. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1355. return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
  1356. }
  1357. float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
  1358. return ( near * far ) / ( ( far - near ) * invClipZ - far );
  1359. }`,YE=`#ifdef PREMULTIPLIED_ALPHA
  1360. gl_FragColor.rgb *= gl_FragColor.a;
  1361. #endif`,$E=`vec4 mvPosition = vec4( transformed, 1.0 );
  1362. #ifdef USE_INSTANCING
  1363. mvPosition = instanceMatrix * mvPosition;
  1364. #endif
  1365. mvPosition = modelViewMatrix * mvPosition;
  1366. gl_Position = projectionMatrix * mvPosition;`,JE=`#ifdef DITHERING
  1367. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1368. #endif`,KE=`#ifdef DITHERING
  1369. vec3 dithering( vec3 color ) {
  1370. float grid_position = rand( gl_FragCoord.xy );
  1371. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1372. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1373. return color + dither_shift_RGB;
  1374. }
  1375. #endif`,QE=`float roughnessFactor = roughness;
  1376. #ifdef USE_ROUGHNESSMAP
  1377. vec4 texelRoughness = texture2D( roughnessMap, vUv );
  1378. roughnessFactor *= texelRoughness.g;
  1379. #endif`,eS=`#ifdef USE_ROUGHNESSMAP
  1380. uniform sampler2D roughnessMap;
  1381. #endif`,tS=`#ifdef USE_SHADOWMAP
  1382. #if NUM_DIR_LIGHT_SHADOWS > 0
  1383. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1384. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1385. #endif
  1386. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1387. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1388. varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  1389. #endif
  1390. #if NUM_POINT_LIGHT_SHADOWS > 0
  1391. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1392. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1393. #endif
  1394. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1395. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  1396. }
  1397. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1398. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1399. }
  1400. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  1401. float occlusion = 1.0;
  1402. vec2 distribution = texture2DDistribution( shadow, uv );
  1403. float hard_shadow = step( compare , distribution.x );
  1404. if (hard_shadow != 1.0 ) {
  1405. float distance = compare - distribution.x ;
  1406. float variance = max( 0.00000, distribution.y * distribution.y );
  1407. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  1408. }
  1409. return occlusion;
  1410. }
  1411. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1412. float shadow = 1.0;
  1413. shadowCoord.xyz /= shadowCoord.w;
  1414. shadowCoord.z += shadowBias;
  1415. bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
  1416. bool inFrustum = all( inFrustumVec );
  1417. bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
  1418. bool frustumTest = all( frustumTestVec );
  1419. if ( frustumTest ) {
  1420. #if defined( SHADOWMAP_TYPE_PCF )
  1421. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1422. float dx0 = - texelSize.x * shadowRadius;
  1423. float dy0 = - texelSize.y * shadowRadius;
  1424. float dx1 = + texelSize.x * shadowRadius;
  1425. float dy1 = + texelSize.y * shadowRadius;
  1426. float dx2 = dx0 / 2.0;
  1427. float dy2 = dy0 / 2.0;
  1428. float dx3 = dx1 / 2.0;
  1429. float dy3 = dy1 / 2.0;
  1430. shadow = (
  1431. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1432. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1433. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1434. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1435. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1436. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1437. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1438. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1439. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1440. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1441. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1442. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1443. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1444. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1445. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1446. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1447. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1448. ) * ( 1.0 / 17.0 );
  1449. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1450. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1451. float dx = texelSize.x;
  1452. float dy = texelSize.y;
  1453. vec2 uv = shadowCoord.xy;
  1454. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1455. uv -= f * texelSize;
  1456. shadow = (
  1457. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1458. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1459. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1460. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1461. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1462. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1463. f.x ) +
  1464. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1465. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1466. f.x ) +
  1467. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1468. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1469. f.y ) +
  1470. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1471. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1472. f.y ) +
  1473. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1474. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1475. f.x ),
  1476. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1477. texture2DCompare( shadowMap, uv + + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1478. f.x ),
  1479. f.y )
  1480. ) * ( 1.0 / 9.0 );
  1481. #elif defined( SHADOWMAP_TYPE_VSM )
  1482. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1483. #else
  1484. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1485. #endif
  1486. }
  1487. return shadow;
  1488. }
  1489. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1490. vec3 absV = abs( v );
  1491. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1492. absV *= scaleToCube;
  1493. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1494. vec2 planar = v.xy;
  1495. float almostATexel = 1.5 * texelSizeY;
  1496. float almostOne = 1.0 - almostATexel;
  1497. if ( absV.z >= almostOne ) {
  1498. if ( v.z > 0.0 )
  1499. planar.x = 4.0 - v.x;
  1500. } else if ( absV.x >= almostOne ) {
  1501. float signX = sign( v.x );
  1502. planar.x = v.z * signX + 2.0 * signX;
  1503. } else if ( absV.y >= almostOne ) {
  1504. float signY = sign( v.y );
  1505. planar.x = v.x + 2.0 * signY + 2.0;
  1506. planar.y = v.z * signY - 2.0;
  1507. }
  1508. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1509. }
  1510. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1511. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1512. vec3 lightToPosition = shadowCoord.xyz;
  1513. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1514. vec3 bd3D = normalize( lightToPosition );
  1515. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1516. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1517. return (
  1518. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1519. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1520. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1521. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1522. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1523. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1524. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1525. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1526. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1527. ) * ( 1.0 / 9.0 );
  1528. #else
  1529. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1530. #endif
  1531. }
  1532. #endif`,nS=`#ifdef USE_SHADOWMAP
  1533. #if NUM_DIR_LIGHT_SHADOWS > 0
  1534. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1535. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1536. #endif
  1537. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1538. uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
  1539. varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  1540. #endif
  1541. #if NUM_POINT_LIGHT_SHADOWS > 0
  1542. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1543. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1544. #endif
  1545. #endif`,iS=`#ifdef USE_SHADOWMAP
  1546. #if NUM_DIR_LIGHT_SHADOWS > 0
  1547. #pragma unroll_loop
  1548. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1549. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;
  1550. }
  1551. #endif
  1552. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1553. #pragma unroll_loop
  1554. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1555. vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;
  1556. }
  1557. #endif
  1558. #if NUM_POINT_LIGHT_SHADOWS > 0
  1559. #pragma unroll_loop
  1560. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1561. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;
  1562. }
  1563. #endif
  1564. #endif`,rS=`float getShadowMask() {
  1565. float shadow = 1.0;
  1566. #ifdef USE_SHADOWMAP
  1567. #if NUM_DIR_LIGHT_SHADOWS > 0
  1568. DirectionalLight directionalLight;
  1569. #pragma unroll_loop
  1570. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1571. directionalLight = directionalLights[ i ];
  1572. shadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1573. }
  1574. #endif
  1575. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1576. SpotLight spotLight;
  1577. #pragma unroll_loop
  1578. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1579. spotLight = spotLights[ i ];
  1580. shadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
  1581. }
  1582. #endif
  1583. #if NUM_POINT_LIGHT_SHADOWS > 0
  1584. PointLight pointLight;
  1585. #pragma unroll_loop
  1586. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1587. pointLight = pointLights[ i ];
  1588. shadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1589. }
  1590. #endif
  1591. #endif
  1592. return shadow;
  1593. }`,aS=`#ifdef USE_SKINNING
  1594. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1595. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1596. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1597. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1598. #endif`,oS=`#ifdef USE_SKINNING
  1599. uniform mat4 bindMatrix;
  1600. uniform mat4 bindMatrixInverse;
  1601. #ifdef BONE_TEXTURE
  1602. uniform highp sampler2D boneTexture;
  1603. uniform int boneTextureSize;
  1604. mat4 getBoneMatrix( const in float i ) {
  1605. float j = i * 4.0;
  1606. float x = mod( j, float( boneTextureSize ) );
  1607. float y = floor( j / float( boneTextureSize ) );
  1608. float dx = 1.0 / float( boneTextureSize );
  1609. float dy = 1.0 / float( boneTextureSize );
  1610. y = dy * ( y + 0.5 );
  1611. vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
  1612. vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
  1613. vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
  1614. vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
  1615. mat4 bone = mat4( v1, v2, v3, v4 );
  1616. return bone;
  1617. }
  1618. #else
  1619. uniform mat4 boneMatrices[ MAX_BONES ];
  1620. mat4 getBoneMatrix( const in float i ) {
  1621. mat4 bone = boneMatrices[ int(i) ];
  1622. return bone;
  1623. }
  1624. #endif
  1625. #endif`,sS=`#ifdef USE_SKINNING
  1626. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1627. vec4 skinned = vec4( 0.0 );
  1628. skinned += boneMatX * skinVertex * skinWeight.x;
  1629. skinned += boneMatY * skinVertex * skinWeight.y;
  1630. skinned += boneMatZ * skinVertex * skinWeight.z;
  1631. skinned += boneMatW * skinVertex * skinWeight.w;
  1632. transformed = ( bindMatrixInverse * skinned ).xyz;
  1633. #endif`,lS=`#ifdef USE_SKINNING
  1634. mat4 skinMatrix = mat4( 0.0 );
  1635. skinMatrix += skinWeight.x * boneMatX;
  1636. skinMatrix += skinWeight.y * boneMatY;
  1637. skinMatrix += skinWeight.z * boneMatZ;
  1638. skinMatrix += skinWeight.w * boneMatW;
  1639. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  1640. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  1641. #ifdef USE_TANGENT
  1642. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  1643. #endif
  1644. #endif`,cS=`float specularStrength;
  1645. #ifdef USE_SPECULARMAP
  1646. vec4 texelSpecular = texture2D( specularMap, vUv );
  1647. specularStrength = texelSpecular.r;
  1648. #else
  1649. specularStrength = 1.0;
  1650. #endif`,uS=`#ifdef USE_SPECULARMAP
  1651. uniform sampler2D specularMap;
  1652. #endif`,hS=`#if defined( TONE_MAPPING )
  1653. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  1654. #endif`,dS=`#ifndef saturate
  1655. #define saturate(a) clamp( a, 0.0, 1.0 )
  1656. #endif
  1657. uniform float toneMappingExposure;
  1658. uniform float toneMappingWhitePoint;
  1659. vec3 LinearToneMapping( vec3 color ) {
  1660. return toneMappingExposure * color;
  1661. }
  1662. vec3 ReinhardToneMapping( vec3 color ) {
  1663. color *= toneMappingExposure;
  1664. return saturate( color / ( vec3( 1.0 ) + color ) );
  1665. }
  1666. #define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )
  1667. vec3 Uncharted2ToneMapping( vec3 color ) {
  1668. color *= toneMappingExposure;
  1669. return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );
  1670. }
  1671. vec3 OptimizedCineonToneMapping( vec3 color ) {
  1672. color *= toneMappingExposure;
  1673. color = max( vec3( 0.0 ), color - 0.004 );
  1674. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  1675. }
  1676. vec3 ACESFilmicToneMapping( vec3 color ) {
  1677. color *= toneMappingExposure;
  1678. return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );
  1679. }`,pS=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
  1680. varying vec2 vUv;
  1681. #endif`,fS=`#ifdef USE_UV
  1682. #ifdef UVS_VERTEX_ONLY
  1683. vec2 vUv;
  1684. #else
  1685. varying vec2 vUv;
  1686. #endif
  1687. uniform mat3 uvTransform;
  1688. #endif`,mS=`#ifdef USE_UV
  1689. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1690. #endif`,gS=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1691. varying vec2 vUv2;
  1692. #endif`,_S=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1693. attribute vec2 uv2;
  1694. varying vec2 vUv2;
  1695. uniform mat3 uv2Transform;
  1696. #endif`,yS=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1697. vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
  1698. #endif`,vS=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
  1699. vec4 worldPosition = vec4( transformed, 1.0 );
  1700. #ifdef USE_INSTANCING
  1701. worldPosition = instanceMatrix * worldPosition;
  1702. #endif
  1703. worldPosition = modelMatrix * worldPosition;
  1704. #endif`,xS=`uniform sampler2D t2D;
  1705. varying vec2 vUv;
  1706. void main() {
  1707. vec4 texColor = texture2D( t2D, vUv );
  1708. gl_FragColor = mapTexelToLinear( texColor );
  1709. #include <tonemapping_fragment>
  1710. #include <encodings_fragment>
  1711. }`,bS=`varying vec2 vUv;
  1712. uniform mat3 uvTransform;
  1713. void main() {
  1714. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1715. gl_Position = vec4( position.xy, 1.0, 1.0 );
  1716. }`,wS=`#include <envmap_common_pars_fragment>
  1717. uniform float opacity;
  1718. varying vec3 vWorldDirection;
  1719. #include <cube_uv_reflection_fragment>
  1720. void main() {
  1721. vec3 vReflect = vWorldDirection;
  1722. #include <envmap_fragment>
  1723. gl_FragColor = envColor;
  1724. gl_FragColor.a *= opacity;
  1725. #include <tonemapping_fragment>
  1726. #include <encodings_fragment>
  1727. }`,MS=`varying vec3 vWorldDirection;
  1728. #include <common>
  1729. void main() {
  1730. vWorldDirection = transformDirection( position, modelMatrix );
  1731. #include <begin_vertex>
  1732. #include <project_vertex>
  1733. gl_Position.z = gl_Position.w;
  1734. }`,TS=`#if DEPTH_PACKING == 3200
  1735. uniform float opacity;
  1736. #endif
  1737. #include <common>
  1738. #include <packing>
  1739. #include <uv_pars_fragment>
  1740. #include <map_pars_fragment>
  1741. #include <alphamap_pars_fragment>
  1742. #include <logdepthbuf_pars_fragment>
  1743. #include <clipping_planes_pars_fragment>
  1744. void main() {
  1745. #include <clipping_planes_fragment>
  1746. vec4 diffuseColor = vec4( 1.0 );
  1747. #if DEPTH_PACKING == 3200
  1748. diffuseColor.a = opacity;
  1749. #endif
  1750. #include <map_fragment>
  1751. #include <alphamap_fragment>
  1752. #include <alphatest_fragment>
  1753. #include <logdepthbuf_fragment>
  1754. #if DEPTH_PACKING == 3200
  1755. gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );
  1756. #elif DEPTH_PACKING == 3201
  1757. gl_FragColor = packDepthToRGBA( gl_FragCoord.z );
  1758. #endif
  1759. }`,ES=`#include <common>
  1760. #include <uv_pars_vertex>
  1761. #include <displacementmap_pars_vertex>
  1762. #include <morphtarget_pars_vertex>
  1763. #include <skinning_pars_vertex>
  1764. #include <logdepthbuf_pars_vertex>
  1765. #include <clipping_planes_pars_vertex>
  1766. void main() {
  1767. #include <uv_vertex>
  1768. #include <skinbase_vertex>
  1769. #ifdef USE_DISPLACEMENTMAP
  1770. #include <beginnormal_vertex>
  1771. #include <morphnormal_vertex>
  1772. #include <skinnormal_vertex>
  1773. #endif
  1774. #include <begin_vertex>
  1775. #include <morphtarget_vertex>
  1776. #include <skinning_vertex>
  1777. #include <displacementmap_vertex>
  1778. #include <project_vertex>
  1779. #include <logdepthbuf_vertex>
  1780. #include <clipping_planes_vertex>
  1781. }`,SS=`#define DISTANCE
  1782. uniform vec3 referencePosition;
  1783. uniform float nearDistance;
  1784. uniform float farDistance;
  1785. varying vec3 vWorldPosition;
  1786. #include <common>
  1787. #include <packing>
  1788. #include <uv_pars_fragment>
  1789. #include <map_pars_fragment>
  1790. #include <alphamap_pars_fragment>
  1791. #include <clipping_planes_pars_fragment>
  1792. void main () {
  1793. #include <clipping_planes_fragment>
  1794. vec4 diffuseColor = vec4( 1.0 );
  1795. #include <map_fragment>
  1796. #include <alphamap_fragment>
  1797. #include <alphatest_fragment>
  1798. float dist = length( vWorldPosition - referencePosition );
  1799. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  1800. dist = saturate( dist );
  1801. gl_FragColor = packDepthToRGBA( dist );
  1802. }`,AS=`#define DISTANCE
  1803. varying vec3 vWorldPosition;
  1804. #include <common>
  1805. #include <uv_pars_vertex>
  1806. #include <displacementmap_pars_vertex>
  1807. #include <morphtarget_pars_vertex>
  1808. #include <skinning_pars_vertex>
  1809. #include <clipping_planes_pars_vertex>
  1810. void main() {
  1811. #include <uv_vertex>
  1812. #include <skinbase_vertex>
  1813. #ifdef USE_DISPLACEMENTMAP
  1814. #include <beginnormal_vertex>
  1815. #include <morphnormal_vertex>
  1816. #include <skinnormal_vertex>
  1817. #endif
  1818. #include <begin_vertex>
  1819. #include <morphtarget_vertex>
  1820. #include <skinning_vertex>
  1821. #include <displacementmap_vertex>
  1822. #include <project_vertex>
  1823. #include <worldpos_vertex>
  1824. #include <clipping_planes_vertex>
  1825. vWorldPosition = worldPosition.xyz;
  1826. }`,CS=`uniform sampler2D tEquirect;
  1827. varying vec3 vWorldDirection;
  1828. #include <common>
  1829. void main() {
  1830. vec3 direction = normalize( vWorldDirection );
  1831. vec2 sampleUV;
  1832. sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  1833. sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;
  1834. vec4 texColor = texture2D( tEquirect, sampleUV );
  1835. gl_FragColor = mapTexelToLinear( texColor );
  1836. #include <tonemapping_fragment>
  1837. #include <encodings_fragment>
  1838. }`,PS=`varying vec3 vWorldDirection;
  1839. #include <common>
  1840. void main() {
  1841. vWorldDirection = transformDirection( position, modelMatrix );
  1842. #include <begin_vertex>
  1843. #include <project_vertex>
  1844. }`,LS=`uniform vec3 diffuse;
  1845. uniform float opacity;
  1846. uniform float dashSize;
  1847. uniform float totalSize;
  1848. varying float vLineDistance;
  1849. #include <common>
  1850. #include <color_pars_fragment>
  1851. #include <fog_pars_fragment>
  1852. #include <logdepthbuf_pars_fragment>
  1853. #include <clipping_planes_pars_fragment>
  1854. void main() {
  1855. #include <clipping_planes_fragment>
  1856. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  1857. discard;
  1858. }
  1859. vec3 outgoingLight = vec3( 0.0 );
  1860. vec4 diffuseColor = vec4( diffuse, opacity );
  1861. #include <logdepthbuf_fragment>
  1862. #include <color_fragment>
  1863. outgoingLight = diffuseColor.rgb;
  1864. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  1865. #include <tonemapping_fragment>
  1866. #include <encodings_fragment>
  1867. #include <fog_fragment>
  1868. #include <premultiplied_alpha_fragment>
  1869. }`,DS=`uniform float scale;
  1870. attribute float lineDistance;
  1871. varying float vLineDistance;
  1872. #include <common>
  1873. #include <color_pars_vertex>
  1874. #include <fog_pars_vertex>
  1875. #include <logdepthbuf_pars_vertex>
  1876. #include <clipping_planes_pars_vertex>
  1877. void main() {
  1878. #include <color_vertex>
  1879. vLineDistance = scale * lineDistance;
  1880. vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
  1881. gl_Position = projectionMatrix * mvPosition;
  1882. #include <logdepthbuf_vertex>
  1883. #include <clipping_planes_vertex>
  1884. #include <fog_vertex>
  1885. }`,IS=`uniform vec3 diffuse;
  1886. uniform float opacity;
  1887. #ifndef FLAT_SHADED
  1888. varying vec3 vNormal;
  1889. #endif
  1890. #include <common>
  1891. #include <color_pars_fragment>
  1892. #include <uv_pars_fragment>
  1893. #include <uv2_pars_fragment>
  1894. #include <map_pars_fragment>
  1895. #include <alphamap_pars_fragment>
  1896. #include <aomap_pars_fragment>
  1897. #include <lightmap_pars_fragment>
  1898. #include <envmap_common_pars_fragment>
  1899. #include <envmap_pars_fragment>
  1900. #include <cube_uv_reflection_fragment>
  1901. #include <fog_pars_fragment>
  1902. #include <specularmap_pars_fragment>
  1903. #include <logdepthbuf_pars_fragment>
  1904. #include <clipping_planes_pars_fragment>
  1905. void main() {
  1906. #include <clipping_planes_fragment>
  1907. vec4 diffuseColor = vec4( diffuse, opacity );
  1908. #include <logdepthbuf_fragment>
  1909. #include <map_fragment>
  1910. #include <color_fragment>
  1911. #include <alphamap_fragment>
  1912. #include <alphatest_fragment>
  1913. #include <specularmap_fragment>
  1914. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  1915. #ifdef USE_LIGHTMAP
  1916. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  1917. reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  1918. #else
  1919. reflectedLight.indirectDiffuse += vec3( 1.0 );
  1920. #endif
  1921. #include <aomap_fragment>
  1922. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  1923. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  1924. #include <envmap_fragment>
  1925. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  1926. #include <tonemapping_fragment>
  1927. #include <encodings_fragment>
  1928. #include <fog_fragment>
  1929. #include <premultiplied_alpha_fragment>
  1930. }`,RS=`#include <common>
  1931. #include <uv_pars_vertex>
  1932. #include <uv2_pars_vertex>
  1933. #include <envmap_pars_vertex>
  1934. #include <color_pars_vertex>
  1935. #include <fog_pars_vertex>
  1936. #include <morphtarget_pars_vertex>
  1937. #include <skinning_pars_vertex>
  1938. #include <logdepthbuf_pars_vertex>
  1939. #include <clipping_planes_pars_vertex>
  1940. void main() {
  1941. #include <uv_vertex>
  1942. #include <uv2_vertex>
  1943. #include <color_vertex>
  1944. #include <skinbase_vertex>
  1945. #ifdef USE_ENVMAP
  1946. #include <beginnormal_vertex>
  1947. #include <morphnormal_vertex>
  1948. #include <skinnormal_vertex>
  1949. #include <defaultnormal_vertex>
  1950. #endif
  1951. #include <begin_vertex>
  1952. #include <morphtarget_vertex>
  1953. #include <skinning_vertex>
  1954. #include <project_vertex>
  1955. #include <logdepthbuf_vertex>
  1956. #include <worldpos_vertex>
  1957. #include <clipping_planes_vertex>
  1958. #include <envmap_vertex>
  1959. #include <fog_vertex>
  1960. }`,zS=`uniform vec3 diffuse;
  1961. uniform vec3 emissive;
  1962. uniform float opacity;
  1963. varying vec3 vLightFront;
  1964. varying vec3 vIndirectFront;
  1965. #ifdef DOUBLE_SIDED
  1966. varying vec3 vLightBack;
  1967. varying vec3 vIndirectBack;
  1968. #endif
  1969. #include <common>
  1970. #include <packing>
  1971. #include <dithering_pars_fragment>
  1972. #include <color_pars_fragment>
  1973. #include <uv_pars_fragment>
  1974. #include <uv2_pars_fragment>
  1975. #include <map_pars_fragment>
  1976. #include <alphamap_pars_fragment>
  1977. #include <aomap_pars_fragment>
  1978. #include <lightmap_pars_fragment>
  1979. #include <emissivemap_pars_fragment>
  1980. #include <envmap_common_pars_fragment>
  1981. #include <envmap_pars_fragment>
  1982. #include <cube_uv_reflection_fragment>
  1983. #include <bsdfs>
  1984. #include <lights_pars_begin>
  1985. #include <fog_pars_fragment>
  1986. #include <shadowmap_pars_fragment>
  1987. #include <shadowmask_pars_fragment>
  1988. #include <specularmap_pars_fragment>
  1989. #include <logdepthbuf_pars_fragment>
  1990. #include <clipping_planes_pars_fragment>
  1991. void main() {
  1992. #include <clipping_planes_fragment>
  1993. vec4 diffuseColor = vec4( diffuse, opacity );
  1994. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  1995. vec3 totalEmissiveRadiance = emissive;
  1996. #include <logdepthbuf_fragment>
  1997. #include <map_fragment>
  1998. #include <color_fragment>
  1999. #include <alphamap_fragment>
  2000. #include <alphatest_fragment>
  2001. #include <specularmap_fragment>
  2002. #include <emissivemap_fragment>
  2003. reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );
  2004. #ifdef DOUBLE_SIDED
  2005. reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
  2006. #else
  2007. reflectedLight.indirectDiffuse += vIndirectFront;
  2008. #endif
  2009. #include <lightmap_fragment>
  2010. reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
  2011. #ifdef DOUBLE_SIDED
  2012. reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
  2013. #else
  2014. reflectedLight.directDiffuse = vLightFront;
  2015. #endif
  2016. reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
  2017. #include <aomap_fragment>
  2018. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2019. #include <envmap_fragment>
  2020. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2021. #include <tonemapping_fragment>
  2022. #include <encodings_fragment>
  2023. #include <fog_fragment>
  2024. #include <premultiplied_alpha_fragment>
  2025. #include <dithering_fragment>
  2026. }`,kS=`#define LAMBERT
  2027. varying vec3 vLightFront;
  2028. varying vec3 vIndirectFront;
  2029. #ifdef DOUBLE_SIDED
  2030. varying vec3 vLightBack;
  2031. varying vec3 vIndirectBack;
  2032. #endif
  2033. #include <common>
  2034. #include <uv_pars_vertex>
  2035. #include <uv2_pars_vertex>
  2036. #include <envmap_pars_vertex>
  2037. #include <bsdfs>
  2038. #include <lights_pars_begin>
  2039. #include <color_pars_vertex>
  2040. #include <fog_pars_vertex>
  2041. #include <morphtarget_pars_vertex>
  2042. #include <skinning_pars_vertex>
  2043. #include <shadowmap_pars_vertex>
  2044. #include <logdepthbuf_pars_vertex>
  2045. #include <clipping_planes_pars_vertex>
  2046. void main() {
  2047. #include <uv_vertex>
  2048. #include <uv2_vertex>
  2049. #include <color_vertex>
  2050. #include <beginnormal_vertex>
  2051. #include <morphnormal_vertex>
  2052. #include <skinbase_vertex>
  2053. #include <skinnormal_vertex>
  2054. #include <defaultnormal_vertex>
  2055. #include <begin_vertex>
  2056. #include <morphtarget_vertex>
  2057. #include <skinning_vertex>
  2058. #include <project_vertex>
  2059. #include <logdepthbuf_vertex>
  2060. #include <clipping_planes_vertex>
  2061. #include <worldpos_vertex>
  2062. #include <envmap_vertex>
  2063. #include <lights_lambert_vertex>
  2064. #include <shadowmap_vertex>
  2065. #include <fog_vertex>
  2066. }`,BS=`#define MATCAP
  2067. uniform vec3 diffuse;
  2068. uniform float opacity;
  2069. uniform sampler2D matcap;
  2070. varying vec3 vViewPosition;
  2071. #ifndef FLAT_SHADED
  2072. varying vec3 vNormal;
  2073. #endif
  2074. #include <common>
  2075. #include <uv_pars_fragment>
  2076. #include <map_pars_fragment>
  2077. #include <alphamap_pars_fragment>
  2078. #include <fog_pars_fragment>
  2079. #include <bumpmap_pars_fragment>
  2080. #include <normalmap_pars_fragment>
  2081. #include <logdepthbuf_pars_fragment>
  2082. #include <clipping_planes_pars_fragment>
  2083. void main() {
  2084. #include <clipping_planes_fragment>
  2085. vec4 diffuseColor = vec4( diffuse, opacity );
  2086. #include <logdepthbuf_fragment>
  2087. #include <map_fragment>
  2088. #include <alphamap_fragment>
  2089. #include <alphatest_fragment>
  2090. #include <normal_fragment_begin>
  2091. #include <normal_fragment_maps>
  2092. vec3 viewDir = normalize( vViewPosition );
  2093. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2094. vec3 y = cross( viewDir, x );
  2095. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  2096. #ifdef USE_MATCAP
  2097. vec4 matcapColor = texture2D( matcap, uv );
  2098. matcapColor = matcapTexelToLinear( matcapColor );
  2099. #else
  2100. vec4 matcapColor = vec4( 1.0 );
  2101. #endif
  2102. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  2103. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2104. #include <tonemapping_fragment>
  2105. #include <encodings_fragment>
  2106. #include <fog_fragment>
  2107. #include <premultiplied_alpha_fragment>
  2108. }`,FS=`#define MATCAP
  2109. varying vec3 vViewPosition;
  2110. #ifndef FLAT_SHADED
  2111. varying vec3 vNormal;
  2112. #endif
  2113. #include <common>
  2114. #include <uv_pars_vertex>
  2115. #include <displacementmap_pars_vertex>
  2116. #include <fog_pars_vertex>
  2117. #include <morphtarget_pars_vertex>
  2118. #include <skinning_pars_vertex>
  2119. #include <logdepthbuf_pars_vertex>
  2120. #include <clipping_planes_pars_vertex>
  2121. void main() {
  2122. #include <uv_vertex>
  2123. #include <beginnormal_vertex>
  2124. #include <morphnormal_vertex>
  2125. #include <skinbase_vertex>
  2126. #include <skinnormal_vertex>
  2127. #include <defaultnormal_vertex>
  2128. #ifndef FLAT_SHADED
  2129. vNormal = normalize( transformedNormal );
  2130. #endif
  2131. #include <begin_vertex>
  2132. #include <morphtarget_vertex>
  2133. #include <skinning_vertex>
  2134. #include <displacementmap_vertex>
  2135. #include <project_vertex>
  2136. #include <logdepthbuf_vertex>
  2137. #include <clipping_planes_vertex>
  2138. #include <fog_vertex>
  2139. vViewPosition = - mvPosition.xyz;
  2140. }`,OS=`#define TOON
  2141. uniform vec3 diffuse;
  2142. uniform vec3 emissive;
  2143. uniform vec3 specular;
  2144. uniform float shininess;
  2145. uniform float opacity;
  2146. #include <common>
  2147. #include <packing>
  2148. #include <dithering_pars_fragment>
  2149. #include <color_pars_fragment>
  2150. #include <uv_pars_fragment>
  2151. #include <uv2_pars_fragment>
  2152. #include <map_pars_fragment>
  2153. #include <alphamap_pars_fragment>
  2154. #include <aomap_pars_fragment>
  2155. #include <lightmap_pars_fragment>
  2156. #include <emissivemap_pars_fragment>
  2157. #include <gradientmap_pars_fragment>
  2158. #include <fog_pars_fragment>
  2159. #include <bsdfs>
  2160. #include <lights_pars_begin>
  2161. #include <lights_toon_pars_fragment>
  2162. #include <shadowmap_pars_fragment>
  2163. #include <bumpmap_pars_fragment>
  2164. #include <normalmap_pars_fragment>
  2165. #include <specularmap_pars_fragment>
  2166. #include <logdepthbuf_pars_fragment>
  2167. #include <clipping_planes_pars_fragment>
  2168. void main() {
  2169. #include <clipping_planes_fragment>
  2170. vec4 diffuseColor = vec4( diffuse, opacity );
  2171. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2172. vec3 totalEmissiveRadiance = emissive;
  2173. #include <logdepthbuf_fragment>
  2174. #include <map_fragment>
  2175. #include <color_fragment>
  2176. #include <alphamap_fragment>
  2177. #include <alphatest_fragment>
  2178. #include <specularmap_fragment>
  2179. #include <normal_fragment_begin>
  2180. #include <normal_fragment_maps>
  2181. #include <emissivemap_fragment>
  2182. #include <lights_toon_fragment>
  2183. #include <lights_fragment_begin>
  2184. #include <lights_fragment_maps>
  2185. #include <lights_fragment_end>
  2186. #include <aomap_fragment>
  2187. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2188. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2189. #include <tonemapping_fragment>
  2190. #include <encodings_fragment>
  2191. #include <fog_fragment>
  2192. #include <premultiplied_alpha_fragment>
  2193. #include <dithering_fragment>
  2194. }`,NS=`#define TOON
  2195. varying vec3 vViewPosition;
  2196. #ifndef FLAT_SHADED
  2197. varying vec3 vNormal;
  2198. #endif
  2199. #include <common>
  2200. #include <uv_pars_vertex>
  2201. #include <uv2_pars_vertex>
  2202. #include <displacementmap_pars_vertex>
  2203. #include <color_pars_vertex>
  2204. #include <fog_pars_vertex>
  2205. #include <morphtarget_pars_vertex>
  2206. #include <skinning_pars_vertex>
  2207. #include <shadowmap_pars_vertex>
  2208. #include <logdepthbuf_pars_vertex>
  2209. #include <clipping_planes_pars_vertex>
  2210. void main() {
  2211. #include <uv_vertex>
  2212. #include <uv2_vertex>
  2213. #include <color_vertex>
  2214. #include <beginnormal_vertex>
  2215. #include <morphnormal_vertex>
  2216. #include <skinbase_vertex>
  2217. #include <skinnormal_vertex>
  2218. #include <defaultnormal_vertex>
  2219. #ifndef FLAT_SHADED
  2220. vNormal = normalize( transformedNormal );
  2221. #endif
  2222. #include <begin_vertex>
  2223. #include <morphtarget_vertex>
  2224. #include <skinning_vertex>
  2225. #include <displacementmap_vertex>
  2226. #include <project_vertex>
  2227. #include <logdepthbuf_vertex>
  2228. #include <clipping_planes_vertex>
  2229. vViewPosition = - mvPosition.xyz;
  2230. #include <worldpos_vertex>
  2231. #include <shadowmap_vertex>
  2232. #include <fog_vertex>
  2233. }`,US=`#define PHONG
  2234. uniform vec3 diffuse;
  2235. uniform vec3 emissive;
  2236. uniform vec3 specular;
  2237. uniform float shininess;
  2238. uniform float opacity;
  2239. #include <common>
  2240. #include <packing>
  2241. #include <dithering_pars_fragment>
  2242. #include <color_pars_fragment>
  2243. #include <uv_pars_fragment>
  2244. #include <uv2_pars_fragment>
  2245. #include <map_pars_fragment>
  2246. #include <alphamap_pars_fragment>
  2247. #include <aomap_pars_fragment>
  2248. #include <lightmap_pars_fragment>
  2249. #include <emissivemap_pars_fragment>
  2250. #include <envmap_common_pars_fragment>
  2251. #include <envmap_pars_fragment>
  2252. #include <cube_uv_reflection_fragment>
  2253. #include <fog_pars_fragment>
  2254. #include <bsdfs>
  2255. #include <lights_pars_begin>
  2256. #include <lights_phong_pars_fragment>
  2257. #include <shadowmap_pars_fragment>
  2258. #include <bumpmap_pars_fragment>
  2259. #include <normalmap_pars_fragment>
  2260. #include <specularmap_pars_fragment>
  2261. #include <logdepthbuf_pars_fragment>
  2262. #include <clipping_planes_pars_fragment>
  2263. void main() {
  2264. #include <clipping_planes_fragment>
  2265. vec4 diffuseColor = vec4( diffuse, opacity );
  2266. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2267. vec3 totalEmissiveRadiance = emissive;
  2268. #include <logdepthbuf_fragment>
  2269. #include <map_fragment>
  2270. #include <color_fragment>
  2271. #include <alphamap_fragment>
  2272. #include <alphatest_fragment>
  2273. #include <specularmap_fragment>
  2274. #include <normal_fragment_begin>
  2275. #include <normal_fragment_maps>
  2276. #include <emissivemap_fragment>
  2277. #include <lights_phong_fragment>
  2278. #include <lights_fragment_begin>
  2279. #include <lights_fragment_maps>
  2280. #include <lights_fragment_end>
  2281. #include <aomap_fragment>
  2282. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2283. #include <envmap_fragment>
  2284. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2285. #include <tonemapping_fragment>
  2286. #include <encodings_fragment>
  2287. #include <fog_fragment>
  2288. #include <premultiplied_alpha_fragment>
  2289. #include <dithering_fragment>
  2290. }`,VS=`#define PHONG
  2291. varying vec3 vViewPosition;
  2292. #ifndef FLAT_SHADED
  2293. varying vec3 vNormal;
  2294. #endif
  2295. #include <common>
  2296. #include <uv_pars_vertex>
  2297. #include <uv2_pars_vertex>
  2298. #include <displacementmap_pars_vertex>
  2299. #include <envmap_pars_vertex>
  2300. #include <color_pars_vertex>
  2301. #include <fog_pars_vertex>
  2302. #include <morphtarget_pars_vertex>
  2303. #include <skinning_pars_vertex>
  2304. #include <shadowmap_pars_vertex>
  2305. #include <logdepthbuf_pars_vertex>
  2306. #include <clipping_planes_pars_vertex>
  2307. void main() {
  2308. #include <uv_vertex>
  2309. #include <uv2_vertex>
  2310. #include <color_vertex>
  2311. #include <beginnormal_vertex>
  2312. #include <morphnormal_vertex>
  2313. #include <skinbase_vertex>
  2314. #include <skinnormal_vertex>
  2315. #include <defaultnormal_vertex>
  2316. #ifndef FLAT_SHADED
  2317. vNormal = normalize( transformedNormal );
  2318. #endif
  2319. #include <begin_vertex>
  2320. #include <morphtarget_vertex>
  2321. #include <skinning_vertex>
  2322. #include <displacementmap_vertex>
  2323. #include <project_vertex>
  2324. #include <logdepthbuf_vertex>
  2325. #include <clipping_planes_vertex>
  2326. vViewPosition = - mvPosition.xyz;
  2327. #include <worldpos_vertex>
  2328. #include <envmap_vertex>
  2329. #include <shadowmap_vertex>
  2330. #include <fog_vertex>
  2331. }`,GS=`#define STANDARD
  2332. #ifdef PHYSICAL
  2333. #define REFLECTIVITY
  2334. #define CLEARCOAT
  2335. #define TRANSPARENCY
  2336. #endif
  2337. uniform vec3 diffuse;
  2338. uniform vec3 emissive;
  2339. uniform float roughness;
  2340. uniform float metalness;
  2341. uniform float opacity;
  2342. #ifdef TRANSPARENCY
  2343. uniform float transparency;
  2344. #endif
  2345. #ifdef REFLECTIVITY
  2346. uniform float reflectivity;
  2347. #endif
  2348. #ifdef CLEARCOAT
  2349. uniform float clearcoat;
  2350. uniform float clearcoatRoughness;
  2351. #endif
  2352. #ifdef USE_SHEEN
  2353. uniform vec3 sheen;
  2354. #endif
  2355. varying vec3 vViewPosition;
  2356. #ifndef FLAT_SHADED
  2357. varying vec3 vNormal;
  2358. #ifdef USE_TANGENT
  2359. varying vec3 vTangent;
  2360. varying vec3 vBitangent;
  2361. #endif
  2362. #endif
  2363. #include <common>
  2364. #include <packing>
  2365. #include <dithering_pars_fragment>
  2366. #include <color_pars_fragment>
  2367. #include <uv_pars_fragment>
  2368. #include <uv2_pars_fragment>
  2369. #include <map_pars_fragment>
  2370. #include <alphamap_pars_fragment>
  2371. #include <aomap_pars_fragment>
  2372. #include <lightmap_pars_fragment>
  2373. #include <emissivemap_pars_fragment>
  2374. #include <bsdfs>
  2375. #include <cube_uv_reflection_fragment>
  2376. #include <envmap_common_pars_fragment>
  2377. #include <envmap_physical_pars_fragment>
  2378. #include <fog_pars_fragment>
  2379. #include <lights_pars_begin>
  2380. #include <lights_physical_pars_fragment>
  2381. #include <shadowmap_pars_fragment>
  2382. #include <bumpmap_pars_fragment>
  2383. #include <normalmap_pars_fragment>
  2384. #include <clearcoat_normalmap_pars_fragment>
  2385. #include <roughnessmap_pars_fragment>
  2386. #include <metalnessmap_pars_fragment>
  2387. #include <logdepthbuf_pars_fragment>
  2388. #include <clipping_planes_pars_fragment>
  2389. void main() {
  2390. #include <clipping_planes_fragment>
  2391. vec4 diffuseColor = vec4( diffuse, opacity );
  2392. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2393. vec3 totalEmissiveRadiance = emissive;
  2394. #include <logdepthbuf_fragment>
  2395. #include <map_fragment>
  2396. #include <color_fragment>
  2397. #include <alphamap_fragment>
  2398. #include <alphatest_fragment>
  2399. #include <roughnessmap_fragment>
  2400. #include <metalnessmap_fragment>
  2401. #include <normal_fragment_begin>
  2402. #include <normal_fragment_maps>
  2403. #include <clearcoat_normal_fragment_begin>
  2404. #include <clearcoat_normal_fragment_maps>
  2405. #include <emissivemap_fragment>
  2406. #include <lights_physical_fragment>
  2407. #include <lights_fragment_begin>
  2408. #include <lights_fragment_maps>
  2409. #include <lights_fragment_end>
  2410. #include <aomap_fragment>
  2411. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2412. #ifdef TRANSPARENCY
  2413. diffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );
  2414. #endif
  2415. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2416. #include <tonemapping_fragment>
  2417. #include <encodings_fragment>
  2418. #include <fog_fragment>
  2419. #include <premultiplied_alpha_fragment>
  2420. #include <dithering_fragment>
  2421. }`,HS=`#define STANDARD
  2422. varying vec3 vViewPosition;
  2423. #ifndef FLAT_SHADED
  2424. varying vec3 vNormal;
  2425. #ifdef USE_TANGENT
  2426. varying vec3 vTangent;
  2427. varying vec3 vBitangent;
  2428. #endif
  2429. #endif
  2430. #include <common>
  2431. #include <uv_pars_vertex>
  2432. #include <uv2_pars_vertex>
  2433. #include <displacementmap_pars_vertex>
  2434. #include <color_pars_vertex>
  2435. #include <fog_pars_vertex>
  2436. #include <morphtarget_pars_vertex>
  2437. #include <skinning_pars_vertex>
  2438. #include <shadowmap_pars_vertex>
  2439. #include <logdepthbuf_pars_vertex>
  2440. #include <clipping_planes_pars_vertex>
  2441. void main() {
  2442. #include <uv_vertex>
  2443. #include <uv2_vertex>
  2444. #include <color_vertex>
  2445. #include <beginnormal_vertex>
  2446. #include <morphnormal_vertex>
  2447. #include <skinbase_vertex>
  2448. #include <skinnormal_vertex>
  2449. #include <defaultnormal_vertex>
  2450. #ifndef FLAT_SHADED
  2451. vNormal = normalize( transformedNormal );
  2452. #ifdef USE_TANGENT
  2453. vTangent = normalize( transformedTangent );
  2454. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  2455. #endif
  2456. #endif
  2457. #include <begin_vertex>
  2458. #include <morphtarget_vertex>
  2459. #include <skinning_vertex>
  2460. #include <displacementmap_vertex>
  2461. #include <project_vertex>
  2462. #include <logdepthbuf_vertex>
  2463. #include <clipping_planes_vertex>
  2464. vViewPosition = - mvPosition.xyz;
  2465. #include <worldpos_vertex>
  2466. #include <shadowmap_vertex>
  2467. #include <fog_vertex>
  2468. }`,WS=`#define NORMAL
  2469. uniform float opacity;
  2470. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2471. varying vec3 vViewPosition;
  2472. #endif
  2473. #ifndef FLAT_SHADED
  2474. varying vec3 vNormal;
  2475. #ifdef USE_TANGENT
  2476. varying vec3 vTangent;
  2477. varying vec3 vBitangent;
  2478. #endif
  2479. #endif
  2480. #include <packing>
  2481. #include <uv_pars_fragment>
  2482. #include <bumpmap_pars_fragment>
  2483. #include <normalmap_pars_fragment>
  2484. #include <logdepthbuf_pars_fragment>
  2485. #include <clipping_planes_pars_fragment>
  2486. void main() {
  2487. #include <clipping_planes_fragment>
  2488. #include <logdepthbuf_fragment>
  2489. #include <normal_fragment_begin>
  2490. #include <normal_fragment_maps>
  2491. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  2492. }`,jS=`#define NORMAL
  2493. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2494. varying vec3 vViewPosition;
  2495. #endif
  2496. #ifndef FLAT_SHADED
  2497. varying vec3 vNormal;
  2498. #ifdef USE_TANGENT
  2499. varying vec3 vTangent;
  2500. varying vec3 vBitangent;
  2501. #endif
  2502. #endif
  2503. #include <common>
  2504. #include <uv_pars_vertex>
  2505. #include <displacementmap_pars_vertex>
  2506. #include <morphtarget_pars_vertex>
  2507. #include <skinning_pars_vertex>
  2508. #include <logdepthbuf_pars_vertex>
  2509. #include <clipping_planes_pars_vertex>
  2510. void main() {
  2511. #include <uv_vertex>
  2512. #include <beginnormal_vertex>
  2513. #include <morphnormal_vertex>
  2514. #include <skinbase_vertex>
  2515. #include <skinnormal_vertex>
  2516. #include <defaultnormal_vertex>
  2517. #ifndef FLAT_SHADED
  2518. vNormal = normalize( transformedNormal );
  2519. #ifdef USE_TANGENT
  2520. vTangent = normalize( transformedTangent );
  2521. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  2522. #endif
  2523. #endif
  2524. #include <begin_vertex>
  2525. #include <morphtarget_vertex>
  2526. #include <skinning_vertex>
  2527. #include <displacementmap_vertex>
  2528. #include <project_vertex>
  2529. #include <logdepthbuf_vertex>
  2530. #include <clipping_planes_vertex>
  2531. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2532. vViewPosition = - mvPosition.xyz;
  2533. #endif
  2534. }`,qS=`uniform vec3 diffuse;
  2535. uniform float opacity;
  2536. #include <common>
  2537. #include <color_pars_fragment>
  2538. #include <map_particle_pars_fragment>
  2539. #include <fog_pars_fragment>
  2540. #include <logdepthbuf_pars_fragment>
  2541. #include <clipping_planes_pars_fragment>
  2542. void main() {
  2543. #include <clipping_planes_fragment>
  2544. vec3 outgoingLight = vec3( 0.0 );
  2545. vec4 diffuseColor = vec4( diffuse, opacity );
  2546. #include <logdepthbuf_fragment>
  2547. #include <map_particle_fragment>
  2548. #include <color_fragment>
  2549. #include <alphatest_fragment>
  2550. outgoingLight = diffuseColor.rgb;
  2551. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2552. #include <tonemapping_fragment>
  2553. #include <encodings_fragment>
  2554. #include <fog_fragment>
  2555. #include <premultiplied_alpha_fragment>
  2556. }`,ZS=`uniform float size;
  2557. uniform float scale;
  2558. #include <common>
  2559. #include <color_pars_vertex>
  2560. #include <fog_pars_vertex>
  2561. #include <morphtarget_pars_vertex>
  2562. #include <logdepthbuf_pars_vertex>
  2563. #include <clipping_planes_pars_vertex>
  2564. void main() {
  2565. #include <color_vertex>
  2566. #include <begin_vertex>
  2567. #include <morphtarget_vertex>
  2568. #include <project_vertex>
  2569. gl_PointSize = size;
  2570. #ifdef USE_SIZEATTENUATION
  2571. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2572. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  2573. #endif
  2574. #include <logdepthbuf_vertex>
  2575. #include <clipping_planes_vertex>
  2576. #include <worldpos_vertex>
  2577. #include <fog_vertex>
  2578. }`,XS=`uniform vec3 color;
  2579. uniform float opacity;
  2580. #include <common>
  2581. #include <packing>
  2582. #include <fog_pars_fragment>
  2583. #include <bsdfs>
  2584. #include <lights_pars_begin>
  2585. #include <shadowmap_pars_fragment>
  2586. #include <shadowmask_pars_fragment>
  2587. void main() {
  2588. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  2589. #include <tonemapping_fragment>
  2590. #include <encodings_fragment>
  2591. #include <fog_fragment>
  2592. }`,YS=`#include <fog_pars_vertex>
  2593. #include <shadowmap_pars_vertex>
  2594. void main() {
  2595. #include <begin_vertex>
  2596. #include <project_vertex>
  2597. #include <worldpos_vertex>
  2598. #include <shadowmap_vertex>
  2599. #include <fog_vertex>
  2600. }`,$S=`uniform vec3 diffuse;
  2601. uniform float opacity;
  2602. #include <common>
  2603. #include <uv_pars_fragment>
  2604. #include <map_pars_fragment>
  2605. #include <alphamap_pars_fragment>
  2606. #include <fog_pars_fragment>
  2607. #include <logdepthbuf_pars_fragment>
  2608. #include <clipping_planes_pars_fragment>
  2609. void main() {
  2610. #include <clipping_planes_fragment>
  2611. vec3 outgoingLight = vec3( 0.0 );
  2612. vec4 diffuseColor = vec4( diffuse, opacity );
  2613. #include <logdepthbuf_fragment>
  2614. #include <map_fragment>
  2615. #include <alphamap_fragment>
  2616. #include <alphatest_fragment>
  2617. outgoingLight = diffuseColor.rgb;
  2618. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2619. #include <tonemapping_fragment>
  2620. #include <encodings_fragment>
  2621. #include <fog_fragment>
  2622. }`,JS=`uniform float rotation;
  2623. uniform vec2 center;
  2624. #include <common>
  2625. #include <uv_pars_vertex>
  2626. #include <fog_pars_vertex>
  2627. #include <logdepthbuf_pars_vertex>
  2628. #include <clipping_planes_pars_vertex>
  2629. void main() {
  2630. #include <uv_vertex>
  2631. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  2632. vec2 scale;
  2633. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  2634. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  2635. #ifndef USE_SIZEATTENUATION
  2636. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2637. if ( isPerspective ) scale *= - mvPosition.z;
  2638. #endif
  2639. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  2640. vec2 rotatedPosition;
  2641. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  2642. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  2643. mvPosition.xy += rotatedPosition;
  2644. gl_Position = projectionMatrix * mvPosition;
  2645. #include <logdepthbuf_vertex>
  2646. #include <clipping_planes_vertex>
  2647. #include <fog_vertex>
  2648. }`,Yn={alphamap_fragment:R2,alphamap_pars_fragment:z2,alphatest_fragment:k2,aomap_fragment:B2,aomap_pars_fragment:F2,begin_vertex:O2,beginnormal_vertex:N2,bsdfs:U2,bumpmap_pars_fragment:V2,clipping_planes_fragment:G2,clipping_planes_pars_fragment:H2,clipping_planes_pars_vertex:W2,clipping_planes_vertex:j2,color_fragment:q2,color_pars_fragment:Z2,color_pars_vertex:X2,color_vertex:Y2,common:$2,cube_uv_reflection_fragment:J2,defaultnormal_vertex:K2,displacementmap_pars_vertex:Q2,displacementmap_vertex:eE,emissivemap_fragment:tE,emissivemap_pars_fragment:nE,encodings_fragment:iE,encodings_pars_fragment:rE,envmap_fragment:aE,envmap_common_pars_fragment:oE,envmap_pars_fragment:sE,envmap_pars_vertex:lE,envmap_physical_pars_fragment:vE,envmap_vertex:cE,fog_vertex:uE,fog_pars_vertex:hE,fog_fragment:dE,fog_pars_fragment:pE,gradientmap_pars_fragment:fE,lightmap_fragment:mE,lightmap_pars_fragment:gE,lights_lambert_vertex:_E,lights_pars_begin:yE,lights_toon_fragment:xE,lights_toon_pars_fragment:bE,lights_phong_fragment:wE,lights_phong_pars_fragment:ME,lights_physical_fragment:TE,lights_physical_pars_fragment:EE,lights_fragment_begin:SE,lights_fragment_maps:AE,lights_fragment_end:CE,logdepthbuf_fragment:PE,logdepthbuf_pars_fragment:LE,logdepthbuf_pars_vertex:DE,logdepthbuf_vertex:IE,map_fragment:RE,map_pars_fragment:zE,map_particle_fragment:kE,map_particle_pars_fragment:BE,metalnessmap_fragment:FE,metalnessmap_pars_fragment:OE,morphnormal_vertex:NE,morphtarget_pars_vertex:UE,morphtarget_vertex:VE,normal_fragment_begin:GE,normal_fragment_maps:HE,normalmap_pars_fragment:WE,clearcoat_normal_fragment_begin:jE,clearcoat_normal_fragment_maps:qE,clearcoat_normalmap_pars_fragment:ZE,packing:XE,premultiplied_alpha_fragment:YE,project_vertex:$E,dithering_fragment:JE,dithering_pars_fragment:KE,roughnessmap_fragment:QE,roughnessmap_pars_fragment:eS,shadowmap_pars_fragment:tS,shadowmap_pars_vertex:nS,shadowmap_vertex:iS,shadowmask_pars_fragment:rS,skinbase_vertex:aS,skinning_pars_vertex:oS,skinning_vertex:sS,skinnormal_vertex:lS,specularmap_fragment:cS,specularmap_pars_fragment:uS,tonemapping_fragment:hS,tonemapping_pars_fragment:dS,uv_pars_fragment:pS,uv_pars_vertex:fS,uv_vertex:mS,uv2_pars_fragment:gS,uv2_pars_vertex:_S,uv2_vertex:yS,worldpos_vertex:vS,background_frag:xS,background_vert:bS,cube_frag:wS,cube_vert:MS,depth_frag:TS,depth_vert:ES,distanceRGBA_frag:SS,distanceRGBA_vert:AS,equirect_frag:CS,equirect_vert:PS,linedashed_frag:LS,linedashed_vert:DS,meshbasic_frag:IS,meshbasic_vert:RS,meshlambert_frag:zS,meshlambert_vert:kS,meshmatcap_frag:BS,meshmatcap_vert:FS,meshtoon_frag:OS,meshtoon_vert:NS,meshphong_frag:US,meshphong_vert:VS,meshphysical_frag:GS,meshphysical_vert:HS,normal_frag:WS,normal_vert:jS,points_frag:qS,points_vert:ZS,shadow_frag:XS,shadow_vert:YS,sprite_frag:$S,sprite_vert:JS},Ro={basic:{uniforms:pr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.fog]),vertexShader:Yn.meshbasic_vert,fragmentShader:Yn.meshbasic_frag},lambert:{uniforms:pr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.fog,an.lights,{emissive:{value:new en(0)}}]),vertexShader:Yn.meshlambert_vert,fragmentShader:Yn.meshlambert_frag},phong:{uniforms:pr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.bumpmap,an.normalmap,an.displacementmap,an.fog,an.lights,{emissive:{value:new en(0)},specular:{value:new en(1118481)},shininess:{value:30}}]),vertexShader:Yn.meshphong_vert,fragmentShader:Yn.meshphong_frag},standard:{uniforms:pr([an.common,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.bumpmap,an.normalmap,an.displacementmap,an.roughnessmap,an.metalnessmap,an.fog,an.lights,{emissive:{value:new en(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Yn.meshphysical_vert,fragmentShader:Yn.meshphysical_frag},toon:{uniforms:pr([an.common,an.specularmap,an.aomap,an.lightmap,an.emissivemap,an.bumpmap,an.normalmap,an.displacementmap,an.gradientmap,an.fog,an.lights,{emissive:{value:new en(0)},specular:{value:new en(1118481)},shininess:{value:30}}]),vertexShader:Yn.meshtoon_vert,fragmentShader:Yn.meshtoon_frag},matcap:{uniforms:pr([an.common,an.bumpmap,an.normalmap,an.displacementmap,an.fog,{matcap:{value:null}}]),vertexShader:Yn.meshmatcap_vert,fragmentShader:Yn.meshmatcap_frag},points:{uniforms:pr([an.points,an.fog]),vertexShader:Yn.points_vert,fragmentShader:Yn.points_frag},dashed:{uniforms:pr([an.common,an.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Yn.linedashed_vert,fragmentShader:Yn.linedashed_frag},depth:{uniforms:pr([an.common,an.displacementmap]),vertexShader:Yn.depth_vert,fragmentShader:Yn.depth_frag},normal:{uniforms:pr([an.common,an.bumpmap,an.normalmap,an.displacementmap,{opacity:{value:1}}]),vertexShader:Yn.normal_vert,fragmentShader:Yn.normal_frag},sprite:{uniforms:pr([an.sprite,an.fog]),vertexShader:Yn.sprite_vert,fragmentShader:Yn.sprite_frag},background:{uniforms:{uvTransform:{value:new dr},t2D:{value:null}},vertexShader:Yn.background_vert,fragmentShader:Yn.background_frag},cube:{uniforms:pr([an.envmap,{opacity:{value:1}}]),vertexShader:Yn.cube_vert,fragmentShader:Yn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Yn.equirect_vert,fragmentShader:Yn.equirect_frag},distanceRGBA:{uniforms:pr([an.common,an.displacementmap,{referencePosition:{value:new Ee},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Yn.distanceRGBA_vert,fragmentShader:Yn.distanceRGBA_frag},shadow:{uniforms:pr([an.lights,an.fog,{color:{value:new en(0)},opacity:{value:1}}]),vertexShader:Yn.shadow_vert,fragmentShader:Yn.shadow_frag}};Ro.physical={uniforms:pr([Ro.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new en(0)},clearcoatNormalScale:{value:new Lt(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:Yn.meshphysical_vert,fragmentShader:Yn.meshphysical_frag};function KS(e,n,i,l){var h=new en(0),p=0,_,s,M=null,T=0,C=null;function E(I,B,O,U){var q=B.background,ee=e.xr,he=ee.getSession&&ee.getSession();if(he&&he.environmentBlendMode==="additive"&&(q=null),q===null?L(h,p):q&&q.isColor&&(L(q,1),U=!0),(e.autoClear||U)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),q&&(q.isCubeTexture||q.isWebGLCubeRenderTarget||q.mapping===oh)){s===void 0&&(s=new Ai(new hf(1,1,1),new Nr({type:"BackgroundCubeMaterial",uniforms:vc(Ro.cube.uniforms),vertexShader:Ro.cube.vertexShader,fragmentShader:Ro.cube.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(K,ie,ue){this.matrixWorld.copyPosition(ue.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s));var Ce=q.isWebGLCubeRenderTarget?q.texture:q;s.material.uniforms.envMap.value=Ce,s.material.uniforms.flipEnvMap.value=Ce.isCubeTexture?-1:1,(M!==q||T!==Ce.version||C!==e.toneMapping)&&(s.material.needsUpdate=!0,M=q,T=Ce.version,C=e.toneMapping),I.unshift(s,s.geometry,s.material,0,0,null)}else q&&q.isTexture&&(_===void 0&&(_=new Ai(new Ec(2,2),new Nr({type:"BackgroundMaterial",uniforms:vc(Ro.background.uniforms),vertexShader:Ro.background.vertexShader,fragmentShader:Ro.background.fragmentShader,side:Jl,depthTest:!1,depthWrite:!1,fog:!1})),_.geometry.deleteAttribute("normal"),Object.defineProperty(_.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(_)),_.material.uniforms.t2D.value=q,q.matrixAutoUpdate===!0&&q.updateMatrix(),_.material.uniforms.uvTransform.value.copy(q.matrix),(M!==q||T!==q.version||C!==e.toneMapping)&&(_.material.needsUpdate=!0,M=q,T=q.version,C=e.toneMapping),I.unshift(_,_.geometry,_.material,0,0,null))}function L(I,B){n.buffers.color.setClear(I.r,I.g,I.b,B,l)}return{getClearColor:function(){return h},setClearColor:function(I,B){h.set(I),p=B!==void 0?B:1,L(h,p)},getClearAlpha:function(){return p},setClearAlpha:function(I){p=I,L(h,p)},render:E}}function QS(e,n,i,l){var h=l.isWebGL2,p;function _(T){p=T}function s(T,C){e.drawArrays(p,T,C),i.update(C,p)}function M(T,C,E,L){if(L!==0){var I,B;if(h)I=e,B="drawArraysInstanced";else if(I=n.get("ANGLE_instanced_arrays"),B="drawArraysInstancedANGLE",I===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}I[B](p,C,E,L),i.update(E,p,L)}}this.setMode=_,this.render=s,this.renderInstances=M}function eA(e,n,i){var l;function h(){if(l!==void 0)return l;var ie=n.get("EXT_texture_filter_anisotropic");return ie!==null?l=e.getParameter(ie.MAX_TEXTURE_MAX_ANISOTROPY_EXT):l=0,l}function p(ie){if(ie==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";ie="mediump"}return ie==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var _=typeof WebGL2RenderingContext!="undefined"&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&e instanceof WebGL2ComputeRenderingContext,s=i.precision!==void 0?i.precision:"highp",M=p(s);M!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",M,"instead."),s=M);var T=i.logarithmicDepthBuffer===!0,C=e.getParameter(34930),E=e.getParameter(35660),L=e.getParameter(3379),I=e.getParameter(34076),B=e.getParameter(34921),O=e.getParameter(36347),U=e.getParameter(36348),q=e.getParameter(36349),ee=E>0,he=_||!!n.get("OES_texture_float"),Ce=ee&&he,K=_?e.getParameter(36183):0;return{isWebGL2:_,getMaxAnisotropy:h,getMaxPrecision:p,precision:s,logarithmicDepthBuffer:T,maxTextures:C,maxVertexTextures:E,maxTextureSize:L,maxCubemapSize:I,maxAttributes:B,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:q,vertexTextures:ee,floatFragmentTextures:he,floatVertexTextures:Ce,maxSamples:K}}function tA(){var e=this,n=null,i=0,l=!1,h=!1,p=new ja,_=new dr,s={value:null,needsUpdate:!1};this.uniform=s,this.numPlanes=0,this.numIntersection=0,this.init=function(C,E,L){var I=C.length!==0||E||i!==0||l;return l=E,n=T(C,L,0),i=C.length,I},this.beginShadows=function(){h=!0,T(null)},this.endShadows=function(){h=!1,M()},this.setState=function(C,E,L,I,B,O){if(!l||C===null||C.length===0||h&&!L)h?T(null):M();else{var U=h?0:i,q=U*4,ee=B.clippingState||null;s.value=ee,ee=T(C,I,q,O);for(var he=0;he!==q;++he)ee[he]=n[he];B.clippingState=ee,this.numIntersection=E?this.numPlanes:0,this.numPlanes+=U}};function M(){s.value!==n&&(s.value=n,s.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function T(C,E,L,I){var B=C!==null?C.length:0,O=null;if(B!==0){if(O=s.value,I!==!0||O===null){var U=L+B*4,q=E.matrixWorldInverse;_.getNormalMatrix(q),(O===null||O.length<U)&&(O=new Float32Array(U));for(var ee=0,he=L;ee!==B;++ee,he+=4)p.copy(C[ee]).applyMatrix4(q,_),p.normal.toArray(O,he),O[he+3]=p.constant}s.value=O,s.needsUpdate=!0}return e.numPlanes=B,O}}function nA(e){var n={};return{get:function(i){if(n[i]!==void 0)return n[i];var l;switch(i){case"WEBGL_depth_texture":l=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":l=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":l=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":l=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:l=e.getExtension(i)}return l===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),n[i]=l,l}}}function iA(e,n,i){var l=new WeakMap,h=new WeakMap;function p(C){var E=C.target,L=l.get(E);L.index!==null&&n.remove(L.index);for(var I in L.attributes)n.remove(L.attributes[I]);E.removeEventListener("dispose",p),l.delete(E);var B=h.get(L);B&&(n.remove(B),h.delete(L)),i.memory.geometries--}function _(C,E){var L=l.get(E);return L||(E.addEventListener("dispose",p),E.isBufferGeometry?L=E:E.isGeometry&&(E._bufferGeometry===void 0&&(E._bufferGeometry=new yn().setFromObject(C)),L=E._bufferGeometry),l.set(E,L),i.memory.geometries++,L)}function s(C){var E=C.index,L=C.attributes;E!==null&&n.update(E,34963);for(var I in L)n.update(L[I],34962);var B=C.morphAttributes;for(var I in B)for(var O=B[I],U=0,q=O.length;U<q;U++)n.update(O[U],34962)}function M(C){var E=[],L=C.index,I=C.attributes.position,B=0;if(L!==null){var O=L.array;B=L.version;for(var U=0,q=O.length;U<q;U+=3){var ee=O[U+0],he=O[U+1],Ce=O[U+2];E.push(ee,he,he,Ce,Ce,ee)}}else{var O=I.array;B=I.version;for(var U=0,q=O.length/3-1;U<q;U+=3){var ee=U+0,he=U+1,Ce=U+2;E.push(ee,he,he,Ce,Ce,ee)}}var K=new(V0(E)>65535?yh:_h)(E,1);K.version=B,n.update(K,34963);var ie=h.get(C);ie&&n.remove(ie),h.set(C,K)}function T(C){var E=h.get(C);if(E){var L=C.index;L!==null&&E.version<L.version&&M(C)}else M(C);return h.get(C)}return{get:_,update:s,getWireframeAttribute:T}}function rA(e,n,i,l){var h=l.isWebGL2,p;function _(L){p=L}var s,M;function T(L){s=L.type,M=L.bytesPerElement}function C(L,I){e.drawElements(p,I,s,L*M),i.update(I,p)}function E(L,I,B,O){if(O!==0){var U,q;if(h)U=e,q="drawElementsInstanced";else if(U=n.get("ANGLE_instanced_arrays"),q="drawElementsInstancedANGLE",U===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}U[q](p,B,s,I*M,O),i.update(B,p,O)}}this.setMode=_,this.setIndex=T,this.render=C,this.renderInstances=E}function aA(e){var n={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines:0};function l(p,_,s){switch(s=s||1,i.calls++,_){case 4:i.triangles+=s*(p/3);break;case 1:i.lines+=s*(p/2);break;case 3:i.lines+=s*(p-1);break;case 2:i.lines+=s*p;break;case 0:i.points+=s*p;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",_);break}}function h(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}return{memory:n,render:i,programs:null,autoReset:!0,reset:h,update:l}}function oA(e,n){return Math.abs(n[1])-Math.abs(e[1])}function sA(e){var n={},i=new Float32Array(8);function l(h,p,_,s){var M=h.morphTargetInfluences,T=M===void 0?0:M.length,C=n[p.id];if(C===void 0){C=[];for(var E=0;E<T;E++)C[E]=[E,0];n[p.id]=C}for(var L=_.morphTargets&&p.morphAttributes.position,I=_.morphNormals&&p.morphAttributes.normal,E=0;E<T;E++){var B=C[E];B[1]!==0&&(L&&p.deleteAttribute("morphTarget"+E),I&&p.deleteAttribute("morphNormal"+E))}for(var E=0;E<T;E++){var B=C[E];B[0]=E,B[1]=M[E]}C.sort(oA);for(var O=0,E=0;E<8;E++){var B=C[E];if(B){var U=B[0],q=B[1];if(q){L&&p.setAttribute("morphTarget"+E,L[U]),I&&p.setAttribute("morphNormal"+E,I[U]),i[E]=q,O+=q;continue}}i[E]=0}var ee=p.morphTargetsRelative?1:1-O;s.getUniforms().setValue(e,"morphTargetBaseInfluence",ee),s.getUniforms().setValue(e,"morphTargetInfluences",i)}return{update:l}}function lA(e,n,i,l){var h={};function p(s){var M=l.render.frame,T=s.geometry,C=n.get(s,T);return h[C.id]!==M&&(T.isGeometry&&C.updateFromObject(s),n.update(C),h[C.id]=M),s.isInstancedMesh&&i.update(s.instanceMatrix,34962),C}function _(){h={}}return{update:p,dispose:_}}function rs(e,n,i,l,h,p,_,s,M,T){e=e!==void 0?e:[],n=n!==void 0?n:jg,_=_!==void 0?_:Mo,mi.call(this,e,n,i,l,h,p,_,s,M,T),this.flipY=!1}rs.prototype=Object.create(mi.prototype),rs.prototype.constructor=rs,rs.prototype.isCubeTexture=!0,Object.defineProperty(rs.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});function Mh(e,n,i,l){mi.call(this,null),this.image={data:e||null,width:n||1,height:i||1,depth:l||1},this.magFilter=Ui,this.minFilter=Ui,this.wrapR=wr,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Mh.prototype=Object.create(mi.prototype),Mh.prototype.constructor=Mh,Mh.prototype.isDataTexture2DArray=!0;function Th(e,n,i,l){mi.call(this,null),this.image={data:e||null,width:n||1,height:i||1,depth:l||1},this.magFilter=Ui,this.minFilter=Ui,this.wrapR=wr,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Th.prototype=Object.create(mi.prototype),Th.prototype.constructor=Th,Th.prototype.isDataTexture3D=!0;var j0=new mi,cA=new Mh,uA=new Th,q0=new rs,Z0=[],X0=[],Y0=new Float32Array(16),$0=new Float32Array(9),J0=new Float32Array(4);function Sc(e,n,i){var l=e[0];if(l<=0||l>0)return e;var h=n*i,p=Z0[h];if(p===void 0&&(p=new Float32Array(h),Z0[h]=p),n!==0){l.toArray(p,0);for(var _=1,s=0;_!==n;++_)s+=i,e[_].toArray(p,s)}return p}function ya(e,n){if(e.length!==n.length)return!1;for(var i=0,l=e.length;i<l;i++)if(e[i]!==n[i])return!1;return!0}function oa(e,n){for(var i=0,l=n.length;i<l;i++)e[i]=n[i]}function K0(e,n){var i=X0[n];i===void 0&&(i=new Int32Array(n),X0[n]=i);for(var l=0;l!==n;++l)i[l]=e.allocateTextureUnit();return i}function hA(e,n){var i=this.cache;i[0]!==n&&(e.uniform1f(this.addr,n),i[0]=n)}function dA(e,n){var i=this.cache;if(n.x!==void 0)(i[0]!==n.x||i[1]!==n.y)&&(e.uniform2f(this.addr,n.x,n.y),i[0]=n.x,i[1]=n.y);else{if(ya(i,n))return;e.uniform2fv(this.addr,n),oa(i,n)}}function pA(e,n){var i=this.cache;if(n.x!==void 0)(i[0]!==n.x||i[1]!==n.y||i[2]!==n.z)&&(e.uniform3f(this.addr,n.x,n.y,n.z),i[0]=n.x,i[1]=n.y,i[2]=n.z);else if(n.r!==void 0)(i[0]!==n.r||i[1]!==n.g||i[2]!==n.b)&&(e.uniform3f(this.addr,n.r,n.g,n.b),i[0]=n.r,i[1]=n.g,i[2]=n.b);else{if(ya(i,n))return;e.uniform3fv(this.addr,n),oa(i,n)}}function fA(e,n){var i=this.cache;if(n.x!==void 0)(i[0]!==n.x||i[1]!==n.y||i[2]!==n.z||i[3]!==n.w)&&(e.uniform4f(this.addr,n.x,n.y,n.z,n.w),i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=n.w);else{if(ya(i,n))return;e.uniform4fv(this.addr,n),oa(i,n)}}function mA(e,n){var i=this.cache,l=n.elements;if(l===void 0){if(ya(i,n))return;e.uniformMatrix2fv(this.addr,!1,n),oa(i,n)}else{if(ya(i,l))return;J0.set(l),e.uniformMatrix2fv(this.addr,!1,J0),oa(i,l)}}function gA(e,n){var i=this.cache,l=n.elements;if(l===void 0){if(ya(i,n))return;e.uniformMatrix3fv(this.addr,!1,n),oa(i,n)}else{if(ya(i,l))return;$0.set(l),e.uniformMatrix3fv(this.addr,!1,$0),oa(i,l)}}function _A(e,n){var i=this.cache,l=n.elements;if(l===void 0){if(ya(i,n))return;e.uniformMatrix4fv(this.addr,!1,n),oa(i,n)}else{if(ya(i,l))return;Y0.set(l),e.uniformMatrix4fv(this.addr,!1,Y0),oa(i,l)}}function yA(e,n,i){var l=this.cache,h=i.allocateTextureUnit();l[0]!==h&&(e.uniform1i(this.addr,h),l[0]=h),i.safeSetTexture2D(n||j0,h)}function vA(e,n,i){var l=this.cache,h=i.allocateTextureUnit();l[0]!==h&&(e.uniform1i(this.addr,h),l[0]=h),i.setTexture2DArray(n||cA,h)}function xA(e,n,i){var l=this.cache,h=i.allocateTextureUnit();l[0]!==h&&(e.uniform1i(this.addr,h),l[0]=h),i.setTexture3D(n||uA,h)}function bA(e,n,i){var l=this.cache,h=i.allocateTextureUnit();l[0]!==h&&(e.uniform1i(this.addr,h),l[0]=h),i.safeSetTextureCube(n||q0,h)}function wA(e,n){var i=this.cache;i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n)}function MA(e,n){var i=this.cache;ya(i,n)||(e.uniform2iv(this.addr,n),oa(i,n))}function TA(e,n){var i=this.cache;ya(i,n)||(e.uniform3iv(this.addr,n),oa(i,n))}function EA(e,n){var i=this.cache;ya(i,n)||(e.uniform4iv(this.addr,n),oa(i,n))}function SA(e,n){var i=this.cache;i[0]!==n&&(e.uniform1ui(this.addr,n),i[0]=n)}function AA(e){switch(e){case 5126:return hA;case 35664:return dA;case 35665:return pA;case 35666:return fA;case 35674:return mA;case 35675:return gA;case 35676:return _A;case 5124:case 35670:return wA;case 35667:case 35671:return MA;case 35668:case 35672:return TA;case 35669:case 35673:return EA;case 5125:return SA;case 35678:case 36198:case 36298:case 36306:case 35682:return yA;case 35679:case 36299:case 36307:return xA;case 35680:case 36300:case 36308:case 36293:return bA;case 36289:case 36303:case 36311:case 36292:return vA}}function CA(e,n){e.uniform1fv(this.addr,n)}function PA(e,n){e.uniform1iv(this.addr,n)}function LA(e,n){e.uniform2iv(this.addr,n)}function DA(e,n){e.uniform3iv(this.addr,n)}function IA(e,n){e.uniform4iv(this.addr,n)}function RA(e,n){var i=Sc(n,this.size,2);e.uniform2fv(this.addr,i)}function zA(e,n){var i=Sc(n,this.size,3);e.uniform3fv(this.addr,i)}function kA(e,n){var i=Sc(n,this.size,4);e.uniform4fv(this.addr,i)}function BA(e,n){var i=Sc(n,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function FA(e,n){var i=Sc(n,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function OA(e,n){var i=Sc(n,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function NA(e,n,i){var l=n.length,h=K0(i,l);e.uniform1iv(this.addr,h);for(var p=0;p!==l;++p)i.safeSetTexture2D(n[p]||j0,h[p])}function UA(e,n,i){var l=n.length,h=K0(i,l);e.uniform1iv(this.addr,h);for(var p=0;p!==l;++p)i.safeSetTextureCube(n[p]||q0,h[p])}function VA(e){switch(e){case 5126:return CA;case 35664:return RA;case 35665:return zA;case 35666:return kA;case 35674:return BA;case 35675:return FA;case 35676:return OA;case 5124:case 35670:return PA;case 35667:case 35671:return LA;case 35668:case 35672:return DA;case 35669:case 35673:return IA;case 35678:case 36198:case 36298:case 36306:case 35682:return NA;case 35680:case 36300:case 36308:case 36293:return UA}}function GA(e,n,i){this.id=e,this.addr=i,this.cache=[],this.setValue=AA(n.type)}function Q0(e,n,i){this.id=e,this.addr=i,this.cache=[],this.size=n.size,this.setValue=VA(n.type)}Q0.prototype.updateCache=function(e){var n=this.cache;e instanceof Float32Array&&n.length!==e.length&&(this.cache=new Float32Array(e.length)),oa(n,e)};function ex(e){this.id=e,this.seq=[],this.map={}}ex.prototype.setValue=function(e,n,i){for(var l=this.seq,h=0,p=l.length;h!==p;++h){var _=l[h];_.setValue(e,n[_.id],i)}};var E_=/([\w\d_]+)(\])?(\[|\.)?/g;function tx(e,n){e.seq.push(n),e.map[n.id]=n}function HA(e,n,i){var l=e.name,h=l.length;for(E_.lastIndex=0;;){var p=E_.exec(l),_=E_.lastIndex,s=p[1],M=p[2]==="]",T=p[3];if(M&&(s=s|0),T===void 0||T==="["&&_+2===h){tx(i,T===void 0?new GA(s,e,n):new Q0(s,e,n));break}else{var C=i.map,E=C[s];E===void 0&&(E=new ex(s),tx(i,E)),i=E}}}function as(e,n){this.seq=[],this.map={};for(var i=e.getProgramParameter(n,35718),l=0;l<i;++l){var h=e.getActiveUniform(n,l),p=e.getUniformLocation(n,h.name);HA(h,p,this)}}as.prototype.setValue=function(e,n,i,l){var h=this.map[n];h!==void 0&&h.setValue(e,i,l)},as.prototype.setOptional=function(e,n,i){var l=n[i];l!==void 0&&this.setValue(e,i,l)},as.upload=function(e,n,i,l){for(var h=0,p=n.length;h!==p;++h){var _=n[h],s=i[_.id];s.needsUpdate!==!1&&_.setValue(e,s.value,l)}},as.seqWithValue=function(e,n){for(var i=[],l=0,h=e.length;l!==h;++l){var p=e[l];p.id in n&&i.push(p)}return i};function nx(e,n,i){var l=e.createShader(n);return e.shaderSource(l,i),e.compileShader(l),l}var WA=0;function jA(e){for(var n=e.split(`
  2649. `),i=0;i<n.length;i++)n[i]=i+1+": "+n[i];return n.join(`
  2650. `)}function ix(e){switch(e){case ia:return["Linear","( value )"];case hh:return["sRGB","( value )"];case Kg:return["RGBE","( value )"];case S0:return["RGBM","( value, 7.0 )"];case A0:return["RGBM","( value, 16.0 )"];case C0:return["RGBD","( value, 256.0 )"];case E0:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case c2:return["LogLuv","( value )"];default:throw new Error("unsupported encoding: "+e)}}function rx(e,n,i){var l=e.getShaderParameter(n,35713),h=e.getShaderInfoLog(n).trim();if(l&&h==="")return"";var p=e.getShaderSource(n);return"THREE.WebGLShader: gl.getShaderInfoLog() "+i+`
  2651. `+h+jA(p)}function Eh(e,n){var i=ix(n);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function qA(e,n){var i=ix(n);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function ZA(e,n){var i;switch(n){case Hg:i="Linear";break;case MT:i="Reinhard";break;case TT:i="Uncharted2";break;case ET:i="OptimizedCineon";break;case ST:i="ACESFilmic";break;default:throw new Error("unsupported toneMapping: "+n)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function XA(e){var n=[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||e.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""];return n.filter(Sh).join(`
  2652. `)}function YA(e){var n=[];for(var i in e){var l=e[i];l!==!1&&n.push("#define "+i+" "+l)}return n.join(`
  2653. `)}function $A(e,n){for(var i={},l=e.getProgramParameter(n,35721),h=0;h<l;h++){var p=e.getActiveAttrib(n,h),_=p.name;i[_]=e.getAttribLocation(n,_)}return i}function Sh(e){return e!==""}function ax(e,n){return e.replace(/NUM_DIR_LIGHTS/g,n.numDirLights).replace(/NUM_SPOT_LIGHTS/g,n.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,n.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,n.numPointLights).replace(/NUM_HEMI_LIGHTS/g,n.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,n.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,n.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,n.numPointLightShadows)}function ox(e,n){return e.replace(/NUM_CLIPPING_PLANES/g,n.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,n.numClippingPlanes-n.numClipIntersection)}var JA=/^[ \t]*#include +<([\w\d./]+)>/gm;function S_(e){return e.replace(JA,KA)}function KA(e,n){var i=Yn[n];if(i===void 0)throw new Error("Can not resolve #include <"+n+">");return S_(i)}var QA=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function sx(e){return e.replace(QA,eC)}function eC(e,n,i,l){for(var h="",p=parseInt(n);p<parseInt(i);p++)h+=l.replace(/\[ i \]/g,"[ "+p+" ]").replace(/UNROLLED_LOOP_INDEX/g,p);return h}function lx(e){var n="precision "+e.precision+` float;
  2654. precision `+e.precision+" int;";return e.precision==="highp"?n+=`
  2655. #define HIGH_PRECISION`:e.precision==="mediump"?n+=`
  2656. #define MEDIUM_PRECISION`:e.precision==="lowp"&&(n+=`
  2657. #define LOW_PRECISION`),n}function tC(e){var n="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===i0?n="SHADOWMAP_TYPE_PCF":e.shadowMapType===eT?n="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===ih&&(n="SHADOWMAP_TYPE_VSM"),n}function nC(e){var n="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case jg:case qg:n="ENVMAP_TYPE_CUBE";break;case oh:case Xg:n="ENVMAP_TYPE_CUBE_UV";break;case p0:case Zg:n="ENVMAP_TYPE_EQUIREC";break;case f0:n="ENVMAP_TYPE_SPHERE";break}return n}function iC(e){var n="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case qg:case Zg:n="ENVMAP_MODE_REFRACTION";break}return n}function rC(e){var n="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Up:n="ENVMAP_BLENDING_MULTIPLY";break;case bT:n="ENVMAP_BLENDING_MIX";break;case wT:n="ENVMAP_BLENDING_ADD";break}return n}function aC(e,n,i){var l=e.getContext(),h=i.defines,p=i.vertexShader,_=i.fragmentShader,s=tC(i),M=nC(i),T=iC(i),C=rC(i),E=e.gammaFactor>0?e.gammaFactor:1,L=i.isWebGL2?"":XA(i),I=YA(h),B=l.createProgram(),O,U,q=i.numMultiviewViews;if(i.isRawShaderMaterial?(O=[I].filter(Sh).join(`
  2658. `),O.length>0&&(O+=`
  2659. `),U=[L,I].filter(Sh).join(`
  2660. `),U.length>0&&(U+=`
  2661. `)):(O=[lx(i),"#define SHADER_NAME "+i.shaderName,I,i.instancing?"#define USE_INSTANCING":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+E,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+T:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+s:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  2662. `].filter(Sh).join(`
  2663. `),U=[L,lx(i),"#define SHADER_NAME "+i.shaderName,I,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+E,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+M:"",i.envMap?"#define "+T:"",i.envMap?"#define "+C:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+s:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==Vp?"#define TONE_MAPPING":"",i.toneMapping!==Vp?Yn.tonemapping_pars_fragment:"",i.toneMapping!==Vp?ZA("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.outputEncoding||i.mapEncoding||i.matcapEncoding||i.envMapEncoding||i.emissiveMapEncoding||i.lightMapEncoding?Yn.encodings_pars_fragment:"",i.mapEncoding?Eh("mapTexelToLinear",i.mapEncoding):"",i.matcapEncoding?Eh("matcapTexelToLinear",i.matcapEncoding):"",i.envMapEncoding?Eh("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Eh("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMapEncoding?Eh("lightMapTexelToLinear",i.lightMapEncoding):"",i.outputEncoding?qA("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",`
  2664. `].filter(Sh).join(`
  2665. `)),p=S_(p),p=ax(p,i),p=ox(p,i),_=S_(_),_=ax(_,i),_=ox(_,i),p=sx(p),_=sx(_),i.isWebGL2&&!i.isRawShaderMaterial){var ee=!1,he=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&p.match(he)!==null&&_.match(he)!==null&&(ee=!0,p=p.replace(he,""),_=_.replace(he,"")),O=[`#version 300 es
  2666. `,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  2667. `)+`
  2668. `+O,U=[`#version 300 es
  2669. `,"#define varying in",ee?"":"out highp vec4 pc_fragColor;",ee?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  2670. `)+`
  2671. `+U,q>0&&(O=O.replace(`#version 300 es
  2672. `,[`#version 300 es
  2673. `,"#extension GL_OVR_multiview2 : require","layout(num_views = "+q+") in;","#define VIEW_ID gl_ViewID_OVR"].join(`
  2674. `)),O=O.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join(`
  2675. `),["uniform mat4 modelViewMatrices["+q+"];","uniform mat4 projectionMatrices["+q+"];","uniform mat4 viewMatrices["+q+"];","uniform mat3 normalMatrices["+q+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join(`
  2676. `)),U=U.replace(`#version 300 es
  2677. `,[`#version 300 es
  2678. `,"#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join(`
  2679. `)),U=U.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+q+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join(`
  2680. `)))}var Ce=O+p,K=U+_,ie=nx(l,35633,Ce),ue=nx(l,35632,K);if(l.attachShader(B,ie),l.attachShader(B,ue),i.index0AttributeName!==void 0?l.bindAttribLocation(B,0,i.index0AttributeName):i.morphTargets===!0&&l.bindAttribLocation(B,0,"position"),l.linkProgram(B),e.debug.checkShaderErrors){var ae=l.getProgramInfoLog(B).trim(),le=l.getShaderInfoLog(ie).trim(),De=l.getShaderInfoLog(ue).trim(),ye=!0,se=!0;if(l.getProgramParameter(B,35714)===!1){ye=!1;var Ue=rx(l,ie,"vertex"),Oe=rx(l,ue,"fragment");console.error("THREE.WebGLProgram: shader error: ",l.getError(),"35715",l.getProgramParameter(B,35715),"gl.getProgramInfoLog",ae,Ue,Oe)}else ae!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",ae):(le===""||De==="")&&(se=!1);se&&(this.diagnostics={runnable:ye,programLog:ae,vertexShader:{log:le,prefix:O},fragmentShader:{log:De,prefix:U}})}l.deleteShader(ie),l.deleteShader(ue);var We;this.getUniforms=function(){return We===void 0&&(We=new as(l,B)),We};var st;return this.getAttributes=function(){return st===void 0&&(st=$A(l,B)),st},this.destroy=function(){l.deleteProgram(B),this.program=void 0},this.name=i.shaderName,this.id=WA++,this.cacheKey=n,this.usedTimes=1,this.program=B,this.vertexShader=ie,this.fragmentShader=ue,this.numMultiviewViews=q,this}function oC(e,n,i){var l=[],h=i.isWebGL2,p=i.logarithmicDepthBuffer,_=i.floatVertexTextures,s=i.precision,M=i.maxVertexUniforms,T=i.vertexTextures,C={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},E=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","numMultiviewViews","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen"];function L(O,U){var q;if(U){var ee=Ro[U];q={name:O.type,uniforms:P2.clone(ee.uniforms),vertexShader:ee.vertexShader,fragmentShader:ee.fragmentShader}}else q={name:O.type,uniforms:O.uniforms,vertexShader:O.vertexShader,fragmentShader:O.fragmentShader};return q}function I(O){var U=O.skeleton,q=U.bones;if(_)return 1024;var ee=M,he=Math.floor((ee-20)/4),Ce=Math.min(he,q.length);return Ce<q.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+q.length+" bones. This GPU supports "+Ce+"."),0):Ce}function B(O){var U;return O?O.isTexture?U=O.encoding:O.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),U=O.texture.encoding):U=ia,U}this.getParameters=function(O,U,q,ee,he,Ce,K){var ie=ee.fog,ue=O.isMeshStandardMaterial?ee.environment:null,ae=O.envMap||ue,le=C[O.type],De=K.isSkinnedMesh?I(K):0;O.precision!==null&&(s=i.getMaxPrecision(O.precision),s!==O.precision&&console.warn("THREE.WebGLProgram.getParameters:",O.precision,"not supported, using",s,"instead."));var ye=L(O,le);O.onBeforeCompile(ye,e);var se=e.getRenderTarget(),Ue=se&&se.isWebGLMultiviewRenderTarget?se.numViews:0,Oe={isWebGL2:h,shaderID:le,shaderName:ye.name,uniforms:ye.uniforms,vertexShader:ye.vertexShader,fragmentShader:ye.fragmentShader,defines:O.defines,isRawShaderMaterial:O.isRawShaderMaterial,isShaderMaterial:O.isShaderMaterial,precision:s,instancing:K.isInstancedMesh===!0,supportsVertexTextures:T,numMultiviewViews:Ue,outputEncoding:se!==null?B(se.texture):e.outputEncoding,map:!!O.map,mapEncoding:B(O.map),matcap:!!O.matcap,matcapEncoding:B(O.matcap),envMap:!!ae,envMapMode:ae&&ae.mapping,envMapEncoding:B(ae),envMapCubeUV:!!ae&&(ae.mapping===oh||ae.mapping===Xg),lightMap:!!O.lightMap,lightMapEncoding:B(O.lightMap),aoMap:!!O.aoMap,emissiveMap:!!O.emissiveMap,emissiveMapEncoding:B(O.emissiveMap),bumpMap:!!O.bumpMap,normalMap:!!O.normalMap,objectSpaceNormalMap:O.normalMapType===d2,tangentSpaceNormalMap:O.normalMapType===Xs,clearcoatNormalMap:!!O.clearcoatNormalMap,displacementMap:!!O.displacementMap,roughnessMap:!!O.roughnessMap,metalnessMap:!!O.metalnessMap,specularMap:!!O.specularMap,alphaMap:!!O.alphaMap,gradientMap:!!O.gradientMap,sheen:!!O.sheen,combine:O.combine,vertexTangents:O.normalMap&&O.vertexTangents,vertexColors:O.vertexColors,vertexUvs:!!O.map||!!O.bumpMap||!!O.normalMap||!!O.specularMap||!!O.alphaMap||!!O.emissiveMap||!!O.roughnessMap||!!O.metalnessMap||!!O.clearcoatNormalMap||!!O.displacementMap,uvsVertexOnly:!(O.map||O.bumpMap||O.normalMap||O.specularMap||O.alphaMap||O.emissiveMap||O.roughnessMap||O.metalnessMap||O.clearcoatNormalMap)&&!!O.displacementMap,fog:!!ie,useFog:O.fog,fogExp2:ie&&ie.isFogExp2,flatShading:O.flatShading,sizeAttenuation:O.sizeAttenuation,logarithmicDepthBuffer:p,skinning:O.skinning&&De>0,maxBones:De,useVertexTexture:_,morphTargets:O.morphTargets,morphNormals:O.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:U.directional.length,numPointLights:U.point.length,numSpotLights:U.spot.length,numRectAreaLights:U.rectArea.length,numHemiLights:U.hemi.length,numDirLightShadows:U.directionalShadowMap.length,numPointLightShadows:U.pointShadowMap.length,numSpotLightShadows:U.spotShadowMap.length,numClippingPlanes:he,numClipIntersection:Ce,dithering:O.dithering,shadowMapEnabled:e.shadowMap.enabled&&q.length>0,shadowMapType:e.shadowMap.type,toneMapping:O.toneMapped?e.toneMapping:Vp,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:O.premultipliedAlpha,alphaTest:O.alphaTest,doubleSided:O.side===rh,flipSided:O.side===tr,depthPacking:O.depthPacking!==void 0?O.depthPacking:!1,index0AttributeName:O.index0AttributeName,extensionDerivatives:O.extensions&&O.extensions.derivatives,extensionFragDepth:O.extensions&&O.extensions.frawbuffers,extensionDrawbuffers:O.extensions&&O.extensions.drawbuffers,extensionShaderTextureLOD:O.extensions&&O.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.get("EXT_frag_depth")!==null,rendererExtensionDrawBuffers:h||n.get("WEBGL_draw_buffers")!==null,rendererExtensionShaderTextureLod:h||n.get("EXT_shader_texture_lod")!==null,onBeforeCompile:O.onBeforeCompile};return Oe},this.getProgramCacheKey=function(O){var U=[];if(O.shaderID?U.push(O.shaderID):(U.push(O.fragmentShader),U.push(O.vertexShader)),O.defines!==void 0)for(var q in O.defines)U.push(q),U.push(O.defines[q]);if(O.isRawShaderMaterial===void 0){for(var ee=0;ee<E.length;ee++)U.push(O[E[ee]]);U.push(e.outputEncoding),U.push(e.gammaFactor)}return U.push(O.onBeforeCompile.toString()),U.join()},this.acquireProgram=function(O,U){for(var q,ee=0,he=l.length;ee<he;ee++){var Ce=l[ee];if(Ce.cacheKey===U){q=Ce,++q.usedTimes;break}}return q===void 0&&(q=new aC(e,U,O),l.push(q)),q},this.releaseProgram=function(O){if(--O.usedTimes===0){var U=l.indexOf(O);l[U]=l[l.length-1],l.pop(),O.destroy()}},this.programs=l}function sC(){var e=new WeakMap;function n(p){var _=e.get(p);return _===void 0&&(_={},e.set(p,_)),_}function i(p){e.delete(p)}function l(p,_,s){e.get(p)[_]=s}function h(){e=new WeakMap}return{get:n,remove:i,update:l,dispose:h}}function lC(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.program!==n.program?e.program.id-n.program.id:e.material.id!==n.material.id?e.material.id-n.material.id:e.z!==n.z?e.z-n.z:e.id-n.id}function cC(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.z!==n.z?n.z-e.z:e.id-n.id}function cx(){var e=[],n=0,i=[],l=[],h={id:-1};function p(){n=0,i.length=0,l.length=0}function _(C,E,L,I,B,O){var U=e[n];return U===void 0?(U={id:C.id,object:C,geometry:E,material:L,program:L.program||h,groupOrder:I,renderOrder:C.renderOrder,z:B,group:O},e[n]=U):(U.id=C.id,U.object=C,U.geometry=E,U.material=L,U.program=L.program||h,U.groupOrder=I,U.renderOrder=C.renderOrder,U.z=B,U.group=O),n++,U}function s(C,E,L,I,B,O){var U=_(C,E,L,I,B,O);(L.transparent===!0?l:i).push(U)}function M(C,E,L,I,B,O){var U=_(C,E,L,I,B,O);(L.transparent===!0?l:i).unshift(U)}function T(C,E){i.length>1&&i.sort(C||lC),l.length>1&&l.sort(E||cC)}return{opaque:i,transparent:l,init:p,push:s,unshift:M,sort:T}}function uC(){var e=new WeakMap;function n(h){var p=h.target;p.removeEventListener("dispose",n),e.delete(p)}function i(h,p){var _=e.get(h),s;return _===void 0?(s=new cx,e.set(h,new WeakMap),e.get(h).set(p,s),h.addEventListener("dispose",n)):(s=_.get(p),s===void 0&&(s=new cx,_.set(p,s))),s}function l(){e=new WeakMap}return{get:i,dispose:l}}function hC(){var e={};return{get:function(n){if(e[n.id]!==void 0)return e[n.id];var i;switch(n.type){case"DirectionalLight":i={direction:new Ee,color:new en,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"SpotLight":i={position:new Ee,direction:new Ee,color:new en,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"PointLight":i={position:new Ee,color:new en,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new Ee,skyColor:new en,groundColor:new en};break;case"RectAreaLight":i={color:new en,position:new Ee,halfWidth:new Ee,halfHeight:new Ee};break}return e[n.id]=i,i}}}var dC=0;function pC(e,n){return(n.castShadow?1:0)-(e.castShadow?1:0)}function fC(){for(var e=new hC,n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},i=0;i<9;i++)n.probe.push(new Ee);var l=new Ee,h=new jn,p=new jn;function _(s,M,T){for(var C=0,E=0,L=0,I=0;I<9;I++)n.probe[I].set(0,0,0);var B=0,O=0,U=0,q=0,ee=0,he=0,Ce=0,K=0,ie=T.matrixWorldInverse;s.sort(pC);for(var I=0,ue=s.length;I<ue;I++){var ae=s[I],le=ae.color,De=ae.intensity,ye=ae.distance,se=ae.shadow&&ae.shadow.map?ae.shadow.map.texture:null;if(ae.isAmbientLight)C+=le.r*De,E+=le.g*De,L+=le.b*De;else if(ae.isLightProbe)for(var Ue=0;Ue<9;Ue++)n.probe[Ue].addScaledVector(ae.sh.coefficients[Ue],De);else if(ae.isDirectionalLight){var Oe=e.get(ae);if(Oe.color.copy(ae.color).multiplyScalar(ae.intensity),Oe.direction.setFromMatrixPosition(ae.matrixWorld),l.setFromMatrixPosition(ae.target.matrixWorld),Oe.direction.sub(l),Oe.direction.transformDirection(ie),Oe.shadow=ae.castShadow,ae.castShadow){var We=ae.shadow;Oe.shadowBias=We.bias,Oe.shadowRadius=We.radius,Oe.shadowMapSize=We.mapSize,n.directionalShadowMap[B]=se,n.directionalShadowMatrix[B]=ae.shadow.matrix,he++}n.directional[B]=Oe,B++}else if(ae.isSpotLight){var Oe=e.get(ae);if(Oe.position.setFromMatrixPosition(ae.matrixWorld),Oe.position.applyMatrix4(ie),Oe.color.copy(le).multiplyScalar(De),Oe.distance=ye,Oe.direction.setFromMatrixPosition(ae.matrixWorld),l.setFromMatrixPosition(ae.target.matrixWorld),Oe.direction.sub(l),Oe.direction.transformDirection(ie),Oe.coneCos=Math.cos(ae.angle),Oe.penumbraCos=Math.cos(ae.angle*(1-ae.penumbra)),Oe.decay=ae.decay,Oe.shadow=ae.castShadow,ae.castShadow){var We=ae.shadow;Oe.shadowBias=We.bias,Oe.shadowRadius=We.radius,Oe.shadowMapSize=We.mapSize,n.spotShadowMap[U]=se,n.spotShadowMatrix[U]=ae.shadow.matrix,K++}n.spot[U]=Oe,U++}else if(ae.isRectAreaLight){var Oe=e.get(ae);Oe.color.copy(le).multiplyScalar(De),Oe.position.setFromMatrixPosition(ae.matrixWorld),Oe.position.applyMatrix4(ie),p.identity(),h.copy(ae.matrixWorld),h.premultiply(ie),p.extractRotation(h),Oe.halfWidth.set(ae.width*.5,0,0),Oe.halfHeight.set(0,ae.height*.5,0),Oe.halfWidth.applyMatrix4(p),Oe.halfHeight.applyMatrix4(p),n.rectArea[q]=Oe,q++}else if(ae.isPointLight){var Oe=e.get(ae);if(Oe.position.setFromMatrixPosition(ae.matrixWorld),Oe.position.applyMatrix4(ie),Oe.color.copy(ae.color).multiplyScalar(ae.intensity),Oe.distance=ae.distance,Oe.decay=ae.decay,Oe.shadow=ae.castShadow,ae.castShadow){var We=ae.shadow;Oe.shadowBias=We.bias,Oe.shadowRadius=We.radius,Oe.shadowMapSize=We.mapSize,Oe.shadowCameraNear=We.camera.near,Oe.shadowCameraFar=We.camera.far,n.pointShadowMap[O]=se,n.pointShadowMatrix[O]=ae.shadow.matrix,Ce++}n.point[O]=Oe,O++}else if(ae.isHemisphereLight){var Oe=e.get(ae);Oe.direction.setFromMatrixPosition(ae.matrixWorld),Oe.direction.transformDirection(ie),Oe.direction.normalize(),Oe.skyColor.copy(ae.color).multiplyScalar(De),Oe.groundColor.copy(ae.groundColor).multiplyScalar(De),n.hemi[ee]=Oe,ee++}}n.ambient[0]=C,n.ambient[1]=E,n.ambient[2]=L;var st=n.hash;(st.directionalLength!==B||st.pointLength!==O||st.spotLength!==U||st.rectAreaLength!==q||st.hemiLength!==ee||st.numDirectionalShadows!==he||st.numPointShadows!==Ce||st.numSpotShadows!==K)&&(n.directional.length=B,n.spot.length=U,n.rectArea.length=q,n.point.length=O,n.hemi.length=ee,n.directionalShadowMap.length=he,n.pointShadowMap.length=Ce,n.spotShadowMap.length=K,n.directionalShadowMatrix.length=he,n.pointShadowMatrix.length=Ce,n.spotShadowMatrix.length=K,st.directionalLength=B,st.pointLength=O,st.spotLength=U,st.rectAreaLength=q,st.hemiLength=ee,st.numDirectionalShadows=he,st.numPointShadows=Ce,st.numSpotShadows=K,n.version=dC++)}return{setup:_,state:n}}function ux(){var e=new fC,n=[],i=[];function l(){n.length=0,i.length=0}function h(M){n.push(M)}function p(M){i.push(M)}function _(M){e.setup(n,i,M)}var s={lightsArray:n,shadowsArray:i,lights:e};return{init:l,state:s,setupLights:_,pushLight:h,pushShadow:p}}function mC(){var e=new WeakMap;function n(h){var p=h.target;p.removeEventListener("dispose",n),e.delete(p)}function i(h,p){var _;return e.has(h)===!1?(_=new ux,e.set(h,new WeakMap),e.get(h).set(p,_),h.addEventListener("dispose",n)):e.get(h).has(p)===!1?(_=new ux,e.get(h).set(p,_)):_=e.get(h).get(p),_}function l(){e=new WeakMap}return{get:i,dispose:l}}function nl(e){Rn.call(this),this.type="MeshDepthMaterial",this.depthPacking=u2,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}nl.prototype=Object.create(Rn.prototype),nl.prototype.constructor=nl,nl.prototype.isMeshDepthMaterial=!0,nl.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this};function il(e){Rn.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new Ee,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}il.prototype=Object.create(Rn.prototype),il.prototype.constructor=il,il.prototype.isMeshDistanceMaterial=!0,il.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};var gC=`uniform sampler2D shadow_pass;
  2681. uniform vec2 resolution;
  2682. uniform float radius;
  2683. #include <packing>
  2684. void main() {
  2685. float mean = 0.0;
  2686. float squared_mean = 0.0;
  2687. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
  2688. for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
  2689. #ifdef HORIZONAL_PASS
  2690. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
  2691. mean += distribution.x;
  2692. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  2693. #else
  2694. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
  2695. mean += depth;
  2696. squared_mean += depth * depth;
  2697. #endif
  2698. }
  2699. mean = mean * HALF_SAMPLE_RATE;
  2700. squared_mean = squared_mean * HALF_SAMPLE_RATE;
  2701. float std_dev = sqrt( squared_mean - mean * mean );
  2702. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  2703. }`,_C=`void main() {
  2704. gl_Position = vec4( position, 1.0 );
  2705. }`;function hx(e,n,i){var l=new wh,h=new Lt,p=new Lt,_=new gi,s=[],M=[],T={},C={0:tr,1:Jl,2:rh},E=new Nr({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lt},radius:{value:4}},vertexShader:_C,fragmentShader:gC}),L=E.clone();L.defines.HORIZONAL_PASS=1;var I=new yn;I.setAttribute("position",new zn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var B=new Ai(I,E),O=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=i0,this.render=function(K,ie,ue){if(O.enabled!==!1&&!(O.autoUpdate===!1&&O.needsUpdate===!1)&&K.length!==0){var ae=e.getRenderTarget(),le=e.getActiveCubeFace(),De=e.getActiveMipmapLevel(),ye=e.state;ye.setBlending(Qo),ye.buffers.color.setClear(1,1,1,1),ye.buffers.depth.setTest(!0),ye.setScissorTest(!1);for(var se=0,Ue=K.length;se<Ue;se++){var Oe=K[se],We=Oe.shadow;if(We===void 0){console.warn("THREE.WebGLShadowMap:",Oe,"has no shadow.");continue}h.copy(We.mapSize);var st=We.getFrameExtents();if(h.multiply(st),p.copy(We.mapSize),(h.x>i||h.y>i)&&(console.warn("THREE.WebGLShadowMap:",Oe,"has shadow exceeding max texture size, reducing"),h.x>i&&(p.x=Math.floor(i/st.x),h.x=p.x*st.x,We.mapSize.x=p.x),h.y>i&&(p.y=Math.floor(i/st.y),h.y=p.y*st.y,We.mapSize.y=p.y)),We.map===null&&!We.isPointLightShadow&&this.type===ih){var St={minFilter:qi,magFilter:qi,format:Aa};We.map=new Mr(h.x,h.y,St),We.map.texture.name=Oe.name+".shadowMap",We.mapPass=new Mr(h.x,h.y,St),We.camera.updateProjectionMatrix()}if(We.map===null){var St={minFilter:Ui,magFilter:Ui,format:Aa};We.map=new Mr(h.x,h.y,St),We.map.texture.name=Oe.name+".shadowMap",We.camera.updateProjectionMatrix()}e.setRenderTarget(We.map),e.clear();for(var gt=We.getViewportCount(),At=0;At<gt;At++){var Dt=We.getViewport(At);_.set(p.x*Dt.x,p.y*Dt.y,p.x*Dt.z,p.y*Dt.w),ye.viewport(_),We.updateMatrices(Oe,At),l=We.getFrustum(),Ce(ie,ue,We.camera,Oe,this.type)}!We.isPointLightShadow&&this.type===ih&&U(We,ue)}O.needsUpdate=!1,e.setRenderTarget(ae,le,De)}};function U(K,ie){var ue=n.update(B);E.uniforms.shadow_pass.value=K.map.texture,E.uniforms.resolution.value=K.mapSize,E.uniforms.radius.value=K.radius,e.setRenderTarget(K.mapPass),e.clear(),e.renderBufferDirect(ie,null,ue,E,B,null),L.uniforms.shadow_pass.value=K.mapPass.texture,L.uniforms.resolution.value=K.mapSize,L.uniforms.radius.value=K.radius,e.setRenderTarget(K.map),e.clear(),e.renderBufferDirect(ie,null,ue,L,B,null)}function q(K,ie,ue){var ae=K<<0|ie<<1|ue<<2,le=s[ae];return le===void 0&&(le=new nl({depthPacking:h2,morphTargets:K,skinning:ie}),s[ae]=le),le}function ee(K,ie,ue){var ae=K<<0|ie<<1|ue<<2,le=M[ae];return le===void 0&&(le=new il({morphTargets:K,skinning:ie}),M[ae]=le),le}function he(K,ie,ue,ae,le,De){var ye=K.geometry,se=null,Ue=q,Oe=K.customDepthMaterial;if(ue.isPointLight===!0&&(Ue=ee,Oe=K.customDistanceMaterial),Oe===void 0){var We=!1;ie.morphTargets===!0&&(ye.isBufferGeometry===!0?We=ye.morphAttributes&&ye.morphAttributes.position&&ye.morphAttributes.position.length>0:ye.isGeometry===!0&&(We=ye.morphTargets&&ye.morphTargets.length>0));var st=!1;K.isSkinnedMesh===!0&&(ie.skinning===!0?st=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",K));var St=K.isInstancedMesh===!0;se=Ue(We,st,St)}else se=Oe;if(e.localClippingEnabled&&ie.clipShadows===!0&&ie.clippingPlanes.length!==0){var gt=se.uuid,At=ie.uuid,Dt=T[gt];Dt===void 0&&(Dt={},T[gt]=Dt);var Ot=Dt[At];Ot===void 0&&(Ot=se.clone(),Dt[At]=Ot),se=Ot}return se.visible=ie.visible,se.wireframe=ie.wireframe,De===ih?se.side=ie.shadowSide!==null?ie.shadowSide:ie.side:se.side=ie.shadowSide!==null?ie.shadowSide:C[ie.side],se.clipShadows=ie.clipShadows,se.clippingPlanes=ie.clippingPlanes,se.clipIntersection=ie.clipIntersection,se.wireframeLinewidth=ie.wireframeLinewidth,se.linewidth=ie.linewidth,ue.isPointLight===!0&&se.isMeshDistanceMaterial===!0&&(se.referencePosition.setFromMatrixPosition(ue.matrixWorld),se.nearDistance=ae,se.farDistance=le),se}function Ce(K,ie,ue,ae,le){if(K.visible!==!1){var De=K.layers.test(ie.layers);if(De&&(K.isMesh||K.isLine||K.isPoints)&&(K.castShadow||K.receiveShadow&&le===ih)&&(!K.frustumCulled||l.intersectsObject(K))){K.modelViewMatrix.multiplyMatrices(ue.matrixWorldInverse,K.matrixWorld);var ye=n.update(K),se=K.material;if(Array.isArray(se))for(var Ue=ye.groups,Oe=0,We=Ue.length;Oe<We;Oe++){var st=Ue[Oe],St=se[st.materialIndex];if(St&&St.visible){var gt=he(K,St,ae,ue.near,ue.far,le);e.renderBufferDirect(ue,null,ye,gt,K,st)}}else if(se.visible){var gt=he(K,se,ae,ue.near,ue.far,le);e.renderBufferDirect(ue,null,ye,gt,K,null)}}for(var At=K.children,Dt=0,Ot=At.length;Dt<Ot;Dt++)Ce(At[Dt],ie,ue,ae,le)}}}function yC(e,n,i){var l=i.isWebGL2;function h(){var qe=!1,Nt=new gi,Qt=null,Pn=new gi(0,0,0,0);return{setMask:function(pn){Qt!==pn&&!qe&&(e.colorMask(pn,pn,pn,pn),Qt=pn)},setLocked:function(pn){qe=pn},setClear:function(pn,On,Gn,Zn,Wi){Wi===!0&&(pn*=Zn,On*=Zn,Gn*=Zn),Nt.set(pn,On,Gn,Zn),Pn.equals(Nt)===!1&&(e.clearColor(pn,On,Gn,Zn),Pn.copy(Nt))},reset:function(){qe=!1,Qt=null,Pn.set(-1,0,0,0)}}}function p(){var qe=!1,Nt=null,Qt=null,Pn=null;return{setTest:function(pn){pn?ce(2929):we(2929)},setMask:function(pn){Nt!==pn&&!qe&&(e.depthMask(pn),Nt=pn)},setFunc:function(pn){if(Qt!==pn){if(pn)switch(pn){case fT:e.depthFunc(512);break;case mT:e.depthFunc(519);break;case gT:e.depthFunc(513);break;case Gg:e.depthFunc(515);break;case _T:e.depthFunc(514);break;case yT:e.depthFunc(518);break;case vT:e.depthFunc(516);break;case xT:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);Qt=pn}},setLocked:function(pn){qe=pn},setClear:function(pn){Pn!==pn&&(e.clearDepth(pn),Pn=pn)},reset:function(){qe=!1,Nt=null,Qt=null,Pn=null}}}function _(){var qe=!1,Nt=null,Qt=null,Pn=null,pn=null,On=null,Gn=null,Zn=null,Wi=null;return{setTest:function(Nn){qe||(Nn?ce(2960):we(2960))},setMask:function(Nn){Nt!==Nn&&!qe&&(e.stencilMask(Nn),Nt=Nn)},setFunc:function(Nn,Ci,ei){(Qt!==Nn||Pn!==Ci||pn!==ei)&&(e.stencilFunc(Nn,Ci,ei),Qt=Nn,Pn=Ci,pn=ei)},setOp:function(Nn,Ci,ei){(On!==Nn||Gn!==Ci||Zn!==ei)&&(e.stencilOp(Nn,Ci,ei),On=Nn,Gn=Ci,Zn=ei)},setLocked:function(Nn){qe=Nn},setClear:function(Nn){Wi!==Nn&&(e.clearStencil(Nn),Wi=Nn)},reset:function(){qe=!1,Nt=null,Qt=null,Pn=null,pn=null,On=null,Gn=null,Zn=null,Wi=null}}}var s=new h,M=new p,T=new _,C=e.getParameter(34921),E=new Uint8Array(C),L=new Uint8Array(C),I=new Uint8Array(C),B={},O=null,U=null,q=null,ee=null,he=null,Ce=null,K=null,ie=null,ue=null,ae=!1,le=null,De=null,ye=null,se=null,Ue=null,Oe=e.getParameter(35661),We=!1,st=0,St=e.getParameter(7938);St.indexOf("WebGL")!==-1?(st=parseFloat(/^WebGL\ ([0-9])/.exec(St)[1]),We=st>=1):St.indexOf("OpenGL ES")!==-1&&(st=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(St)[1]),We=st>=2);var gt=null,At={},Dt=new gi,Ot=new gi;function Pe(qe,Nt,Qt){var Pn=new Uint8Array(4),pn=e.createTexture();e.bindTexture(qe,pn),e.texParameteri(qe,10241,9728),e.texParameteri(qe,10240,9728);for(var On=0;On<Qt;On++)e.texImage2D(Nt+On,0,6408,1,1,0,6408,5121,Pn);return pn}var ge={};ge[3553]=Pe(3553,3553,1),ge[34067]=Pe(34067,34069,6),s.setClear(0,0,0,1),M.setClear(1),T.setClear(0),ce(2929),M.setFunc(Gg),Vt(!1),oe(n0),ce(2884),ot(Qo);function Ve(){for(var qe=0,Nt=E.length;qe<Nt;qe++)E[qe]=0}function Ne(qe){Ie(qe,0)}function Ie(qe,Nt){if(E[qe]=1,L[qe]===0&&(e.enableVertexAttribArray(qe),L[qe]=1),I[qe]!==Nt){var Qt=l?e:n.get("ANGLE_instanced_arrays");Qt[l?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](qe,Nt),I[qe]=Nt}}function it(){for(var qe=0,Nt=L.length;qe!==Nt;++qe)L[qe]!==E[qe]&&(e.disableVertexAttribArray(qe),L[qe]=0)}function ce(qe){B[qe]!==!0&&(e.enable(qe),B[qe]=!0)}function we(qe){B[qe]!==!1&&(e.disable(qe),B[qe]=!1)}function Me(qe){return O!==qe?(e.useProgram(qe),O=qe,!0):!1}var pe={[Ql]:32774,[iT]:32778,[rT]:32779};if(l)pe[c0]=32775,pe[u0]=32776;else{var Be=n.get("EXT_blend_minmax");Be!==null&&(pe[c0]=Be.MIN_EXT,pe[u0]=Be.MAX_EXT)}var $e={[aT]:0,[oT]:1,[sT]:768,[h0]:770,[pT]:776,[hT]:774,[cT]:772,[lT]:769,[d0]:771,[dT]:775,[uT]:773};function ot(qe,Nt,Qt,Pn,pn,On,Gn,Zn){if(qe===Qo){U&&(we(3042),U=!1);return}if(U||(ce(3042),U=!0),qe!==nT){if(qe!==q||Zn!==ae){if((ee!==Ql||K!==Ql)&&(e.blendEquation(32774),ee=Ql,K=Ql),Zn)switch(qe){case ah:e.blendFuncSeparate(1,771,1,771);break;case o0:e.blendFunc(1,1);break;case s0:e.blendFuncSeparate(0,0,769,771);break;case l0:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",qe);break}else switch(qe){case ah:e.blendFuncSeparate(770,771,1,771);break;case o0:e.blendFunc(770,1);break;case s0:e.blendFunc(0,769);break;case l0:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",qe);break}he=null,Ce=null,ie=null,ue=null,q=qe,ae=Zn}return}pn=pn||Nt,On=On||Qt,Gn=Gn||Pn,(Nt!==ee||pn!==K)&&(e.blendEquationSeparate(pe[Nt],pe[pn]),ee=Nt,K=pn),(Qt!==he||Pn!==Ce||On!==ie||Gn!==ue)&&(e.blendFuncSeparate($e[Qt],$e[Pn],$e[On],$e[Gn]),he=Qt,Ce=Pn,ie=On,ue=Gn),q=qe,ae=null}function bt(qe,Nt){qe.side===rh?we(2884):ce(2884);var Qt=qe.side===tr;Nt&&(Qt=!Qt),Vt(Qt),qe.blending===ah&&qe.transparent===!1?ot(Qo):ot(qe.blending,qe.blendEquation,qe.blendSrc,qe.blendDst,qe.blendEquationAlpha,qe.blendSrcAlpha,qe.blendDstAlpha,qe.premultipliedAlpha),M.setFunc(qe.depthFunc),M.setTest(qe.depthTest),M.setMask(qe.depthWrite),s.setMask(qe.colorWrite);var Pn=qe.stencilWrite;T.setTest(Pn),Pn&&(T.setMask(qe.stencilWriteMask),T.setFunc(qe.stencilFunc,qe.stencilRef,qe.stencilFuncMask),T.setOp(qe.stencilFail,qe.stencilZFail,qe.stencilZPass)),xt(qe.polygonOffset,qe.polygonOffsetFactor,qe.polygonOffsetUnits)}function Vt(qe){le!==qe&&(qe?e.frontFace(2304):e.frontFace(2305),le=qe)}function oe(qe){qe!==KM?(ce(2884),qe!==De&&(qe===n0?e.cullFace(1029):qe===QM?e.cullFace(1028):e.cullFace(1032))):we(2884),De=qe}function ve(qe){qe!==ye&&(We&&e.lineWidth(qe),ye=qe)}function xt(qe,Nt,Qt){qe?(ce(32823),(se!==Nt||Ue!==Qt)&&(e.polygonOffset(Nt,Qt),se=Nt,Ue=Qt)):we(32823)}function mt(qe){qe?ce(3089):we(3089)}function xn(qe){qe===void 0&&(qe=33984+Oe-1),gt!==qe&&(e.activeTexture(qe),gt=qe)}function un(qe,Nt){gt===null&&xn();var Qt=At[gt];Qt===void 0&&(Qt={type:void 0,texture:void 0},At[gt]=Qt),(Qt.type!==qe||Qt.texture!==Nt)&&(e.bindTexture(qe,Nt||ge[qe]),Qt.type=qe,Qt.texture=Nt)}function tn(){var qe=At[gt];qe!==void 0&&qe.type!==void 0&&(e.bindTexture(qe.type,null),qe.type=void 0,qe.texture=void 0)}function dn(){try{e.compressedTexImage2D.apply(e,arguments)}catch(qe){console.error("THREE.WebGLState:",qe)}}function bn(){try{e.texImage2D.apply(e,arguments)}catch(qe){console.error("THREE.WebGLState:",qe)}}function ln(){try{e.texImage3D.apply(e,arguments)}catch(qe){console.error("THREE.WebGLState:",qe)}}function Gt(qe){Dt.equals(qe)===!1&&(e.scissor(qe.x,qe.y,qe.z,qe.w),Dt.copy(qe))}function on(qe){Ot.equals(qe)===!1&&(e.viewport(qe.x,qe.y,qe.z,qe.w),Ot.copy(qe))}function Zt(){for(var qe=0;qe<L.length;qe++)L[qe]===1&&(e.disableVertexAttribArray(qe),L[qe]=0);B={},gt=null,At={},O=null,q=null,le=null,De=null,s.reset(),M.reset(),T.reset()}return{buffers:{color:s,depth:M,stencil:T},initAttributes:Ve,enableAttribute:Ne,enableAttributeAndDivisor:Ie,disableUnusedAttributes:it,enable:ce,disable:we,useProgram:Me,setBlending:ot,setMaterial:bt,setFlipSided:Vt,setCullFace:oe,setLineWidth:ve,setPolygonOffset:xt,setScissorTest:mt,activeTexture:xn,bindTexture:un,unbindTexture:tn,compressedTexImage2D:dn,texImage2D:bn,texImage3D:ln,scissor:Gt,viewport:on,reset:Zt}}function vC(e,n,i,l,h,p,_){var s=h.isWebGL2,M=h.maxTextures,T=h.maxCubemapSize,C=h.maxTextureSize,E=h.maxSamples,L=new WeakMap,I,B=!1;try{B=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(oe){}function O(oe,ve){return B?new OffscreenCanvas(oe,ve):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function U(oe,ve,xt,mt){var xn=1;if((oe.width>mt||oe.height>mt)&&(xn=mt/Math.max(oe.width,oe.height)),xn<1||ve===!0)if(typeof HTMLImageElement!="undefined"&&oe instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&oe instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&oe instanceof ImageBitmap){var un=ve?Wn.floorPowerOfTwo:Math.floor,tn=un(xn*oe.width),dn=un(xn*oe.height);I===void 0&&(I=O(tn,dn));var bn=xt?O(tn,dn):I;bn.width=tn,bn.height=dn;var ln=bn.getContext("2d");return ln.drawImage(oe,0,0,tn,dn),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+tn+"x"+dn+")."),bn}else return"data"in oe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),oe;return oe}function q(oe){return Wn.isPowerOfTwo(oe.width)&&Wn.isPowerOfTwo(oe.height)}function ee(oe){return s?!1:oe.wrapS!==wr||oe.wrapT!==wr||oe.minFilter!==Ui&&oe.minFilter!==qi}function he(oe,ve){return oe.generateMipmaps&&ve&&oe.minFilter!==Ui&&oe.minFilter!==qi}function Ce(oe,ve,xt,mt){e.generateMipmap(oe);var xn=l.get(ve);xn.__maxMipLevel=Math.log(Math.max(xt,mt))*Math.LOG2E}function K(oe,ve,xt){if(s===!1)return ve;if(oe!==null){if(e[oe]!==void 0)return e[oe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+oe+"'")}var mt=ve;return ve===6403&&(xt===5126&&(mt=33326),xt===5131&&(mt=33325),xt===5121&&(mt=33321)),ve===6407&&(xt===5126&&(mt=34837),xt===5131&&(mt=34843),xt===5121&&(mt=32849)),ve===6408&&(xt===5126&&(mt=34836),xt===5131&&(mt=34842),xt===5121&&(mt=32856)),mt===33325||mt===33326||mt===34842||mt===34836?n.get("EXT_color_buffer_float"):(mt===34843||mt===34837)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),mt}function ie(oe){return oe===Ui||oe===Gp||oe===Hp?9728:9729}function ue(oe){var ve=oe.target;ve.removeEventListener("dispose",ue),le(ve),ve.isVideoTexture&&L.delete(ve),_.memory.textures--}function ae(oe){var ve=oe.target;ve.removeEventListener("dispose",ae),De(ve),_.memory.textures--}function le(oe){var ve=l.get(oe);ve.__webglInit!==void 0&&(e.deleteTexture(ve.__webglTexture),l.remove(oe))}function De(oe){var ve=l.get(oe),xt=l.get(oe.texture);if(oe){if(xt.__webglTexture!==void 0&&e.deleteTexture(xt.__webglTexture),oe.depthTexture&&oe.depthTexture.dispose(),oe.isWebGLCubeRenderTarget)for(var mt=0;mt<6;mt++)e.deleteFramebuffer(ve.__webglFramebuffer[mt]),ve.__webglDepthbuffer&&e.deleteRenderbuffer(ve.__webglDepthbuffer[mt]);else e.deleteFramebuffer(ve.__webglFramebuffer),ve.__webglDepthbuffer&&e.deleteRenderbuffer(ve.__webglDepthbuffer);if(oe.isWebGLMultiviewRenderTarget){e.deleteTexture(ve.__webglColorTexture),e.deleteTexture(ve.__webglDepthStencilTexture),_.memory.textures-=2;for(var mt=0,xn=ve.__webglViewFramebuffers.length;mt<xn;mt++)e.deleteFramebuffer(ve.__webglViewFramebuffers[mt])}l.remove(oe.texture),l.remove(oe)}}var ye=0;function se(){ye=0}function Ue(){var oe=ye;return oe>=M&&console.warn("THREE.WebGLTextures: Trying to use "+oe+" texture units while this GPU supports only "+M),ye+=1,oe}function Oe(oe,ve){var xt=l.get(oe);if(oe.isVideoTexture&&Be(oe),oe.version>0&&xt.__version!==oe.version){var mt=oe.image;if(mt===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(mt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge(xt,oe,ve);return}}i.activeTexture(33984+ve),i.bindTexture(3553,xt.__webglTexture)}function We(oe,ve){var xt=l.get(oe);if(oe.version>0&&xt.__version!==oe.version){ge(xt,oe,ve);return}i.activeTexture(33984+ve),i.bindTexture(35866,xt.__webglTexture)}function st(oe,ve){var xt=l.get(oe);if(oe.version>0&&xt.__version!==oe.version){ge(xt,oe,ve);return}i.activeTexture(33984+ve),i.bindTexture(32879,xt.__webglTexture)}function St(oe,ve){if(oe.image.length===6){var xt=l.get(oe);if(oe.version>0&&xt.__version!==oe.version){Pe(xt,oe),i.activeTexture(33984+ve),i.bindTexture(34067,xt.__webglTexture),e.pixelStorei(37440,oe.flipY);for(var mt=oe&&(oe.isCompressedTexture||oe.image[0].isCompressedTexture),xn=oe.image[0]&&oe.image[0].isDataTexture,un=[],tn=0;tn<6;tn++)!mt&&!xn?un[tn]=U(oe.image[tn],!1,!0,T):un[tn]=xn?oe.image[tn].image:oe.image[tn];var dn=un[0],bn=q(dn)||s,ln=p.convert(oe.format),Gt=p.convert(oe.type),on=K(oe.internalFormat,ln,Gt);Ot(34067,oe,bn);var Zt;if(mt){for(var tn=0;tn<6;tn++){Zt=un[tn].mipmaps;for(var qe=0;qe<Zt.length;qe++){var Nt=Zt[qe];oe.format!==Aa&&oe.format!==Mo?ln!==null?i.compressedTexImage2D(34069+tn,qe,on,Nt.width,Nt.height,0,Nt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+tn,qe,on,Nt.width,Nt.height,0,ln,Gt,Nt.data)}}xt.__maxMipLevel=Zt.length-1}else{Zt=oe.mipmaps;for(var tn=0;tn<6;tn++)if(xn){i.texImage2D(34069+tn,0,on,un[tn].width,un[tn].height,0,ln,Gt,un[tn].data);for(var qe=0;qe<Zt.length;qe++){var Nt=Zt[qe],Qt=Nt.image[tn].image;i.texImage2D(34069+tn,qe+1,on,Qt.width,Qt.height,0,ln,Gt,Qt.data)}}else{i.texImage2D(34069+tn,0,on,ln,Gt,un[tn]);for(var qe=0;qe<Zt.length;qe++){var Nt=Zt[qe];i.texImage2D(34069+tn,qe+1,on,ln,Gt,Nt.image[tn])}}xt.__maxMipLevel=Zt.length}he(oe,bn)&&Ce(34067,oe,dn.width,dn.height),xt.__version=oe.version,oe.onUpdate&&oe.onUpdate(oe)}else i.activeTexture(33984+ve),i.bindTexture(34067,xt.__webglTexture)}}function gt(oe,ve){i.activeTexture(33984+ve),i.bindTexture(34067,l.get(oe).__webglTexture)}var At={[Zs]:10497,[wr]:33071,[sh]:33648},Dt={[Ui]:9728,[Gp]:9984,[Hp]:9986,[qi]:9729,[Yg]:9985,[ec]:9987};function Ot(oe,ve,xt){xt?(e.texParameteri(oe,10242,At[ve.wrapS]),e.texParameteri(oe,10243,At[ve.wrapT]),(oe===32879||oe===35866)&&e.texParameteri(oe,32882,At[ve.wrapR]),e.texParameteri(oe,10240,Dt[ve.magFilter]),e.texParameteri(oe,10241,Dt[ve.minFilter])):(e.texParameteri(oe,10242,33071),e.texParameteri(oe,10243,33071),(oe===32879||oe===35866)&&e.texParameteri(oe,32882,33071),(ve.wrapS!==wr||ve.wrapT!==wr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(oe,10240,ie(ve.magFilter)),e.texParameteri(oe,10241,ie(ve.minFilter)),ve.minFilter!==Ui&&ve.minFilter!==qi&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));var mt=n.get("EXT_texture_filter_anisotropic");if(mt){if(ve.type===lh&&n.get("OES_texture_float_linear")===null||ve.type===$g&&(s||n.get("OES_texture_half_float_linear"))===null)return;(ve.anisotropy>1||l.get(ve).__currentAnisotropy)&&(e.texParameterf(oe,mt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ve.anisotropy,h.getMaxAnisotropy())),l.get(ve).__currentAnisotropy=ve.anisotropy)}}function Pe(oe,ve){oe.__webglInit===void 0&&(oe.__webglInit=!0,ve.addEventListener("dispose",ue),oe.__webglTexture=e.createTexture(),_.memory.textures++)}function ge(oe,ve,xt){var mt=3553;ve.isDataTexture2DArray&&(mt=35866),ve.isDataTexture3D&&(mt=32879),Pe(oe,ve),i.activeTexture(33984+xt),i.bindTexture(mt,oe.__webglTexture),e.pixelStorei(37440,ve.flipY),e.pixelStorei(37441,ve.premultiplyAlpha),e.pixelStorei(3317,ve.unpackAlignment);var xn=ee(ve)&&q(ve.image)===!1,un=U(ve.image,xn,!1,C),tn=q(un)||s,dn=p.convert(ve.format),bn=p.convert(ve.type),ln=K(ve.internalFormat,dn,bn);Ot(mt,ve,tn);var Gt,on=ve.mipmaps;if(ve.isDepthTexture){if(ln=6402,ve.type===lh){if(s===!1)throw new Error("Float Depth Texture only supported in WebGL2.0");ln=36012}else s&&(ln=33189);ve.format===tc&&ln===6402&&ve.type!==jp&&ve.type!==m0&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ve.type=jp,bn=p.convert(ve.type)),ve.format===ch&&(ln=34041,ve.type!==qp&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ve.type=qp,bn=p.convert(ve.type))),i.texImage2D(3553,0,ln,un.width,un.height,0,dn,bn,null)}else if(ve.isDataTexture)if(on.length>0&&tn){for(var Zt=0,qe=on.length;Zt<qe;Zt++)Gt=on[Zt],i.texImage2D(3553,Zt,ln,Gt.width,Gt.height,0,dn,bn,Gt.data);ve.generateMipmaps=!1,oe.__maxMipLevel=on.length-1}else i.texImage2D(3553,0,ln,un.width,un.height,0,dn,bn,un.data),oe.__maxMipLevel=0;else if(ve.isCompressedTexture){for(var Zt=0,qe=on.length;Zt<qe;Zt++)Gt=on[Zt],ve.format!==Aa&&ve.format!==Mo?dn!==null?i.compressedTexImage2D(3553,Zt,ln,Gt.width,Gt.height,0,Gt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,Zt,ln,Gt.width,Gt.height,0,dn,bn,Gt.data);oe.__maxMipLevel=on.length-1}else if(ve.isDataTexture2DArray)i.texImage3D(35866,0,ln,un.width,un.height,un.depth,0,dn,bn,un.data),oe.__maxMipLevel=0;else if(ve.isDataTexture3D)i.texImage3D(32879,0,ln,un.width,un.height,un.depth,0,dn,bn,un.data),oe.__maxMipLevel=0;else if(on.length>0&&tn){for(var Zt=0,qe=on.length;Zt<qe;Zt++)Gt=on[Zt],i.texImage2D(3553,Zt,ln,dn,bn,Gt);ve.generateMipmaps=!1,oe.__maxMipLevel=on.length-1}else i.texImage2D(3553,0,ln,dn,bn,un),oe.__maxMipLevel=0;he(ve,tn)&&Ce(mt,ve,un.width,un.height),oe.__version=ve.version,ve.onUpdate&&ve.onUpdate(ve)}function Ve(oe,ve,xt,mt){var xn=p.convert(ve.texture.format),un=p.convert(ve.texture.type),tn=K(ve.texture.internalFormat,xn,un);i.texImage2D(mt,0,tn,ve.width,ve.height,0,xn,un,null),e.bindFramebuffer(36160,oe),e.framebufferTexture2D(36160,xt,mt,l.get(ve.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ne(oe,ve,xt){if(e.bindRenderbuffer(36161,oe),ve.depthBuffer&&!ve.stencilBuffer){if(xt){var mt=pe(ve);e.renderbufferStorageMultisample(36161,mt,33189,ve.width,ve.height)}else e.renderbufferStorage(36161,33189,ve.width,ve.height);e.framebufferRenderbuffer(36160,36096,36161,oe)}else if(ve.depthBuffer&&ve.stencilBuffer){if(xt){var mt=pe(ve);e.renderbufferStorageMultisample(36161,mt,35056,ve.width,ve.height)}else e.renderbufferStorage(36161,34041,ve.width,ve.height);e.framebufferRenderbuffer(36160,33306,36161,oe)}else{var xn=p.convert(ve.texture.format),un=p.convert(ve.texture.type),tn=K(ve.texture.internalFormat,xn,un);if(xt){var mt=pe(ve);e.renderbufferStorageMultisample(36161,mt,tn,ve.width,ve.height)}else e.renderbufferStorage(36161,tn,ve.width,ve.height)}e.bindRenderbuffer(36161,null)}function Ie(oe,ve){var xt=ve&&ve.isWebGLCubeRenderTarget;if(xt)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,oe),!(ve.depthTexture&&ve.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!l.get(ve.depthTexture).__webglTexture||ve.depthTexture.image.width!==ve.width||ve.depthTexture.image.height!==ve.height)&&(ve.depthTexture.image.width=ve.width,ve.depthTexture.image.height=ve.height,ve.depthTexture.needsUpdate=!0),Oe(ve.depthTexture,0);var mt=l.get(ve.depthTexture).__webglTexture;if(ve.depthTexture.format===tc)e.framebufferTexture2D(36160,36096,3553,mt,0);else if(ve.depthTexture.format===ch)e.framebufferTexture2D(36160,33306,3553,mt,0);else throw new Error("Unknown depthTexture format")}function it(oe){var ve=l.get(oe),xt=oe.isWebGLCubeRenderTarget===!0;if(oe.depthTexture){if(xt)throw new Error("target.depthTexture not supported in Cube render targets");Ie(ve.__webglFramebuffer,oe)}else if(xt){ve.__webglDepthbuffer=[];for(var mt=0;mt<6;mt++)e.bindFramebuffer(36160,ve.__webglFramebuffer[mt]),ve.__webglDepthbuffer[mt]=e.createRenderbuffer(),Ne(ve.__webglDepthbuffer[mt],oe)}else e.bindFramebuffer(36160,ve.__webglFramebuffer),ve.__webglDepthbuffer=e.createRenderbuffer(),Ne(ve.__webglDepthbuffer,oe);e.bindFramebuffer(36160,null)}function ce(oe){var ve=l.get(oe),xt=l.get(oe.texture);oe.addEventListener("dispose",ae),xt.__webglTexture=e.createTexture(),_.memory.textures++;var mt=oe.isWebGLCubeRenderTarget===!0,xn=oe.isWebGLMultisampleRenderTarget===!0,un=oe.isWebGLMultiviewRenderTarget===!0,tn=q(oe)||s;if(mt){ve.__webglFramebuffer=[];for(var dn=0;dn<6;dn++)ve.__webglFramebuffer[dn]=e.createFramebuffer()}else if(ve.__webglFramebuffer=e.createFramebuffer(),xn)if(s){ve.__webglMultisampledFramebuffer=e.createFramebuffer(),ve.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,ve.__webglColorRenderbuffer);var bn=p.convert(oe.texture.format),ln=p.convert(oe.texture.type),Gt=K(oe.texture.internalFormat,bn,ln),on=pe(oe);e.renderbufferStorageMultisample(36161,on,Gt,oe.width,oe.height),e.bindFramebuffer(36160,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,ve.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),oe.depthBuffer&&(ve.__webglDepthRenderbuffer=e.createRenderbuffer(),Ne(ve.__webglDepthRenderbuffer,oe,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(un){var Zt=oe.width,qe=oe.height,Nt=oe.numViews;e.bindFramebuffer(36160,ve.__webglFramebuffer);var Qt=n.get("OVR_multiview2");_.memory.textures+=2;var Pn=e.createTexture();e.bindTexture(35866,Pn),e.texParameteri(35866,10240,9728),e.texParameteri(35866,10241,9728),e.texImage3D(35866,0,32856,Zt,qe,Nt,0,6408,5121,null),Qt.framebufferTextureMultiviewOVR(36160,36064,Pn,0,0,Nt);var pn=e.createTexture();e.bindTexture(35866,pn),e.texParameteri(35866,10240,9728),e.texParameteri(35866,10241,9728),e.texImage3D(35866,0,35056,Zt,qe,Nt,0,34041,34042,null),Qt.framebufferTextureMultiviewOVR(36160,33306,pn,0,0,Nt);for(var On=new Array(Nt),dn=0;dn<Nt;++dn)On[dn]=e.createFramebuffer(),e.bindFramebuffer(36160,On[dn]),e.framebufferTextureLayer(36160,36064,Pn,0,dn);ve.__webglColorTexture=Pn,ve.__webglDepthStencilTexture=pn,ve.__webglViewFramebuffers=On,e.bindFramebuffer(36160,null),e.bindTexture(35866,null)}if(mt){i.bindTexture(34067,xt.__webglTexture),Ot(34067,oe.texture,tn);for(var dn=0;dn<6;dn++)Ve(ve.__webglFramebuffer[dn],oe,36064,34069+dn);he(oe.texture,tn)&&Ce(34067,oe.texture,oe.width,oe.height),i.bindTexture(34067,null)}else un||(i.bindTexture(3553,xt.__webglTexture),Ot(3553,oe.texture,tn),Ve(ve.__webglFramebuffer,oe,36064,3553),he(oe.texture,tn)&&Ce(3553,oe.texture,oe.width,oe.height),i.bindTexture(3553,null));oe.depthBuffer&&it(oe)}function we(oe){var ve=oe.texture,xt=q(oe)||s;if(he(ve,xt)){var mt=oe.isWebGLCubeRenderTarget?34067:3553,xn=l.get(ve).__webglTexture;i.bindTexture(mt,xn),Ce(mt,ve,oe.width,oe.height),i.bindTexture(mt,null)}}function Me(oe){if(oe.isWebGLMultisampleRenderTarget)if(s){var ve=l.get(oe);e.bindFramebuffer(36008,ve.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,ve.__webglFramebuffer);var xt=oe.width,mt=oe.height,xn=16384;oe.depthBuffer&&(xn|=256),oe.stencilBuffer&&(xn|=1024),e.blitFramebuffer(0,0,xt,mt,0,0,xt,mt,xn,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function pe(oe){return s&&oe.isWebGLMultisampleRenderTarget?Math.min(E,oe.samples):0}function Be(oe){var ve=_.render.frame;L.get(oe)!==ve&&(L.set(oe,ve),oe.update())}var $e=!1,ot=!1;function bt(oe,ve){oe&&oe.isWebGLRenderTarget&&($e===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),$e=!0),oe=oe.texture),Oe(oe,ve)}function Vt(oe,ve){oe&&oe.isWebGLCubeRenderTarget&&(ot===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ot=!0),oe=oe.texture),oe&&oe.isCubeTexture||Array.isArray(oe.image)&&oe.image.length===6?St(oe,ve):gt(oe,ve)}this.allocateTextureUnit=Ue,this.resetTextureUnits=se,this.setTexture2D=Oe,this.setTexture2DArray=We,this.setTexture3D=st,this.setTextureCube=St,this.setTextureCubeDynamic=gt,this.setupRenderTarget=ce,this.updateRenderTargetMipmap=we,this.updateMultisampleRenderTarget=Me,this.safeSetTexture2D=bt,this.safeSetTextureCube=Vt}function xC(e,n,i){var l=i.isWebGL2;function h(p){var _;if(p===Wp)return 5121;if(p===LT)return 32819;if(p===DT)return 32820;if(p===IT)return 33635;if(p===AT)return 5120;if(p===CT)return 5122;if(p===jp)return 5123;if(p===PT)return 5124;if(p===m0)return 5125;if(p===lh)return 5126;if(p===$g)return l?5131:(_=n.get("OES_texture_half_float"),_!==null?_.HALF_FLOAT_OES:null);if(p===RT)return 6406;if(p===Mo)return 6407;if(p===Aa)return 6408;if(p===zT)return 6409;if(p===kT)return 6410;if(p===tc)return 6402;if(p===ch)return 34041;if(p===FT)return 6403;if(p===OT)return 36244;if(p===NT)return 33319;if(p===UT)return 33320;if(p===VT)return 36248;if(p===GT)return 36249;if(p===g0||p===_0||p===y0||p===v0)if(_=n.get("WEBGL_compressed_texture_s3tc"),_!==null){if(p===g0)return _.COMPRESSED_RGB_S3TC_DXT1_EXT;if(p===_0)return _.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(p===y0)return _.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(p===v0)return _.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(p===x0||p===b0||p===w0||p===M0)if(_=n.get("WEBGL_compressed_texture_pvrtc"),_!==null){if(p===x0)return _.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(p===b0)return _.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(p===w0)return _.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(p===M0)return _.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(p===HT)return _=n.get("WEBGL_compressed_texture_etc1"),_!==null?_.COMPRESSED_RGB_ETC1_WEBGL:null;if(p===WT||p===jT||p===qT||p===ZT||p===XT||p===YT||p===$T||p===JT||p===KT||p===QT||p===e2||p===t2||p===n2||p===i2)return _=n.get("WEBGL_compressed_texture_astc"),_!==null?p:null;if(p===qp)return l?34042:(_=n.get("WEBGL_depth_texture"),_!==null?_.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:h}}function A_(e,n,i,l){Mr.call(this,e,n,l),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=i}A_.prototype=Object.assign(Object.create(Mr.prototype),{constructor:A_,isWebGLMultiviewRenderTarget:!0,copy:function(e){return Mr.prototype.copy.call(this,e),this.numViews=e.numViews,this},setNumViews:function(e){return this.numViews!==e&&(this.numViews=e,this.dispose()),this}});function bC(e,n){var i=2,l=e.extensions,h=e.properties,p,_,s,M,T,C,E,L=0;function I(){if(E===void 0){var ue=l.get("OVR_multiview2");if(E=ue!==null&&n.getContextAttributes().antialias===!1,E){L=n.getParameter(ue.MAX_VIEWS_OVR),p=new A_(0,0,i),C=new Lt,M=[],s=[],T=[];for(var ae=0;ae<L;ae++)M[ae]=new jn,s[ae]=new dr}}return E}function B(ue){return ue.isArrayCamera?ue.cameras:(T[0]=ue,T)}function O(ue,ae){for(var le=B(ue),De=0;De<le.length;De++)M[De].copy(le[De].projectionMatrix);ae.setValue(n,"projectionMatrices",M)}function U(ue,ae){for(var le=B(ue),De=0;De<le.length;De++)M[De].copy(le[De].matrixWorldInverse);ae.setValue(n,"viewMatrices",M)}function q(ue,ae,le){for(var De=B(ae),ye=0;ye<De.length;ye++)M[ye].multiplyMatrices(De[ye].matrixWorldInverse,ue.matrixWorld),s[ye].getNormalMatrix(M[ye]);le.setValue(n,"modelViewMatrices",M),le.setValue(n,"normalMatrices",s)}function ee(ue){if(ue.isArrayCamera===void 0)return!0;var ae=ue.cameras;if(ae.length>L)return!1;for(var le=1,De=ae.length;le<De;le++)if(ae[0].viewport.z!==ae[le].viewport.z||ae[0].viewport.w!==ae[le].viewport.w)return!1;return!0}function he(ue){if(_?C.set(_.width,_.height):e.getDrawingBufferSize(C),ue.isArrayCamera){var ae=ue.cameras[0].viewport;p.setSize(ae.z,ae.w),p.setNumViews(ue.cameras.length)}else p.setSize(C.x,C.y),p.setNumViews(i)}function Ce(ue){ee(ue)!==!1&&(_=e.getRenderTarget(),he(ue),e.setRenderTarget(p))}function K(ue){p===e.getRenderTarget()&&(e.setRenderTarget(_),ie(ue))}function ie(ue){var ae=p,le=ae.numViews,De=h.get(ae).__webglViewFramebuffers,ye=ae.width,se=ae.height;if(ue.isArrayCamera)for(var Ue=0;Ue<le;Ue++){var Oe=ue.cameras[Ue].viewport,We=Oe.x,st=Oe.y,St=We+Oe.z,gt=st+Oe.w;n.bindFramebuffer(36008,De[Ue]),n.blitFramebuffer(0,0,ye,se,We,st,St,gt,16384,9728)}else n.bindFramebuffer(36008,De[0]),n.blitFramebuffer(0,0,ye,se,0,0,C.x,C.y,16384,9728)}this.isAvailable=I,this.attachCamera=Ce,this.detachCamera=K,this.updateCameraProjectionMatricesUniform=O,this.updateCameraViewMatricesUniform=U,this.updateObjectMatricesUniforms=q}function C_(e){Xi.call(this),this.cameras=e||[]}C_.prototype=Object.assign(Object.create(Xi.prototype),{constructor:C_,isArrayCamera:!0});function rl(){rn.call(this),this.type="Group"}rl.prototype=Object.assign(Object.create(rn.prototype),{constructor:rl,isGroup:!0});function dx(e,n){var i=this,l=null,h=null,p="local-floor",_=null,s=[],M=new Map,T=new Xi;T.layers.enable(1),T.viewport=new gi;var C=new Xi;C.layers.enable(2),C.viewport=new gi;var E=new C_([T,C]);E.layers.enable(1),E.layers.enable(2);var L=null,I=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(le){var De=s[le];return De===void 0&&(De={},s[le]=De),De.targetRay===void 0&&(De.targetRay=new rl,De.targetRay.matrixAutoUpdate=!1,De.targetRay.visible=!1),De.targetRay},this.getControllerGrip=function(le){var De=s[le];return De===void 0&&(De={},s[le]=De),De.grip===void 0&&(De.grip=new rl,De.grip.matrixAutoUpdate=!1,De.grip.visible=!1),De.grip};function B(le){var De=M.get(le.inputSource);De&&(De.targetRay&&De.targetRay.dispatchEvent({type:le.type}),De.grip&&De.grip.dispatchEvent({type:le.type}))}function O(){M.forEach(function(le,De){le.targetRay&&(le.targetRay.dispatchEvent({type:"disconnected",data:De}),le.targetRay.visible=!1),le.grip&&(le.grip.dispatchEvent({type:"disconnected",data:De}),le.grip.visible=!1)}),M.clear(),e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),ae.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function U(le){h=le,ae.setContext(l),ae.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}this.setFramebufferScaleFactor=function(){},this.setReferenceSpaceType=function(le){p=le},this.getReferenceSpace=function(){return h},this.getSession=function(){return l},this.setSession=function(le){if(l=le,l!==null){l.addEventListener("select",B),l.addEventListener("selectstart",B),l.addEventListener("selectend",B),l.addEventListener("squeeze",B),l.addEventListener("squeezestart",B),l.addEventListener("squeezeend",B),l.addEventListener("end",O);var De=n.getContextAttributes(),ye={antialias:De.antialias,alpha:De.alpha,depth:De.depth,stencil:De.stencil},se=new XRWebGLLayer(l,n,ye);l.updateRenderState({baseLayer:se}),l.requestReferenceSpace(p).then(U),l.addEventListener("inputsourceschange",q)}};function q(le){for(var De=l.inputSources,ye=0;ye<s.length;ye++)M.set(De[ye],s[ye]);for(var ye=0;ye<le.removed.length;ye++){var se=le.removed[ye],Ue=M.get(se);Ue&&(Ue.targetRay&&Ue.targetRay.dispatchEvent({type:"disconnected",data:se}),Ue.grip&&Ue.grip.dispatchEvent({type:"disconnected",data:se}),M.delete(se))}for(var ye=0;ye<le.added.length;ye++){var se=le.added[ye],Ue=M.get(se);Ue&&(Ue.targetRay&&Ue.targetRay.dispatchEvent({type:"connected",data:se}),Ue.grip&&Ue.grip.dispatchEvent({type:"connected",data:se}))}}var ee=new Ee,he=new Ee;function Ce(le,De,ye){ee.setFromMatrixPosition(De.matrixWorld),he.setFromMatrixPosition(ye.matrixWorld);var se=ee.distanceTo(he),Ue=De.projectionMatrix.elements,Oe=ye.projectionMatrix.elements,We=Ue[14]/(Ue[10]-1),st=Ue[14]/(Ue[10]+1),St=(Ue[9]+1)/Ue[5],gt=(Ue[9]-1)/Ue[5],At=(Ue[8]-1)/Ue[0],Dt=(Oe[8]+1)/Oe[0],Ot=We*At,Pe=We*Dt,ge=se/(-At+Dt),Ve=ge*-At;De.matrixWorld.decompose(le.position,le.quaternion,le.scale),le.translateX(Ve),le.translateZ(ge),le.matrixWorld.compose(le.position,le.quaternion,le.scale),le.matrixWorldInverse.getInverse(le.matrixWorld);var Ne=We+ge,Ie=st+ge,it=Ot-Ve,ce=Pe+(se-Ve),we=St*st/Ie*Ne,Me=gt*st/Ie*Ne;le.projectionMatrix.makePerspective(it,ce,we,Me,Ne,Ie)}function K(le,De){De===null?le.matrixWorld.copy(le.matrix):le.matrixWorld.multiplyMatrices(De.matrixWorld,le.matrix),le.matrixWorldInverse.getInverse(le.matrixWorld)}this.getCamera=function(le){E.near=C.near=T.near=le.near,E.far=C.far=T.far=le.far,(L!==E.near||I!==E.far)&&(l.updateRenderState({depthNear:E.near,depthFar:E.far}),L=E.near,I=E.far);var De=le.parent,ye=E.cameras;K(E,De);for(var se=0;se<ye.length;se++)K(ye[se],De);le.matrixWorld.copy(E.matrixWorld);for(var Ue=le.children,se=0,Oe=Ue.length;se<Oe;se++)Ue[se].updateMatrixWorld(!0);return Ce(E,T,C),E};var ie=null;function ue(le,De){if(_=De.getViewerPose(h),_!==null){var ye=_.views,se=l.renderState.baseLayer;e.setFramebuffer(se.framebuffer);for(var Ue=0;Ue<ye.length;Ue++){var Oe=ye[Ue],We=se.getViewport(Oe),st=E.cameras[Ue];st.matrix.fromArray(Oe.transform.matrix),st.projectionMatrix.fromArray(Oe.projectionMatrix),st.viewport.set(We.x,We.y,We.width,We.height),Ue===0&&E.matrix.copy(st.matrix)}}for(var St=l.inputSources,Ue=0;Ue<s.length;Ue++){var gt=s[Ue],At=St[Ue],Dt=null,Ot=null;At&&(gt.targetRay&&(Dt=De.getPose(At.targetRaySpace,h),Dt!==null&&(gt.targetRay.matrix.fromArray(Dt.transform.matrix),gt.targetRay.matrix.decompose(gt.targetRay.position,gt.targetRay.rotation,gt.targetRay.scale))),gt.grip&&At.gripSpace&&(Ot=De.getPose(At.gripSpace,h),Ot!==null&&(gt.grip.matrix.fromArray(Ot.transform.matrix),gt.grip.matrix.decompose(gt.grip.position,gt.grip.rotation,gt.grip.scale)))),gt.targetRay&&(gt.targetRay.visible=Dt!==null),gt.grip&&(gt.grip.visible=Ot!==null)}ie&&ie(le,De)}var ae=new W0;ae.setAnimationLoop(ue),this.setAnimationLoop=function(le){ie=le},this.dispose=function(){}}Object.assign(dx.prototype,To.prototype);function px(e){e=e||{};var n=e.canvas!==void 0?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=e.context!==void 0?e.context:null,l=e.alpha!==void 0?e.alpha:!1,h=e.depth!==void 0?e.depth:!0,p=e.stencil!==void 0?e.stencil:!0,_=e.antialias!==void 0?e.antialias:!1,s=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,M=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,T=e.powerPreference!==void 0?e.powerPreference:"default",C=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,E=null,L=null;this.domElement=n,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=ia,this.physicallyCorrectLights=!1,this.toneMapping=Hg,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var I=this,B=!1,O=null,U=0,q=0,ee=null,he=null,Ce=-1,K={geometry:null,program:null,wireframe:!1},ie=null,ue=null,ae=new gi,le=new gi,De=null,ye=n.width,se=n.height,Ue=1,Oe=null,We=null,st=new gi(0,0,ye,se),St=new gi(0,0,ye,se),gt=!1,At=new wh,Dt=new tA,Ot=!1,Pe=!1,ge=new jn,Ve=new Ee;function Ne(){return ee===null?Ue:1}var Ie;try{var it={alpha:l,depth:h,stencil:p,antialias:_,premultipliedAlpha:s,preserveDrawingBuffer:M,powerPreference:T,failIfMajorPerformanceCaveat:C,xrCompatible:!0};if(n.addEventListener("webglcontextlost",Zt,!1),n.addEventListener("webglcontextrestored",qe,!1),Ie=i||n.getContext("webgl",it)||n.getContext("experimental-webgl",it),Ie===null)throw n.getContext("webgl")!==null?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");Ie.getShaderPrecisionFormat===void 0&&(Ie.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(W){throw console.error("THREE.WebGLRenderer: "+W.message),W}var ce,we,Me,pe,Be,$e,ot,bt,Vt,oe,ve,xt,mt,xn,un,tn,dn;function bn(){ce=new nA(Ie),we=new eA(Ie,ce,e),we.isWebGL2===!1&&(ce.get("WEBGL_depth_texture"),ce.get("OES_texture_float"),ce.get("OES_texture_half_float"),ce.get("OES_texture_half_float_linear"),ce.get("OES_standard_derivatives"),ce.get("OES_element_index_uint"),ce.get("ANGLE_instanced_arrays")),ce.get("OES_texture_float_linear"),dn=new xC(Ie,ce,we),Me=new yC(Ie,ce,we),Me.scissor(le.copy(St).multiplyScalar(Ue).floor()),Me.viewport(ae.copy(st).multiplyScalar(Ue).floor()),pe=new aA,Be=new sC,$e=new vC(Ie,ce,Me,Be,we,dn,pe),ot=new I2(Ie,we),bt=new iA(Ie,ot,pe),Vt=new lA(Ie,bt,ot,pe),xn=new sA(Ie),oe=new oC(I,ce,we),ve=new uC,xt=new mC,mt=new KS(I,Me,Vt,s),un=new QS(Ie,ce,pe,we),tn=new rA(Ie,ce,pe,we),pe.programs=oe.programs,I.capabilities=we,I.extensions=ce,I.properties=Be,I.renderLists=ve,I.state=Me,I.info=pe}bn();var ln=new dx(I,Ie);this.xr=ln;var Gt=new bC(I,Ie),on=new hx(I,Vt,we.maxTextureSize);this.shadowMap=on,this.getContext=function(){return Ie},this.getContextAttributes=function(){return Ie.getContextAttributes()},this.forceContextLoss=function(){var W=ce.get("WEBGL_lose_context");W&&W.loseContext()},this.forceContextRestore=function(){var W=ce.get("WEBGL_lose_context");W&&W.restoreContext()},this.getPixelRatio=function(){return Ue},this.setPixelRatio=function(W){W!==void 0&&(Ue=W,this.setSize(ye,se,!1))},this.getSize=function(W){return W===void 0&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),W=new Lt),W.set(ye,se)},this.setSize=function(W,Y,ze){if(ln.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ye=W,se=Y,n.width=Math.floor(W*Ue),n.height=Math.floor(Y*Ue),ze!==!1&&(n.style.width=W+"px",n.style.height=Y+"px"),this.setViewport(0,0,W,Y)},this.getDrawingBufferSize=function(W){return W===void 0&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),W=new Lt),W.set(ye*Ue,se*Ue).floor()},this.setDrawingBufferSize=function(W,Y,ze){ye=W,se=Y,Ue=ze,n.width=Math.floor(W*ze),n.height=Math.floor(Y*ze),this.setViewport(0,0,W,Y)},this.getCurrentViewport=function(W){return W===void 0&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),W=new gi),W.copy(ae)},this.getViewport=function(W){return W.copy(st)},this.setViewport=function(W,Y,ze,xe){W.isVector4?st.set(W.x,W.y,W.z,W.w):st.set(W,Y,ze,xe),Me.viewport(ae.copy(st).multiplyScalar(Ue).floor())},this.getScissor=function(W){return W.copy(St)},this.setScissor=function(W,Y,ze,xe){W.isVector4?St.set(W.x,W.y,W.z,W.w):St.set(W,Y,ze,xe),Me.scissor(le.copy(St).multiplyScalar(Ue).floor())},this.getScissorTest=function(){return gt},this.setScissorTest=function(W){Me.setScissorTest(gt=W)},this.setOpaqueSort=function(W){Oe=W},this.setTransparentSort=function(W){We=W},this.getClearColor=function(){return mt.getClearColor()},this.setClearColor=function(){mt.setClearColor.apply(mt,arguments)},this.getClearAlpha=function(){return mt.getClearAlpha()},this.setClearAlpha=function(){mt.setClearAlpha.apply(mt,arguments)},this.clear=function(W,Y,ze){var xe=0;(W===void 0||W)&&(xe|=16384),(Y===void 0||Y)&&(xe|=256),(ze===void 0||ze)&&(xe|=1024),Ie.clear(xe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Zt,!1),n.removeEventListener("webglcontextrestored",qe,!1),ve.dispose(),xt.dispose(),Be.dispose(),Vt.dispose(),ln.dispose(),Nn.stop()};function Zt(W){W.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),B=!0}function qe(){console.log("THREE.WebGLRenderer: Context Restored."),B=!1,bn()}function Nt(W){var Y=W.target;Y.removeEventListener("dispose",Nt),Qt(Y)}function Qt(W){Pn(W),Be.remove(W)}function Pn(W){var Y=Be.get(W).program;W.program=void 0,Y!==void 0&&oe.releaseProgram(Y)}function pn(W,Y){W.render(function(ze){I.renderBufferImmediate(ze,Y)})}this.renderBufferImmediate=function(W,Y){Me.initAttributes();var ze=Be.get(W);W.hasPositions&&!ze.position&&(ze.position=Ie.createBuffer()),W.hasNormals&&!ze.normal&&(ze.normal=Ie.createBuffer()),W.hasUvs&&!ze.uv&&(ze.uv=Ie.createBuffer()),W.hasColors&&!ze.color&&(ze.color=Ie.createBuffer());var xe=Y.getAttributes();W.hasPositions&&(Ie.bindBuffer(34962,ze.position),Ie.bufferData(34962,W.positionArray,35048),Me.enableAttribute(xe.position),Ie.vertexAttribPointer(xe.position,3,5126,!1,0,0)),W.hasNormals&&(Ie.bindBuffer(34962,ze.normal),Ie.bufferData(34962,W.normalArray,35048),Me.enableAttribute(xe.normal),Ie.vertexAttribPointer(xe.normal,3,5126,!1,0,0)),W.hasUvs&&(Ie.bindBuffer(34962,ze.uv),Ie.bufferData(34962,W.uvArray,35048),Me.enableAttribute(xe.uv),Ie.vertexAttribPointer(xe.uv,2,5126,!1,0,0)),W.hasColors&&(Ie.bindBuffer(34962,ze.color),Ie.bufferData(34962,W.colorArray,35048),Me.enableAttribute(xe.color),Ie.vertexAttribPointer(xe.color,3,5126,!1,0,0)),Me.disableUnusedAttributes(),Ie.drawArrays(4,0,W.count),W.count=0};var On=new So;this.renderBufferDirect=function(W,Y,ze,xe,Mt,_t){Y===null&&(Y=On);var Ft=Mt.isMesh&&Mt.matrixWorld.determinant()<0,nn=Hr(W,Y,xe,Mt);Me.setMaterial(xe,Ft);var Ln=!1;(K.geometry!==ze.id||K.program!==nn.id||K.wireframe!==(xe.wireframe===!0))&&(K.geometry=ze.id,K.program=nn.id,K.wireframe=xe.wireframe===!0,Ln=!0),(xe.morphTargets||xe.morphNormals)&&(xn.update(Mt,ze,xe,nn),Ln=!0);var Dn=ze.index,wt=ze.attributes.position;if(Dn===null){if(wt===void 0||wt.count===0)return}else if(Dn.count===0)return;var cn=1;xe.wireframe===!0&&(Dn=bt.getWireframeAttribute(ze),cn=2);var $t,fn=un;Dn!==null&&($t=ot.get(Dn),fn=tn,fn.setIndex($t)),Ln&&(Gn(Mt,ze,xe,nn),Dn!==null&&Ie.bindBuffer(34963,$t.buffer));var Tn=Dn!==null?Dn.count:wt.count,Sn=ze.drawRange.start*cn,di=ze.drawRange.count*cn,Ar=_t!==null?_t.start*cn:0,ai=_t!==null?_t.count*cn:1/0,li=Math.max(Sn,Ar),oi=Math.min(Tn,Sn+di,Ar+ai)-1,ys=Math.max(0,oi-li+1);if(ys!==0){if(Mt.isMesh)xe.wireframe===!0?(Me.setLineWidth(xe.wireframeLinewidth*Ne()),fn.setMode(1)):fn.setMode(4);else if(Mt.isLine){var za=xe.linewidth;za===void 0&&(za=1),Me.setLineWidth(za*Ne()),Mt.isLineSegments?fn.setMode(1):Mt.isLineLoop?fn.setMode(2):fn.setMode(3)}else Mt.isPoints?fn.setMode(0):Mt.isSprite&&fn.setMode(4);Mt.isInstancedMesh?fn.renderInstances(ze,li,ys,Mt.count):ze.isInstancedBufferGeometry?fn.renderInstances(ze,li,ys,ze.maxInstancedCount):fn.render(li,ys)}};function Gn(W,Y,ze,xe){if(!(we.isWebGL2===!1&&(W.isInstancedMesh||Y.isInstancedBufferGeometry)&&ce.get("ANGLE_instanced_arrays")===null)){Me.initAttributes();var Mt=Y.attributes,_t=xe.getAttributes(),Ft=ze.defaultAttributeValues;for(var nn in _t){var Ln=_t[nn];if(Ln>=0){var Dn=Mt[nn];if(Dn!==void 0){var wt=Dn.normalized,cn=Dn.itemSize,$t=ot.get(Dn);if($t===void 0)continue;var fn=$t.buffer,Tn=$t.type,Sn=$t.bytesPerElement;if(Dn.isInterleavedBufferAttribute){var di=Dn.data,Ar=di.stride,ai=Dn.offset;di&&di.isInstancedInterleavedBuffer?(Me.enableAttributeAndDivisor(Ln,di.meshPerAttribute),Y.maxInstancedCount===void 0&&(Y.maxInstancedCount=di.meshPerAttribute*di.count)):Me.enableAttribute(Ln),Ie.bindBuffer(34962,fn),Ie.vertexAttribPointer(Ln,cn,Tn,wt,Ar*Sn,ai*Sn)}else Dn.isInstancedBufferAttribute?(Me.enableAttributeAndDivisor(Ln,Dn.meshPerAttribute),Y.maxInstancedCount===void 0&&(Y.maxInstancedCount=Dn.meshPerAttribute*Dn.count)):Me.enableAttribute(Ln),Ie.bindBuffer(34962,fn),Ie.vertexAttribPointer(Ln,cn,Tn,wt,0,0)}else if(nn==="instanceMatrix"){var $t=ot.get(W.instanceMatrix);if($t===void 0)continue;var fn=$t.buffer,Tn=$t.type;Me.enableAttributeAndDivisor(Ln+0,1),Me.enableAttributeAndDivisor(Ln+1,1),Me.enableAttributeAndDivisor(Ln+2,1),Me.enableAttributeAndDivisor(Ln+3,1),Ie.bindBuffer(34962,fn),Ie.vertexAttribPointer(Ln+0,4,Tn,!1,64,0),Ie.vertexAttribPointer(Ln+1,4,Tn,!1,64,16),Ie.vertexAttribPointer(Ln+2,4,Tn,!1,64,32),Ie.vertexAttribPointer(Ln+3,4,Tn,!1,64,48)}else if(Ft!==void 0){var li=Ft[nn];if(li!==void 0)switch(li.length){case 2:Ie.vertexAttrib2fv(Ln,li);break;case 3:Ie.vertexAttrib3fv(Ln,li);break;case 4:Ie.vertexAttrib4fv(Ln,li);break;default:Ie.vertexAttrib1fv(Ln,li)}}}}Me.disableUnusedAttributes()}}this.compile=function(W,Y){L=xt.get(W,Y),L.init(),W.traverse(function(xe){xe.isLight&&(L.pushLight(xe),xe.castShadow&&L.pushShadow(xe))}),L.setupLights(Y);var ze={};W.traverse(function(xe){if(xe.material)if(Array.isArray(xe.material))for(var Mt=0;Mt<xe.material.length;Mt++)xe.material[Mt].uuid in ze||(yi(xe.material[Mt],W,xe),ze[xe.material[Mt].uuid]=!0);else xe.material.uuid in ze||(yi(xe.material,W,xe),ze[xe.material.uuid]=!0)})};var Zn=null;function Wi(W){ln.isPresenting||Zn&&Zn(W)}var Nn=new W0;Nn.setAnimationLoop(Wi),typeof window!="undefined"&&Nn.setContext(window),this.setAnimationLoop=function(W){Zn=W,ln.setAnimationLoop(W),Nn.start()},this.render=function(W,Y){var ze,xe;if(arguments[2]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),ze=arguments[2]),arguments[3]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),xe=arguments[3]),!(Y&&Y.isCamera)){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(!B){K.geometry=null,K.program=null,K.wireframe=!1,Ce=-1,ie=null,W.autoUpdate===!0&&W.updateMatrixWorld(),Y.parent===null&&Y.updateMatrixWorld(),ln.enabled&&ln.isPresenting&&(Y=ln.getCamera(Y)),L=xt.get(W,Y),L.init(),W.onBeforeRender(I,W,Y,ze||ee),ge.multiplyMatrices(Y.projectionMatrix,Y.matrixWorldInverse),At.setFromProjectionMatrix(ge),Pe=this.localClippingEnabled,Ot=Dt.init(this.clippingPlanes,Pe,Y),E=ve.get(W,Y),E.init(),Ci(W,Y,0,I.sortObjects),I.sortObjects===!0&&E.sort(Oe,We),Ot&&Dt.beginShadows();var Mt=L.state.shadowsArray;on.render(Mt,W,Y),L.setupLights(Y),Ot&&Dt.endShadows(),this.info.autoReset&&this.info.reset(),ze!==void 0&&this.setRenderTarget(ze),ln.enabled&&Gt.isAvailable()&&Gt.attachCamera(Y),mt.render(E,W,Y,xe);var _t=E.opaque,Ft=E.transparent;if(W.overrideMaterial){var nn=W.overrideMaterial;_t.length&&ei(_t,W,Y,nn),Ft.length&&ei(Ft,W,Y,nn)}else _t.length&&ei(_t,W,Y),Ft.length&&ei(Ft,W,Y);W.onAfterRender(I,W,Y),ee!==null&&($e.updateRenderTargetMipmap(ee),$e.updateMultisampleRenderTarget(ee)),Me.buffers.depth.setTest(!0),Me.buffers.depth.setMask(!0),Me.buffers.color.setMask(!0),Me.setPolygonOffset(!1),ln.enabled&&Gt.isAvailable()&&Gt.detachCamera(Y),E=null,L=null}};function Ci(W,Y,ze,xe){if(W.visible!==!1){var Mt=W.layers.test(Y.layers);if(Mt){if(W.isGroup)ze=W.renderOrder;else if(W.isLOD)W.autoUpdate===!0&&W.update(Y);else if(W.isLight)L.pushLight(W),W.castShadow&&L.pushShadow(W);else if(W.isSprite){if(!W.frustumCulled||At.intersectsSprite(W)){xe&&Ve.setFromMatrixPosition(W.matrixWorld).applyMatrix4(ge);var _t=Vt.update(W),Ft=W.material;Ft.visible&&E.push(W,_t,Ft,ze,Ve.z,null)}}else if(W.isImmediateRenderObject)xe&&Ve.setFromMatrixPosition(W.matrixWorld).applyMatrix4(ge),E.push(W,null,W.material,ze,Ve.z,null);else if((W.isMesh||W.isLine||W.isPoints)&&(W.isSkinnedMesh&&W.skeleton.frame!==pe.render.frame&&(W.skeleton.update(),W.skeleton.frame=pe.render.frame),!W.frustumCulled||At.intersectsObject(W))){xe&&Ve.setFromMatrixPosition(W.matrixWorld).applyMatrix4(ge);var _t=Vt.update(W),Ft=W.material;if(Array.isArray(Ft))for(var nn=_t.groups,Ln=0,Dn=nn.length;Ln<Dn;Ln++){var wt=nn[Ln],cn=Ft[wt.materialIndex];cn&&cn.visible&&E.push(W,_t,cn,ze,Ve.z,wt)}else Ft.visible&&E.push(W,_t,Ft,ze,Ve.z,null)}}for(var $t=W.children,Ln=0,Dn=$t.length;Ln<Dn;Ln++)Ci($t[Ln],Y,ze,xe)}}function ei(W,Y,ze,xe){for(var Mt=0,_t=W.length;Mt<_t;Mt++){var Ft=W[Mt],nn=Ft.object,Ln=Ft.geometry,Dn=xe===void 0?Ft.material:xe,wt=Ft.group;if(ze.isArrayCamera)if(ue=ze,ln.enabled&&Gt.isAvailable())Ki(nn,Y,ze,Ln,Dn,wt);else for(var cn=ze.cameras,$t=0,fn=cn.length;$t<fn;$t++){var Tn=cn[$t];nn.layers.test(Tn.layers)&&(Me.viewport(ae.copy(Tn.viewport)),L.setupLights(Tn),Ki(nn,Y,Tn,Ln,Dn,wt))}else ue=null,Ki(nn,Y,ze,Ln,Dn,wt)}}function Ki(W,Y,ze,xe,Mt,_t){if(W.onBeforeRender(I,Y,ze,xe,Mt,_t),L=xt.get(Y,ue||ze),W.modelViewMatrix.multiplyMatrices(ze.matrixWorldInverse,W.matrixWorld),W.normalMatrix.getNormalMatrix(W.modelViewMatrix),W.isImmediateRenderObject){var Ft=Hr(ze,Y,Mt,W);Me.setMaterial(Mt),K.geometry=null,K.program=null,K.wireframe=!1,pn(W,Ft)}else I.renderBufferDirect(ze,Y,xe,Mt,W,_t);W.onAfterRender(I,Y,ze,xe,Mt,_t),L=xt.get(Y,ue||ze)}function yi(W,Y,ze){var xe=Be.get(W),Mt=L.state.lights,_t=L.state.shadowsArray,Ft=Mt.state.version,nn=oe.getParameters(W,Mt.state,_t,Y,Dt.numPlanes,Dt.numIntersection,ze),Ln=oe.getProgramCacheKey(nn),Dn=xe.program,wt=!0;if(Dn===void 0)W.addEventListener("dispose",Nt);else if(Dn.cacheKey!==Ln)Pn(W);else if(xe.lightsStateVersion!==Ft)xe.lightsStateVersion=Ft,wt=!1;else{if(nn.shaderID!==void 0)return;wt=!1}wt&&(Dn=oe.acquireProgram(nn,Ln),xe.program=Dn,xe.uniforms=nn.uniforms,xe.environment=W.isMeshStandardMaterial?Y.environment:null,xe.outputEncoding=I.outputEncoding,W.program=Dn);var cn=Dn.getAttributes();if(W.morphTargets){W.numSupportedMorphTargets=0;for(var $t=0;$t<I.maxMorphTargets;$t++)cn["morphTarget"+$t]>=0&&W.numSupportedMorphTargets++}if(W.morphNormals){W.numSupportedMorphNormals=0;for(var $t=0;$t<I.maxMorphNormals;$t++)cn["morphNormal"+$t]>=0&&W.numSupportedMorphNormals++}var fn=xe.uniforms;(!W.isShaderMaterial&&!W.isRawShaderMaterial||W.clipping===!0)&&(xe.numClippingPlanes=Dt.numPlanes,xe.numIntersection=Dt.numIntersection,fn.clippingPlanes=Dt.uniform),xe.fog=Y.fog,xe.needsLights=_n(W),xe.lightsStateVersion=Ft,xe.needsLights&&(fn.ambientLightColor.value=Mt.state.ambient,fn.lightProbe.value=Mt.state.probe,fn.directionalLights.value=Mt.state.directional,fn.spotLights.value=Mt.state.spot,fn.rectAreaLights.value=Mt.state.rectArea,fn.pointLights.value=Mt.state.point,fn.hemisphereLights.value=Mt.state.hemi,fn.directionalShadowMap.value=Mt.state.directionalShadowMap,fn.directionalShadowMatrix.value=Mt.state.directionalShadowMatrix,fn.spotShadowMap.value=Mt.state.spotShadowMap,fn.spotShadowMatrix.value=Mt.state.spotShadowMatrix,fn.pointShadowMap.value=Mt.state.pointShadowMap,fn.pointShadowMatrix.value=Mt.state.pointShadowMatrix);var Tn=xe.program.getUniforms(),Sn=as.seqWithValue(Tn.seq,fn);xe.uniformsList=Sn}function Hr(W,Y,ze,xe){$e.resetTextureUnits();var Mt=Y.fog,_t=ze.isMeshStandardMaterial?Y.environment:null,Ft=Be.get(ze),nn=L.state.lights;if(Ot&&(Pe||W!==ie)){var Ln=W===ie&&ze.id===Ce;Dt.setState(ze.clippingPlanes,ze.clipIntersection,ze.clipShadows,W,Ft,Ln)}ze.version===Ft.__version?(Ft.program===void 0||ze.fog&&Ft.fog!==Mt||Ft.environment!==_t||Ft.needsLights&&Ft.lightsStateVersion!==nn.state.version||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==Dt.numPlanes||Ft.numIntersection!==Dt.numIntersection)||Ft.outputEncoding!==I.outputEncoding)&&yi(ze,Y,xe):(yi(ze,Y,xe),Ft.__version=ze.version);var Dn=!1,wt=!1,cn=!1,$t=Ft.program,fn=$t.getUniforms(),Tn=Ft.uniforms;if(Me.useProgram($t.program)&&(Dn=!0,wt=!0,cn=!0),ze.id!==Ce&&(Ce=ze.id,wt=!0),Dn||ie!==W){if($t.numMultiviewViews>0?Gt.updateCameraProjectionMatricesUniform(W,fn):fn.setValue(Ie,"projectionMatrix",W.projectionMatrix),we.logarithmicDepthBuffer&&fn.setValue(Ie,"logDepthBufFC",2/(Math.log(W.far+1)/Math.LN2)),ie!==W&&(ie=W,wt=!0,cn=!0),ze.isShaderMaterial||ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshStandardMaterial||ze.envMap){var Sn=fn.map.cameraPosition;Sn!==void 0&&Sn.setValue(Ie,Ve.setFromMatrixPosition(W.matrixWorld))}(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial)&&fn.setValue(Ie,"isOrthographic",W.isOrthographicCamera===!0),(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial||ze.skinning)&&($t.numMultiviewViews>0?Gt.updateCameraViewMatricesUniform(W,fn):fn.setValue(Ie,"viewMatrix",W.matrixWorldInverse))}if(ze.skinning){fn.setOptional(Ie,xe,"bindMatrix"),fn.setOptional(Ie,xe,"bindMatrixInverse");var di=xe.skeleton;if(di){var Ar=di.bones;if(we.floatVertexTextures){if(di.boneTexture===void 0){var ai=Math.sqrt(Ar.length*4);ai=Wn.ceilPowerOfTwo(ai),ai=Math.max(ai,4);var li=new Float32Array(ai*ai*4);li.set(di.boneMatrices);var oi=new Mc(li,ai,ai,Aa,lh);di.boneMatrices=li,di.boneTexture=oi,di.boneTextureSize=ai}fn.setValue(Ie,"boneTexture",di.boneTexture,$e),fn.setValue(Ie,"boneTextureSize",di.boneTextureSize)}else fn.setOptional(Ie,di,"boneMatrices")}}return(wt||Ft.receiveShadow!==xe.receiveShadow)&&(Ft.receiveShadow=xe.receiveShadow,fn.setValue(Ie,"receiveShadow",xe.receiveShadow)),wt&&(fn.setValue(Ie,"toneMappingExposure",I.toneMappingExposure),fn.setValue(Ie,"toneMappingWhitePoint",I.toneMappingWhitePoint),Ft.needsLights&&Et(Tn,cn),Mt&&ze.fog&&Z(Tn,Mt),ze.isMeshBasicMaterial?ki(Tn,ze):ze.isMeshLambertMaterial?(ki(Tn,ze),de(Tn,ze)):ze.isMeshToonMaterial?(ki(Tn,ze),Ge(Tn,ze)):ze.isMeshPhongMaterial?(ki(Tn,ze),Le(Tn,ze)):ze.isMeshStandardMaterial?(ki(Tn,ze,_t),ze.isMeshPhysicalMaterial?Ke(Tn,ze,_t):Je(Tn,ze,_t)):ze.isMeshMatcapMaterial?(ki(Tn,ze),je(Tn,ze)):ze.isMeshDepthMaterial?(ki(Tn,ze),nt(Tn,ze)):ze.isMeshDistanceMaterial?(ki(Tn,ze),yt(Tn,ze)):ze.isMeshNormalMaterial?(ki(Tn,ze),Ut(Tn,ze)):ze.isLineBasicMaterial?(Wr(Tn,ze),ze.isLineDashedMaterial&&Sr(Tn,ze)):ze.isPointsMaterial?_e(Tn,ze):ze.isSpriteMaterial?G(Tn,ze):ze.isShadowMaterial&&(Tn.color.value.copy(ze.color),Tn.opacity.value=ze.opacity),Tn.ltc_1!==void 0&&(Tn.ltc_1.value=an.LTC_1),Tn.ltc_2!==void 0&&(Tn.ltc_2.value=an.LTC_2),as.upload(Ie,Ft.uniformsList,Tn,$e),ze.isShaderMaterial&&(ze.uniformsNeedUpdate=!1)),ze.isShaderMaterial&&ze.uniformsNeedUpdate===!0&&(as.upload(Ie,Ft.uniformsList,Tn,$e),ze.uniformsNeedUpdate=!1),ze.isSpriteMaterial&&fn.setValue(Ie,"center",xe.center),$t.numMultiviewViews>0?Gt.updateObjectMatricesUniforms(xe,W,fn):(fn.setValue(Ie,"modelViewMatrix",xe.modelViewMatrix),fn.setValue(Ie,"normalMatrix",xe.normalMatrix)),fn.setValue(Ie,"modelMatrix",xe.matrixWorld),$t}function ki(W,Y,ze){W.opacity.value=Y.opacity,Y.color&&W.diffuse.value.copy(Y.color),Y.emissive&&W.emissive.value.copy(Y.emissive).multiplyScalar(Y.emissiveIntensity),Y.map&&(W.map.value=Y.map),Y.alphaMap&&(W.alphaMap.value=Y.alphaMap),Y.specularMap&&(W.specularMap.value=Y.specularMap);var xe=Y.envMap||ze;xe&&(W.envMap.value=xe,W.flipEnvMap.value=xe.isCubeTexture?-1:1,W.reflectivity.value=Y.reflectivity,W.refractionRatio.value=Y.refractionRatio,W.maxMipLevel.value=Be.get(xe).__maxMipLevel),Y.lightMap&&(W.lightMap.value=Y.lightMap,W.lightMapIntensity.value=Y.lightMapIntensity),Y.aoMap&&(W.aoMap.value=Y.aoMap,W.aoMapIntensity.value=Y.aoMapIntensity);var Mt;Y.map?Mt=Y.map:Y.specularMap?Mt=Y.specularMap:Y.displacementMap?Mt=Y.displacementMap:Y.normalMap?Mt=Y.normalMap:Y.bumpMap?Mt=Y.bumpMap:Y.roughnessMap?Mt=Y.roughnessMap:Y.metalnessMap?Mt=Y.metalnessMap:Y.alphaMap?Mt=Y.alphaMap:Y.emissiveMap&&(Mt=Y.emissiveMap),Mt!==void 0&&(Mt.isWebGLRenderTarget&&(Mt=Mt.texture),Mt.matrixAutoUpdate===!0&&Mt.updateMatrix(),W.uvTransform.value.copy(Mt.matrix));var _t;Y.aoMap?_t=Y.aoMap:Y.lightMap&&(_t=Y.lightMap),_t!==void 0&&(_t.isWebGLRenderTarget&&(_t=_t.texture),_t.matrixAutoUpdate===!0&&_t.updateMatrix(),W.uv2Transform.value.copy(_t.matrix))}function Wr(W,Y){W.diffuse.value.copy(Y.color),W.opacity.value=Y.opacity}function Sr(W,Y){W.dashSize.value=Y.dashSize,W.totalSize.value=Y.dashSize+Y.gapSize,W.scale.value=Y.scale}function _e(W,Y){W.diffuse.value.copy(Y.color),W.opacity.value=Y.opacity,W.size.value=Y.size*Ue,W.scale.value=se*.5,Y.map&&(W.map.value=Y.map),Y.alphaMap&&(W.alphaMap.value=Y.alphaMap);var ze;Y.map?ze=Y.map:Y.alphaMap&&(ze=Y.alphaMap),ze!==void 0&&(ze.matrixAutoUpdate===!0&&ze.updateMatrix(),W.uvTransform.value.copy(ze.matrix))}function G(W,Y){W.diffuse.value.copy(Y.color),W.opacity.value=Y.opacity,W.rotation.value=Y.rotation,Y.map&&(W.map.value=Y.map),Y.alphaMap&&(W.alphaMap.value=Y.alphaMap);var ze;Y.map?ze=Y.map:Y.alphaMap&&(ze=Y.alphaMap),ze!==void 0&&(ze.matrixAutoUpdate===!0&&ze.updateMatrix(),W.uvTransform.value.copy(ze.matrix))}function Z(W,Y){W.fogColor.value.copy(Y.color),Y.isFog?(W.fogNear.value=Y.near,W.fogFar.value=Y.far):Y.isFogExp2&&(W.fogDensity.value=Y.density)}function de(W,Y){Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap)}function Le(W,Y){W.specular.value.copy(Y.specular),W.shininess.value=Math.max(Y.shininess,1e-4),Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function Ge(W,Y){W.specular.value.copy(Y.specular),W.shininess.value=Math.max(Y.shininess,1e-4),Y.gradientMap&&(W.gradientMap.value=Y.gradientMap),Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function Je(W,Y,ze){W.roughness.value=Y.roughness,W.metalness.value=Y.metalness,Y.roughnessMap&&(W.roughnessMap.value=Y.roughnessMap),Y.metalnessMap&&(W.metalnessMap.value=Y.metalnessMap),Y.emissiveMap&&(W.emissiveMap.value=Y.emissiveMap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias),(Y.envMap||ze)&&(W.envMapIntensity.value=Y.envMapIntensity)}function Ke(W,Y,ze){Je(W,Y,ze),W.reflectivity.value=Y.reflectivity,W.clearcoat.value=Y.clearcoat,W.clearcoatRoughness.value=Y.clearcoatRoughness,Y.sheen&&W.sheen.value.copy(Y.sheen),Y.clearcoatNormalMap&&(W.clearcoatNormalScale.value.copy(Y.clearcoatNormalScale),W.clearcoatNormalMap.value=Y.clearcoatNormalMap,Y.side===tr&&W.clearcoatNormalScale.value.negate()),W.transparency.value=Y.transparency}function je(W,Y){Y.matcap&&(W.matcap.value=Y.matcap),Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function nt(W,Y){Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function yt(W,Y){Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias),W.referencePosition.value.copy(Y.referencePosition),W.nearDistance.value=Y.nearDistance,W.farDistance.value=Y.farDistance}function Ut(W,Y){Y.bumpMap&&(W.bumpMap.value=Y.bumpMap,W.bumpScale.value=Y.bumpScale,Y.side===tr&&(W.bumpScale.value*=-1)),Y.normalMap&&(W.normalMap.value=Y.normalMap,W.normalScale.value.copy(Y.normalScale),Y.side===tr&&W.normalScale.value.negate()),Y.displacementMap&&(W.displacementMap.value=Y.displacementMap,W.displacementScale.value=Y.displacementScale,W.displacementBias.value=Y.displacementBias)}function Et(W,Y){W.ambientLightColor.needsUpdate=Y,W.lightProbe.needsUpdate=Y,W.directionalLights.needsUpdate=Y,W.pointLights.needsUpdate=Y,W.spotLights.needsUpdate=Y,W.rectAreaLights.needsUpdate=Y,W.hemisphereLights.needsUpdate=Y}function _n(W){return W.isMeshLambertMaterial||W.isMeshToonMaterial||W.isMeshPhongMaterial||W.isMeshStandardMaterial||W.isShadowMaterial||W.isShaderMaterial&&W.lights===!0}this.setFramebuffer=function(W){O!==W&&ee===null&&Ie.bindFramebuffer(36160,W),O=W},this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return ee},this.setRenderTarget=function(W,Y,ze){ee=W,U=Y,q=ze,W&&Be.get(W).__webglFramebuffer===void 0&&$e.setupRenderTarget(W);var xe=O,Mt=!1;if(W){var _t=Be.get(W).__webglFramebuffer;W.isWebGLCubeRenderTarget?(xe=_t[Y||0],Mt=!0):W.isWebGLMultisampleRenderTarget?xe=Be.get(W).__webglMultisampledFramebuffer:xe=_t,ae.copy(W.viewport),le.copy(W.scissor),De=W.scissorTest}else ae.copy(st).multiplyScalar(Ue).floor(),le.copy(St).multiplyScalar(Ue).floor(),De=gt;if(he!==xe&&(Ie.bindFramebuffer(36160,xe),he=xe),Me.viewport(ae),Me.scissor(le),Me.setScissorTest(De),Mt){var Ft=Be.get(W.texture);Ie.framebufferTexture2D(36160,36064,34069+(Y||0),Ft.__webglTexture,ze||0)}},this.readRenderTargetPixels=function(W,Y,ze,xe,Mt,_t,Ft){if(!(W&&W.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}var nn=Be.get(W).__webglFramebuffer;if(W.isWebGLCubeRenderTarget&&Ft!==void 0&&(nn=nn[Ft]),nn){var Ln=!1;nn!==he&&(Ie.bindFramebuffer(36160,nn),Ln=!0);try{var Dn=W.texture,wt=Dn.format,cn=Dn.type;if(wt!==Aa&&dn.convert(wt)!==Ie.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(cn!==Wp&&dn.convert(cn)!==Ie.getParameter(35738)&&!(cn===lh&&(we.isWebGL2||ce.get("OES_texture_float")||ce.get("WEBGL_color_buffer_float")))&&!(cn===$g&&(we.isWebGL2?ce.get("EXT_color_buffer_float"):ce.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ie.checkFramebufferStatus(36160)===36053?Y>=0&&Y<=W.width-xe&&ze>=0&&ze<=W.height-Mt&&Ie.readPixels(Y,ze,xe,Mt,dn.convert(wt),dn.convert(cn),_t):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Ln&&Ie.bindFramebuffer(36160,he)}}},this.copyFramebufferToTexture=function(W,Y,ze){ze===void 0&&(ze=0);var xe=Math.pow(2,-ze),Mt=Math.floor(Y.image.width*xe),_t=Math.floor(Y.image.height*xe),Ft=dn.convert(Y.format);$e.setTexture2D(Y,0),Ie.copyTexImage2D(3553,ze,Ft,W.x,W.y,Mt,_t,0),Me.unbindTexture()},this.copyTextureToTexture=function(W,Y,ze,xe){var Mt=Y.image.width,_t=Y.image.height,Ft=dn.convert(ze.format),nn=dn.convert(ze.type);$e.setTexture2D(ze,0),Y.isDataTexture?Ie.texSubImage2D(3553,xe||0,W.x,W.y,Mt,_t,Ft,nn,Y.image.data):Ie.texSubImage2D(3553,xe||0,W.x,W.y,Ft,nn,Y.image),Me.unbindTexture()},this.initTexture=function(W){$e.setTexture2D(W,0),Me.unbindTexture()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function P_(e,n){this.name="",this.color=new en(e),this.density=n!==void 0?n:25e-5}Object.assign(P_.prototype,{isFogExp2:!0,clone:function(){return new P_(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});function L_(e,n,i){this.name="",this.color=new en(e),this.near=n!==void 0?n:1,this.far=i!==void 0?i:1e3}Object.assign(L_.prototype,{isFog:!0,clone:function(){return new L_(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});function zo(e,n){this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=Xp,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(zo.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(zo.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,n,i){e*=this.stride,i*=n.stride;for(var l=0,h=this.stride;l<h;l++)this.array[e+l]=n.array[i+l];return this},set:function(e,n){return n===void 0&&(n=0),this.array.set(e,n),this},clone:function(){return new this.constructor().copy(this)},onUpload:function(e){return this.onUploadCallback=e,this}});var al=new Ee;function Ah(e,n,i,l){this.data=e,this.itemSize=n,this.offset=i,this.normalized=l===!0}Object.defineProperties(Ah.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Ah.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(var n=0,i=this.data.count;n<i;n++)al.x=this.getX(n),al.y=this.getY(n),al.z=this.getZ(n),al.applyMatrix4(e),this.setXYZ(n,al.x,al.y,al.z);return this},setX:function(e,n){return this.data.array[e*this.data.stride+this.offset]=n,this},setY:function(e,n){return this.data.array[e*this.data.stride+this.offset+1]=n,this},setZ:function(e,n){return this.data.array[e*this.data.stride+this.offset+2]=n,this},setW:function(e,n){return this.data.array[e*this.data.stride+this.offset+3]=n,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=n,this.data.array[e+1]=i,this},setXYZ:function(e,n,i,l){return e=e*this.data.stride+this.offset,this.data.array[e+0]=n,this.data.array[e+1]=i,this.data.array[e+2]=l,this},setXYZW:function(e,n,i,l,h){return e=e*this.data.stride+this.offset,this.data.array[e+0]=n,this.data.array[e+1]=i,this.data.array[e+2]=l,this.data.array[e+3]=h,this}});function ol(e){Rn.call(this),this.type="SpriteMaterial",this.color=new en(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}ol.prototype=Object.create(Rn.prototype),ol.prototype.constructor=ol,ol.prototype.isSpriteMaterial=!0,ol.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this};var Ac,Ch=new Ee,Cc=new Ee,Pc=new Ee,Lc=new Lt,Ph=new Lt,fx=new jn,ff=new Ee,Lh=new Ee,mf=new Ee,mx=new Lt,D_=new Lt,gx=new Lt;function I_(e){if(rn.call(this),this.type="Sprite",Ac===void 0){Ac=new yn;var n=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new zo(n,5);Ac.setIndex([0,1,2,0,2,3]),Ac.setAttribute("position",new Ah(i,3,0,!1)),Ac.setAttribute("uv",new Ah(i,2,3,!1))}this.geometry=Ac,this.material=e!==void 0?e:new ol,this.center=new Lt(.5,.5)}I_.prototype=Object.assign(Object.create(rn.prototype),{constructor:I_,isSprite:!0,raycast:function(e,n){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Cc.setFromMatrixScale(this.matrixWorld),fx.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Pc.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Cc.multiplyScalar(-Pc.z);var i=this.material.rotation,l,h;i!==0&&(h=Math.cos(i),l=Math.sin(i));var p=this.center;gf(ff.set(-.5,-.5,0),Pc,p,Cc,l,h),gf(Lh.set(.5,-.5,0),Pc,p,Cc,l,h),gf(mf.set(.5,.5,0),Pc,p,Cc,l,h),mx.set(0,0),D_.set(1,0),gx.set(1,1);var _=e.ray.intersectTriangle(ff,Lh,mf,!1,Ch);if(!(_===null&&(gf(Lh.set(-.5,.5,0),Pc,p,Cc,l,h),D_.set(0,1),_=e.ray.intersectTriangle(ff,mf,Lh,!1,Ch),_===null))){var s=e.ray.origin.distanceTo(Ch);s<e.near||s>e.far||n.push({distance:s,point:Ch.clone(),uv:sr.getUV(Ch,ff,Lh,mf,mx,D_,gx,new Lt),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return rn.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this}});function gf(e,n,i,l,h,p){Lc.subVectors(e,i).addScalar(.5).multiply(l),h!==void 0?(Ph.x=p*Lc.x-h*Lc.y,Ph.y=h*Lc.x+p*Lc.y):Ph.copy(Lc),e.copy(n),e.x+=Ph.x,e.y+=Ph.y,e.applyMatrix4(fx)}var _f=new Ee,_x=new Ee;function yf(){rn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}yf.prototype=Object.assign(Object.create(rn.prototype),{constructor:yf,isLOD:!0,copy:function(e){rn.prototype.copy.call(this,e,!1);for(var n=e.levels,i=0,l=n.length;i<l;i++){var h=n[i];this.addLevel(h.object.clone(),h.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,n){n===void 0&&(n=0),n=Math.abs(n);for(var i=this.levels,l=0;l<i.length&&!(n<i[l].distance);l++);return i.splice(l,0,{distance:n,object:e}),this.add(e),this},getObjectForDistance:function(e){var n=this.levels;if(n.length>0){for(var i=1,l=n.length;i<l&&!(e<n[i].distance);i++);return n[i-1].object}return null},raycast:function(e,n){var i=this.levels;if(i.length>0){_f.setFromMatrixPosition(this.matrixWorld);var l=e.ray.origin.distanceTo(_f);this.getObjectForDistance(l).raycast(e,n)}},update:function(e){var n=this.levels;if(n.length>1){_f.setFromMatrixPosition(e.matrixWorld),_x.setFromMatrixPosition(this.matrixWorld);var i=_f.distanceTo(_x);n[0].object.visible=!0;for(var l=1,h=n.length;l<h&&i>=n[l].distance;l++)n[l-1].object.visible=!1,n[l].object.visible=!0;for(;l<h;l++)n[l].object.visible=!1}},toJSON:function(e){var n=rn.prototype.toJSON.call(this,e);this.autoUpdate===!1&&(n.object.autoUpdate=!1),n.object.levels=[];for(var i=this.levels,l=0,h=i.length;l<h;l++){var p=i[l];n.object.levels.push({object:p.object.uuid,distance:p.distance})}return n}});function Dh(e,n){e&&e.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Ai.call(this,e,n),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new jn,this.bindMatrixInverse=new jn}Dh.prototype=Object.assign(Object.create(Ai.prototype),{constructor:Dh,isSkinnedMesh:!0,bind:function(e,n){this.skeleton=e,n===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),n=this.matrixWorld),this.bindMatrix.copy(n),this.bindMatrixInverse.getInverse(n)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var e=new gi,n=this.geometry.attributes.skinWeight,i=0,l=n.count;i<l;i++){e.x=n.getX(i),e.y=n.getY(i),e.z=n.getZ(i),e.w=n.getW(i);var h=1/e.manhattanLength();h!==1/0?e.multiplyScalar(h):e.set(1,0,0,0),n.setXYZW(i,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){Ai.prototype.updateMatrixWorld.call(this,e),this.bindMode==="attached"?this.bindMatrixInverse.getInverse(this.matrixWorld):this.bindMode==="detached"?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var yx=new jn,wC=new jn;function vf(e,n){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(this.bones.length*16),this.frame=-1,n===void 0)this.calculateInverses();else if(this.bones.length===n.length)this.boneInverses=n.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,l=this.bones.length;i<l;i++)this.boneInverses.push(new jn)}}Object.assign(vf.prototype,{calculateInverses:function(){this.boneInverses=[];for(var e=0,n=this.bones.length;e<n;e++){var i=new jn;this.bones[e]&&i.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(i)}},pose:function(){var e,n,i;for(n=0,i=this.bones.length;n<i;n++)e=this.bones[n],e&&e.matrixWorld.getInverse(this.boneInverses[n]);for(n=0,i=this.bones.length;n<i;n++)e=this.bones[n],e&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},update:function(){for(var e=this.bones,n=this.boneInverses,i=this.boneMatrices,l=this.boneTexture,h=0,p=e.length;h<p;h++){var _=e[h]?e[h].matrixWorld:wC;yx.multiplyMatrices(_,n[h]),yx.toArray(i,h*16)}l!==void 0&&(l.needsUpdate=!0)},clone:function(){return new vf(this.bones,this.boneInverses)},getBoneByName:function(e){for(var n=0,i=this.bones.length;n<i;n++){var l=this.bones[n];if(l.name===e)return l}}});function R_(){rn.call(this),this.type="Bone"}R_.prototype=Object.assign(Object.create(rn.prototype),{constructor:R_,isBone:!0});var vx=new jn,xx=new jn,Dc=[],Ih=new Ai;function z_(e,n,i){Ai.call(this,e,n),this.instanceMatrix=new zn(new Float32Array(i*16),16),this.count=i,this.frustumCulled=!1}z_.prototype=Object.assign(Object.create(Ai.prototype),{constructor:z_,isInstancedMesh:!0,getMatrixAt:function(e,n){n.fromArray(this.instanceMatrix.array,e*16)},raycast:function(e,n){var i=this.matrixWorld,l=this.count;if(Ih.geometry=this.geometry,Ih.material=this.material,Ih.material!==void 0)for(var h=0;h<l;h++)this.getMatrixAt(h,vx),xx.multiplyMatrices(i,vx),Ih.matrixWorld=xx,Ih.raycast(e,Dc),Dc.length>0&&(Dc[0].instanceId=h,Dc[0].object=this,n.push(Dc[0]),Dc.length=0)},setMatrixAt:function(e,n){n.toArray(this.instanceMatrix.array,e*16)},updateMorphTargets:function(){}});function Ri(e){Rn.call(this),this.type="LineBasicMaterial",this.color=new en(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}Ri.prototype=Object.create(Rn.prototype),Ri.prototype.constructor=Ri,Ri.prototype.isLineBasicMaterial=!0,Ri.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this};var bx=new Ee,wx=new Ee,Tx=new jn,xf=new dc,bf=new Co;function sa(e,n,i){i===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),rn.call(this),this.type="Line",this.geometry=e!==void 0?e:new yn,this.material=n!==void 0?n:new Ri}sa.prototype=Object.assign(Object.create(rn.prototype),{constructor:sa,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var n=e.attributes.position,i=[0],l=1,h=n.count;l<h;l++)bx.fromBufferAttribute(n,l-1),wx.fromBufferAttribute(n,l),i[l]=i[l-1],i[l]+=bx.distanceTo(wx);e.setAttribute("lineDistance",new sn(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry){var p=e.vertices,i=e.lineDistances;i[0]=0;for(var l=1,h=p.length;l<h;l++)i[l]=i[l-1],i[l]+=p[l-1].distanceTo(p[l])}return this},raycast:function(e,n){var i=e.linePrecision,l=this.geometry,h=this.matrixWorld;if(l.boundingSphere===null&&l.computeBoundingSphere(),bf.copy(l.boundingSphere),bf.applyMatrix4(h),bf.radius+=i,e.ray.intersectsSphere(bf)!==!1){Tx.getInverse(h),xf.copy(e.ray).applyMatrix4(Tx);var p=i/((this.scale.x+this.scale.y+this.scale.z)/3),_=p*p,s=new Ee,M=new Ee,T=new Ee,C=new Ee,E=this&&this.isLineSegments?2:1;if(l.isBufferGeometry){var L=l.index,I=l.attributes,B=I.position.array;if(L!==null)for(var O=L.array,U=0,q=O.length-1;U<q;U+=E){var ee=O[U],he=O[U+1];s.fromArray(B,ee*3),M.fromArray(B,he*3);var Ce=xf.distanceSqToSegment(s,M,C,T);if(!(Ce>_)){C.applyMatrix4(this.matrixWorld);var K=e.ray.origin.distanceTo(C);K<e.near||K>e.far||n.push({distance:K,point:T.clone().applyMatrix4(this.matrixWorld),index:U,face:null,faceIndex:null,object:this})}}else for(var U=0,q=B.length/3-1;U<q;U+=E){s.fromArray(B,3*U),M.fromArray(B,3*U+3);var Ce=xf.distanceSqToSegment(s,M,C,T);if(!(Ce>_)){C.applyMatrix4(this.matrixWorld);var K=e.ray.origin.distanceTo(C);K<e.near||K>e.far||n.push({distance:K,point:T.clone().applyMatrix4(this.matrixWorld),index:U,face:null,faceIndex:null,object:this})}}}else if(l.isGeometry)for(var ie=l.vertices,ue=ie.length,U=0;U<ue-1;U+=E){var Ce=xf.distanceSqToSegment(ie[U],ie[U+1],C,T);if(!(Ce>_)){C.applyMatrix4(this.matrixWorld);var K=e.ray.origin.distanceTo(C);K<e.near||K>e.far||n.push({distance:K,point:T.clone().applyMatrix4(this.matrixWorld),index:U,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var wf=new Ee,Mf=new Ee;function Vi(e,n){sa.call(this,e,n),this.type="LineSegments"}Vi.prototype=Object.assign(Object.create(sa.prototype),{constructor:Vi,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var n=e.attributes.position,i=[],l=0,h=n.count;l<h;l+=2)wf.fromBufferAttribute(n,l),Mf.fromBufferAttribute(n,l+1),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+wf.distanceTo(Mf);e.setAttribute("lineDistance",new sn(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(e.isGeometry)for(var p=e.vertices,i=e.lineDistances,l=0,h=p.length;l<h;l+=2)wf.copy(p[l]),Mf.copy(p[l+1]),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+wf.distanceTo(Mf);return this}});function Tf(e,n){sa.call(this,e,n),this.type="LineLoop"}Tf.prototype=Object.assign(Object.create(sa.prototype),{constructor:Tf,isLineLoop:!0});function os(e){Rn.call(this),this.type="PointsMaterial",this.color=new en(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}os.prototype=Object.create(Rn.prototype),os.prototype.constructor=os,os.prototype.isPointsMaterial=!0,os.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this};var Ex=new jn,k_=new dc,Ef=new Co,Sf=new Ee;function Af(e,n){rn.call(this),this.type="Points",this.geometry=e!==void 0?e:new yn,this.material=n!==void 0?n:new os,this.updateMorphTargets()}Af.prototype=Object.assign(Object.create(rn.prototype),{constructor:Af,isPoints:!0,raycast:function(e,n){var i=this.geometry,l=this.matrixWorld,h=e.params.Points.threshold;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ef.copy(i.boundingSphere),Ef.applyMatrix4(l),Ef.radius+=h,e.ray.intersectsSphere(Ef)!==!1){Ex.getInverse(l),k_.copy(e.ray).applyMatrix4(Ex);var p=h/((this.scale.x+this.scale.y+this.scale.z)/3),_=p*p;if(i.isBufferGeometry){var s=i.index,M=i.attributes,T=M.position.array;if(s!==null)for(var C=s.array,E=0,L=C.length;E<L;E++){var I=C[E];Sf.fromArray(T,I*3),B_(Sf,I,_,l,e,n,this)}else for(var E=0,B=T.length/3;E<B;E++)Sf.fromArray(T,E*3),B_(Sf,E,_,l,e,n,this)}else for(var O=i.vertices,E=0,B=O.length;E<B;E++)B_(O[E],E,_,l,e,n,this)}},updateMorphTargets:function(){var e=this.geometry,n,i,l;if(e.isBufferGeometry){var h=e.morphAttributes,p=Object.keys(h);if(p.length>0){var _=h[p[0]];if(_!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},n=0,i=_.length;n<i;n++)l=_[n].name||String(n),this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=n}}else{var s=e.morphTargets;s!==void 0&&s.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});function B_(e,n,i,l,h,p,_){var s=k_.distanceSqToPoint(e);if(s<i){var M=new Ee;k_.closestPointToPoint(e,M),M.applyMatrix4(l);var T=h.ray.origin.distanceTo(M);if(T<h.near||T>h.far)return;p.push({distance:T,distanceToRay:Math.sqrt(s),point:M,index:n,face:null,object:_})}}function Sx(e,n,i,l,h,p,_,s,M){mi.call(this,e,n,i,l,h,p,_,s,M),this.format=_!==void 0?_:Mo,this.minFilter=p!==void 0?p:qi,this.magFilter=h!==void 0?h:qi,this.generateMipmaps=!1}Sx.prototype=Object.assign(Object.create(mi.prototype),{constructor:Sx,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Rh(e,n,i,l,h,p,_,s,M,T,C,E){mi.call(this,null,p,_,s,M,T,l,h,C,E),this.image={width:n,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}Rh.prototype=Object.create(mi.prototype),Rh.prototype.constructor=Rh,Rh.prototype.isCompressedTexture=!0;function Cf(e,n,i,l,h,p,_,s,M){mi.call(this,e,n,i,l,h,p,_,s,M),this.needsUpdate=!0}Cf.prototype=Object.create(mi.prototype),Cf.prototype.constructor=Cf,Cf.prototype.isCanvasTexture=!0;function Pf(e,n,i,l,h,p,_,s,M,T){if(T=T!==void 0?T:tc,T!==tc&&T!==ch)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&T===tc&&(i=jp),i===void 0&&T===ch&&(i=qp),mi.call(this,null,l,h,p,_,s,T,i,M),this.image={width:e,height:n},this.magFilter=_!==void 0?_:Ui,this.minFilter=s!==void 0?s:Ui,this.flipY=!1,this.generateMipmaps=!1}Pf.prototype=Object.create(mi.prototype),Pf.prototype.constructor=Pf,Pf.prototype.isDepthTexture=!0;function Lf(e){yn.call(this),this.type="WireframeGeometry";var n=[],i,l,h,p,_,s=[0,0],M={},T,C,E,L,I=["a","b","c"],B;if(e&&e.isGeometry){var O=e.faces;for(i=0,h=O.length;i<h;i++){var U=O[i];for(l=0;l<3;l++)C=U[I[l]],E=U[I[(l+1)%3]],s[0]=Math.min(C,E),s[1]=Math.max(C,E),L=s[0]+","+s[1],M[L]===void 0&&(M[L]={index1:s[0],index2:s[1]})}for(L in M)T=M[L],B=e.vertices[T.index1],n.push(B.x,B.y,B.z),B=e.vertices[T.index2],n.push(B.x,B.y,B.z)}else if(e&&e.isBufferGeometry){var q,ee,he,Ce,K,ie,ue,ae;if(B=new Ee,e.index!==null){for(q=e.attributes.position,ee=e.index,he=e.groups,he.length===0&&(he=[{start:0,count:ee.count,materialIndex:0}]),p=0,_=he.length;p<_;++p)for(Ce=he[p],K=Ce.start,ie=Ce.count,i=K,h=K+ie;i<h;i+=3)for(l=0;l<3;l++)C=ee.getX(i+l),E=ee.getX(i+(l+1)%3),s[0]=Math.min(C,E),s[1]=Math.max(C,E),L=s[0]+","+s[1],M[L]===void 0&&(M[L]={index1:s[0],index2:s[1]});for(L in M)T=M[L],B.fromBufferAttribute(q,T.index1),n.push(B.x,B.y,B.z),B.fromBufferAttribute(q,T.index2),n.push(B.x,B.y,B.z)}else for(q=e.attributes.position,i=0,h=q.count/3;i<h;i++)for(l=0;l<3;l++)ue=3*i+l,B.fromBufferAttribute(q,ue),n.push(B.x,B.y,B.z),ae=3*i+(l+1)%3,B.fromBufferAttribute(q,ae),n.push(B.x,B.y,B.z)}this.setAttribute("position",new sn(n,3))}Lf.prototype=Object.create(yn.prototype),Lf.prototype.constructor=Lf;function Df(e,n,i){Fn.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:n,stacks:i},this.fromBufferGeometry(new zh(e,n,i)),this.mergeVertices()}Df.prototype=Object.create(Fn.prototype),Df.prototype.constructor=Df;function zh(e,n,i){yn.call(this),this.type="ParametricBufferGeometry",this.parameters={func:e,slices:n,stacks:i};var l=[],h=[],p=[],_=[],s=1e-5,M=new Ee,T=new Ee,C=new Ee,E=new Ee,L=new Ee,I,B;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var O=n+1;for(I=0;I<=i;I++){var U=I/i;for(B=0;B<=n;B++){var q=B/n;e(q,U,T),h.push(T.x,T.y,T.z),q-s>=0?(e(q-s,U,C),E.subVectors(T,C)):(e(q+s,U,C),E.subVectors(C,T)),U-s>=0?(e(q,U-s,C),L.subVectors(T,C)):(e(q,U+s,C),L.subVectors(C,T)),M.crossVectors(E,L).normalize(),p.push(M.x,M.y,M.z),_.push(q,U)}}for(I=0;I<i;I++)for(B=0;B<n;B++){var ee=I*O+B,he=I*O+B+1,Ce=(I+1)*O+B+1,K=(I+1)*O+B;l.push(ee,he,K),l.push(he,Ce,K)}this.setIndex(l),this.setAttribute("position",new sn(h,3)),this.setAttribute("normal",new sn(p,3)),this.setAttribute("uv",new sn(_,2))}zh.prototype=Object.create(yn.prototype),zh.prototype.constructor=zh;function If(e,n,i,l){Fn.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:n,radius:i,detail:l},this.fromBufferGeometry(new la(e,n,i,l)),this.mergeVertices()}If.prototype=Object.create(Fn.prototype),If.prototype.constructor=If;function la(e,n,i,l){yn.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:n,radius:i,detail:l},i=i||1,l=l||0;var h=[],p=[];_(l),M(i),T(),this.setAttribute("position",new sn(h,3)),this.setAttribute("normal",new sn(h.slice(),3)),this.setAttribute("uv",new sn(p,2)),l===0?this.computeVertexNormals():this.normalizeNormals();function _(q){for(var ee=new Ee,he=new Ee,Ce=new Ee,K=0;K<n.length;K+=3)L(n[K+0],ee),L(n[K+1],he),L(n[K+2],Ce),s(ee,he,Ce,q)}function s(q,ee,he,Ce){var K=Math.pow(2,Ce),ie=[],ue,ae;for(ue=0;ue<=K;ue++){ie[ue]=[];var le=q.clone().lerp(he,ue/K),De=ee.clone().lerp(he,ue/K),ye=K-ue;for(ae=0;ae<=ye;ae++)ae===0&&ue===K?ie[ue][ae]=le:ie[ue][ae]=le.clone().lerp(De,ae/ye)}for(ue=0;ue<K;ue++)for(ae=0;ae<2*(K-ue)-1;ae++){var se=Math.floor(ae/2);ae%2===0?(E(ie[ue][se+1]),E(ie[ue+1][se]),E(ie[ue][se])):(E(ie[ue][se+1]),E(ie[ue+1][se+1]),E(ie[ue+1][se]))}}function M(q){for(var ee=new Ee,he=0;he<h.length;he+=3)ee.x=h[he+0],ee.y=h[he+1],ee.z=h[he+2],ee.normalize().multiplyScalar(q),h[he+0]=ee.x,h[he+1]=ee.y,h[he+2]=ee.z}function T(){for(var q=new Ee,ee=0;ee<h.length;ee+=3){q.x=h[ee+0],q.y=h[ee+1],q.z=h[ee+2];var he=O(q)/2/Math.PI+.5,Ce=U(q)/Math.PI+.5;p.push(he,1-Ce)}I(),C()}function C(){for(var q=0;q<p.length;q+=6){var ee=p[q+0],he=p[q+2],Ce=p[q+4],K=Math.max(ee,he,Ce),ie=Math.min(ee,he,Ce);K>.9&&ie<.1&&(ee<.2&&(p[q+0]+=1),he<.2&&(p[q+2]+=1),Ce<.2&&(p[q+4]+=1))}}function E(q){h.push(q.x,q.y,q.z)}function L(q,ee){var he=q*3;ee.x=e[he+0],ee.y=e[he+1],ee.z=e[he+2]}function I(){for(var q=new Ee,ee=new Ee,he=new Ee,Ce=new Ee,K=new Lt,ie=new Lt,ue=new Lt,ae=0,le=0;ae<h.length;ae+=9,le+=6){q.set(h[ae+0],h[ae+1],h[ae+2]),ee.set(h[ae+3],h[ae+4],h[ae+5]),he.set(h[ae+6],h[ae+7],h[ae+8]),K.set(p[le+0],p[le+1]),ie.set(p[le+2],p[le+3]),ue.set(p[le+4],p[le+5]),Ce.copy(q).add(ee).add(he).divideScalar(3);var De=O(Ce);B(K,le+0,q,De),B(ie,le+2,ee,De),B(ue,le+4,he,De)}}function B(q,ee,he,Ce){Ce<0&&q.x===1&&(p[ee]=q.x-1),he.x===0&&he.z===0&&(p[ee]=Ce/2/Math.PI+.5)}function O(q){return Math.atan2(q.z,-q.x)}function U(q){return Math.atan2(-q.y,Math.sqrt(q.x*q.x+q.z*q.z))}}la.prototype=Object.create(yn.prototype),la.prototype.constructor=la;function Rf(e,n){Fn.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:n},this.fromBufferGeometry(new kh(e,n)),this.mergeVertices()}Rf.prototype=Object.create(Fn.prototype),Rf.prototype.constructor=Rf;function kh(e,n){var i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],l=[2,1,0,0,3,2,1,3,0,2,3,1];la.call(this,i,l,e,n),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:n}}kh.prototype=Object.create(la.prototype),kh.prototype.constructor=kh;function zf(e,n){Fn.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:n},this.fromBufferGeometry(new Ic(e,n)),this.mergeVertices()}zf.prototype=Object.create(Fn.prototype),zf.prototype.constructor=zf;function Ic(e,n){var i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],l=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];la.call(this,i,l,e,n),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:n}}Ic.prototype=Object.create(la.prototype),Ic.prototype.constructor=Ic;function kf(e,n){Fn.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:n},this.fromBufferGeometry(new Bh(e,n)),this.mergeVertices()}kf.prototype=Object.create(Fn.prototype),kf.prototype.constructor=kf;function Bh(e,n){var i=(1+Math.sqrt(5))/2,l=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],h=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];la.call(this,l,h,e,n),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:n}}Bh.prototype=Object.create(la.prototype),Bh.prototype.constructor=Bh;function Bf(e,n){Fn.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:n},this.fromBufferGeometry(new Fh(e,n)),this.mergeVertices()}Bf.prototype=Object.create(Fn.prototype),Bf.prototype.constructor=Bf;function Fh(e,n){var i=(1+Math.sqrt(5))/2,l=1/i,h=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-l,-i,0,-l,i,0,l,-i,0,l,i,-l,-i,0,-l,i,0,l,-i,0,l,i,0,-i,0,-l,i,0,-l,-i,0,l,i,0,l],p=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];la.call(this,h,p,e,n),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:n}}Fh.prototype=Object.create(la.prototype),Fh.prototype.constructor=Fh;function Ff(e,n,i,l,h,p){Fn.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:n,radius:i,radialSegments:l,closed:h},p!==void 0&&console.warn("THREE.TubeGeometry: taper has been removed.");var _=new Rc(e,n,i,l,h);this.tangents=_.tangents,this.normals=_.normals,this.binormals=_.binormals,this.fromBufferGeometry(_),this.mergeVertices()}Ff.prototype=Object.create(Fn.prototype),Ff.prototype.constructor=Ff;function Rc(e,n,i,l,h){yn.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:n,radius:i,radialSegments:l,closed:h},n=n||64,i=i||1,l=l||8,h=h||!1;var p=e.computeFrenetFrames(n,h);this.tangents=p.tangents,this.normals=p.normals,this.binormals=p.binormals;var _=new Ee,s=new Ee,M=new Lt,T=new Ee,C,E,L=[],I=[],B=[],O=[];U(),this.setIndex(O),this.setAttribute("position",new sn(L,3)),this.setAttribute("normal",new sn(I,3)),this.setAttribute("uv",new sn(B,2));function U(){for(C=0;C<n;C++)q(C);q(h===!1?n:0),he(),ee()}function q(Ce){T=e.getPointAt(Ce/n,T);var K=p.normals[Ce],ie=p.binormals[Ce];for(E=0;E<=l;E++){var ue=E/l*Math.PI*2,ae=Math.sin(ue),le=-Math.cos(ue);s.x=le*K.x+ae*ie.x,s.y=le*K.y+ae*ie.y,s.z=le*K.z+ae*ie.z,s.normalize(),I.push(s.x,s.y,s.z),_.x=T.x+i*s.x,_.y=T.y+i*s.y,_.z=T.z+i*s.z,L.push(_.x,_.y,_.z)}}function ee(){for(E=1;E<=n;E++)for(C=1;C<=l;C++){var Ce=(l+1)*(E-1)+(C-1),K=(l+1)*E+(C-1),ie=(l+1)*E+C,ue=(l+1)*(E-1)+C;O.push(Ce,K,ue),O.push(K,ie,ue)}}function he(){for(C=0;C<=n;C++)for(E=0;E<=l;E++)M.x=C/n,M.y=E/l,B.push(M.x,M.y)}}Rc.prototype=Object.create(yn.prototype),Rc.prototype.constructor=Rc,Rc.prototype.toJSON=function(){var e=yn.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e};function Of(e,n,i,l,h,p,_){Fn.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:n,tubularSegments:i,radialSegments:l,p:h,q:p},_!==void 0&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new Oh(e,n,i,l,h,p)),this.mergeVertices()}Of.prototype=Object.create(Fn.prototype),Of.prototype.constructor=Of;function Oh(e,n,i,l,h,p){yn.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:n,tubularSegments:i,radialSegments:l,p:h,q:p},e=e||1,n=n||.4,i=Math.floor(i)||64,l=Math.floor(l)||8,h=h||2,p=p||3;var _=[],s=[],M=[],T=[],C,E,L=new Ee,I=new Ee,B=new Ee,O=new Ee,U=new Ee,q=new Ee,ee=new Ee;for(C=0;C<=i;++C){var he=C/i*h*Math.PI*2;for(ye(he,h,p,e,B),ye(he+.01,h,p,e,O),q.subVectors(O,B),ee.addVectors(O,B),U.crossVectors(q,ee),ee.crossVectors(U,q),U.normalize(),ee.normalize(),E=0;E<=l;++E){var Ce=E/l*Math.PI*2,K=-n*Math.cos(Ce),ie=n*Math.sin(Ce);L.x=B.x+(K*ee.x+ie*U.x),L.y=B.y+(K*ee.y+ie*U.y),L.z=B.z+(K*ee.z+ie*U.z),s.push(L.x,L.y,L.z),I.subVectors(L,B).normalize(),M.push(I.x,I.y,I.z),T.push(C/i),T.push(E/l)}}for(E=1;E<=i;E++)for(C=1;C<=l;C++){var ue=(l+1)*(E-1)+(C-1),ae=(l+1)*E+(C-1),le=(l+1)*E+C,De=(l+1)*(E-1)+C;_.push(ue,ae,De),_.push(ae,le,De)}this.setIndex(_),this.setAttribute("position",new sn(s,3)),this.setAttribute("normal",new sn(M,3)),this.setAttribute("uv",new sn(T,2));function ye(se,Ue,Oe,We,st){var St=Math.cos(se),gt=Math.sin(se),At=Oe/Ue*se,Dt=Math.cos(At);st.x=We*(2+Dt)*.5*St,st.y=We*(2+Dt)*gt*.5,st.z=We*Math.sin(At)*.5}}Oh.prototype=Object.create(yn.prototype),Oh.prototype.constructor=Oh;function Nf(e,n,i,l,h){Fn.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:n,radialSegments:i,tubularSegments:l,arc:h},this.fromBufferGeometry(new Nh(e,n,i,l,h)),this.mergeVertices()}Nf.prototype=Object.create(Fn.prototype),Nf.prototype.constructor=Nf;function Nh(e,n,i,l,h){yn.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:n,radialSegments:i,tubularSegments:l,arc:h},e=e||1,n=n||.4,i=Math.floor(i)||8,l=Math.floor(l)||6,h=h||Math.PI*2;var p=[],_=[],s=[],M=[],T=new Ee,C=new Ee,E=new Ee,L,I;for(L=0;L<=i;L++)for(I=0;I<=l;I++){var B=I/l*h,O=L/i*Math.PI*2;C.x=(e+n*Math.cos(O))*Math.cos(B),C.y=(e+n*Math.cos(O))*Math.sin(B),C.z=n*Math.sin(O),_.push(C.x,C.y,C.z),T.x=e*Math.cos(B),T.y=e*Math.sin(B),E.subVectors(C,T).normalize(),s.push(E.x,E.y,E.z),M.push(I/l),M.push(L/i)}for(L=1;L<=i;L++)for(I=1;I<=l;I++){var U=(l+1)*L+I-1,q=(l+1)*(L-1)+I-1,ee=(l+1)*(L-1)+I,he=(l+1)*L+I;p.push(U,q,he),p.push(q,ee,he)}this.setIndex(p),this.setAttribute("position",new sn(_,3)),this.setAttribute("normal",new sn(s,3)),this.setAttribute("uv",new sn(M,2))}Nh.prototype=Object.create(yn.prototype),Nh.prototype.constructor=Nh;var MC={triangulate:function(e,n,i){i=i||2;var l=n&&n.length,h=l?n[0]*i:e.length,p=Ax(e,0,h,i,!0),_=[];if(!p||p.next===p.prev)return _;var s,M,T,C,E,L,I;if(l&&(p=CC(e,n,p,i)),e.length>80*i){s=T=e[0],M=C=e[1];for(var B=i;B<h;B+=i)E=e[B],L=e[B+1],E<s&&(s=E),L<M&&(M=L),E>T&&(T=E),L>C&&(C=L);I=Math.max(T-s,C-M),I=I!==0?1/I:0}return Vh(p,_,i,s,M,I),_}};function Ax(e,n,i,l,h){var p,_;if(h===OC(e,n,i,l)>0)for(p=n;p<i;p+=l)_=Lx(p,e[p],e[p+1],_);else for(p=i-l;p>=n;p-=l)_=Lx(p,e[p],e[p+1],_);return _&&sl(_,_.next)&&(Hh(_),_=_.next),_}function Uh(e,n){if(!e)return e;n||(n=e);var i=e,l;do if(l=!1,!i.steiner&&(sl(i,i.next)||cr(i.prev,i,i.next)===0)){if(Hh(i),i=n=i.prev,i===i.next)break;l=!0}else i=i.next;while(l||i!==n);return n}function Vh(e,n,i,l,h,p,_){if(e){!_&&p&&IC(e,l,h,p);for(var s=e,M,T;e.prev!==e.next;){if(M=e.prev,T=e.next,p?EC(e,l,h,p):TC(e)){n.push(M.i/i),n.push(e.i/i),n.push(T.i/i),Hh(e),e=T.next,s=T.next;continue}if(e=T,e===s){_?_===1?(e=SC(e,n,i),Vh(e,n,i,l,h,p,2)):_===2&&AC(e,n,i,l,h,p):Vh(Uh(e),n,i,l,h,p,1);break}}}}function TC(e){var n=e.prev,i=e,l=e.next;if(cr(n,i,l)>=0)return!1;for(var h=e.next.next;h!==e.prev;){if(zc(n.x,n.y,i.x,i.y,l.x,l.y,h.x,h.y)&&cr(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function EC(e,n,i,l){var h=e.prev,p=e,_=e.next;if(cr(h,p,_)>=0)return!1;for(var s=h.x<p.x?h.x<_.x?h.x:_.x:p.x<_.x?p.x:_.x,M=h.y<p.y?h.y<_.y?h.y:_.y:p.y<_.y?p.y:_.y,T=h.x>p.x?h.x>_.x?h.x:_.x:p.x>_.x?p.x:_.x,C=h.y>p.y?h.y>_.y?h.y:_.y:p.y>_.y?p.y:_.y,E=F_(s,M,n,i,l),L=F_(T,C,n,i,l),I=e.prevZ,B=e.nextZ;I&&I.z>=E&&B&&B.z<=L;){if(I!==e.prev&&I!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,I.x,I.y)&&cr(I.prev,I,I.next)>=0||(I=I.prevZ,B!==e.prev&&B!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,B.x,B.y)&&cr(B.prev,B,B.next)>=0))return!1;B=B.nextZ}for(;I&&I.z>=E;){if(I!==e.prev&&I!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,I.x,I.y)&&cr(I.prev,I,I.next)>=0)return!1;I=I.prevZ}for(;B&&B.z<=L;){if(B!==e.prev&&B!==e.next&&zc(h.x,h.y,p.x,p.y,_.x,_.y,B.x,B.y)&&cr(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function SC(e,n,i){var l=e;do{var h=l.prev,p=l.next.next;!sl(h,p)&&Cx(h,l,l.next,p)&&Gh(h,p)&&Gh(p,h)&&(n.push(h.i/i),n.push(l.i/i),n.push(p.i/i),Hh(l),Hh(l.next),l=e=p),l=l.next}while(l!==e);return l}function AC(e,n,i,l,h,p){var _=e;do{for(var s=_.next.next;s!==_.prev;){if(_.i!==s.i&&kC(_,s)){var M=Px(_,s);_=Uh(_,_.next),M=Uh(M,M.next),Vh(_,n,i,l,h,p),Vh(M,n,i,l,h,p);return}s=s.next}_=_.next}while(_!==e)}function CC(e,n,i,l){var h=[],p,_,s,M,T;for(p=0,_=n.length;p<_;p++)s=n[p]*l,M=p<_-1?n[p+1]*l:e.length,T=Ax(e,s,M,l,!1),T===T.next&&(T.steiner=!0),h.push(zC(T));for(h.sort(PC),p=0;p<h.length;p++)LC(h[p],i),i=Uh(i,i.next);return i}function PC(e,n){return e.x-n.x}function LC(e,n){if(n=DC(e,n),n){var i=Px(n,e);Uh(i,i.next)}}function DC(e,n){var i=n,l=e.x,h=e.y,p=-1/0,_;do{if(h<=i.y&&h>=i.next.y&&i.next.y!==i.y){var s=i.x+(h-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=l&&s>p){if(p=s,s===l){if(h===i.y)return i;if(h===i.next.y)return i.next}_=i.x<i.next.x?i:i.next}}i=i.next}while(i!==n);if(!_)return null;if(l===p)return _.prev;var M=_,T=_.x,C=_.y,E=1/0,L;for(i=_.next;i!==M;)l>=i.x&&i.x>=T&&l!==i.x&&zc(h<C?l:p,h,T,C,h<C?p:l,h,i.x,i.y)&&(L=Math.abs(h-i.y)/(l-i.x),(L<E||L===E&&i.x>_.x)&&Gh(i,e)&&(_=i,E=L)),i=i.next;return _}function IC(e,n,i,l){var h=e;do h.z===null&&(h.z=F_(h.x,h.y,n,i,l)),h.prevZ=h.prev,h.nextZ=h.next,h=h.next;while(h!==e);h.prevZ.nextZ=null,h.prevZ=null,RC(h)}function RC(e){var n,i,l,h,p,_,s,M,T=1;do{for(i=e,e=null,p=null,_=0;i;){for(_++,l=i,s=0,n=0;n<T&&(s++,l=l.nextZ,!!l);n++);for(M=T;s>0||M>0&&l;)s!==0&&(M===0||!l||i.z<=l.z)?(h=i,i=i.nextZ,s--):(h=l,l=l.nextZ,M--),p?p.nextZ=h:e=h,h.prevZ=p,p=h;i=l}p.nextZ=null,T*=2}while(_>1);return e}function F_(e,n,i,l,h){return e=32767*(e-i)*h,n=32767*(n-l)*h,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e|n<<1}function zC(e){var n=e,i=e;do(n.x<i.x||n.x===i.x&&n.y<i.y)&&(i=n),n=n.next;while(n!==e);return i}function zc(e,n,i,l,h,p,_,s){return(h-_)*(n-s)-(e-_)*(p-s)>=0&&(e-_)*(l-s)-(i-_)*(n-s)>=0&&(i-_)*(p-s)-(h-_)*(l-s)>=0}function kC(e,n){return e.next.i!==n.i&&e.prev.i!==n.i&&!BC(e,n)&&Gh(e,n)&&Gh(n,e)&&FC(e,n)}function cr(e,n,i){return(n.y-e.y)*(i.x-n.x)-(n.x-e.x)*(i.y-n.y)}function sl(e,n){return e.x===n.x&&e.y===n.y}function Cx(e,n,i,l){return sl(e,i)&&sl(n,l)||sl(e,l)&&sl(i,n)?!0:cr(e,n,i)>0!=cr(e,n,l)>0&&cr(i,l,e)>0!=cr(i,l,n)>0}function BC(e,n){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==n.i&&i.next.i!==n.i&&Cx(i,i.next,e,n))return!0;i=i.next}while(i!==e);return!1}function Gh(e,n){return cr(e.prev,e,e.next)<0?cr(e,n,e.next)>=0&&cr(e,e.prev,n)>=0:cr(e,n,e.prev)<0||cr(e,e.next,n)<0}function FC(e,n){var i=e,l=!1,h=(e.x+n.x)/2,p=(e.y+n.y)/2;do i.y>p!=i.next.y>p&&i.next.y!==i.y&&h<(i.next.x-i.x)*(p-i.y)/(i.next.y-i.y)+i.x&&(l=!l),i=i.next;while(i!==e);return l}function Px(e,n){var i=new O_(e.i,e.x,e.y),l=new O_(n.i,n.x,n.y),h=e.next,p=n.prev;return e.next=n,n.prev=e,i.next=h,h.prev=i,l.next=i,i.prev=l,p.next=l,l.prev=p,l}function Lx(e,n,i,l){var h=new O_(e,n,i);return l?(h.next=l.next,h.prev=l,l.next.prev=h,l.next=h):(h.prev=h,h.next=h),h}function Hh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function O_(e,n,i){this.i=e,this.x=n,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function OC(e,n,i,l){for(var h=0,p=n,_=i-l;p<i;p+=l)h+=(e[_]-e[p])*(e[p+1]+e[_+1]),_=p;return h}var ss={area:function(e){for(var n=e.length,i=0,l=n-1,h=0;h<n;l=h++)i+=e[l].x*e[h].y-e[h].x*e[l].y;return i*.5},isClockWise:function(e){return ss.area(e)<0},triangulateShape:function(e,n){var i=[],l=[],h=[];Dx(e),Ix(i,e);var p=e.length;n.forEach(Dx);for(var _=0;_<n.length;_++)l.push(p),p+=n[_].length,Ix(i,n[_]);for(var s=MC.triangulate(i,l),_=0;_<s.length;_+=3)h.push(s.slice(_,_+3));return h}};function Dx(e){var n=e.length;n>2&&e[n-1].equals(e[0])&&e.pop()}function Ix(e,n){for(var i=0;i<n.length;i++)e.push(n[i].x),e.push(n[i].y)}function kc(e,n){Fn.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:n},this.fromBufferGeometry(new ko(e,n)),this.mergeVertices()}kc.prototype=Object.create(Fn.prototype),kc.prototype.constructor=kc,kc.prototype.toJSON=function(){var e=Fn.prototype.toJSON.call(this),n=this.parameters.shapes,i=this.parameters.options;return Rx(n,i,e)};function ko(e,n){yn.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:n},e=Array.isArray(e)?e:[e];for(var i=this,l=[],h=[],p=0,_=e.length;p<_;p++){var s=e[p];M(s)}this.setAttribute("position",new sn(l,3)),this.setAttribute("uv",new sn(h,2)),this.computeVertexNormals();function M(T){var C=[],E=n.curveSegments!==void 0?n.curveSegments:12,L=n.steps!==void 0?n.steps:1,I=n.depth!==void 0?n.depth:100,B=n.bevelEnabled!==void 0?n.bevelEnabled:!0,O=n.bevelThickness!==void 0?n.bevelThickness:6,U=n.bevelSize!==void 0?n.bevelSize:O-2,q=n.bevelOffset!==void 0?n.bevelOffset:0,ee=n.bevelSegments!==void 0?n.bevelSegments:3,he=n.extrudePath,Ce=n.UVGenerator!==void 0?n.UVGenerator:NC;n.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),I=n.amount);var K,ie=!1,ue,ae,le,De;he&&(K=he.getSpacedPoints(L),ie=!0,B=!1,ue=he.computeFrenetFrames(L,!1),ae=new Ee,le=new Ee,De=new Ee),B||(ee=0,O=0,U=0,q=0);var ye,se,Ue,Oe=T.extractPoints(E),We=Oe.shape,st=Oe.holes,St=!ss.isClockWise(We);if(St)for(We=We.reverse(),se=0,Ue=st.length;se<Ue;se++)ye=st[se],ss.isClockWise(ye)&&(st[se]=ye.reverse());var gt=ss.triangulateShape(We,st),At=We;for(se=0,Ue=st.length;se<Ue;se++)ye=st[se],We=We.concat(ye);function Dt(Gt,on,Zt){return on||console.error("THREE.ExtrudeGeometry: vec does not exist"),on.clone().multiplyScalar(Zt).add(Gt)}var Ot,Pe,ge,Ve,Ne,Ie=We.length,it,ce=gt.length;function we(Gt,on,Zt){var qe,Nt,Qt,Pn=Gt.x-on.x,pn=Gt.y-on.y,On=Zt.x-Gt.x,Gn=Zt.y-Gt.y,Zn=Pn*Pn+pn*pn,Wi=Pn*Gn-pn*On;if(Math.abs(Wi)>Number.EPSILON){var Nn=Math.sqrt(Zn),Ci=Math.sqrt(On*On+Gn*Gn),ei=on.x-pn/Nn,Ki=on.y+Pn/Nn,yi=Zt.x-Gn/Ci,Hr=Zt.y+On/Ci,ki=((yi-ei)*Gn-(Hr-Ki)*On)/(Pn*Gn-pn*On);qe=ei+Pn*ki-Gt.x,Nt=Ki+pn*ki-Gt.y;var Wr=qe*qe+Nt*Nt;if(Wr<=2)return new Lt(qe,Nt);Qt=Math.sqrt(Wr/2)}else{var Sr=!1;Pn>Number.EPSILON?On>Number.EPSILON&&(Sr=!0):Pn<-Number.EPSILON?On<-Number.EPSILON&&(Sr=!0):Math.sign(pn)===Math.sign(Gn)&&(Sr=!0),Sr?(qe=-pn,Nt=Pn,Qt=Math.sqrt(Zn)):(qe=Pn,Nt=pn,Qt=Math.sqrt(Zn/2))}return new Lt(qe/Qt,Nt/Qt)}for(var Me=[],pe=0,Be=At.length,$e=Be-1,ot=pe+1;pe<Be;pe++,$e++,ot++)$e===Be&&($e=0),ot===Be&&(ot=0),Me[pe]=we(At[pe],At[$e],At[ot]);var bt=[],Vt,oe=Me.concat();for(se=0,Ue=st.length;se<Ue;se++){for(ye=st[se],Vt=[],pe=0,Be=ye.length,$e=Be-1,ot=pe+1;pe<Be;pe++,$e++,ot++)$e===Be&&($e=0),ot===Be&&(ot=0),Vt[pe]=we(ye[pe],ye[$e],ye[ot]);bt.push(Vt),oe=oe.concat(Vt)}for(Ot=0;Ot<ee;Ot++){for(ge=Ot/ee,Ve=O*Math.cos(ge*Math.PI/2),Pe=U*Math.sin(ge*Math.PI/2)+q,pe=0,Be=At.length;pe<Be;pe++)Ne=Dt(At[pe],Me[pe],Pe),un(Ne.x,Ne.y,-Ve);for(se=0,Ue=st.length;se<Ue;se++)for(ye=st[se],Vt=bt[se],pe=0,Be=ye.length;pe<Be;pe++)Ne=Dt(ye[pe],Vt[pe],Pe),un(Ne.x,Ne.y,-Ve)}for(Pe=U+q,pe=0;pe<Ie;pe++)Ne=B?Dt(We[pe],oe[pe],Pe):We[pe],ie?(le.copy(ue.normals[0]).multiplyScalar(Ne.x),ae.copy(ue.binormals[0]).multiplyScalar(Ne.y),De.copy(K[0]).add(le).add(ae),un(De.x,De.y,De.z)):un(Ne.x,Ne.y,0);var ve;for(ve=1;ve<=L;ve++)for(pe=0;pe<Ie;pe++)Ne=B?Dt(We[pe],oe[pe],Pe):We[pe],ie?(le.copy(ue.normals[ve]).multiplyScalar(Ne.x),ae.copy(ue.binormals[ve]).multiplyScalar(Ne.y),De.copy(K[ve]).add(le).add(ae),un(De.x,De.y,De.z)):un(Ne.x,Ne.y,I/L*ve);for(Ot=ee-1;Ot>=0;Ot--){for(ge=Ot/ee,Ve=O*Math.cos(ge*Math.PI/2),Pe=U*Math.sin(ge*Math.PI/2)+q,pe=0,Be=At.length;pe<Be;pe++)Ne=Dt(At[pe],Me[pe],Pe),un(Ne.x,Ne.y,I+Ve);for(se=0,Ue=st.length;se<Ue;se++)for(ye=st[se],Vt=bt[se],pe=0,Be=ye.length;pe<Be;pe++)Ne=Dt(ye[pe],Vt[pe],Pe),ie?un(Ne.x,Ne.y+K[L-1].y,K[L-1].x+Ve):un(Ne.x,Ne.y,I+Ve)}xt(),mt();function xt(){var Gt=l.length/3;if(B){var on=0,Zt=Ie*on;for(pe=0;pe<ce;pe++)it=gt[pe],tn(it[2]+Zt,it[1]+Zt,it[0]+Zt);for(on=L+ee*2,Zt=Ie*on,pe=0;pe<ce;pe++)it=gt[pe],tn(it[0]+Zt,it[1]+Zt,it[2]+Zt)}else{for(pe=0;pe<ce;pe++)it=gt[pe],tn(it[2],it[1],it[0]);for(pe=0;pe<ce;pe++)it=gt[pe],tn(it[0]+Ie*L,it[1]+Ie*L,it[2]+Ie*L)}i.addGroup(Gt,l.length/3-Gt,0)}function mt(){var Gt=l.length/3,on=0;for(xn(At,on),on+=At.length,se=0,Ue=st.length;se<Ue;se++)ye=st[se],xn(ye,on),on+=ye.length;i.addGroup(Gt,l.length/3-Gt,1)}function xn(Gt,on){var Zt,qe;for(pe=Gt.length;--pe>=0;){Zt=pe,qe=pe-1,qe<0&&(qe=Gt.length-1);var Nt=0,Qt=L+ee*2;for(Nt=0;Nt<Qt;Nt++){var Pn=Ie*Nt,pn=Ie*(Nt+1),On=on+Zt+Pn,Gn=on+qe+Pn,Zn=on+qe+pn,Wi=on+Zt+pn;dn(On,Gn,Zn,Wi)}}}function un(Gt,on,Zt){C.push(Gt),C.push(on),C.push(Zt)}function tn(Gt,on,Zt){bn(Gt),bn(on),bn(Zt);var qe=l.length/3,Nt=Ce.generateTopUV(i,l,qe-3,qe-2,qe-1);ln(Nt[0]),ln(Nt[1]),ln(Nt[2])}function dn(Gt,on,Zt,qe){bn(Gt),bn(on),bn(qe),bn(on),bn(Zt),bn(qe);var Nt=l.length/3,Qt=Ce.generateSideWallUV(i,l,Nt-6,Nt-3,Nt-2,Nt-1);ln(Qt[0]),ln(Qt[1]),ln(Qt[3]),ln(Qt[1]),ln(Qt[2]),ln(Qt[3])}function bn(Gt){l.push(C[Gt*3+0]),l.push(C[Gt*3+1]),l.push(C[Gt*3+2])}function ln(Gt){h.push(Gt.x),h.push(Gt.y)}}}ko.prototype=Object.create(yn.prototype),ko.prototype.constructor=ko,ko.prototype.toJSON=function(){var e=yn.prototype.toJSON.call(this),n=this.parameters.shapes,i=this.parameters.options;return Rx(n,i,e)};var NC={generateTopUV:function(e,n,i,l,h){var p=n[i*3],_=n[i*3+1],s=n[l*3],M=n[l*3+1],T=n[h*3],C=n[h*3+1];return[new Lt(p,_),new Lt(s,M),new Lt(T,C)]},generateSideWallUV:function(e,n,i,l,h,p){var _=n[i*3],s=n[i*3+1],M=n[i*3+2],T=n[l*3],C=n[l*3+1],E=n[l*3+2],L=n[h*3],I=n[h*3+1],B=n[h*3+2],O=n[p*3],U=n[p*3+1],q=n[p*3+2];return Math.abs(s-C)<.01?[new Lt(_,1-M),new Lt(T,1-E),new Lt(L,1-B),new Lt(O,1-q)]:[new Lt(s,1-M),new Lt(C,1-E),new Lt(I,1-B),new Lt(U,1-q)]}};function Rx(e,n,i){if(i.shapes=[],Array.isArray(e))for(var l=0,h=e.length;l<h;l++){var p=e[l];i.shapes.push(p.uuid)}else i.shapes.push(e.uuid);return n.extrudePath!==void 0&&(i.options.extrudePath=n.extrudePath.toJSON()),i}function Uf(e,n){Fn.call(this),this.type="TextGeometry",this.parameters={text:e,parameters:n},this.fromBufferGeometry(new Wh(e,n)),this.mergeVertices()}Uf.prototype=Object.create(Fn.prototype),Uf.prototype.constructor=Uf;function Wh(e,n){n=n||{};var i=n.font;if(!(i&&i.isFont))return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Fn;var l=i.generateShapes(e,n.size);n.depth=n.height!==void 0?n.height:50,n.bevelThickness===void 0&&(n.bevelThickness=10),n.bevelSize===void 0&&(n.bevelSize=8),n.bevelEnabled===void 0&&(n.bevelEnabled=!1),ko.call(this,l,n),this.type="TextBufferGeometry"}Wh.prototype=Object.create(ko.prototype),Wh.prototype.constructor=Wh;function Vf(e,n,i,l,h,p,_){Fn.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:n,heightSegments:i,phiStart:l,phiLength:h,thetaStart:p,thetaLength:_},this.fromBufferGeometry(new Bc(e,n,i,l,h,p,_)),this.mergeVertices()}Vf.prototype=Object.create(Fn.prototype),Vf.prototype.constructor=Vf;function Bc(e,n,i,l,h,p,_){yn.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:n,heightSegments:i,phiStart:l,phiLength:h,thetaStart:p,thetaLength:_},e=e||1,n=Math.max(3,Math.floor(n)||8),i=Math.max(2,Math.floor(i)||6),l=l!==void 0?l:0,h=h!==void 0?h:Math.PI*2,p=p!==void 0?p:0,_=_!==void 0?_:Math.PI;var s=Math.min(p+_,Math.PI),M,T,C=0,E=[],L=new Ee,I=new Ee,B=[],O=[],U=[],q=[];for(T=0;T<=i;T++){var ee=[],he=T/i,Ce=0;for(T==0&&p==0?Ce=.5/n:T==i&&s==Math.PI&&(Ce=-.5/n),M=0;M<=n;M++){var K=M/n;L.x=-e*Math.cos(l+K*h)*Math.sin(p+he*_),L.y=e*Math.cos(p+he*_),L.z=e*Math.sin(l+K*h)*Math.sin(p+he*_),O.push(L.x,L.y,L.z),I.copy(L).normalize(),U.push(I.x,I.y,I.z),q.push(K+Ce,1-he),ee.push(C++)}E.push(ee)}for(T=0;T<i;T++)for(M=0;M<n;M++){var ie=E[T][M+1],ue=E[T][M],ae=E[T+1][M],le=E[T+1][M+1];(T!==0||p>0)&&B.push(ie,ue,le),(T!==i-1||s<Math.PI)&&B.push(ue,ae,le)}this.setIndex(B),this.setAttribute("position",new sn(O,3)),this.setAttribute("normal",new sn(U,3)),this.setAttribute("uv",new sn(q,2))}Bc.prototype=Object.create(yn.prototype),Bc.prototype.constructor=Bc;function Gf(e,n,i,l,h,p){Fn.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:n,thetaSegments:i,phiSegments:l,thetaStart:h,thetaLength:p},this.fromBufferGeometry(new jh(e,n,i,l,h,p)),this.mergeVertices()}Gf.prototype=Object.create(Fn.prototype),Gf.prototype.constructor=Gf;function jh(e,n,i,l,h,p){yn.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:n,thetaSegments:i,phiSegments:l,thetaStart:h,thetaLength:p},e=e||.5,n=n||1,h=h!==void 0?h:0,p=p!==void 0?p:Math.PI*2,i=i!==void 0?Math.max(3,i):8,l=l!==void 0?Math.max(1,l):1;var _=[],s=[],M=[],T=[],C,E=e,L=(n-e)/l,I=new Ee,B=new Lt,O,U;for(O=0;O<=l;O++){for(U=0;U<=i;U++)C=h+U/i*p,I.x=E*Math.cos(C),I.y=E*Math.sin(C),s.push(I.x,I.y,I.z),M.push(0,0,1),B.x=(I.x/n+1)/2,B.y=(I.y/n+1)/2,T.push(B.x,B.y);E+=L}for(O=0;O<l;O++){var q=O*(i+1);for(U=0;U<i;U++){C=U+q;var ee=C,he=C+i+1,Ce=C+i+2,K=C+1;_.push(ee,he,K),_.push(he,Ce,K)}}this.setIndex(_),this.setAttribute("position",new sn(s,3)),this.setAttribute("normal",new sn(M,3)),this.setAttribute("uv",new sn(T,2))}jh.prototype=Object.create(yn.prototype),jh.prototype.constructor=jh;function Hf(e,n,i,l){Fn.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:n,phiStart:i,phiLength:l},this.fromBufferGeometry(new qh(e,n,i,l)),this.mergeVertices()}Hf.prototype=Object.create(Fn.prototype),Hf.prototype.constructor=Hf;function qh(e,n,i,l){yn.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:n,phiStart:i,phiLength:l},n=Math.floor(n)||12,i=i||0,l=l||Math.PI*2,l=Wn.clamp(l,0,Math.PI*2);var h=[],p=[],_=[],s,M=1/n,T=new Ee,C=new Lt,E,L;for(E=0;E<=n;E++){var I=i+E*M*l,B=Math.sin(I),O=Math.cos(I);for(L=0;L<=e.length-1;L++)T.x=e[L].x*B,T.y=e[L].y,T.z=e[L].x*O,p.push(T.x,T.y,T.z),C.x=E/n,C.y=L/(e.length-1),_.push(C.x,C.y)}for(E=0;E<n;E++)for(L=0;L<e.length-1;L++){s=L+E*e.length;var U=s,q=s+e.length,ee=s+e.length+1,he=s+1;h.push(U,q,he),h.push(q,ee,he)}if(this.setIndex(h),this.setAttribute("position",new sn(p,3)),this.setAttribute("uv",new sn(_,2)),this.computeVertexNormals(),l===Math.PI*2){var Ce=this.attributes.normal.array,K=new Ee,ie=new Ee,ue=new Ee;for(s=n*e.length*3,E=0,L=0;E<e.length;E++,L+=3)K.x=Ce[L+0],K.y=Ce[L+1],K.z=Ce[L+2],ie.x=Ce[s+L+0],ie.y=Ce[s+L+1],ie.z=Ce[s+L+2],ue.addVectors(K,ie).normalize(),Ce[L+0]=Ce[s+L+0]=ue.x,Ce[L+1]=Ce[s+L+1]=ue.y,Ce[L+2]=Ce[s+L+2]=ue.z}}qh.prototype=Object.create(yn.prototype),qh.prototype.constructor=qh;function Fc(e,n){Fn.call(this),this.type="ShapeGeometry",typeof n=="object"&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),n=n.curveSegments),this.parameters={shapes:e,curveSegments:n},this.fromBufferGeometry(new Oc(e,n)),this.mergeVertices()}Fc.prototype=Object.create(Fn.prototype),Fc.prototype.constructor=Fc,Fc.prototype.toJSON=function(){var e=Fn.prototype.toJSON.call(this),n=this.parameters.shapes;return zx(n,e)};function Oc(e,n){yn.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:n},n=n||12;var i=[],l=[],h=[],p=[],_=0,s=0;if(Array.isArray(e)===!1)T(e);else for(var M=0;M<e.length;M++)T(e[M]),this.addGroup(_,s,M),_+=s,s=0;this.setIndex(i),this.setAttribute("position",new sn(l,3)),this.setAttribute("normal",new sn(h,3)),this.setAttribute("uv",new sn(p,2));function T(C){var E,L,I,B=l.length/3,O=C.extractPoints(n),U=O.shape,q=O.holes;for(ss.isClockWise(U)===!1&&(U=U.reverse()),E=0,L=q.length;E<L;E++)I=q[E],ss.isClockWise(I)===!0&&(q[E]=I.reverse());var ee=ss.triangulateShape(U,q);for(E=0,L=q.length;E<L;E++)I=q[E],U=U.concat(I);for(E=0,L=U.length;E<L;E++){var he=U[E];l.push(he.x,he.y,0),h.push(0,0,1),p.push(he.x,he.y)}for(E=0,L=ee.length;E<L;E++){var Ce=ee[E],K=Ce[0]+B,ie=Ce[1]+B,ue=Ce[2]+B;i.push(K,ie,ue),s+=3}}}Oc.prototype=Object.create(yn.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var e=yn.prototype.toJSON.call(this),n=this.parameters.shapes;return zx(n,e)};function zx(e,n){if(n.shapes=[],Array.isArray(e))for(var i=0,l=e.length;i<l;i++){var h=e[i];n.shapes.push(h.uuid)}else n.shapes.push(e.uuid);return n}function Wf(e,n){yn.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:n},n=n!==void 0?n:1;var i=[],l=Math.cos(Wn.DEG2RAD*n),h=[0,0],p={},_,s,M,T=["a","b","c"],C;e.isBufferGeometry?(C=new Fn,C.fromBufferGeometry(e)):C=e.clone(),C.mergeVertices(),C.computeFaceNormals();for(var E=C.vertices,L=C.faces,I=0,B=L.length;I<B;I++)for(var O=L[I],U=0;U<3;U++)_=O[T[U]],s=O[T[(U+1)%3]],h[0]=Math.min(_,s),h[1]=Math.max(_,s),M=h[0]+","+h[1],p[M]===void 0?p[M]={index1:h[0],index2:h[1],face1:I,face2:void 0}:p[M].face2=I;for(M in p){var q=p[M];if(q.face2===void 0||L[q.face1].normal.dot(L[q.face2].normal)<=l){var ee=E[q.index1];i.push(ee.x,ee.y,ee.z),ee=E[q.index2],i.push(ee.x,ee.y,ee.z)}}this.setAttribute("position",new sn(i,3))}Wf.prototype=Object.create(yn.prototype),Wf.prototype.constructor=Wf;function Nc(e,n,i,l,h,p,_,s){Fn.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:n,height:i,radialSegments:l,heightSegments:h,openEnded:p,thetaStart:_,thetaLength:s},this.fromBufferGeometry(new ls(e,n,i,l,h,p,_,s)),this.mergeVertices()}Nc.prototype=Object.create(Fn.prototype),Nc.prototype.constructor=Nc;function ls(e,n,i,l,h,p,_,s){yn.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:n,height:i,radialSegments:l,heightSegments:h,openEnded:p,thetaStart:_,thetaLength:s};var M=this;e=e!==void 0?e:1,n=n!==void 0?n:1,i=i||1,l=Math.floor(l)||8,h=Math.floor(h)||1,p=p!==void 0?p:!1,_=_!==void 0?_:0,s=s!==void 0?s:Math.PI*2;var T=[],C=[],E=[],L=[],I=0,B=[],O=i/2,U=0;q(),p===!1&&(e>0&&ee(!0),n>0&&ee(!1)),this.setIndex(T),this.setAttribute("position",new sn(C,3)),this.setAttribute("normal",new sn(E,3)),this.setAttribute("uv",new sn(L,2));function q(){var he,Ce,K=new Ee,ie=new Ee,ue=0,ae=(n-e)/i;for(Ce=0;Ce<=h;Ce++){var le=[],De=Ce/h,ye=De*(n-e)+e;for(he=0;he<=l;he++){var se=he/l,Ue=se*s+_,Oe=Math.sin(Ue),We=Math.cos(Ue);ie.x=ye*Oe,ie.y=-De*i+O,ie.z=ye*We,C.push(ie.x,ie.y,ie.z),K.set(Oe,ae,We).normalize(),E.push(K.x,K.y,K.z),L.push(se,1-De),le.push(I++)}B.push(le)}for(he=0;he<l;he++)for(Ce=0;Ce<h;Ce++){var st=B[Ce][he],St=B[Ce+1][he],gt=B[Ce+1][he+1],At=B[Ce][he+1];T.push(st,St,At),T.push(St,gt,At),ue+=6}M.addGroup(U,ue,0),U+=ue}function ee(he){var Ce,K,ie,ue=new Lt,ae=new Ee,le=0,De=he===!0?e:n,ye=he===!0?1:-1;for(K=I,Ce=1;Ce<=l;Ce++)C.push(0,O*ye,0),E.push(0,ye,0),L.push(.5,.5),I++;for(ie=I,Ce=0;Ce<=l;Ce++){var se=Ce/l,Ue=se*s+_,Oe=Math.cos(Ue),We=Math.sin(Ue);ae.x=De*We,ae.y=O*ye,ae.z=De*Oe,C.push(ae.x,ae.y,ae.z),E.push(0,ye,0),ue.x=Oe*.5+.5,ue.y=We*.5*ye+.5,L.push(ue.x,ue.y),I++}for(Ce=0;Ce<l;Ce++){var st=K+Ce,St=ie+Ce;he===!0?T.push(St,St+1,st):T.push(St+1,St,st),le+=3}M.addGroup(U,le,he===!0?1:2),U+=le}}ls.prototype=Object.create(yn.prototype),ls.prototype.constructor=ls;function jf(e,n,i,l,h,p,_){Nc.call(this,0,e,n,i,l,h,p,_),this.type="ConeGeometry",this.parameters={radius:e,height:n,radialSegments:i,heightSegments:l,openEnded:h,thetaStart:p,thetaLength:_}}jf.prototype=Object.create(Nc.prototype),jf.prototype.constructor=jf;function qf(e,n,i,l,h,p,_){ls.call(this,0,e,n,i,l,h,p,_),this.type="ConeBufferGeometry",this.parameters={radius:e,height:n,radialSegments:i,heightSegments:l,openEnded:h,thetaStart:p,thetaLength:_}}qf.prototype=Object.create(ls.prototype),qf.prototype.constructor=qf;function Zf(e,n,i,l){Fn.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:n,thetaStart:i,thetaLength:l},this.fromBufferGeometry(new Zh(e,n,i,l)),this.mergeVertices()}Zf.prototype=Object.create(Fn.prototype),Zf.prototype.constructor=Zf;function Zh(e,n,i,l){yn.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:n,thetaStart:i,thetaLength:l},e=e||1,n=n!==void 0?Math.max(3,n):8,i=i!==void 0?i:0,l=l!==void 0?l:Math.PI*2;var h=[],p=[],_=[],s=[],M,T,C=new Ee,E=new Lt;for(p.push(0,0,0),_.push(0,0,1),s.push(.5,.5),T=0,M=3;T<=n;T++,M+=3){var L=i+T/n*l;C.x=e*Math.cos(L),C.y=e*Math.sin(L),p.push(C.x,C.y,C.z),_.push(0,0,1),E.x=(p[M]/e+1)/2,E.y=(p[M+1]/e+1)/2,s.push(E.x,E.y)}for(M=1;M<=n;M++)h.push(M,M+1,0);this.setIndex(h),this.setAttribute("position",new sn(p,3)),this.setAttribute("normal",new sn(_,3)),this.setAttribute("uv",new sn(s,2))}Zh.prototype=Object.create(yn.prototype),Zh.prototype.constructor=Zh;var Tr=Object.freeze({__proto__:null,WireframeGeometry:Lf,ParametricGeometry:Df,ParametricBufferGeometry:zh,TetrahedronGeometry:Rf,TetrahedronBufferGeometry:kh,OctahedronGeometry:zf,OctahedronBufferGeometry:Ic,IcosahedronGeometry:kf,IcosahedronBufferGeometry:Bh,DodecahedronGeometry:Bf,DodecahedronBufferGeometry:Fh,PolyhedronGeometry:If,PolyhedronBufferGeometry:la,TubeGeometry:Ff,TubeBufferGeometry:Rc,TorusKnotGeometry:Of,TorusKnotBufferGeometry:Oh,TorusGeometry:Nf,TorusBufferGeometry:Nh,TextGeometry:Uf,TextBufferGeometry:Wh,SphereGeometry:Vf,SphereBufferGeometry:Bc,RingGeometry:Gf,RingBufferGeometry:jh,PlaneGeometry:pf,PlaneBufferGeometry:Ec,LatheGeometry:Hf,LatheBufferGeometry:qh,ShapeGeometry:Fc,ShapeBufferGeometry:Oc,ExtrudeGeometry:kc,ExtrudeBufferGeometry:ko,EdgesGeometry:Wf,ConeGeometry:jf,ConeBufferGeometry:qf,CylinderGeometry:Nc,CylinderBufferGeometry:ls,CircleGeometry:Zf,CircleBufferGeometry:Zh,BoxGeometry:C2,BoxBufferGeometry:hf});function Uc(e){Rn.call(this),this.type="ShadowMaterial",this.color=new en(0),this.transparent=!0,this.setValues(e)}Uc.prototype=Object.create(Rn.prototype),Uc.prototype.constructor=Uc,Uc.prototype.isShadowMaterial=!0,Uc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this};function cs(e){Nr.call(this,e),this.type="RawShaderMaterial"}cs.prototype=Object.create(Nr.prototype),cs.prototype.constructor=cs,cs.prototype.isRawShaderMaterial=!0;function Ur(e){Rn.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new en(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new en(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Ur.prototype=Object.create(Rn.prototype),Ur.prototype.constructor=Ur,Ur.prototype.isMeshStandardMaterial=!0,Ur.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Vc(e){Ur.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new Lt(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(e)}Vc.prototype=Object.create(Ur.prototype),Vc.prototype.constructor=Vc,Vc.prototype.isMeshPhysicalMaterial=!0,Vc.prototype.copy=function(e){return Ur.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearcoat=e.clearcoat,this.clearcoatRoughness=e.clearcoatRoughness,e.sheen?this.sheen=(this.sheen||new en).copy(e.sheen):this.sheen=null,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.transparency=e.transparency,this};function ll(e){Rn.call(this),this.type="MeshPhongMaterial",this.color=new en(16777215),this.specular=new en(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new en(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Up,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}ll.prototype=Object.create(Rn.prototype),ll.prototype.constructor=ll,ll.prototype.isMeshPhongMaterial=!0,ll.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Gc(e){Rn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new en(16777215),this.specular=new en(1118481),this.shininess=30,this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new en(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Gc.prototype=Object.create(Rn.prototype),Gc.prototype.constructor=Gc,Gc.prototype.isMeshToonMaterial=!0,Gc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Hc(e){Rn.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Hc.prototype=Object.create(Rn.prototype),Hc.prototype.constructor=Hc,Hc.prototype.isMeshNormalMaterial=!0,Hc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Wc(e){Rn.call(this),this.type="MeshLambertMaterial",this.color=new en(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new en(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Up,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Wc.prototype=Object.create(Rn.prototype),Wc.prototype.constructor=Wc,Wc.prototype.isMeshLambertMaterial=!0,Wc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function jc(e){Rn.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new en(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}jc.prototype=Object.create(Rn.prototype),jc.prototype.constructor=jc,jc.prototype.isMeshMatcapMaterial=!0,jc.prototype.copy=function(e){return Rn.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function qc(e){Ri.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}qc.prototype=Object.create(Ri.prototype),qc.prototype.constructor=qc,qc.prototype.isLineDashedMaterial=!0,qc.prototype.copy=function(e){return Ri.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var UC=Object.freeze({__proto__:null,ShadowMaterial:Uc,SpriteMaterial:ol,RawShaderMaterial:cs,ShaderMaterial:Nr,PointsMaterial:os,MeshPhysicalMaterial:Vc,MeshStandardMaterial:Ur,MeshPhongMaterial:ll,MeshToonMaterial:Gc,MeshNormalMaterial:Hc,MeshLambertMaterial:Wc,MeshDepthMaterial:nl,MeshDistanceMaterial:il,MeshBasicMaterial:lr,MeshMatcapMaterial:jc,LineDashedMaterial:qc,LineBasicMaterial:Ri,Material:Rn}),Gi={arraySlice:function(e,n,i){return Gi.isTypedArray(e)?new e.constructor(e.subarray(n,i!==void 0?i:e.length)):e.slice(n,i)},convertArray:function(e,n,i){return!e||!i&&e.constructor===n?e:typeof n.BYTES_PER_ELEMENT=="number"?new n(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function n(p,_){return e[p]-e[_]}for(var i=e.length,l=new Array(i),h=0;h!==i;++h)l[h]=h;return l.sort(n),l},sortedArray:function(e,n,i){for(var l=e.length,h=new e.constructor(l),p=0,_=0;_!==l;++p)for(var s=i[p]*n,M=0;M!==n;++M)h[_++]=e[s+M];return h},flattenJSON:function(e,n,i,l){for(var h=1,p=e[0];p!==void 0&&p[l]===void 0;)p=e[h++];if(p!==void 0){var _=p[l];if(_!==void 0)if(Array.isArray(_))do _=p[l],_!==void 0&&(n.push(p.time),i.push.apply(i,_)),p=e[h++];while(p!==void 0);else if(_.toArray!==void 0)do _=p[l],_!==void 0&&(n.push(p.time),_.toArray(i,i.length)),p=e[h++];while(p!==void 0);else do _=p[l],_!==void 0&&(n.push(p.time),i.push(_)),p=e[h++];while(p!==void 0)}},subclip:function(e,n,i,l,h){h=h||30;var p=e.clone();p.name=n;for(var _=[],s=0;s<p.tracks.length;++s){for(var M=p.tracks[s],T=M.getValueSize(),C=[],E=[],L=0;L<M.times.length;++L){var I=M.times[L]*h;if(!(I<i||I>=l)){C.push(M.times[L]);for(var B=0;B<T;++B)E.push(M.values[L*T+B])}}C.length!==0&&(M.times=Gi.convertArray(C,M.times.constructor),M.values=Gi.convertArray(E,M.values.constructor),_.push(M))}p.tracks=_;for(var O=1/0,s=0;s<p.tracks.length;++s)O>p.tracks[s].times[0]&&(O=p.tracks[s].times[0]);for(var s=0;s<p.tracks.length;++s)p.tracks[s].shift(-1*O);return p.resetDuration(),p}};function Vr(e,n,i,l){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=l!==void 0?l:new n.constructor(i),this.sampleValues=n,this.valueSize=i}Object.assign(Vr.prototype,{evaluate:function(e){var n=this.parameterPositions,i=this._cachedIndex,l=n[i],h=n[i-1];e:{t:{var p;n:{i:if(!(e<l)){for(var _=i+2;;){if(l===void 0){if(e<h)break i;return i=n.length,this._cachedIndex=i,this.afterEnd_(i-1,e,h)}if(i===_)break;if(h=l,l=n[++i],e<l)break t}p=n.length;break n}if(!(e>=h)){var s=n[1];e<s&&(i=2,h=s);for(var _=i-2;;){if(h===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,l);if(i===_)break;if(l=h,h=n[--i-1],e>=h)break t}p=i,i=0;break n}break e}for(;i<p;){var M=i+p>>>1;e<n[M]?p=M:i=M+1}if(l=n[i],h=n[i-1],h===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,l);if(l===void 0)return i=n.length,this._cachedIndex=i,this.afterEnd_(i-1,h,e)}this._cachedIndex=i,this.intervalChanged_(i,h,l)}return this.interpolate_(i,h,e,l)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){for(var n=this.resultBuffer,i=this.sampleValues,l=this.valueSize,h=e*l,p=0;p!==l;++p)n[p]=i[h+p];return n},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}});//!\ DECLARE ALIAS AFTER assign prototype !
  2706. Object.assign(Vr.prototype,{beforeStart_:Vr.prototype.copySampleValue_,afterEnd_:Vr.prototype.copySampleValue_});function N_(e,n,i,l){Vr.call(this,e,n,i,l),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}N_.prototype=Object.assign(Object.create(Vr.prototype),{constructor:N_,DefaultSettings_:{endingStart:ic,endingEnd:ic},intervalChanged_:function(e,n,i){var l=this.parameterPositions,h=e-2,p=e+1,_=l[h],s=l[p];if(_===void 0)switch(this.getSettings_().endingStart){case rc:h=e,_=2*n-i;break;case Zp:h=l.length-2,_=n+l[h]-l[h+1];break;default:h=e,_=i}if(s===void 0)switch(this.getSettings_().endingEnd){case rc:p=e,s=2*i-n;break;case Zp:p=1,s=i+l[1]-l[0];break;default:p=e-1,s=n}var M=(i-n)*.5,T=this.valueSize;this._weightPrev=M/(n-_),this._weightNext=M/(s-i),this._offsetPrev=h*T,this._offsetNext=p*T},interpolate_:function(e,n,i,l){for(var h=this.resultBuffer,p=this.sampleValues,_=this.valueSize,s=e*_,M=s-_,T=this._offsetPrev,C=this._offsetNext,E=this._weightPrev,L=this._weightNext,I=(i-n)/(l-n),B=I*I,O=B*I,U=-E*O+2*E*B-E*I,q=(1+E)*O+(-1.5-2*E)*B+(-.5+E)*I+1,ee=(-1-L)*O+(1.5+L)*B+.5*I,he=L*O-L*B,Ce=0;Ce!==_;++Ce)h[Ce]=U*p[T+Ce]+q*p[M+Ce]+ee*p[s+Ce]+he*p[C+Ce];return h}});function Xf(e,n,i,l){Vr.call(this,e,n,i,l)}Xf.prototype=Object.assign(Object.create(Vr.prototype),{constructor:Xf,interpolate_:function(e,n,i,l){for(var h=this.resultBuffer,p=this.sampleValues,_=this.valueSize,s=e*_,M=s-_,T=(i-n)/(l-n),C=1-T,E=0;E!==_;++E)h[E]=p[M+E]*C+p[s+E]*T;return h}});function U_(e,n,i,l){Vr.call(this,e,n,i,l)}U_.prototype=Object.assign(Object.create(Vr.prototype),{constructor:U_,interpolate_:function(e){return this.copySampleValue_(e-1)}});function fr(e,n,i,l){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(n===void 0||n.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Gi.convertArray(n,this.TimeBufferType),this.values=Gi.convertArray(i,this.ValueBufferType),this.setInterpolation(l||this.DefaultInterpolation)}Object.assign(fr,{toJSON:function(e){var n=e.constructor,i;if(n.toJSON!==void 0)i=n.toJSON(e);else{i={name:e.name,times:Gi.convertArray(e.times,Array),values:Gi.convertArray(e.values,Array)};var l=e.getInterpolation();l!==e.DefaultInterpolation&&(i.interpolation=l)}return i.type=e.ValueTypeName,i}}),Object.assign(fr.prototype,{constructor:fr,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:nc,InterpolantFactoryMethodDiscrete:function(e){return new U_(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new Xf(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new N_(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var n;switch(e){case uh:n=this.InterpolantFactoryMethodDiscrete;break;case nc:n=this.InterpolantFactoryMethodLinear;break;case Jg:n=this.InterpolantFactoryMethodSmooth;break}if(n===void 0){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=n,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return uh;case this.InterpolantFactoryMethodLinear:return nc;case this.InterpolantFactoryMethodSmooth:return Jg}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(e!==0)for(var n=this.times,i=0,l=n.length;i!==l;++i)n[i]+=e;return this},scale:function(e){if(e!==1)for(var n=this.times,i=0,l=n.length;i!==l;++i)n[i]*=e;return this},trim:function(e,n){for(var i=this.times,l=i.length,h=0,p=l-1;h!==l&&i[h]<e;)++h;for(;p!==-1&&i[p]>n;)--p;if(++p,h!==0||p!==l){h>=p&&(p=Math.max(p,1),h=p-1);var _=this.getValueSize();this.times=Gi.arraySlice(i,h,p),this.values=Gi.arraySlice(this.values,h*_,p*_)}return this},validate:function(){var e=!0,n=this.getValueSize();n-Math.floor(n)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var i=this.times,l=this.values,h=i.length;h===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var p=null,_=0;_!==h;_++){var s=i[_];if(typeof s=="number"&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,_,s),e=!1;break}if(p!==null&&p>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,_,s,p),e=!1;break}p=s}if(l!==void 0&&Gi.isTypedArray(l))for(var _=0,M=l.length;_!==M;++_){var T=l[_];if(isNaN(T)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,_,T),e=!1;break}}return e},optimize:function(){for(var e=Gi.arraySlice(this.times),n=Gi.arraySlice(this.values),i=this.getValueSize(),l=this.getInterpolation()===Jg,h=1,p=e.length-1,_=1;_<p;++_){var s=!1,M=e[_],T=e[_+1];if(M!==T&&(_!==1||M!==M[0]))if(l)s=!0;else for(var C=_*i,E=C-i,L=C+i,I=0;I!==i;++I){var B=n[C+I];if(B!==n[E+I]||B!==n[L+I]){s=!0;break}}if(s){if(_!==h){e[h]=e[_];for(var O=_*i,U=h*i,I=0;I!==i;++I)n[U+I]=n[O+I]}++h}}if(p>0){e[h]=e[p];for(var O=p*i,U=h*i,I=0;I!==i;++I)n[U+I]=n[O+I];++h}return h!==e.length?(this.times=Gi.arraySlice(e,0,h),this.values=Gi.arraySlice(n,0,h*i)):(this.times=e,this.values=n),this},clone:function(){var e=Gi.arraySlice(this.times,0),n=Gi.arraySlice(this.values,0),i=this.constructor,l=new i(this.name,e,n);return l.createInterpolant=this.createInterpolant,l}});function V_(e,n,i){fr.call(this,e,n,i)}V_.prototype=Object.assign(Object.create(fr.prototype),{constructor:V_,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:uh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function G_(e,n,i,l){fr.call(this,e,n,i,l)}G_.prototype=Object.assign(Object.create(fr.prototype),{constructor:G_,ValueTypeName:"color"});function Zc(e,n,i,l){fr.call(this,e,n,i,l)}Zc.prototype=Object.assign(Object.create(fr.prototype),{constructor:Zc,ValueTypeName:"number"});function H_(e,n,i,l){Vr.call(this,e,n,i,l)}H_.prototype=Object.assign(Object.create(Vr.prototype),{constructor:H_,interpolate_:function(e,n,i,l){for(var h=this.resultBuffer,p=this.sampleValues,_=this.valueSize,s=e*_,M=(i-n)/(l-n),T=s+_;s!==T;s+=4)Or.slerpFlat(h,0,p,s-_,p,s,M);return h}});function Xh(e,n,i,l){fr.call(this,e,n,i,l)}Xh.prototype=Object.assign(Object.create(fr.prototype),{constructor:Xh,ValueTypeName:"quaternion",DefaultInterpolation:nc,InterpolantFactoryMethodLinear:function(e){return new H_(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0});function W_(e,n,i,l){fr.call(this,e,n,i,l)}W_.prototype=Object.assign(Object.create(fr.prototype),{constructor:W_,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:uh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Xc(e,n,i,l){fr.call(this,e,n,i,l)}Xc.prototype=Object.assign(Object.create(fr.prototype),{constructor:Xc,ValueTypeName:"vector"});function va(e,n,i){this.name=e,this.tracks=i,this.duration=n!==void 0?n:-1,this.uuid=Wn.generateUUID(),this.duration<0&&this.resetDuration()}function VC(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Zc;case"vector":case"vector2":case"vector3":case"vector4":return Xc;case"color":return G_;case"quaternion":return Xh;case"bool":case"boolean":return V_;case"string":return W_}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function GC(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var n=VC(e.type);if(e.times===void 0){var i=[],l=[];Gi.flattenJSON(e.keys,i,l,"value"),e.times=i,e.values=l}return n.parse!==void 0?n.parse(e):new n(e.name,e.times,e.values,e.interpolation)}Object.assign(va,{parse:function(e){for(var n=[],i=e.tracks,l=1/(e.fps||1),h=0,p=i.length;h!==p;++h)n.push(GC(i[h]).scale(l));return new va(e.name,e.duration,n)},toJSON:function(e){for(var n=[],i=e.tracks,l={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid},h=0,p=i.length;h!==p;++h)n.push(fr.toJSON(i[h]));return l},CreateFromMorphTargetSequence:function(e,n,i,l){for(var h=n.length,p=[],_=0;_<h;_++){var s=[],M=[];s.push((_+h-1)%h,_,(_+1)%h),M.push(0,1,0);var T=Gi.getKeyframeOrder(s);s=Gi.sortedArray(s,1,T),M=Gi.sortedArray(M,1,T),!l&&s[0]===0&&(s.push(h),M.push(M[0])),p.push(new Zc(".morphTargetInfluences["+n[_].name+"]",s,M).scale(1/i))}return new va(e,-1,p)},findByName:function(e,n){var i=e;if(!Array.isArray(e)){var l=e;i=l.geometry&&l.geometry.animations||l.animations}for(var h=0;h<i.length;h++)if(i[h].name===n)return i[h];return null},CreateClipsFromMorphTargetSequences:function(e,n,i){for(var l={},h=/^([\w-]*?)([\d]+)$/,p=0,_=e.length;p<_;p++){var s=e[p],M=s.name.match(h);if(M&&M.length>1){var T=M[1],C=l[T];C||(l[T]=C=[]),C.push(s)}}var E=[];for(var T in l)E.push(va.CreateFromMorphTargetSequence(T,l[T],n,i));return E},parseAnimation:function(e,n){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(he,Ce,K,ie,ue){if(K.length!==0){var ae=[],le=[];Gi.flattenJSON(K,ae,le,ie),ae.length!==0&&ue.push(new he(Ce,ae,le))}},l=[],h=e.name||"default",p=e.length||-1,_=e.fps||30,s=e.hierarchy||[],M=0;M<s.length;M++){var T=s[M].keys;if(!(!T||T.length===0))if(T[0].morphTargets){for(var C={},E=0;E<T.length;E++)if(T[E].morphTargets)for(var L=0;L<T[E].morphTargets.length;L++)C[T[E].morphTargets[L]]=-1;for(var I in C){for(var B=[],O=[],L=0;L!==T[E].morphTargets.length;++L){var U=T[E];B.push(U.time),O.push(U.morphTarget===I?1:0)}l.push(new Zc(".morphTargetInfluence["+I+"]",B,O))}p=C.length*(_||1)}else{var q=".bones["+n[M].name+"]";i(Xc,q+".position",T,"pos",l),i(Xh,q+".quaternion",T,"rot",l),i(Xc,q+".scale",T,"scl",l)}}if(l.length===0)return null;var ee=new va(h,p,l);return ee}}),Object.assign(va.prototype,{resetDuration:function(){for(var e=this.tracks,n=0,i=0,l=e.length;i!==l;++i){var h=this.tracks[i];n=Math.max(n,h.times[h.times.length-1])}return this.duration=n,this},trim:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){for(var e=!0,n=0;n<this.tracks.length;n++)e=e&&this.tracks[n].validate();return e},optimize:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){for(var e=[],n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());return new va(this.name,this.duration,e)}});var Yc={enabled:!1,files:{},add:function(e,n){this.enabled!==!1&&(this.files[e]=n)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function kx(e,n,i){var l=this,h=!1,p=0,_=0,s=void 0,M=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=i,this.itemStart=function(T){_++,h===!1&&l.onStart!==void 0&&l.onStart(T,p,_),h=!0},this.itemEnd=function(T){p++,l.onProgress!==void 0&&l.onProgress(T,p,_),p===_&&(h=!1,l.onLoad!==void 0&&l.onLoad())},this.itemError=function(T){l.onError!==void 0&&l.onError(T)},this.resolveURL=function(T){return s?s(T):T},this.setURLModifier=function(T){return s=T,this},this.addHandler=function(T,C){return M.push(T,C),this},this.removeHandler=function(T){var C=M.indexOf(T);return C!==-1&&M.splice(C,2),this},this.getHandler=function(T){for(var C=0,E=M.length;C<E;C+=2){var L=M[C],I=M[C+1];if(L.global&&(L.lastIndex=0),L.test(T))return I}return null}}var HC=new kx;function ri(e){this.manager=e!==void 0?e:HC,this.crossOrigin="anonymous",this.path="",this.resourcePath=""}Object.assign(ri.prototype,{load:function(){},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this}});var Ia={};function xa(e){ri.call(this,e)}xa.prototype=Object.assign(Object.create(ri.prototype),{constructor:xa,load:function(e,n,i,l){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);var h=this,p=Yc.get(e);if(p!==void 0)return h.manager.itemStart(e),setTimeout(function(){n&&n(p),h.manager.itemEnd(e)},0),p;if(Ia[e]!==void 0){Ia[e].push({onLoad:n,onProgress:i,onError:l});return}var _=/^data:(.*?)(;base64)?,(.*)$/,s=e.match(_);if(s){var M=s[1],T=!!s[2],C=s[3];C=decodeURIComponent(C),T&&(C=atob(C));try{var E,L=(this.responseType||"").toLowerCase();switch(L){case"arraybuffer":case"blob":for(var I=new Uint8Array(C.length),B=0;B<C.length;B++)I[B]=C.charCodeAt(B);L==="blob"?E=new Blob([I.buffer],{type:M}):E=I.buffer;break;case"document":var O=new DOMParser;E=O.parseFromString(C,M);break;case"json":E=JSON.parse(C);break;default:E=C;break}setTimeout(function(){n&&n(E),h.manager.itemEnd(e)},0)}catch(ee){setTimeout(function(){l&&l(ee),h.manager.itemError(e),h.manager.itemEnd(e)},0)}}else{Ia[e]=[],Ia[e].push({onLoad:n,onProgress:i,onError:l});var U=new XMLHttpRequest;U.open("GET",e,!0),U.addEventListener("load",function(ee){var he=this.response,Ce=Ia[e];if(delete Ia[e],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Yc.add(e,he);for(var K=0,ie=Ce.length;K<ie;K++){var ue=Ce[K];ue.onLoad&&ue.onLoad(he)}h.manager.itemEnd(e)}else{for(var K=0,ie=Ce.length;K<ie;K++){var ue=Ce[K];ue.onError&&ue.onError(ee)}h.manager.itemError(e),h.manager.itemEnd(e)}},!1),U.addEventListener("progress",function(ee){for(var he=Ia[e],Ce=0,K=he.length;Ce<K;Ce++){var ie=he[Ce];ie.onProgress&&ie.onProgress(ee)}},!1),U.addEventListener("error",function(ee){var he=Ia[e];delete Ia[e];for(var Ce=0,K=he.length;Ce<K;Ce++){var ie=he[Ce];ie.onError&&ie.onError(ee)}h.manager.itemError(e),h.manager.itemEnd(e)},!1),U.addEventListener("abort",function(ee){var he=Ia[e];delete Ia[e];for(var Ce=0,K=he.length;Ce<K;Ce++){var ie=he[Ce];ie.onError&&ie.onError(ee)}h.manager.itemError(e),h.manager.itemEnd(e)},!1),this.responseType!==void 0&&(U.responseType=this.responseType),this.withCredentials!==void 0&&(U.withCredentials=this.withCredentials),U.overrideMimeType&&U.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(var q in this.requestHeader)U.setRequestHeader(q,this.requestHeader[q]);U.send(null)}return h.manager.itemStart(e),U},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}});function Bx(e){ri.call(this,e)}Bx.prototype=Object.assign(Object.create(ri.prototype),{constructor:Bx,load:function(e,n,i,l){var h=this,p=new xa(h.manager);p.setPath(h.path),p.load(e,function(_){n(h.parse(JSON.parse(_)))},i,l)},parse:function(e){for(var n=[],i=0;i<e.length;i++){var l=va.parse(e[i]);n.push(l)}return n}});function Fx(e){ri.call(this,e)}Fx.prototype=Object.assign(Object.create(ri.prototype),{constructor:Fx,load:function(e,n,i,l){var h=this,p=[],_=new Rh;_.image=p;var s=new xa(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer");function M(L){s.load(e[L],function(I){var B=h.parse(I,!0);p[L]={width:B.width,height:B.height,format:B.format,mipmaps:B.mipmaps},T+=1,T===6&&(B.mipmapCount===1&&(_.minFilter=qi),_.format=B.format,_.needsUpdate=!0,n&&n(_))},i,l)}if(Array.isArray(e))for(var T=0,C=0,E=e.length;C<E;++C)M(C);else s.load(e,function(L){var I=h.parse(L,!0);if(I.isCubemap)for(var B=I.mipmaps.length/I.mipmapCount,O=0;O<B;O++){p[O]={mipmaps:[]};for(var U=0;U<I.mipmapCount;U++)p[O].mipmaps.push(I.mipmaps[O*I.mipmapCount+U]),p[O].format=I.format,p[O].width=I.width,p[O].height=I.height}else _.image.width=I.width,_.image.height=I.height,_.mipmaps=I.mipmaps;I.mipmapCount===1&&(_.minFilter=qi),_.format=I.format,_.needsUpdate=!0,n&&n(_)},i,l);return _}});function Ox(e){ri.call(this,e)}Ox.prototype=Object.assign(Object.create(ri.prototype),{constructor:Ox,load:function(e,n,i,l){var h=this,p=new Mc,_=new xa(this.manager);return _.setResponseType("arraybuffer"),_.setPath(this.path),_.load(e,function(s){var M=h.parse(s);M&&(M.image!==void 0?p.image=M.image:M.data!==void 0&&(p.image.width=M.width,p.image.height=M.height,p.image.data=M.data),p.wrapS=M.wrapS!==void 0?M.wrapS:wr,p.wrapT=M.wrapT!==void 0?M.wrapT:wr,p.magFilter=M.magFilter!==void 0?M.magFilter:qi,p.minFilter=M.minFilter!==void 0?M.minFilter:qi,p.anisotropy=M.anisotropy!==void 0?M.anisotropy:1,M.format!==void 0&&(p.format=M.format),M.type!==void 0&&(p.type=M.type),M.mipmaps!==void 0&&(p.mipmaps=M.mipmaps,p.minFilter=ec),M.mipmapCount===1&&(p.minFilter=qi),p.needsUpdate=!0,n&&n(p,M))},i,l),p}});function Yh(e){ri.call(this,e)}Yh.prototype=Object.assign(Object.create(ri.prototype),{constructor:Yh,load:function(e,n,i,l){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);var h=this,p=Yc.get(e);if(p!==void 0)return h.manager.itemStart(e),setTimeout(function(){n&&n(p),h.manager.itemEnd(e)},0),p;var _=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){_.removeEventListener("load",s,!1),_.removeEventListener("error",M,!1),Yc.add(e,this),n&&n(this),h.manager.itemEnd(e)}function M(T){_.removeEventListener("load",s,!1),_.removeEventListener("error",M,!1),l&&l(T),h.manager.itemError(e),h.manager.itemEnd(e)}return _.addEventListener("load",s,!1),_.addEventListener("error",M,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(_.crossOrigin=this.crossOrigin),h.manager.itemStart(e),_.src=e,_}});function j_(e){ri.call(this,e)}j_.prototype=Object.assign(Object.create(ri.prototype),{constructor:j_,load:function(e,n,i,l){var h=new rs,p=new Yh(this.manager);p.setCrossOrigin(this.crossOrigin),p.setPath(this.path);var _=0;function s(T){p.load(e[T],function(C){h.images[T]=C,_++,_===6&&(h.needsUpdate=!0,n&&n(h))},void 0,l)}for(var M=0;M<e.length;++M)s(M);return h}});function $h(e){ri.call(this,e)}$h.prototype=Object.assign(Object.create(ri.prototype),{constructor:$h,load:function(e,n,i,l){var h=new mi,p=new Yh(this.manager);return p.setCrossOrigin(this.crossOrigin),p.setPath(this.path),p.load(e,function(_){h.image=_;var s=e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0;h.format=s?Mo:Aa,h.needsUpdate=!0,n!==void 0&&n(h)},i,l),h}});function Cn(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(Cn.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,n){var i=this.getUtoTmapping(e);return this.getPoint(i,n)},getPoints:function(e){e===void 0&&(e=5);for(var n=[],i=0;i<=e;i++)n.push(this.getPoint(i/e));return n},getSpacedPoints:function(e){e===void 0&&(e=5);for(var n=[],i=0;i<=e;i++)n.push(this.getPointAt(i/e));return n},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e===void 0&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n=[],i,l=this.getPoint(0),h,p=0;for(n.push(0),h=1;h<=e;h++)i=this.getPoint(h/e),p+=i.distanceTo(l),n.push(p),l=i;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,n){var i=this.getLengths(),l=0,h=i.length,p;n?p=n:p=e*i[h-1];for(var _=0,s=h-1,M;_<=s;)if(l=Math.floor(_+(s-_)/2),M=i[l]-p,M<0)_=l+1;else if(M>0)s=l-1;else{s=l;break}if(l=s,i[l]===p)return l/(h-1);var T=i[l],C=i[l+1],E=C-T,L=(p-T)/E,I=(l+L)/(h-1);return I},getTangent:function(e){var n=1e-4,i=e-n,l=e+n;i<0&&(i=0),l>1&&(l=1);var h=this.getPoint(i),p=this.getPoint(l),_=p.clone().sub(h);return _.normalize()},getTangentAt:function(e){var n=this.getUtoTmapping(e);return this.getTangent(n)},computeFrenetFrames:function(e,n){var i=new Ee,l=[],h=[],p=[],_=new Ee,s=new jn,M,T,C;for(M=0;M<=e;M++)T=M/e,l[M]=this.getTangentAt(T),l[M].normalize();h[0]=new Ee,p[0]=new Ee;var E=Number.MAX_VALUE,L=Math.abs(l[0].x),I=Math.abs(l[0].y),B=Math.abs(l[0].z);for(L<=E&&(E=L,i.set(1,0,0)),I<=E&&(E=I,i.set(0,1,0)),B<=E&&i.set(0,0,1),_.crossVectors(l[0],i).normalize(),h[0].crossVectors(l[0],_),p[0].crossVectors(l[0],h[0]),M=1;M<=e;M++)h[M]=h[M-1].clone(),p[M]=p[M-1].clone(),_.crossVectors(l[M-1],l[M]),_.length()>Number.EPSILON&&(_.normalize(),C=Math.acos(Wn.clamp(l[M-1].dot(l[M]),-1,1)),h[M].applyMatrix4(s.makeRotationAxis(_,C))),p[M].crossVectors(l[M],h[M]);if(n===!0)for(C=Math.acos(Wn.clamp(h[0].dot(h[e]),-1,1)),C/=e,l[0].dot(_.crossVectors(h[0],h[e]))>0&&(C=-C),M=1;M<=e;M++)h[M].applyMatrix4(s.makeRotationAxis(l[M],C*M)),p[M].crossVectors(l[M],h[M]);return{tangents:l,normals:h,binormals:p}},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}});function ba(e,n,i,l,h,p,_,s){Cn.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=n||0,this.xRadius=i||1,this.yRadius=l||1,this.aStartAngle=h||0,this.aEndAngle=p||2*Math.PI,this.aClockwise=_||!1,this.aRotation=s||0}ba.prototype=Object.create(Cn.prototype),ba.prototype.constructor=ba,ba.prototype.isEllipseCurve=!0,ba.prototype.getPoint=function(e,n){for(var i=n||new Lt,l=Math.PI*2,h=this.aEndAngle-this.aStartAngle,p=Math.abs(h)<Number.EPSILON;h<0;)h+=l;for(;h>l;)h-=l;h<Number.EPSILON&&(p?h=0:h=l),this.aClockwise===!0&&!p&&(h===l?h=-l:h=h-l);var _=this.aStartAngle+e*h,s=this.aX+this.xRadius*Math.cos(_),M=this.aY+this.yRadius*Math.sin(_);if(this.aRotation!==0){var T=Math.cos(this.aRotation),C=Math.sin(this.aRotation),E=s-this.aX,L=M-this.aY;s=E*T-L*C+this.aX,M=E*C+L*T+this.aY}return i.set(s,M)},ba.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},ba.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},ba.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this};function Jh(e,n,i,l,h,p){ba.call(this,e,n,i,i,l,h,p),this.type="ArcCurve"}Jh.prototype=Object.create(ba.prototype),Jh.prototype.constructor=Jh,Jh.prototype.isArcCurve=!0;function q_(){var e=0,n=0,i=0,l=0;function h(p,_,s,M){e=p,n=s,i=-3*p+3*_-2*s-M,l=2*p-2*_+s+M}return{initCatmullRom:function(p,_,s,M,T){h(_,s,T*(s-p),T*(M-_))},initNonuniformCatmullRom:function(p,_,s,M,T,C,E){var L=(_-p)/T-(s-p)/(T+C)+(s-_)/C,I=(s-_)/C-(M-_)/(C+E)+(M-s)/E;L*=C,I*=C,h(_,s,L,I)},calc:function(p){var _=p*p,s=_*p;return e+n*p+i*_+l*s}}}var Yf=new Ee,Z_=new q_,X_=new q_,Y_=new q_;function ca(e,n,i,l){Cn.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=n||!1,this.curveType=i||"centripetal",this.tension=l||.5}ca.prototype=Object.create(Cn.prototype),ca.prototype.constructor=ca,ca.prototype.isCatmullRomCurve3=!0,ca.prototype.getPoint=function(e,n){var i=n||new Ee,l=this.points,h=l.length,p=(h-(this.closed?0:1))*e,_=Math.floor(p),s=p-_;this.closed?_+=_>0?0:(Math.floor(Math.abs(_)/h)+1)*h:s===0&&_===h-1&&(_=h-2,s=1);var M,T,C,E;if(this.closed||_>0?M=l[(_-1)%h]:(Yf.subVectors(l[0],l[1]).add(l[0]),M=Yf),T=l[_%h],C=l[(_+1)%h],this.closed||_+2<h?E=l[(_+2)%h]:(Yf.subVectors(l[h-1],l[h-2]).add(l[h-1]),E=Yf),this.curveType==="centripetal"||this.curveType==="chordal"){var L=this.curveType==="chordal"?.5:.25,I=Math.pow(M.distanceToSquared(T),L),B=Math.pow(T.distanceToSquared(C),L),O=Math.pow(C.distanceToSquared(E),L);B<1e-4&&(B=1),I<1e-4&&(I=B),O<1e-4&&(O=B),Z_.initNonuniformCatmullRom(M.x,T.x,C.x,E.x,I,B,O),X_.initNonuniformCatmullRom(M.y,T.y,C.y,E.y,I,B,O),Y_.initNonuniformCatmullRom(M.z,T.z,C.z,E.z,I,B,O)}else this.curveType==="catmullrom"&&(Z_.initCatmullRom(M.x,T.x,C.x,E.x,this.tension),X_.initCatmullRom(M.y,T.y,C.y,E.y,this.tension),Y_.initCatmullRom(M.z,T.z,C.z,E.z,this.tension));return i.set(Z_.calc(s),X_.calc(s),Y_.calc(s)),i},ca.prototype.copy=function(e){Cn.prototype.copy.call(this,e),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var l=e.points[n];this.points.push(l.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},ca.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);e.points=[];for(var n=0,i=this.points.length;n<i;n++){var l=this.points[n];e.points.push(l.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},ca.prototype.fromJSON=function(e){Cn.prototype.fromJSON.call(this,e),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var l=e.points[n];this.points.push(new Ee().fromArray(l))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this};function Nx(e,n,i,l,h){var p=(l-n)*.5,_=(h-i)*.5,s=e*e,M=e*s;return(2*i-2*l+p+_)*M+(-3*i+3*l-2*p-_)*s+p*e+i}function WC(e,n){var i=1-e;return i*i*n}function jC(e,n){return 2*(1-e)*e*n}function qC(e,n){return e*e*n}function Kh(e,n,i,l){return WC(e,n)+jC(e,i)+qC(e,l)}function ZC(e,n){var i=1-e;return i*i*i*n}function XC(e,n){var i=1-e;return 3*i*i*e*n}function YC(e,n){return 3*(1-e)*e*e*n}function $C(e,n){return e*e*e*n}function Qh(e,n,i,l,h){return ZC(e,n)+XC(e,i)+YC(e,l)+$C(e,h)}function Xa(e,n,i,l){Cn.call(this),this.type="CubicBezierCurve",this.v0=e||new Lt,this.v1=n||new Lt,this.v2=i||new Lt,this.v3=l||new Lt}Xa.prototype=Object.create(Cn.prototype),Xa.prototype.constructor=Xa,Xa.prototype.isCubicBezierCurve=!0,Xa.prototype.getPoint=function(e,n){var i=n||new Lt,l=this.v0,h=this.v1,p=this.v2,_=this.v3;return i.set(Qh(e,l.x,h.x,p.x,_.x),Qh(e,l.y,h.y,p.y,_.y)),i},Xa.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Xa.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Xa.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this};function Bo(e,n,i,l){Cn.call(this),this.type="CubicBezierCurve3",this.v0=e||new Ee,this.v1=n||new Ee,this.v2=i||new Ee,this.v3=l||new Ee}Bo.prototype=Object.create(Cn.prototype),Bo.prototype.constructor=Bo,Bo.prototype.isCubicBezierCurve3=!0,Bo.prototype.getPoint=function(e,n){var i=n||new Ee,l=this.v0,h=this.v1,p=this.v2,_=this.v3;return i.set(Qh(e,l.x,h.x,p.x,_.x),Qh(e,l.y,h.y,p.y,_.y),Qh(e,l.z,h.z,p.z,_.z)),i},Bo.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Bo.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Bo.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this};function ua(e,n){Cn.call(this),this.type="LineCurve",this.v1=e||new Lt,this.v2=n||new Lt}ua.prototype=Object.create(Cn.prototype),ua.prototype.constructor=ua,ua.prototype.isLineCurve=!0,ua.prototype.getPoint=function(e,n){var i=n||new Lt;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},ua.prototype.getPointAt=function(e,n){return this.getPoint(e,n)},ua.prototype.getTangent=function(){var e=this.v2.clone().sub(this.v1);return e.normalize()},ua.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},ua.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},ua.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Ya(e,n){Cn.call(this),this.type="LineCurve3",this.v1=e||new Ee,this.v2=n||new Ee}Ya.prototype=Object.create(Cn.prototype),Ya.prototype.constructor=Ya,Ya.prototype.isLineCurve3=!0,Ya.prototype.getPoint=function(e,n){var i=n||new Ee;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},Ya.prototype.getPointAt=function(e,n){return this.getPoint(e,n)},Ya.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ya.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Ya.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function $a(e,n,i){Cn.call(this),this.type="QuadraticBezierCurve",this.v0=e||new Lt,this.v1=n||new Lt,this.v2=i||new Lt}$a.prototype=Object.create(Cn.prototype),$a.prototype.constructor=$a,$a.prototype.isQuadraticBezierCurve=!0,$a.prototype.getPoint=function(e,n){var i=n||new Lt,l=this.v0,h=this.v1,p=this.v2;return i.set(Kh(e,l.x,h.x,p.x),Kh(e,l.y,h.y,p.y)),i},$a.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},$a.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},$a.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Fo(e,n,i){Cn.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new Ee,this.v1=n||new Ee,this.v2=i||new Ee}Fo.prototype=Object.create(Cn.prototype),Fo.prototype.constructor=Fo,Fo.prototype.isQuadraticBezierCurve3=!0,Fo.prototype.getPoint=function(e,n){var i=n||new Ee,l=this.v0,h=this.v1,p=this.v2;return i.set(Kh(e,l.x,h.x,p.x),Kh(e,l.y,h.y,p.y),Kh(e,l.z,h.z,p.z)),i},Fo.prototype.copy=function(e){return Cn.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Fo.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Fo.prototype.fromJSON=function(e){return Cn.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function Ja(e){Cn.call(this),this.type="SplineCurve",this.points=e||[]}Ja.prototype=Object.create(Cn.prototype),Ja.prototype.constructor=Ja,Ja.prototype.isSplineCurve=!0,Ja.prototype.getPoint=function(e,n){var i=n||new Lt,l=this.points,h=(l.length-1)*e,p=Math.floor(h),_=h-p,s=l[p===0?p:p-1],M=l[p],T=l[p>l.length-2?l.length-1:p+1],C=l[p>l.length-3?l.length-1:p+2];return i.set(Nx(_,s.x,M.x,T.x,C.x),Nx(_,s.y,M.y,T.y,C.y)),i},Ja.prototype.copy=function(e){Cn.prototype.copy.call(this,e),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var l=e.points[n];this.points.push(l.clone())}return this},Ja.prototype.toJSON=function(){var e=Cn.prototype.toJSON.call(this);e.points=[];for(var n=0,i=this.points.length;n<i;n++){var l=this.points[n];e.points.push(l.toArray())}return e},Ja.prototype.fromJSON=function(e){Cn.prototype.fromJSON.call(this,e),this.points=[];for(var n=0,i=e.points.length;n<i;n++){var l=e.points[n];this.points.push(new Lt().fromArray(l))}return this};var $_=Object.freeze({__proto__:null,ArcCurve:Jh,CatmullRomCurve3:ca,CubicBezierCurve:Xa,CubicBezierCurve3:Bo,EllipseCurve:ba,LineCurve:ua,LineCurve3:Ya,QuadraticBezierCurve:$a,QuadraticBezierCurve3:Fo,SplineCurve:Ja});function us(){Cn.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}us.prototype=Object.assign(Object.create(Cn.prototype),{constructor:us,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),n=this.curves[this.curves.length-1].getPoint(1);e.equals(n)||this.curves.push(new ua(n,e))},getPoint:function(e){for(var n=e*this.getLength(),i=this.getCurveLengths(),l=0;l<i.length;){if(i[l]>=n){var h=i[l]-n,p=this.curves[l],_=p.getLength(),s=_===0?0:1-h/_;return p.getPointAt(s)}l++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],n=0,i=0,l=this.curves.length;i<l;i++)n+=this.curves[i].getLength(),e.push(n);return this.cacheLengths=e,e},getSpacedPoints:function(e){e===void 0&&(e=40);for(var n=[],i=0;i<=e;i++)n.push(this.getPoint(i/e));return this.autoClose&&n.push(n[0]),n},getPoints:function(e){e=e||12;for(var n=[],i,l=0,h=this.curves;l<h.length;l++)for(var p=h[l],_=p&&p.isEllipseCurve?e*2:p&&(p.isLineCurve||p.isLineCurve3)?1:p&&p.isSplineCurve?e*p.points.length:e,s=p.getPoints(_),M=0;M<s.length;M++){var T=s[M];i&&i.equals(T)||(n.push(T),i=T)}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){Cn.prototype.copy.call(this,e),this.curves=[];for(var n=0,i=e.curves.length;n<i;n++){var l=e.curves[n];this.curves.push(l.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){var e=Cn.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(var n=0,i=this.curves.length;n<i;n++){var l=this.curves[n];e.curves.push(l.toJSON())}return e},fromJSON:function(e){Cn.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(var n=0,i=e.curves.length;n<i;n++){var l=e.curves[n];this.curves.push(new $_[l.type]().fromJSON(l))}return this}});function Ka(e){us.call(this),this.type="Path",this.currentPoint=new Lt,e&&this.setFromPoints(e)}Ka.prototype=Object.assign(Object.create(us.prototype),{constructor:Ka,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(var n=1,i=e.length;n<i;n++)this.lineTo(e[n].x,e[n].y);return this},moveTo:function(e,n){return this.currentPoint.set(e,n),this},lineTo:function(e,n){var i=new ua(this.currentPoint.clone(),new Lt(e,n));return this.curves.push(i),this.currentPoint.set(e,n),this},quadraticCurveTo:function(e,n,i,l){var h=new $a(this.currentPoint.clone(),new Lt(e,n),new Lt(i,l));return this.curves.push(h),this.currentPoint.set(i,l),this},bezierCurveTo:function(e,n,i,l,h,p){var _=new Xa(this.currentPoint.clone(),new Lt(e,n),new Lt(i,l),new Lt(h,p));return this.curves.push(_),this.currentPoint.set(h,p),this},splineThru:function(e){var n=[this.currentPoint.clone()].concat(e),i=new Ja(n);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,n,i,l,h,p){var _=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+_,n+s,i,l,h,p),this},absarc:function(e,n,i,l,h,p){return this.absellipse(e,n,i,i,l,h,p),this},ellipse:function(e,n,i,l,h,p,_,s){var M=this.currentPoint.x,T=this.currentPoint.y;return this.absellipse(e+M,n+T,i,l,h,p,_,s),this},absellipse:function(e,n,i,l,h,p,_,s){var M=new ba(e,n,i,l,h,p,_,s);if(this.curves.length>0){var T=M.getPoint(0);T.equals(this.currentPoint)||this.lineTo(T.x,T.y)}this.curves.push(M);var C=M.getPoint(1);return this.currentPoint.copy(C),this},copy:function(e){return us.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=us.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return us.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}});function cl(e){Ka.call(this,e),this.uuid=Wn.generateUUID(),this.type="Shape",this.holes=[]}cl.prototype=Object.assign(Object.create(Ka.prototype),{constructor:cl,getPointsHoles:function(e){for(var n=[],i=0,l=this.holes.length;i<l;i++)n[i]=this.holes[i].getPoints(e);return n},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){Ka.prototype.copy.call(this,e),this.holes=[];for(var n=0,i=e.holes.length;n<i;n++){var l=e.holes[n];this.holes.push(l.clone())}return this},toJSON:function(){var e=Ka.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(var n=0,i=this.holes.length;n<i;n++){var l=this.holes[n];e.holes.push(l.toJSON())}return e},fromJSON:function(e){Ka.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(var n=0,i=e.holes.length;n<i;n++){var l=e.holes[n];this.holes.push(new Ka().fromJSON(l))}return this}});function Mi(e,n){rn.call(this),this.type="Light",this.color=new en(e),this.intensity=n!==void 0?n:1,this.receiveShadow=void 0}Mi.prototype=Object.assign(Object.create(rn.prototype),{constructor:Mi,isLight:!0,copy:function(e){return rn.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var n=rn.prototype.toJSON.call(this,e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}});function J_(e,n,i){Mi.call(this,e,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(rn.DefaultUp),this.updateMatrix(),this.groundColor=new en(n)}J_.prototype=Object.assign(Object.create(Mi.prototype),{constructor:J_,isHemisphereLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}});function Oo(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new Lt(512,512),this.map=null,this.mapPass=null,this.matrix=new jn,this._frustum=new wh,this._frameExtents=new Lt(1,1),this._viewportCount=1,this._viewports=[new gi(0,0,1,1)]}Object.assign(Oo.prototype,{_projScreenMatrix:new jn,_lightPositionWorld:new Ee,_lookTarget:new Ee,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){var n=this.camera,i=this.matrix,l=this._projScreenMatrix,h=this._lookTarget,p=this._lightPositionWorld;p.setFromMatrixPosition(e.matrixWorld),n.position.copy(p),h.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(h),n.updateMatrixWorld(),l.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(l),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(n.projectionMatrix),i.multiply(n.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){var e={};return this.bias!==0&&(e.bias=this.bias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}});function K_(){Oo.call(this,new Xi(50,1,.5,500))}K_.prototype=Object.assign(Object.create(Oo.prototype),{constructor:K_,isSpotLightShadow:!0,updateMatrices:function(e){var n=this.camera,i=Wn.RAD2DEG*2*e.angle,l=this.mapSize.width/this.mapSize.height,h=e.distance||n.far;(i!==n.fov||l!==n.aspect||h!==n.far)&&(n.fov=i,n.aspect=l,n.far=h,n.updateProjectionMatrix()),Oo.prototype.updateMatrices.call(this,e)}});function $f(e,n,i,l,h,p){Mi.call(this,e,n),this.type="SpotLight",this.position.copy(rn.DefaultUp),this.updateMatrix(),this.target=new rn,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(_){this.intensity=_/Math.PI}}),this.distance=i!==void 0?i:0,this.angle=l!==void 0?l:Math.PI/3,this.penumbra=h!==void 0?h:0,this.decay=p!==void 0?p:1,this.shadow=new K_}$f.prototype=Object.assign(Object.create(Mi.prototype),{constructor:$f,isSpotLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}});function Q_(){Oo.call(this,new Xi(90,1,.5,500)),this._frameExtents=new Lt(4,2),this._viewportCount=6,this._viewports=[new gi(2,1,1,1),new gi(0,1,1,1),new gi(3,1,1,1),new gi(1,1,1,1),new gi(3,0,1,1),new gi(1,0,1,1)],this._cubeDirections=[new Ee(1,0,0),new Ee(-1,0,0),new Ee(0,0,1),new Ee(0,0,-1),new Ee(0,1,0),new Ee(0,-1,0)],this._cubeUps=[new Ee(0,1,0),new Ee(0,1,0),new Ee(0,1,0),new Ee(0,1,0),new Ee(0,0,1),new Ee(0,0,-1)]}Q_.prototype=Object.assign(Object.create(Oo.prototype),{constructor:Q_,isPointLightShadow:!0,updateMatrices:function(e,n){n===void 0&&(n=0);var i=this.camera,l=this.matrix,h=this._lightPositionWorld,p=this._lookTarget,_=this._projScreenMatrix;h.setFromMatrixPosition(e.matrixWorld),i.position.copy(h),p.copy(i.position),p.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(p),i.updateMatrixWorld(),l.makeTranslation(-h.x,-h.y,-h.z),_.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_)}});function Jf(e,n,i,l){Mi.call(this,e,n),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(h){this.intensity=h/(4*Math.PI)}}),this.distance=i!==void 0?i:0,this.decay=l!==void 0?l:1,this.shadow=new Q_}Jf.prototype=Object.assign(Object.create(Mi.prototype),{constructor:Jf,isPointLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}});function $c(e,n,i,l,h,p){Io.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e!==void 0?e:-1,this.right=n!==void 0?n:1,this.top=i!==void 0?i:1,this.bottom=l!==void 0?l:-1,this.near=h!==void 0?h:.1,this.far=p!==void 0?p:2e3,this.updateProjectionMatrix()}$c.prototype=Object.assign(Object.create(Io.prototype),{constructor:$c,isOrthographicCamera:!0,copy:function(e,n){return Io.prototype.copy.call(this,e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this},setViewOffset:function(e,n,i,l,h,p){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=l,this.view.width=h,this.view.height=p,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,l=(this.top+this.bottom)/2,h=i-e,p=i+e,_=l+n,s=l-n;if(this.view!==null&&this.view.enabled){var M=(this.right-this.left)/this.view.fullWidth/this.zoom,T=(this.top-this.bottom)/this.view.fullHeight/this.zoom;h+=M*this.view.offsetX,p=h+M*this.view.width,_-=T*this.view.offsetY,s=_-T*this.view.height}this.projectionMatrix.makeOrthographic(h,p,_,s,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var n=rn.prototype.toJSON.call(this,e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}});function ey(){Oo.call(this,new $c(-5,5,5,-5,.5,500))}ey.prototype=Object.assign(Object.create(Oo.prototype),{constructor:ey,isDirectionalLightShadow:!0,updateMatrices:function(e){Oo.prototype.updateMatrices.call(this,e)}});function Kf(e,n){Mi.call(this,e,n),this.type="DirectionalLight",this.position.copy(rn.DefaultUp),this.updateMatrix(),this.target=new rn,this.shadow=new ey}Kf.prototype=Object.assign(Object.create(Mi.prototype),{constructor:Kf,isDirectionalLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}});function ty(e,n){Mi.call(this,e,n),this.type="AmbientLight",this.castShadow=void 0}ty.prototype=Object.assign(Object.create(Mi.prototype),{constructor:ty,isAmbientLight:!0});function ny(e,n,i,l){Mi.call(this,e,n),this.type="RectAreaLight",this.width=i!==void 0?i:10,this.height=l!==void 0?l:10}ny.prototype=Object.assign(Object.create(Mi.prototype),{constructor:ny,isRectAreaLight:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var n=Mi.prototype.toJSON.call(this,e);return n.object.width=this.width,n.object.height=this.height,n}});function iy(e){ri.call(this,e),this.textures={}}iy.prototype=Object.assign(Object.create(ri.prototype),{constructor:iy,load:function(e,n,i,l){var h=this,p=new xa(h.manager);p.setPath(h.path),p.load(e,function(_){n(h.parse(JSON.parse(_)))},i,l)},parse:function(e){var n=this.textures;function i(M){return n[M]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",M),n[M]}var l=new UC[e.type];if(e.uuid!==void 0&&(l.uuid=e.uuid),e.name!==void 0&&(l.name=e.name),e.color!==void 0&&l.color.setHex(e.color),e.roughness!==void 0&&(l.roughness=e.roughness),e.metalness!==void 0&&(l.metalness=e.metalness),e.sheen!==void 0&&(l.sheen=new en().setHex(e.sheen)),e.emissive!==void 0&&l.emissive.setHex(e.emissive),e.specular!==void 0&&l.specular.setHex(e.specular),e.shininess!==void 0&&(l.shininess=e.shininess),e.clearcoat!==void 0&&(l.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(l.clearcoatRoughness=e.clearcoatRoughness),e.vertexColors!==void 0&&(l.vertexColors=e.vertexColors),e.fog!==void 0&&(l.fog=e.fog),e.flatShading!==void 0&&(l.flatShading=e.flatShading),e.blending!==void 0&&(l.blending=e.blending),e.combine!==void 0&&(l.combine=e.combine),e.side!==void 0&&(l.side=e.side),e.opacity!==void 0&&(l.opacity=e.opacity),e.transparent!==void 0&&(l.transparent=e.transparent),e.alphaTest!==void 0&&(l.alphaTest=e.alphaTest),e.depthTest!==void 0&&(l.depthTest=e.depthTest),e.depthWrite!==void 0&&(l.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(l.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(l.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(l.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(l.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(l.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(l.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(l.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(l.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(l.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(l.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(l.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(l.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(l.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(l.rotation=e.rotation),e.linewidth!==1&&(l.linewidth=e.linewidth),e.dashSize!==void 0&&(l.dashSize=e.dashSize),e.gapSize!==void 0&&(l.gapSize=e.gapSize),e.scale!==void 0&&(l.scale=e.scale),e.polygonOffset!==void 0&&(l.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(l.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(l.polygonOffsetUnits=e.polygonOffsetUnits),e.skinning!==void 0&&(l.skinning=e.skinning),e.morphTargets!==void 0&&(l.morphTargets=e.morphTargets),e.morphNormals!==void 0&&(l.morphNormals=e.morphNormals),e.dithering!==void 0&&(l.dithering=e.dithering),e.visible!==void 0&&(l.visible=e.visible),e.toneMapped!==void 0&&(l.toneMapped=e.toneMapped),e.userData!==void 0&&(l.userData=e.userData),e.uniforms!==void 0)for(var h in e.uniforms){var p=e.uniforms[h];switch(l.uniforms[h]={},p.type){case"t":l.uniforms[h].value=i(p.value);break;case"c":l.uniforms[h].value=new en().setHex(p.value);break;case"v2":l.uniforms[h].value=new Lt().fromArray(p.value);break;case"v3":l.uniforms[h].value=new Ee().fromArray(p.value);break;case"v4":l.uniforms[h].value=new gi().fromArray(p.value);break;case"m3":l.uniforms[h].value=new dr().fromArray(p.value);case"m4":l.uniforms[h].value=new jn().fromArray(p.value);break;default:l.uniforms[h].value=p.value}}if(e.defines!==void 0&&(l.defines=e.defines),e.vertexShader!==void 0&&(l.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(l.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(var _ in e.extensions)l.extensions[_]=e.extensions[_];if(e.shading!==void 0&&(l.flatShading=e.shading===1),e.size!==void 0&&(l.size=e.size),e.sizeAttenuation!==void 0&&(l.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(l.map=i(e.map)),e.matcap!==void 0&&(l.matcap=i(e.matcap)),e.alphaMap!==void 0&&(l.alphaMap=i(e.alphaMap),l.transparent=!0),e.bumpMap!==void 0&&(l.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(l.bumpScale=e.bumpScale),e.normalMap!==void 0&&(l.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(l.normalMapType=e.normalMapType),e.normalScale!==void 0){var s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),l.normalScale=new Lt().fromArray(s)}return e.displacementMap!==void 0&&(l.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(l.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(l.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(l.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(l.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(l.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(l.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(l.specularMap=i(e.specularMap)),e.envMap!==void 0&&(l.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(l.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(l.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(l.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(l.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(l.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(l.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(l.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(l.gradientMap=i(e.gradientMap)),e.clearcoatNormalMap!==void 0&&(l.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(l.clearcoatNormalScale=new Lt().fromArray(e.clearcoatNormalScale)),l},setTextures:function(e){return this.textures=e,this}});var ul={decodeText:function(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);for(var n="",i=0,l=e.length;i<l;i++)n+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(n))}catch(h){return n}},extractUrlBase:function(e){var n=e.lastIndexOf("/");return n===-1?"./":e.substr(0,n+1)}};function ry(){yn.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}ry.prototype=Object.assign(Object.create(yn.prototype),{constructor:ry,isInstancedBufferGeometry:!0,copy:function(e){return yn.prototype.copy.call(this,e),this.maxInstancedCount=e.maxInstancedCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){var e=yn.prototype.toJSON.call(this);return e.maxInstancedCount=this.maxInstancedCount,e.isInstancedBufferGeometry=!0,e}});function ay(e,n,i,l){typeof i=="number"&&(l=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),zn.call(this,e,n,i),this.meshPerAttribute=l||1}ay.prototype=Object.assign(Object.create(zn.prototype),{constructor:ay,isInstancedBufferAttribute:!0,copy:function(e){return zn.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){var e=zn.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}});function oy(e){ri.call(this,e)}oy.prototype=Object.assign(Object.create(ri.prototype),{constructor:oy,load:function(e,n,i,l){var h=this,p=new xa(h.manager);p.setPath(h.path),p.load(e,function(_){n(h.parse(JSON.parse(_)))},i,l)},parse:function(e){var n=e.isInstancedBufferGeometry?new ry:new yn,i=e.data.index;if(i!==void 0){var l=new sy[i.type](i.array);n.setIndex(new zn(l,1))}var h=e.data.attributes;for(var p in h){var _=h[p],l=new sy[_.type](_.array),s=_.isInstancedBufferAttribute?ay:zn,M=new s(l,_.itemSize,_.normalized);_.name!==void 0&&(M.name=_.name),n.setAttribute(p,M)}var T=e.data.morphAttributes;if(T)for(var p in T){for(var C=T[p],E=[],L=0,I=C.length;L<I;L++){var _=C[L],l=new sy[_.type](_.array),M=new zn(l,_.itemSize,_.normalized);_.name!==void 0&&(M.name=_.name),E.push(M)}n.morphAttributes[p]=E}var B=e.data.morphTargetsRelative;B&&(n.morphTargetsRelative=!0);var O=e.data.groups||e.data.drawcalls||e.data.offsets;if(O!==void 0)for(var L=0,U=O.length;L!==U;++L){var q=O[L];n.addGroup(q.start,q.count,q.materialIndex)}var ee=e.data.boundingSphere;if(ee!==void 0){var he=new Ee;ee.center!==void 0&&he.fromArray(ee.center),n.boundingSphere=new Co(he,ee.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}});var sy={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray!="undefined"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ly(e){ri.call(this,e)}ly.prototype=Object.assign(Object.create(ri.prototype),{constructor:ly,load:function(e,n,i,l){var h=this,p=this.path===""?ul.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||p;var _=new xa(h.manager);_.setPath(this.path),_.load(e,function(s){var M=null;try{M=JSON.parse(s)}catch(C){l!==void 0&&l(C),console.error("THREE:ObjectLoader: Can't parse "+e+".",C.message);return}var T=M.metadata;if(T===void 0||T.type===void 0||T.type.toLowerCase()==="geometry"){console.error("THREE.ObjectLoader: Can't load "+e);return}h.parse(M,n)},i,l)},parse:function(e,n){var i=this.parseShape(e.shapes),l=this.parseGeometries(e.geometries,i),h=this.parseImages(e.images,function(){n!==void 0&&n(s)}),p=this.parseTextures(e.textures,h),_=this.parseMaterials(e.materials,p),s=this.parseObject(e.object,l,_);return e.animations&&(s.animations=this.parseAnimations(e.animations)),(e.images===void 0||e.images.length===0)&&n!==void 0&&n(s),s},parseShape:function(e){var n={};if(e!==void 0)for(var i=0,l=e.length;i<l;i++){var h=new cl().fromJSON(e[i]);n[h.uuid]=h}return n},parseGeometries:function(e,n){var i={};if(e!==void 0)for(var l=new oy,h=0,p=e.length;h<p;h++){var _,s=e[h];switch(s.type){case"PlaneGeometry":case"PlaneBufferGeometry":_=new Tr[s.type](s.width,s.height,s.widthSegments,s.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":_=new Tr[s.type](s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":_=new Tr[s.type](s.radius,s.segments,s.thetaStart,s.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":_=new Tr[s.type](s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":_=new Tr[s.type](s.radius,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":_=new Tr[s.type](s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":_=new Tr[s.type](s.radius,s.detail);break;case"RingGeometry":case"RingBufferGeometry":_=new Tr[s.type](s.innerRadius,s.outerRadius,s.thetaSegments,s.phiSegments,s.thetaStart,s.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":_=new Tr[s.type](s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":_=new Tr[s.type](s.radius,s.tube,s.tubularSegments,s.radialSegments,s.p,s.q);break;case"TubeGeometry":case"TubeBufferGeometry":_=new Tr[s.type](new $_[s.path.type]().fromJSON(s.path),s.tubularSegments,s.radius,s.radialSegments,s.closed);break;case"LatheGeometry":case"LatheBufferGeometry":_=new Tr[s.type](s.points,s.segments,s.phiStart,s.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":_=new Tr[s.type](s.vertices,s.indices,s.radius,s.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var E=[],M=0,T=s.shapes.length;M<T;M++){var C=n[s.shapes[M]];E.push(C)}_=new Tr[s.type](E,s.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(var E=[],M=0,T=s.shapes.length;M<T;M++){var C=n[s.shapes[M]];E.push(C)}var L=s.options.extrudePath;L!==void 0&&(s.options.extrudePath=new $_[L.type]().fromJSON(L)),_=new Tr[s.type](E,s.options);break;case"BufferGeometry":case"InstancedBufferGeometry":_=l.parse(s);break;case"Geometry":if("THREE"in window&&"LegacyJSONLoader"in THREE){var I=new THREE.LegacyJSONLoader;_=I.parse(s,this.resourcePath).geometry}else console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+s.type+'"');continue}_.uuid=s.uuid,s.name!==void 0&&(_.name=s.name),_.isBufferGeometry===!0&&s.userData!==void 0&&(_.userData=s.userData),i[s.uuid]=_}return i},parseMaterials:function(e,n){var i={},l={};if(e!==void 0){var h=new iy;h.setTextures(n);for(var p=0,_=e.length;p<_;p++){var s=e[p];if(s.type==="MultiMaterial"){for(var M=[],T=0;T<s.materials.length;T++){var C=s.materials[T];i[C.uuid]===void 0&&(i[C.uuid]=h.parse(C)),M.push(i[C.uuid])}l[s.uuid]=M}else i[s.uuid]===void 0&&(i[s.uuid]=h.parse(s)),l[s.uuid]=i[s.uuid]}}return l},parseAnimations:function(e){for(var n=[],i=0;i<e.length;i++){var l=e[i],h=va.parse(l);l.uuid!==void 0&&(h.uuid=l.uuid),n.push(h)}return n},parseImages:function(e,n){var i=this,l={};function h(O){return i.manager.itemStart(O),_.load(O,function(){i.manager.itemEnd(O)},void 0,function(){i.manager.itemError(O),i.manager.itemEnd(O)})}if(e!==void 0&&e.length>0){var p=new kx(n),_=new Yh(p);_.setCrossOrigin(this.crossOrigin);for(var s=0,M=e.length;s<M;s++){var T=e[s],C=T.url;if(Array.isArray(C)){l[T.uuid]=[];for(var E=0,L=C.length;E<L;E++){var I=C[E],B=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(I)?I:i.resourcePath+I;l[T.uuid].push(h(B))}}else{var B=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(T.url)?T.url:i.resourcePath+T.url;l[T.uuid]=h(B)}}}return l},parseTextures:function(e,n){function i(M,T){return typeof M=="number"?M:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",M),T[M])}var l={};if(e!==void 0)for(var h=0,p=e.length;h<p;h++){var _=e[h];_.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',_.uuid),n[_.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",_.image);var s;Array.isArray(n[_.image])?s=new rs(n[_.image]):s=new mi(n[_.image]),s.needsUpdate=!0,s.uuid=_.uuid,_.name!==void 0&&(s.name=_.name),_.mapping!==void 0&&(s.mapping=i(_.mapping,JC)),_.offset!==void 0&&s.offset.fromArray(_.offset),_.repeat!==void 0&&s.repeat.fromArray(_.repeat),_.center!==void 0&&s.center.fromArray(_.center),_.rotation!==void 0&&(s.rotation=_.rotation),_.wrap!==void 0&&(s.wrapS=i(_.wrap[0],Ux),s.wrapT=i(_.wrap[1],Ux)),_.format!==void 0&&(s.format=_.format),_.type!==void 0&&(s.type=_.type),_.encoding!==void 0&&(s.encoding=_.encoding),_.minFilter!==void 0&&(s.minFilter=i(_.minFilter,Vx)),_.magFilter!==void 0&&(s.magFilter=i(_.magFilter,Vx)),_.anisotropy!==void 0&&(s.anisotropy=_.anisotropy),_.flipY!==void 0&&(s.flipY=_.flipY),_.premultiplyAlpha!==void 0&&(s.premultiplyAlpha=_.premultiplyAlpha),_.unpackAlignment!==void 0&&(s.unpackAlignment=_.unpackAlignment),l[_.uuid]=s}return l},parseObject:function(e,n,i){var l;function h(U){return n[U]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",U),n[U]}function p(U){if(U!==void 0){if(Array.isArray(U)){for(var q=[],ee=0,he=U.length;ee<he;ee++){var Ce=U[ee];i[Ce]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",Ce),q.push(i[Ce])}return q}return i[U]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",U),i[U]}}switch(e.type){case"Scene":l=new So,e.background!==void 0&&Number.isInteger(e.background)&&(l.background=new en(e.background)),e.fog!==void 0&&(e.fog.type==="Fog"?l.fog=new L_(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(l.fog=new P_(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":l=new Xi(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(l.focus=e.focus),e.zoom!==void 0&&(l.zoom=e.zoom),e.filmGauge!==void 0&&(l.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(l.filmOffset=e.filmOffset),e.view!==void 0&&(l.view=Object.assign({},e.view));break;case"OrthographicCamera":l=new $c(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(l.zoom=e.zoom),e.view!==void 0&&(l.view=Object.assign({},e.view));break;case"AmbientLight":l=new ty(e.color,e.intensity);break;case"DirectionalLight":l=new Kf(e.color,e.intensity);break;case"PointLight":l=new Jf(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":l=new ny(e.color,e.intensity,e.width,e.height);break;case"SpotLight":l=new $f(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":l=new J_(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var _=h(e.geometry),s=p(e.material);_.bones&&_.bones.length>0?l=new Dh(_,s):l=new Ai(_,s);break;case"InstancedMesh":var _=h(e.geometry),s=p(e.material),M=e.count,T=e.instanceMatrix;l=new z_(_,s,M),l.instanceMatrix=new zn(new Float32Array(T.array),16);break;case"LOD":l=new yf;break;case"Line":l=new sa(h(e.geometry),p(e.material),e.mode);break;case"LineLoop":l=new Tf(h(e.geometry),p(e.material));break;case"LineSegments":l=new Vi(h(e.geometry),p(e.material));break;case"PointCloud":case"Points":l=new Af(h(e.geometry),p(e.material));break;case"Sprite":l=new I_(p(e.material));break;case"Group":l=new rl;break;default:l=new rn}if(l.uuid=e.uuid,e.name!==void 0&&(l.name=e.name),e.matrix!==void 0?(l.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(l.matrixAutoUpdate=e.matrixAutoUpdate),l.matrixAutoUpdate&&l.matrix.decompose(l.position,l.quaternion,l.scale)):(e.position!==void 0&&l.position.fromArray(e.position),e.rotation!==void 0&&l.rotation.fromArray(e.rotation),e.quaternion!==void 0&&l.quaternion.fromArray(e.quaternion),e.scale!==void 0&&l.scale.fromArray(e.scale)),e.castShadow!==void 0&&(l.castShadow=e.castShadow),e.receiveShadow!==void 0&&(l.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(l.shadow.bias=e.shadow.bias),e.shadow.radius!==void 0&&(l.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&l.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(l.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(l.visible=e.visible),e.frustumCulled!==void 0&&(l.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(l.renderOrder=e.renderOrder),e.userData!==void 0&&(l.userData=e.userData),e.layers!==void 0&&(l.layers.mask=e.layers),e.children!==void 0)for(var C=e.children,E=0;E<C.length;E++)l.add(this.parseObject(C[E],n,i));if(e.type==="LOD"){e.autoUpdate!==void 0&&(l.autoUpdate=e.autoUpdate);for(var L=e.levels,I=0;I<L.length;I++){var B=L[I],O=l.getObjectByProperty("uuid",B.object);O!==void 0&&l.addLevel(O,B.distance)}}return l}});var JC={UVMapping:Wg,CubeReflectionMapping:jg,CubeRefractionMapping:qg,EquirectangularReflectionMapping:p0,EquirectangularRefractionMapping:Zg,SphericalReflectionMapping:f0,CubeUVReflectionMapping:oh,CubeUVRefractionMapping:Xg},Ux={RepeatWrapping:Zs,ClampToEdgeWrapping:wr,MirroredRepeatWrapping:sh},Vx={NearestFilter:Ui,NearestMipmapNearestFilter:Gp,NearestMipmapLinearFilter:Hp,LinearFilter:qi,LinearMipmapNearestFilter:Yg,LinearMipmapLinearFilter:ec};function Gx(e){typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),ri.call(this,e),this.options=void 0}Gx.prototype=Object.assign(Object.create(ri.prototype),{constructor:Gx,setOptions:function(n){return this.options=n,this},load:function(e,n,i,l){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);var h=this,p=Yc.get(e);if(p!==void 0)return h.manager.itemStart(e),setTimeout(function(){n&&n(p),h.manager.itemEnd(e)},0),p;fetch(e).then(function(_){return _.blob()}).then(function(_){return h.options===void 0?createImageBitmap(_):createImageBitmap(_,h.options)}).then(function(_){Yc.add(e,_),n&&n(_),h.manager.itemEnd(e)}).catch(function(_){l&&l(_),h.manager.itemError(e),h.manager.itemEnd(e)}),h.manager.itemStart(e)}});function Hx(){this.type="ShapePath",this.color=new en,this.subPaths=[],this.currentPath=null}Object.assign(Hx.prototype,{moveTo:function(e,n){return this.currentPath=new Ka,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,n),this},lineTo:function(e,n){return this.currentPath.lineTo(e,n),this},quadraticCurveTo:function(e,n,i,l){return this.currentPath.quadraticCurveTo(e,n,i,l),this},bezierCurveTo:function(e,n,i,l,h,p){return this.currentPath.bezierCurveTo(e,n,i,l,h,p),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,n){function i(We){for(var st=[],St=0,gt=We.length;St<gt;St++){var At=We[St],Dt=new cl;Dt.curves=At.curves,st.push(Dt)}return st}function l(We,st){for(var St=st.length,gt=!1,At=St-1,Dt=0;Dt<St;At=Dt++){var Ot=st[At],Pe=st[Dt],ge=Pe.x-Ot.x,Ve=Pe.y-Ot.y;if(Math.abs(Ve)>Number.EPSILON){if(Ve<0&&(Ot=st[Dt],ge=-ge,Pe=st[At],Ve=-Ve),We.y<Ot.y||We.y>Pe.y)continue;if(We.y===Ot.y){if(We.x===Ot.x)return!0}else{var Ne=Ve*(We.x-Ot.x)-ge*(We.y-Ot.y);if(Ne===0)return!0;if(Ne<0)continue;gt=!gt}}else{if(We.y!==Ot.y)continue;if(Pe.x<=We.x&&We.x<=Ot.x||Ot.x<=We.x&&We.x<=Pe.x)return!0}}return gt}var h=ss.isClockWise,p=this.subPaths;if(p.length===0)return[];if(n===!0)return i(p);var _,s,M,T=[];if(p.length===1)return s=p[0],M=new cl,M.curves=s.curves,T.push(M),T;var C=!h(p[0].getPoints());C=e?!C:C;var E=[],L=[],I=[],B=0,O;L[B]=void 0,I[B]=[];for(var U=0,q=p.length;U<q;U++)s=p[U],O=s.getPoints(),_=h(O),_=e?!_:_,_?(!C&&L[B]&&B++,L[B]={s:new cl,p:O},L[B].s.curves=s.curves,C&&B++,I[B]=[]):I[B].push({h:s,p:O[0]});if(!L[0])return i(p);if(L.length>1){for(var ee=!1,he=[],Ce=0,K=L.length;Ce<K;Ce++)E[Ce]=[];for(var Ce=0,K=L.length;Ce<K;Ce++)for(var ie=I[Ce],ue=0;ue<ie.length;ue++){for(var ae=ie[ue],le=!0,De=0;De<L.length;De++)l(ae.p,L[De].p)&&(Ce!==De&&he.push({froms:Ce,tos:De,hole:ue}),le?(le=!1,E[De].push(ae)):ee=!0);le&&E[Ce].push(ae)}he.length>0&&(ee||(I=E))}for(var ye,U=0,se=L.length;U<se;U++){M=L[U].s,T.push(M),ye=I[U];for(var Ue=0,Oe=ye.length;Ue<Oe;Ue++)M.holes.push(ye[Ue].h)}return T}});function Wx(e){this.type="Font",this.data=e}Object.assign(Wx.prototype,{isFont:!0,generateShapes:function(e,n){n===void 0&&(n=100);for(var i=[],l=KC(e,n,this.data),h=0,p=l.length;h<p;h++)Array.prototype.push.apply(i,l[h].toShapes());return i}});function KC(e,n,i){for(var l=Array.from?Array.from(e):String(e).split(""),h=n/i.resolution,p=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*h,_=[],s=0,M=0,T=0;T<l.length;T++){var C=l[T];if(C===`
  2707. `)s=0,M-=p;else{var E=QC(C,h,s,M,i);s+=E.offsetX,_.push(E.path)}}return _}function QC(e,n,i,l,h){var p=h.glyphs[e]||h.glyphs["?"];if(!p){console.error('THREE.Font: character "'+e+'" does not exists in font family '+h.familyName+".");return}var _=new Hx,s,M,T,C,E,L,I,B;if(p.o)for(var O=p._cachedOutline||(p._cachedOutline=p.o.split(" ")),U=0,q=O.length;U<q;){var ee=O[U++];switch(ee){case"m":s=O[U++]*n+i,M=O[U++]*n+l,_.moveTo(s,M);break;case"l":s=O[U++]*n+i,M=O[U++]*n+l,_.lineTo(s,M);break;case"q":T=O[U++]*n+i,C=O[U++]*n+l,E=O[U++]*n+i,L=O[U++]*n+l,_.quadraticCurveTo(E,L,T,C);break;case"b":T=O[U++]*n+i,C=O[U++]*n+l,E=O[U++]*n+i,L=O[U++]*n+l,I=O[U++]*n+i,B=O[U++]*n+l,_.bezierCurveTo(E,L,I,B,T,C);break}}return{offsetX:p.ha*n,path:_}}function jx(e){ri.call(this,e)}jx.prototype=Object.assign(Object.create(ri.prototype),{constructor:jx,load:function(e,n,i,l){var h=this,p=new xa(this.manager);p.setPath(this.path),p.load(e,function(_){var s;try{s=JSON.parse(_)}catch(T){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),s=JSON.parse(_.substring(65,_.length-2))}var M=h.parse(s);n&&n(M)},i,l)},parse:function(e){return new Wx(e)}});var Qf,qx={getContext:function(){return Qf===void 0&&(Qf=new(window.AudioContext||window.webkitAudioContext)),Qf},setContext:function(e){Qf=e}};function cy(e){ri.call(this,e)}cy.prototype=Object.assign(Object.create(ri.prototype),{constructor:cy,load:function(e,n,i,l){var h=new xa(this.manager);h.setResponseType("arraybuffer"),h.setPath(this.path),h.load(e,function(p){var _=p.slice(0),s=qx.getContext();s.decodeAudioData(_,function(M){n(M)})},i,l)}});function uy(){this.coefficients=[];for(var e=0;e<9;e++)this.coefficients.push(new Ee)}Object.assign(uy.prototype,{isSphericalHarmonics3:!0,set:function(e){for(var n=0;n<9;n++)this.coefficients[n].copy(e[n]);return this},zero:function(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this},getAt:function(e,n){var i=e.x,l=e.y,h=e.z,p=this.coefficients;return n.copy(p[0]).multiplyScalar(.282095),n.addScale(p[1],.488603*l),n.addScale(p[2],.488603*h),n.addScale(p[3],.488603*i),n.addScale(p[4],1.092548*(i*l)),n.addScale(p[5],1.092548*(l*h)),n.addScale(p[6],.315392*(3*h*h-1)),n.addScale(p[7],1.092548*(i*h)),n.addScale(p[8],.546274*(i*i-l*l)),n},getIrradianceAt:function(e,n){var i=e.x,l=e.y,h=e.z,p=this.coefficients;return n.copy(p[0]).multiplyScalar(.886227),n.addScale(p[1],1.023328*l),n.addScale(p[2],1.023328*h),n.addScale(p[3],1.023328*i),n.addScale(p[4],.858086*i*l),n.addScale(p[5],.858086*l*h),n.addScale(p[6],.743125*h*h-.247708),n.addScale(p[7],.858086*i*h),n.addScale(p[8],.429043*(i*i-l*l)),n},add:function(e){for(var n=0;n<9;n++)this.coefficients[n].add(e.coefficients[n]);return this},scale:function(e){for(var n=0;n<9;n++)this.coefficients[n].multiplyScalar(e);return this},lerp:function(e,n){for(var i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],n);return this},equals:function(e){for(var n=0;n<9;n++)if(!this.coefficients[n].equals(e.coefficients[n]))return!1;return!0},copy:function(e){return this.set(e.coefficients)},clone:function(){return new this.constructor().copy(this)},fromArray:function(e,n){n===void 0&&(n=0);for(var i=this.coefficients,l=0;l<9;l++)i[l].fromArray(e,n+l*3);return this},toArray:function(e,n){e===void 0&&(e=[]),n===void 0&&(n=0);for(var i=this.coefficients,l=0;l<9;l++)i[l].toArray(e,n+l*3);return e}}),Object.assign(uy,{getBasisAt:function(e,n){var i=e.x,l=e.y,h=e.z;n[0]=.282095,n[1]=.488603*l,n[2]=.488603*h,n[3]=.488603*i,n[4]=1.092548*i*l,n[5]=1.092548*l*h,n[6]=.315392*(3*h*h-1),n[7]=1.092548*i*h,n[8]=.546274*(i*i-l*l)}});function Qa(e,n){Mi.call(this,void 0,n),this.sh=e!==void 0?e:new uy}Qa.prototype=Object.assign(Object.create(Mi.prototype),{constructor:Qa,isLightProbe:!0,copy:function(e){return Mi.prototype.copy.call(this,e),this.sh.copy(e.sh),this.intensity=e.intensity,this},toJSON:function(e){var n=Mi.prototype.toJSON.call(this,e);return n}});function Zx(e,n,i){Qa.call(this,void 0,i);var l=new en().set(e),h=new en().set(n),p=new Ee(l.r,l.g,l.b),_=new Ee(h.r,h.g,h.b),s=Math.sqrt(Math.PI),M=s*Math.sqrt(.75);this.sh.coefficients[0].copy(p).add(_).multiplyScalar(s),this.sh.coefficients[1].copy(p).sub(_).multiplyScalar(M)}Zx.prototype=Object.assign(Object.create(Qa.prototype),{constructor:Zx,isHemisphereLightProbe:!0,copy:function(e){return Qa.prototype.copy.call(this,e),this},toJSON:function(e){var n=Qa.prototype.toJSON.call(this,e);return n}});function Xx(e,n){Qa.call(this,void 0,n);var i=new en().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}Xx.prototype=Object.assign(Object.create(Qa.prototype),{constructor:Xx,isAmbientLightProbe:!0,copy:function(e){return Qa.prototype.copy.call(this,e),this},toJSON:function(e){var n=Qa.prototype.toJSON.call(this,e);return n}});var Yx=new jn,$x=new jn;function eP(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Xi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Xi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign(eP.prototype,{update:function(e){var n=this._cache,i=n.focus!==e.focus||n.fov!==e.fov||n.aspect!==e.aspect*this.aspect||n.near!==e.near||n.far!==e.far||n.zoom!==e.zoom||n.eyeSep!==this.eyeSep;if(i){n.focus=e.focus,n.fov=e.fov,n.aspect=e.aspect*this.aspect,n.near=e.near,n.far=e.far,n.zoom=e.zoom,n.eyeSep=this.eyeSep;var l=e.projectionMatrix.clone(),h=n.eyeSep/2,p=h*n.near/n.focus,_=n.near*Math.tan(Wn.DEG2RAD*n.fov*.5)/n.zoom,s,M;$x.elements[12]=-h,Yx.elements[12]=h,s=-_*n.aspect+p,M=_*n.aspect+p,l.elements[0]=2*n.near/(M-s),l.elements[8]=(M+s)/(M-s),this.cameraL.projectionMatrix.copy(l),s=-_*n.aspect-p,M=_*n.aspect-p,l.elements[0]=2*n.near/(M-s),l.elements[8]=(M+s)/(M-s),this.cameraR.projectionMatrix.copy(l)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply($x),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Yx)}});function Jx(e){this.autoStart=e!==void 0?e:!0,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}Object.assign(Jx.prototype,{start:function(){this.startTime=(typeof performance=="undefined"?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var n=(typeof performance=="undefined"?Date:performance).now();e=(n-this.oldTime)/1e3,this.oldTime=n,this.elapsedTime+=e}return e}});var hl=new Ee,Kx=new Or,tP=new Ee,dl=new Ee;function Qx(){rn.call(this),this.type="AudioListener",this.context=qx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Jx}Qx.prototype=Object.assign(Object.create(rn.prototype),{constructor:Qx,getInput:function(){return this.gain},removeFilter:function(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this},updateMatrixWorld:function(e){rn.prototype.updateMatrixWorld.call(this,e);var n=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(hl,Kx,tP),dl.set(0,0,-1).applyQuaternion(Kx),n.positionX){var l=this.context.currentTime+this.timeDelta;n.positionX.linearRampToValueAtTime(hl.x,l),n.positionY.linearRampToValueAtTime(hl.y,l),n.positionZ.linearRampToValueAtTime(hl.z,l),n.forwardX.linearRampToValueAtTime(dl.x,l),n.forwardY.linearRampToValueAtTime(dl.y,l),n.forwardZ.linearRampToValueAtTime(dl.z,l),n.upX.linearRampToValueAtTime(i.x,l),n.upY.linearRampToValueAtTime(i.y,l),n.upZ.linearRampToValueAtTime(i.z,l)}else n.setPosition(hl.x,hl.y,hl.z),n.setOrientation(dl.x,dl.y,dl.z,i.x,i.y,i.z)}});function ed(e){rn.call(this),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this._startedAt=0,this._pausedAt=0,this.filters=[]}ed.prototype=Object.assign(Object.create(rn.prototype),{constructor:ed,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setMediaElementSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this},setMediaStreamSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this},setBuffer:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(e){if(e===void 0&&(e=0),this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;var n=this.context.createBufferSource();return n.buffer=this.buffer,n.loop=this.loop,n.loopStart=this.loopStart,n.loopEnd=this.loopEnd,n.onended=this.onEnded.bind(this),n.start(this._startedAt,this._pausedAt+this.offset,this.duration),this.isPlaying=!0,this.source=n,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()},pause:function(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._pausedAt=(this.context.currentTime-this._startedAt)*this.playbackRate,this.source.stop(),this.source.onended=null,this.isPlaying=!1),this},stop:function(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._pausedAt=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,n=this.filters.length;e<n;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var e=1,n=this.filters.length;e<n;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(e){return e||(e=[]),this.isPlaying===!0?(this.disconnect(),this.filters=e,this.connect()):this.filters=e,this},setDetune:function(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(e){return this.setFilters(e?[e]:[])},setPlaybackRate:function(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this},setLoopStart:function(e){return this.loopStart=e,this},setLoopEnd:function(e){return this.loopEnd=e,this},getVolume:function(){return this.gain.gain.value},setVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}});var pl=new Ee,e1=new Or,nP=new Ee,fl=new Ee;function t1(e){ed.call(this,e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}t1.prototype=Object.assign(Object.create(ed.prototype),{constructor:t1,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(e){return this.panner.refDistance=e,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(e){return this.panner.rolloffFactor=e,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(e){return this.panner.distanceModel=e,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(e){return this.panner.maxDistance=e,this},setDirectionalCone:function(e,n,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=n,this.panner.coneOuterGain=i,this},updateMatrixWorld:function(e){if(rn.prototype.updateMatrixWorld.call(this,e),!(this.hasPlaybackControl===!0&&this.isPlaying===!1)){this.matrixWorld.decompose(pl,e1,nP),fl.set(0,0,1).applyQuaternion(e1);var n=this.panner;if(n.positionX){var i=this.context.currentTime+this.listener.timeDelta;n.positionX.linearRampToValueAtTime(pl.x,i),n.positionY.linearRampToValueAtTime(pl.y,i),n.positionZ.linearRampToValueAtTime(pl.z,i),n.orientationX.linearRampToValueAtTime(fl.x,i),n.orientationY.linearRampToValueAtTime(fl.y,i),n.orientationZ.linearRampToValueAtTime(fl.z,i)}else n.setPosition(pl.x,pl.y,pl.z),n.setOrientation(fl.x,fl.y,fl.z)}}});function n1(e,n){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=n!==void 0?n:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}Object.assign(n1.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var e=0,n=this.getFrequencyData(),i=0;i<n.length;i++)e+=n[i];return e/n.length}});function i1(e,n,i){this.binding=e,this.valueSize=i;var l=Float64Array,h;switch(n){case"quaternion":h=this._slerp;break;case"string":case"bool":l=Array,h=this._select;break;default:h=this._lerp}this.buffer=new l(i*4),this._mixBufferRegion=h,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}Object.assign(i1.prototype,{accumulate:function(e,n){var i=this.buffer,l=this.valueSize,h=e*l+l,p=this.cumulativeWeight;if(p===0){for(var _=0;_!==l;++_)i[h+_]=i[_];p=n}else{p+=n;var s=n/p;this._mixBufferRegion(i,h,0,s,l)}this.cumulativeWeight=p},apply:function(e){var n=this.valueSize,i=this.buffer,l=e*n+n,h=this.cumulativeWeight,p=this.binding;if(this.cumulativeWeight=0,h<1){var _=n*3;this._mixBufferRegion(i,l,_,1-h,n)}for(var s=n,M=n+n;s!==M;++s)if(i[s]!==i[s+n]){p.setValue(i,l);break}},saveOriginalState:function(){var e=this.binding,n=this.buffer,i=this.valueSize,l=i*3;e.getValue(n,l);for(var h=i,p=l;h!==p;++h)n[h]=n[l+h%i];this.cumulativeWeight=0},restoreOriginalState:function(){var e=this.valueSize*3;this.binding.setValue(this.buffer,e)},_select:function(e,n,i,l,h){if(l>=.5)for(var p=0;p!==h;++p)e[n+p]=e[i+p]},_slerp:function(e,n,i,l){Or.slerpFlat(e,n,e,n,e,i,l)},_lerp:function(e,n,i,l,h){for(var p=1-l,_=0;_!==h;++_){var s=n+_;e[s]=e[s]*p+e[i+_]*l}}});var hy="\\[\\]\\.:\\/",iP=new RegExp("["+hy+"]","g"),dy="[^"+hy+"]",rP="[^"+hy.replace("\\.","")+"]",aP=/((?:WC+[\/:])*)/.source.replace("WC",dy),oP=/(WCOD+)?/.source.replace("WCOD",rP),sP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dy),lP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dy),cP=new RegExp("^"+aP+oP+sP+lP+"$"),uP=["material","materials","bones"];function r1(e,n,i){var l=i||mr.parseTrackName(n);this._targetGroup=e,this._bindings=e.subscribe_(n,l)}Object.assign(r1.prototype,{getValue:function(e,n){this.bind();var i=this._targetGroup.nCachedObjects_,l=this._bindings[i];l!==void 0&&l.getValue(e,n)},setValue:function(e,n){for(var i=this._bindings,l=this._targetGroup.nCachedObjects_,h=i.length;l!==h;++l)i[l].setValue(e,n)},bind:function(){for(var e=this._bindings,n=this._targetGroup.nCachedObjects_,i=e.length;n!==i;++n)e[n].bind()},unbind:function(){for(var e=this._bindings,n=this._targetGroup.nCachedObjects_,i=e.length;n!==i;++n)e[n].unbind()}});function mr(e,n,i){this.path=n,this.parsedPath=i||mr.parseTrackName(n),this.node=mr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(mr,{Composite:r1,create:function(e,n,i){return e&&e.isAnimationObjectGroup?new mr.Composite(e,n,i):new mr(e,n,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(iP,"")},parseTrackName:function(e){var n=cP.exec(e);if(!n)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},l=i.nodeName&&i.nodeName.lastIndexOf(".");if(l!==void 0&&l!==-1){var h=i.nodeName.substring(l+1);uP.indexOf(h)!==-1&&(i.nodeName=i.nodeName.substring(0,l),i.objectName=h)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,n){if(!n||n===""||n==="root"||n==="."||n===-1||n===e.name||n===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(n);if(i!==void 0)return i}if(e.children){var l=function(p){for(var _=0;_<p.length;_++){var s=p[_];if(s.name===n||s.uuid===n)return s;var M=l(s.children);if(M)return M}return null},h=l(e.children);if(h)return h}return null}}),Object.assign(mr.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(n,i){n[i]=this.node[this.propertyName]},function(n,i){for(var l=this.resolvedProperty,h=0,p=l.length;h!==p;++h)n[i++]=l[h]},function(n,i){n[i]=this.resolvedProperty[this.propertyIndex]},function(n,i){this.resolvedProperty.toArray(n,i)}],SetterByBindingTypeAndVersioning:[[function(n,i){this.targetObject[this.propertyName]=n[i]},function(n,i){this.targetObject[this.propertyName]=n[i],this.targetObject.needsUpdate=!0},function(n,i){this.targetObject[this.propertyName]=n[i],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(n,i){for(var l=this.resolvedProperty,h=0,p=l.length;h!==p;++h)l[h]=n[i++]},function(n,i){for(var l=this.resolvedProperty,h=0,p=l.length;h!==p;++h)l[h]=n[i++];this.targetObject.needsUpdate=!0},function(n,i){for(var l=this.resolvedProperty,h=0,p=l.length;h!==p;++h)l[h]=n[i++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(n,i){this.resolvedProperty[this.propertyIndex]=n[i]},function(n,i){this.resolvedProperty[this.propertyIndex]=n[i],this.targetObject.needsUpdate=!0},function(n,i){this.resolvedProperty[this.propertyIndex]=n[i],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(n,i){this.resolvedProperty.fromArray(n,i)},function(n,i){this.resolvedProperty.fromArray(n,i),this.targetObject.needsUpdate=!0},function(n,i){this.resolvedProperty.fromArray(n,i),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(n,i){this.bind(),this.getValue(n,i)},setValue:function(n,i){this.bind(),this.setValue(n,i)},bind:function(){var e=this.node,n=this.parsedPath,i=n.objectName,l=n.propertyName,h=n.propertyIndex;if(e||(e=mr.findNode(this.rootNode,n.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){var p=n.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(var _=0;_<e.length;_++)if(e[_].name===p){p=_;break}break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(p!==void 0){if(e[p]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[p]}}var s=e[l];if(s===void 0){var M=n.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+M+"."+l+" but it wasn't found.",e);return}var T=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?T=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(T=this.Versioning.MatrixWorldNeedsUpdate);var C=this.BindingType.Direct;if(h!==void 0){if(l==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}for(var _=0;_<this.node.geometry.morphAttributes.position.length;_++)if(e.geometry.morphAttributes.position[_].name===h){h=_;break}}else{if(!e.geometry.morphTargets){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);return}for(var _=0;_<this.node.geometry.morphTargets.length;_++)if(e.geometry.morphTargets[_].name===h){h=_;break}}}C=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=h}else s.fromArray!==void 0&&s.toArray!==void 0?(C=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(C=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=l;this.getValue=this.GetterByBindingType[C],this.setValue=this.SetterByBindingTypeAndVersioning[C][T]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}});//!\ DECLARE ALIAS AFTER assign prototype !
  2708. Object.assign(mr.prototype,{_getValue_unbound:mr.prototype.getValue,_setValue_unbound:mr.prototype.setValue});function hP(){this.uuid=Wn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var l=this;this.stats={objects:{get total(){return l._objects.length},get inUse(){return this.total-l.nCachedObjects_}},get bindingsPerObject(){return l._bindings.length}}}Object.assign(hP.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=this._objects,n=e.length,i=this.nCachedObjects_,l=this._indicesByUUID,h=this._paths,p=this._parsedPaths,_=this._bindings,s=_.length,M=void 0,T=0,C=arguments.length;T!==C;++T){var E=arguments[T],L=E.uuid,I=l[L];if(I===void 0){I=n++,l[L]=I,e.push(E);for(var B=0,O=s;B!==O;++B)_[B].push(new mr(E,h[B],p[B]))}else if(I<i){M=e[I];var U=--i,q=e[U];l[q.uuid]=I,e[I]=q,l[L]=U,e[U]=E;for(var B=0,O=s;B!==O;++B){var ee=_[B],he=ee[U],Ce=ee[I];ee[I]=he,Ce===void 0&&(Ce=new mr(E,h[B],p[B])),ee[U]=Ce}}else e[I]!==M&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=i},remove:function(){for(var e=this._objects,n=this.nCachedObjects_,i=this._indicesByUUID,l=this._bindings,h=l.length,p=0,_=arguments.length;p!==_;++p){var s=arguments[p],M=s.uuid,T=i[M];if(T!==void 0&&T>=n){var C=n++,E=e[C];i[E.uuid]=T,e[T]=E,i[M]=C,e[C]=s;for(var L=0,I=h;L!==I;++L){var B=l[L],O=B[C],U=B[T];B[T]=O,B[C]=U}}}this.nCachedObjects_=n},uncache:function(){for(var e=this._objects,n=e.length,i=this.nCachedObjects_,l=this._indicesByUUID,h=this._bindings,p=h.length,_=0,s=arguments.length;_!==s;++_){var M=arguments[_],T=M.uuid,C=l[T];if(C!==void 0)if(delete l[T],C<i){var E=--i,L=e[E],I=--n,B=e[I];l[L.uuid]=C,e[C]=L,l[B.uuid]=E,e[E]=B,e.pop();for(var O=0,U=p;O!==U;++O){var q=h[O],ee=q[E],he=q[I];q[C]=ee,q[E]=he,q.pop()}}else{var I=--n,B=e[I];l[B.uuid]=C,e[C]=B,e.pop();for(var O=0,U=p;O!==U;++O){var q=h[O];q[C]=q[I],q.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,n){var i=this._bindingsIndicesByPath,l=i[e],h=this._bindings;if(l!==void 0)return h[l];var p=this._paths,_=this._parsedPaths,s=this._objects,M=s.length,T=this.nCachedObjects_,C=new Array(M);l=h.length,i[e]=l,p.push(e),_.push(n),h.push(C);for(var E=T,L=s.length;E!==L;++E){var I=s[E];C[E]=new mr(I,e,n)}return C},unsubscribe_:function(e){var n=this._bindingsIndicesByPath,i=n[e];if(i!==void 0){var l=this._paths,h=this._parsedPaths,p=this._bindings,_=p.length-1,s=p[_],M=e[_];n[M]=i,p[i]=s,p.pop(),h[i]=h[_],h.pop(),l[i]=l[_],l.pop()}}});function a1(e,n,i){this._mixer=e,this._clip=n,this._localRoot=i||null;for(var l=n.tracks,h=l.length,p=new Array(h),_={endingStart:ic,endingEnd:ic},s=0;s!==h;++s){var M=l[s].createInterpolant(null);p[s]=M,M.settings=_}this._interpolantSettings=_,this._interpolants=p,this._propertyBindings=new Array(h),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=a2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}Object.assign(a1.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,n){return this.loop=e,this.repetitions=n,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,n,i){if(e.fadeOut(n),this.fadeIn(n),i){var l=this._clip.duration,h=e._clip.duration,p=h/l,_=l/h;e.warp(1,p,n),this.warp(_,1,n)}return this},crossFadeTo:function(e,n,i){return e.crossFadeFrom(this,n,i)},stopFading:function(){var e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._effectiveTimeScale,0,e)},warp:function(e,n,i){var l=this._mixer,h=l.time,p=this._timeScaleInterpolant,_=this.timeScale;p===null&&(p=l._lendControlInterpolant(),this._timeScaleInterpolant=p);var s=p.parameterPositions,M=p.sampleValues;return s[0]=h,s[1]=h+i,M[0]=e/_,M[1]=n/_,this},stopWarping:function(){var e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,n,i,l){if(!this.enabled){this._updateWeight(e);return}var h=this._startTime;if(h!==null){var p=(e-h)*i;if(p<0||i===0)return;this._startTime=null,n=i*p}n*=this._updateTimeScale(e);var _=this._updateTime(n),s=this._updateWeight(e);if(s>0)for(var M=this._interpolants,T=this._propertyBindings,C=0,E=M.length;C!==E;++C)M[C].evaluate(_),T[C].accumulate(l,s)},_updateWeight:function(e){var n=0;if(this.enabled){n=this.weight;var i=this._weightInterpolant;if(i!==null){var l=i.evaluate(e)[0];n*=l,e>i.parameterPositions[1]&&(this.stopFading(),l===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n},_updateTimeScale:function(e){var n=0;if(!this.paused){n=this.timeScale;var i=this._timeScaleInterpolant;if(i!==null){var l=i.evaluate(e)[0];n*=l,e>i.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n},_updateTime:function(e){var n=this.time+e,i=this._clip.duration,l=this.loop,h=this._loopCount,p=l===o2;if(e===0)return h===-1?n:p&&(h&1)===1?i-n:n;if(l===r2){h===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=i)n=i;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(h===-1&&(e>=0?(h=0,this._setEndings(!0,this.repetitions===0,p)):this._setEndings(this.repetitions===0,!0,p)),n>=i||n<0){var _=Math.floor(n/i);n-=i*_,h+=Math.abs(_);var s=this.repetitions-h;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?i:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(s===1){var M=e<0;this._setEndings(M,!M,p)}else this._setEndings(!1,!1,p);this._loopCount=h,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:_})}}else this.time=n;if(p&&(h&1)===1)return i-n}return n},_setEndings:function(e,n,i){var l=this._interpolantSettings;i?(l.endingStart=rc,l.endingEnd=rc):(e?l.endingStart=this.zeroSlopeAtStart?rc:ic:l.endingStart=Zp,n?l.endingEnd=this.zeroSlopeAtEnd?rc:ic:l.endingEnd=Zp)},_scheduleFading:function(e,n,i){var l=this._mixer,h=l.time,p=this._weightInterpolant;p===null&&(p=l._lendControlInterpolant(),this._weightInterpolant=p);var _=p.parameterPositions,s=p.sampleValues;return _[0]=h,s[0]=n,_[1]=h+e,s[1]=i,this}});function o1(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}o1.prototype=Object.assign(Object.create(To.prototype),{constructor:o1,_bindAction:function(e,n){var i=e._localRoot||this._root,l=e._clip.tracks,h=l.length,p=e._propertyBindings,_=e._interpolants,s=i.uuid,M=this._bindingsByRootAndName,T=M[s];T===void 0&&(T={},M[s]=T);for(var C=0;C!==h;++C){var E=l[C],L=E.name,I=T[L];if(I!==void 0)p[C]=I;else{if(I=p[C],I!==void 0){I._cacheIndex===null&&(++I.referenceCount,this._addInactiveBinding(I,s,L));continue}var B=n&&n._propertyBindings[C].binding.parsedPath;I=new i1(mr.create(i,L,B),E.ValueTypeName,E.getValueSize()),++I.referenceCount,this._addInactiveBinding(I,s,L),p[C]=I}_[C].resultBuffer=I.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){var n=(e._localRoot||this._root).uuid,i=e._clip.uuid,l=this._actionsByClip[i];this._bindAction(e,l&&l.knownActions[0]),this._addInactiveAction(e,i,n)}for(var h=e._propertyBindings,p=0,_=h.length;p!==_;++p){var s=h[p];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var n=e._propertyBindings,i=0,l=n.length;i!==l;++i){var h=n[i];--h.useCount===0&&(h.restoreOriginalState(),this._takeBackBinding(h))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var n=e._cacheIndex;return n!==null&&n<this._nActiveActions},_addInactiveAction:function(e,n,i){var l=this._actions,h=this._actionsByClip,p=h[n];if(p===void 0)p={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,h[n]=p;else{var _=p.knownActions;e._byClipCacheIndex=_.length,_.push(e)}e._cacheIndex=l.length,l.push(e),p.actionByRoot[i]=e},_removeInactiveAction:function(e){var n=this._actions,i=n[n.length-1],l=e._cacheIndex;i._cacheIndex=l,n[l]=i,n.pop(),e._cacheIndex=null;var h=e._clip.uuid,p=this._actionsByClip,_=p[h],s=_.knownActions,M=s[s.length-1],T=e._byClipCacheIndex;M._byClipCacheIndex=T,s[T]=M,s.pop(),e._byClipCacheIndex=null;var C=_.actionByRoot,E=(e._localRoot||this._root).uuid;delete C[E],s.length===0&&delete p[h],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var n=e._propertyBindings,i=0,l=n.length;i!==l;++i){var h=n[i];--h.referenceCount===0&&this._removeInactiveBinding(h)}},_lendAction:function(e){var n=this._actions,i=e._cacheIndex,l=this._nActiveActions++,h=n[l];e._cacheIndex=l,n[l]=e,h._cacheIndex=i,n[i]=h},_takeBackAction:function(e){var n=this._actions,i=e._cacheIndex,l=--this._nActiveActions,h=n[l];e._cacheIndex=l,n[l]=e,h._cacheIndex=i,n[i]=h},_addInactiveBinding:function(e,n,i){var l=this._bindingsByRootAndName,h=l[n],p=this._bindings;h===void 0&&(h={},l[n]=h),h[i]=e,e._cacheIndex=p.length,p.push(e)},_removeInactiveBinding:function(e){var n=this._bindings,i=e.binding,l=i.rootNode.uuid,h=i.path,p=this._bindingsByRootAndName,_=p[l],s=n[n.length-1],M=e._cacheIndex;s._cacheIndex=M,n[M]=s,n.pop(),delete _[h],Object.keys(_).length===0&&delete p[l]},_lendBinding:function(e){var n=this._bindings,i=e._cacheIndex,l=this._nActiveBindings++,h=n[l];e._cacheIndex=l,n[l]=e,h._cacheIndex=i,n[i]=h},_takeBackBinding:function(e){var n=this._bindings,i=e._cacheIndex,l=--this._nActiveBindings,h=n[l];e._cacheIndex=l,n[l]=e,h._cacheIndex=i,n[i]=h},_lendControlInterpolant:function(){var e=this._controlInterpolants,n=this._nActiveControlInterpolants++,i=e[n];return i===void 0&&(i=new Xf(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=n,e[n]=i),i},_takeBackControlInterpolant:function(e){var n=this._controlInterpolants,i=e.__cacheIndex,l=--this._nActiveControlInterpolants,h=n[l];e.__cacheIndex=l,n[l]=e,h.__cacheIndex=i,n[i]=h},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,n){var i=n||this._root,l=i.uuid,h=typeof e=="string"?va.findByName(i,e):e,p=h!==null?h.uuid:e,_=this._actionsByClip[p],s=null;if(_!==void 0){var M=_.actionByRoot[l];if(M!==void 0)return M;s=_.knownActions[0],h===null&&(h=s._clip)}if(h===null)return null;var T=new a1(this,h,n);return this._bindAction(T,s),this._addInactiveAction(T,p,l),T},existingAction:function(e,n){var i=n||this._root,l=i.uuid,h=typeof e=="string"?va.findByName(i,e):e,p=h?h.uuid:e,_=this._actionsByClip[p];return _!==void 0&&_.actionByRoot[l]||null},stopAllAction:function(){var e=this._actions,n=this._nActiveActions,i=this._bindings,l=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var h=0;h!==n;++h)e[h].reset();for(var h=0;h!==l;++h)i[h].useCount=0;return this},update:function(e){e*=this.timeScale;for(var n=this._actions,i=this._nActiveActions,l=this.time+=e,h=Math.sign(e),p=this._accuIndex^=1,_=0;_!==i;++_){var s=n[_];s._update(l,e,h,p)}for(var M=this._bindings,T=this._nActiveBindings,_=0;_!==T;++_)M[_].apply(p);return this},setTime:function(e){this.time=0;for(var n=0;n<this._actions.length;n++)this._actions[n].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){var n=this._actions,i=e.uuid,l=this._actionsByClip,h=l[i];if(h!==void 0){for(var p=h.knownActions,_=0,s=p.length;_!==s;++_){var M=p[_];this._deactivateAction(M);var T=M._cacheIndex,C=n[n.length-1];M._cacheIndex=null,M._byClipCacheIndex=null,C._cacheIndex=T,n[T]=C,n.pop(),this._removeInactiveBindingsForAction(M)}delete l[i]}},uncacheRoot:function(e){var n=e.uuid,i=this._actionsByClip;for(var l in i){var h=i[l].actionByRoot,p=h[n];p!==void 0&&(this._deactivateAction(p),this._removeInactiveAction(p))}var _=this._bindingsByRootAndName,s=_[n];if(s!==void 0)for(var M in s){var T=s[M];T.restoreOriginalState(),this._removeInactiveBinding(T)}},uncacheAction:function(e,n){var i=this.existingAction(e,n);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}});function py(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}py.prototype.clone=function(){return new py(this.value.clone===void 0?this.value:this.value.clone())};function s1(e,n,i){zo.call(this,e,n),this.meshPerAttribute=i||1}s1.prototype=Object.assign(Object.create(zo.prototype),{constructor:s1,isInstancedInterleavedBuffer:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}});function dP(e,n,i,l){this.ray=new dc(e,n),this.near=i||0,this.far=l||1/0,this.camera=null,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function l1(e,n){return e.distance-n.distance}function fy(e,n,i,l){if(e.visible!==!1&&(e.raycast(n,i),l===!0))for(var h=e.children,p=0,_=h.length;p<_;p++)fy(h[p],n,i,!0)}Object.assign(dP.prototype,{linePrecision:1,set:function(e,n){this.ray.set(e,n)},setFromCamera:function(e,n){n&&n.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(n.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(n).sub(this.ray.origin).normalize(),this.camera=n):n&&n.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(n.near+n.far)/(n.near-n.far)).unproject(n),this.ray.direction.set(0,0,-1).transformDirection(n.matrixWorld),this.camera=n):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,n,i){var l=i||[];return fy(e,this,l,n),l.sort(l1),l},intersectObjects:function(e,n,i){var l=i||[];if(Array.isArray(e)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),l;for(var h=0,p=e.length;h<p;h++)fy(e[h],this,l,n);return l.sort(l1),l}});function pP(e,n,i){return this.radius=e!==void 0?e:1,this.phi=n!==void 0?n:0,this.theta=i!==void 0?i:0,this}Object.assign(pP.prototype,{set:function(e,n,i){return this.radius=e,this.phi=n,this.theta=i,this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){var e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,n,i){return this.radius=Math.sqrt(e*e+n*n+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Wn.clamp(n/this.radius,-1,1))),this}});function fP(e,n,i){return this.radius=e!==void 0?e:1,this.theta=n!==void 0?n:0,this.y=i!==void 0?i:0,this}Object.assign(fP.prototype,{set:function(e,n,i){return this.radius=e,this.theta=n,this.y=i,this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this},setFromVector3:function(e){return this.setFromCartesianCoords(e.x,e.y,e.z)},setFromCartesianCoords:function(e,n,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=n,this}});var c1=new Lt;function u1(e,n){this.min=e!==void 0?e:new Lt(1/0,1/0),this.max=n!==void 0?n:new Lt(-1/0,-1/0)}Object.assign(u1.prototype,{set:function(e,n){return this.min.copy(e),this.max.copy(n),this},setFromPoints:function(e){this.makeEmpty();for(var n=0,i=e.length;n<i;n++)this.expandByPoint(e[n]);return this},setFromCenterAndSize:function(e,n){var i=c1.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(e){return e===void 0&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new Lt),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return e===void 0&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new Lt),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,n){return n===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),n=new Lt),n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)},clampPoint:function(e,n){return n===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),n=new Lt),n.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var n=c1.copy(e).clamp(this.min,this.max);return n.sub(e).length()},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var h1=new Ee,em=new Ee;function d1(e,n){this.start=e!==void 0?e:new Ee,this.end=n!==void 0?n:new Ee}Object.assign(d1.prototype,{set:function(e,n){return this.start.copy(e),this.end.copy(n),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return e===void 0&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new Ee),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return e===void 0&&(console.warn("THREE.Line3: .delta() target is now required"),e=new Ee),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,n){return n===void 0&&(console.warn("THREE.Line3: .at() target is now required"),n=new Ee),this.delta(n).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,n){h1.subVectors(e,this.start),em.subVectors(this.end,this.start);var i=em.dot(em),l=em.dot(h1),h=l/i;return n&&(h=Wn.clamp(h,0,1)),h},closestPointToPoint:function(e,n,i){var l=this.closestPointToPointParameter(e,n);return i===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new Ee),this.delta(i).multiplyScalar(l).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}});function tm(e){rn.call(this),this.material=e,this.render=function(){}}tm.prototype=Object.create(rn.prototype),tm.prototype.constructor=tm,tm.prototype.isImmediateRenderObject=!0;var p1=new Ee;function td(e,n){rn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;for(var i=new yn,l=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],h=0,p=1,_=32;h<_;h++,p++){var s=h/_*Math.PI*2,M=p/_*Math.PI*2;l.push(Math.cos(s),Math.sin(s),1,Math.cos(M),Math.sin(M),1)}i.setAttribute("position",new sn(l,3));var T=new Ri({fog:!1});this.cone=new Vi(i,T),this.add(this.cone),this.update()}td.prototype=Object.create(rn.prototype),td.prototype.constructor=td,td.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},td.prototype.update=function(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,n=e*Math.tan(this.light.angle);this.cone.scale.set(n,n,e),p1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(p1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var hs=new Ee,nm=new jn,my=new jn;function f1(e){var n=[];e&&e.isBone&&n.push(e);for(var i=0;i<e.children.length;i++)n.push.apply(n,f1(e.children[i]));return n}function nd(e){for(var n=f1(e),i=new yn,l=[],h=[],p=new en(0,0,1),_=new en(0,1,0),s=0;s<n.length;s++){var M=n[s];M.parent&&M.parent.isBone&&(l.push(0,0,0),l.push(0,0,0),h.push(p.r,p.g,p.b),h.push(_.r,_.g,_.b))}i.setAttribute("position",new sn(l,3)),i.setAttribute("color",new sn(h,3));var T=new Ri({vertexColors:Kl,depthTest:!1,depthWrite:!1,transparent:!0});Vi.call(this,i,T),this.root=e,this.bones=n,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}nd.prototype=Object.create(Vi.prototype),nd.prototype.constructor=nd,nd.prototype.updateMatrixWorld=function(e){var n=this.bones,i=this.geometry,l=i.getAttribute("position");my.getInverse(this.root.matrixWorld);for(var h=0,p=0;h<n.length;h++){var _=n[h];_.parent&&_.parent.isBone&&(nm.multiplyMatrices(my,_.matrixWorld),hs.setFromMatrixPosition(nm),l.setXYZ(p,hs.x,hs.y,hs.z),nm.multiplyMatrices(my,_.parent.matrixWorld),hs.setFromMatrixPosition(nm),l.setXYZ(p+1,hs.x,hs.y,hs.z),p+=2)}i.getAttribute("position").needsUpdate=!0,rn.prototype.updateMatrixWorld.call(this,e)};function id(e,n,i){this.light=e,this.light.updateMatrixWorld(),this.color=i;var l=new Bc(n,4,2),h=new lr({wireframe:!0,fog:!1});Ai.call(this,l,h),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}id.prototype=Object.create(Ai.prototype),id.prototype.constructor=id,id.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},id.prototype.update=function(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)};var mP=new Ee,m1=new en,g1=new en;function rd(e,n,i){rn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;var l=new Ic(n);l.rotateY(Math.PI*.5),this.material=new lr({wireframe:!0,fog:!1}),this.color===void 0&&(this.material.vertexColors=Kl);var h=l.getAttribute("position"),p=new Float32Array(h.count*3);l.setAttribute("color",new zn(p,3)),this.add(new Ai(l,this.material)),this.update()}rd.prototype=Object.create(rn.prototype),rd.prototype.constructor=rd,rd.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},rd.prototype.update=function(){var e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{var n=e.geometry.getAttribute("color");m1.copy(this.light.color),g1.copy(this.light.groundColor);for(var i=0,l=n.count;i<l;i++){var h=i<l/2?m1:g1;n.setXYZ(i,h.r,h.g,h.b)}n.needsUpdate=!0}e.lookAt(mP.setFromMatrixPosition(this.light.matrixWorld).negate())};function gy(e,n,i,l){e=e||10,n=n||10,i=new en(i!==void 0?i:4473924),l=new en(l!==void 0?l:8947848);for(var h=n/2,p=e/n,_=e/2,s=[],M=[],T=0,C=0,E=-_;T<=n;T++,E+=p){s.push(-_,0,E,_,0,E),s.push(E,0,-_,E,0,_);var L=T===h?i:l;L.toArray(M,C),C+=3,L.toArray(M,C),C+=3,L.toArray(M,C),C+=3,L.toArray(M,C),C+=3}var I=new yn;I.setAttribute("position",new sn(s,3)),I.setAttribute("color",new sn(M,3));var B=new Ri({vertexColors:Kl});Vi.call(this,I,B)}gy.prototype=Object.assign(Object.create(Vi.prototype),{constructor:gy,copy:function(e){return Vi.prototype.copy.call(this,e),this.geometry.copy(e.geometry),this.material.copy(e.material),this},clone:function(){return new this.constructor().copy(this)}});function _y(e,n,i,l,h,p){e=e||10,n=n||16,i=i||8,l=l||64,h=new en(h!==void 0?h:4473924),p=new en(p!==void 0?p:8947848);var _=[],s=[],M,T,C,E,L,I,B;for(E=0;E<=n;E++)C=E/n*(Math.PI*2),M=Math.sin(C)*e,T=Math.cos(C)*e,_.push(0,0,0),_.push(M,0,T),B=E&1?h:p,s.push(B.r,B.g,B.b),s.push(B.r,B.g,B.b);for(E=0;E<=i;E++)for(B=E&1?h:p,I=e-e/i*E,L=0;L<l;L++)C=L/l*(Math.PI*2),M=Math.sin(C)*I,T=Math.cos(C)*I,_.push(M,0,T),s.push(B.r,B.g,B.b),C=(L+1)/l*(Math.PI*2),M=Math.sin(C)*I,T=Math.cos(C)*I,_.push(M,0,T),s.push(B.r,B.g,B.b);var O=new yn;O.setAttribute("position",new sn(_,3)),O.setAttribute("color",new sn(s,3));var U=new Ri({vertexColors:Kl});Vi.call(this,O,U)}_y.prototype=Object.create(Vi.prototype),_y.prototype.constructor=_y;var _1=new Ee,im=new Ee,y1=new Ee;function ad(e,n,i){rn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,n===void 0&&(n=1);var l=new yn;l.setAttribute("position",new sn([-n,n,0,n,n,0,n,-n,0,-n,-n,0,-n,n,0],3));var h=new Ri({fog:!1});this.lightPlane=new sa(l,h),this.add(this.lightPlane),l=new yn,l.setAttribute("position",new sn([0,0,0,0,0,1],3)),this.targetLine=new sa(l,h),this.add(this.targetLine),this.update()}ad.prototype=Object.create(rn.prototype),ad.prototype.constructor=ad,ad.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},ad.prototype.update=function(){_1.setFromMatrixPosition(this.light.matrixWorld),im.setFromMatrixPosition(this.light.target.matrixWorld),y1.subVectors(im,_1),this.lightPlane.lookAt(im),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(im),this.targetLine.scale.z=y1.length()};var rm=new Ee,zi=new Io;function am(e){var n=new yn,i=new Ri({color:16777215,vertexColors:tT}),l=[],h=[],p={},_=new en(16755200),s=new en(16711680),M=new en(43775),T=new en(16777215),C=new en(3355443);E("n1","n2",_),E("n2","n4",_),E("n4","n3",_),E("n3","n1",_),E("f1","f2",_),E("f2","f4",_),E("f4","f3",_),E("f3","f1",_),E("n1","f1",_),E("n2","f2",_),E("n3","f3",_),E("n4","f4",_),E("p","n1",s),E("p","n2",s),E("p","n3",s),E("p","n4",s),E("u1","u2",M),E("u2","u3",M),E("u3","u1",M),E("c","t",T),E("p","c",C),E("cn1","cn2",C),E("cn3","cn4",C),E("cf1","cf2",C),E("cf3","cf4",C);function E(I,B,O){L(I,O),L(B,O)}function L(I,B){l.push(0,0,0),h.push(B.r,B.g,B.b),p[I]===void 0&&(p[I]=[]),p[I].push(l.length/3-1)}n.setAttribute("position",new sn(l,3)),n.setAttribute("color",new sn(h,3)),Vi.call(this,n,i),this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=p,this.update()}am.prototype=Object.create(Vi.prototype),am.prototype.constructor=am,am.prototype.update=function(){var e=this.geometry,n=this.pointMap,i=1,l=1;zi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Hi("c",n,e,zi,0,0,-1),Hi("t",n,e,zi,0,0,1),Hi("n1",n,e,zi,-i,-l,-1),Hi("n2",n,e,zi,i,-l,-1),Hi("n3",n,e,zi,-i,l,-1),Hi("n4",n,e,zi,i,l,-1),Hi("f1",n,e,zi,-i,-l,1),Hi("f2",n,e,zi,i,-l,1),Hi("f3",n,e,zi,-i,l,1),Hi("f4",n,e,zi,i,l,1),Hi("u1",n,e,zi,i*.7,l*1.1,-1),Hi("u2",n,e,zi,-i*.7,l*1.1,-1),Hi("u3",n,e,zi,0,l*2,-1),Hi("cf1",n,e,zi,-i,0,1),Hi("cf2",n,e,zi,i,0,1),Hi("cf3",n,e,zi,0,-l,1),Hi("cf4",n,e,zi,0,l,1),Hi("cn1",n,e,zi,-i,0,-1),Hi("cn2",n,e,zi,i,0,-1),Hi("cn3",n,e,zi,0,-l,-1),Hi("cn4",n,e,zi,0,l,-1),e.getAttribute("position").needsUpdate=!0};function Hi(e,n,i,l,h,p,_){rm.set(h,p,_).unproject(l);var s=n[e];if(s!==void 0)for(var M=i.getAttribute("position"),T=0,C=s.length;T<C;T++)M.setXYZ(s[T],rm.x,rm.y,rm.z)}var om=new Pa;function ml(e,n){this.object=e,n===void 0&&(n=16776960);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),l=new Float32Array(8*3),h=new yn;h.setIndex(new zn(i,1)),h.setAttribute("position",new zn(l,3)),Vi.call(this,h,new Ri({color:n})),this.matrixAutoUpdate=!1,this.update()}ml.prototype=Object.create(Vi.prototype),ml.prototype.constructor=ml,ml.prototype.update=function(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&om.setFromObject(this.object),!om.isEmpty()){var n=om.min,i=om.max,l=this.geometry.attributes.position,h=l.array;h[0]=i.x,h[1]=i.y,h[2]=i.z,h[3]=n.x,h[4]=i.y,h[5]=i.z,h[6]=n.x,h[7]=n.y,h[8]=i.z,h[9]=i.x,h[10]=n.y,h[11]=i.z,h[12]=i.x,h[13]=i.y,h[14]=n.z,h[15]=n.x,h[16]=i.y,h[17]=n.z,h[18]=n.x,h[19]=n.y,h[20]=n.z,h[21]=i.x,h[22]=n.y,h[23]=n.z,l.needsUpdate=!0,this.geometry.computeBoundingSphere()}},ml.prototype.setFromObject=function(e){return this.object=e,this.update(),this},ml.prototype.copy=function(e){return Vi.prototype.copy.call(this,e),this.object=e.object,this},ml.prototype.clone=function(){return new this.constructor().copy(this)};function sm(e,n){this.type="Box3Helper",this.box=e,n=n||16776960;var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),l=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],h=new yn;h.setIndex(new zn(i,1)),h.setAttribute("position",new sn(l,3)),Vi.call(this,h,new Ri({color:n})),this.geometry.computeBoundingSphere()}sm.prototype=Object.create(Vi.prototype),sm.prototype.constructor=sm,sm.prototype.updateMatrixWorld=function(e){var n=this.box;n.isEmpty()||(n.getCenter(this.position),n.getSize(this.scale),this.scale.multiplyScalar(.5),rn.prototype.updateMatrixWorld.call(this,e))};function lm(e,n,i){this.type="PlaneHelper",this.plane=e,this.size=n===void 0?1:n;var l=i!==void 0?i:16776960,h=[1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],p=new yn;p.setAttribute("position",new sn(h,3)),p.computeBoundingSphere(),sa.call(this,p,new Ri({color:l}));var _=[1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],s=new yn;s.setAttribute("position",new sn(_,3)),s.computeBoundingSphere(),this.add(new Ai(s,new lr({color:l,opacity:.2,transparent:!0,depthWrite:!1})))}lm.prototype=Object.create(sa.prototype),lm.prototype.constructor=lm,lm.prototype.updateMatrixWorld=function(e){var n=-this.plane.constant;Math.abs(n)<1e-8&&(n=1e-8),this.scale.set(.5*this.size,.5*this.size,n),this.children[0].material.side=n<0?tr:Jl,this.lookAt(this.plane.normal),rn.prototype.updateMatrixWorld.call(this,e)};var v1=new Ee,cm,yy;function ds(e,n,i,l,h,p){rn.call(this),e===void 0&&(e=new Ee(0,0,1)),n===void 0&&(n=new Ee(0,0,0)),i===void 0&&(i=1),l===void 0&&(l=16776960),h===void 0&&(h=.2*i),p===void 0&&(p=.2*h),cm===void 0&&(cm=new yn,cm.setAttribute("position",new sn([0,0,0,0,1,0],3)),yy=new ls(0,.5,1,5,1),yy.translate(0,-.5,0)),this.position.copy(n),this.line=new sa(cm,new Ri({color:l})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ai(yy,new lr({color:l})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,h,p)}ds.prototype=Object.create(rn.prototype),ds.prototype.constructor=ds,ds.prototype.setDirection=function(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{v1.set(e.z,0,-e.x).normalize();var n=Math.acos(e.y);this.quaternion.setFromAxisAngle(v1,n)}},ds.prototype.setLength=function(e,n,i){n===void 0&&(n=.2*e),i===void 0&&(i=.2*n),this.line.scale.set(1,Math.max(1e-4,e-n),1),this.line.updateMatrix(),this.cone.scale.set(i,n,i),this.cone.position.y=e,this.cone.updateMatrix()},ds.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},ds.prototype.copy=function(e){return rn.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},ds.prototype.clone=function(){return new this.constructor().copy(this)};function vy(e){e=e||1;var n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],l=new yn;l.setAttribute("position",new sn(n,3)),l.setAttribute("color",new sn(i,3));var h=new Ri({vertexColors:Kl});Vi.call(this,l,h)}vy.prototype=Object.create(Vi.prototype),vy.prototype.constructor=vy;var Jc=4,ps=8,eo=Math.pow(2,ps),x1=[.125,.215,.35,.446,.526,.582],b1=ps-Jc+1+x1.length,Kc=20,to={[ia]:0,[hh]:1,[Kg]:2,[S0]:3,[A0]:4,[C0]:5,[E0]:6},xy=new $c,um=vP(Kc),fs=null,ms=null,{_lodPlanes:od,_sizeLods:w1,_sigmas:hm}=gP(),dm=null,_i=null,by=null,gl=(1+Math.sqrt(5))/2,Qc=1/gl,M1=[new Ee(1,1,1),new Ee(-1,1,1),new Ee(1,1,-1),new Ee(-1,1,-1),new Ee(0,gl,Qc),new Ee(0,gl,-Qc),new Ee(Qc,0,gl),new Ee(-Qc,0,gl),new Ee(gl,Qc,0),new Ee(-gl,Qc,0)];function T1(e){_i=e,wy(um)}T1.prototype={constructor:T1,fromScene:function(e,n=0,i=.1,l=100){by=_i.getRenderTarget();var h=E1();return _P(e,i,l,h),n>0&&P1(h,0,0,n),C1(h),S1(h),h},fromEquirectangular:function(e){return e.magFilter=Ui,e.minFilter=Ui,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){by=_i.getRenderTarget();var n=E1(e);return yP(e,n),C1(n),S1(n),n},compileCubemapShader:function(){ms==null&&(ms=I1(),wy(ms))},compileEquirectangularShader:function(){fs==null&&(fs=D1(),wy(fs))},dispose:function(){um.dispose(),ms!=null&&ms.dispose(),fs!=null&&fs.dispose();for(var e=0;e<od.length;e++)od[e].dispose()}};function gP(){for(var e=[],n=[],i=[],l=ps,h=0;h<b1;h++){var p=Math.pow(2,l);n.push(p);var _=1/p;h>ps-Jc?_=x1[h-ps+Jc-1]:h==0&&(_=0),i.push(_);for(var s=1/(p-1),M=-s/2,T=1+s/2,C=[M,M,T,M,T,T,M,M,T,T,M,T],E=6,L=6,I=3,B=2,O=1,U=new Float32Array(I*L*E),q=new Float32Array(B*L*E),ee=new Float32Array(O*L*E),he=0;he<E;he++){var Ce=he%3*2/3-1,K=he>2?0:-1,ie=[Ce,K,0,Ce+2/3,K,0,Ce+2/3,K+1,0,Ce,K,0,Ce+2/3,K+1,0,Ce,K+1,0];U.set(ie,I*L*he),q.set(C,B*L*he);var ue=[he,he,he,he,he,he];ee.set(ue,O*L*he)}var ae=new yn;ae.setAttribute("position",new zn(U,I)),ae.setAttribute("uv",new zn(q,B)),ae.setAttribute("faceIndex",new zn(ee,O)),e.push(ae),l>Jc&&l--}return{_lodPlanes:e,_sizeLods:n,_sigmas:i}}function E1(e){var n={magFilter:Ui,minFilter:Ui,generateMipmaps:!1,type:e?e.type:Wp,format:e?e.format:BT,encoding:e?e.encoding:Kg,depthBuffer:!1,stencilBuffer:!1},i=A1(n);return i.depthBuffer=!e,dm=A1(n),i}function S1(e){dm.dispose(),_i.setRenderTarget(by),e.scissorTest=!1,e.setSize(e.width,e.height)}function _P(e,n,i,l){var h=90,p=1,_=new Xi(h,p,n,i),s=[1,1,1,1,-1,1],M=[1,1,-1,-1,-1,1],T=_i.outputEncoding,C=_i.toneMapping,E=_i.toneMappingExposure,L=_i.getClearColor(),I=_i.getClearAlpha();_i.toneMapping=Hg,_i.toneMappingExposure=1,_i.outputEncoding=ia,e.scale.z*=-1;var B=e.background;if(B&&B.isColor){B.convertSRGBToLinear();var O=Math.max(B.r,B.g,B.b),U=Math.min(Math.max(Math.ceil(Math.log2(O)),-128),127);B=B.multiplyScalar(Math.pow(2,-U));var q=(U+128)/255;_i.setClearColor(B,q),e.background=null}for(var ee=0;ee<6;ee++){var he=ee%3;he==0?(_.up.set(0,s[ee],0),_.lookAt(M[ee],0,0)):he==1?(_.up.set(0,0,s[ee]),_.lookAt(0,M[ee],0)):(_.up.set(0,s[ee],0),_.lookAt(0,0,M[ee])),My(l,he*eo,ee>2?eo:0,eo,eo),_i.setRenderTarget(l),_i.render(e,_)}_i.toneMapping=C,_i.toneMappingExposure=E,_i.outputEncoding=T,_i.setClearColor(L,I),e.scale.z*=-1}function yP(e,n){var i=new So;e.isCubeTexture?ms==null&&(ms=I1()):fs==null&&(fs=D1());var l=e.isCubeTexture?ms:fs;i.add(new Ai(od[0],l));var h=l.uniforms;h.envMap.value=e,e.isCubeTexture||h.texelSize.value.set(1/e.image.width,1/e.image.height),h.inputEncoding.value=to[e.encoding],h.outputEncoding.value=to[e.encoding],My(n,0,0,3*eo,2*eo),_i.setRenderTarget(n),_i.render(i,xy)}function wy(e){var n=new So;n.add(new Ai(od[0],e)),_i.compile(n,xy)}function A1(e){var n=new Mr(3*eo,3*eo,e);return n.texture.mapping=oh,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function My(e,n,i,l,h){e.viewport.set(n,i,l,h),e.scissor.set(n,i,l,h)}function C1(e){var n=_i.autoClear;_i.autoClear=!1;for(var i=1;i<b1;i++){var l=Math.sqrt(hm[i]*hm[i]-hm[i-1]*hm[i-1]),h=M1[(i-1)%M1.length];P1(e,i-1,i,l,h)}_i.autoClear=n}function P1(e,n,i,l,h){L1(e,dm,n,i,l,"latitudinal",h),L1(dm,e,i,i,l,"longitudinal",h)}function L1(e,n,i,l,h,p,_){p!=="latitudinal"&&p!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");var s=3,M=new So;M.add(new Ai(od[l],um));var T=um.uniforms,C=w1[i]-1,E=isFinite(h)?Math.PI/(2*C):2*Math.PI/(2*Kc-1),L=h/E,I=isFinite(h)?1+Math.floor(s*L):Kc;I>Kc&&console.warn(`sigmaRadians, ${h}, is too large and will clip, as it requested ${I} samples when the maximum is set to ${Kc}`);for(var B=[],O=0,U=0;U<Kc;++U){var he=U/L,q=Math.exp(-he*he/2);B.push(q),U==0?O+=q:U<I&&(O+=2*q)}for(var U=0;U<B.length;U++)B[U]=B[U]/O;T.envMap.value=e.texture,T.samples.value=I,T.weights.value=B,T.latitudinal.value=p==="latitudinal",_&&(T.poleAxis.value=_),T.dTheta.value=E,T.mipInt.value=ps-i,T.inputEncoding.value=to[e.texture.encoding],T.outputEncoding.value=to[e.texture.encoding];var ee=w1[l],he=3*Math.max(0,eo-2*ee),Ce=(l===0?0:2*eo)+2*ee*(l>ps-Jc?l-ps+Jc:0);My(n,he,Ce,3*ee,2*ee),_i.setRenderTarget(n),_i.render(M,xy)}function vP(e){var n=new Float32Array(e),i=new Ee(0,1,0),l=new cs({defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:to[ia]},outputEncoding:{value:to[ia]}},vertexShader:Ty(),fragmentShader:`
  2709. precision mediump float;
  2710. precision mediump int;
  2711. varying vec3 vOutputDirection;
  2712. uniform sampler2D envMap;
  2713. uniform int samples;
  2714. uniform float weights[n];
  2715. uniform bool latitudinal;
  2716. uniform float dTheta;
  2717. uniform float mipInt;
  2718. uniform vec3 poleAxis;
  2719. ${Ey()}
  2720. #define ENVMAP_TYPE_CUBE_UV
  2721. #include <cube_uv_reflection_fragment>
  2722. void main() {
  2723. gl_FragColor = vec4(0.0);
  2724. for (int i = 0; i < n; i++) {
  2725. if (i >= samples)
  2726. break;
  2727. for (int dir = -1; dir < 2; dir += 2) {
  2728. if (i == 0 && dir == 1)
  2729. continue;
  2730. vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
  2731. if (all(equal(axis, vec3(0.0))))
  2732. axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);
  2733. axis = normalize(axis);
  2734. float theta = dTheta * float(dir * i);
  2735. float cosTheta = cos(theta);
  2736. // Rodrigues' axis-angle rotation
  2737. vec3 sampleDirection = vOutputDirection * cosTheta
  2738. + cross(axis, vOutputDirection) * sin(theta)
  2739. + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
  2740. gl_FragColor.rgb +=
  2741. weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);
  2742. }
  2743. }
  2744. gl_FragColor = linearToOutputTexel(gl_FragColor);
  2745. }
  2746. `,blending:Qo,depthTest:!1,depthWrite:!1});return l.type="SphericalGaussianBlur",l}function D1(){var e=new Lt(1,1),n=new cs({uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:to[ia]},outputEncoding:{value:to[ia]}},vertexShader:Ty(),fragmentShader:`
  2747. precision mediump float;
  2748. precision mediump int;
  2749. varying vec3 vOutputDirection;
  2750. uniform sampler2D envMap;
  2751. uniform vec2 texelSize;
  2752. ${Ey()}
  2753. #define RECIPROCAL_PI 0.31830988618
  2754. #define RECIPROCAL_PI2 0.15915494
  2755. void main() {
  2756. gl_FragColor = vec4(0.0);
  2757. vec3 outputDirection = normalize(vOutputDirection);
  2758. vec2 uv;
  2759. uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;
  2760. uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;
  2761. vec2 f = fract(uv / texelSize - 0.5);
  2762. uv -= f * texelSize;
  2763. vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  2764. uv.x += texelSize.x;
  2765. vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  2766. uv.y += texelSize.y;
  2767. vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  2768. uv.x -= texelSize.x;
  2769. vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
  2770. vec3 tm = mix(tl, tr, f.x);
  2771. vec3 bm = mix(bl, br, f.x);
  2772. gl_FragColor.rgb = mix(tm, bm, f.y);
  2773. gl_FragColor = linearToOutputTexel(gl_FragColor);
  2774. }
  2775. `,blending:Qo,depthTest:!1,depthWrite:!1});return n.type="EquirectangularToCubeUV",n}function I1(){var e=new cs({uniforms:{envMap:{value:null},inputEncoding:{value:to[ia]},outputEncoding:{value:to[ia]}},vertexShader:Ty(),fragmentShader:`
  2776. precision mediump float;
  2777. precision mediump int;
  2778. varying vec3 vOutputDirection;
  2779. uniform samplerCube envMap;
  2780. ${Ey()}
  2781. void main() {
  2782. gl_FragColor = vec4(0.0);
  2783. gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;
  2784. gl_FragColor = linearToOutputTexel(gl_FragColor);
  2785. }
  2786. `,blending:Qo,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function Ty(){return`
  2787. precision mediump float;
  2788. precision mediump int;
  2789. attribute vec3 position;
  2790. attribute vec2 uv;
  2791. attribute float faceIndex;
  2792. varying vec3 vOutputDirection;
  2793. vec3 getDirection(vec2 uv, float face) {
  2794. uv = 2.0 * uv - 1.0;
  2795. vec3 direction = vec3(uv, 1.0);
  2796. if (face == 0.0) {
  2797. direction = direction.zyx;
  2798. direction.z *= -1.0;
  2799. } else if (face == 1.0) {
  2800. direction = direction.xzy;
  2801. direction.z *= -1.0;
  2802. } else if (face == 3.0) {
  2803. direction = direction.zyx;
  2804. direction.x *= -1.0;
  2805. } else if (face == 4.0) {
  2806. direction = direction.xzy;
  2807. direction.y *= -1.0;
  2808. } else if (face == 5.0) {
  2809. direction.xz *= -1.0;
  2810. }
  2811. return direction;
  2812. }
  2813. void main() {
  2814. vOutputDirection = getDirection(uv, faceIndex);
  2815. gl_Position = vec4( position, 1.0 );
  2816. }
  2817. `}function Ey(){return`
  2818. uniform int inputEncoding;
  2819. uniform int outputEncoding;
  2820. #include <encodings_pars_fragment>
  2821. vec4 inputTexelToLinear(vec4 value){
  2822. if(inputEncoding == 0){
  2823. return value;
  2824. }else if(inputEncoding == 1){
  2825. return sRGBToLinear(value);
  2826. }else if(inputEncoding == 2){
  2827. return RGBEToLinear(value);
  2828. }else if(inputEncoding == 3){
  2829. return RGBMToLinear(value, 7.0);
  2830. }else if(inputEncoding == 4){
  2831. return RGBMToLinear(value, 16.0);
  2832. }else if(inputEncoding == 5){
  2833. return RGBDToLinear(value, 256.0);
  2834. }else{
  2835. return GammaToLinear(value, 2.2);
  2836. }
  2837. }
  2838. vec4 linearToOutputTexel(vec4 value){
  2839. if(outputEncoding == 0){
  2840. return value;
  2841. }else if(outputEncoding == 1){
  2842. return LinearTosRGB(value);
  2843. }else if(outputEncoding == 2){
  2844. return LinearToRGBE(value);
  2845. }else if(outputEncoding == 3){
  2846. return LinearToRGBM(value, 7.0);
  2847. }else if(outputEncoding == 4){
  2848. return LinearToRGBM(value, 16.0);
  2849. }else if(outputEncoding == 5){
  2850. return LinearToRGBD(value, 256.0);
  2851. }else{
  2852. return LinearToGamma(value, 2.2);
  2853. }
  2854. }
  2855. vec4 envMapTexelToLinear(vec4 color) {
  2856. return inputTexelToLinear(color);
  2857. }
  2858. `}Cn.create=function(e,n){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Cn.prototype),e.prototype.constructor=e,e.prototype.getPoint=n,e},Object.assign(us.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var n=this.getPoints(e);return this.createGeometry(n)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var n=this.getSpacedPoints(e);return this.createGeometry(n)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var n=new Fn,i=0,l=e.length;i<l;i++){var h=e[i];n.vertices.push(new Ee(h.x,h.y,h.z||0))}return n}}),Object.assign(Ka.prototype,{fromPoints:function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),Object.create(ca.prototype),Object.create(ca.prototype);function R1(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),ca.call(this,e),this.type="catmullrom"}R1.prototype=Object.create(ca.prototype),Object.assign(R1.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),gy.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},nd.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(ri.prototype,{extractUrlBase:function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),ul.extractUrlBase(e)}}),ri.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(ly.prototype,{setTexturePath:function(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}),Object.assign(u1.prototype,{center:function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Pa.prototype,{center:function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),wh.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},d1.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Object.assign(Wn,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),Wn.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),Wn.ceilPowerOfTwo(e)}}),Object.assign(dr.prototype,{flattenToArrayOffset:function(e,n){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,n)},multiplyVector3:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(jn.prototype,{extractPosition:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,n){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,n)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new Ee().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,n,i,l,h,p){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,n,l,i,h,p)}}),ja.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Or.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Object.assign(dc.prototype,{isIntersectionBox:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(sr.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,n)},midpoint:function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(sr,{barycoordFromPoint:function(e,n,i,l,h){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),sr.getBarycoord(e,n,i,l,h)},normal:function(e,n,i,l){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),sr.getNormal(e,n,i,l)}}),Object.assign(cl.prototype,{extractAllPoints:function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new kc(this,e)},makeGeometry:function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Fc(this,e)}}),Object.assign(Lt.prototype,{fromAttribute:function(e,n,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,n,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Ee.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,n){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(n,e)},applyProjection:function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},fromAttribute:function(e,n,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,n,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(gi.prototype,{fromAttribute:function(e,n,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,n,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Fn.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.assign(rn.prototype,{getChildByName:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,n){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(n,e)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(rn.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Ai.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Ai.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),s2},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(yf.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(vf.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Dh.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Cn.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),Xi.prototype.setLens=function(e,n){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),n!==void 0&&(this.filmGauge=n),this.setFocalLength(e)},Object.defineProperties(Mi.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(zn.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===dh},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(dh)}}}),Object.assign(zn.prototype,{setDynamic:function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(e===!0?dh:Xp),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(yn.prototype,{addIndex:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addAttribute:function(e,n){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(n&&n.isBufferAttribute)&&!(n&&n.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new zn(arguments[1],arguments[2]))):e==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(n),this):this.setAttribute(e,n)},addDrawCall:function(e,n,i){i!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,n)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(yn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(zo.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===dh},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),Object.assign(zo.prototype,{setDynamic:function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(e===!0?dh:Xp),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(ko.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(py.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Rn.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new en}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===r0}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(ll.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Nr.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign(px.prototype,{clearTarget:function(e,n,i,l){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(n,i,l)},animate:function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(px.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=e===!0?hh:ia}}}),Object.defineProperties(hx.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Mr.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(ed.prototype,{load:{value:function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var n=this,i=new cy;return i.load(e,function(l){n.setBuffer(l)}),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),n1.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},bh.prototype.updateCubeMap=function(e,n){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,n)},Ys.crossOrigin=void 0,Ys.loadTexture=function(e,n,i,l){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var h=new $h;h.setCrossOrigin(this.crossOrigin);var p=h.load(e,i,void 0,l);return n&&(p.mapping=n),p},Ys.loadTextureCube=function(e,n,i,l){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var h=new j_;h.setCrossOrigin(this.crossOrigin);var p=h.load(e,i,void 0,l);return n&&(p.mapping=n),p},Ys.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Ys.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:JM}}));class pm extends tt.MxDbAlignedDimension{constructor(){super()}getDimText(){var n=new Ee(this.point1.x-this.point2.x,this.point1.y-this.point2.y,0),i=n.length();return i.toFixed(2)}create(){return new pm}getTypeName(){return this.constructor.name}}function xP(){return wn(this,null,function*(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(`
  2859. 指定第一点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new pm;l.setPoint1(i),l.setColor(65314);const h=new tt.McEdGetPointWorldDrawObject;h.setDraw(p=>{l.setPoint2(p),h.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(h),e.setMessage(`
  2860. 指定第二点:`),e.setInputToucheType(tt.MxType.InputToucheType.kGetEnd),e.go(p=>{if(p!=0){console.log(p);return}const _=e.value();l.setPoint2(_),tt.MxFun.getCurrentDraw().addMxEntity(l),alert("测试长度是:"+l.getDimText())})})})}function bP(){const e=new tt.MrxDbgUiPrPoint,n=tt.MxFun.getCurrentDraw(),i=new tt.MxDb2LineAngularDimension;i.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const l=new tt.McEdGetPointWorldDrawObject;l.setColor(te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor()),e.setMessage(`
  2861. 指定第一点:`),e.go(h=>{h===0&&(e.setMessage(`
  2862. 指定第二个角度点:`),i.point1=e.value(),l.setDraw((p,_)=>{i.point2=p,_.drawLine(i.point1,p)}),e.setUserDraw(l),e.go(p=>{e.setMessage(`
  2863. 指定最后一个点:`),p===0&&(i.point2=e.value(),l.setDraw((_,s)=>{i.point3=_,l.drawCustomEntity(i)}),e.go(_=>{_===0&&n.addMxEntity(i)}))}))})}function wP(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(`
  2864. 指定坐标点:`),e.go(n=>{if(n!=0)return;const i=e.value();let l=new tt.MxDbCoord;l.point1=i,l.point2=i.clone(),l.color=te.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw((h,p)=>{l.point2=h,p.drawCustomEntity(l)}),e.setMessage(`
  2865. 指定标注点:`),e.go(h=>{if(h!=0){console.log(h);return}l.point2=e.value(),tt.MxFun.addToCurrentSpace(l)})})}function MP(){new pm().rxInit(),tt.MxFun.addCommand("Mx_Linear",xP),tt.MxFun.addCommand("BR_AngleMeasure",bP),tt.MxFun.addCommand("BR_CoordMeasure",wP)}function TP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("select entity:");let i=(yield e.go()).getMcDbEntity();if(i!==null){if(console.log("ent.objectName",i.objectName),i instanceof te.McDbBlockReference){let h=i.explode();if(h.GetCount()==0)return;let p=h.GetCount();for(let _=0;_<p;_++){let s=h.AtObject(_).val;if(s instanceof te.McDbPolyline){let M=s,T=M.numVerts();for(let C=0;C<T;C++){let E=M.getPointAt(C),L=M.getBulgeAt(C);console.log("polyline.pt"+C+":"+Er(E.val)),console.log("polyline.bulge"+C+":"+L)}}}}else if(i instanceof te.McDbPolyline){let l=i,h=l.numVerts();for(let p=0;p<h;p++){let _=l.getPointAt(p),s=l.getBulgeAt(p);console.log("polyline.pt"+p+":"+Er(_.val)),console.log("polyline.bulge"+p+":"+s)}}}})}function EP(){tt.MxFun.addCommand("MxTest_SelectEntity",TP)}class SP{constructor(){this.m_aryColumn=[],this.m_allData=[],this.m_dColumnHeight=14,this.m_dRowHeight=10,this.m_dRowLineWdith=0,this.m_dColumnLineWidth=.5,this.m_dRowTextHeight=6,this.m_dColumnTextHeight=10}addColumn(n,i){this.m_aryColumn.push({name:n,w:i})}addRow(n){this.m_allData.push(n)}}class AP{constructor(){this.data=new SP,this.pt=new te.McGePoint3d,this.dScale=1,this.mxcad=te.MxCpp.getCurrentMxCAD()}draw(n,i){return this.pt=n,this.dScale=i,this.data.m_aryColumn.length==0||this.data.m_allData.length==0?!1:(this.DrawTableHead(),this.DrawContent(),!0)}DrawTableHead(){let n=this.data,i=this.pt.clone(),l=this.pt.clone(),h=new te.McGeVector3d(0,1,0).mult(this.Scale(this.data.m_dColumnHeight));console.log(h);let p=this.Scale(this.data.m_dColumnLineWidth),_=0,s=new te.McGeVector3d(1,0,0);for(let M=0;M<n.m_aryColumn.length;M++){let T=n.m_aryColumn[M];this.DrawLine(l,l.clone().subvec(h),p),this.DrawMCText(l.clone().addvec(s.clone().mult(this.Scale(T.w)*.5)).subvec(h.clone().mult(.5)),T.name,this.Scale(n.m_dColumnTextHeight)),l.addvec(s.clone().mult(this.Scale(T.w))),_+=this.Scale(T.w)}return this.DrawLine(l,l.clone().subvec(h),p),this.DrawLine(i,i.clone().addvec(s.clone().mult(_)),p),this.DrawLine(i.clone().subvec(h),i.addvec(s.clone().mult(_)).subvec(h),p),!0}DrawContent(){let n=this.data,i=this.pt,l=0;for(let T=0;T<n.m_aryColumn.length;T++)l+=this.Scale(n.m_aryColumn[T].w);let h=this.Scale(this.data.m_dRowLineWdith),p=new te.McGeVector3d(1,0,0),_=new te.McGeVector3d(0,1,0),s=i.clone().subvec(_.clone().mult(this.Scale(n.m_dColumnHeight))),M=_.clone().mult(this.Scale(n.m_dRowHeight));for(let T=0;T<n.m_allData.length;T++){let C=s.clone();for(let E=0;E<n.m_aryColumn.length;E++){let L=n.m_aryColumn[E];this.DrawLine(C,C.clone().subvec(M),h),this.DrawMCText(C.clone().addvec(p.clone().mult(this.Scale(L.w*.5))).subvec(M.clone().mult(.5)),n.m_allData[T][E],this.Scale(n.m_dRowTextHeight)),C.addvec(p.clone().mult(this.Scale(L.w)))}this.DrawLine(C,C.clone().subvec(M),h),this.DrawLine(s,s.clone().addvec(p.clone().mult(l)),h),this.DrawLine(s.clone().subvec(M),s.clone().addvec(p.clone().mult(l)).subvec(M),h),s.subvec(M)}return!0}DrawLine(n,i,l){this.mxcad.drawLineWidth=l,this.mxcad.drawColorIndex=te.ColorIndexType.kMagenta,this.mxcad.drawLine(n.x,n.y,i.x,i.y)}DrawMCText(n,i,l){this.mxcad.drawColorIndex=0,this.mxcad.drawColor=new te.McCmColor(0,255,0),this.mxcad.drawText(n.x,n.y,i,l,0,te.McDb.TextHorzMode.kTextMid,te.McDb.TextVertMode.kTextVertMid)}Scale(n){return n*this.dScale}}var CP=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function z1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k1={exports:{}};(function(e,n){var i=function(){var l=function(K,ie){var ue=236,ae=17,le=K,De=p[ie],ye=null,se=0,Ue=null,Oe=[],We={},st=function(ce,we){se=le*4+17,ye=function(Me){for(var pe=new Array(Me),Be=0;Be<Me;Be+=1){pe[Be]=new Array(Me);for(var $e=0;$e<Me;$e+=1)pe[Be][$e]=null}return pe}(se),St(0,0),St(se-7,0),St(0,se-7),Dt(),At(),Pe(ce,we),le>=7&&Ot(ce),Ue==null&&(Ue=Ne(le,De,Oe)),ge(Ue,we)},St=function(ce,we){for(var Me=-1;Me<=7;Me+=1)if(!(ce+Me<=-1||se<=ce+Me))for(var pe=-1;pe<=7;pe+=1)we+pe<=-1||se<=we+pe||(0<=Me&&Me<=6&&(pe==0||pe==6)||0<=pe&&pe<=6&&(Me==0||Me==6)||2<=Me&&Me<=4&&2<=pe&&pe<=4?ye[ce+Me][we+pe]=!0:ye[ce+Me][we+pe]=!1)},gt=function(){for(var ce=0,we=0,Me=0;Me<8;Me+=1){st(!0,Me);var pe=s.getLostPoint(We);(Me==0||ce>pe)&&(ce=pe,we=Me)}return we},At=function(){for(var ce=8;ce<se-8;ce+=1)ye[ce][6]==null&&(ye[ce][6]=ce%2==0);for(var we=8;we<se-8;we+=1)ye[6][we]==null&&(ye[6][we]=we%2==0)},Dt=function(){for(var ce=s.getPatternPosition(le),we=0;we<ce.length;we+=1)for(var Me=0;Me<ce.length;Me+=1){var pe=ce[we],Be=ce[Me];if(ye[pe][Be]==null)for(var $e=-2;$e<=2;$e+=1)for(var ot=-2;ot<=2;ot+=1)$e==-2||$e==2||ot==-2||ot==2||$e==0&&ot==0?ye[pe+$e][Be+ot]=!0:ye[pe+$e][Be+ot]=!1}},Ot=function(ce){for(var we=s.getBCHTypeNumber(le),Me=0;Me<18;Me+=1){var pe=!ce&&(we>>Me&1)==1;ye[Math.floor(Me/3)][Me%3+se-8-3]=pe}for(var Me=0;Me<18;Me+=1){var pe=!ce&&(we>>Me&1)==1;ye[Me%3+se-8-3][Math.floor(Me/3)]=pe}},Pe=function(ce,we){for(var Me=De<<3|we,pe=s.getBCHTypeInfo(Me),Be=0;Be<15;Be+=1){var $e=!ce&&(pe>>Be&1)==1;Be<6?ye[Be][8]=$e:Be<8?ye[Be+1][8]=$e:ye[se-15+Be][8]=$e}for(var Be=0;Be<15;Be+=1){var $e=!ce&&(pe>>Be&1)==1;Be<8?ye[8][se-Be-1]=$e:Be<9?ye[8][15-Be-1+1]=$e:ye[8][15-Be-1]=$e}ye[se-8][8]=!ce},ge=function(ce,we){for(var Me=-1,pe=se-1,Be=7,$e=0,ot=s.getMaskFunction(we),bt=se-1;bt>0;bt-=2)for(bt==6&&(bt-=1);;){for(var Vt=0;Vt<2;Vt+=1)if(ye[pe][bt-Vt]==null){var oe=!1;$e<ce.length&&(oe=(ce[$e]>>>Be&1)==1);var ve=ot(pe,bt-Vt);ve&&(oe=!oe),ye[pe][bt-Vt]=oe,Be-=1,Be==-1&&($e+=1,Be=7)}if(pe+=Me,pe<0||se<=pe){pe-=Me,Me=-Me;break}}},Ve=function(ce,we){for(var Me=0,pe=0,Be=0,$e=new Array(we.length),ot=new Array(we.length),bt=0;bt<we.length;bt+=1){var Vt=we[bt].dataCount,oe=we[bt].totalCount-Vt;pe=Math.max(pe,Vt),Be=Math.max(Be,oe),$e[bt]=new Array(Vt);for(var ve=0;ve<$e[bt].length;ve+=1)$e[bt][ve]=255&ce.getBuffer()[ve+Me];Me+=Vt;var xt=s.getErrorCorrectPolynomial(oe),mt=T($e[bt],xt.getLength()-1),xn=mt.mod(xt);ot[bt]=new Array(xt.getLength()-1);for(var ve=0;ve<ot[bt].length;ve+=1){var un=ve+xn.getLength()-ot[bt].length;ot[bt][ve]=un>=0?xn.getAt(un):0}}for(var tn=0,ve=0;ve<we.length;ve+=1)tn+=we[ve].totalCount;for(var dn=new Array(tn),bn=0,ve=0;ve<pe;ve+=1)for(var bt=0;bt<we.length;bt+=1)ve<$e[bt].length&&(dn[bn]=$e[bt][ve],bn+=1);for(var ve=0;ve<Be;ve+=1)for(var bt=0;bt<we.length;bt+=1)ve<ot[bt].length&&(dn[bn]=ot[bt][ve],bn+=1);return dn},Ne=function(ce,we,Me){for(var pe=C.getRSBlocks(ce,we),Be=E(),$e=0;$e<Me.length;$e+=1){var ot=Me[$e];Be.put(ot.getMode(),4),Be.put(ot.getLength(),s.getLengthInBits(ot.getMode(),ce)),ot.write(Be)}for(var bt=0,$e=0;$e<pe.length;$e+=1)bt+=pe[$e].dataCount;if(Be.getLengthInBits()>bt*8)throw"code length overflow. ("+Be.getLengthInBits()+">"+bt*8+")";for(Be.getLengthInBits()+4<=bt*8&&Be.put(0,4);Be.getLengthInBits()%8!=0;)Be.putBit(!1);for(;!(Be.getLengthInBits()>=bt*8||(Be.put(ue,8),Be.getLengthInBits()>=bt*8));)Be.put(ae,8);return Ve(Be,pe)};We.addData=function(ce,we){we=we||"Byte";var Me=null;switch(we){case"Numeric":Me=L(ce);break;case"Alphanumeric":Me=I(ce);break;case"Byte":Me=B(ce);break;case"Kanji":Me=O(ce);break;default:throw"mode:"+we}Oe.push(Me),Ue=null},We.isDark=function(ce,we){if(ce<0||se<=ce||we<0||se<=we)throw ce+","+we;return ye[ce][we]},We.getModuleCount=function(){return se},We.make=function(){if(le<1){for(var ce=1;ce<40;ce++){for(var we=C.getRSBlocks(ce,De),Me=E(),pe=0;pe<Oe.length;pe++){var Be=Oe[pe];Me.put(Be.getMode(),4),Me.put(Be.getLength(),s.getLengthInBits(Be.getMode(),ce)),Be.write(Me)}for(var $e=0,pe=0;pe<we.length;pe++)$e+=we[pe].dataCount;if(Me.getLengthInBits()<=$e*8)break}le=ce}st(!1,gt())},We.createTableTag=function(ce,we){ce=ce||2,we=typeof we=="undefined"?ce*4:we;var Me="";Me+='<table style="',Me+=" border-width: 0px; border-style: none;",Me+=" border-collapse: collapse;",Me+=" padding: 0px; margin: "+we+"px;",Me+='">',Me+="<tbody>";for(var pe=0;pe<We.getModuleCount();pe+=1){Me+="<tr>";for(var Be=0;Be<We.getModuleCount();Be+=1)Me+='<td style="',Me+=" border-width: 0px; border-style: none;",Me+=" border-collapse: collapse;",Me+=" padding: 0px; margin: 0px;",Me+=" width: "+ce+"px;",Me+=" height: "+ce+"px;",Me+=" background-color: ",Me+=We.isDark(pe,Be)?"#000000":"#ffffff",Me+=";",Me+='"/>';Me+="</tr>"}return Me+="</tbody>",Me+="</table>",Me},We.createSvgTag=function(ce,we,Me,pe){var Be={};typeof arguments[0]=="object"&&(Be=arguments[0],ce=Be.cellSize,we=Be.margin,Me=Be.alt,pe=Be.title),ce=ce||2,we=typeof we=="undefined"?ce*4:we,Me=typeof Me=="string"?{text:Me}:Me||{},Me.text=Me.text||null,Me.id=Me.text?Me.id||"qrcode-description":null,pe=typeof pe=="string"?{text:pe}:pe||{},pe.text=pe.text||null,pe.id=pe.text?pe.id||"qrcode-title":null;var $e=We.getModuleCount()*ce+we*2,ot,bt,Vt,oe,ve="",xt;for(xt="l"+ce+",0 0,"+ce+" -"+ce+",0 0,-"+ce+"z ",ve+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',ve+=Be.scalable?"":' width="'+$e+'px" height="'+$e+'px"',ve+=' viewBox="0 0 '+$e+" "+$e+'" ',ve+=' preserveAspectRatio="xMinYMin meet"',ve+=pe.text||Me.text?' role="img" aria-labelledby="'+Ie([pe.id,Me.id].join(" ").trim())+'"':"",ve+=">",ve+=pe.text?'<title id="'+Ie(pe.id)+'">'+Ie(pe.text)+"</title>":"",ve+=Me.text?'<description id="'+Ie(Me.id)+'">'+Ie(Me.text)+"</description>":"",ve+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',ve+='<path d="',Vt=0;Vt<We.getModuleCount();Vt+=1)for(oe=Vt*ce+we,ot=0;ot<We.getModuleCount();ot+=1)We.isDark(Vt,ot)&&(bt=ot*ce+we,ve+="M"+bt+","+oe+xt);return ve+='" stroke="transparent" fill="black"/>',ve+="</svg>",ve},We.createDataURL=function(ce,we){ce=ce||2,we=typeof we=="undefined"?ce*4:we;var Me=We.getModuleCount()*ce+we*2,pe=we,Be=Me-we;return Ce(Me,Me,function($e,ot){if(pe<=$e&&$e<Be&&pe<=ot&&ot<Be){var bt=Math.floor(($e-pe)/ce),Vt=Math.floor((ot-pe)/ce);return We.isDark(Vt,bt)?0:1}else return 1})},We.createImgTag=function(ce,we,Me){ce=ce||2,we=typeof we=="undefined"?ce*4:we;var pe=We.getModuleCount()*ce+we*2,Be="";return Be+="<img",Be+=' src="',Be+=We.createDataURL(ce,we),Be+='"',Be+=' width="',Be+=pe,Be+='"',Be+=' height="',Be+=pe,Be+='"',Me&&(Be+=' alt="',Be+=Ie(Me),Be+='"'),Be+="/>",Be};var Ie=function(ce){for(var we="",Me=0;Me<ce.length;Me+=1){var pe=ce.charAt(Me);switch(pe){case"<":we+="&lt;";break;case">":we+="&gt;";break;case"&":we+="&amp;";break;case'"':we+="&quot;";break;default:we+=pe;break}}return we},it=function(ce){var we=1;ce=typeof ce=="undefined"?we*2:ce;var Me=We.getModuleCount()*we+ce*2,pe=ce,Be=Me-ce,$e,ot,bt,Vt,oe,ve={"██":"█","█ ":"▀"," █":"▄"," ":" "},xt={"██":"▀","█ ":"▀"," █":" "," ":" "},mt="";for($e=0;$e<Me;$e+=2){for(bt=Math.floor(($e-pe)/we),Vt=Math.floor(($e+1-pe)/we),ot=0;ot<Me;ot+=1)oe="█",pe<=ot&&ot<Be&&pe<=$e&&$e<Be&&We.isDark(bt,Math.floor((ot-pe)/we))&&(oe=" "),pe<=ot&&ot<Be&&pe<=$e+1&&$e+1<Be&&We.isDark(Vt,Math.floor((ot-pe)/we))?oe+=" ":oe+="█",mt+=ce<1&&$e+1>=Be?xt[oe]:ve[oe];mt+=`
  2866. `}return Me%2&&ce>0?mt.substring(0,mt.length-Me-1)+Array(Me+1).join("▀"):mt.substring(0,mt.length-1)};return We.createASCII=function(ce,we){if(ce=ce||1,ce<2)return it(we);ce-=1,we=typeof we=="undefined"?ce*2:we;var Me=We.getModuleCount()*ce+we*2,pe=we,Be=Me-we,$e,ot,bt,Vt,oe=Array(ce+1).join("██"),ve=Array(ce+1).join(" "),xt="",mt="";for($e=0;$e<Me;$e+=1){for(bt=Math.floor(($e-pe)/ce),mt="",ot=0;ot<Me;ot+=1)Vt=1,pe<=ot&&ot<Be&&pe<=$e&&$e<Be&&We.isDark(bt,Math.floor((ot-pe)/ce))&&(Vt=0),mt+=Vt?oe:ve;for(bt=0;bt<ce;bt+=1)xt+=mt+`
  2867. `}return xt.substring(0,xt.length-1)},We.renderTo2dContext=function(ce,we){we=we||2;for(var Me=We.getModuleCount(),pe=0;pe<Me;pe++)for(var Be=0;Be<Me;Be++)ce.fillStyle=We.isDark(pe,Be)?"black":"white",ce.fillRect(pe*we,Be*we,we,we)},We};l.stringToBytesFuncs={default:function(K){for(var ie=[],ue=0;ue<K.length;ue+=1){var ae=K.charCodeAt(ue);ie.push(ae&255)}return ie}},l.stringToBytes=l.stringToBytesFuncs.default,l.createStringToBytes=function(K,ie){var ue=function(){for(var le=ee(K),De=function(){var At=le.read();if(At==-1)throw"eof";return At},ye=0,se={};;){var Ue=le.read();if(Ue==-1)break;var Oe=De(),We=De(),st=De(),St=String.fromCharCode(Ue<<8|Oe),gt=We<<8|st;se[St]=gt,ye+=1}if(ye!=ie)throw ye+" != "+ie;return se}(),ae="?".charCodeAt(0);return function(le){for(var De=[],ye=0;ye<le.length;ye+=1){var se=le.charCodeAt(ye);if(se<128)De.push(se);else{var Ue=ue[le.charAt(ye)];typeof Ue=="number"?(Ue&255)==Ue?De.push(Ue):(De.push(Ue>>>8),De.push(Ue&255)):De.push(ae)}}return De}};var h={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},p={L:1,M:0,Q:3,H:2},_={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=function(){var K=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],ie=1335,ue=7973,ae=21522,le={},De=function(ye){for(var se=0;ye!=0;)se+=1,ye>>>=1;return se};return le.getBCHTypeInfo=function(ye){for(var se=ye<<10;De(se)-De(ie)>=0;)se^=ie<<De(se)-De(ie);return(ye<<10|se)^ae},le.getBCHTypeNumber=function(ye){for(var se=ye<<12;De(se)-De(ue)>=0;)se^=ue<<De(se)-De(ue);return ye<<12|se},le.getPatternPosition=function(ye){return K[ye-1]},le.getMaskFunction=function(ye){switch(ye){case _.PATTERN000:return function(se,Ue){return(se+Ue)%2==0};case _.PATTERN001:return function(se,Ue){return se%2==0};case _.PATTERN010:return function(se,Ue){return Ue%3==0};case _.PATTERN011:return function(se,Ue){return(se+Ue)%3==0};case _.PATTERN100:return function(se,Ue){return(Math.floor(se/2)+Math.floor(Ue/3))%2==0};case _.PATTERN101:return function(se,Ue){return se*Ue%2+se*Ue%3==0};case _.PATTERN110:return function(se,Ue){return(se*Ue%2+se*Ue%3)%2==0};case _.PATTERN111:return function(se,Ue){return(se*Ue%3+(se+Ue)%2)%2==0};default:throw"bad maskPattern:"+ye}},le.getErrorCorrectPolynomial=function(ye){for(var se=T([1],0),Ue=0;Ue<ye;Ue+=1)se=se.multiply(T([1,M.gexp(Ue)],0));return se},le.getLengthInBits=function(ye,se){if(1<=se&&se<10)switch(ye){case h.MODE_NUMBER:return 10;case h.MODE_ALPHA_NUM:return 9;case h.MODE_8BIT_BYTE:return 8;case h.MODE_KANJI:return 8;default:throw"mode:"+ye}else if(se<27)switch(ye){case h.MODE_NUMBER:return 12;case h.MODE_ALPHA_NUM:return 11;case h.MODE_8BIT_BYTE:return 16;case h.MODE_KANJI:return 10;default:throw"mode:"+ye}else if(se<41)switch(ye){case h.MODE_NUMBER:return 14;case h.MODE_ALPHA_NUM:return 13;case h.MODE_8BIT_BYTE:return 16;case h.MODE_KANJI:return 12;default:throw"mode:"+ye}else throw"type:"+se},le.getLostPoint=function(ye){for(var se=ye.getModuleCount(),Ue=0,Oe=0;Oe<se;Oe+=1)for(var We=0;We<se;We+=1){for(var st=0,St=ye.isDark(Oe,We),gt=-1;gt<=1;gt+=1)if(!(Oe+gt<0||se<=Oe+gt))for(var At=-1;At<=1;At+=1)We+At<0||se<=We+At||gt==0&&At==0||St==ye.isDark(Oe+gt,We+At)&&(st+=1);st>5&&(Ue+=3+st-5)}for(var Oe=0;Oe<se-1;Oe+=1)for(var We=0;We<se-1;We+=1){var Dt=0;ye.isDark(Oe,We)&&(Dt+=1),ye.isDark(Oe+1,We)&&(Dt+=1),ye.isDark(Oe,We+1)&&(Dt+=1),ye.isDark(Oe+1,We+1)&&(Dt+=1),(Dt==0||Dt==4)&&(Ue+=3)}for(var Oe=0;Oe<se;Oe+=1)for(var We=0;We<se-6;We+=1)ye.isDark(Oe,We)&&!ye.isDark(Oe,We+1)&&ye.isDark(Oe,We+2)&&ye.isDark(Oe,We+3)&&ye.isDark(Oe,We+4)&&!ye.isDark(Oe,We+5)&&ye.isDark(Oe,We+6)&&(Ue+=40);for(var We=0;We<se;We+=1)for(var Oe=0;Oe<se-6;Oe+=1)ye.isDark(Oe,We)&&!ye.isDark(Oe+1,We)&&ye.isDark(Oe+2,We)&&ye.isDark(Oe+3,We)&&ye.isDark(Oe+4,We)&&!ye.isDark(Oe+5,We)&&ye.isDark(Oe+6,We)&&(Ue+=40);for(var Ot=0,We=0;We<se;We+=1)for(var Oe=0;Oe<se;Oe+=1)ye.isDark(Oe,We)&&(Ot+=1);var Pe=Math.abs(100*Ot/se/se-50)/5;return Ue+=Pe*10,Ue},le}(),M=function(){for(var K=new Array(256),ie=new Array(256),ue=0;ue<8;ue+=1)K[ue]=1<<ue;for(var ue=8;ue<256;ue+=1)K[ue]=K[ue-4]^K[ue-5]^K[ue-6]^K[ue-8];for(var ue=0;ue<255;ue+=1)ie[K[ue]]=ue;var ae={};return ae.glog=function(le){if(le<1)throw"glog("+le+")";return ie[le]},ae.gexp=function(le){for(;le<0;)le+=255;for(;le>=256;)le-=255;return K[le]},ae}();function T(K,ie){if(typeof K.length=="undefined")throw K.length+"/"+ie;var ue=function(){for(var le=0;le<K.length&&K[le]==0;)le+=1;for(var De=new Array(K.length-le+ie),ye=0;ye<K.length-le;ye+=1)De[ye]=K[ye+le];return De}(),ae={};return ae.getAt=function(le){return ue[le]},ae.getLength=function(){return ue.length},ae.multiply=function(le){for(var De=new Array(ae.getLength()+le.getLength()-1),ye=0;ye<ae.getLength();ye+=1)for(var se=0;se<le.getLength();se+=1)De[ye+se]^=M.gexp(M.glog(ae.getAt(ye))+M.glog(le.getAt(se)));return T(De,0)},ae.mod=function(le){if(ae.getLength()-le.getLength()<0)return ae;for(var De=M.glog(ae.getAt(0))-M.glog(le.getAt(0)),ye=new Array(ae.getLength()),se=0;se<ae.getLength();se+=1)ye[se]=ae.getAt(se);for(var se=0;se<le.getLength();se+=1)ye[se]^=M.gexp(M.glog(le.getAt(se))+De);return T(ye,0).mod(le)},ae}var C=function(){var K=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],ie=function(le,De){var ye={};return ye.totalCount=le,ye.dataCount=De,ye},ue={},ae=function(le,De){switch(De){case p.L:return K[(le-1)*4+0];case p.M:return K[(le-1)*4+1];case p.Q:return K[(le-1)*4+2];case p.H:return K[(le-1)*4+3];default:return}};return ue.getRSBlocks=function(le,De){var ye=ae(le,De);if(typeof ye=="undefined")throw"bad rs block @ typeNumber:"+le+"/errorCorrectionLevel:"+De;for(var se=ye.length/3,Ue=[],Oe=0;Oe<se;Oe+=1)for(var We=ye[Oe*3+0],st=ye[Oe*3+1],St=ye[Oe*3+2],gt=0;gt<We;gt+=1)Ue.push(ie(st,St));return Ue},ue}(),E=function(){var K=[],ie=0,ue={};return ue.getBuffer=function(){return K},ue.getAt=function(ae){var le=Math.floor(ae/8);return(K[le]>>>7-ae%8&1)==1},ue.put=function(ae,le){for(var De=0;De<le;De+=1)ue.putBit((ae>>>le-De-1&1)==1)},ue.getLengthInBits=function(){return ie},ue.putBit=function(ae){var le=Math.floor(ie/8);K.length<=le&&K.push(0),ae&&(K[le]|=128>>>ie%8),ie+=1},ue},L=function(K){var ie=h.MODE_NUMBER,ue=K,ae={};ae.getMode=function(){return ie},ae.getLength=function(ye){return ue.length},ae.write=function(ye){for(var se=ue,Ue=0;Ue+2<se.length;)ye.put(le(se.substring(Ue,Ue+3)),10),Ue+=3;Ue<se.length&&(se.length-Ue==1?ye.put(le(se.substring(Ue,Ue+1)),4):se.length-Ue==2&&ye.put(le(se.substring(Ue,Ue+2)),7))};var le=function(ye){for(var se=0,Ue=0;Ue<ye.length;Ue+=1)se=se*10+De(ye.charAt(Ue));return se},De=function(ye){if("0"<=ye&&ye<="9")return ye.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+ye};return ae},I=function(K){var ie=h.MODE_ALPHA_NUM,ue=K,ae={};ae.getMode=function(){return ie},ae.getLength=function(De){return ue.length},ae.write=function(De){for(var ye=ue,se=0;se+1<ye.length;)De.put(le(ye.charAt(se))*45+le(ye.charAt(se+1)),11),se+=2;se<ye.length&&De.put(le(ye.charAt(se)),6)};var le=function(De){if("0"<=De&&De<="9")return De.charCodeAt(0)-"0".charCodeAt(0);if("A"<=De&&De<="Z")return De.charCodeAt(0)-"A".charCodeAt(0)+10;switch(De){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+De}};return ae},B=function(K){var ie=h.MODE_8BIT_BYTE,ue=l.stringToBytes(K),ae={};return ae.getMode=function(){return ie},ae.getLength=function(le){return ue.length},ae.write=function(le){for(var De=0;De<ue.length;De+=1)le.put(ue[De],8)},ae},O=function(K){var ie=h.MODE_KANJI,ue=l.stringToBytesFuncs.SJIS;if(!ue)throw"sjis not supported.";(function(De,ye){var se=ue(De);if(se.length!=2||(se[0]<<8|se[1])!=ye)throw"sjis not supported."})("友",38726);var ae=ue(K),le={};return le.getMode=function(){return ie},le.getLength=function(De){return~~(ae.length/2)},le.write=function(De){for(var ye=ae,se=0;se+1<ye.length;){var Ue=(255&ye[se])<<8|255&ye[se+1];if(33088<=Ue&&Ue<=40956)Ue-=33088;else if(57408<=Ue&&Ue<=60351)Ue-=49472;else throw"illegal char at "+(se+1)+"/"+Ue;Ue=(Ue>>>8&255)*192+(Ue&255),De.put(Ue,13),se+=2}if(se<ye.length)throw"illegal char at "+(se+1)},le},U=function(){var K=[],ie={};return ie.writeByte=function(ue){K.push(ue&255)},ie.writeShort=function(ue){ie.writeByte(ue),ie.writeByte(ue>>>8)},ie.writeBytes=function(ue,ae,le){ae=ae||0,le=le||ue.length;for(var De=0;De<le;De+=1)ie.writeByte(ue[De+ae])},ie.writeString=function(ue){for(var ae=0;ae<ue.length;ae+=1)ie.writeByte(ue.charCodeAt(ae))},ie.toByteArray=function(){return K},ie.toString=function(){var ue="";ue+="[";for(var ae=0;ae<K.length;ae+=1)ae>0&&(ue+=","),ue+=K[ae];return ue+="]",ue},ie},q=function(){var K=0,ie=0,ue=0,ae="",le={},De=function(se){ae+=String.fromCharCode(ye(se&63))},ye=function(se){if(!(se<0)){if(se<26)return 65+se;if(se<52)return 97+(se-26);if(se<62)return 48+(se-52);if(se==62)return 43;if(se==63)return 47}throw"n:"+se};return le.writeByte=function(se){for(K=K<<8|se&255,ie+=8,ue+=1;ie>=6;)De(K>>>ie-6),ie-=6},le.flush=function(){if(ie>0&&(De(K<<6-ie),K=0,ie=0),ue%3!=0)for(var se=3-ue%3,Ue=0;Ue<se;Ue+=1)ae+="="},le.toString=function(){return ae},le},ee=function(K){var ie=K,ue=0,ae=0,le=0,De={};De.read=function(){for(;le<8;){if(ue>=ie.length){if(le==0)return-1;throw"unexpected end of file./"+le}var se=ie.charAt(ue);if(ue+=1,se=="=")return le=0,-1;if(se.match(/^\s$/))continue;ae=ae<<6|ye(se.charCodeAt(0)),le+=6}var Ue=ae>>>le-8&255;return le-=8,Ue};var ye=function(se){if(65<=se&&se<=90)return se-65;if(97<=se&&se<=122)return se-97+26;if(48<=se&&se<=57)return se-48+52;if(se==43)return 62;if(se==47)return 63;throw"c:"+se};return De},he=function(K,ie){var ue=K,ae=ie,le=new Array(K*ie),De={};De.setPixel=function(Oe,We,st){le[We*ue+Oe]=st},De.write=function(Oe){Oe.writeString("GIF87a"),Oe.writeShort(ue),Oe.writeShort(ae),Oe.writeByte(128),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(0),Oe.writeByte(255),Oe.writeByte(255),Oe.writeByte(255),Oe.writeString(","),Oe.writeShort(0),Oe.writeShort(0),Oe.writeShort(ue),Oe.writeShort(ae),Oe.writeByte(0);var We=2,st=se(We);Oe.writeByte(We);for(var St=0;st.length-St>255;)Oe.writeByte(255),Oe.writeBytes(st,St,255),St+=255;Oe.writeByte(st.length-St),Oe.writeBytes(st,St,st.length-St),Oe.writeByte(0),Oe.writeString(";")};var ye=function(Oe){var We=Oe,st=0,St=0,gt={};return gt.write=function(At,Dt){if(At>>>Dt)throw"length over";for(;st+Dt>=8;)We.writeByte(255&(At<<st|St)),Dt-=8-st,At>>>=8-st,St=0,st=0;St=At<<st|St,st=st+Dt},gt.flush=function(){st>0&&We.writeByte(St)},gt},se=function(Oe){for(var We=1<<Oe,st=(1<<Oe)+1,St=Oe+1,gt=Ue(),At=0;At<We;At+=1)gt.add(String.fromCharCode(At));gt.add(String.fromCharCode(We)),gt.add(String.fromCharCode(st));var Dt=U(),Ot=ye(Dt);Ot.write(We,St);var Pe=0,ge=String.fromCharCode(le[Pe]);for(Pe+=1;Pe<le.length;){var Ve=String.fromCharCode(le[Pe]);Pe+=1,gt.contains(ge+Ve)?ge=ge+Ve:(Ot.write(gt.indexOf(ge),St),gt.size()<4095&&(gt.size()==1<<St&&(St+=1),gt.add(ge+Ve)),ge=Ve)}return Ot.write(gt.indexOf(ge),St),Ot.write(st,St),Ot.flush(),Dt.toByteArray()},Ue=function(){var Oe={},We=0,st={};return st.add=function(St){if(st.contains(St))throw"dup key:"+St;Oe[St]=We,We+=1},st.size=function(){return We},st.indexOf=function(St){return Oe[St]},st.contains=function(St){return typeof Oe[St]!="undefined"},st};return De},Ce=function(K,ie,ue){for(var ae=he(K,ie),le=0;le<ie;le+=1)for(var De=0;De<K;De+=1)ae.setPixel(De,le,ue(De,le));var ye=U();ae.write(ye);for(var se=q(),Ue=ye.toByteArray(),Oe=0;Oe<Ue.length;Oe+=1)se.writeByte(Ue[Oe]);return se.flush(),"data:image/gif;base64,"+se};return l}();(function(){i.stringToBytesFuncs["UTF-8"]=function(l){function h(p){for(var _=[],s=0;s<p.length;s++){var M=p.charCodeAt(s);M<128?_.push(M):M<2048?_.push(192|M>>6,128|M&63):M<55296||M>=57344?_.push(224|M>>12,128|M>>6&63,128|M&63):(s++,M=65536+((M&1023)<<10|p.charCodeAt(s)&1023),_.push(240|M>>18,128|M>>12&63,128|M>>6&63,128|M&63))}return _}return h(l)}})(),function(l){e.exports=l()}(function(){return i})})(k1);var PP=k1.exports;const LP=z1(PP);function DP(e){let n={};if(n.ObjectName=e.objectName,n.id=e.getObjectID().id,n.handle=e.getHandle(),n.layer=e.layer,n.color=e.trueColor.getColorString(),n.colorVal=e.trueColor.getColorValue(e.layerId),n.linetype=e.linetype,n.textStyle=e.textStyle,n.type=e.objectName,n.dxf0=e.dxf0,e instanceof te.McDbText){let i=e;n.position=Er(i.position),n.textString=i.textString}else if(e instanceof te.McDbMText){let i=e;n.contents=i.contents,n.location=Er(i.location)}else if(e instanceof te.McDbLine){let i=e;n.startPoint=Er(i.startPoint),n.endPoint=Er(i.endPoint)}else if(e instanceof te.McDbCircle){let i=e;n.center=Er(i.center),n.radius=i.radius}else if(e instanceof te.McDbArc){let i=e;n.center=Er(i.center),n.startAngle=i.startAngle,n.endAngle=i.endAngle}else if(e instanceof te.McDbPolyline){let i=e,l=i.numVerts();n.num=l;for(let h=0;h<l;h++){let p=i.getPointAt(h),_=i.getBulgeAt(h);n["pt"+h]=Er(p.val),n["bulge"+h]=_}}else if(e instanceof te.McDbBlockReference){let i=e;n.position=Er(i.position),n.blockTransform=i.blockTransform,n.blockName=i.blockName}else if(e instanceof te.McDbAlignedDimension){let i=e;n.xLine1Point=Er(i.xLine1Point),n.xLine2Point=Er(i.xLine2Point),i.GetAllText().forEach((h,p)=>{n["txt:"+p]=h})}else if(e instanceof te.McDbRotatedDimension){let i=e;n.xLine1Point=Er(i.xLine1Point),n.xLine2Point=Er(i.xLine2Point),i.GetAllText().forEach((h,p)=>{n["txt:"+p]=h})}else if(e instanceof te.McDbDimension)e.GetAllText().forEach((h,p)=>{n["txt:"+p]=h});else if(e instanceof te.McDbHatch){let i=e;n.patternType=i.patternType(),n.patternName=i.patternName(),n.patternAngle=i.patternAngle,n.patternScale=i.patternScale,n.patternSpace=i.patternSpace,n.patternDouble=i.patternDouble,n.hatchStyle=i.hatchStyle(),n.isSolid=i.isSolid(),n.numLoops=i.numLoops;for(let l=0;l<n.numLoops;l++){let h=i.getLoopAt(l);h.vertices.forEach((p,_)=>{h["pt:"+_]={},h["pt:"+_].x=p.x,h["pt:"+_].y=p.y,h["pt:"+_].z=p.z}),n["loop:"+l]=h}n.numPatternDefinitions=i.numPatternDefinitions;for(let l=0;l<n.numPatternDefinitions;l++)n["patternDefinitions:"+l]=i.getPatternDefinitionAt(l)}else if(e instanceof te.McDbRasterImage){let i=e,l=i.getOrientation();n.orientation={},n.orientation.origin=l.origin.toVector3(),n.orientation.uCorner=l.uCorner.toVector3(),n.orientation.vOnPlane=l.vOnPlane.toVector3();let h=i.clipBoundary();n.clipBoundary={},h.forEach((_,s)=>{n.clipBoundary["pt"+s]=_.toVector3()}),n.clipBoundaryType=i.clipBoundaryType();let p=i.imageDefId().getMcDbRasterImageDef();p&&(n.filePath=p.sourceFileName)}return n}function IP(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet;e.allSelect(),e.forEach(n=>{let i=n.getMcDbEntity();i&&(i=DP(i),console.log(JSON.stringify(i)))})})}function RP(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet,n=new te.MxCADResbuf;n.AddString("0",8),e.allSelect(n),e.forEach(i=>{let l=i.getMcDbEntity();if(l&&l instanceof te.McDbHatch){let h={},p=l;h.patternType=p.patternType(),h.patternName=p.patternName(),h.patternAngle=p.patternAngle,h.patternScale=p.patternScale,h.patternSpace=p.patternSpace,h.patternDouble=p.patternDouble,h.hatchStyle=p.hatchStyle(),h.isSolid=p.isSolid(),h.numLoops=p.numLoops;for(let _=0;_<h.numLoops;_++){let s=p.getLoopAt(_);s.vertices.forEach((M,T)=>{s["pt:"+T]={},s["pt:"+T].x=M.x,s["pt:"+T].y=M.y,s["pt:"+T].z=M.z}),h["loop:"+_]=s}h.numPatternDefinitions=p.numPatternDefinitions;for(let _=0;_<h.numPatternDefinitions;_++)h["patternDefinitions:"+_]=p.getPatternDefinitionAt(_);console.log(h)}})})}function zP(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=e.getDatabase(),i={};i.name="GRIDMODE",i.isShow=e.getSysVarLong("GRIDMODE");let l=e.getSysVarPoint("SNAPUNIT");i.xdist=l.x,i.ydist=l.x,console.log(i);let h={};h.name="ORTHOMODE",h.isShow=e.getSysVarLong("ORTHOMODE"),console.log(h);let p={};p.name="AUTOSNAP",p.enable=(e.getSysVarLong("AUTOSNAP")&8)!=0,p.polarang=e.getSysVarDouble("POLARANG"),console.log(p);let _={};_.name="OSMODE",_.enable=(e.getSysVarLong("OSMODE")&16384)==0,_.value=e.getSysVarLong("OSMODE"),_.End=(e.getSysVarLong("OSMODE")&1)!=0,_.Mid=(e.getSysVarLong("OSMODE")&2)!=0,_.Cen=(e.getSysVarLong("OSMODE")&4)!=0,_.Node=(e.getSysVarLong("OSMODE")&8)!=0,_.Quad=(e.getSysVarLong("OSMODE")&16)!=0,_.Int=(e.getSysVarLong("OSMODE")&32)!=0,_.Ins=(e.getSysVarLong("OSMODE")&64)!=0,_.Perp=(e.getSysVarLong("OSMODE")&128)!=0,_.Tan=(e.getSysVarLong("OSMODE")&256)!=0,_.Near=(e.getSysVarLong("OSMODE")&512)!=0,console.log(_);let s={};s.name="DYNTRACE",s.enable=e.getSysVarLong("DYNTRACE")!=0,console.log(s);let M={};M.name="DYNINPUT",M.enable=e.getSysVarLong("DYNINPUT")!=0,console.log(M);let T={};T.LTSCALE=e.getSysVarDouble("LTSCALE"),T.CELTSCALE=e.getSysVarDouble("CELTSCALE"),T.CELTYPE=e.getSysVarString("CELTYPE"),T.TEXTSTYLE=e.getSysVarString("TEXTSTYLE"),T.CLAYOUTNAME=e.getSysVarString("CLAYOUTNAME"),T.CLAYER=e.getSysVarString("CLAYER"),T.CECOLOR=n.getCurrentlyTrueColor().getColorValue(),T.INSBASE=e.getSysVarPoint("INSBASE"),T.CELWEIGHT=e.getSysVarLong("CELWEIGHT"),T.PDMODE=e.getSysVarLong("PDMODE"),T.PDSIZE=e.getSysVarDouble("PDSIZE"),console.log(T)})}function kP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();if(i===null)return;i.getxData().forEach((h,p,_)=>{console.log(JSON.stringify({val:h,type:p,dxf:_}))})})}function BP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();i!==null&&i.setxDataString("DataName","xxxxx")})}function FP(){return wn(this,null,function*(){const e=new te.MxCADUiPrPoint;e.setMessage(`
  2868. 指定第一点:`);let n=yield e.go();if(n)for(e.setMessage(`
  2869. 指定下一个点:`);;){e.setBasePt(n);let i=yield e.go();if(!i)return;let l=new te.McDbLine(n,i);te.MxCpp.getCurrentMxCAD().drawEntity(l),n=i}})}function B1(){let e=window.location.hostname;return e.substring(0,4)!="http"&&(e=document.location.protocol+"//"+e),e}function OP(){return wn(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=B1()+e.substring(16));let n=e+"tree.mxweb",i=te.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(n,"tree");if(!l.isValid())return;let h=new te.McDbBlockReference;h.blockTableRecordId=l;let p=h.getBoundingBox();if(p.ret){let E=p.maxPt.distanceTo(p.minPt);E>1e-5&&h.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/E)}let _=new te.MxCADUiPrPoint;_.setMessage("指定插入基点"),_.setUserDraw((E,L)=>{h.position=E,L.drawMcDbEntity(h)});let s=yield _.go();if(!s)return;h.position=s;let M=i.drawEntity(h);if(!M.isValid){console.log("insert error");return}h=M.getMcDbEntity(),h.disableDisplay(!0),l.getMcDbBlockTableRecord().getAllEntityId().forEach((E,L)=>{if(!E.isKindOf("McDbAttributeDefinition"))return;let I=E.getMcDbEntity(),B=I.tag,O=I.textString,U=new te.McDbAttribute;U.position=I.position,U.alignmentPoint=I.alignmentPoint,U.height=I.height,U.trueColor=I.trueColor,U.widthFactor=I.widthFactor,O.length>0?U.textString=O:U.textString="test"+L,U.tag=B,U.isInvisible=I.isInvisible,U.transformBy(h.blockTransform),U=h.appendAttribute(U).getMcDbEntity(),U.textStyle=I.textStyle,U.layer=I.layer}),h.disableDisplay(!1)})}function NP(){let i=te.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable().getAllRecordId(),l=[];return i.forEach(h=>{let p=h.getMcDbLayerTableRecord();if(p===null)return;console.log(p),console.log("layerRec.color:"+p.color.getColorString()),console.log("layerRec.name:"+p.name);let _={};_.name=p.name,_.color=p.color.getColorString(),l.push(_)}),tt.MxFun.postMessageToParentFrame(l),l}function UP(){let n=te.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable();if(!n.has("xxx11")){let i=new te.McDbLayerTableRecord;i.name="xxx11",n.add(i)}n.has("xxx11")&&console.log("add layer ok")}function VP(){te.MxCpp.App.getCurrentMxCAD().getDatabase().getLinetypeTable().getAllRecordId().forEach(l=>{let h=l.getMcDbLinetypeTableRecord();h!==null&&console.log(h)})}function GP(){te.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable().getAllRecordId().forEach(l=>{let h=l.getMcDbTextStyleTableRecord();if(h===null)return;let p={};p.name=h.name,p.font=h.font(),p.fileName=h.fileName,p.bigFontFileName=h.bigFontFileName,p.textSize=h.textSize,p.xScale=h.xScale,console.log(p)})}function HP(){return wn(this,null,function*(){let n=te.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable(),i="MyTextStyle";n.has(i,!1)&&n.get(i,!1).erase(!1);let l=new te.McDbTextStyleTableRecord;l.fileName="txt.shx",l.bigFontFileName="hztxt.shx",l.textSize=10,l.name=i,l.xScale=.7,n.add(l).isValid()&&console.log("add ok")})}function WP(){te.MxCpp.App.getCurrentMxCAD().getDatabase().getBlockTable().getAllRecordId().forEach(l=>{let h=l.getMcDbBlockTableRecord();h!==null&&(console.log(h),console.log("blkRec.name:"+h.name),console.log("blkRec.origin:"+h.origin))})}function jP(){return wn(this,null,function*(){let e=new AP;e.data.addColumn("序号",30),e.data.addColumn("名称",45),e.data.addColumn("材料",60),e.data.addColumn("长度",50);for(let h=0;h<10;h++){let p=""+h;e.data.addRow([p,"AAAA","BBBB","1000"])}let n=new te.MxCADUiPrPoint;n.setMessage(`
  2870. 指定表格插入点:`);let i=yield n.go();if(!i)return;let l=tt.MxFun.screenCoordLong2Doc(100)/200;e.draw(i,l)})}function qP(){return wn(this,null,function*(){const e=new tt.MrxDbgUiPrPoint;e.setMessage(`
  2871. 指定插入点:`);let n=yield e.go();if(!n)return;let i=tt.MxFun.getCurrentDraw();const l=LP(5,"L");l.addData("https://www.mxdraw3d.com"),l.make();const h=l.createDataURL(),p=new $h().load(h),_=new lr({map:p});let s=tt.MxFun.screenCoordLong2Doc(80),M=tt.MxFun.screenCoordLong2Doc(80),T=new tt.MxDbImage;T.setRenderOrder(tt.MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1),T.setPoint1(n);let C=new Ee(n.x+s,n.y+M,n.z);T.setPoint2(C),T.setMaterial(_),i.addMxEntity(T),setInterval(()=>{i.updateDisplay()},100)})}function ZP(){return wn(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=B1()+e.substring(16));let n=e+"stamp.mxweb",i=te.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(n,"stamp");if(!l.isValid())return;let h=new te.McDbBlockReference;h.blockTableRecordId=l;let p=h.getBoundingBox();if(p.ret){let M=p.maxPt.distanceTo(p.minPt);M>1e-5&&h.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/M)}let _=new te.MxCADUiPrPoint;_.setMessage("指定插入基点"),_.setUserDraw((M,T)=>{h.position=M,T.drawMcDbEntity(h)});let s=yield _.go();s&&(h.position=s,i.drawEntity(h))})}function XP(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=e.database.getLinetypeTable().get("TestMyLine");n.isErase()||n.erase();let i=e.addLinetypeEx("TestMyLine",'.5,-.2,["HW",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.2',"");if(!i.isValid())return;let p=(yield new te.MxCADUiPrEntity().go()).getMcDbEntity();p&&(p.linetypeId=i)})}function Sy(e){e.getAllObjectName().forEach(i=>{console.log(i);let h=e.getAt(i).getMcDbObject();if(h instanceof te.McDbDictionary){let p=h;console.log(p),Sy(p)}else h instanceof te.McDbXrecord&&h.getData().PrintData()})}function YP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择标注对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();if(i&&i.isHaveExtensionDictionary()){let l=i.getExtensionDictionary();Sy(l)}})}function $P(){return wn(this,null,function*(){let n=te.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary();n.getAllObjectName().forEach(l=>{console.log(l);let p=n.getAt(l).getMcDbObject();if(p instanceof te.McDbDictionary){let _=p;console.log(_),Sy(_)}})})}function JP(){return wn(this,null,function*(){let n=te.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary(),i="MyDict",l=n.getAt(i);if(l.isNull()){let p=new te.McDbDictionary;l=n.addObject(i,p)}let h=l.getMcDbDictionary();if(h){let p=new te.McDbXrecord,_=new te.MxCADResbuf;_.AddString("TestData"),p.setData(_),h.addObject("MyRecord",p),console.log("write xrecord ok")}})}function KP(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择标注对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();i&&(i.trueColor=new te.McCmColor(255,0,255))})}let Ay;function QP(){return wn(this,null,function*(){if(Ay){let e=Ay.getMcDbEntity();if(!e)return;e.visible=!0}else{let e=new te.MxCADUiPrEntity;e.setMessage("选择标注对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();if(!i)return;i.visible=!1,Ay=n}})}function e3(){return wn(this,null,function*(){let e="WALL";te.MxCpp.getCurrentMxCAD().database.layerTable.has(e)||console.log("no have layer:"+e);let i=new te.MxCADUiPrEntity;i.setMessage("选择对象");let l=yield i.go();if(!l.isValid())return;let h=l.getMcDbEntity();h&&(h.layer=e)})}function t3(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet;if(!(yield e.userSelect(`
  2872. 选择对象`)))return;let i=te.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder().maxDrawOrder+1;e.forEach(l=>{let h=l.getMcDbEntity();h&&(h.drawOrder=i)})})}function n3(){tt.MxFun.addCommand("TestGetAllEntity",IP),tt.MxFun.addCommand("MxTest_GetSysVars",zP),tt.MxFun.addCommand("MxTest_ReadxData",kP),tt.MxFun.addCommand("MxTest_WritexData",BP),tt.MxFun.addCommand("MxTest_DrawLine",FP),tt.MxFun.addCommand("MxTest_InsertBlock",OP),tt.MxFun.addCommand("MxTest_GetAllLayer",NP),tt.MxFun.addCommand("MxTest_AddLayer",UP),tt.MxFun.addCommand("MxTest_GetAllTextStyle",GP),tt.MxFun.addCommand("MxTest_GetAllBlock",WP),tt.MxFun.addCommand("MxTest_GetAllLinetype",VP),tt.MxFun.addCommand("Mx_Test_DrawTable",jP),tt.MxFun.addCommand("Mx_Test_QRCode",qP),tt.MxFun.addCommand("MxTest_InsertStamp",ZP),tt.MxFun.addCommand("MxTest_LineTypeTest",XP),tt.MxFun.addCommand("TestGentEntityOnLayer",RP),tt.MxFun.addCommand("MxTest_GetNamedObjectsDictionary",$P),tt.MxFun.addCommand("MxTest_GetObjectExDictionaryData",YP),tt.MxFun.addCommand("MxTest_WriteXRecord",JP),tt.MxFun.addCommand("MxTest_AddTextStyleTable",HP),tt.MxFun.addCommand("Mx_Test_ChangeColor",KP),tt.MxFun.addCommand("Mx_Test_ChangeVisible",QP),tt.MxFun.addCommand("Mx_Test_ChangeEntityLayer",e3),tt.MxFun.addCommand("Mx_ChaneEntityDrawOrder",t3)}function i3(){return wn(this,null,function*(){let{baseUrl:e="",saveDwgUrl:n="",mxfilepath:i=""}=vd().getUploadFileConfig();te.MxCpp.getCurrentMxCAD().saveFileToUrl(n,(l,h)=>{try{let p=JSON.parse(h);if(p.ret=="ok"){let _=e+i+p.file;fetch(_).then(s=>wn(this,null,function*(){const M=yield s.blob();te.MxTools.saveAsFileDialog({blob:M,filename:p.file,types:[{description:"dwg图纸",accept:{"application/octet-stream":[".dwg"]}}]})}))}else console.log(h)}catch(p){console.log("Mx: sserverResult error")}})})}function r3(){return wn(this,null,function*(){let{baseUrl:e="",mxfilepath:n="",saveUrl:i=""}=vd().getUploadFileConfig();te.MxCpp.getCurrentMxCAD().saveFileToUrl(i,(l,h)=>{try{let p=JSON.parse(h);if(p.ret=="ok"){let _=e+n+p.file;te.MxTools.downloadFileFromUrl(_,p.file)}else console.log(h)}catch(p){console.log("Mx: sserverResult error")}})})}function a3(){return wn(this,null,function*(){te.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/8c79da20e232495888dbb0da17459399.mxweb")})}function o3(){return wn(this,null,function*(){te.MxCpp.getCurrentMxCAD().newFile()})}function s3(){return wn(this,null,function*(){let e=new te.MxCADUiPrPoint;e.setMessage(`
  2873. 指定输出范围第一点:`);let n=yield e.go();if(!n)return;e.setMessage(`
  2874. 指定输出范围第二点:`),e.setUserDraw((s,M)=>{M.setColor(16711680);let T=new te.McDbPolyline;T.addVertexAt(n),T.addVertexAt(new te.McGePoint3d(n.x,s.y)),T.addVertexAt(s),T.addVertexAt(new te.McGePoint3d(s.x,n.y)),T.constantWidth=tt.MxFun.screenCoordLong2Doc(2),T.isClosed=!0,M.drawMcDbEntity(T);let C=[];C.push(n.toVector3()),C.push(new THREE.Vector3(n.x,s.y)),C.push(s.toVector3()),C.push(new THREE.Vector3(s.x,n.y)),M.setColor(12868),M.drawSolid(C,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let{baseUrl:l="",mxfilepath:h="",printPdfUrl:p=""}=vd().getUploadFileConfig();console.log(vd().getUploadFileConfig());let _={width:"2100",height:"2970",bd_pt1_x:""+n.x,bd_pt1_y:""+n.y,bd_pt2_x:""+i.x,bd_pt2_y:""+i.y};te.MxCpp.getCurrentMxCAD().saveFileToUrl(p,(s,M)=>{try{let T=JSON.parse(M);if(T.ret=="ok"){let C=l+h+T.file;te.MxTools.downloadFileFromUrl(C,T.file)}else console.log(M)}catch(T){console.log("Mx: sserverResult error")}},void 0,JSON.stringify(_))})}function l3(n){return wn(this,arguments,function*({param:e}){te.MxCpp.getCurrentMxCAD().openWebFile(e)})}function c3(){return wn(this,null,function*(){const e=te.MxCpp.getCurrentMxCAD();e.saveFile(e.getCurrentFileName(),n=>{window.parent.postMessage({cmd:"MKY_Download_Mxweb",file:n})},!1,!1)})}function u3(){tt.MxFun.addCommand("Mx_Export_DWG",i3),tt.MxFun.addCommand("Mx_Export_MxWeb",r3),tt.MxFun.addCommand("Mx_Open_MxWeb",a3),tt.MxFun.addCommand("MxTest_NewFile",o3),tt.MxFun.addCommand("Mx_Export_Pdf",s3),tt.MxFun.addCommand("MKY_Open_Mxweb",l3),tt.MxFun.addCommand("MKY_Download_Mxweb",c3)}function h3(){return wn(this,null,function*(){let e="0601",n="001A",i=new te.MxCADSelectionSet,l=new te.MxCADResbuf;l.AddMcDbEntityTypes("TEXT,MTEXT,INSERT,ACAD_PROXY_ENTITY"),i.allSelect(l);let h,p,_=i.count();for(let s=0;s<_;s++){let T=i.item(s).getMcDbEntity();if(!T)return;if(T instanceof te.McDbText){let C=T;if(C.textString==e){h=C.position,p=C.getBoundingBox();break}}else if(T instanceof te.McDbMText){let C=T;if(C.contents==e){h=C.location,p=C.getBoundingBox();break}}else if(T instanceof te.McDbBlockReference){let C=T,E=C.getAllAttribute(),L=0;if(E.forEach(I=>{let B=I.getMcDbEntity();(B.textString==e||B.textString==n)&&L++}),L==2){h=C.position,p=C.getBoundingBox();break}}else if(T instanceof te.McDbProxyEntity){let C=T,E=C.getAllTextContent(),L=0;if(E.forEach(I=>{I==e&&L++}),L>=1){p=C.getBoundingBox(),p&&p.ret&&(h=new te.McGePoint3d(p.minPt.x+(p.maxPt.x-p.minPt.x)*.5,p.minPt.y+(p.maxPt.y-p.minPt.y)*.5));break}}}if(p&&p.ret){console.log(p);let s=p.minPt.distanceTo(p.maxPt)*2;tt.MxFun.getCurrentDraw().zoomW(new THREE.Vector3(p.minPt.x-s,p.minPt.y-s,0),new THREE.Vector3(p.maxPt.x+s,p.maxPt.y+s,0))}else h?tt.MxFun.getCurrentDraw().zoomCenter(h.x,h.y):console.log("没有找到文字:"+e)})}function d3(){tt.MxFun.addCommand("MxTest_FindText",h3)}class fm extends te.McDbCustomEntity{constructor(n){super(n),this.pt1=new te.McGePoint3d,this.pt2=new te.McGePoint3d}create(n){return new fm(n)}getTypeName(){return"McDbTestLineCustomEntity"}dwgInFields(n){return this.pt1=n.readPoint("pt1").val,this.pt2=n.readPoint("pt2").val,!0}dwgOutFields(n){return n.writePoint("pt1",this.pt1),n.writePoint("pt2",this.pt2),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=h):n==1&&(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=h)}getGripPoints(){let n=new te.McGePoint3dArray;return n.append(this.pt1),n.append(this.pt2),n}worldDraw(n){let i=new te.McDbLine(this.pt1,this.pt2);n.drawEntity(i)}setPoint1(n){this.assertWrite(),this.pt1=n.clone()}setPoint2(n){this.assertWrite(),this.pt2=n.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function p3(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD();const n=new te.MxCADUiPrPoint;n.setMessage(`
  2875. 指定一点:`);let i=yield n.go();if(!i)return;n.setBasePt(i),n.setUseBasePt(!0),n.setMessage(`
  2876. 指定二点:`);let l=yield n.go();if(!l)return;let h=new fm;h.setPoint1(i),h.setPoint2(l),e.drawEntity(h)})}function f3(){new fm().rxInit(),tt.MxFun.addCommand("MxTest_DrawCustomEntity",p3)}function m3(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成块的对象:"))||e.count()==0)return;let n=te.MxCpp.getCurrentMxCAD(),l=n.getDatabase().getBlockTable().add(new te.McDbBlockTableRecord),h=l.getMcDbBlockTableRecord();if(h==null)return;let p,_,s,M;if(e.forEach(L=>{let I=L.getMcDbEntity();if(!I)return;let B=I.clone();h.appendAcDbEntity(B);let O=I.getBoundingBox();O.ret&&(p?(p>O.minPt.x&&(p=O.minPt.x),_>O.minPt.y&&(_=O.minPt.y),s<O.maxPt.x&&(s=O.maxPt.x),M<O.maxPt.y&&(M=O.maxPt.y)):(p=O.minPt.x,_=O.minPt.y,s=O.maxPt.x,M=O.maxPt.y))}),p===void 0)return;let T=p+(s-p)*.5,C=_+(M-_)*.5;h.origin=new te.McGePoint3d(T,C,0);let E=new te.McDbBlockReference;E.blockTableRecordId=l,E.position=new te.McGePoint3d(T,C,0),n.drawEntity(E),e.forEach(L=>{let I=L.getMcDbEntity();I&&I.erase()})})}function g3(){tt.MxFun.addCommand("MxTest_SelectEntitysToBlock",m3)}function _3(){return wn(this,null,function*(){const e=new te.MxCADUiPrPoint;e.setMessage(`
  2877. 指定填充区域内部一点:`),e.disableAllTrace(!0),e.setDisableOsnap(!0);let n=yield e.go();if(!n)return;let i=te.MxCADUtility.builderHatchFromPoint(n);if(!i){tt.MxFun.acutPrintf(`没有找到闭合区域
  2878. `);return}te.MxCpp.getCurrentMxCAD().drawEntity(i)})}function y3(){tt.MxFun.addCommand("MxTest_DrawHatchFormPoint",_3)}const Cy={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function v3(e){if(/^\d+,\s*\d+,\s*\d+$/.test(e))return e.split(",").map(Number);if(/^0x[0-9a-fA-F]{6}$/.test(e)){const n=parseInt(e,16);return[n>>16&255,n>>8&255,n&255]}else if(/^#[0-9a-fA-F]{6}$/.test(e)){const n=parseInt(e.slice(1),16);return[n>>16&255,n>>8&255,n&255]}else if(Cy[e.toLowerCase()]){const n=e.toLowerCase();if(Cy[n])return Cy[n]}else{const n=new te.McCmColor;return n.setColorIndex(256),[n.red,n.green,n.blue]}}const x3=e=>{const n=te.MxCpp.getCurrentDatabase().layerTable;if(n.has(e))return;const i=new te.McDbLayerTableRecord;i.color=new te.McCmColor(0,0,0),i.isFrozen=!1,i.isLocked=!1,i.isOff=!1,i.lineWeight=te.McDb.LineWeight.kLnWtByLayer,i.name=e,n.add(i)},gs=[{name:"color",description:"颜色",type:"str",required:!0},{name:"layer",description:"图层",type:"str",required:!0},{name:"lineweight",description:"线重",type:"float",required:!0}],_s=(e,n)=>{n.layer&&x3(n.layer);const i=l=>{n.color?l.trueColor=new te.McCmColor(...v3(n.color)):l.trueColor=new te.McCmColor(te.MxCpp.getCurrentDatabase().getCurrentlyDrawColor()),n.layer?l.layer=n.layer:l.layer=te.MxCpp.getCurrentDatabase().getCurrentlyLayerName(),n.lineweight&&(l.lineweight=n.lineweight)};Array.isArray(e)?e.forEach(i):e&&i(e)},b3=e=>{const n=e.split(",").map(h=>Number(h)),i=[];let l=0;for(;l<n.length;){const h=n[l];l++;const p=n[l];if(l++,typeof h=="undefined"||typeof p=="undefined")return i;const _=new te.McGePoint3d(h,p);i.push(_)}return i},ur=e=>{if(typeof e=="object"&&"x"in e&&"y"in e)return new te.McGePoint3d(e.x,e.y);if(Array.isArray(e))return new te.McGePoint3d(e[0],e[1]);if(typeof e=="string"){const[n,i]=e.split(",").map(l=>Number(l));if(typeof n=="number"&&typeof i=="number")return new te.McGePoint3d(n,i)}};class w3{call(n){if(console.log(n),n&&n.pt1&&n.pt2){let i=te.MxCpp.getCurrentMxCAD();n.pt1&&(n.pt1=ur(n.pt1)),n.pt2&&(n.pt2=ur(n.pt2));const l=i.drawLine(n.pt1.x,n.pt1.y,n.pt2.x,n.pt2.y);_s(l.getMcDbEntity(),n),i.updateDisplay()}}regist_data(){return{filename:"drawline.json",name:"draw_line",description:"根据直线的开始点和结束点绘制一个直线段",params:[{name:"pt1",description:"直线开始点",type:"tuple[float, float]",required:!0},{name:"pt2",description:"直线结束点",type:"tuple[float, float]",required:!0},...gs]}}}function M3(){wa.regist(w3)}class T3{call(n){if(console.log(n),n&&n.cen&&n.radius){n.cen&&(n.center=ur(n.cen));let i=te.MxCpp.getCurrentMxCAD();const l=i.drawCircle(n.center.x,n.center.y,n.radius);_s(l.getMcDbEntity(),n),i.updateDisplay()}}regist_data(){return{filename:"drawcircle.json",name:"draw_circle",description:"根据圆心和半径绘制一个圆",params:[{name:"center",description:"圆的中心点",type:"tuple[float, float]",required:!0},{name:"radius",description:"圆的半径",type:"float",required:!0},...gs]}}}const E3=()=>{wa.regist(T3)};function Gr(e,n,i,l,h){const p=e.x,_=e.y,s=n.x,M=n.y,T=i.x,C=i.y,E=l.x,L=l.y,I=(p-s)*(C-L)-(_-M)*(T-E);if(I===0)return null;const B=((p-T)*(C-L)-(_-C)*(T-E))/I,O=-((p-s)*(_-C)-(_-M)*(p-T))/I,U=p+B*(s-p),q=_+B*(M-_),ee=new te.McGePoint3d(U,q,0);return h||B>0&&B<1&&O>0&&O<1?ee:null}function eu(e,n){const i=n.x,l=n.y;let h=!1;for(let p=0,_=e.length-1;p<e.length;_=p++){const s=e[p].x,M=e[p].y,T=e[_].x,C=e[_].y;M>l!=C>l&&i<(T-s)*(l-M)/(C-M)+s&&(h=!h)}return h}function sd(e,n,i,l){const h=e-i,p=n-l;let _=0;return h==0?_=Math.PI/2:_=Math.atan(Math.abs(p/h)),h<0&&p>=0?_=Math.PI-_:h<0&&p<0?_=Math.PI+_:h>=0&&p<0&&(_=Math.PI*2-_),_}function ld(e,n,i,l){const h=new te.McDbArc;return h.center=e,h.radius=n,h.startAngle=i,h.endAngle=l,h}class S3{call(n){return wn(this,null,function*(){console.log(n);let{center:i,radius:l,startAngle:h,endAngle:p,is3PDraw:_,point1:s,point2:M,point3:T}=n,C=te.MxCpp.getCurrentMxCAD();C.newFile(),C.zoomAll();const E=new te.MxCADUiPrPoint,L=new te.MxCADUiPrDist;if(_){if(s&&(s=ur(s)),M&&(M=ur(M)),T&&(T=ur(T)),E.setKeyWords(""),!s&&(E.setMessage("指定圆弧起点"),E.setUserDraw((B,O)=>{if(!M||!T)return;const U=new te.McDbArc;U.computeArc(B.x,B.y,M.x,M.y,T.x,T.y),O.drawMcDbEntity(U)}),s=yield E.go(),!s)||!M&&(E.setMessage("指定圆弧第二个点"),E.setUserDraw((B,O)=>{if(!s||!T)return;const U=new te.McDbArc;U.computeArc(s.x,s.y,B.x,B.y,T.x,T.y),O.drawMcDbEntity(U)}),M=yield E.go(),!M)||!T&&(E.setMessage("指定圆弧的端点"),E.setUserDraw((B,O)=>{if(!s||!M)return;const U=new te.McDbArc;U.computeArc(s.x,s.y,M.x,M.y,B.x,B.y),O.drawMcDbEntity(U)}),T=yield E.go(),!T))return;const I=new te.McDbArc;console.log(s.x,s.y,M.x,M.y,T.x,T.y),I.computeArc(s.x,s.y,M.x,M.y,T.x,T.y),_s(I,n),C.drawEntity(I),C.updateDisplay()}else{if(i&&(i=ur(i)),h&&(h=h*(Math.PI/180)),p&&(p=p*(Math.PI/180)),!i){E.setMessage("指定圆弧圆心"),E.setKeyWords(""),E.setUserDraw((O,U)=>{l&&U.drawMcDbEntity(ld(O,l,h||0,p||Math.PI*2))});const B=yield E.go();if(!B)return;i=B}if(!l&&(L.setBasePt(i),L.setMessage(te._ML_String("MxAiDrawCircleArc_Radius","指定圆弧半径")),L.setKeyWords(""),L.setUserDraw((B,O)=>{if(!i)return;const U=B.distanceTo(i);O.drawMcDbEntity(ld(i,U,h||0,p||Math.PI*2))}),l=yield L.go(),!l))return;if(!h){if(!i)return;L.setBasePt(i),L.setMessage(te._ML_String("MxAiDrawCircleArc_StartAngle","指定圆弧开始角")),L.setKeyWords(""),L.setUserDraw((O,U)=>{i&&l&&(h=sd(i.x,i.y,O.x,O.y)-Math.PI,U.drawMcDbEntity(ld(i,l,h||0,p||Math.PI*2)))});const B=yield L.go();if(!B)return;L.getDetailedResult()===tt.DetailedResult.kCoordIn&&(h=B*(Math.PI/180))}if(!p){if(!i)return;L.setBasePt(i),L.setMessage(te._ML_String("MxAiDrawCircleArc_EndAngle","指定圆弧结束角")),L.setKeyWords(""),L.setUserDraw((O,U)=>{i&&l&&(p=sd(i.x,i.y,O.x,O.y)-Math.PI,U.drawMcDbEntity(ld(i,l,h||0,p||Math.PI*2)))});const B=yield L.go();if(!B)return;L.getDetailedResult()===tt.DetailedResult.kCoordIn&&(p=B*(Math.PI/180))}const I=ld(i,l,h,p);_s(I,n),C.drawEntity(I),C.updateDisplay()}})}regist_data(){return{filename:"drawcirclearc.json",name:"draw_circle_arc",description:"绘制圆弧",params:[{name:"center",description:"圆弧圆心",type:"tuple[float, float]",required:!0},{name:"radius",description:"圆弧半径",type:"float",required:!0},{name:"startAngle",description:"圆弧开始角",type:"float",required:!0},{name:"endAngle",description:"圆弧结束角",type:"float",required:!0},{name:"is3PDraw",description:"是否三点绘制",type:"boolean",required:!0},{name:"point1",description:"三点绘制圆弧的第一个点(起点)",type:"tuple[float, float]",required:!0},{name:"point2",description:"三点绘制圆弧的第二个点",type:"tuple[float, float]",required:!0},{name:"point3",description:"三点绘制圆弧的第三个点(终点)",type:"tuple[float, float]",required:!0},...gs]}}}const A3=()=>{wa.regist(S3)};function F1(e=new te.McGePoint3d,n=new te.McGePoint3d,i=3){const l=n.x,h=n.y,p=e.x,_=e.y,s=Math.max(3,i),T=Math.sqrt(Qv(l-p,2)+Qv(h-_,2))/Math.cos(Math.PI/s),C=Math.atan2(h-_,l-p)-Math.PI/s,E=[];for(let L=0;L<s;L++){const I=C+L*2*Math.PI/s,B=p+T*Math.cos(I),O=_+T*Math.sin(I);E.push(new te.McGePoint3d(B,O))}return E}function O1(e=new te.McGePoint3d,n=new te.McGePoint3d,i=3){const l=[];i=Math.max(3,i),l.push(n);const h=Math.PI*2/i;for(let p=1;p<i;p++){const _=Math.cos(h*p),s=Math.sin(h*p),M=e.clone(),T=n.clone(),C=T.x-M.x,E=T.y-M.y,L=C*_-E*s+M.x,I=C*s+E*_+M.y,B=new te.McGePoint3d(L,I);l.push(B)}return l}function C3(e,n,i){let l=n.x-e.x,h=n.y-e.y,p=Math.sqrt(l*l+h*h),_=Math.atan2(h,l),s=2*Math.PI/Math.max(3,i),M=[e,n];for(let T=0;T<i;T++){let C=e.x+p*Math.cos(_+T*s),E=e.y+p*Math.sin(_+T*s);e=new te.McGePoint3d(C,E),M.push(e)}return M}class P3{call(n){return wn(this,null,function*(){te.MxCpp.getCurrentMxCAD().newFile(),console.log(n);let{isDrawToCenter:i,sideNum:l,startPoint:h,endPoint:p,radius:_,centerPoint:s,isTangentToTheCircle:M}=n;if(!l){const T=new te.MxCADUiPrInt;T.setMessage("输入边的数目<5>"),T.setKeyWords(""),T.clearLastInputPoint(),l=(yield T.go())||5}if(i){if(s)s=ur(s);else{const L=new te.MxCADUiPrPoint;if(L.setMessage(`
  2879. 指定正多变形的中心点`),L.setKeyWords(""),L.clearLastInputPoint(),s=yield L.go(),!s)return}let T=te.McGeVector3d.kXAxis,C;if(!_){const L=new te.MxCADUiPrDist;L.setMessage(te._ML_String("MxAiDrawPolygon_radius","指定圆的半径")),L.setKeyWords(""),L.setBasePt(s),L.setUserDraw((B,O)=>{if(M){const U=B.distanceTo(s);T=B.sub(s);const q=s.clone().addvec(B.sub(s).normalize().mult(U)),ee=F1(s,q,l),he=new te.McDbPolyline;ee.forEach(Ce=>{he.addVertexAt(Ce)}),he.isClosed=!0,O.drawMcDbEntity(he)}else{C=B;const U=new te.McDbPolyline;O1(s,B,l).forEach(q=>{U.addVertexAt(q)}),U.isClosed=!0,O.drawMcDbEntity(U)}});const I=yield L.go();if(!I)return;_=I}const E=new te.McDbPolyline;if(E.isClosed=!0,M){const L=s.clone().addvec(T.normalize().mult(_));F1(s,L,l).forEach(B=>{E.addVertexAt(B)})}else{if(!C){const L=te.McGeVector3d.kXAxis.clone().rotateBy(Math.PI/l).mult(_);C=s.clone().addvec(L)}O1(s,C,l).forEach(L=>{E.addVertexAt(L)})}te.MxCpp.getCurrentMxCAD().drawEntity(E)}else{const T=E=>{const L=new te.McDbPolyline;return C3(h,E,l||5).forEach(B=>{L.addVertexAt(B)}),L.isClosed=!0,L};if(h)h=ur(h);else{const E=new te.MxCADUiPrPoint;if(E.clearLastInputPoint(),E.setMessage(`
  2880. 指定边的第一个端点`),E.setKeyWords(""),h=yield E.go(),!h)return;E.setUserDraw((L,I)=>{I.drawMcDbEntity(T(L))})}if(p)p=ur(p);else{const E=new te.MxCADUiPrPoint;E.setBasePt(h),E.setMessage(`
  2881. 指定边的第二个端点`),p=yield E.go()}if(!p)return;const C=T(p);te.MxCpp.getCurrentMxCAD().drawEntity(C)}})}regist_data(){return{filename:"DrawPolygon.json",name:"draw_polygon",description:"绘制正多边形",params:[{name:"isDrawToCenter",description:"是否用圆绘制多边形",type:"boolean",required:!0},{name:"sideNum",description:"边数",type:"int",required:!0},{name:"startPoint",description:"边绘制提供开始点",type:"tuple[float, float]",required:!0},{name:"endPoint",description:"边绘制提供结束点",type:"tuple[float, float]",required:!0},{name:"radius",description:"圆的半径",type:"number",required:!0},{name:"centerPoint",description:"圆心",type:"tuple[float, float]",required:!0},{name:"isTangentToTheCircle",description:"外切于圆",type:"boolean",required:!0}]}}}const L3=()=>{wa.regist(P3)},N1=(e,n,i)=>{const l=Math.cos(i),h=Math.sin(i),p=n.x-e.x,_=n.y-e.y,s=p*l-_*h+e.x,M=p*h+_*l+e.y,T=n.z;return new te.McGePoint3d(s,M,T)},Py=(e,n,i=0)=>{const l=new te.McGePoint3d((e.x+n.x)/2,(e.y+n.y)/2,(e.z+n.z)/2),h=new te.McGePoint3d(e.x,n.y,e.z),p=new te.McGePoint3d(n.x,e.y,n.z),_=N1(l,h,i),s=N1(l,p,i);return[e,_,n,s]},U1=(e,n)=>[n.x>=e.x&&n.y>=e.y,n.x<e.x&&n.y>=e.y,n.x<e.x&&n.y<e.y,n.x>=e.x&&n.y<e.y];function V1(e,n,i){if(n===0&&i===0)return e;const[l,h,p,_]=e,s=l.distanceTo(_),M=l.distanceTo(h),[T,C,E,L]=U1(l,p),I=C||E?-n:n,B=E||L?-i:i;if(s-Math.abs(I)*2<=0||M-Math.abs(B)*2<=0)return e;const O=new te.McGePoint3d(l.x+I,l.y,l.z),U=new te.McGePoint3d(l.x,l.y+B,l.z),q=new te.McGePoint3d(h.x,h.y-B,h.z),ee=new te.McGePoint3d(h.x+I,h.y,h.z),he=new te.McGePoint3d(p.x-I,p.y,p.z),Ce=new te.McGePoint3d(p.x,h.y-B,p.z),K=new te.McGePoint3d(_.x,_.y+B,_.z),ie=new te.McGePoint3d(_.x-I,_.y,_.z);return[O,U,q,ee,he,Ce,K,ie]}function D3(e,n,i){if(e.isEqualTo(n))return 0;let l=e.c().addvec(n.c().sub(e).mult(.5)),h=n.c().sub(e);h.rotateBy(Math.PI/2,te.McGeVector3d.kZAxis);let p=new te.McDbLine(l,l.c().addvec(h)),_=i.c();_.rotateBy(Math.PI/2,te.McGeVector3d.kZAxis);let s=new te.McDbLine(e,e.c().addvec(_)),M=p.IntersectWith(s,te.McDb.Intersect.kExtendBoth);if(M.isEmpty())return 0;let T=M.at(0),C=T.distanceTo(e);h.normalize(),h.mult(C);let E=T.c().addvec(h),L=T.c().subvec(h),I=E.c().sub(e),B=L.c().sub(e),O=E;return I.angleTo1(i)>B.angleTo1(i)&&(O=L),te.MxCADUtility.calcBulge(e,O,n).val}class I3{call(n){return wn(this,null,function*(){console.log(n),te.MxCpp.getCurrentMxCAD().newFile();let{pt1:i,pt2:l,chamfer1Length:h,chamfer2Length:p,filletRadius:_,lineWidth:s,area:M,rectLength:T,rectWidth:C,rotationAngle:E}=n;const L=(O,U)=>{const[q,ee,he,Ce]=Py(O,U,E),K=new te.McDbPolyline;return K.addVertexAt(q,0,s,s),K.addVertexAt(ee,0,s,s),K.addVertexAt(he,0,s,s),K.addVertexAt(Ce,0,s,s),K.isClosed=!0,s&&(K.constantWidth=s),K},I=(O,U)=>{let q;if(_){const ee=V1(Py(O,U,E),_,_),[he,Ce,K,ie]=U1(O,U);if(ee.length===8){q||(q=new te.McDbPolyline);const ue=(se,Ue,Oe)=>{let We=new te.McGeVector3d(Oe);const st=D3(se,Ue,We);q.addVertexAt(se,st,s,s),q.addVertexAt(Ue,0,s,s)},ae=new te.McGeVector3d(-1,0),le=new te.McGeVector3d(0,1),De=new te.McGeVector3d(1,0),ye=new te.McGeVector3d(0,-1);ie&&(le.y=-1,De.x=1,ye.y=1),Ce&&(ae.x=1,le.y=1,De.x=-1,ye.y=-1),K&&(ae.x=1,le.y=-1,De.x=-1,ye.y=1),ue(ee[0],ee[1],ae),ue(ee[2],ee[3],le),ue(ee[4],ee[5],De),ue(ee[6],ee[7],ye),q.isClosed=!0}}else(h||p)&&(q||(q=new te.McDbPolyline),V1(Py(O,U,E),h||p,p||h).forEach(he=>{q.addVertexAt(he)}),q.isClosed=!0);return q||(q=L(O,U)),s&&(q.constantWidth=s),q};if(i)i=ur(i);else{const O=new te.MxCADUiPrPoint;if(O.setMessage("指定第一个角点"),O.setKeyWords(""),i=yield O.go(),!i)return}if(M&&(T&&(C=M/T),C&&(T=M/C)),T&&C&&(l=new te.McGePoint3d(i.x+C,i.y+T,0)),l)l=ur(l);else{const O=new te.MxCADUiPrPoint;if(O.setMessage("指定第二个角点"),O.setKeyWords(""),O.setUserDraw((U,q)=>{q.drawMcDbEntity(I(i,U))}),l=yield O.go(),!l)return}const B=I(i,l);_s(B,n),te.MxCpp.getCurrentMxCAD().drawEntity(B)})}regist_data(){return{filename:"drawRect.json",name:"draw_rect",description:"根据一些信息绘制矩形",params:[{name:"pt1",description:"一个对角点",type:"tuple[float, float]",required:!0},{name:"pt2",description:"另一个对角点",type:"tuple[float, float]",required:!0},{name:"lineWidth",description:"矩形线的宽",type:"float",required:!0},{name:"filletRadius",description:"圆角半径",type:"float",required:!0},{name:"chamfer1Length",description:"第一个倒角距离",type:"float",required:!0},{name:"chamfer2Length",description:"第二个倒角距离",type:"float",required:!0},{name:"rectLength",description:"长度",type:"float",required:!0},{name:"rectWidth",description:"矩形宽度",type:"float",required:!0},{name:"area",description:"面积",type:"float",required:!0},{name:"rotationAngle",description:"旋转角度",type:"float",required:!0},...gs]}}}function R3(){wa.regist(I3)}const no=(e,n,i,l,h)=>{const p=new te.McDbEllipse,_=new te.McGePoint3d((e.x+n.x)/2,(n.y+n.y)/2),s=e.sub(n),M=s,T=e.distanceTo(n)/2,E=i/2/T;return p.center=_,p.majorAxis=s,p.minorAxis=M,p.radiusRatio=E,p.startAngle=l,p.endAngle=h,p};class z3{call(n){return wn(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:h}=n;const p=te.MxCpp.getCurrentMxCAD();p.newFile();const _=new te.MxCADUiPrPoint,s=new te.MxCADUiPrDist;if(i&&(i=ur(i)),l&&(l=ur(l)),!i&&(_.setMessage("指定椭圆的轴端点1"),_.setKeyWords(""),_.setUserDraw((T,C)=>{l&&h&&C.drawMcDbEntity(no(T,l,h,0,Math.PI*2))}),i=yield _.go(),!i)||!l&&(_.setMessage("指定椭圆的轴端点2"),_.setKeyWords(""),_.setUserDraw((T,C)=>{i&&h&&C.drawMcDbEntity(no(i,T,h,0,Math.PI*2))}),l=yield _.go(),!l))return;if(!h){s.setMessage("指定半轴长度"),s.setKeyWords("");const T=new te.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(s.setBasePt(T),s.setUserDraw((C,E)=>{i&&E.drawMcDbEntity(no(i,l,T.distanceTo(C),0,Math.PI*2))}),h=yield s.go(),!h)return}const M=no(i,l,h,0,Math.PI*2);_s(M,n),p.drawEntity(M)})}regist_data(){return{filename:"drawellipse.json",name:"draw_ellipse",description:"绘制椭圆",params:[{name:"endPoint1",description:"椭圆端点1",type:"tuple[float, float]",required:!0},{name:"endPoint2",description:"椭圆端点2",type:"tuple[float, float]",required:!0},{name:"halfAxisLength",description:"半轴长度",type:"float",required:!0},...gs]}}}class k3{call(n){return wn(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:h,startAngle:p,endAngle:_}=n;const s=te.MxCpp.getCurrentMxCAD();s.newFile();const M=new te.MxCADUiPrPoint,T=new te.MxCADUiPrDist;if(i&&(i=ur(i)),l&&(l=ur(l)),p&&(p=p*(Math.PI/180)),_&&(_=_*(Math.PI/180)),!i&&(M.setMessage("指定椭圆的轴端点1"),M.setKeyWords(""),M.setUserDraw((I,B)=>{l&&h&&B.drawMcDbEntity(no(I,l,h,0,Math.PI*2))}),i=yield M.go(),!i)||!l&&(M.setMessage("指定椭圆的轴端点2"),M.setKeyWords(""),M.setUserDraw((I,B)=>{i&&h&&B.drawMcDbEntity(no(i,I,h,0,Math.PI*2))}),l=yield M.go(),!l))return;const C=new te.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(!h&&(T.setMessage("指定半轴长度"),T.setKeyWords(""),T.setBasePt(C),T.setUserDraw((I,B)=>{i&&B.drawMcDbEntity(no(i,l,C.distanceTo(I),0,Math.PI*2))}),h=yield T.go(),!h))return;const E=sd(C.x,C.y,i.x,i.y);if(!p){T.setMessage(te._ML_String("EllipticalArc_startAngle","指定起点角度")),T.setKeyWords(""),T.setUserDraw((B,O)=>{p=sd(C.x,C.y,B.x,B.y)-E-Math.PI,O.drawMcDbEntity(no(i,l,h,p,Math.PI*2))});const I=yield T.go();if(!I)return;T.getDetailedResult()==tt.DetailedResult.kCoordIn&&(p=I*(180/Math.PI))}if(!_){T.setLastInputPoint(C),T.setMessage(te._ML_String("EllipticalArc_endAngle","指定端点角度")),T.setKeyWords(""),T.setUserDraw((B,O)=>{_=sd(C.x,C.y,B.x,B.y)-E-Math.PI,O.drawMcDbEntity(no(i,l,h,p,_))});const I=yield T.go();if(!I)return;T.getDetailedResult()===tt.DetailedResult.kCoordIn&&(_=I*(180/Math.PI))}const L=no(i,l,h,p,_);_s(L,n),s.drawEntity(L)})}regist_data(){return{filename:"drawellipseArc.json",name:"draw_ellipse_arc",description:"绘制椭圆弧",params:[{name:"endPoint1",description:"椭圆弧端点1",type:"tuple[float, float]",required:!0},{name:"endPoint2",description:"椭圆弧端点2",type:"tuple[float, float]",required:!0},{name:"halfAxisLength",description:"半轴长度",type:"float",required:!0},{name:"startAngle",description:"开始角度",type:"float",required:!0},{name:"endAngle",description:"结束角度",type:"float",required:!0},...gs]}}}const B3=()=>{wa.regist(z3),wa.regist(k3)},ha=class ha{constructor(n,i,l=50){this.width=50,this.isDraw=!1,this.update(n,i,l)}update(n,i,l=this.width){let h=n.clone().sub(i).normalize();h=new te.McGeVector3d(-h.y,h.x,0).mult(l/2);const p=h.clone().negate();this.outsidePoints=[n.clone().addvec(h),i.clone().addvec(h)],this.insidePoints=[n.clone().addvec(p),i.clone().addvec(p)],this.width=l,this.startPoint=n.clone(),this.endPoint=i.clone(),this.outsideLine?(this.outsideLine.startPoint=this.outsidePoints[0],this.outsideLine.endPoint=this.outsidePoints[1]):this.outsideLine=new te.McDbLine(this.outsidePoints[0],this.outsidePoints[1]),this.insideLine?(this.insideLine.startPoint=this.insidePoints[0],this.insideLine.endPoint=this.insidePoints[1]):this.insideLine=new te.McDbLine(this.insidePoints[0],this.insidePoints[1]),this.startClosedLine?(this.startClosedLine.startPoint=this.outsidePoints[0],this.startClosedLine.endPoint=this.insidePoints[0]):this.startClosedLine=new te.McDbLine(this.outsidePoints[0],this.insidePoints[0]),this.endClosedLine?(this.endClosedLine.startPoint=this.outsidePoints[1],this.endClosedLine.endPoint=this.insidePoints[1]):this.endClosedLine=new te.McDbLine(this.outsidePoints[1],this.insidePoints[1])}clone(){const n=new ha(this.startPoint,this.endPoint,this.width);return n.insideLine=this.insideLine.clone(),n.outsideLine=this.outsideLine.clone(),n}hiddenStartClosedLine(){this.startClosedLine.visible=!1}hiddenEndClosedLine(){this.endClosedLine.visible=!1}getClosedStartLineToDiffWallInsideLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffWallOutsideLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffWallInsideLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffWallOutsideLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getInsideToDiffInsideIntersectionPoint(n,i=!1){return Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffOutsideIntersectionPoint(n,i=!1){return Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getInsideToDiffOutsideIntersectionPoint(n,i=!1){return Gr(n.outsideLine.startPoint,n.outsideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffInsideIntersectionPoint(n,i=!1){return Gr(n.insideLine.startPoint,n.insideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getClosedStartLineToDiffLineClosedStartLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.startClosedLine.startPoint,n.startClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffLineClosedEndLineIntersectionPoint(n,i=!1){return this.startClosedLine.visible?Gr(n.endClosedLine.startPoint,n.endClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedStartLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.startClosedLine.startPoint,n.startClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedEndLineIntersectionPoint(n,i=!1){return this.endClosedLine.visible?Gr(n.endClosedLine.startPoint,n.endClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}isCorner(n){const i=n.startPoint.sub(n.endPoint).normalize(),l=i.clone().mult(n.width),h=i.clone().mult(-n.width),p=n.insideLine.startPoint.clone().addvec(l),_=n.insideLine.startPoint.clone().addvec(h),s=n.outsideLine.startPoint.clone().addvec(h),M=n.outsideLine.startPoint.clone().addvec(l),T=n.insideLine.endPoint.clone().addvec(l),C=n.insideLine.endPoint.clone().addvec(h),E=n.outsideLine.endPoint.clone().addvec(h),L=n.outsideLine.endPoint.clone().addvec(l),I=eu([p,_,s,M],this.startPoint),B=eu([p,_,s,M],this.endPoint),O=eu([T,C,E,L],this.startPoint),U=eu([T,C,E,L],this.endPoint);return[{start:I,end:B},{start:O,end:U}]}handlingCorners(n){const[i,l]=this.isCorner(n);if(l.start){this.outsideLine.startPoint=n.outsideLine.endPoint=this.getOutsideToDiffOutsideIntersectionPoint(n,!0),this.insideLine.startPoint=n.insideLine.endPoint=this.getInsideToDiffInsideIntersectionPoint(n,!0),this.hiddenStartClosedLine(),n.hiddenEndClosedLine();return}else if(l.end){this.outsideLine.endPoint=n.insideLine.endPoint=this.getOutsideToDiffInsideIntersectionPoint(n,!0),this.insideLine.endPoint=n.outsideLine.endPoint=this.getInsideToDiffOutsideIntersectionPoint(n,!0),this.hiddenEndClosedLine(),n.hiddenEndClosedLine();return}else if(i.start){this.insideLine.startPoint=n.outsideLine.startPoint=this.getInsideToDiffOutsideIntersectionPoint(n,!0),this.outsideLine.startPoint=n.insideLine.startPoint=this.getOutsideToDiffInsideIntersectionPoint(n,!0),this.hiddenStartClosedLine(),n.hiddenStartClosedLine();return}else if(i.end){this.outsideLine.endPoint=n.outsideLine.startPoint=this.getOutsideToDiffOutsideIntersectionPoint(n,!0),this.insideLine.endPoint=n.insideLine.startPoint=this.getInsideToDiffInsideIntersectionPoint(n,!0),this.hiddenEndClosedLine(),n.hiddenStartClosedLine();return}}processingIntersection(){const n=[];ha.lines.forEach(i=>{const l=this.getInsideToDiffInsideIntersectionPoint(i),h=this.getInsideToDiffOutsideIntersectionPoint(i),p=this.getOutsideToDiffOutsideIntersectionPoint(i),_=this.getOutsideToDiffInsideIntersectionPoint(i);(l||h||p||_)&&n.push({diffLine:i,intersectionPoints:[l,h,p,_]})}),n.forEach(({diffLine:i,intersectionPoints:l})=>{const[h,p]=this.isCorner(i);h.end||h.start||p.start||p.start;const[_,s,M,T]=l,C=[i.insideLine.startPoint,i.insideLine.endPoint,i.outsideLine.endPoint,i.outsideLine.startPoint];if(eu(C,this.startPoint),eu(C,this.endPoint),_&&s&&M&&T){const E=Gr(this.startPoint,this.endPoint,i.startPoint,i.endPoint),L=new ha(this.startPoint,E,this.width),I=new ha(E,this.endPoint,this.width),B=new ha(i.startPoint,E,i.width),O=new ha(E,i.endPoint,i.width);L.insideLine.startPoint=this.insideLine.startPoint,L.outsideLine.startPoint=this.outsideLine.startPoint,I.insideLine.endPoint=this.insideLine.endPoint,I.outsideLine.endPoint=this.outsideLine.endPoint,i.remove(),this.remove(),L.draw(),I.draw(),B.draw(),O.draw()}else if(M&&s||_&&T){const E=Gr(this.startPoint,this.endPoint,i.startPoint,i.endPoint,!0),L=new ha(i.startPoint,E,i.width);L.hiddenEndClosedLine();const I=new ha(E,i.endPoint,i.width);I.hiddenStartClosedLine(),i.remove(),L.draw(),I.draw()}else{if(n.length===1)return this.handlingCorners(i);p.start?(console.log("endCorner.start"),M&&(i.outsideLine.endPoint=this.outsideLine.startPoint=M),_&&(i.insideLine.endPoint=this.insideLine.startPoint=_),this.hiddenStartClosedLine(),i.hiddenEndClosedLine()):p.end?(console.log("endCorner.end"),T&&(i.insideLine.endPoint=this.outsideLine.endPoint=T),s&&(i.outsideLine.endPoint=this.insideLine.endPoint=s),this.hiddenEndClosedLine(),i.hiddenEndClosedLine()):h.start?(console.log("startCorner.start"),s&&(i.outsideLine.startPoint=this.insideLine.startPoint=s),T&&(i.insideLine.startPoint=this.outsideLine.startPoint=T),i.hiddenStartClosedLine(),this.hiddenStartClosedLine()):h.end&&(console.log("startCorner.end"),M&&(i.outsideLine.startPoint=this.outsideLine.endPoint=M),_&&(i.insideLine.startPoint=this.insideLine.endPoint=_),i.hiddenStartClosedLine(),this.hiddenEndClosedLine())}})}draw(n=!0){if(this.isDraw)return;const i=te.MxCpp.getCurrentMxCAD();if(this.outsideLine&&this.outsideLine.erase(),this.insideLine&&this.insideLine.erase(),!i)return;this.outsideLine.trueColor=new te.McCmColor(255,0,0),this.outsideId=i.drawEntity(this.outsideLine),this.insideLine.trueColor=new te.McCmColor(0,255,255),this.insideId=i.drawEntity(this.insideLine);const l=this.outsideId.getMcDbEntity();l&&(this.outsideLine=l);const h=this.insideId.getMcDbEntity();h&&(this.insideLine=h),this.startClosedId=i.drawEntity(this.startClosedLine),this.endClosedId=i.drawEntity(this.endClosedLine);const p=this.startClosedId.getMcDbEntity();p&&(this.startClosedLine=p);const _=this.endClosedId.getMcDbEntity();_&&(this.endClosedLine=_),i.updateDisplay(),ha.lines.add(this),this.isDraw=!0,n&&this.processingIntersection()}remove(){this.endClosedId&&this.endClosedId.erase(),this.startClosedId&&this.startClosedId.erase(),this.insideId&&this.insideId.erase(),this.outsideId&&this.outsideId.erase(),ha.lines.delete(this)}};ha.lines=new Set;let Ly=ha;class F3{call(n){if(n&&n.points){let i=te.MxCpp.getCurrentMxCAD();const l=b3(n.points);if(l.length<2)return;l.forEach((h,p)=>{const _=l[p+1];if(!_)return;new Ly(h,_,n.width).draw()}),i.updateDisplay()}}regist_data(){return{filename:"drawWall.json",name:"drawWall",description:"根据坐标点合集绘制墙",params:[{name:"points",description:"绘制墙的坐标点",type:"str",required:!0},{name:"width",description:"绘制墙的宽度",type:"float",required:!1},...gs]}}}setTimeout(()=>{te.MxCpp.App.getCurrentMxCAD().insertBlock(new URL("data:application/octet-stream;base64,TXhXZWIxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3LjAuMy4zLjIwMjMwOTA2LjEAAAAAAAAAAAAAAAAAAAMCAxEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAPAAAAe3R5cGU6MH10eHQuc2h4FgAAAHt0eXBlOjB9e2JpZ31oenR4dC5zaHgAUACVogAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABdAEAAAJ++AAAAAAAAACaeBuZm8GkzZhpilRyOJBAn4tc//5R2bFAe3kyw6fWWTAWwe1PchVprNnl8tMN/pIaWS/hZsrTh7OpqqM6DRLbNLHLv444qfqMJUFd6pQqzE/GB36X84thmjIVMBlKvqvpMFCFQBOiWYZAI4QbTgIDKHKXlbSonTHsTBcWU+YgeAjST3E5p17PW/6vaFQrxuESiD6lUcUJb3tsNa7Xyu9Z9AvP6MaOXJMHWCDPMIiVvDMqBWlZ38zKJKgqyEnUJbRr3pTur3EfRKqhJuCSOHFG1YPFoGYKLGeSeStBcHpaCU2gQJiF0HdudLQPz9VcK0wePfr5JLL390wEmhRuzwgk90fTnBUNkA1c3A+QLGL2GsZSdyZrin7sleYrIImkwmnf8eYYi4XiH8bu8GHQgOcBP3XHnsn8UsZ6YuTRmqdwbfCJS2QK/9fWC9dq6RfjZu2y/yh9/WJ860OBLFs6bcYr3gsQJRJ9sH9SUEpC2DbXL5zJalvMwYS8ZiUWMHkm2JgLvHQDQthvTtBO8cNk085/KHm+GPvpkJYI2uWgM5G67Dd89R1mJA36ajdRZoAbCi9DWaHIabFTB8uUe6EjjIw/Lih1jrDWxJwaxUWTnPpv+NzVSef2xLC1pb5UGbsYUrox9pf1zDTZGCI62UD+WqRhWtTsaT/gM0gc2BadKMORGy7AQ5gDFSedSMCezVrfEG3Jq2GX5BO8bLOJ9LtLHQ9tIYkWXb4EdGrtjEcOBrEiBIAAcSqyk8k/f59G7XTxLgGyjGe4WUiIqh4Aof8tYOzH0gBAaY3ZcK2PNePhDCcUWfgh8nf5BdDSxHab0LQyABIKJITRuzOycyh4ZWuQPNuALUTOJ3PnE5xLFJ8rBy2RmWiDhiO5JAky0TiH/mgJcgwXUB3heK8XCBBh2+hHJ9xoCh3xPIl3ltaBaDvqrZgyO+uBzPvdLOeljgbNPqlKnYykEDV+/Uc/2lgqQf5FlCyPhYaV7GSbZIROrYeGI2IBu1hxBVZhPUpFFmamGLpVo9+T7fbvuHLe1wjEBz/AysTUBsMLLcQHfTqS6uDI6EPsapoSyC9Ja+RRHiKQzJyoj3JJokdefntZ23+2/Wy6aZAGBJseTI93qtZnMxVEBuzasJeI1JtPPOs9hbTtZV5pEA7taTycqBjVZK4WjZdPfPcB22Aapi91ngktqafjIXaVWQs4VxjXjFoV9nc+pmC8dITVbJnnpNEZF+u+O3Z3olp9xgcqgdgauoHpoz4MYWzNRv7CQ6PenT0xfwOpGnNn8p/Z0SVh1np5Dj87O4BquzWCY/h+CBc+hbpFx7/ljvhyxDhOWydYPVEEQ8Z2I4RXD14VpIsjJdKXArxFs/Ml9kGun32aU7SbQQpNFdQJbFkLN3zhQYqPkPFB330qg5p4FJjNHufIDX6XeJaxU/t/oOTclmdsnnj3t82+KK2rpyRkAPgjQxl4LSzZKpIKRiLJX8x6ZLygrdGjkP5qq8VW/aFVCDhTqju/8+8aYTgPjFK7dlmiyYCYszy/QxSF2spXChXZN/qtLmfi+4h/7PcvOOxz1KYe44E1YdYi0Urmf2d2Mc2d1bQ9hHwJpEntuFsSlIII9dOtPBoZTLszMdVSfq/K2pD/amOa0MeNKdEXDKJ/6vXkBhftUfbOwxAT29dzxWZdPuXAQM2JieVzJD4TJN2jssnPocwGTnExPu+SJq2YxE0/GVm5erg67LtOxhyfw9ddqt87oceqksrppzLCMbEKOsYuDulMJ4EARLtzJmzF4Aq2cqnD6Swgy3W1Qhvk6c8WujhW+9Bg1J1ju4a5FV/aaPsp0qKtQb5JcLkmqYAJkdp3QRPzoQiRdeVLBW+rr5vclybWUY7qy2S1XJAxifQ573cvciggQ8zMH0Y4Ra2wSPrhL+ClLyMR9OlcPbtlFlt6vrvAtlPio0pFedXSPmvu8BxngBKWkux2dk7rQMlyTswH924BSaQk86y1TXQD3FlRrY3sHDSYi8zr5LcTXh9C9Fz1sgXMDU2ieYg+jAi5iXKA47VuTQp3uiKxxEdnWBiA3PK7rDQL2NCGnBAeDhpbCue6qfJeGnqHKTUzpriuxMlCLB64NV92xTls2p+COV/KNgKO5bkDu8lpGYAavW1YMgi1+zz4G0fqQYalAkNM7dKU1oXG+Ir1EumBRSqwDkhPD+NY2ZP976WZN+VBEHZSsSoYMCYjRvysX7QkAfosVzAdWAVlDgB1bZB+LNGxBrKsIK8jxp+A2sek6+rVTZSm0igaWZ5ycIzCyU/JhYiSsJlS5YvG+MV5C5DdQo0JO32YknSThUX80LuWtTohFUVPc3b+2kXzv8hsWwk09rZvYW2X6SyWWjtuciRAgVVh0zqGszaWIjwEngnkUNm45n60wRoHYyygQ2o4qWiAFnqJffiWfVkPQpAsLhgzI42rhNjwmQtGbGBuH4+SxrIkPr8oZfvmHDFTdZOrDv/80tB8jRaf+RvYrQw2reClkO8orYaXmC2R9RV2vR9CvFRoDizVVmAYfEtx7vHAblwnCJFLzb1UdxGVwOhVPILp9jLBLXFkOT6bips7we7o+6eu3DcUfBhCJ0xqfte6AFzxpbP7ucb2lAIWieKGaw/I6YI93xISXIbmA5wfOqPP+rPHSHbEVUE3LCG6BQGoO06K/onrjDToxNSHkIiKvPdg1GnFGkcGyOHXXfUiCzF6zs24ahYQzDW7WRJ3HmWhxUbD6AvbBZ2X4nPACTNgysK5/k4y6NiUUe9Pdq/KYJnHiZuRgzm512BxTtKRA/2eoOW7Hpi9sCYumYvBRFZisTYZJ0X2TnCe7QWlrTcED8q929lKCWJ8nF770jTmHWpWDPXTLjM5zL5v+BHdmT5JPVOQFLDpXSKzuj7AJ2JqJRT0u1BIV+Fw/UukTWORcPsQDC1QLNkkzI5W/jRL4rRaDZ8e+wS6LQGH9Ztt2EFB3m1ryfvak+i7FXrguXoz09Fokm+oXVLY07GtmwYqlV4BGyzPbFrKYF1BTKDDN1wzQOYtMzNDIk1+aoSnB4sxPoxqr6/lydxHdYLjr0uetm7daDcmKHEBJs3c999DxB4z1hmFDZ/zIH+qtqEonDy0BCJ0FvTTljEfCCABs9m0Fy4/3qCo7/mCXXu8Gdd69EAGt++5qZ88b43rB/Dq9rKT+VbmF1Rg6lnvwFyBGlYsW+lHw/ddv9K2UQ0eGLnrzD9ycvNfNmSX3ko0l6YioJfFl2X98yevvHV2pE70IJ3OUFND18Acq8hraEc3Wp4D1+uGFrDjtf0QPwrNfLDhFx1m+6DrcwoPvlnG5G6cNbdS6GUMyflVy4lGl/5GZPXTq5qI+aYbHWaGW2t3C7NoG0Lk2TQY2zSJIoFx/+1zPKXcI93j6VqHoEiXoFNx1TThmtw0bSs1McyWUjkPcnDLwJAxfMdB6NqVNqxU82m1wYEEyCL4ZbolEs7epDtiEAHc3zkNLtI02uIOCejTc+1agdjaZ4hufthr/q8HLo+qwAeWwiuWTC5GJO1xykhgpLCZFddHRfhR515UavDgFm35/AWydtVu/d+N78pAmRmiqrwSivcqxZ9JmnxgbJYFwqjpFPL46jPl3vpilqn+BP1cCe0NbyhCYQsMJdi/2VTudgAerpf0xE+kx7a6Ug9JiAvnx0a5ud6b4C+cuhOYRmaAPU7VEUZ3CZj3/OK04xEBNTRhHnGS2j4RWPPgcJep16Bvyxqpf0QLGv7PcP2X8XUCeE0T0OZpx450yHRy52mb9LQeCDvExkAKfXV75XakgWB520i9QP/DvmLIbkOnfZvznBPn6RZrup60uGG2vcFXVVBS2jumF/e79HXkarU1k5RV+A4AGU6nm3ksNOtOGVAetMibgBjt2Fcp8FK18NtK5BBKdbNKyaBv0M/XZGgoEiHKxRX2C0TFggUXtfIfU/WNmReSTwjHvegUIsEhZlZHxnSxX6zd8hGZEZZi5sxyKMGh/PSmK3ZbO22g3KCvnWMeKrPGLBpH/MuwsHRUHLCf7G/VTqQjZ+WkAWKbZotF/C6XyOJ1Rn1Os2kAtfTIAnDjftfkvQYv0wi4t6HSO/9kPFskSiuBO0rK/b1kLk2jkdkeh7vcH86sKleI9UMPFCec7ZcAJiwvA3VjTzilcLYFqTLfVM9kcZGCUAfx3F+1w6gzLNXMvWYibVE/RFYRqxDLSS44z6r+o0Nuhzk6FglhbjPbZw9LXLyIqix5Vxc5maYzECAVIzpyNp8vQ5PO3Jvl62swcecBlE2tiF5ziz1mPygGBTlJbThtakFwLgtK2Zdevg1W2RIEMLFaOEleRtfYLI5eO9Sz7VovMhMKJnaeqJaidqzcVlA4EmwXQczWoWxXUPNUgJPAVB4GNWrI8Y+DH0DzR9E/g8W0gmzUPvT2m0UirF1dlbo1+6lky6pmZWC0LTEWMLBJZ/1vWJzRLp+LrSn+IP++to6ilv3pjuVI/9o81Xuupu3xSWmLrdJv57t4FHYLmiH9goEkdVcA5PkUysKC0nl9gxPeubVZqz2Hu0xcf+xyg3p6R1r6FrnLm+0XYSRSuFmfTYCRfySmYSjHe2yNemVzl02Ue4a5+8WGjHwyvbiEDoOVeHQGIDei4i03ADUoUQ1fn5Lax8wa7mWb/w44r+dwSAG0irQLMlOjbU6lRicXWjHFRAyOobb7UHPEx8BuO7wD8ViHbsnk36Q1qXwj0rVhpxFZkfJnRGUikhA1g5if3f5UktkvGGCwtOXM9oYC+jzG65yAUhFBPoRCyPSuM/JXGr+ZdaMmpo9B2HJ1b4uf8FyZ3LHG8gOCi3F7FK/pj49e7iX8++pxXgNpclhZca7NMBEfSWH3Hw8oYDcqbTHwhsTTRX1aseRlexsxOP5HjixpG1rzoIU0p2E9Od8O667bD3OzJ+3cIcRN7aq2D9FSTPQ87BIVeFdvQ29BYAfwJJajubtYkD2FtBAOiGgssNXoJiXVdzPv01Y/HKIPfewjGaaXtP4i/MBrf0DwiP96bnL71BuMyALItvwsMiuugG2wlcXHwN09g8CzSv95CSiKDSMSgFbKSKJTAtPad0gMnHXXD8OwN6I1FPMj7ER+CtDBsXldfQcotwL1OD0WLgSaXqu8Kyvg+1cQV6ZNf6bSs2NKwZGMdmtCRrz2mjKzhNHA/T2f9XBIQ9P0qSBsSuujZGykUoGvvEKclDp90wsNbPRgiwLWI5CEylzqveQ6dV6f7nQO2lc7x/ZLfAj0NIiYlnH7Uaixx8lOVGvUhOY6snnyaMTj2YTzuMqSjb9qmeWpzNJcF2jLKOwT59KXtHAvh2ai7fVGyM80jtCyBGbpQk8JHF8V6dVFmum8IjE+8s8p6DJBI7u8YWqSIAnxFzR95D/AiLnmjmyEVHVXO0PPZYv31KXTIohDwlVP3sWOJK1/LsSAx0R4VlUJ9AloAABsj3EaApiVDecz4LxaWYiBbKNIGZHKe8ZaMo06uJ8SCJy6uygjJRxUkKW07oRmshiEft22HKrmUe/9j9zqvwIdUp8hoh+mNFJP2TJq01C/R7TiSi0Bd4RHCl1s354OK9LYkWbbT7p8bIk4YVTsi9NVuN9WENcFpoKW77nIwJZFFa21w7OtX9+u5C2GolXjA20N0S9yvKlq94iTlDgXpo+IMYMzkiDajti9woG6bPUqRQqWLAkxy99v3/eaYYv+XlKSwSnGuv8F64juJ3bEBXNgi092/TNJa8yJ41OCwr9AXbB/CHN+dcY3Et0Q2KTOdJDvwJ2PZpHYj9Yg4xJYHdD9nbwHdr/NACB0+Gybc6J46foWrXfWrVfcbc8eyRPcGJgUDSXWik385WpyLsJtPqNYdQyucXBZA6IB0HEiI6q3Chet7cWRSBLValAhkkJya2+bvDoJaD9ytsQuO7LoVQ6UBd66+qvFFgNsNe56pCCIlrnYGerwId5ED0FpDcjFwv/iUI4Mm5UXeFzIowmtNhh7uPUEIFd+Kzh6geuwSdMdTq8REhb3Kfuooe/mkleRjlCGQo3USyGFhrMbn9iK8VVKHEEBXRjnVfpqz08P0UlJPEk8RQAN8v/A7B7U0Wt9ICYhPu6/3bmRTQ/GsjYLCi4zqB2EdPT8U2DY3gLPRuKtHsQRXm7GhW3g+c/2w7aKUYgZUJlwrNk7KaDhLV0KZs4hjApf0EjmqrPupHj52pykMlNMFvQeZYBf3fFgV0qTfR6BBb3DmE25aN7CeKvTQ7v9zi644EttTpwZITTRJ0UonrGL/BiXwK3UPHyPNJKUoDPv68OYgUQlEI0+GBHLO8FEIeOB2vwpJ61/gEYOPJ/kce7e0z/wkfy5b22SospLW9KGtWCcpV8NzngHH/3Ef8/D8H/hXaOTGvXmnpB1xVHyEuwlvr2vp233KIfqCxezaSo970i9f+JQF1hN7P6z6pxrgLxyHtQx9OzRJAIsdP606nQ5SdYYYWtJlnnSxNKHC06u+loAVdpRi8sLMugfvTRJFM3zN9p5my6sALEwq5VtWCtC2fCH6ralFt2PNZaRpKsyxSmAr04VPloS8P6+D7IPaYFUEhmMM6sIglpFezTbl9IPeL6gZL6IR2Td+x3jc4Q50eadapDCSlvp3vQWpMOcjVaqNacgnH1wH8r97tbEabgK80B3XwRMwS2BOw7+24mNTdK3lkSrBST0N71h7dxTAP+Nz73ytaXCvj8VFr5LJrL6ld0mW4bVsVptcyNnL1Y2L+WKY+SGlS5Yxsj5fLvfy9hXZM9LpFHOz6KQqHUlRK0a+oBIGQKPiGNwBqa4pnKdWZ4xzHav6T7WwLamMSYztyu2CZJh8CKQPZcHJsNk20Nav7ZuInrhTOZLKb3dDUnEP9FN7L2TpwY67hErFUiWh19otAITOSKdRziJ/tNFvZ1ldgzXJMUiiUpLZryAxII9QeKp5QZxRzInBX2sCOZoLKo7XuvF3F2oqTI2g31zPtDGoXKmXTXvlDGhh/otKi/NCFGsuRSGGj4sHBEsNydgk2RTg1XjX8oOViRK6pHgQ1PBGpzEOB8Wm97U93opxT9wBddzDo0yqaCuEEH0jyJ8Cwj1Wx5OTab3oLk1yQCn45L9QfSZpL+QPdJrwSh+fV0EKXGcTg1dpO7GUIP8lU7HMtCrWXqf5CNKvaOEWiR8Mi1FZ9IfqBMvSJj7JBdybXI6oK1QDSqOyP5YcJs/OQU+WrnaG2ARBdIz53uUUHdxz5h595wk/peFR2+FZXY2CppCWnVyeso5UMSi/FqFEFPf3wd1Ur0gM24utARGB9SG/TrBE/TGdAd2RgDdvbGig50ujLPoJftREuVkR2puYGa4LfjlEFHu42WHukcwRHwPHv2pKy5mmq24NLiHnLCizydGoeO5qtvt47/6Sx2uxrgolbfOIXpJcjPSRPxKOrcZGBwyVzmOJ+/AuzOizW+la0VPIl0iUoZsoORG9gRyAunh4D2FTizYRjblV28ClaEyOs1P898dVFHW1PWQRic6o2zU9PgR1XnDkhI8GyaXZMgShngs7u+yrKfrd+dylJw5lFYindJ/dj4i9WxZjzDBFbl+Jnh6hFxgSr+rw8L4bZencNVULNOpzy4LUKT/7Is0HkJbdMZYyxbUXs1w2SV/N8c0zrZ/WmDxKwrfMK8uJPhzbuwFEyPSdvwi+BGhI2GjcTWzN5X27ZbJoFhdlxf5+xrVwJJLJAeKyu0Z279YHkojxES9YIwkluFc07iGigbCBh8cmwvS5ITWrOi1DWfqQhwbrqh8UxhX1MZTB330U9ZkjJbul0nM2QfgqZPfeanDcWKMjzbRZkAgFFuSY/JFjfIPFF/CpOd42RSKQ5eH0K39XFOMkK/eS8qVgrGYN6b+JZx3T5zrUa4Tc8NzUSdkDX8nRaIvlrBeI1Fq+RqnkuCD+THVGyynCX/ZS3HJUT6/YeI41CweBotCuts9nO/t1PotKejClV/7tfq1O8sSH8toKQGuLLWE5YVl5fXoYOWS9nZ+e870fqfT5VeAa8iTidjja0RqV5EtN0wz2g0ebueipXqJG/ZbGCkXyWLfxgR37SK4cM3bhOg6GsaGo3cnOmuBarZwDg3/irukg9SQzdjJhQXLVvt9MV2PmuqwUsJzNFGaDoXe+llGRiVoLgpZvUyEmwyRjyzn0XZyjl1/LM+ny4UvPy4XX6cHCFtq19WZQhDPcfJqW2dqdoybITJYT1XnO6co6o4PKdW7VztlyuMWBaTIOdyS+vzJTKyiKDbrijATvDoxjCqSEAaVM3JnGoPrIyc/jrqBFk6Z/uLoJbVwhvKk3eUM7M1hIqKhuGgXeEwW3gtzbVXrKw4cVvKq3EYnKPgqVOBGqAm2c86n6+yMO5VOidFRSJopPAhglOy5RTBhCo2Q2p1+H/px03wPXJlxEnQ0yUzjOvUX0DzvXHmTrcaY+oY4Qfv09IxBAy+3kYxpvjJV/4lqQh34FHgDXy7srIA1G3wxnNAWdxKCUtiYgJq86ONevJOQqzx8B/kK5UzUG+ijg/LcFTzbDAkZJsiVaT368jKLxvQNiMMefQWEtZs3E5DL5o2Ij/0uHHXn9Pbh+6DbgcnYKYBNuHuHNAgR/qMcjazcsxxq/bXsRmhpa8a7ZcIt03V01iEWk6Sgh93hvfuexe5W81+/Ac6ewQJ7aaVL64bs8dlgr2OetUHWe2rJGV54jzNpw0KdM9xN2B1fBDQLrA+2IIYHuPcSd5SLAwMcD8L5PDkTUtqzAgkVn1zJ8lLNGeO2PWDBd3F1fLnbZFpC0WCdnN9Z3j/yA63Xv0NhkR1rDPA7JDyFz0837HPU2bhPYYjejiKEllEilnOMVor7npXwkbpDNNWXkVsrsK+JbQRrhjeZyToTebg8OidZ87NtGIW3VCCW3DVlvdTM2Sqnb8xj6jiiDfDUZQ270tyjgPXlD+LVC77jNmmsun1tXiwbskddbjFKPoh6tFFUBT2TUqSwrb+BqxUornpz522hDg6BhagK3x3jBwzi4rl3T7Mw4dQcAt1tmIOUU18A9PIU6W4P0Quct6RKhjpmpF1OwoHoZENcau2GdpPc3501ATcirpck9qoCOK8EqI9UMLtekHn0k6LFIE+ax1NX96tOaBW57U5+a4iCki+U9d8qeAxVq3JwkEdHiEZDQ3zhQ9E+Oqa74riIG88Nci2mbwlhMBuzg6bjgqlkTn3JW/+dCWuoeuHVNQRY8HstQZz2BdU9OKTwMDoV6O1dPYMdMaxeFNussu3DueOMsMzuN4jMon2goUj6kIFnjNRw0FFn8hsAxBk9sOlZI+pdovDBdEcr77kAELEiwoxn0reM/cNumRTd1OZiRhuKmEO4Pc6NNInW87+1Y4P2kzB+hqLhkGQjYzSUMPkyTuOhqr3KphZNCJC9dPsOOpKCkPEQPjn6Bsd6vLn4RgAAPq8c0fk3h1aN2SPjkP7aGlYIEqLYh6EHSCdo13b7qKmltbSuqJdsjTEil7CvOfPXdLSCsuv3Ru+6rSslHMmdncuVG3JwJwCf3mrPWoOP70ZAqR1ZimlmryUf0DnbQb+2zFiGE15Er75uCLlsh7ErhCEgBzGrFlwFe2j8I0+KK9hAhiIL3PxlFR8GxvpCM6KGxxYSeS7j5yqKCch9He3NA1Tu05Tu/4spzP4QElyDmQa2s6pqk2nio/2Avh3hTHkekNKKp1JOZqzL04jOKr7aaaPlVxhP8qVr/vLir1CGdyBDswaKTSsTB9vOIRDIH7ixN+PKCOL6UcctaI8gAZErs2EWvrU/d83cMdbJmI3hpPOajiHrVVMPIJ6/ox0UeW7zsg7rpuot6tuBYCB5F6HhC5KR+hcILALlgckpCtVG3vet4rME6gGTpOI/sobiGU65yxOMPwofkgyuGOmcbhixrVdHMfGTm819VjaDuWJBdKvZhl9bt3WMKN756Ip8wM3F2w39y97FigtexAye+1xLj863ld1DZXc6xopv1I9WanoOnHmAnffpjiSycAaeTGoeTujt54Kpf8GNxN6ZjE9QAaO/z86W5Mdv0PgOK5i9NRgTymoo2Z0TtrGsVdr1qDu2/C72sWmWR2BwH+mM1uGsY0nmwhigax9RCAkaMPxCFJ5sOKyYl1FShS6EWV5Bv5FyZi7Q5M7DQantsY4MeKHihsLvNmxE54l5pnxee76TIdAKuLA4nj5bApUIcDfdYXauV9SjxU63mn52niGX4Ye6Ea/bvCR3reS8dPb9pG/xNczQUe9XGd8iXnBZ8T4rSa5BVqbbfT2zzLV+8fu8+NMn4HpCYElUnWK6ORxdS9pvpyF6DkgJMvBwSJ33raNFTwLebpT1PjNVleCiKAa2YIWOrQ+9hHrNPVE6GAv/eIibecP+cLyr1TnghyU4n0d+lpWMe7JYDnz1uXkhr1pXNh06Kaqnw7aV4gfXa9E5wJ0vVByoQ1+RyaEm8GQYTPbCVE+kHZFCunENKDKTomH6IAXduotzNSGEGC0dBofc6v5Z3goWdW8rSiYI04eW7ciXeOdduBCq9VlRkdhbeeBLH0JhjgL/D8pc1ffl0lH8TrNzHTFbZyCZ6Jw+/SdnGKZi/lVdRZXYx6GWmnUcyx7vHFYDLwqL7HOdl7dF/c+8juZFsBFRcUTT+Hmi5pWgjcEG+B5/Y7HZ3h5R+/8BZgPCA3mNyXhNjnkb6iaAhuXqkFH8ElRSiCPzf30+Lu5xAecppULz5XDfk+p13q383+lwzlQglDOpG4rD2e0iz7fiWCJF9SQeVe8g6DWJ0d3LNUAT7CLb0/WG9/Qj3EMj3YaOnLguZe2vRCLGzpknS6RcW+tYK2hxFmUwMQkkEv6rMN2S5XyqfrOlWNumuwo1iqaSG7FPdp5kGwI4BrbS6QYCeY7gLo7lFFgoNhTPD0jM8tIEBvrt6bI8tv0PARaIivEjXTP/Zss7IkLI6iWUwgjZplaafcTC58cairqZxZKsg/R+UxtlPp1lNj8EHcWMM8wukDGoAdt6PqBIEC3P7A/tYv9oFhztSornbHBO9ESE8SqWUbGYa08MwqhBSrBDdeXNMxkr+XAIa+Clxrik1sLA/6exK06IIYmrZ5GwbuvuqiFvkW1/SWGoIYh21tKJNA+k3oVnozIa0JOX37bFbk4wCKLTpBkRZtnMh1eKhd22nHeiYCpN0IRS2fFSvbHfXoiLzvvSDr5spr1zQ88jYgXREW8vvGaqcMPNYMP57+dWQhdmvnh6e6TBxrI7GRiCzo8hffp3Lq0EwMeh/aufKN0RDbRBZk2veSHvd3ipUQAerYWz6I4jkENDRzPwxeCRsCVbpX+1dg8eeTeRnA6mX3RsupLGEctSZE9uB2mbosDJ7sTrmUWuqwatjpjGJ23n6Ob8xA+SAh0WUOyuTeIVHHSY+XwmRdNq7nc6h3PRL0DWbOeKtklre9smuYcjwX9KIH5G7FgiIDX/za/aB4C9EvaAcjtLWbAwRKWjtavjo6UO3bKWY5+zkhiotVE+S30Trcliz/u/JwuDYBNZS55OrIc2RTqi14ZbBLslgagWU9KWHBYEWWLNOgwEJ486hTBMV3VkCGrltEZwW6Mn5Ugqj3WhASWC5o9iw5vIzICvp9wkn6BWs8lKCLLHPrT9edR2LZivH6y3U1612I//oj9npjfw42cqIhAoc/5U2uQdTbTMhuGdxrp+iguEJGKMyH3OU0wv+Ldso0n97yX8BQ/f/x/7hm7gspZTn8EeaaEiuJio1P0NnZ5iN9TlK4VKPmL1WchDnZBrZwTApGhjN0+2lb/J3q1uf+GTMbznOOTaUPAB9RF0a9yar1W2Xy2xTbINFa0j6HiiBOymouQVb4K17w+sgTNekoP+Kr0rgf8Z8g0syWHFTosOrI7zZMScjbHDjVYZoUPCh+hwlWTTtGBp6y0wdn9g6rT3auvrBnlzv1MPaiJM74tVFne9gt6nyxnHQbURJhy7Gb9ZVInm1HH7ABAqLnqUnNhZypt7AVXGg83k+coX8JfNcZ9lYQeJ8OAn7tVDD5MDZAGJp0z5V2R5wVL7D8DXxt51/0VYdVy06V+j7v5k3RK3BdoDypofI/F/Q+YPF6EIYWcdjwwUUJtOOwNQPJSHJFs6LDXSs1UcA4s72hOF9zmnmcOiii3msv8TKbm1wRafVQXb9I38YGA0uKAiU0PxboFEt0OohFeNaRCI2GRNpoevLOkbi39Nt8WoIKitTzpn4+1lbCd8ItZ1I3nuLDjmz9TjZ+pJRqF01rIeTHYC5wHf69uxhsoOL8gwnvx/N9G1YsYQnXAYgAUU0OprA3GVZRrevPltF6mg27yxgviItjf7aMejtlHXxaEqjAoK0DSBdd90/I3wjKl0A/3JVjpTBbLdo75pUGH+VfiK6R1gKBGcrkI1ZmRt5iRf156mRT6FU5Ymw3xXcT2q6ql8M3Wyo8Qk9hT9EfMFgD4/Ea22xDpiq0ZVmifUjrjncbEYpnR0Rc7Kiy8WJ5t4jFeOO+f1n73jGSe3E4BDp0h84oNjyvSs4v2vAhqMM3T1br5G59bcu8GruOXnIGYG/ArNJkBPS637kxoWSkuGvtBMG77GCttiyJWxU6R6N9Z5O2j5cmDn/OI5qSblPbniIydAkFO/fvLRVohM6AYiuR5R9dUgoG0WAjQASM8rasCsER0S1Y+fOkGYzFRjVULtKoaGTu0YOq/oPi8D3Llc8c/vZraQNtkhgWbPDE/tY4DKVWibtlcYbWjFqAaLOqs1zY7FKOBqYWNmqBDTBIBGMM1jInGGGwQpJTWhl3L4rv7chAZnsxQoDRouwkiKttbsafQ2NiNP8h/9np+Vmd3FDU9CS5+lcxB+79OKSmvieSXrV6hZyEwmChtHbu9qC2Ab4cDlRgi44lVv2wrQmCVZH+ZW8eXnJFwWF96PBrVnwaiK+lfJlhsFys7DYg1SCX3C4kzqcFZiYBDgyvHDkUiy6d+Ltf4xtMkda/3EKAmPqAPV3005NM84tj+TkB06yD4/xudp61p6q1sjb1sb5CeHxN7ZurceRufbqJiGV8R5+nl55cO4hl2JFi693lZzvDyjN6L+G6Nr4utMN57KblNKxo2tpCFpofRAe/UQI4xY9m+xNJDkMVb8zBHBPcrFEPmPsrVeJ+XYcYhG5SVJ2VUognvfKyQOsE+RUpEJHibiuh+2bUvvBHYOWErJKVZmGZvsz/6x+cg3Kz7+5KeYLNG+MFoHYYaeJzPHJHLyyneTJwz6vIcaukhbQ4JrwzmNq9bi27mdyQ8pngtUb0TsNMmHUSSHgiysNZMVZFU4BcfXaeR4xD0Da6pGBLitBCE1Yusn6IMtRNBqzkUh2QE4y+Ze6PnSyh2MUhkZZGmT7Maev8wLz7VQl3igK/afybrK1C3YMIBnDBDqlt6fM5dLMICs48qX2S7geOocHyVW12gkAUJeTlkoQcx7kFxCaaBhqx0v53t4xHS1xjzITb4ZrWtMSHtGFkks/kKPehYUKfvksas+rS/Qp3D8zTdaGPa2Ma6WOmhhoB/U1Sjfq+7+Pf94zNrRHUPmBR81w7melzqD4YX8CASyPzZWHrie3xccS8Fz9ip9wtuC94CLFw++AiB7D0dOZMSD4eQnXe5O84b2hr2ZIyv40mJA0zkQngSNMNCo3TpPvnvBCF9oHppF06j0mXKi5267F6IlSpgTeJveFVDzrAGehk//YJmCTG7bwD29N48827k8tDp+5sa+cThOAzCjPD3khHdUDaUavEhOKv/rlaF82HijIlSBrK912AAYD0+TBq0KYYAYjIazw3wl5g64X/O4WIcM7vWLbHB8Rvd8dy9riWaf3wzCni5zLZD+Xrsumvh65s4mDSfMJkiHx2Z8HXYYIBM0y7npGP/yijqsnPch+5OFzr/tvIIwKz33hMj56TRG10BZ2b7jBSnnpanRupVJOwaMEg9zHP3V9SMquX/TXMEadJAOcAQ14PEM5nKkiuG1IuTWi0JtbgYZkpQf5WDpbCRUxJCApc5I1cDnrDuMybFW4dFNV6iemp47fEG/tUtjs/TyCo6qNz74BizTO1Ew64D/58RdgZWrH18whitpPZmIKSkjBhufcGshIoDgRxczIqwQ/obz4bUu9E41iVkODe0zLaXtlKRGVKpsl658yG83+PQ6R82zRGXx9TGHAarJ9jifFabmn6sTTjfjwpg0n++aaYNFJb3qU4w0stq/NRYsAg+43/lzAhbP3QaVQWTS6MgW94bQKN6klz9OrekuKOUsL38JSuED611yCKeZQTnvYp8REtxQkgci+9txu6VmeDCdBiAk3GIYSmL1eVqDimtDgMO9SoZ0O5TRyVWZ3xJF/emOmkd2aCV6Ikphv9Qpq4udajboGrEBH4FJWU9s1RelvnYzQMCP8LT1iYsZhORIjUXFH1X8oRXRkbNm2Cx1mmsOsTF2BQVD4WWnuHaAWlj46XchlSyWPSm0UJpZjWVzxpAHy9Z0u+U/qNsbaHpFHRm4A41F/Jp22jdzlGen9VbHO019GPMl2hp09R8uINCcTwWRYFaG+zq8tB7jePGWIGVay0dANmezdy4E5ENIbE4SaxoFWpbvVsdf3buTEUXr9QMD1aTL9i1zAmQmvAm0rlAeMq2x00/gYzeOvmkHOsXoTl0p9yzmxD02JcubC0hzgHKG57JnyEDFKUgVtnLhyIin4Ab6veMO9xA+0pj3fz/MsYCaT3mYs74PHMmyWdiJCu3iUENkUK7C8cSlZRQwJvYCkc/WUZcfQ3/ApOlbYsJPhCwenjB+ovEeqe7qyXDnmO5e1lrGtgo/v4NC6DOpM1fmBTxVoAUbjwuRTg+JAj6xguq4UWmG13zzrsUui1s0NLiVu5pSU+cj3Is3orm441Rij+kjZF8/Le6lj2HbrMX4aRVMthQCFWvGvhj6lVD4riQ64S7OR8m2FvFstqFXy/sVM+WTHiSxZx8rbzgTTYTD2T4ErzM8N9C7qGwVlFgidHw6OsNvhTXVLSpQR6gAsnr9gEQ9W1n9pvi+URYXzSVvJ6+sbNDKHbgvLeNL8jrIhXTjdNFmoRfdGcnlDcWBzAz9xxXdv4RAEm3aYV4sGUTO7fax2rzHs9ClBKiRatGH+6VeThI2wENTxMy0lqD8MnCeSp9gI7k19c29AuhFkIzPo37qGStnBDDlMrmafvM3e64TZn23gD8I/aIM6g1lI+N/U7ZSG1DpMlQN8DY4N5DPesyu30oodAli3a8MO/0daIpcbX+9zf1i/8+P7u6SzWPYuc6MXx2xDtvrPPwqYgCYM8z/dJH4iC65Y20xjaj8qvfIEENT/ndu7EjBptJ3G2AlQqOilw2JW688ULIjiLy7AwMXk02hotLwyJyKDW5tEPLTd5s9aN6yJiLEVRJAmKNKDvpVfcnbho1T7KKiXVfBlvt8Ss2Rl8g/J9xCt2mIWi7iAF8LHvoFJa7qZymEhUOe6yl8n1dpBCx7Lww/Ovm8l/3WBczVSX1dUIAr4QLZWEtv+SARivcnKC/Tval+clzknKhUtfIdk02I0w9XvDsv8TLZ8luF0XjBoyfM/gm5x2w7LetEiMkSyq/WvS/8h3fC3ReWRavLNm/rk5ZKxPItZlm/QnoP+OttYxa+yczjlZ7xynew+wM1v8t45etYP4Qa9fnET2bzEZ8e6Dth8KwFIGqR3WNO4W71Ktfql244gsYUdRYV5vzZ4wlXcKdWKMW14leuMXXBOtCCemD7UCLhNa5KSK6GA5YZ+blWYH/pm9aJDI3dhe5ZY5MMqNrrBo2mSLWiNvLA0+QPQlLx4qiaYuzbj+eITttkPHzc6P7tVJiD99DK6bPjuDxARK2VHgqhZ4rxL9o9+5SqyzlSJcQ1iKtkArtKAnlrHY/Z2KwNNSVZHcg4lo3HWYwovVAVMoLHPcbA2LZal63jv+WtAXLfYbdFeqa5k1vcLBs1KeuL/FYNyoM3AKIBLuZJ023uQs5+He2AW0oGSqcO52Epca8Ovu7Y4Cxekvyifq8a9qV43DH9R3fkLSJ8NEWGg5cFtSKWHJCd0IEP9MsigTa5kEH+wLJ/J42b2jEvu0NDeUallmUA1JdJ4Xo4Dmgg8Zgs2V/Ad9b0AXrgr9A2BVOsptxxZsvDr0IIWDBRAtSpw40cfwwr82WzEQyDHmC0Q4oorrSnSTX8tNiSG/meF7CUbMwbPUAL/f30hZ+cIH3A3d51b3DWA+QxKg+thSrMFvEYDDvq1IPbXXXAxudvvDQIUsrLepPggVylgtWpiJq8PAkuBGm/0f9RxRxK3iEbsRthUFWpQPyRL6cREOXHz3ODSq4npQIU7ysU38BrxQJ71KvtMRArZE+BiQKOkRMI7vlXP+oI94q4qfEjFYlKtJKVLZp4pzbUTQq+EzqiXqSgzSKq8JXgxd2MM8/duT9Fzh9G+gyipdSO1KUEQEU6NWenYoAsLaIOwRZ8CcQi/YNGiZa/5nNoGyKdp3KLR09Bac4g/GFJ7CD0aytUax2N77nALI+J0dZU4hp0jICzGM1LQFUemP1rKDVD0r1FnPobHOkKthYf6weNnbabqYfDrXxF5vqHQ3IFNw5jTK5KCbanDRfZf9nwmTPLSWTjVSJt+NgUUKucfkLvXid6HAsON3z97CE5qxSw2+u4TsAyAWdHbrbnTCJm8jb18zTly0Ro1vgl3lfKBJL9MPj/TOlQnV31yl8sve2QF435GxLt6ny9cr56PDI5RGh6jeIPwhlaY1Sqbgf6Di42lK6wQ3lnCEqObQ6pH66mcrCrIGYtMklwQzBBAO3f1f9SUG2EKRL6GcIfN+BaGKuw6HMPnEcpZ9IY8L+g3ObnNoZgCIVfQDvpyr+vntLtPID7WoQIEVv5okUB3rbXPWBY7HNDOcTO4+/IoqXiEXrTcNxNTA4BkYt9wqkLXEjVoXo0p8hYIXbieE7lmeX544Mp25+TKy/kbn4K5lZRiXfucQjZO5uoUOcEsVDymPAneUTD3GAgZex61eIKxZD3BQXFies0jkoxQqdBx/cVrFRGK3VfHXtiMxGs70lFhER6MJ3FLizCaq6U+2BEw+/JxuFXS9ekHTKsFG3253FkyWk4/3JP+PPeALVyWj0X7kG3wjzLKD/CMqg6NCYS2eRUtelOeogop+HhG0J0e43nh2Nuf8HC5nl9Lhqf/zBF1q0zx9s4r43h9kvlOIPEutCfOHJJJ+Ude49Hv/m5xYZDNNv4//PQzeHWM5mntZ6fiDJ2P2uJy9ZNO+NC8xBZLkH/hu0kCU8P1c319MYBAENggCqAQ++N5Uam9HW7v7aWPvJ70CO/YXoW56w2gJgz30C4fCUolgPrgWa5qlBSLsuMT2wp/zwhVNniiwJx60ElHIHfax5KggtWpNK0rLIdTctJZqhj2nWKHQTquEZ7UY+K1cKTNA+bcwsKVmuUPCaLjS1PVwAky0sRQt+3fSuvHrfURpeg23kZtyLv7jHhcg5FkvT1Kr7pSvyIhl4F5Ngw4R5VED6e+B5zNcv8x69GpbLZbdk9Fb+JK450xOpO+Dqgh1zEhW1ZElJWuGq6sodYCIq7vEUid91t2r88zBoC8ocHflQoWKrbvDjvvSvq9ua+bgRZLMdCvTjyo8eoBs2iC5qJN8aZk4YzgV1fUkmtWhji2GwcN4q070Yy1/ccR4I8cuek8d7zMJBFb9K9/euZm1Em9mlSe4ak92tSarqoDhlYLsQNTuWggfbeM+jWzos4L48yuWJQ979v2zevjy48mExpg3W1zU5SXhQNVandDIEltav9+zHfcXAOIHAVQ4gMrL/F8LKw66rnpvWxnBCA1LuQ9FKngXOXr2UAQp9zKGiULYGQPrBCxqwBISr15px2fsTZb7T824dZjiM3PwLm+12SI2EXcoSuB5QrYMeAj8NIaX4MH1qdDsdLZV5s2cVI+QlraHy1/Rxv1rXx1a7jGi9FhpOhUzFu+ke8W4280QSPI8vShGbPcTJzxCA8AbzP7xNl+OgEFZDQFsNRY5bqsY7kR1VoRI09lxskqvWQ5z7S2CrobQyc7O2HlqZ1rt7iIQwR9CrgEaCZPqDGcVq6v0PJrUN14WpzoI1YY+v3idvJcn0scs39iIp2MHMiHumejg04iZiCc0MTTCJCABisj3rRFSQTT+kDBoIKDoFMIuublQ2Zgp9jc/dK39D2kHXX+fVoNe5DHUqNLN/Dzccz61QBWj8+q/Ynsq17o6k+uLMAB9/r5k2QQw+Zhi3lusF3Qnw+Hi54Anzq6vlx9KN4brFR93WNnc+pv0dyvfr287xW/bQZBFNGoUdvX3R6Eo+t9hxacaBTsBpSWYpfvOHzvYsfiCtZhMNahZWZuv/Jslt6vUhEuI0QdRlJMkGtEvtHMG9n3PmWb5g30OR1r2daf4Qx13gopDhRAh/uFVGLJLRJwBCFZQrOUsSOi1uS9gc3sldGGyjeuLwlOFiuzbFpA9twDO4gEcJ9mA4YdegbHhrZwPVL+MtCFYuCmkZk8LNJEgUIWuUEhU9wFdHOk1DXvomBtNgD19EQIng2wdTBH1XFgFiFlpnC2E6AjwAwDvHpAjAV0EWvH+4bWfeZwrUbPoywwJMGRrcfmHxqRdvwobnwSyNMLuSejapA7lr2gas1Gd4VfoLqp2ER2hWobMRRYCRSvfkxqZHn1QHw8Hf3GvfXlB512OXso8Az9JeVcoKwJgGyUDDB4wERZhr3VJSKjiRmy+o+xLAibQz2yEphmY+aKoyGoR9z6zLyYcKUm5zNqfjVALDmmZKU08cThtTtJseCIkX3FtI7TeTiZBvsGPLrCBT7TE3K567SMl+92JZYqjPySAVpnoHyjlRLm9C4i9sDUJpS/D5yYWTG2cdQjuhvh9YTWJ+TQ65OAlWDa7ReJmZ4TSAUH3JKmdiLoQ613p4W7o9ph2ufSLwsrkwrfeTLIg/TuStMYXhW1nbHmOnyGx4ES3iCXWlYv4ebYBlY8/ISEgC8C2CC/5+hZEr93nr3C4quj8jBUb03G8Fk+M4GP486WW57W5qhEF/ZpO9n5bQYbdkkWPG41s4ohRCpl5n2CoEjeIjqnhUgbq4JlsnYNzpOlgJ0GXMBr6lLUgpg8QzOp2lDYb4KTwww2KG0FRkP15j4+gmiEAgu8Yl0dQe3S5r8w55JORasg2GQ58sPUc2GYc98npui7vJ7h9dbEUI7cKjlpH3j10RddaTZgWG6rGxDrv8/XZweOrl56Ct2qGkJzOFzXm7yQ1J/IR1/2RfY59tKLvPblt/3C8fKqjIj4cCTGLnIf8vzTW0r5f3F/bEljwfcWotKp2z2p+g5/iR/po7siWv5xWetaNETqsv3c5AsBYbiKqgqh8xSl+l1dmjMlju8Gx4kkxz2sSNWotmoOvo3f5JiwjCtFusmLEgQmsqKW0hXS3yLL6E8J5yxy3wU1mSG7bDPVBFbRfAC7CF8X3AkcYEruySDP8KUEqs9XXlCRfnHKZep4oPz9hPFDWZYbHbrznLgNnw6eB7xTzytigCUNGRZuklePmG8hF74QOVkA9l2H6unT/qkwC/iZ7DkDZ6zwX5h87p52nAx4+bk2H/ZNgflSPXC7YTWCo66H78XFn0EYiP680r4TxB2ANav1dqB5EHM0k4fkn3moKsl1Y4+EKrGu2kK7x7y8cU6p99juNoG4nd2b8Tz6surtRaKMhWtptAaP2fIB/WCPhgjeEXmSsr3KucVj+xft5I5SiI8G9a+l23IbrPXUI2DKcPEu0DW8xuDOPyl8rWKW8Ek+Pmd3M9Z1fNK6z5ZTBLBVFuL4gEkVHw5BcJVOJd8EuWU5Gl52V/mJKLF0Yg7YQX+I9qZ5CAeJZxk49twwwVsG49mGSFJU+ZtmxSlTa4DoM7Gwg5tiM3KxZBYWecnpmnRpdbf/+U/+k1umJNQCwBznBTI0Cb2gJy6yDDmBgZ1AIUCzP/xVUYaG0XMkdou3k/T4EMKC0uF/LdFhGTlG0KoIw4GRO2BQwM7VKiZwGLLbgBYk8TpgTP/MPibIMF04yB8XfZ8930gLv1qrgTMHUNLwOkaS+eViSp8pb61PQzCj+S8BlE3iX0SDQRTxcaLxfDBLHN+jyh0vSG2nqlnYOzJ8wY9kz4n8MqSkOs8ksuUybe6+/kxw5jsljkZtpLKz3lI5cHwtB26cAkaLN5Cu9STICwZArrseQJixvect5mlOTOVhw/yTBqgl2jFe1tOQFTKkCyqVtCk6sJ+hjn7DTwx7C2qOucNw2Az6i04BKc0Twd1CfnXIBiUU3hUSxl8MFs0jjY9M4v2aSxU8m9Jtbgo5TIyvybbyafcOrk5/OVVwCfCyaEW4UCFobIU5USRMWVA5NPkLuVsVVw9ZxTxWQAY0BReVxV11reOPKQFMlReqlZdfpNYEEWz6hVyzNs+nqaccbhnAWy5L2844SislOnlx9TqnuJlZ4TJM6JwqFi9ht94uNOpZXGQPMpwKCYVmW/7XrlZrUUBxegsgbzhBYmRFsB3XbOu6nEDwe0TMDrw2vBJujgdti+OOh2z6gzjhCr3XRen0k9BYN0sU7BjwsmaDitBOmw4qgHWN6BhB4tf1ZL+4iephYBwG6Sw3Oh8j2ZemQDMEyCsQ7WFbKRz/BT9Lm7EFipljAsq3XhwBH65KMiVtCN3g3QHXsTwWTeeZ0IeJpCxg9z0B05nsgb50wpQQUE1eOKSyaHi7ODOJJeJOYtCS0XAvuTtRaByw2R0mLISrkg+3eBzPFk9OsPLRvq9FkNUGl4vz+VRkFxfFrdkZ12BWcnwqFMydXdTCqFfjRodw3TAM0LFGTXR0VjqEqsQfM523wOW6I/+KO3cOFWWH8dSh0aLjex8VgbBW99hgpsoQUQ5PkLmu26A125ZK1lM0okl5d0bpf3rb26oHAAR2MIScOlgo+k6zOJR3XkvERnMHs6c3kfCSg0qBAuSv3g3f3Kc4C8pUarjybSwlt1EbEsQuWVZqYLkPpMRF3DJN7Zq+OG5bZgzpYgV7nAvPbIAN5Fp+uCrtaVnWNYG/aEf3SChLPve77PbT88RB3UMapnIdHZCljAtr1TdUdzvBpguD0J1Sr3Is/RwXo2ACh+C1ZxpiHgU4zINgJ0XXX1+fmrPNmbxW+g9BBquaV3kgYv6+9jvyPsyWImkK81+75/FmCtfMjJBvKqOtEyfMOVuxVqC5jCzD88Wcjj3QypriAYNQNvvVFMQQpAzxIvcD4OAhl0rFtUBYsNHCHQISBnezxx0ZQJ/Cp25AfEwLtBpYgbTRpbJVBQXsGRwre1XC+K5DVo+pOJr9/6lfEr0bJdOWV+m4r7HTQzU4GafymiY8lFJ1wjo3H5k10nErzc2zjCMJTJ78XM+HtXnPD9rI7/EIS+3xv2t25BqTb6VzwqCbbfp1iGBl7yW7OjMtYVPrTUKcWCSYZzID7TddkY4ZpzXSEAdsFWmlWFT3FI9J3izLnFrqbdHiDRRXyQceEc4DVsYPrKaeZ+f11psAG15C7d25gAcnZlvCtFpIxUGnZLp+aPtF/xWkrXiwPICw6y4MBDv0qvcpMsiEfvjxy4nx0FkWnU6+56sIftFzL4iXFzhi9Z5xIYS+Ch1XZa5AYN/4ig6qicdqAM5q8IgZ9mvxULIIppBDGSZ0tpVBL4sVZVkZs0I562M4SEi5I1lxQOkWUJktBWc6crroswJU25Yl7jRKqfrm0u/bD3awGkNkNc4ezQmcaMdxqhUMZX+kqaaePped/5/JN2zabhUI5Xr6IcoT9xPtTjx+QnRYsWKBTlhUDQ5jf2ZHugJ/jyWa/I4URFxOPpIbV7pRitp2c5aOyAsW6aGuTzy+MSVrl/TCHlGlhJI2a56kJSmvZ8eFw8F6+1tbFS25CQC4J85uph4iYlvmvloVWnBoPV4xz+bqzIUUwE/E0Hr7ehc87Hovgh768k/gtN1uJc8lOjeyiYRdD53Pn4S2SFB8KQtnisYOnW9bWYoW8x9A4bR+59YmolCOFz0GF3K2SJYnmVt2iCTK1pqMgw3c+zWekn4OFJ+TvSHNTN4B3uh1PZGYM4ZWMaeRQK8rVY0wjGxh1YYk8jQBaWLaYErn51Acu7eAu2iiGeQmkebKpFaNuc9f0SS2TxPdzD/2ZXhLSPO6hs2TCVHT2ke/isclYcQe4wjoChaZLFwrBTkYvHvaZdC7JiV5/wGsCKHVkhnv8mOqGlyJ5cifYUp8q9agvUdFhxy8L8/ybg8F5czuiM8Oos17CRdSsOE9DQUAXkGVKRKdEOl5AcicBXkCO5lmZ4BymA3QHXN4/w8WckLgRds7c9v8uHQXPAdJqDJxqeTsz3iBoMU99hDBM7W7hGmZX6jEzjTroG4hGnhaYt2RR1JnMSSF2Yk3z0wJ0ZWab4Q=",self.location).href,"树")},2e3);class O3{call(n){return wn(this,null,function*(){let i=te.MxCpp.App.getCurrentMxCAD();if(n.name){const h=i.getDatabase().getBlockTable().get(n.name);if(!h||!h.isValid())return;let p=new te.McDbBlockReference;p.blockTableRecordId=h;let _=p.getBoundingBox(),s=0;if(_.ret){let M=_.maxPt.distanceTo(_.minPt);M>1e-5&&(s=i.getMxDrawObject().screenCoordLong2Doc(100)/M,p.setScale(s))}p.position=new te.McGePoint3d(n.pos[0],n.pos[1]),i.drawEntity(p),i.updateDisplay()}})}regist_data(){return{filename:"insertBock.json",name:"insertBock",description:"放置插入某个物品",params:[{name:"name",description:"要放置插入的物品名称",type:"str",required:!0},{name:"pos",description:"要放置插入物品的位置",type:"tuple[float, float]",required:!0}]}}}function N3(){wa.regist(F3),wa.regist(O3)}class U3{call(n){return wn(this,null,function*(){let i=te.MxCpp.getCurrentMxCAD();console.log(n),i.newFile();let l;const h=typeof n.isMText=="undefined"?!1:n.isMText,p=()=>{const s=new te.McDbMText;return s.textHeight=n.textSize||100,s.location=n.textPos||new te.McGePoint3d,s.contents=n.textString||"",s},_=()=>{const s=new te.McDbText;return s.height=n.textSize||100,s.textString=n.textString||"",s.position=n.textPos||new te.McGePoint3d,s};if(!n.textString){const s=new te.MxCADUiPrString;s.setMessage("请输入文字");const M=yield s.go();if(!M)return;n.textString=M}if(n.textPos)n.textPos=ur(n.textPos);else{const s=new te.MxCADUiPrPoint;s.clearLastInputPoint(),s.setMessage("请指定文字位置");const M=yield s.go();if(s.setUserDraw((T,C)=>{if(n.textPos=T,h){const E=p();C.drawMcDbEntity(E)}else{const E=_();C.drawMcDbEntity(E)}}),!M)return;n.textPos=M}if(!n.textSize){const s=new te.MxCADUiPrPoint;s.clearLastInputPoint(),s.setMessage("通过线段长度确定文字高度");const M=yield s.go();if(M){s.setUserDraw((C,E)=>{if(n.textSize=M.distanceTo(C),h){const L=p();E.drawMcDbEntity(L)}else{const L=_();E.drawMcDbEntity(L)}});const T=yield s.go();T&&(n.textSize=T.distanceTo(M))}}if(h){const s=p();l=i.drawEntity(s)}else{const s=_();l=i.drawEntity(s)}_s(l.getMcDbEntity(),n),i.updateDisplay()})}regist_data(){return{filename:"drawText.json",name:"draw_text",description:"绘制或者插入文字或者多行文字(文本)",params:[{name:"isMText",description:"绘制的文字是否为多行文字",type:"boolean",required:!0},{name:"textString",description:"绘制的文字的内容",type:"str",required:!0},{name:"textPos",description:"绘制的文字的位置",type:"tuple[float, float]",required:!0},{name:"textSize",description:"绘制的文字的高度",type:"float",required:!0},...gs]}}}function V3(){wa.regist(U3)}class G3{call(n){if(console.log(n),n.isWithdraw){typeof n.withdrawNum!="number"&&(n.withdrawNum=1);for(let i=0;i<n.withdrawNum;i++)tt.MxFun.sendStringToExecute("Mx_Undo")}if(n.isRestore){typeof n.restoreNum!="number"&&(n.restoreNum=1);for(let i=0;i<n.restoreNum;i++)tt.MxFun.sendStringToExecute("Mx_Redo")}}regist_data(){return{filename:"call_withdraw_restore.json",name:"call_withdraw_restore",description:"撤回撤销和恢复",params:[{name:"isWithdraw",description:"是否要撤回或撤销",type:"boolean",required:!0},{name:"isRestore",description:"是否要恢复",type:"boolean",required:!0},{name:"withdrawNum",description:"撤回撤销(上)几步",type:"int",required:!1},{name:"restoreNum",description:"恢复(前)几步",type:"int",required:!1}]}}}function H3(){wa.regist(G3)}class W3{constructor(){this.aryRegData=[]}regist(n){let i=new n,l=i.regist_data();te.MxCpp.Ai.addFunction(l.name,i.call),this.aryRegData.push(l)}regist_server(n){this.aryRegData.forEach(i=>{i.operation_code=n,te.MxCpp.Ai.registTool(i)}),te.MxCpp.Ai.reloadTools({operation_code:n})}}let wa=new W3;function j3(){return wn(this,null,function*(){let e=new te.MxCADUiPrString;e.setMessage(`
  2882. human:`);let n=yield e.go();n&&te.MxCpp.Ai.chat_tool(n)})}function q3(){return wn(this,null,function*(){let e=new te.MxCADUiPrString;e.setMessage(`
  2883. 输入 server_operate_code:`);let n=yield e.go();n&&wa.regist_server(n)})}function Z3(){tt.MxFun.addCommand("Mx_Ai",j3),tt.MxFun.addCommand("Mx_AiRegistServer",q3),M3(),E3(),A3(),L3(),B3(),N3(),V3(),H3(),R3()}function X3(e,n){let i=40,l=new te.MxCADResbuf;l.AddString("电杆层",0),l.AddString("INSERT",5020);let h=new te.MxCADSelectionSet;h.crossingSelect(e.x-i,e.y-i,e.x+i,e.y+i,l);let p=[];if(h.forEach(_=>{let s=_.getMcDbEntity();if(s){let M=s;n[M.getObjectID().id]&&p.push({dist:M.position.distanceTo(e),blk:n[M.getObjectID().id]})}}),p.length!=0)return p.sort((_,s)=>_.dist-s.dist),p[0].dist<i?p[0].blk:!1}function Y3(e,n,i){let l=n[e],h=l.ref,p=40,_=new te.MxCADResbuf;_.AddString("0",0),_.AddString("LINE",5020);let s=new te.MxCADSelectionSet;s.crossingSelect(h.position.x-p,h.position.y-p,h.position.x+p,h.position.y+p,_),s.forEach(M=>{let T=M.getMcDbEntity();if(T){let C=T,E=C.endPoint,L=C.startPoint.distanceTo(h.position);if(L>C.endPoint.distanceTo(h.position)&&(L=C.endPoint.distanceTo(h.position),E=C.startPoint),L<p&&!C[C.getObjectID().id]){let I=X3(E,n);I&&(i[C.getObjectID().id]={tag1:l.tag,tag2:I.tag,handle:C.getHandle()})}}})}function $3(){return wn(this,null,function*(){let e=new te.MxCADSelectionSet,n=new te.MxCADResbuf;n.AddString("电杆层",0),n.AddString("INSERT",5020),e.allSelect(n);let i={};e.forEach(h=>{let p=h.getMcDbEntity();if(p){let _=p,s=_.getAllAttribute(),M={};s.forEach(T=>{let C=T.getMcDbEntity();C.tag=="杆号"&&(M.tag=C.textString)}),M.tag&&(M.handle=_.getHandle(),i[h.id]={ref:_,tag:M.tag},console.log(M))}});let l={};Object.keys(i).forEach(h=>{Y3(h,i,l)}),Object.keys(l).forEach(h=>{console.log(l[h])})})}function J3(){tt.MxFun.addCommand("MxTest_UserGetData",$3)}function K3(){J3()}class cd extends te.McDbCustomEntity{create(n){throw new Error("Method not implemented.")}getTypeName(){throw new Error("Method not implemented.")}dwgInFields(n){throw new Error("Method not implemented.")}dwgOutFields(n){throw new Error("Method not implemented.")}worldDraw(n){throw new Error("Method not implemented.")}}class ud extends cd{constructor(n){super(n),this.pt=new te.McGePoint3d}create(n){return new ud(n)}getTypeName(){return"McDbGisPoint"}dwgInFields(n){return this.pt=n.readPoint("pt").val,!0}dwgOutFields(n){return n.writePoint("pt",this.pt),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n==0&&(this.pt.x+=i,this.pt.y+=l,this.pt.z+=h)}getGripPoints(){let n=new te.McGePoint3dArray;return n.append(this.pt),n}worldDraw(n){n.drawEntity(new te.McDbPoint(this.pt))}setPoint(n){this.assertWrite(),this.pt=n.clone()}getPoint(){return this.pt}}class hd extends cd{constructor(n){super(n),this.pts=[]}create(n){return new hd(n)}getTypeName(){return"McDbGisMultiPoint"}dwgInFields(n){return this.pts=n.readPoints("pts").val,!0}dwgOutFields(n){return n.writePoints("pts",this.pts),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n>=0&&n<this.pts.length&&(this.pts[n].x+=i,this.pts[n].y+=l,this.pts[n].z+=h)}getGripPoints(){let n=new te.McGePoint3dArray;return this.pts.forEach(i=>{n.append(i)}),n}worldDraw(n){this.pts.forEach(i=>{n.drawEntity(new te.McDbPoint(i))})}setPoint(n,i){this.assertWrite(),n>=0&&n<this.pts.length&&(this.pts[n]=i.clone())}getPoint(n){return n>=0&&n<this.pts.length?this.pts[n]:new te.McGePoint3d}addPoint(n){this.pts.push(n.clone())}removeAllPoint(){this.pts=[]}getPointCount(){return this.pts.length}}class dd extends cd{constructor(n){super(n),this.pts=[]}create(n){return new dd(n)}getTypeName(){return"McDbGisLineString"}dwgInFields(n){return this.pts=n.readPoints("pts").val,!0}dwgOutFields(n){return n.writePoints("pts",this.pts),!0}moveGripPointsAt(n,i,l,h){this.assertWrite(),n>=0&&n<this.pts.length&&(this.pts[n].x+=i,this.pts[n].y+=l,this.pts[n].z+=h)}getGripPoints(){let n=new te.McGePoint3dArray;return this.pts.forEach(i=>{n.append(i)}),n}worldDraw(n){let i=new te.McDbPolyline;this.pts.forEach(l=>{i.addVertexAt(l)}),n.drawEntity(i)}setPoint(n,i){this.assertWrite(),n>=0&&n<this.pts.length&&(this.pts[n]=i.clone())}getPoint(n){return n>=0&&n<this.pts.length?this.pts[n]:new te.McGePoint3d}addPoint(n){this.pts.push(n.clone())}removeAllPoint(){this.pts=[]}getPointCount(){return this.pts.length}}class pd extends cd{constructor(n){super(n),this.ptss=[]}create(n){return new pd(n)}getTypeName(){return"McDbGisMultiLineString"}dwgInFields(n){this.ptss=[];let i=n.readLong("ptss_n");for(let l=0;l<i.val;l++){let h=n.readPoints("ptss_"+l);h.ret&&this.ptss.push(h.val)}return!0}dwgOutFields(n){return n.writeLong("ptss_n",this.ptss.length),this.ptss.forEach((i,l)=>{n.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(n,i,l,h){this.assertWrite();let p=0;for(let _=0;_<this.ptss.length;_++){let s=this.ptss[_];for(let M=0;M<s.length;M++){if(p==n){this.ptss[_][M].x+=i,this.ptss[_][M].y+=l,this.ptss[_][M].z+=h,_=this.ptss.length;break}p++}}}getGripPoints(){let n=new te.McGePoint3dArray;return this.ptss.forEach(i=>{i.forEach(l=>{n.append(l)})}),n}worldDraw(n){for(let i=0;i<this.ptss.length;i++){let l=this.ptss[i],h=new te.McDbPolyline;l.forEach(p=>{h.addVertexAt(p)}),n.drawEntity(h)}}addPoints(n){this.ptss.push(n)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(n){return n>=0&&n<this.ptss.length?this.ptss[n]:[]}}class fd extends cd{constructor(n){super(n),this.ptss=[]}create(n){return new fd(n)}getTypeName(){return"McDbGisPolygon"}dwgInFields(n){this.ptss=[];let i=n.readLong("ptss_n");for(let l=0;l<i.val;l++){let h=n.readPoints("ptss_"+l);h.ret&&this.ptss.push(h.val)}return!0}dwgOutFields(n){return n.writeLong("ptss_n",this.ptss.length),this.ptss.forEach((i,l)=>{n.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(n,i,l,h){this.assertWrite();let p=0;for(let _=0;_<this.ptss.length;_++){let s=this.ptss[_];for(let M=0;M<s.length;M++){if(p==n){this.ptss[_][M].x+=i,this.ptss[_][M].y+=l,this.ptss[_][M].z+=h,_=this.ptss.length;break}p++}}}getGripPoints(){let n=new te.McGePoint3dArray;return this.ptss.forEach(i=>{i.forEach(l=>{n.append(l)})}),n}worldDraw(n){let i=new te.McDbHatch;for(let l=0;l<this.ptss.length;l++){let h=this.ptss[l];h.length>2&&i.appendLoop(new te.McGePoint3dArray(h))}i.numLoops>0&&n.drawEntity(i)}addPoints(n){this.ptss.push(n)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(n){return n>=0&&n<this.ptss.length?this.ptss[n]:[]}}function Q3(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标");let i=yield n.go();if(i){let l=new ud;l.setPoint(i),e.drawEntity(l)}})}function eL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标");let i=new hd,l=[];for(;;){n.clearLastInputPoint(),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let h=yield n.go();if(h){i.addPoint(h);let p=new te.McDbPoint(h);l.push(e.drawEntity(p))}else break}i.getPointCount()>0&&e.drawEntity(i),l.forEach(h=>{h.erase()})})}function tL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标");let i=new dd,l=[],h;for(;;){h&&(n.setBasePt(h),n.setUseBasePt(!0)),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let p=yield n.go();if(p){if(i.addPoint(p),h){let _=new te.McDbLine;_.startPoint=h,_.endPoint=p,l.push(e.drawEntity(_))}h=p}else break}i.getPointCount()>1&&e.drawEntity(i),l.forEach(p=>{p.erase()})})}function nL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标"),n.setKeyWords("[下一段线(N)]");let i=new pd,l=[],h=[],p;for(;;){p?n.setBasePt(p):n.setUseBasePt(!1),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let _=yield n.go();if(n.isKeyWordPicked("N"))l.length>1&&i.addPoints(l),l=[],p=void 0;else if(_){if(l.push(_),p){let s=new te.McDbLine;s.startPoint=p,s.endPoint=_,h.push(e.drawEntity(s))}p=_}else break}l.length>1&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),h.forEach(_=>{_.erase()})})}function iL(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint;n.setMessage("点取一个点坐标");let i=new fd,l=[],h=[],p;for(;;){p?n.setBasePt(p):n.setUseBasePt(!1),l.length>2&&n.setKeyWords("[闭合(C)/退出(E)]"),n.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let _=yield n.go();if(n.isKeyWordPicked("C")){let s=new te.McDbLine;s.startPoint=l[0],s.endPoint=l[l.length-1],h.push(e.drawEntity(s)),l.length>2&&i.addPoints(l),l=[],p=void 0}else{if(n.isKeyWordPicked("E"))break;if(_){if(l.push(_),p){let s=new te.McDbLine;s.startPoint=p,s.endPoint=_,h.push(e.drawEntity(s))}p=_}else break}}l.length>2&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),h.forEach(_=>{_.erase()})})}function rL(){let e=new te.MxCADSelectionSet,n=new te.MxCADResbuf;n.AddMcDbEntityTypes("McDbCustomEntity"),e.allSelect(n);let i={type:"FeatureCollection",features:[]};e.forEach(l=>{let h=l.getMcDbEntity();if(h){if(h instanceof ud){let _=h.getPoint(),s={type:"Feature",properties:{},geometry:{type:"Point",coordinates:[_.x,_.y,_.z]}};i.features.push(s)}else if(h instanceof hd){let p=h,_=[],s=p.getPointCount();for(let T=0;T<s;T++){let C=p.getPoint(T);_.push([C.x,C.y,C.z])}let M={type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:_}};i.features.push(M)}else if(h instanceof dd){let p=h,_=[],s=p.getPointCount();for(let T=0;T<s;T++){let C=p.getPoint(T);_.push([C.x,C.y,C.z])}let M={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:_}};i.features.push(M)}else if(h instanceof pd){let p=h,_=[],s=p.getPointsCount();for(let T=0;T<s;T++){let C=p.getPoints(T),E=[];for(let L=0;L<C.length;L++){let I=C[L];E.push([I.x,I.y,I.z])}_.push(E)}let M={type:"Feature",properties:{},geometry:{type:"MultiLineString",coordinates:_}};i.features.push(M)}else if(h instanceof fd){let p=h,_=[],s=p.getPointsCount();for(let T=0;T<s;T++){let C=p.getPoints(T),E=[];for(let L=0;L<C.length;L++){let I=C[L];E.push([I.x,I.y,I.z])}_.push(E)}let M={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:_}};i.features.push(M)}}}),console.log(JSON.stringify(i))}function aL(){tt.MxFun.addCommand("MxGis_DrawPoint",Q3),tt.MxFun.addCommand("MxGis_DrawMultiPoint",eL),tt.MxFun.addCommand("MxGis_DrawLineString",tL),tt.MxFun.addCommand("MxGis_DrawMultiLineString",nL),tt.MxFun.addCommand("MxGis_DrawPolygon",iL),tt.MxFun.addCommand("MxGis_Get_geojson",rL),new ud().rxInit(),new hd().rxInit(),new dd().rxInit(),new pd().rxInit(),new fd().rxInit()}var G1={exports:{}};(function(e,n){(function(i,l){e.exports=l()})(CP,function(){var i,l,h;function p(s,M){if(!i)i=M;else if(!l)l=M;else{var T="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+i+")(sharedChunk); ("+l+")(sharedChunk); self.onerror = null;",C={};i(C),h=M(C),typeof window!="undefined"&&window&&window.URL&&window.URL.createObjectURL&&(h.workerUrl=window.URL.createObjectURL(new Blob([T],{type:"text/javascript"})))}}p(["exports"],function(s){var M="2.8.2",T=C;function C(a,t,o,c){this.cx=3*a,this.bx=3*(o-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(c-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=c,this.p2x=o,this.p2y=c}C.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},C.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},C.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},C.prototype.solveCurveX=function(a,t){var o,c,d,m,y;for(t===void 0&&(t=1e-6),d=a,y=0;y<8;y++){if(m=this.sampleCurveX(d)-a,Math.abs(m)<t)return d;var v=this.sampleCurveDerivativeX(d);if(Math.abs(v)<1e-6)break;d-=m/v}if((d=a)<(o=0))return o;if(d>(c=1))return c;for(;o<c;){if(m=this.sampleCurveX(d),Math.abs(m-a)<t)return d;a>m?o=d:c=d,d=.5*(c-o)+o}return d},C.prototype.solve=function(a,t){return this.sampleCurveY(this.solveCurveX(a,t))};var E=L;function L(a,t){this.x=a,this.y=t}L.prototype={clone:function(){return new L(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,t){return this.clone()._rotateAround(a,t)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var t=a.x-this.x,o=a.y-this.y;return t*t+o*o},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,t){return Math.atan2(this.x*t-this.y*a,this.x*a+this.y*t)},_matMult:function(a){var t=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=t,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var t=Math.cos(a),o=Math.sin(a),c=o*this.x+t*this.y;return this.x=t*this.x-o*this.y,this.y=c,this},_rotateAround:function(a,t){var o=Math.cos(a),c=Math.sin(a),d=t.y+c*(this.x-t.x)+o*(this.y-t.y);return this.x=t.x+o*(this.x-t.x)-c*(this.y-t.y),this.y=d,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},L.convert=function(a){return a instanceof L?a:Array.isArray(a)?new L(a[0],a[1]):a};var I=typeof self!="undefined"?self:{};const B=Math.PI/180,O=180/Math.PI;function U(a){return a*B}function q(a){return a*O}const ee=[[0,0],[1,0],[1,1],[0,1]];function he(a){if(a<=0)return 0;if(a>=1)return 1;const t=a*a,o=t*a;return 4*(a<.5?o:3*(a-t)+o-.75)}function Ce(a,t,o,c){const d=new T(a,t,o,c);return function(m){return d.solve(m)}}const K=Ce(.25,.1,.25,1);function ie(a,t,o){return Math.min(o,Math.max(t,a))}function ue(a,t,o){return(o=ie((o-a)/(t-a),0,1))*o*(3-2*o)}function ae(a,t,o){const c=o-t,d=((a-t)%c+c)%c+t;return d===t?o:d}function le(a,t,o){if(!a.length)return o(null,[]);let c=a.length;const d=new Array(a.length);let m=null;a.forEach((y,v)=>{t(y,(w,A)=>{w&&(m=w),d[v]=A,--c==0&&o(m,d)})})}function De(a){const t=[];for(const o in a)t.push(a[o]);return t}function ye(a,...t){for(const o of t)for(const c in o)a[c]=o[c];return a}let se=1;function Ue(){return se++}function Oe(){return function a(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,a)}()}function We(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function st(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function St(a,t){a.forEach(o=>{t[o]&&(t[o]=t[o].bind(t))})}function gt(a,t){return a.indexOf(t,a.length-t.length)!==-1}function At(a,t,o){const c={};for(const d in a)c[d]=t.call(o||this,a[d],d,a);return c}function Dt(a,t,o){const c={};for(const d in a)t.call(o||this,a[d],d,a)&&(c[d]=a[d]);return c}function Ot(a){return Array.isArray(a)?a.map(Ot):typeof a=="object"&&a?At(a,Ot):a}const Pe={};function ge(a){Pe[a]||(typeof console!="undefined"&&console.warn(a),Pe[a]=!0)}function Ve(a,t,o){return(o.y-a.y)*(t.x-a.x)>(t.y-a.y)*(o.x-a.x)}function Ne(a){let t=0;for(let o,c,d=0,m=a.length,y=m-1;d<m;y=d++)o=a[d],c=a[y],t+=(c.x-o.x)*(o.y+c.y);return t}function Ie(){return typeof WorkerGlobalScope!="undefined"&&typeof self!="undefined"&&self instanceof WorkerGlobalScope}function it(a){const t={};if(a.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(o,c,d,m)=>{const y=d||m;return t[c]=!y||y.toLowerCase(),""}),t["max-age"]){const o=parseInt(t["max-age"],10);isNaN(o)?delete t["max-age"]:t["max-age"]=o}return t}let ce,we,Me,pe,Be=null;function $e(a){if(Be==null){const t=a.navigator?a.navigator.userAgent:null;Be=!!a.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Be}function ot(a){try{const t=I[a];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(t){return!1}}const bt={now:()=>Me!==void 0?Me:I.performance.now(),setNow(a){Me=a},restoreNow(){Me=void 0},frame(a){const t=I.requestAnimationFrame(a);return{cancel:()=>I.cancelAnimationFrame(t)}},getImageData(a,t=0){const{width:o,height:c}=a;pe||(pe=I.document.createElement("canvas"));const d=pe.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return(o>pe.width||c>pe.height)&&(pe.width=o,pe.height=c),d.clearRect(-t,-t,o+2*t,c+2*t),d.drawImage(a,0,0,o,c),d.getImageData(-t,-t,o+2*t,c+2*t)},resolveURL:a=>(ce||(ce=I.document.createElement("a")),ce.href=a,ce.href),get devicePixelRatio(){return I.devicePixelRatio},get prefersReducedMotion(){return!!I.matchMedia&&(we==null&&(we=I.matchMedia("(prefers-reduced-motion: reduce)")),we.matches)}};let Vt;const oe={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(Vt==null){const a=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Vt=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):a}catch(t){Vt=a}}return Vt},get EVENTS_URL(){return this.API_URL?this.API_URL.indexOf("https://api.mapbox.cn")===0?"https://events.mapbox.cn/events/v2":this.API_URL.indexOf("https://api.mapbox.com")===0?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},ve={supported:!1,testSupport:function(a){!xn&&mt&&(un?tn(a):xt=a)}};let xt,mt,xn=!1,un=!1;function tn(a){const t=a.createTexture();a.bindTexture(a.TEXTURE_2D,t);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,mt),a.isContextLost())return;ve.supported=!0}catch(o){}a.deleteTexture(t),xn=!0}I.document&&(mt=I.document.createElement("img"),mt.onload=function(){xt&&tn(xt),xt=null,un=!0},mt.onerror=function(){xn=!0,xt=null},mt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const dn="01",bn="NO_ACCESS_TOKEN";function ln(a){return a.indexOf("mapbox:")===0}function Gt(a){return oe.API_URL_REGEX.test(a)}const on=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Zt(a){const t=a.match(on);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function qe(a){const t=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${t}`}function Nt(a){if(!a)return null;const t=a.split(".");if(!t||t.length!==3)return null;try{return JSON.parse(decodeURIComponent(I.atob(t[1]).split("").map(o=>"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(o){return null}}class Qt{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const o=Nt(oe.ACCESS_TOKEN);let c="";return c=o&&o.u?I.btoa(encodeURIComponent(o.u).replace(/%([0-9A-F]{2})/g,(d,m)=>String.fromCharCode(+("0x"+m)))):oe.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${c}`:`mapbox.eventData:${c}`}fetchEventData(){const t=ot("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid");if(t)try{const d=I.localStorage.getItem(o);d&&(this.eventData=JSON.parse(d));const m=I.localStorage.getItem(c);m&&(this.anonId=m)}catch(d){ge("Unable to read from LocalStorage")}}saveEventData(){const t=ot("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid");if(t)try{I.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&I.localStorage.setItem(o,JSON.stringify(this.eventData))}catch(d){ge("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,o,c,d){if(!oe.EVENTS_URL)return;const m=Zt(oe.EVENTS_URL);m.params.push(`access_token=${d||oe.ACCESS_TOKEN||""}`);const y={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:M,skuId:dn,userId:this.anonId},v=o?ye(y,o):y,w={url:qe(m),headers:{"Content-Type":"text/plain"},body:JSON.stringify([v])};this.pendingRequest=Ge(w,A=>{this.pendingRequest=null,c(A),this.saveEventData(),this.processRequests(d)})}queueRequest(t,o){this.queue.push(t),this.processRequests(o)}}const Pn=new class extends Qt{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,t){oe.EVENTS_URL&&oe.ACCESS_TOKEN&&Array.isArray(a)&&a.some(o=>ln(o)||Gt(o))&&this.queueRequest(Date.now(),t)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Nt(oe.ACCESS_TOKEN),o=t?t.u:oe.ACCESS_TOKEN;let c=o!==this.eventData.tokenU;st(this.anonId)||(this.anonId=Oe(),c=!0);const d=this.queue.shift();if(this.eventData.lastSuccess){const m=new Date(this.eventData.lastSuccess),y=new Date(d),v=(d-this.eventData.lastSuccess)/864e5;c=c||v>=1||v<-1||m.getDate()!==y.getDate()}else c=!0;c?this.postEvent(d,{"enabled.telemetry":!1},m=>{m||(this.eventData.lastSuccess=d,this.eventData.tokenU=o)},a):this.processRequests()}},pn=Pn.postTurnstileEvent.bind(Pn),On=new class extends Qt{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,t,o,c){this.skuToken=t,this.errorCb=c,oe.EVENTS_URL&&(o||oe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(bn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),st(this.anonId)||(this.anonId=Oe()),this.postEvent(o,{skuToken:this.skuToken},c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a))}},Gn=On.postMapLoadEvent.bind(On),Zn=new class extends Qt{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,t,o,c){if(!oe.API_URL||!oe.SESSION_PATH)return;const d=Zt(oe.API_URL+oe.SESSION_PATH);d.params.push(`sku=${t||""}`),d.params.push(`access_token=${c||oe.ACCESS_TOKEN||""}`);const m={url:qe(d),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Je(m,y=>{this.pendingRequest=null,o(y),this.saveEventData(),this.processRequests(c)})}getSessionAPI(a,t,o,c){this.skuToken=t,this.errorCb=c,oe.SESSION_PATH&&oe.API_URL&&(o||oe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(bn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||this.getSession(o,this.skuToken,c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a)}},Wi=Zn.getSessionAPI.bind(Zn),Nn=new Set,Ci="mapbox-tiles";let ei,Ki,yi=500,Hr=50;function ki(){I.caches&&!ei&&(ei=I.caches.open(Ci))}function Wr(a){const t=a.indexOf("?");return t<0?a:a.slice(0,t)}let Sr=1/0;const _e={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(_e);class G extends Error{constructor(t,o,c){o===401&&Gt(c)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=o,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Z=Ie()?()=>self.worker&&self.worker.referrer:()=>(I.location.protocol==="blob:"?I.parent:I).location.href,de=function(a,t){if(!(/^file:/.test(o=a.url)||/^file:/.test(Z())&&!/^\w+:/.test(o))){if(I.fetch&&I.Request&&I.AbortController&&I.Request.prototype.hasOwnProperty("signal"))return function(c,d){const m=new I.AbortController,y=new I.Request(c.url,{method:c.method||"GET",body:c.body,credentials:c.credentials,headers:c.headers,referrer:Z(),signal:m.signal});let v=!1,w=!1;const A=(D=y.url).indexOf("sku=")>0&&Gt(D);var D;c.type==="json"&&y.headers.set("Accept","application/json");const R=(V,j,$)=>{if(w)return;if(V&&V.message!=="SecurityError"&&ge(V),j&&$)return k(j);const ne=Date.now();I.fetch(y).then(me=>{if(me.ok){const ke=A?me.clone():null;return k(me,ke,ne)}return d(new G(me.statusText,me.status,c.url))}).catch(me=>{me.code!==20&&d(new Error(me.message))})},k=(V,j,$)=>{(c.type==="arrayBuffer"?V.arrayBuffer():c.type==="json"?V.json():V.text()).then(ne=>{w||(j&&$&&function(me,ke,He){if(ki(),!ei)return;const Ze={status:ke.status,statusText:ke.statusText,headers:new I.Headers};ke.headers.forEach((lt,ht)=>Ze.headers.set(ht,lt));const Xe=it(ke.headers.get("Cache-Control")||"");if(Xe["no-store"])return;Xe["max-age"]&&Ze.headers.set("Expires",new Date(He+1e3*Xe["max-age"]).toUTCString());const Ye=Ze.headers.get("Expires");Ye&&(new Date(Ye).getTime()-He<42e4||function(lt,ht){if(Ki===void 0)try{new Response(new ReadableStream),Ki=!0}catch(vt){Ki=!1}Ki?ht(lt.body):lt.blob().then(ht)}(ke,lt=>{const ht=new I.Response(lt,Ze);ki(),ei&&ei.then(vt=>vt.put(Wr(me.url),ht)).catch(vt=>ge(vt.message))}))}(y,j,$),v=!0,d(null,ne,V.headers.get("Cache-Control"),V.headers.get("Expires")))}).catch(ne=>{w||d(new Error(ne.message))})};return A?function(V,j){if(ki(),!ei)return j(null);const $=Wr(V.url);ei.then(ne=>{ne.match($).then(me=>{const ke=function(He){if(!He)return!1;const Ze=new Date(He.headers.get("Expires")||0),Xe=it(He.headers.get("Cache-Control")||"");return Ze>Date.now()&&!Xe["no-cache"]}(me);ne.delete($),ke&&ne.put($,me.clone()),j(null,me,ke)}).catch(j)}).catch(j)}(y,R):R(null,null),{cancel:()=>{w=!0,v||m.abort()}}}(a,t);if(Ie()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,t,void 0,!0)}var o;return function(c,d){const m=new I.XMLHttpRequest;m.open(c.method||"GET",c.url,!0),c.type==="arrayBuffer"&&(m.responseType="arraybuffer");for(const y in c.headers)m.setRequestHeader(y,c.headers[y]);return c.type==="json"&&(m.responseType="text",m.setRequestHeader("Accept","application/json")),m.withCredentials=c.credentials==="include",m.onerror=()=>{d(new Error(m.statusText))},m.onload=()=>{if((m.status>=200&&m.status<300||m.status===0)&&m.response!==null){let y=m.response;if(c.type==="json")try{y=JSON.parse(m.response)}catch(v){return d(v)}d(null,y,m.getResponseHeader("Cache-Control"),m.getResponseHeader("Expires"))}else d(new G(m.statusText,m.status,c.url))},m.send(c.body),{cancel:()=>m.abort()}}(a,t)},Le=function(a,t){return de(ye(a,{type:"arrayBuffer"}),t)},Ge=function(a,t){return de(ye(a,{method:"POST"}),t)},Je=function(a,t){return de(ye(a,{method:"GET"}),t)};function Ke(a){const t=I.document.createElement("a");return t.href=a,t.protocol===I.document.location.protocol&&t.host===I.document.location.host}const je="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nt,yt;nt=[],yt=0;const Ut=function(a,t){if(ve.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),yt>=oe.MAX_PARALLEL_IMAGE_REQUESTS){const m={requestParameters:a,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return nt.push(m),m}yt++;let o=!1;const c=()=>{if(!o)for(o=!0,yt--;nt.length&&yt<oe.MAX_PARALLEL_IMAGE_REQUESTS;){const m=nt.shift(),{requestParameters:y,callback:v,cancelled:w}=m;w||(m.cancel=Ut(y,v).cancel)}},d=Le(a,(m,y,v,w)=>{c(),m?t(m):y&&(I.createImageBitmap?function(A,D){const R=new I.Blob([new Uint8Array(A)],{type:"image/png"});I.createImageBitmap(R).then(k=>{D(null,k)}).catch(k=>{D(new Error(`Could not load image because of ${k.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(y,(A,D)=>t(A,D,v,w)):function(A,D){const R=new I.Image,k=I.URL;R.onload=()=>{D(null,R),k.revokeObjectURL(R.src),R.onload=null,I.requestAnimationFrame(()=>{R.src=je})},R.onerror=()=>D(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const V=new I.Blob([new Uint8Array(A)],{type:"image/png"});R.src=A.byteLength?k.createObjectURL(V):je}(y,(A,D)=>t(A,D,v,w)))});return{cancel:()=>{d.cancel(),c()}}};function Et(a,t,o){o[a]&&o[a].indexOf(t)!==-1||(o[a]=o[a]||[],o[a].push(t))}function _n(a,t,o){if(o&&o[a]){const c=o[a].indexOf(t);c!==-1&&o[a].splice(c,1)}}class W{constructor(t,o={}){ye(this,o),this.type=t}}class Y extends W{constructor(t,o={}){super("error",ye({error:t},o))}}class ze{on(t,o){return this._listeners=this._listeners||{},Et(t,o,this._listeners),this}off(t,o){return _n(t,o,this._listeners),_n(t,o,this._oneTimeListeners),this}once(t,o){return o?(this._oneTimeListeners=this._oneTimeListeners||{},Et(t,o,this._oneTimeListeners),this):new Promise(c=>this.once(t,c))}fire(t,o){typeof t=="string"&&(t=new W(t,o||{}));const c=t.type;if(this.listens(c)){t.target=this;const d=this._listeners&&this._listeners[c]?this._listeners[c].slice():[];for(const v of d)v.call(this,t);const m=this._oneTimeListeners&&this._oneTimeListeners[c]?this._oneTimeListeners[c].slice():[];for(const v of m)_n(c,v,this._oneTimeListeners),v.call(this,t);const y=this._eventedParent;y&&(ye(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),y.fire(t))}else t instanceof Y&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,o){return this._eventedParent=t,this._eventedParentData=o,this}}var xe=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Mt(a,...t){for(const o of t)for(const c in o)a[c]=o[c];return a}function _t(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function Ft(a){if(Array.isArray(a))return a.map(Ft);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const t={};for(const o in a)t[o]=Ft(a[o]);return t}return _t(a)}class nn extends Error{constructor(t,o){super(o),this.message=o,this.key=t}}class Ln{constructor(t,o=[]){this.parent=t,this.bindings={};for(const[c,d]of o)this.bindings[c]=d}concat(t){return new Ln(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Dn={kind:"null"},wt={kind:"number"},cn={kind:"string"},$t={kind:"boolean"},fn={kind:"color"},Tn={kind:"object"},Sn={kind:"value"},di={kind:"collator"},Ar={kind:"formatted"},ai={kind:"resolvedImage"};function li(a,t){return{kind:"array",itemType:a,N:t}}function oi(a){if(a.kind==="array"){const t=oi(a.itemType);return typeof a.N=="number"?`array<${t}, ${a.N}>`:a.itemType.kind==="value"?"array":`array<${t}>`}return a.kind}const ys=[Dn,wt,cn,$t,fn,Ar,Tn,li(Sn),ai];function za(a,t){if(t.kind==="error")return null;if(a.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!za(a.itemType,t.itemType))&&(typeof a.N!="number"||a.N===t.N))return null}else{if(a.kind===t.kind)return null;if(a.kind==="value"){for(const o of ys)if(!za(o,t))return null}}return`Expected ${oi(a)} but found ${oi(t)} instead.`}function iu(a,t){return t.some(o=>o.kind===a.kind)}function vs(a,t){return t.some(o=>o==="null"?a===null:o==="array"?Array.isArray(a):o==="object"?a&&!Array.isArray(a)&&typeof a=="object":o===typeof a)}function ru(a){var t={exports:{}};return a(t,t.exports),t.exports}var xd=ru(function(a,t){var o={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function c(v){return(v=Math.round(v))<0?0:v>255?255:v}function d(v){return c(v[v.length-1]==="%"?parseFloat(v)/100*255:parseInt(v))}function m(v){return(w=v[v.length-1]==="%"?parseFloat(v)/100:parseFloat(v))<0?0:w>1?1:w;var w}function y(v,w,A){return A<0?A+=1:A>1&&(A-=1),6*A<1?v+(w-v)*A*6:2*A<1?w:3*A<2?v+(w-v)*(2/3-A)*6:v}try{t.parseCSSColor=function(v){var w,A=v.replace(/ /g,"").toLowerCase();if(A in o)return o[A].slice();if(A[0]==="#")return A.length===4?(w=parseInt(A.substr(1),16))>=0&&w<=4095?[(3840&w)>>4|(3840&w)>>8,240&w|(240&w)>>4,15&w|(15&w)<<4,1]:null:A.length===7&&(w=parseInt(A.substr(1),16))>=0&&w<=16777215?[(16711680&w)>>16,(65280&w)>>8,255&w,1]:null;var D=A.indexOf("("),R=A.indexOf(")");if(D!==-1&&R+1===A.length){var k=A.substr(0,D),V=A.substr(D+1,R-(D+1)).split(","),j=1;switch(k){case"rgba":if(V.length!==4)return null;j=m(V.pop());case"rgb":return V.length!==3?null:[d(V[0]),d(V[1]),d(V[2]),j];case"hsla":if(V.length!==4)return null;j=m(V.pop());case"hsl":if(V.length!==3)return null;var $=(parseFloat(V[0])%360+360)%360/360,ne=m(V[1]),me=m(V[2]),ke=me<=.5?me*(ne+1):me+ne-me*ne,He=2*me-ke;return[c(255*y(He,ke,$+1/3)),c(255*y(He,ke,$)),c(255*y(He,ke,$-1/3)),j];default:return null}}return null}}catch(v){}});class Xn{constructor(t,o,c,d=1){this.r=t,this.g=o,this.b=c,this.a=d}static parse(t){if(!t)return;if(t instanceof Xn)return t;if(typeof t!="string")return;const o=xd.parseCSSColor(t);return o?new Xn(o[0]/255*o[3],o[1]/255*o[3],o[2]/255*o[3],o[3]):void 0}toString(){const[t,o,c,d]=this.toArray();return`rgba(${Math.round(t)},${Math.round(o)},${Math.round(c)},${d})`}toArray(){const{r:t,g:o,b:c,a:d}=this;return d===0?[0,0,0,0]:[255*t/d,255*o/d,255*c/d,d]}}Xn.black=new Xn(0,0,0,1),Xn.white=new Xn(1,1,1,1),Xn.transparent=new Xn(0,0,0,0),Xn.red=new Xn(1,0,0,1),Xn.blue=new Xn(0,0,1,1);class xs{constructor(t,o,c){this.sensitivity=t?o?"variant":"case":o?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,o){return this.collator.compare(t,o)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class bd{constructor(t,o,c,d,m){this.text=t.normalize?t.normalize():t,this.image=o,this.scale=c,this.fontStack=d,this.textColor=m}}class Bi{constructor(t){this.sections=t}static fromString(t){return new Bi([new bd(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof Bi?t:Bi.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}serialize(){const t=["format"];for(const o of this.sections){if(o.image){t.push(["image",o.image.name]);continue}t.push(o.text);const c={};o.fontStack&&(c["text-font"]=["literal",o.fontStack.split(",")]),o.scale&&(c["font-scale"]=o.scale),o.textColor&&(c["text-color"]=["rgba"].concat(o.textColor.toArray())),t.push(c)}return t}}class Cr{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Cr({name:t,available:!1}):null}serialize(){return["image",this.name]}}function da(a,t,o,c){return typeof a=="number"&&a>=0&&a<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof o=="number"&&o>=0&&o<=255?c===void 0||typeof c=="number"&&c>=0&&c<=1?null:`Invalid rgba value [${[a,t,o,c].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof c=="number"?[a,t,o,c]:[a,t,o]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function au(a){if(a===null||typeof a=="string"||typeof a=="boolean"||typeof a=="number"||a instanceof Xn||a instanceof xs||a instanceof Bi||a instanceof Cr)return!0;if(Array.isArray(a)){for(const t of a)if(!au(t))return!1;return!0}if(typeof a=="object"){for(const t in a)if(!au(a[t]))return!1;return!0}return!1}function Pi(a){if(a===null)return Dn;if(typeof a=="string")return cn;if(typeof a=="boolean")return $t;if(typeof a=="number")return wt;if(a instanceof Xn)return fn;if(a instanceof xs)return di;if(a instanceof Bi)return Ar;if(a instanceof Cr)return ai;if(Array.isArray(a)){const t=a.length;let o;for(const c of a){const d=Pi(c);if(o){if(o===d)continue;o=Sn;break}o=d}return li(o||Sn,t)}return Tn}function ka(a){const t=typeof a;return a===null?"":t==="string"||t==="number"||t==="boolean"?String(a):a instanceof Xn||a instanceof Bi||a instanceof Cr?a.toString():JSON.stringify(a)}class Ba{constructor(t,o){this.type=t,this.value=o}static parse(t,o){if(t.length!==2)return o.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!au(t[1]))return o.error("invalid value");const c=t[1];let d=Pi(c);const m=o.expectedType;return d.kind!=="array"||d.N!==0||!m||m.kind!=="array"||typeof m.N=="number"&&m.N!==0||(d=m),new Ba(d,c)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Xn?["rgba"].concat(this.value.toArray()):this.value instanceof Bi?this.value.serialize():this.value}}class Qi{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const wd={string:cn,number:wt,boolean:$t,object:Tn};class pa{constructor(t,o){this.type=t,this.args=o}static parse(t,o){if(t.length<2)return o.error("Expected at least one argument.");let c,d=1;const m=t[0];if(m==="array"){let v,w;if(t.length>2){const A=t[1];if(typeof A!="string"||!(A in wd)||A==="object")return o.error('The item type argument of "array" must be one of string, number, boolean',1);v=wd[A],d++}else v=Sn;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return o.error('The length argument to "array" must be a positive integer literal',2);w=t[2],d++}c=li(v,w)}else c=wd[m];const y=[];for(;d<t.length;d++){const v=o.parse(t[d],d,Sn);if(!v)return null;y.push(v)}return new pa(c,y)}evaluate(t){for(let o=0;o<this.args.length;o++){const c=this.args[o].evaluate(t);if(!za(this.type,Pi(c)))return c;if(o===this.args.length-1)throw new Qi(`Expected value to be of type ${oi(this.type)}, but found ${oi(Pi(c))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=this.type,o=[t.kind];if(t.kind==="array"){const c=t.itemType;if(c.kind==="string"||c.kind==="number"||c.kind==="boolean"){o.push(c.kind);const d=t.N;(typeof d=="number"||this.args.length>1)&&o.push(d)}}return o.concat(this.args.map(c=>c.serialize()))}}class bs{constructor(t){this.type=Ar,this.sections=t}static parse(t,o){if(t.length<2)return o.error("Expected at least one argument.");const c=t[1];if(!Array.isArray(c)&&typeof c=="object")return o.error("First argument must be an image or text section.");const d=[];let m=!1;for(let y=1;y<=t.length-1;++y){const v=t[y];if(m&&typeof v=="object"&&!Array.isArray(v)){m=!1;let w=null;if(v["font-scale"]&&(w=o.parse(v["font-scale"],1,wt),!w))return null;let A=null;if(v["text-font"]&&(A=o.parse(v["text-font"],1,li(cn)),!A))return null;let D=null;if(v["text-color"]&&(D=o.parse(v["text-color"],1,fn),!D))return null;const R=d[d.length-1];R.scale=w,R.font=A,R.textColor=D}else{const w=o.parse(t[y],1,Sn);if(!w)return null;const A=w.type.kind;if(A!=="string"&&A!=="value"&&A!=="null"&&A!=="resolvedImage")return o.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");m=!0,d.push({content:w,scale:null,font:null,textColor:null})}}return new bs(d)}evaluate(t){return new Bi(this.sections.map(o=>{const c=o.content.evaluate(t);return Pi(c)===ai?new bd("",c,null,null,null):new bd(ka(c),null,o.scale?o.scale.evaluate(t):null,o.font?o.font.evaluate(t).join(","):null,o.textColor?o.textColor.evaluate(t):null)}))}eachChild(t){for(const o of this.sections)t(o.content),o.scale&&t(o.scale),o.font&&t(o.font),o.textColor&&t(o.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const o of this.sections){t.push(o.content.serialize());const c={};o.scale&&(c["font-scale"]=o.scale.serialize()),o.font&&(c["text-font"]=o.font.serialize()),o.textColor&&(c["text-color"]=o.textColor.serialize()),t.push(c)}return t}}class ws{constructor(t){this.type=ai,this.input=t}static parse(t,o){if(t.length!==2)return o.error("Expected two arguments.");const c=o.parse(t[1],1,cn);return c?new ws(c):o.error("No image name provided.")}evaluate(t){const o=this.input.evaluate(t),c=Cr.fromString(o);return c&&t.availableImages&&(c.available=t.availableImages.indexOf(o)>-1),c}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Dy={"to-boolean":$t,"to-color":fn,"to-number":wt,"to-string":cn};class fa{constructor(t,o){this.type=t,this.args=o}static parse(t,o){if(t.length<2)return o.error("Expected at least one argument.");const c=t[0];if((c==="to-boolean"||c==="to-string")&&t.length!==2)return o.error("Expected one argument.");const d=Dy[c],m=[];for(let y=1;y<t.length;y++){const v=o.parse(t[y],y,Sn);if(!v)return null;m.push(v)}return new fa(d,m)}evaluate(t){if(this.type.kind==="boolean")return!!this.args[0].evaluate(t);if(this.type.kind==="color"){let o,c;for(const d of this.args){if(o=d.evaluate(t),c=null,o instanceof Xn)return o;if(typeof o=="string"){const m=t.parseColor(o);if(m)return m}else if(Array.isArray(o)&&(c=o.length<3||o.length>4?`Invalid rbga value ${JSON.stringify(o)}: expected an array containing either three or four numeric values.`:da(o[0],o[1],o[2],o[3]),!c))return new Xn(o[0]/255,o[1]/255,o[2]/255,o[3])}throw new Qi(c||`Could not parse color from value '${typeof o=="string"?o:String(JSON.stringify(o))}'`)}if(this.type.kind==="number"){let o=null;for(const c of this.args){if(o=c.evaluate(t),o===null)return 0;const d=Number(o);if(!isNaN(d))return d}throw new Qi(`Could not convert ${JSON.stringify(o)} to number.`)}return this.type.kind==="formatted"?Bi.fromString(ka(this.args[0].evaluate(t))):this.type.kind==="resolvedImage"?Cr.fromString(ka(this.args[0].evaluate(t))):ka(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){if(this.type.kind==="formatted")return new bs([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new ws(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild(o=>{t.push(o.serialize())}),t}}const Iy=["Unknown","Point","LineString","Polygon"];class gm{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Iy[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,o=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*o-t[0])+this.featureDistanceData.bearing[1]*(d*o-t[1])}return 0}parseColor(t){let o=this._parseColorCache[t];return o||(o=this._parseColorCache[t]=Xn.parse(t)),o}}class Pr{constructor(t,o,c,d){this.name=t,this.type=o,this._evaluate=c,this.args=d}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(t=>t.serialize()))}static parse(t,o){const c=t[0],d=Pr.definitions[c];if(!d)return o.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0);const m=Array.isArray(d)?d[0]:d.type,y=Array.isArray(d)?[[d[1],d[2]]]:d.overloads,v=y.filter(([A])=>!Array.isArray(A)||A.length===t.length-1);let w=null;for(const[A,D]of v){w=new ro(o.registry,o.path,null,o.scope);const R=[];let k=!1;for(let V=1;V<t.length;V++){const j=t[V],$=Array.isArray(A)?A[V-1]:A.type,ne=w.parse(j,1+R.length,$);if(!ne){k=!0;break}R.push(ne)}if(!k)if(Array.isArray(A)&&A.length!==R.length)w.error(`Expected ${A.length} arguments, but found ${R.length} instead.`);else{for(let V=0;V<R.length;V++){const j=Array.isArray(A)?A[V]:A.type,$=R[V];w.concat(V+1).checkSubtype(j,$.type)}if(w.errors.length===0)return new Pr(c,m,D,R)}}if(v.length===1)o.errors.push(...w.errors);else{const A=(v.length?v:y).map(([R])=>{return k=R,Array.isArray(k)?`(${k.map(oi).join(", ")})`:`(${oi(k.type)}...)`;var k}).join(" | "),D=[];for(let R=1;R<t.length;R++){const k=o.parse(t[R],1+D.length);if(!k)return null;D.push(oi(k.type))}o.error(`Expected arguments of type ${A}, but found (${D.join(", ")}) instead.`)}return null}static register(t,o){Pr.definitions=o;for(const c in o)t[c]=Pr}}class ou{constructor(t,o,c){this.type=di,this.locale=c,this.caseSensitive=t,this.diacriticSensitive=o}static parse(t,o){if(t.length!==2)return o.error("Expected one argument.");const c=t[1];if(typeof c!="object"||Array.isArray(c))return o.error("Collator options argument must be an object.");const d=o.parse(c["case-sensitive"]!==void 0&&c["case-sensitive"],1,$t);if(!d)return null;const m=o.parse(c["diacritic-sensitive"]!==void 0&&c["diacritic-sensitive"],1,$t);if(!m)return null;let y=null;return c.locale&&(y=o.parse(c.locale,1,cn),!y)?null:new ou(d,m,y)}evaluate(t){return new xs(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const io=8192;function Md(a,t){a[0]=Math.min(a[0],t[0]),a[1]=Math.min(a[1],t[1]),a[2]=Math.max(a[2],t[0]),a[3]=Math.max(a[3],t[1])}function su(a,t){return!(a[0]<=t[0]||a[2]>=t[2]||a[1]<=t[1]||a[3]>=t[3])}function _m(a,t){const o=(180+a[0])/360,c=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,d=Math.pow(2,t.z);return[Math.round(o*d*io),Math.round(c*d*io)]}function lu(a,t,o){const c=a[0]-t[0],d=a[1]-t[1],m=a[0]-o[0],y=a[1]-o[1];return c*y-m*d==0&&c*m<=0&&d*y<=0}function Td(a,t){let o=!1;for(let y=0,v=t.length;y<v;y++){const w=t[y];for(let A=0,D=w.length;A<D-1;A++){if(lu(a,w[A],w[A+1]))return!1;(d=w[A])[1]>(c=a)[1]!=(m=w[A+1])[1]>c[1]&&c[0]<(m[0]-d[0])*(c[1]-d[1])/(m[1]-d[1])+d[0]&&(o=!o)}}var c,d,m;return o}function Ry(a,t){for(let o=0;o<t.length;o++)if(Td(a,t[o]))return!0;return!1}function ym(a,t,o,c){const d=c[0]-o[0],m=c[1]-o[1],y=(a[0]-o[0])*m-d*(a[1]-o[1]),v=(t[0]-o[0])*m-d*(t[1]-o[1]);return y>0&&v<0||y<0&&v>0}function zy(a,t,o){for(const A of o)for(let D=0;D<A.length-1;++D)if((v=[(y=A[D+1])[0]-(m=A[D])[0],y[1]-m[1]])[0]*(w=[(d=t)[0]-(c=a)[0],d[1]-c[1]])[1]-v[1]*w[0]!=0&&ym(c,d,m,y)&&ym(m,y,c,d))return!0;var c,d,m,y,v,w;return!1}function vm(a,t){for(let o=0;o<a.length;++o)if(!Td(a[o],t))return!1;for(let o=0;o<a.length-1;++o)if(zy(a[o],a[o+1],t))return!1;return!0}function ky(a,t){for(let o=0;o<t.length;o++)if(vm(a,t[o]))return!0;return!1}function cu(a,t,o){const c=[];for(let d=0;d<a.length;d++){const m=[];for(let y=0;y<a[d].length;y++){const v=_m(a[d][y],o);Md(t,v),m.push(v)}c.push(m)}return c}function _l(a,t,o){const c=[];for(let d=0;d<a.length;d++){const m=cu(a[d],t,o);c.push(m)}return c}function xm(a,t,o,c){if(a[0]<o[0]||a[0]>o[2]){const d=.5*c;let m=a[0]-o[0]>d?-c:o[0]-a[0]>d?c:0;m===0&&(m=a[0]-o[2]>d?-c:o[2]-a[0]>d?c:0),a[0]+=m}Md(t,a)}function bm(a,t,o,c){const d=Math.pow(2,c.z)*io,m=[c.x*io,c.y*io],y=[];if(!a)return y;for(const v of a)for(const w of v){const A=[w.x+m[0],w.y+m[1]];xm(A,t,o,d),y.push(A)}return y}function wm(a,t,o,c){const d=Math.pow(2,c.z)*io,m=[c.x*io,c.y*io],y=[];if(!a)return y;for(const w of a){const A=[];for(const D of w){const R=[D.x+m[0],D.y+m[1]];Md(t,R),A.push(R)}y.push(A)}if(t[2]-t[0]<=d/2){(v=t)[0]=v[1]=1/0,v[2]=v[3]=-1/0;for(const w of y)for(const A of w)xm(A,t,o,d)}var v;return y}class No{constructor(t,o){this.type=$t,this.geojson=t,this.geometries=o}static parse(t,o){if(t.length!==2)return o.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(au(t[1])){const c=t[1];if(c.type==="FeatureCollection")for(let d=0;d<c.features.length;++d){const m=c.features[d].geometry.type;if(m==="Polygon"||m==="MultiPolygon")return new No(c,c.features[d].geometry)}else if(c.type==="Feature"){const d=c.geometry.type;if(d==="Polygon"||d==="MultiPolygon")return new No(c,c.geometry)}else if(c.type==="Polygon"||c.type==="MultiPolygon")return new No(c,c)}return o.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(o,c){const d=[1/0,1/0,-1/0,-1/0],m=[1/0,1/0,-1/0,-1/0],y=o.canonicalID();if(!y)return!1;if(c.type==="Polygon"){const v=cu(c.coordinates,m,y),w=bm(o.geometry(),d,m,y);if(!su(d,m))return!1;for(const A of w)if(!Td(A,v))return!1}if(c.type==="MultiPolygon"){const v=_l(c.coordinates,m,y),w=bm(o.geometry(),d,m,y);if(!su(d,m))return!1;for(const A of w)if(!Ry(A,v))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(o,c){const d=[1/0,1/0,-1/0,-1/0],m=[1/0,1/0,-1/0,-1/0],y=o.canonicalID();if(!y)return!1;if(c.type==="Polygon"){const v=cu(c.coordinates,m,y),w=wm(o.geometry(),d,m,y);if(!su(d,m))return!1;for(const A of w)if(!vm(A,v))return!1}if(c.type==="MultiPolygon"){const v=_l(c.coordinates,m,y),w=wm(o.geometry(),d,m,y);if(!su(d,m))return!1;for(const A of w)if(!ky(A,v))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function gr(a){if(a instanceof Pr&&(a.name==="get"&&a.args.length===1||a.name==="feature-state"||a.name==="has"&&a.args.length===1||a.name==="properties"||a.name==="geometry-type"||a.name==="id"||/^filter-/.test(a.name))||a instanceof No)return!1;let t=!0;return a.eachChild(o=>{t&&!gr(o)&&(t=!1)}),t}function yl(a){if(a instanceof Pr&&a.name==="feature-state")return!1;let t=!0;return a.eachChild(o=>{t&&!yl(o)&&(t=!1)}),t}function vl(a,t){if(a instanceof Pr&&t.indexOf(a.name)>=0)return!1;let o=!0;return a.eachChild(c=>{o&&!vl(c,t)&&(o=!1)}),o}class Uo{constructor(t,o){this.type=o.type,this.name=t,this.boundExpression=o}static parse(t,o){if(t.length!==2||typeof t[1]!="string")return o.error("'var' expression requires exactly one string literal argument.");const c=t[1];return o.scope.has(c)?new Uo(c,o.scope.get(c)):o.error(`Unknown variable "${c}". Make sure "${c}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class ro{constructor(t,o=[],c,d=new Ln,m=[]){this.registry=t,this.path=o,this.key=o.map(y=>`[${y}]`).join(""),this.scope=d,this.errors=m,this.expectedType=c}parse(t,o,c,d,m={}){return o?this.concat(o,c,d)._parse(t,m):this._parse(t,m)}_parse(t,o){function c(d,m,y){return y==="assert"?new pa(m,[d]):y==="coerce"?new fa(m,[d]):d}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=t[0];if(typeof d!="string")return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const m=this.registry[d];if(m){let y=m.parse(t,this);if(!y)return null;if(this.expectedType){const v=this.expectedType,w=y.type;if(v.kind!=="string"&&v.kind!=="number"&&v.kind!=="boolean"&&v.kind!=="object"&&v.kind!=="array"||w.kind!=="value")if(v.kind!=="color"&&v.kind!=="formatted"&&v.kind!=="resolvedImage"||w.kind!=="value"&&w.kind!=="string"){if(this.checkSubtype(v,w))return null}else y=c(y,v,o.typeAnnotation||"coerce");else y=c(y,v,o.typeAnnotation||"assert")}if(!(y instanceof Ba)&&y.type.kind!=="resolvedImage"&&uu(y)){const v=new gm;try{y=new Ba(y.type,y.evaluate(v))}catch(w){return this.error(w.message),null}}return y}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,o,c){const d=typeof t=="number"?this.path.concat(t):this.path,m=c?this.scope.concat(c):this.scope;return new ro(this.registry,d,o||null,m,this.errors)}error(t,...o){const c=`${this.key}${o.map(d=>`[${d}]`).join("")}`;this.errors.push(new nn(c,t))}checkSubtype(t,o){const c=za(t,o);return c&&this.error(c),c}}function uu(a){if(a instanceof Uo)return uu(a.boundExpression);if(a instanceof Pr&&a.name==="error"||a instanceof ou||a instanceof No)return!1;const t=a instanceof fa||a instanceof pa;let o=!0;return a.eachChild(c=>{o=t?o&&uu(c):o&&c instanceof Ba}),!!o&&gr(a)&&vl(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function xl(a,t){const o=a.length-1;let c,d,m=0,y=o,v=0;for(;m<=y;)if(v=Math.floor((m+y)/2),c=a[v],d=a[v+1],c<=t){if(v===o||t<d)return v;m=v+1}else{if(!(c>t))throw new Qi("Input is not a number.");y=v-1}return 0}class bl{constructor(t,o,c){this.type=t,this.input=o,this.labels=[],this.outputs=[];for(const[d,m]of c)this.labels.push(d),this.outputs.push(m)}static parse(t,o){if(t.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return o.error("Expected an even number of arguments.");const c=o.parse(t[1],1,wt);if(!c)return null;const d=[];let m=null;o.expectedType&&o.expectedType.kind!=="value"&&(m=o.expectedType);for(let y=1;y<t.length;y+=2){const v=y===1?-1/0:t[y],w=t[y+1],A=y,D=y+1;if(typeof v!="number")return o.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',A);if(d.length&&d[d.length-1][0]>=v)return o.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',A);const R=o.parse(w,D,m);if(!R)return null;m=m||R.type,d.push([v,R])}return new bl(m,c,d)}evaluate(t){const o=this.labels,c=this.outputs;if(o.length===1)return c[0].evaluate(t);const d=this.input.evaluate(t);if(d<=o[0])return c[0].evaluate(t);const m=o.length;return d>=o[m-1]?c[m-1].evaluate(t):c[xl(o,d)].evaluate(t)}eachChild(t){t(this.input);for(const o of this.outputs)t(o)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){const t=["step",this.input.serialize()];for(let o=0;o<this.labels.length;o++)o>0&&t.push(this.labels[o]),t.push(this.outputs[o].serialize());return t}}function gn(a,t,o){return a*(1-o)+t*o}var hu=Object.freeze({__proto__:null,number:gn,color:function(a,t,o){return new Xn(gn(a.r,t.r,o),gn(a.g,t.g,o),gn(a.b,t.b,o),gn(a.a,t.a,o))},array:function(a,t,o){return a.map((c,d)=>gn(c,t[d],o))}});const Mm=.95047,Tm=1.08883,Ed=4/29,Sd=6/29,Ad=3*Sd*Sd,Em=Math.PI/180,Sm=180/Math.PI;function du(a){return a>.008856451679035631?Math.pow(a,.3333333333333333):a/Ad+Ed}function ao(a){return a>Sd?a*a*a:Ad*(a-Ed)}function Ms(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,.4166666666666667)-.055)}function Cd(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function pu(a){const t=Cd(a.r),o=Cd(a.g),c=Cd(a.b),d=du((.4124564*t+.3575761*o+.1804375*c)/Mm),m=du((.2126729*t+.7151522*o+.072175*c)/1);return{l:116*m-16,a:500*(d-m),b:200*(m-du((.0193339*t+.119192*o+.9503041*c)/Tm)),alpha:a.a}}function Pd(a){let t=(a.l+16)/116,o=isNaN(a.a)?t:t+a.a/500,c=isNaN(a.b)?t:t-a.b/200;return t=1*ao(t),o=Mm*ao(o),c=Tm*ao(c),new Xn(Ms(3.2404542*o-1.5371385*t-.4985314*c),Ms(-.969266*o+1.8760108*t+.041556*c),Ms(.0556434*o-.2040259*t+1.0572252*c),a.alpha)}function By(a,t,o){const c=t-a;return a+o*(c>180||c<-180?c-360*Math.round(c/360):c)}const wl={forward:pu,reverse:Pd,interpolate:function(a,t,o){return{l:gn(a.l,t.l,o),a:gn(a.a,t.a,o),b:gn(a.b,t.b,o),alpha:gn(a.alpha,t.alpha,o)}}},Ml={forward:function(a){const{l:t,a:o,b:c}=pu(a),d=Math.atan2(c,o)*Sm;return{h:d<0?d+360:d,c:Math.sqrt(o*o+c*c),l:t,alpha:a.a}},reverse:function(a){const t=a.h*Em,o=a.c;return Pd({l:a.l,a:Math.cos(t)*o,b:Math.sin(t)*o,alpha:a.alpha})},interpolate:function(a,t,o){return{h:By(a.h,t.h,o),c:gn(a.c,t.c,o),l:gn(a.l,t.l,o),alpha:gn(a.alpha,t.alpha,o)}}};var Ld=Object.freeze({__proto__:null,lab:wl,hcl:Ml});class Lr{constructor(t,o,c,d,m){this.type=t,this.operator=o,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[];for(const[y,v]of m)this.labels.push(y),this.outputs.push(v)}static interpolationFactor(t,o,c,d){let m=0;if(t.name==="exponential")m=fu(o,t.base,c,d);else if(t.name==="linear")m=fu(o,1,c,d);else if(t.name==="cubic-bezier"){const y=t.controlPoints;m=new T(y[0],y[1],y[2],y[3]).solve(fu(o,1,c,d))}return m}static parse(t,o){let[c,d,m,...y]=t;if(!Array.isArray(d)||d.length===0)return o.error("Expected an interpolation type expression.",1);if(d[0]==="linear")d={name:"linear"};else if(d[0]==="exponential"){const A=d[1];if(typeof A!="number")return o.error("Exponential interpolation requires a numeric base.",1,1);d={name:"exponential",base:A}}else{if(d[0]!=="cubic-bezier")return o.error(`Unknown interpolation type ${String(d[0])}`,1,0);{const A=d.slice(1);if(A.length!==4||A.some(D=>typeof D!="number"||D<0||D>1))return o.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);d={name:"cubic-bezier",controlPoints:A}}}if(t.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return o.error("Expected an even number of arguments.");if(m=o.parse(m,2,wt),!m)return null;const v=[];let w=null;c==="interpolate-hcl"||c==="interpolate-lab"?w=fn:o.expectedType&&o.expectedType.kind!=="value"&&(w=o.expectedType);for(let A=0;A<y.length;A+=2){const D=y[A],R=y[A+1],k=A+3,V=A+4;if(typeof D!="number")return o.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',k);if(v.length&&v[v.length-1][0]>=D)return o.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',k);const j=o.parse(R,V,w);if(!j)return null;w=w||j.type,v.push([D,j])}return w.kind==="number"||w.kind==="color"||w.kind==="array"&&w.itemType.kind==="number"&&typeof w.N=="number"?new Lr(w,c,d,m,v):o.error(`Type ${oi(w)} is not interpolatable.`)}evaluate(t){const o=this.labels,c=this.outputs;if(o.length===1)return c[0].evaluate(t);const d=this.input.evaluate(t);if(d<=o[0])return c[0].evaluate(t);const m=o.length;if(d>=o[m-1])return c[m-1].evaluate(t);const y=xl(o,d),v=Lr.interpolationFactor(this.interpolation,d,o[y],o[y+1]),w=c[y].evaluate(t),A=c[y+1].evaluate(t);return this.operator==="interpolate"?hu[this.type.kind.toLowerCase()](w,A,v):this.operator==="interpolate-hcl"?Ml.reverse(Ml.interpolate(Ml.forward(w),Ml.forward(A),v)):wl.reverse(wl.interpolate(wl.forward(w),wl.forward(A),v))}eachChild(t){t(this.input);for(const o of this.outputs)t(o)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){let t;t=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const o=[this.operator,t,this.input.serialize()];for(let c=0;c<this.labels.length;c++)o.push(this.labels[c],this.outputs[c].serialize());return o}}function fu(a,t,o,c){const d=c-o,m=a-o;return d===0?0:t===1?m/d:(Math.pow(t,m)-1)/(Math.pow(t,d)-1)}class Tl{constructor(t,o){this.type=t,this.args=o}static parse(t,o){if(t.length<2)return o.error("Expectected at least one argument.");let c=null;const d=o.expectedType;d&&d.kind!=="value"&&(c=d);const m=[];for(const v of t.slice(1)){const w=o.parse(v,1+m.length,c,void 0,{typeAnnotation:"omit"});if(!w)return null;c=c||w.type,m.push(w)}const y=d&&m.some(v=>za(d,v.type));return new Tl(y?Sn:c,m)}evaluate(t){let o,c=null,d=0;for(const m of this.args){if(d++,c=m.evaluate(t),c&&c instanceof Cr&&!c.available&&(o||(o=c),c=null,d===this.args.length))return o;if(c!==null)break}return c}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=["coalesce"];return this.eachChild(o=>{t.push(o.serialize())}),t}}class El{constructor(t,o){this.type=o.type,this.bindings=[].concat(t),this.result=o}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const o of this.bindings)t(o[1]);t(this.result)}static parse(t,o){if(t.length<4)return o.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const c=[];for(let m=1;m<t.length-1;m+=2){const y=t[m];if(typeof y!="string")return o.error(`Expected string, but found ${typeof y} instead.`,m);if(/[^a-zA-Z0-9_]/.test(y))return o.error("Variable names must contain only alphanumeric characters or '_'.",m);const v=o.parse(t[m+1],m+1);if(!v)return null;c.push([y,v])}const d=o.parse(t[t.length-1],t.length-1,o.expectedType,c);return d?new El(c,d):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[o,c]of this.bindings)t.push(o,c.serialize());return t.push(this.result.serialize()),t}}class Dd{constructor(t,o,c){this.type=t,this.index=o,this.input=c}static parse(t,o){if(t.length!==3)return o.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,wt),d=o.parse(t[2],2,li(o.expectedType||Sn));return c&&d?new Dd(d.type.itemType,c,d):null}evaluate(t){const o=this.index.evaluate(t),c=this.input.evaluate(t);if(o<0)throw new Qi(`Array index out of bounds: ${o} < 0.`);if(o>=c.length)throw new Qi(`Array index out of bounds: ${o} > ${c.length-1}.`);if(o!==Math.floor(o))throw new Qi(`Array index must be an integer, but found ${o} instead.`);return c[o]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class mu{constructor(t,o){this.type=$t,this.needle=t,this.haystack=o}static parse(t,o){if(t.length!==3)return o.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,Sn),d=o.parse(t[2],2,Sn);return c&&d?iu(c.type,[$t,cn,wt,Dn,Sn])?new mu(c,d):o.error(`Expected first argument to be of type boolean, string, number or null, but found ${oi(c.type)} instead`):null}evaluate(t){const o=this.needle.evaluate(t),c=this.haystack.evaluate(t);if(c==null)return!1;if(!vs(o,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${oi(Pi(o))} instead.`);if(!vs(c,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${oi(Pi(c))} instead.`);return c.indexOf(o)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class gu{constructor(t,o,c){this.type=wt,this.needle=t,this.haystack=o,this.fromIndex=c}static parse(t,o){if(t.length<=2||t.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,Sn),d=o.parse(t[2],2,Sn);if(!c||!d)return null;if(!iu(c.type,[$t,cn,wt,Dn,Sn]))return o.error(`Expected first argument to be of type boolean, string, number or null, but found ${oi(c.type)} instead`);if(t.length===4){const m=o.parse(t[3],3,wt);return m?new gu(c,d,m):null}return new gu(c,d)}evaluate(t){const o=this.needle.evaluate(t),c=this.haystack.evaluate(t);if(!vs(o,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${oi(Pi(o))} instead.`);if(!vs(c,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${oi(Pi(c))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(t);return c.indexOf(o,d)}return c.indexOf(o)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class _u{constructor(t,o,c,d,m,y){this.inputType=t,this.type=o,this.input=c,this.cases=d,this.outputs=m,this.otherwise=y}static parse(t,o){if(t.length<5)return o.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return o.error("Expected an even number of arguments.");let c,d;o.expectedType&&o.expectedType.kind!=="value"&&(d=o.expectedType);const m={},y=[];for(let A=2;A<t.length-1;A+=2){let D=t[A];const R=t[A+1];Array.isArray(D)||(D=[D]);const k=o.concat(A);if(D.length===0)return k.error("Expected at least one branch label.");for(const j of D){if(typeof j!="number"&&typeof j!="string")return k.error("Branch labels must be numbers or strings.");if(typeof j=="number"&&Math.abs(j)>Number.MAX_SAFE_INTEGER)return k.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof j=="number"&&Math.floor(j)!==j)return k.error("Numeric branch labels must be integer values.");if(c){if(k.checkSubtype(c,Pi(j)))return null}else c=Pi(j);if(m[String(j)]!==void 0)return k.error("Branch labels must be unique.");m[String(j)]=y.length}const V=o.parse(R,A,d);if(!V)return null;d=d||V.type,y.push(V)}const v=o.parse(t[1],1,Sn);if(!v)return null;const w=o.parse(t[t.length-1],t.length-1,d);return w?v.type.kind!=="value"&&o.concat(1).checkSubtype(c,v.type)?null:new _u(c,d,v,m,y,w):null}evaluate(t){const o=this.input.evaluate(t);return(Pi(o)===this.inputType&&this.outputs[this.cases[o]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],o=Object.keys(this.cases).sort(),c=[],d={};for(const y of o){const v=d[this.cases[y]];v===void 0?(d[this.cases[y]]=c.length,c.push([this.cases[y],[y]])):c[v][1].push(y)}const m=y=>this.inputType.kind==="number"?Number(y):y;for(const[y,v]of c)t.push(v.length===1?m(v[0]):v.map(m)),t.push(this.outputs[y].serialize());return t.push(this.otherwise.serialize()),t}}class yu{constructor(t,o,c){this.type=t,this.branches=o,this.otherwise=c}static parse(t,o){if(t.length<4)return o.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return o.error("Expected an odd number of arguments.");let c;o.expectedType&&o.expectedType.kind!=="value"&&(c=o.expectedType);const d=[];for(let y=1;y<t.length-1;y+=2){const v=o.parse(t[y],y,$t);if(!v)return null;const w=o.parse(t[y+1],y+1,c);if(!w)return null;d.push([v,w]),c=c||w.type}const m=o.parse(t[t.length-1],t.length-1,c);return m?new yu(c,d,m):null}evaluate(t){for(const[o,c]of this.branches)if(o.evaluate(t))return c.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[o,c]of this.branches)t(o),t(c);t(this.otherwise)}outputDefined(){return this.branches.every(([t,o])=>o.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild(o=>{t.push(o.serialize())}),t}}class vu{constructor(t,o,c,d){this.type=t,this.input=o,this.beginIndex=c,this.endIndex=d}static parse(t,o){if(t.length<=2||t.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const c=o.parse(t[1],1,Sn),d=o.parse(t[2],2,wt);if(!c||!d)return null;if(!iu(c.type,[li(Sn),cn,Sn]))return o.error(`Expected first argument to be of type array or string, but found ${oi(c.type)} instead`);if(t.length===4){const m=o.parse(t[3],3,wt);return m?new vu(c.type,c,d,m):null}return new vu(c.type,c,d)}evaluate(t){const o=this.input.evaluate(t),c=this.beginIndex.evaluate(t);if(!vs(o,["string","array"]))throw new Qi(`Expected first argument to be of type array or string, but found ${oi(Pi(o))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(t);return o.slice(c,d)}return o.slice(c)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Am(a,t){return a==="=="||a==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function Cm(a,t,o,c){return c.compare(t,o)===0}function Ts(a,t,o){const c=a!=="=="&&a!=="!=";return class eM{constructor(m,y,v){this.type=$t,this.lhs=m,this.rhs=y,this.collator=v,this.hasUntypedArgument=m.type.kind==="value"||y.type.kind==="value"}static parse(m,y){if(m.length!==3&&m.length!==4)return y.error("Expected two or three arguments.");const v=m[0];let w=y.parse(m[1],1,Sn);if(!w)return null;if(!Am(v,w.type))return y.concat(1).error(`"${v}" comparisons are not supported for type '${oi(w.type)}'.`);let A=y.parse(m[2],2,Sn);if(!A)return null;if(!Am(v,A.type))return y.concat(2).error(`"${v}" comparisons are not supported for type '${oi(A.type)}'.`);if(w.type.kind!==A.type.kind&&w.type.kind!=="value"&&A.type.kind!=="value")return y.error(`Cannot compare types '${oi(w.type)}' and '${oi(A.type)}'.`);c&&(w.type.kind==="value"&&A.type.kind!=="value"?w=new pa(A.type,[w]):w.type.kind!=="value"&&A.type.kind==="value"&&(A=new pa(w.type,[A])));let D=null;if(m.length===4){if(w.type.kind!=="string"&&A.type.kind!=="string"&&w.type.kind!=="value"&&A.type.kind!=="value")return y.error("Cannot use collator to compare non-string types.");if(D=y.parse(m[3],3,di),!D)return null}return new eM(w,A,D)}evaluate(m){const y=this.lhs.evaluate(m),v=this.rhs.evaluate(m);if(c&&this.hasUntypedArgument){const w=Pi(y),A=Pi(v);if(w.kind!==A.kind||w.kind!=="string"&&w.kind!=="number")throw new Qi(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${w.kind}, ${A.kind}) instead.`)}if(this.collator&&!c&&this.hasUntypedArgument){const w=Pi(y),A=Pi(v);if(w.kind!=="string"||A.kind!=="string")return t(m,y,v)}return this.collator?o(m,y,v,this.collator.evaluate(m)):t(m,y,v)}eachChild(m){m(this.lhs),m(this.rhs),this.collator&&m(this.collator)}outputDefined(){return!0}serialize(){const m=[a];return this.eachChild(y=>{m.push(y.serialize())}),m}}}const Fy=Ts("==",function(a,t,o){return t===o},Cm),Oy=Ts("!=",function(a,t,o){return t!==o},function(a,t,o,c){return!Cm(0,t,o,c)}),Pm=Ts("<",function(a,t,o){return t<o},function(a,t,o,c){return c.compare(t,o)<0}),Ny=Ts(">",function(a,t,o){return t>o},function(a,t,o,c){return c.compare(t,o)>0}),Uy=Ts("<=",function(a,t,o){return t<=o},function(a,t,o,c){return c.compare(t,o)<=0}),Vy=Ts(">=",function(a,t,o){return t>=o},function(a,t,o,c){return c.compare(t,o)>=0});class Id{constructor(t,o,c,d,m){this.type=cn,this.number=t,this.locale=o,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=m}static parse(t,o){if(t.length!==3)return o.error("Expected two arguments.");const c=o.parse(t[1],1,wt);if(!c)return null;const d=t[2];if(typeof d!="object"||Array.isArray(d))return o.error("NumberFormat options argument must be an object.");let m=null;if(d.locale&&(m=o.parse(d.locale,1,cn),!m))return null;let y=null;if(d.currency&&(y=o.parse(d.currency,1,cn),!y))return null;let v=null;if(d["min-fraction-digits"]&&(v=o.parse(d["min-fraction-digits"],1,wt),!v))return null;let w=null;return d["max-fraction-digits"]&&(w=o.parse(d["max-fraction-digits"],1,wt),!w)?null:new Id(c,m,y,v,w)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class xu{constructor(t){this.type=wt,this.input=t}static parse(t,o){if(t.length!==2)return o.error(`Expected 1 argument, but found ${t.length-1} instead.`);const c=o.parse(t[1],1);return c?c.type.kind!=="array"&&c.type.kind!=="string"&&c.type.kind!=="value"?o.error(`Expected argument of type string or array, but found ${oi(c.type)} instead.`):new xu(c):null}evaluate(t){const o=this.input.evaluate(t);if(typeof o=="string"||Array.isArray(o))return o.length;throw new Qi(`Expected value to be of type string or array, but found ${oi(Pi(o))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild(o=>{t.push(o.serialize())}),t}}const Vo={"==":Fy,"!=":Oy,">":Ny,"<":Pm,">=":Vy,"<=":Uy,array:pa,at:Dd,boolean:pa,case:yu,coalesce:Tl,collator:ou,format:bs,image:ws,in:mu,"index-of":gu,interpolate:Lr,"interpolate-hcl":Lr,"interpolate-lab":Lr,length:xu,let:El,literal:Ba,match:_u,number:pa,"number-format":Id,object:pa,slice:vu,step:bl,string:pa,"to-boolean":fa,"to-color":fa,"to-number":fa,"to-string":fa,var:Uo,within:No};function Rd(a,[t,o,c,d]){t=t.evaluate(a),o=o.evaluate(a),c=c.evaluate(a);const m=d?d.evaluate(a):1,y=da(t,o,c,m);if(y)throw new Qi(y);return new Xn(t/255*m,o/255*m,c/255*m,m)}function Lm(a,t){return a in t}function zd(a,t){const o=t[a];return o===void 0?null:o}function oo(a){return{type:a}}function kd(a){return{result:"success",value:a}}function Go(a){return{result:"error",value:a}}function Es(a){return a["property-type"]==="data-driven"||a["property-type"]==="cross-faded-data-driven"}function Dm(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")>-1}function Bd(a){return!!a.expression&&a.expression.interpolated}function Qn(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":a===null?"null":typeof a}function Ho(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function Im(a){return a}function Fd(a,t){const o=t.type==="color",c=a.stops&&typeof a.stops[0][0]=="object",d=c||!(c||a.property!==void 0),m=a.type||(Bd(t)?"exponential":"interval");if(o&&((a=Mt({},a)).stops&&(a.stops=a.stops.map(A=>[A[0],Xn.parse(A[1])])),a.default=Xn.parse(a.default?a.default:t.default)),a.colorSpace&&a.colorSpace!=="rgb"&&!Ld[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let y,v,w;if(m==="exponential")y=Od;else if(m==="interval")y=Hy;else if(m==="categorical"){y=Gy,v=Object.create(null);for(const A of a.stops)v[A[0]]=A[1];w=typeof a.stops[0][0]}else{if(m!=="identity")throw new Error(`Unknown function type "${m}"`);y=Rm}if(c){const A={},D=[];for(let V=0;V<a.stops.length;V++){const j=a.stops[V],$=j[0].zoom;A[$]===void 0&&(A[$]={zoom:$,type:a.type,property:a.property,default:a.default,stops:[]},D.push($)),A[$].stops.push([j[0].value,j[1]])}const R=[];for(const V of D)R.push([A[V].zoom,Fd(A[V],t)]);const k={name:"linear"};return{kind:"composite",interpolationType:k,interpolationFactor:Lr.interpolationFactor.bind(void 0,k),zoomStops:R.map(V=>V[0]),evaluate:({zoom:V},j)=>Od({stops:R,base:a.base},t,V).evaluate(V,j)}}if(d){const A=m==="exponential"?{name:"exponential",base:a.base!==void 0?a.base:1}:null;return{kind:"camera",interpolationType:A,interpolationFactor:Lr.interpolationFactor.bind(void 0,A),zoomStops:a.stops.map(D=>D[0]),evaluate:({zoom:D})=>y(a,t,D,v,w)}}return{kind:"source",evaluate(A,D){const R=D&&D.properties?D.properties[a.property]:void 0;return R===void 0?Sl(a.default,t.default):y(a,t,R,v,w)}}}function Sl(a,t,o){return a!==void 0?a:t!==void 0?t:o!==void 0?o:void 0}function Gy(a,t,o,c,d){return Sl(typeof o===d?c[o]:void 0,a.default,t.default)}function Hy(a,t,o){if(Qn(o)!=="number")return Sl(a.default,t.default);const c=a.stops.length;if(c===1||o<=a.stops[0][0])return a.stops[0][1];if(o>=a.stops[c-1][0])return a.stops[c-1][1];const d=xl(a.stops.map(m=>m[0]),o);return a.stops[d][1]}function Od(a,t,o){const c=a.base!==void 0?a.base:1;if(Qn(o)!=="number")return Sl(a.default,t.default);const d=a.stops.length;if(d===1||o<=a.stops[0][0])return a.stops[0][1];if(o>=a.stops[d-1][0])return a.stops[d-1][1];const m=xl(a.stops.map(D=>D[0]),o),y=function(D,R,k,V){const j=V-k,$=D-k;return j===0?0:R===1?$/j:(Math.pow(R,$)-1)/(Math.pow(R,j)-1)}(o,c,a.stops[m][0],a.stops[m+1][0]),v=a.stops[m][1],w=a.stops[m+1][1];let A=hu[t.type]||Im;if(a.colorSpace&&a.colorSpace!=="rgb"){const D=Ld[a.colorSpace];A=(R,k)=>D.reverse(D.interpolate(D.forward(R),D.forward(k),y))}return typeof v.evaluate=="function"?{evaluate(...D){const R=v.evaluate.apply(void 0,D),k=w.evaluate.apply(void 0,D);if(R!==void 0&&k!==void 0)return A(R,k,y)}}:A(v,w,y)}function Rm(a,t,o){return t.type==="color"?o=Xn.parse(o):t.type==="formatted"?o=Bi.fromString(o.toString()):t.type==="resolvedImage"?o=Cr.fromString(o.toString()):Qn(o)===t.type||t.type==="enum"&&t.values[o]||(o=void 0),Sl(o,a.default,t.default)}Pr.register(Vo,{error:[{kind:"error"},[cn],(a,[t])=>{throw new Qi(t.evaluate(a))}],typeof:[cn,[Sn],(a,[t])=>oi(Pi(t.evaluate(a)))],"to-rgba":[li(wt,4),[fn],(a,[t])=>t.evaluate(a).toArray()],rgb:[fn,[wt,wt,wt],Rd],rgba:[fn,[wt,wt,wt,wt],Rd],has:{type:$t,overloads:[[[cn],(a,[t])=>Lm(t.evaluate(a),a.properties())],[[cn,Tn],(a,[t,o])=>Lm(t.evaluate(a),o.evaluate(a))]]},get:{type:Sn,overloads:[[[cn],(a,[t])=>zd(t.evaluate(a),a.properties())],[[cn,Tn],(a,[t,o])=>zd(t.evaluate(a),o.evaluate(a))]]},"feature-state":[Sn,[cn],(a,[t])=>zd(t.evaluate(a),a.featureState||{})],properties:[Tn,[],a=>a.properties()],"geometry-type":[cn,[],a=>a.geometryType()],id:[Sn,[],a=>a.id()],zoom:[wt,[],a=>a.globals.zoom],pitch:[wt,[],a=>a.globals.pitch||0],"distance-from-center":[wt,[],a=>a.distanceFromCenter()],"heatmap-density":[wt,[],a=>a.globals.heatmapDensity||0],"line-progress":[wt,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[wt,[],a=>a.globals.skyRadialProgress||0],accumulated:[Sn,[],a=>a.globals.accumulated===void 0?null:a.globals.accumulated],"+":[wt,oo(wt),(a,t)=>{let o=0;for(const c of t)o+=c.evaluate(a);return o}],"*":[wt,oo(wt),(a,t)=>{let o=1;for(const c of t)o*=c.evaluate(a);return o}],"-":{type:wt,overloads:[[[wt,wt],(a,[t,o])=>t.evaluate(a)-o.evaluate(a)],[[wt],(a,[t])=>-t.evaluate(a)]]},"/":[wt,[wt,wt],(a,[t,o])=>t.evaluate(a)/o.evaluate(a)],"%":[wt,[wt,wt],(a,[t,o])=>t.evaluate(a)%o.evaluate(a)],ln2:[wt,[],()=>Math.LN2],pi:[wt,[],()=>Math.PI],e:[wt,[],()=>Math.E],"^":[wt,[wt,wt],(a,[t,o])=>Math.pow(t.evaluate(a),o.evaluate(a))],sqrt:[wt,[wt],(a,[t])=>Math.sqrt(t.evaluate(a))],log10:[wt,[wt],(a,[t])=>Math.log(t.evaluate(a))/Math.LN10],ln:[wt,[wt],(a,[t])=>Math.log(t.evaluate(a))],log2:[wt,[wt],(a,[t])=>Math.log(t.evaluate(a))/Math.LN2],sin:[wt,[wt],(a,[t])=>Math.sin(t.evaluate(a))],cos:[wt,[wt],(a,[t])=>Math.cos(t.evaluate(a))],tan:[wt,[wt],(a,[t])=>Math.tan(t.evaluate(a))],asin:[wt,[wt],(a,[t])=>Math.asin(t.evaluate(a))],acos:[wt,[wt],(a,[t])=>Math.acos(t.evaluate(a))],atan:[wt,[wt],(a,[t])=>Math.atan(t.evaluate(a))],min:[wt,oo(wt),(a,t)=>Math.min(...t.map(o=>o.evaluate(a)))],max:[wt,oo(wt),(a,t)=>Math.max(...t.map(o=>o.evaluate(a)))],abs:[wt,[wt],(a,[t])=>Math.abs(t.evaluate(a))],round:[wt,[wt],(a,[t])=>{const o=t.evaluate(a);return o<0?-Math.round(-o):Math.round(o)}],floor:[wt,[wt],(a,[t])=>Math.floor(t.evaluate(a))],ceil:[wt,[wt],(a,[t])=>Math.ceil(t.evaluate(a))],"filter-==":[$t,[cn,Sn],(a,[t,o])=>a.properties()[t.value]===o.value],"filter-id-==":[$t,[Sn],(a,[t])=>a.id()===t.value],"filter-type-==":[$t,[cn],(a,[t])=>a.geometryType()===t.value],"filter-<":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c<d}],"filter-id-<":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o<c}],"filter->":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c>d}],"filter-id->":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o>c}],"filter-<=":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c<=d}],"filter-id-<=":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o<=c}],"filter->=":[$t,[cn,Sn],(a,[t,o])=>{const c=a.properties()[t.value],d=o.value;return typeof c==typeof d&&c>=d}],"filter-id->=":[$t,[Sn],(a,[t])=>{const o=a.id(),c=t.value;return typeof o==typeof c&&o>=c}],"filter-has":[$t,[Sn],(a,[t])=>t.value in a.properties()],"filter-has-id":[$t,[],a=>a.id()!==null&&a.id()!==void 0],"filter-type-in":[$t,[li(cn)],(a,[t])=>t.value.indexOf(a.geometryType())>=0],"filter-id-in":[$t,[li(Sn)],(a,[t])=>t.value.indexOf(a.id())>=0],"filter-in-small":[$t,[cn,li(Sn)],(a,[t,o])=>o.value.indexOf(a.properties()[t.value])>=0],"filter-in-large":[$t,[cn,li(Sn)],(a,[t,o])=>function(c,d,m,y){for(;m<=y;){const v=m+y>>1;if(d[v]===c)return!0;d[v]>c?y=v-1:m=v+1}return!1}(a.properties()[t.value],o.value,0,o.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(a,[t,o])=>t.evaluate(a)&&o.evaluate(a)],[oo($t),(a,t)=>{for(const o of t)if(!o.evaluate(a))return!1;return!0}]]},any:{type:$t,overloads:[[[$t,$t],(a,[t,o])=>t.evaluate(a)||o.evaluate(a)],[oo($t),(a,t)=>{for(const o of t)if(o.evaluate(a))return!0;return!1}]]},"!":[$t,[$t],(a,[t])=>!t.evaluate(a)],"is-supported-script":[$t,[cn],(a,[t])=>{const o=a.globals&&a.globals.isSupportedScript;return!o||o(t.evaluate(a))}],upcase:[cn,[cn],(a,[t])=>t.evaluate(a).toUpperCase()],downcase:[cn,[cn],(a,[t])=>t.evaluate(a).toLowerCase()],concat:[cn,oo(Sn),(a,t)=>t.map(o=>ka(o.evaluate(a))).join("")],"resolved-locale":[cn,[di],(a,[t])=>t.evaluate(a).resolvedLocale()]});class bu{constructor(t,o){this.expression=t,this._warningHistory={},this._evaluator=new gm,this._defaultValue=o?function(c){return c.type==="color"&&Ho(c.default)?new Xn(0,0,0,0):c.type==="color"?Xn.parse(c.default)||null:c.default===void 0?null:c.default}(o):null,this._enumValues=o&&o.type==="enum"?o.values:null}evaluateWithoutErrorHandling(t,o,c,d,m,y,v,w){return this._evaluator.globals=t,this._evaluator.feature=o,this._evaluator.featureState=c,this._evaluator.canonical=d||null,this._evaluator.availableImages=m||null,this._evaluator.formattedSection=y,this._evaluator.featureTileCoord=v||null,this._evaluator.featureDistanceData=w||null,this.expression.evaluate(this._evaluator)}evaluate(t,o,c,d,m,y,v,w){this._evaluator.globals=t,this._evaluator.feature=o||null,this._evaluator.featureState=c||null,this._evaluator.canonical=d||null,this._evaluator.availableImages=m||null,this._evaluator.formattedSection=y||null,this._evaluator.featureTileCoord=v||null,this._evaluator.featureDistanceData=w||null;try{const A=this.expression.evaluate(this._evaluator);if(A==null||typeof A=="number"&&A!=A)return this._defaultValue;if(this._enumValues&&!(A in this._enumValues))throw new Qi(`Expected value to be one of ${Object.keys(this._enumValues).map(D=>JSON.stringify(D)).join(", ")}, but found ${JSON.stringify(A)} instead.`);return A}catch(A){return this._warningHistory[A.message]||(this._warningHistory[A.message]=!0,typeof console!="undefined"&&console.warn(A.message)),this._defaultValue}}}function Ss(a){return Array.isArray(a)&&a.length>0&&typeof a[0]=="string"&&a[0]in Vo}function Al(a,t){const o=new ro(Vo,[],t?function(d){const m={color:fn,string:cn,number:wt,enum:cn,boolean:$t,formatted:Ar,resolvedImage:ai};return d.type==="array"?li(m[d.value]||Sn,d.length):m[d.type]}(t):void 0),c=o.parse(a,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return c?kd(new bu(c,t)):Go(o.errors)}class Nd{constructor(t,o){this.kind=t,this._styleExpression=o,this.isStateDependent=t!=="constant"&&!yl(o.expression)}evaluateWithoutErrorHandling(t,o,c,d,m,y){return this._styleExpression.evaluateWithoutErrorHandling(t,o,c,d,m,y)}evaluate(t,o,c,d,m,y){return this._styleExpression.evaluate(t,o,c,d,m,y)}}class Ud{constructor(t,o,c,d){this.kind=t,this.zoomStops=c,this._styleExpression=o,this.isStateDependent=t!=="camera"&&!yl(o.expression),this.interpolationType=d}evaluateWithoutErrorHandling(t,o,c,d,m,y){return this._styleExpression.evaluateWithoutErrorHandling(t,o,c,d,m,y)}evaluate(t,o,c,d,m,y){return this._styleExpression.evaluate(t,o,c,d,m,y)}interpolationFactor(t,o,c){return this.interpolationType?Lr.interpolationFactor(this.interpolationType,t,o,c):0}}function zm(a,t){if((a=Al(a,t)).result==="error")return a;const o=a.value.expression,c=gr(o);if(!c&&!Es(t))return Go([new nn("","data expressions not supported")]);const d=vl(o,["zoom","pitch","distance-from-center"]);if(!d&&!Dm(t))return Go([new nn("","zoom expressions not supported")]);const m=Mu(o);return m||d?m instanceof nn?Go([m]):m instanceof Lr&&!Bd(t)?Go([new nn("",'"interpolate" expressions cannot be used with this property')]):kd(m?new Ud(c?"camera":"composite",a.value,m.labels,m instanceof Lr?m.interpolation:void 0):new Nd(c?"constant":"source",a.value)):Go([new nn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class wu{constructor(t,o){this._parameters=t,this._specification=o,Mt(this,Fd(this._parameters,this._specification))}static deserialize(t){return new wu(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Mu(a){let t=null;if(a instanceof El)t=Mu(a.result);else if(a instanceof Tl){for(const o of a.args)if(t=Mu(o),t)break}else(a instanceof bl||a instanceof Lr)&&a.input instanceof Pr&&a.input.name==="zoom"&&(t=a);return t instanceof nn||a.eachChild(o=>{const c=Mu(o);c instanceof nn?t=c:!t&&c?t=new nn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&c&&t!==c&&(t=new nn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}class Ht{constructor(t,o,c,d){this.message=(t?`${t}: `:"")+c,d&&(this.identifier=d),o!=null&&o.__line__&&(this.line=o.__line__)}}function jr(a){const t=a.key,o=a.value,c=a.valueSpec||{},d=a.objectElementValidators||{},m=a.style,y=a.styleSpec;let v=[];const w=Qn(o);if(w!=="object")return[new Ht(t,o,`object expected, ${w} found`)];for(const A in o){const D=A.split(".")[0],R=c[D]||c["*"];let k;d[D]?k=d[D]:c[D]?k=ji:d["*"]?k=d["*"]:c["*"]&&(k=ji),k?v=v.concat(k({key:(t&&`${t}.`)+A,value:o[A],valueSpec:R,style:m,styleSpec:y,object:o,objectKey:A},o)):v.push(new Ht(t,o[A],`unknown property "${A}"`))}for(const A in c)d[A]||c[A].required&&c[A].default===void 0&&o[A]===void 0&&v.push(new Ht(t,o,`missing required property "${A}"`));return v}function Cl(a){const t=a.value,o=a.valueSpec,c=a.style,d=a.styleSpec,m=a.key,y=a.arrayElementValidator||ji;if(Qn(t)!=="array")return[new Ht(m,t,`array expected, ${Qn(t)} found`)];if(o.length&&t.length!==o.length)return[new Ht(m,t,`array length ${o.length} expected, length ${t.length} found`)];if(o["min-length"]&&t.length<o["min-length"])return[new Ht(m,t,`array length at least ${o["min-length"]} expected, length ${t.length} found`)];let v={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};d.$version<7&&(v.function=o.function),Qn(o.value)==="object"&&(v=o.value);let w=[];for(let A=0;A<t.length;A++)w=w.concat(y({array:t,arrayIndex:A,value:t[A],valueSpec:v,style:c,styleSpec:d,key:`${m}[${A}]`}));return w}function km(a){const t=a.key,o=a.value,c=a.valueSpec;let d=Qn(o);if(d==="number"&&o!=o&&(d="NaN"),d!=="number")return[new Ht(t,o,`number expected, ${d} found`)];if("minimum"in c){let m=c.minimum;if(Qn(c.minimum)==="array"&&(m=c.minimum[a.arrayIndex]),o<m)return[new Ht(t,o,`${o} is less than the minimum value ${m}`)]}if("maximum"in c){let m=c.maximum;if(Qn(c.maximum)==="array"&&(m=c.maximum[a.arrayIndex]),o>m)return[new Ht(t,o,`${o} is greater than the maximum value ${m}`)]}return[]}function Bm(a){const t=a.valueSpec,o=_t(a.value.type);let c,d,m,y={};const v=o!=="categorical"&&a.value.property===void 0,w=!v,A=Qn(a.value.stops)==="array"&&Qn(a.value.stops[0])==="array"&&Qn(a.value.stops[0][0])==="object",D=jr({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(V){if(o==="identity")return[new Ht(V.key,V.value,'identity function may not have a "stops" property')];let j=[];const $=V.value;return j=j.concat(Cl({key:V.key,value:$,valueSpec:V.valueSpec,style:V.style,styleSpec:V.styleSpec,arrayElementValidator:R})),Qn($)==="array"&&$.length===0&&j.push(new Ht(V.key,$,"array must have at least one stop")),j},default:function(V){return ji({key:V.key,value:V.value,valueSpec:t,style:V.style,styleSpec:V.styleSpec})}}});return o==="identity"&&v&&D.push(new Ht(a.key,a.value,'missing required property "property"')),o==="identity"||a.value.stops||D.push(new Ht(a.key,a.value,'missing required property "stops"')),o==="exponential"&&a.valueSpec.expression&&!Bd(a.valueSpec)&&D.push(new Ht(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(w&&!Es(a.valueSpec)?D.push(new Ht(a.key,a.value,"property functions not supported")):v&&!Dm(a.valueSpec)&&D.push(new Ht(a.key,a.value,"zoom functions not supported"))),o!=="categorical"&&!A||a.value.property!==void 0||D.push(new Ht(a.key,a.value,'"property" property is required')),D;function R(V){let j=[];const $=V.value,ne=V.key;if(Qn($)!=="array")return[new Ht(ne,$,`array expected, ${Qn($)} found`)];if($.length!==2)return[new Ht(ne,$,`array length 2 expected, length ${$.length} found`)];if(A){if(Qn($[0])!=="object")return[new Ht(ne,$,`object expected, ${Qn($[0])} found`)];if($[0].zoom===void 0)return[new Ht(ne,$,"object stop key must have zoom")];if($[0].value===void 0)return[new Ht(ne,$,"object stop key must have value")];const me=_t($[0].zoom);if(typeof me!="number")return[new Ht(ne,$[0].zoom,"stop zoom values must be numbers")];if(m&&m>me)return[new Ht(ne,$[0].zoom,"stop zoom values must appear in ascending order")];me!==m&&(m=me,d=void 0,y={}),j=j.concat(jr({key:`${ne}[0]`,value:$[0],valueSpec:{zoom:{}},style:V.style,styleSpec:V.styleSpec,objectElementValidators:{zoom:km,value:k}}))}else j=j.concat(k({key:`${ne}[0]`,value:$[0],valueSpec:{},style:V.style,styleSpec:V.styleSpec},$));return Ss(Ft($[1]))?j.concat([new Ht(`${ne}[1]`,$[1],"expressions are not allowed in function stops.")]):j.concat(ji({key:`${ne}[1]`,value:$[1],valueSpec:t,style:V.style,styleSpec:V.styleSpec}))}function k(V,j){const $=Qn(V.value),ne=_t(V.value),me=V.value!==null?V.value:j;if(c){if($!==c)return[new Ht(V.key,me,`${$} stop domain type must match previous stop domain type ${c}`)]}else c=$;if($!=="number"&&$!=="string"&&$!=="boolean"&&typeof ne!="number"&&typeof ne!="string"&&typeof ne!="boolean")return[new Ht(V.key,me,"stop domain value must be a number, string, or boolean")];if($!=="number"&&o!=="categorical"){let ke=`number expected, ${$} found`;return Es(t)&&o===void 0&&(ke+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ht(V.key,me,ke)]}return o!=="categorical"||$!=="number"||typeof ne=="number"&&isFinite(ne)&&Math.floor(ne)===ne?o!=="categorical"&&$==="number"&&typeof ne=="number"&&typeof d=="number"&&d!==void 0&&ne<d?[new Ht(V.key,me,"stop domain values must appear in ascending order")]:(d=ne,o==="categorical"&&ne in y?[new Ht(V.key,me,"stop domain values must be unique")]:(y[ne]=!0,[])):[new Ht(V.key,me,`integer expected, found ${String(ne)}`)]}}function As(a){const t=(a.expressionContext==="property"?zm:Al)(Ft(a.value),a.valueSpec);if(t.result==="error")return t.value.map(c=>new Ht(`${a.key}${c.key}`,a.value,c.message));const o=t.value.expression||t.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!o.outputDefined())return[new Ht(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if(a.expressionContext==="property"&&a.propertyType==="layout"&&!yl(o))return[new Ht(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return Fa(o,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!vl(o,["zoom","feature-state"]))return[new Ht(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!gr(o))return[new Ht(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Fa(a,t){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const d of t.valueSpec.expression.parameters)o.delete(d);if(o.size===0)return[];const c=[];return a instanceof Pr&&o.has(a.name)?[new Ht(t.key,t.value,`["${a.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(a.eachChild(d=>{c.push(...Fa(d,t))}),c)}function Pl(a){const t=a.key,o=a.value,c=a.valueSpec,d=[];return Array.isArray(c.values)?c.values.indexOf(_t(o))===-1&&d.push(new Ht(t,o,`expected one of [${c.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(c.values).indexOf(_t(o))===-1&&d.push(new Ht(t,o,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(o)} found`)),d}function so(a){if(a===!0||a===!1)return!0;if(!Array.isArray(a)||a.length===0)return!1;switch(a[0]){case"has":return a.length>=2&&a[1]!=="$id"&&a[1]!=="$type";case"in":return a.length>=3&&(typeof a[1]!="string"||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return a.length!==3||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const t of a.slice(1))if(!so(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}function lo(a,t="fill"){if(a==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};so(a)||(a=Ll(a));const o=a;let c=!0;try{c=function(A){if(!co(A))return A;let D=Ft(A);return Fm(D),D=Vd(D),D}(o)}catch(A){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
  2884. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
  2885. and paste the contents of this message in the report.
  2886. Thank you!
  2887. Filter Expression:
  2888. ${JSON.stringify(o,null,2)}
  2889. `)}const d=xe[`filter_${t}`],m=Al(c,d);let y=null;if(m.result==="error")throw new Error(m.value.map(A=>`${A.key}: ${A.message}`).join(", "));y=(A,D,R)=>m.value.evaluate(A,D,{},R);let v=null,w=null;if(c!==o){const A=Al(o,d);if(A.result==="error")throw new Error(A.value.map(D=>`${D.key}: ${D.message}`).join(", "));v=(D,R,k,V,j)=>A.value.evaluate(D,R,{},k,void 0,void 0,V,j),w=!gr(A.value.expression)}return y=y,{filter:y,dynamicFilter:v||void 0,needGeometry:Tu(c),needFeature:!!w}}function Vd(a){if(!Array.isArray(a))return a;const t=function(o){if(Om.has(o[0])){for(let c=1;c<o.length;c++)if(co(o[c]))return!0}return o}(a);return t===!0?t:t.map(o=>Vd(o))}function Fm(a){let t=!1;const o=[];if(a[0]==="case"){for(let c=1;c<a.length-1;c+=2)t=t||co(a[c]),o.push(a[c+1]);o.push(a[a.length-1])}else if(a[0]==="match"){t=t||co(a[1]);for(let c=2;c<a.length-1;c+=2)o.push(a[c+1]);o.push(a[a.length-1])}else if(a[0]==="step"){t=t||co(a[1]);for(let c=1;c<a.length-1;c+=2)o.push(a[c+1])}t&&(a.length=0,a.push("any",...o));for(let c=1;c<a.length;c++)Fm(a[c])}function co(a){if(!Array.isArray(a))return!1;if((t=a[0])==="pitch"||t==="distance-from-center")return!0;var t;for(let o=1;o<a.length;o++)if(co(a[o]))return!0;return!1}const Om=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Gd(a,t){return a<t?-1:a>t?1:0}function Tu(a){if(!Array.isArray(a))return!1;if(a[0]==="within")return!0;for(let t=1;t<a.length;t++)if(Tu(a[t]))return!0;return!1}function Ll(a){if(!a)return!0;const t=a[0];return a.length<=1?t!=="any":t==="=="?Dl(a[1],a[2],"=="):t==="!="?Il(Dl(a[1],a[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Dl(a[1],a[2],t):t==="any"?(o=a.slice(1),["any"].concat(o.map(Ll))):t==="all"?["all"].concat(a.slice(1).map(Ll)):t==="none"?["all"].concat(a.slice(1).map(Ll).map(Il)):t==="in"?Hd(a[1],a.slice(2)):t==="!in"?Il(Hd(a[1],a.slice(2))):t==="has"?Wd(a[1]):t==="!has"?Il(Wd(a[1])):t!=="within"||a;var o}function Dl(a,t,o){switch(a){case"$type":return[`filter-type-${o}`,t];case"$id":return[`filter-id-${o}`,t];default:return[`filter-${o}`,a,t]}}function Hd(a,t){if(t.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(o=>typeof o!=typeof t[0])?["filter-in-large",a,["literal",t.sort(Gd)]]:["filter-in-small",a,["literal",t]]}}function Wd(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function Il(a){return["!",a]}function uo(a){return so(Ft(a.value))?As(Mt({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${a.layerType||"fill"}`]})):jd(a)}function jd(a){const t=a.value,o=a.key;if(Qn(t)!=="array")return[new Ht(o,t,`array expected, ${Qn(t)} found`)];const c=a.styleSpec;let d,m=[];if(t.length<1)return[new Ht(o,t,"filter array must have at least 1 element")];switch(m=m.concat(Pl({key:`${o}[0]`,value:t[0],valueSpec:c.filter_operator,style:a.style,styleSpec:a.styleSpec})),_t(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&_t(t[1])==="$type"&&m.push(new Ht(o,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&m.push(new Ht(o,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(d=Qn(t[1]),d!=="string"&&m.push(new Ht(`${o}[1]`,t[1],`string expected, ${d} found`)));for(let y=2;y<t.length;y++)d=Qn(t[y]),_t(t[1])==="$type"?m=m.concat(Pl({key:`${o}[${y}]`,value:t[y],valueSpec:c.geometry_type,style:a.style,styleSpec:a.styleSpec})):d!=="string"&&d!=="number"&&d!=="boolean"&&m.push(new Ht(`${o}[${y}]`,t[y],`string, number, or boolean expected, ${d} found`));break;case"any":case"all":case"none":for(let y=1;y<t.length;y++)m=m.concat(jd({key:`${o}[${y}]`,value:t[y],style:a.style,styleSpec:a.styleSpec}));break;case"has":case"!has":d=Qn(t[1]),t.length!==2?m.push(new Ht(o,t,`filter array for "${t[0]}" operator must have 2 elements`)):d!=="string"&&m.push(new Ht(`${o}[1]`,t[1],`string expected, ${d} found`));break;case"within":d=Qn(t[1]),t.length!==2?m.push(new Ht(o,t,`filter array for "${t[0]}" operator must have 2 elements`)):d!=="object"&&m.push(new Ht(`${o}[1]`,t[1],`object expected, ${d} found`))}return m}function qd(a,t){const o=a.key,c=a.style,d=a.styleSpec,m=a.value,y=a.objectKey,v=d[`${t}_${a.layerType}`];if(!v)return[];const w=y.match(/^(.*)-transition$/);if(t==="paint"&&w&&v[w[1]]&&v[w[1]].transition)return ji({key:o,value:m,valueSpec:d.transition,style:c,styleSpec:d});const A=a.valueSpec||v[y];if(!A)return[new Ht(o,m,`unknown property "${y}"`)];let D;if(Qn(m)==="string"&&Es(A)&&!A.tokens&&(D=/^{([^}]+)}$/.exec(m)))return[new Ht(o,m,`"${y}" does not support interpolation syntax
  2890. Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(D[1])} }\`.`)];const R=[];return a.layerType==="symbol"&&(y==="text-field"&&c&&!c.glyphs&&R.push(new Ht(o,m,'use of "text-field" requires a style "glyphs" property')),y==="text-font"&&Ho(Ft(m))&&_t(m.type)==="identity"&&R.push(new Ht(o,m,'"text-font" does not support identity functions'))),R.concat(ji({key:a.key,value:m,valueSpec:A,style:c,styleSpec:d,expressionContext:"property",propertyType:t,propertyKey:y}))}function Eu(a){return qd(a,"paint")}function Zd(a){return qd(a,"layout")}function Nm(a){let t=[];const o=a.value,c=a.key,d=a.style,m=a.styleSpec;o.type||o.ref||t.push(new Ht(c,o,'either "type" or "ref" is required'));let y=_t(o.type);const v=_t(o.ref);if(o.id){const w=_t(o.id);for(let A=0;A<a.arrayIndex;A++){const D=d.layers[A];_t(D.id)===w&&t.push(new Ht(c,o.id,`duplicate layer id "${o.id}", previously used at line ${D.id.__line__}`))}}if("ref"in o){let w;["type","source","source-layer","filter","layout"].forEach(A=>{A in o&&t.push(new Ht(c,o[A],`"${A}" is prohibited for ref layers`))}),d.layers.forEach(A=>{_t(A.id)===v&&(w=A)}),w?w.ref?t.push(new Ht(c,o.ref,"ref cannot reference another ref layer")):y=_t(w.type):typeof v=="string"&&t.push(new Ht(c,o.ref,`ref layer "${v}" not found`))}else if(y!=="background"&&y!=="sky")if(o.source){const w=d.sources&&d.sources[o.source],A=w&&_t(w.type);w?A==="vector"&&y==="raster"?t.push(new Ht(c,o.source,`layer "${o.id}" requires a raster source`)):A==="raster"&&y!=="raster"?t.push(new Ht(c,o.source,`layer "${o.id}" requires a vector source`)):A!=="vector"||o["source-layer"]?A==="raster-dem"&&y!=="hillshade"?t.push(new Ht(c,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):y!=="line"||!o.paint||!o.paint["line-gradient"]||A==="geojson"&&w.lineMetrics||t.push(new Ht(c,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Ht(c,o,`layer "${o.id}" must specify a "source-layer"`)):t.push(new Ht(c,o.source,`source "${o.source}" not found`))}else t.push(new Ht(c,o,'missing required property "source"'));return t=t.concat(jr({key:c,value:o,valueSpec:m.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ji({key:`${c}.type`,value:o.type,valueSpec:m.layer.type,style:a.style,styleSpec:a.styleSpec,object:o,objectKey:"type"}),filter:w=>uo(Mt({layerType:y},w)),layout:w=>jr({layer:o,key:w.key,value:w.value,valueSpec:{},style:w.style,styleSpec:w.styleSpec,objectElementValidators:{"*":A=>Zd(Mt({layerType:y},A))}}),paint:w=>jr({layer:o,key:w.key,value:w.value,valueSpec:{},style:w.style,styleSpec:w.styleSpec,objectElementValidators:{"*":A=>Eu(Mt({layerType:y},A))}})}})),t}function Oa(a){const t=a.value,o=a.key,c=Qn(t);return c!=="string"?[new Ht(o,t,`string expected, ${c} found`)]:[]}const Um={promoteId:function({key:a,value:t}){if(Qn(t)==="string")return Oa({key:a,value:t});{const o=[];for(const c in t)o.push(...Oa({key:`${a}.${c}`,value:t[c]}));return o}}};function Vm(a){const t=a.value,o=a.key,c=a.styleSpec,d=a.style;if(!t.type)return[new Ht(o,t,'"type" is required')];const m=_t(t.type);let y;switch(m){case"vector":case"raster":case"raster-dem":return y=jr({key:o,value:t,valueSpec:c[`source_${m.replace("-","_")}`],style:a.style,styleSpec:c,objectElementValidators:Um}),y;case"geojson":if(y=jr({key:o,value:t,valueSpec:c.source_geojson,style:d,styleSpec:c,objectElementValidators:Um}),t.cluster)for(const v in t.clusterProperties){const[w,A]=t.clusterProperties[v],D=typeof w=="string"?[w,["accumulated"],["get",v]]:w;y.push(...As({key:`${o}.${v}.map`,value:A,expressionContext:"cluster-map"})),y.push(...As({key:`${o}.${v}.reduce`,value:D,expressionContext:"cluster-reduce"}))}return y;case"video":return jr({key:o,value:t,valueSpec:c.source_video,style:d,styleSpec:c});case"image":return jr({key:o,value:t,valueSpec:c.source_image,style:d,styleSpec:c});case"canvas":return[new Ht(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pl({key:`${o}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:d,styleSpec:c})}}function Gm(a){const t=a.value,o=a.styleSpec,c=o.light,d=a.style;let m=[];const y=Qn(t);if(t===void 0)return m;if(y!=="object")return m=m.concat([new Ht("light",t,`object expected, ${y} found`)]),m;for(const v in t){const w=v.match(/^(.*)-transition$/);m=m.concat(w&&c[w[1]]&&c[w[1]].transition?ji({key:v,value:t[v],valueSpec:o.transition,style:d,styleSpec:o}):c[v]?ji({key:v,value:t[v],valueSpec:c[v],style:d,styleSpec:o}):[new Ht(v,t[v],`unknown property "${v}"`)])}return m}function Hm(a){const t=a.value,o=a.key,c=a.style,d=a.styleSpec,m=d.terrain;let y=[];const v=Qn(t);if(t===void 0)return y;if(v!=="object")return y=y.concat([new Ht("terrain",t,`object expected, ${v} found`)]),y;for(const w in t){const A=w.match(/^(.*)-transition$/);y=y.concat(A&&m[A[1]]&&m[A[1]].transition?ji({key:w,value:t[w],valueSpec:d.transition,style:c,styleSpec:d}):m[w]?ji({key:w,value:t[w],valueSpec:m[w],style:c,styleSpec:d}):[new Ht(w,t[w],`unknown property "${w}"`)])}if(t.source){const w=c.sources&&c.sources[t.source],A=w&&_t(w.type);w?A!=="raster-dem"&&y.push(new Ht(o,t.source,`terrain cannot be used with a source of type ${String(A)}, it only be used with a "raster-dem" source type`)):y.push(new Ht(o,t.source,`source "${t.source}" not found`))}else y.push(new Ht(o,t,'terrain is missing required property "source"'));return y}function Wm(a){const t=a.value,o=a.style,c=a.styleSpec,d=c.fog;let m=[];const y=Qn(t);if(t===void 0)return m;if(y!=="object")return m=m.concat([new Ht("fog",t,`object expected, ${y} found`)]),m;for(const v in t){const w=v.match(/^(.*)-transition$/);m=m.concat(w&&d[w[1]]&&d[w[1]].transition?ji({key:v,value:t[v],valueSpec:c.transition,style:o,styleSpec:c}):d[v]?ji({key:v,value:t[v],valueSpec:d[v],style:o,styleSpec:c}):[new Ht(v,t[v],`unknown property "${v}"`)])}return m}const Rl={"*":()=>[],array:Cl,boolean:function(a){const t=a.value,o=a.key,c=Qn(t);return c!=="boolean"?[new Ht(o,t,`boolean expected, ${c} found`)]:[]},number:km,color:function(a){const t=a.key,o=a.value,c=Qn(o);return c!=="string"?[new Ht(t,o,`color expected, ${c} found`)]:xd.parseCSSColor(o)===null?[new Ht(t,o,`color expected, "${o}" found`)]:[]},enum:Pl,filter:uo,function:Bm,layer:Nm,object:jr,source:Vm,light:Gm,terrain:Hm,fog:Wm,string:Oa,formatted:function(a){return Oa(a).length===0?[]:As(a)},resolvedImage:function(a){return Oa(a).length===0?[]:As(a)},projection:function(a){const t=a.value,o=a.styleSpec,c=o.projection,d=a.style;let m=[];const y=Qn(t);if(y==="object")for(const v in t)m=m.concat(ji({key:v,value:t[v],valueSpec:c[v],style:d,styleSpec:o}));else y!=="string"&&(m=m.concat([new Ht("projection",t,`object or string expected, ${y} found`)]));return m}};function ji(a){const t=a.value,o=a.valueSpec,c=a.styleSpec;return o.expression&&Ho(_t(t))?Bm(a):o.expression&&Ss(Ft(t))?As(a):o.type&&Rl[o.type]?Rl[o.type](a):jr(Mt({},a,{valueSpec:o.type?c[o.type]:o}))}function Dr(a){const t=a.value,o=a.key,c=Oa(a);return c.length||(t.indexOf("{fontstack}")===-1&&c.push(new Ht(o,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&c.push(new Ht(o,t,'"glyphs" url must include a "{range}" token'))),c}function zl(a,t=xe){return Na(ji({key:"",value:a,valueSpec:t.$root,styleSpec:t,style:a,objectElementValidators:{glyphs:Dr,"*":()=>[]}}))}const Wy=a=>Na(Eu(a)),jy=a=>Na(Zd(a));function Na(a){return a.slice().sort((t,o)=>t.line&&o.line?t.line-o.line:0)}function jm(a,t){let o=!1;if(t&&t.length)for(const c of t)a.fire(new Y(new Error(c.message))),o=!0;return o}var ho=Ma;function Ma(a,t,o){var c=this.cells=[];if(a instanceof ArrayBuffer){this.arrayBuffer=a;var d=new Int32Array(this.arrayBuffer);a=d[0],this.d=(t=d[1])+2*(o=d[2]);for(var m=0;m<this.d*this.d;m++){var y=d[3+m],v=d[3+m+1];c.push(y===v?null:d.subarray(y,v))}var w=d[3+c.length+1];this.keys=d.subarray(d[3+c.length],w),this.bboxes=d.subarray(w),this.insert=this._insertReadonly}else{this.d=t+2*o;for(var A=0;A<this.d*this.d;A++)c.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=a,this.padding=o,this.scale=t/a,this.uid=0;var D=o/t*a;this.min=-D,this.max=a+D}Ma.prototype.insert=function(a,t,o,c,d){this._forEachCell(t,o,c,d,this._insertCell,this.uid++),this.keys.push(a),this.bboxes.push(t),this.bboxes.push(o),this.bboxes.push(c),this.bboxes.push(d)},Ma.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Ma.prototype._insertCell=function(a,t,o,c,d,m){this.cells[d].push(m)},Ma.prototype.query=function(a,t,o,c,d){var m=this.min,y=this.max;if(a<=m&&t<=m&&y<=o&&y<=c&&!d)return Array.prototype.slice.call(this.keys);var v=[];return this._forEachCell(a,t,o,c,this._queryCell,v,{},d),v},Ma.prototype._queryCell=function(a,t,o,c,d,m,y,v){var w=this.cells[d];if(w!==null)for(var A=this.keys,D=this.bboxes,R=0;R<w.length;R++){var k=w[R];if(y[k]===void 0){var V=4*k;(v?v(D[V+0],D[V+1],D[V+2],D[V+3]):a<=D[V+2]&&t<=D[V+3]&&o>=D[V+0]&&c>=D[V+1])?(y[k]=!0,m.push(A[k])):y[k]=!1}}},Ma.prototype._forEachCell=function(a,t,o,c,d,m,y,v){for(var w=this._convertToCellCoord(a),A=this._convertToCellCoord(t),D=this._convertToCellCoord(o),R=this._convertToCellCoord(c),k=w;k<=D;k++)for(var V=A;V<=R;V++){var j=this.d*V+k;if((!v||v(this._convertFromCellCoord(k),this._convertFromCellCoord(V),this._convertFromCellCoord(k+1),this._convertFromCellCoord(V+1)))&&d.call(this,a,t,o,c,j,m,y,v))return}},Ma.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},Ma.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},Ma.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var a=this.cells,t=3+this.cells.length+1+1,o=0,c=0;c<this.cells.length;c++)o+=this.cells[c].length;var d=new Int32Array(t+o+this.keys.length+this.bboxes.length);d[0]=this.extent,d[1]=this.n,d[2]=this.padding;for(var m=t,y=0;y<a.length;y++){var v=a[y];d[3+y]=m,d.set(v,m),m+=v.length}return d[3+a.length]=m,d.set(this.keys,m),d[3+a.length+1]=m+=this.keys.length,d.set(this.bboxes,m),m+=this.bboxes.length,d.buffer};const Cs={};function jt(a,t,o={}){Object.defineProperty(a,"_classRegistryKey",{value:t,writeable:!1}),Cs[t]={klass:a,omit:o.omit||[]}}jt(Object,"Object"),ho.serialize=function(a,t){const o=a.toArrayBuffer();return t&&t.push(o),{buffer:o}},ho.deserialize=function(a){return new ho(a.buffer)},Object.defineProperty(ho,"name",{value:"Grid"}),jt(ho,"Grid"),jt(Xn,"Color"),jt(Error,"Error"),jt(G,"AJAXError"),jt(Cr,"ResolvedImage"),jt(wu,"StylePropertyFunction"),jt(bu,"StyleExpression",{omit:["_evaluator"]}),jt(Ud,"ZoomDependentExpression"),jt(Nd,"ZoomConstantExpression"),jt(Pr,"CompoundExpression",{omit:["_evaluate"]});for(const a in Vo)Cs[Vo[a]._classRegistryKey]||jt(Vo[a],`Expression${a}`);function qm(a){return a&&typeof ArrayBuffer!="undefined"&&(a instanceof ArrayBuffer||a.constructor&&a.constructor.name==="ArrayBuffer")}function Su(a){return I.ImageBitmap&&a instanceof I.ImageBitmap}function kl(a,t){if(a==null||typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp)return a;if(qm(a)||Su(a))return t&&t.push(a),a;if(ArrayBuffer.isView(a)){const o=a;return t&&t.push(o.buffer),o}if(a instanceof I.ImageData)return t&&t.push(a.data.buffer),a;if(Array.isArray(a)){const o=[];for(const c of a)o.push(kl(c,t));return o}if(typeof a=="object"){const o=a.constructor,c=o._classRegistryKey;if(!c)throw new Error(`can't serialize object of unregistered class ${c}`);const d=o.serialize?o.serialize(a,t):{};if(!o.serialize){for(const m in a)a.hasOwnProperty(m)&&(Cs[c].omit.indexOf(m)>=0||(d[m]=kl(a[m],t)));a instanceof Error&&(d.message=a.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return c!=="Object"&&(d.$name=c),d}throw new Error("can't serialize object of type "+typeof a)}function Ps(a){if(a==null||typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||qm(a)||Su(a)||ArrayBuffer.isView(a)||a instanceof I.ImageData)return a;if(Array.isArray(a))return a.map(Ps);if(typeof a=="object"){const t=a.$name||"Object",{klass:o}=Cs[t];if(!o)throw new Error(`can't deserialize unregistered class ${t}`);if(o.deserialize)return o.deserialize(a);const c=Object.create(o.prototype);for(const d of Object.keys(a))d!=="$name"&&(c[d]=Ps(a[d]));return c}throw new Error("can't deserialize object of type "+typeof a)}class Xd{constructor(){this.first=!0}update(t,o){const c=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=c,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=c,!0):(this.lastFloorZoom>c?(this.lastIntegerZoom=c+1,this.lastIntegerZoomTime=o):this.lastFloorZoom<c&&(this.lastIntegerZoom=c,this.lastIntegerZoomTime=o),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=c,!0))}}const Zm=a=>a>=1536&&a<=1791,Au=a=>a>=1872&&a<=1919,Bl=a=>a>=2208&&a<=2303,Yd=a=>a>=11904&&a<=12031,Xm=a=>a>=12032&&a<=12255,$d=a=>a>=12272&&a<=12287,Cu=a=>a>=12288&&a<=12351,Fl=a=>a>=12352&&a<=12447,Pu=a=>a>=12448&&a<=12543,Ym=a=>a>=12544&&a<=12591,$m=a=>a>=12704&&a<=12735,Jm=a=>a>=12736&&a<=12783,Jd=a=>a>=12784&&a<=12799,Km=a=>a>=12800&&a<=13055,Qm=a=>a>=13056&&a<=13311,eg=a=>a>=13312&&a<=19903,Kd=a=>a>=19968&&a<=40959,tg=a=>a>=40960&&a<=42127,ng=a=>a>=42128&&a<=42191,ig=a=>a>=44032&&a<=55215,Ol=a=>a>=63744&&a<=64255,Qd=a=>a>=64336&&a<=65023,rg=a=>a>=65040&&a<=65055,Ls=a=>a>=65072&&a<=65103,ag=a=>a>=65104&&a<=65135,Lu=a=>a>=65136&&a<=65279,ep=a=>a>=65280&&a<=65519;function Du(a){for(const t of a)if(Iu(t.charCodeAt(0)))return!0;return!1}function og(a){for(const t of a)if(!sg(t.charCodeAt(0)))return!1;return!0}function sg(a){return!(Zm(a)||Au(a)||Bl(a)||Qd(a)||Lu(a))}function Iu(a){return!(a!==746&&a!==747&&(a<4352||!($m(a)||Ym(a)||Ls(a)&&!(a>=65097&&a<=65103)||Ol(a)||Qm(a)||Yd(a)||Jm(a)||!(!Cu(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||a===12336)||eg(a)||Kd(a)||Km(a)||(t=>t>=12592&&t<=12687)(a)||(t=>t>=43360&&t<=43391)(a)||(t=>t>=55216&&t<=55295)(a)||(t=>t>=4352&&t<=4607)(a)||ig(a)||Fl(a)||$d(a)||(t=>t>=12688&&t<=12703)(a)||Xm(a)||Jd(a)||Pu(a)&&a!==12540||!(!ep(a)||a===65288||a===65289||a===65293||a>=65306&&a<=65310||a===65339||a===65341||a===65343||a>=65371&&a<=65503||a===65507||a>=65512&&a<=65519)||!(!ag(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(t=>t>=5120&&t<=5759)(a)||(t=>t>=6320&&t<=6399)(a)||rg(a)||(t=>t>=19904&&t<=19967)(a)||tg(a)||ng(a))))}function Ru(a){return!(Iu(a)||function(t){return!!((o=>o>=128&&o<=255)(t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||(o=>o>=8192&&o<=8303)(t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||(o=>o>=8448&&o<=8527)(t)||(o=>o>=8528&&o<=8591)(t)||(o=>o>=8960&&o<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||(o=>o>=9216&&o<=9279)(t)&&t!==9251||(o=>o>=9280&&o<=9311)(t)||(o=>o>=9312&&o<=9471)(t)||(o=>o>=9632&&o<=9727)(t)||(o=>o>=9728&&o<=9983)(t)&&!(t>=9754&&t<=9759)||(o=>o>=11008&&o<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Cu(t)||Pu(t)||(o=>o>=57344&&o<=63743)(t)||Ls(t)||ag(t)||ep(t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(a))}function zu(a){return a>=1424&&a<=2303||Qd(a)||Lu(a)}function qy(a,t){return!(!t&&zu(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(o=>o>=6016&&o<=6143)(a))}function Zy(a){for(const t of a)if(zu(t.charCodeAt(0)))return!0;return!1}const tp="deferred",Nl="loading",np="loaded";let ip=null,_r="unavailable",Ir=null;const Ul=function(a){a&&typeof a=="string"&&a.indexOf("NetworkError")>-1&&(_r="error"),ip&&ip(a)};function Wo(){rp.fire(new W("pluginStateChange",{pluginStatus:_r,pluginURL:Ir}))}const rp=new ze,ku=function(){return _r},Ds=function(){if(_r!==tp||!Ir)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_r=Nl,Wo(),Ir&&Le({url:Ir},a=>{a?Ul(a):(_r=np,Wo())})},qr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_r===np||qr.applyArabicShaping!=null,isLoading:()=>_r===Nl,setState(a){_r=a.pluginStatus,Ir=a.pluginURL},isParsed:()=>qr.applyArabicShaping!=null&&qr.processBidirectionalText!=null&&qr.processStyledBidirectionalText!=null,getPluginURL:()=>Ir};class ci{constructor(t,o){this.zoom=t,o?(this.now=o.now,this.fadeDuration=o.fadeDuration,this.zoomHistory=o.zoomHistory,this.transition=o.transition,this.pitch=o.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Xd,this.transition={},this.pitch=0)}isSupportedScript(t){return function(o,c){for(const d of o)if(!qy(d.charCodeAt(0),c))return!1;return!0}(t,qr.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,o=t-Math.floor(t),c=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:o+(1-o)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*o}}}class Vl{constructor(t,o){this.property=t,this.value=o,this.expression=function(c,d){if(Ho(c))return new wu(c,d);if(Ss(c)){const m=zm(c,d);if(m.result==="error")throw new Error(m.value.map(y=>`${y.key}: ${y.message}`).join(", "));return m.value}{let m=c;return typeof c=="string"&&d.type==="color"&&(m=Xn.parse(c)),{kind:"constant",evaluate:()=>m}}}(o===void 0?t.specification.default:o,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,o,c){return this.property.possiblyEvaluate(this,t,o,c)}}class Is{constructor(t){this.property=t,this.value=new Vl(t,void 0)}transitioned(t,o){return new r(this.property,this.value,o,ye({},t.transition,this.transition),t.now)}untransitioned(){return new r(this.property,this.value,null,{},0)}}class f{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return Ot(this._values[t].value.value)}setValue(t,o){this._values.hasOwnProperty(t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].value=new Vl(this._values[t].property,o===null?void 0:Ot(o))}getTransition(t){return Ot(this._values[t].transition)}setTransition(t,o){this._values.hasOwnProperty(t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].transition=Ot(o)||void 0}serialize(){const t={};for(const o of Object.keys(this._values)){const c=this.getValue(o);c!==void 0&&(t[o]=c);const d=this.getTransition(o);d!==void 0&&(t[`${o}-transition`]=d)}return t}transitioned(t,o){const c=new u(this._properties);for(const d of Object.keys(this._values))c._values[d]=this._values[d].transitioned(t,o._values[d]);return c}untransitioned(){const t=new u(this._properties);for(const o of Object.keys(this._values))t._values[o]=this._values[o].untransitioned();return t}}class r{constructor(t,o,c,d,m){const y=d.delay||0,v=d.duration||0;m=m||0,this.property=t,this.value=o,this.begin=m+y,this.end=this.begin+v,t.specification.transition&&(d.delay||d.duration)&&(this.prior=c)}possiblyEvaluate(t,o,c){const d=t.now||0,m=this.value.possiblyEvaluate(t,o,c),y=this.prior;if(y){if(d>this.end)return this.prior=null,m;if(this.value.isDataDriven())return this.prior=null,m;if(d<this.begin)return y.possiblyEvaluate(t,o,c);{const v=(d-this.begin)/(this.end-this.begin);return this.property.interpolate(y.possiblyEvaluate(t,o,c),m,he(v))}}return m}}class u{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,o,c){const d=new b(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].possiblyEvaluate(t,o,c);return d}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class g{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return Ot(this._values[t].value)}setValue(t,o){this._values[t]=new Vl(this._values[t].property,o===null?void 0:Ot(o))}serialize(){const t={};for(const o of Object.keys(this._values)){const c=this.getValue(o);c!==void 0&&(t[o]=c)}return t}possiblyEvaluate(t,o,c){const d=new b(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].possiblyEvaluate(t,o,c);return d}}class x{constructor(t,o,c){this.property=t,this.value=o,this.parameters=c}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,o,c,d){return this.property.evaluate(this.value,this.parameters,t,o,c,d)}}class b{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class S{constructor(t){this.specification=t}possiblyEvaluate(t,o){return t.expression.evaluate(o)}interpolate(t,o,c){const d=hu[this.specification.type];return d?d(t,o,c):t}}class P{constructor(t,o){this.specification=t,this.overrides=o}possiblyEvaluate(t,o,c,d){return new x(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(o,null,{},c,d)}:t.expression,o)}interpolate(t,o,c){if(t.value.kind!=="constant"||o.value.kind!=="constant")return t;if(t.value.value===void 0||o.value.value===void 0)return new x(this,{kind:"constant",value:void 0},t.parameters);const d=hu[this.specification.type];return d?new x(this,{kind:"constant",value:d(t.value.value,o.value.value,c)},t.parameters):t}evaluate(t,o,c,d,m,y){return t.kind==="constant"?t.value:t.evaluate(o,c,d,m,y)}}class z extends P{possiblyEvaluate(t,o,c,d){if(t.value===void 0)return new x(this,{kind:"constant",value:void 0},o);if(t.expression.kind==="constant"){const m=t.expression.evaluate(o,null,{},c,d),y=t.property.specification.type==="resolvedImage"&&typeof m!="string"?m.name:m,v=this._calculate(y,y,y,o);return new x(this,{kind:"constant",value:v},o)}if(t.expression.kind==="camera"){const m=this._calculate(t.expression.evaluate({zoom:o.zoom-1}),t.expression.evaluate({zoom:o.zoom}),t.expression.evaluate({zoom:o.zoom+1}),o);return new x(this,{kind:"constant",value:m},o)}return new x(this,t.expression,o)}evaluate(t,o,c,d,m,y){if(t.kind==="source"){const v=t.evaluate(o,c,d,m,y);return this._calculate(v,v,v,o)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(o.zoom)-1},c,d),t.evaluate({zoom:Math.floor(o.zoom)},c,d),t.evaluate({zoom:Math.floor(o.zoom)+1},c,d),o):t.value}_calculate(t,o,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:t,to:o,other:c}:{from:c,to:o,other:t}}interpolate(t){return t}}class F{constructor(t){this.specification=t}possiblyEvaluate(t,o,c,d){if(t.value!==void 0){if(t.expression.kind==="constant"){const m=t.expression.evaluate(o,null,{},c,d);return this._calculate(m,m,m,o)}return this._calculate(t.expression.evaluate(new ci(Math.floor(o.zoom-1),o)),t.expression.evaluate(new ci(Math.floor(o.zoom),o)),t.expression.evaluate(new ci(Math.floor(o.zoom+1),o)),o)}}_calculate(t,o,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:t,to:o}:{from:c,to:o}}interpolate(t){return t}}class N{constructor(t){this.specification=t}possiblyEvaluate(t,o,c,d){return!!t.expression.evaluate(o,null,{},c,d)}interpolate(){return!1}}class H{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const o in t){const c=t[o];c.specification.overridable&&this.overridableProperties.push(o);const d=this.defaultPropertyValues[o]=new Vl(c,void 0),m=this.defaultTransitionablePropertyValues[o]=new Is(c);this.defaultTransitioningPropertyValues[o]=m.untransitioned(),this.defaultPossiblyEvaluatedValues[o]=d.possiblyEvaluate({})}}}function J(a,t){return 256*(a=ie(Math.floor(a),0,255))+ie(Math.floor(t),0,255)}jt(P,"DataDrivenProperty"),jt(S,"DataConstantProperty"),jt(z,"CrossFadedDataDrivenProperty"),jt(F,"CrossFadedProperty"),jt(N,"ColorRampProperty");const re={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Q{constructor(t,o){this._structArray=t,this._pos1=o*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class X{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,o){return t._trim(),o&&(t.isTransferred=!0,o.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const o=Object.create(this.prototype);return o.arrayBuffer=t.arrayBuffer,o.length=t.length,o.capacity=t.arrayBuffer.byteLength/o.bytesPerElement,o._refreshViews(),o}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const o=this.uint8;this._refreshViews(),o&&this.uint8.set(o)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ae(a,t=1){let o=0,c=0;return{members:a.map(d=>{const m=re[d.type].BYTES_PER_ELEMENT,y=o=fe(o,Math.max(t,m)),v=d.components||1;return c=Math.max(c,m),o+=m*v,{name:d.name,type:d.type,components:v,offset:y}}),size:fe(o,Math.max(c,t)),alignment:t}}function fe(a,t){return Math.ceil(a/t)*t}class Te extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o){const c=this.length;return this.resize(c+1),this.emplace(c,t,o)}emplace(t,o,c){const d=2*t;return this.int16[d+0]=o,this.int16[d+1]=c,t}}Te.prototype.bytesPerElement=4,jt(Te,"StructArrayLayout2i4");class Se extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,t,o,c)}emplace(t,o,c,d){const m=3*t;return this.int16[m+0]=o,this.int16[m+1]=c,this.int16[m+2]=d,t}}Se.prototype.bytesPerElement=6,jt(Se,"StructArrayLayout3i6");class Re extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=4*t;return this.int16[y+0]=o,this.int16[y+1]=c,this.int16[y+2]=d,this.int16[y+3]=m,t}}Re.prototype.bytesPerElement=8,jt(Re,"StructArrayLayout4i8");class be extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=6*t,D=12*t,R=3*t;return this.int16[A+0]=o,this.int16[A+1]=c,this.uint8[D+4]=d,this.uint8[D+5]=m,this.uint8[D+6]=y,this.uint8[D+7]=v,this.float32[R+2]=w,t}}be.prototype.bytesPerElement=12,jt(be,"StructArrayLayout2i4ub1f12");class Fe extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=4*t;return this.float32[y+0]=o,this.float32[y+1]=c,this.float32[y+2]=d,this.float32[y+3]=m,t}}Fe.prototype.bytesPerElement=16,jt(Fe,"StructArrayLayout4f16");class Qe extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D){const R=this.length;return this.resize(R+1),this.emplace(R,t,o,c,d,m,y,v,w,A,D)}emplace(t,o,c,d,m,y,v,w,A,D,R){const k=10*t;return this.uint16[k+0]=o,this.uint16[k+1]=c,this.uint16[k+2]=d,this.uint16[k+3]=m,this.uint16[k+4]=y,this.uint16[k+5]=v,this.uint16[k+6]=w,this.uint16[k+7]=A,this.uint16[k+8]=D,this.uint16[k+9]=R,t}}Qe.prototype.bytesPerElement=20,jt(Qe,"StructArrayLayout10ui20");class at extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w){const A=this.length;return this.resize(A+1),this.emplace(A,t,o,c,d,m,y,v,w)}emplace(t,o,c,d,m,y,v,w,A){const D=8*t;return this.uint16[D+0]=o,this.uint16[D+1]=c,this.uint16[D+2]=d,this.uint16[D+3]=m,this.uint16[D+4]=y,this.uint16[D+5]=v,this.uint16[D+6]=w,this.uint16[D+7]=A,t}}at.prototype.bytesPerElement=16,jt(at,"StructArrayLayout8ui16");class dt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y){const v=this.length;return this.resize(v+1),this.emplace(v,t,o,c,d,m,y)}emplace(t,o,c,d,m,y,v){const w=6*t;return this.int16[w+0]=o,this.int16[w+1]=c,this.int16[w+2]=d,this.int16[w+3]=m,this.int16[w+4]=y,this.int16[w+5]=v,t}}dt.prototype.bytesPerElement=12,jt(dt,"StructArrayLayout6i12");class ut extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne){const me=this.length;return this.resize(me+1),this.emplace(me,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me){const ke=16*t;return this.int16[ke+0]=o,this.int16[ke+1]=c,this.int16[ke+2]=d,this.int16[ke+3]=m,this.uint16[ke+4]=y,this.uint16[ke+5]=v,this.uint16[ke+6]=w,this.uint16[ke+7]=A,this.int16[ke+8]=D,this.int16[ke+9]=R,this.int16[ke+10]=k,this.int16[ke+11]=V,this.int16[ke+12]=j,this.int16[ke+13]=$,this.int16[ke+14]=ne,this.int16[ke+15]=me,t}}ut.prototype.bytesPerElement=32,jt(ut,"StructArrayLayout4i4ui4i4i32");class Rt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,t,o,c)}emplace(t,o,c,d){const m=3*t;return this.float32[m+0]=o,this.float32[m+1]=c,this.float32[m+2]=d,t}}Rt.prototype.bytesPerElement=12,jt(Rt,"StructArrayLayout3f12");class et extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const o=this.length;return this.resize(o+1),this.emplace(o,t)}emplace(t,o){return this.uint32[1*t+0]=o,t}}et.prototype.bytesPerElement=4,jt(et,"StructArrayLayout1ul4");class zt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D,R,k,V){const j=this.length;return this.resize(j+1),this.emplace(j,t,o,c,d,m,y,v,w,A,D,R,k,V)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j){const $=20*t,ne=10*t;return this.int16[$+0]=o,this.int16[$+1]=c,this.int16[$+2]=d,this.int16[$+3]=m,this.int16[$+4]=y,this.float32[ne+3]=v,this.float32[ne+4]=w,this.float32[ne+5]=A,this.float32[ne+6]=D,this.int16[$+14]=R,this.uint32[ne+8]=k,this.uint16[$+18]=V,this.uint16[$+19]=j,t}}zt.prototype.bytesPerElement=40,jt(zt,"StructArrayLayout5i4f1i1ul2ui40");class Pt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=8*t;return this.int16[A+0]=o,this.int16[A+1]=c,this.int16[A+2]=d,this.int16[A+4]=m,this.int16[A+5]=y,this.int16[A+6]=v,this.int16[A+7]=w,t}}Pt.prototype.bytesPerElement=16,jt(Pt,"StructArrayLayout3i2i2i16");class Jt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,o,c,d,m)}emplace(t,o,c,d,m,y){const v=4*t,w=8*t;return this.float32[v+0]=o,this.float32[v+1]=c,this.float32[v+2]=d,this.int16[w+6]=m,this.int16[w+7]=y,t}}Jt.prototype.bytesPerElement=16,jt(Jt,"StructArrayLayout2f1f2i16");class pt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=12*t,v=3*t;return this.uint8[y+0]=o,this.uint8[y+1]=c,this.float32[v+1]=d,this.float32[v+2]=m,t}}pt.prototype.bytesPerElement=12,jt(pt,"StructArrayLayout2ub2f12");class qt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,t,o,c)}emplace(t,o,c,d){const m=3*t;return this.uint16[m+0]=o,this.uint16[m+1]=c,this.uint16[m+2]=d,t}}qt.prototype.bytesPerElement=6,jt(qt,"StructArrayLayout3ui6");class mn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe){const Ye=this.length;return this.resize(Ye+1),this.emplace(Ye,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye){const lt=30*t,ht=15*t,vt=60*t;return this.int16[lt+0]=o,this.int16[lt+1]=c,this.int16[lt+2]=d,this.float32[ht+2]=m,this.float32[ht+3]=y,this.uint16[lt+8]=v,this.uint16[lt+9]=w,this.uint32[ht+5]=A,this.uint32[ht+6]=D,this.uint32[ht+7]=R,this.uint16[lt+16]=k,this.uint16[lt+17]=V,this.uint16[lt+18]=j,this.float32[ht+10]=$,this.float32[ht+11]=ne,this.uint8[vt+48]=me,this.uint8[vt+49]=ke,this.uint8[vt+50]=He,this.uint32[ht+13]=Ze,this.int16[lt+28]=Xe,this.uint8[vt+58]=Ye,t}}mn.prototype.bytesPerElement=60,jt(mn,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Xt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt){const It=this.length;return this.resize(It+1),this.emplace(It,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt)}emplace(t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne,me,ke,He,Ze,Xe,Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt,It){const kt=38*t,En=19*t;return this.int16[kt+0]=o,this.int16[kt+1]=c,this.int16[kt+2]=d,this.float32[En+2]=m,this.float32[En+3]=y,this.int16[kt+8]=v,this.int16[kt+9]=w,this.int16[kt+10]=A,this.int16[kt+11]=D,this.int16[kt+12]=R,this.int16[kt+13]=k,this.uint16[kt+14]=V,this.uint16[kt+15]=j,this.uint16[kt+16]=$,this.uint16[kt+17]=ne,this.uint16[kt+18]=me,this.uint16[kt+19]=ke,this.uint16[kt+20]=He,this.uint16[kt+21]=Ze,this.uint16[kt+22]=Xe,this.uint16[kt+23]=Ye,this.uint16[kt+24]=lt,this.uint16[kt+25]=ht,this.uint16[kt+26]=vt,this.uint16[kt+27]=Tt,this.uint16[kt+28]=rt,this.uint32[En+15]=ft,this.float32[En+16]=Ct,this.float32[En+17]=Bt,this.float32[En+18]=It,t}}Xt.prototype.bytesPerElement=76,jt(Xt,"StructArrayLayout3i2f6i15ui1ul3f76");class Yt extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const o=this.length;return this.resize(o+1),this.emplace(o,t)}emplace(t,o){return this.float32[1*t+0]=o,t}}Yt.prototype.bytesPerElement=4,jt(Yt,"StructArrayLayout1f4");class vn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=7*t;return this.float32[A+0]=o,this.float32[A+1]=c,this.float32[A+2]=d,this.float32[A+3]=m,this.float32[A+4]=y,this.float32[A+5]=v,this.float32[A+6]=w,t}}vn.prototype.bytesPerElement=28,jt(vn,"StructArrayLayout7f28");class kn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,o,c,d,m)}emplace(t,o,c,d,m,y){const v=5*t;return this.float32[v+0]=o,this.float32[v+1]=c,this.float32[v+2]=d,this.float32[v+3]=m,this.float32[v+4]=y,t}}kn.prototype.bytesPerElement=20,jt(kn,"StructArrayLayout5f20");class hn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o,c,d){const m=this.length;return this.resize(m+1),this.emplace(m,t,o,c,d)}emplace(t,o,c,d,m){const y=6*t;return this.uint32[3*t+0]=o,this.uint16[y+2]=c,this.uint16[y+3]=d,this.uint16[y+4]=m,t}}hn.prototype.bytesPerElement=12,jt(hn,"StructArrayLayout1ul3ui12");class Mn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,o){const c=this.length;return this.resize(c+1),this.emplace(c,t,o)}emplace(t,o,c){const d=2*t;return this.uint16[d+0]=o,this.uint16[d+1]=c,t}}Mn.prototype.bytesPerElement=4,jt(Mn,"StructArrayLayout2ui4");class qn extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const o=this.length;return this.resize(o+1),this.emplace(o,t)}emplace(t,o){return this.uint16[1*t+0]=o,t}}qn.prototype.bytesPerElement=2,jt(qn,"StructArrayLayout1ui2");class vi extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o){const c=this.length;return this.resize(c+1),this.emplace(c,t,o)}emplace(t,o,c){const d=2*t;return this.float32[d+0]=o,this.float32[d+1]=c,t}}vi.prototype.bytesPerElement=8,jt(vi,"StructArrayLayout2f8");class nr extends X{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,o,c,d,m,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,o,c,d,m,y,v)}emplace(t,o,c,d,m,y,v,w){const A=8*t,D=4*t;return this.int16[A+0]=o,this.int16[A+1]=c,this.int16[A+2]=d,this.int16[A+3]=m,this.int16[A+4]=y,this.int16[A+5]=v,this.float32[D+3]=w,t}}nr.prototype.bytesPerElement=16,jt(nr,"StructArrayLayout6i1f16");class ir extends Q{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}ir.prototype.size=12;class Rr extends dt{get(t){return new ir(this,t)}}jt(Rr,"FillExtrusionExtArray");class ma extends Q{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}ma.prototype.size=40;class Ua extends zt{get(t){return new ma(this,t)}}jt(Ua,"CollisionBoxArray");class po extends Q{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}po.prototype.size=60;class Va extends mn{get(t){return new po(this,t)}}jt(Va,"PlacedSymbolArray");class bi extends Q{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}bi.prototype.size=76;class Ti extends Xt{get(t){return new bi(this,t)}}jt(Ti,"SymbolInstanceArray");class $n extends Yt{getoffsetX(t){return this.float32[1*t+0]}}jt($n,"GlyphOffsetArray");class Li extends Se{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}jt(Li,"SymbolLineVertexArray");class zr extends Q{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}zr.prototype.size=12;class xi extends hn{get(t){return new zr(this,t)}}jt(xi,"FeatureIndexArray");class Zr extends Q{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Zr.prototype.size=4;class Gl extends Mn{get(t){return new Zr(this,t)}}jt(Gl,"FillExtrusionCentroidArray");class kr extends Q{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}get a_scale(){return this._structArray.float32[this._pos4+3]}}kr.prototype.size=16;class jo extends nr{get(t){return new kr(this,t)}}jt(jo,"CircleGlobeExtArray");const lg=Ae([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),ap=Ae([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Rs=ru(function(a){a.exports=function(t,o){var c,d,m,y,v,w,A,D;for(d=t.length-(c=3&t.length),m=o,v=3432918353,w=461845907,D=0;D<d;)A=255&t.charCodeAt(D)|(255&t.charCodeAt(++D))<<8|(255&t.charCodeAt(++D))<<16|(255&t.charCodeAt(++D))<<24,++D,m=27492+(65535&(y=5*(65535&(m=(m^=A=(65535&(A=(A=(65535&A)*v+(((A>>>16)*v&65535)<<16)&4294967295)<<15|A>>>17))*w+(((A>>>16)*w&65535)<<16)&4294967295)<<13|m>>>19))+((5*(m>>>16)&65535)<<16)&4294967295))+((58964+(y>>>16)&65535)<<16);switch(A=0,c){case 3:A^=(255&t.charCodeAt(D+2))<<16;case 2:A^=(255&t.charCodeAt(D+1))<<8;case 1:m^=A=(65535&(A=(A=(65535&(A^=255&t.charCodeAt(D)))*v+(((A>>>16)*v&65535)<<16)&4294967295)<<15|A>>>17))*w+(((A>>>16)*w&65535)<<16)&4294967295}return m^=t.length,m=2246822507*(65535&(m^=m>>>16))+((2246822507*(m>>>16)&65535)<<16)&4294967295,m=3266489909*(65535&(m^=m>>>13))+((3266489909*(m>>>16)&65535)<<16)&4294967295,(m^=m>>>16)>>>0}}),Xy=ru(function(a){a.exports=function(t,o){for(var c,d=t.length,m=o^d,y=0;d>=4;)c=1540483477*(65535&(c=255&t.charCodeAt(y)|(255&t.charCodeAt(++y))<<8|(255&t.charCodeAt(++y))<<16|(255&t.charCodeAt(++y))<<24))+((1540483477*(c>>>16)&65535)<<16),m=1540483477*(65535&m)+((1540483477*(m>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),d-=4,++y;switch(d){case 3:m^=(255&t.charCodeAt(y+2))<<16;case 2:m^=(255&t.charCodeAt(y+1))<<8;case 1:m=1540483477*(65535&(m^=255&t.charCodeAt(y)))+((1540483477*(m>>>16)&65535)<<16)}return m=1540483477*(65535&(m^=m>>>13))+((1540483477*(m>>>16)&65535)<<16),(m^=m>>>15)>>>0}}),fo=Rs,op=Xy;fo.murmur3=Rs,fo.murmur2=op;class cg{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,o,c,d){this.ids.push(Y1(t)),this.positions.push(o,c,d)}getPositions(t){const o=Y1(t);let c=0,d=this.ids.length-1;for(;c<d;){const y=c+d>>1;this.ids[y]>=o?d=y:c=y+1}const m=[];for(;this.ids[c]===o;)m.push({index:this.positions[3*c],start:this.positions[3*c+1],end:this.positions[3*c+2]}),c++;return m}static serialize(t,o){const c=new Float64Array(t.ids),d=new Uint32Array(t.positions);return Yy(c,d,0,c.length-1),o&&o.push(c.buffer,d.buffer),{ids:c,positions:d}}static deserialize(t){const o=new cg;return o.ids=t.ids,o.positions=t.positions,o.indexed=!0,o}}function Y1(a){const t=+a;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:fo(String(a))}function Yy(a,t,o,c){for(;o<c;){const d=a[o+c>>1];let m=o-1,y=c+1;for(;;){do m++;while(a[m]<d);do y--;while(a[y]>d);if(m>=y)break;ug(a,m,y),ug(t,3*m,3*y),ug(t,3*m+1,3*y+1),ug(t,3*m+2,3*y+2)}y-o<c-y?(Yy(a,t,o,y),o=y+1):(Yy(a,t,y+1,c),c=y)}}function ug(a,t,o){const c=a[t];a[t]=a[o],a[o]=c}jt(cg,"FeaturePositionMap");class qo{constructor(t,o){this.gl=t.gl,this.location=o}}class hg extends qo{constructor(t,o){super(t,o),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class $1 extends qo{constructor(t,o){super(t,o),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class J1 extends qo{constructor(t,o){super(t,o),this.current=Xn.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const zL=new Float32Array(16),kL=new Float32Array(9),BL=new Float32Array(4);function $y(a){return[J(255*a.r,255*a.g),J(255*a.b,255*a.a)]}class sp{constructor(t,o,c){this.value=t,this.uniformNames=o.map(d=>`u_${d}`),this.type=c}setUniform(t,o,c){t.set(c.constantOr(this.value))}getBinding(t,o,c){return this.type==="color"?new J1(t,o):new hg(t,o)}}class Bu{constructor(t,o){this.uniformNames=o.map(c=>`u_${c}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,o){this.pixelRatioFrom=o.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=o.tl.concat(o.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,o,c,d){const m=d==="u_pattern_to"||d==="u_dash_to"?this.patternTo:d==="u_pattern_from"||d==="u_dash_from"?this.patternFrom:d==="u_pixel_ratio_to"?this.pixelRatioTo:d==="u_pixel_ratio_from"?this.pixelRatioFrom:null;m&&t.set(m)}getBinding(t,o,c){return c==="u_pattern_from"||c==="u_pattern_to"||c==="u_dash_from"||c==="u_dash_to"?new $1(t,o):new hg(t,o)}}class Zo{constructor(t,o,c,d){this.expression=t,this.type=c,this.maxValue=0,this.paintVertexAttributes=o.map(m=>({name:`a_${m}`,type:"Float32",components:c==="color"?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(t,o,c,d,m,y){const v=this.paintVertexArray.length,w=this.expression.evaluate(new ci(0),o,{},m,d,y);this.paintVertexArray.resize(t),this._setPaintValue(v,t,w)}updatePaintArray(t,o,c,d,m){const y=this.expression.evaluate({zoom:0},c,d,void 0,m);this._setPaintValue(t,o,y)}_setPaintValue(t,o,c){if(this.type==="color"){const d=$y(c);for(let m=t;m<o;m++)this.paintVertexArray.emplace(m,d[0],d[1])}else{for(let d=t;d<o;d++)this.paintVertexArray.emplace(d,c);this.maxValue=Math.max(this.maxValue,Math.abs(c))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Ga{constructor(t,o,c,d,m,y){this.expression=t,this.uniformNames=o.map(v=>`u_${v}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=m,this.maxValue=0,this.paintVertexAttributes=o.map(v=>({name:`a_${v}`,type:"Float32",components:c==="color"?4:2,offset:0})),this.paintVertexArray=new y}populatePaintArray(t,o,c,d,m,y){const v=this.expression.evaluate(new ci(this.zoom),o,{},m,d,y),w=this.expression.evaluate(new ci(this.zoom+1),o,{},m,d,y),A=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(A,t,v,w)}updatePaintArray(t,o,c,d,m){const y=this.expression.evaluate({zoom:this.zoom},c,d,void 0,m),v=this.expression.evaluate({zoom:this.zoom+1},c,d,void 0,m);this._setPaintValue(t,o,y,v)}_setPaintValue(t,o,c,d){if(this.type==="color"){const m=$y(c),y=$y(d);for(let v=t;v<o;v++)this.paintVertexArray.emplace(v,m[0],m[1],y[0],y[1])}else{for(let m=t;m<o;m++)this.paintVertexArray.emplace(m,c,d);this.maxValue=Math.max(this.maxValue,Math.abs(c),Math.abs(d))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,o){const c=this.useIntegerZoom?Math.floor(o.zoom):o.zoom,d=ie(this.expression.interpolationFactor(c,this.zoom,this.zoom+1),0,1);t.set(d)}getBinding(t,o,c){return new hg(t,o)}}class zs{constructor(t,o,c,d,m,y,v){this.expression=t,this.type=c,this.useIntegerZoom=d,this.zoom=m,this.layerId=v,this.paintVertexAttributes=(c==="array"?ap:lg).members;for(let w=0;w<o.length;++w);this.zoomInPaintVertexArray=new y,this.zoomOutPaintVertexArray=new y}populatePaintArray(t,o,c){const d=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(d,t,o.patterns&&o.patterns[this.layerId],c)}updatePaintArray(t,o,c,d,m,y){this._setPaintValues(t,o,c.patterns&&c.patterns[this.layerId],y)}_setPaintValues(t,o,c,d){if(!d||!c)return;const{min:m,mid:y,max:v}=c,w=d[m],A=d[y],D=d[v];if(w&&A&&D)for(let R=t;R<o;R++)this._setPaintValue(this.zoomInPaintVertexArray,R,A,w),this._setPaintValue(this.zoomOutPaintVertexArray,R,A,D)}_setPaintValue(t,o,c,d){t.emplace(o,c.tl[0],c.tl[1],c.br[0],c.br[1],d.tl[0],d.tl[1],d.br[0],d.br[1],c.pixelRatio,d.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ks{constructor(t,o,c=()=>!0){this.binders={},this._buffers=[];const d=[];for(const m in t.paint._values){if(!c(m))continue;const y=t.paint.get(m);if(!(y instanceof x&&Es(y.property.specification)))continue;const v=OL(m,t.type),w=y.value,A=y.property.specification.type,D=y.property.useIntegerZoom,R=y.property.specification["property-type"],k=R==="cross-faded"||R==="cross-faded-data-driven",V=String(m)==="line-dasharray"&&t.layout.get("line-cap").value.kind!=="constant";if(w.kind!=="constant"||V)if(w.kind==="source"||V||k){const j=K1(m,A,"source");this.binders[m]=k?new zs(w,v,A,D,o,j,t.id):new Zo(w,v,A,j),d.push(`/a_${m}`)}else{const j=K1(m,A,"composite");this.binders[m]=new Ga(w,v,A,D,o,j),d.push(`/z_${m}`)}else this.binders[m]=k?new Bu(w.value,v):new sp(w.value,v,A),d.push(`/u_${m}`)}this.cacheKey=d.sort().join("")}getMaxValue(t){const o=this.binders[t];return o instanceof Zo||o instanceof Ga?o.maxValue:0}populatePaintArrays(t,o,c,d,m,y){for(const v in this.binders){const w=this.binders[v];(w instanceof Zo||w instanceof Ga||w instanceof zs)&&w.populatePaintArray(t,o,c,d,m,y)}}setConstantPatternPositions(t,o){for(const c in this.binders){const d=this.binders[c];d instanceof Bu&&d.setConstantPatternPositions(t,o)}}updatePaintArrays(t,o,c,d,m,y){let v=!1;for(const w in t){const A=o.getPositions(w);for(const D of A){const R=c.feature(D.index);for(const k in this.binders){const V=this.binders[k];if((V instanceof Zo||V instanceof Ga||V instanceof zs)&&V.expression.isStateDependent===!0){const j=d.paint.get(k);V.expression=j.value,V.updatePaintArray(D.start,D.end,R,t[w],m,y),v=!0}}}}return v}defines(){const t=[];for(const o in this.binders){const c=this.binders[o];(c instanceof sp||c instanceof Bu)&&t.push(...c.uniformNames.map(d=>`#define HAS_UNIFORM_${d}`))}return t}getBinderAttributes(){const t=[];for(const o in this.binders){const c=this.binders[o];if(c instanceof Zo||c instanceof Ga||c instanceof zs)for(let d=0;d<c.paintVertexAttributes.length;d++)t.push(c.paintVertexAttributes[d].name)}return t}getBinderUniforms(){const t=[];for(const o in this.binders){const c=this.binders[o];if(c instanceof sp||c instanceof Bu||c instanceof Ga)for(const d of c.uniformNames)t.push(d)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,o){const c=[];for(const d in this.binders){const m=this.binders[d];if(m instanceof sp||m instanceof Bu||m instanceof Ga){for(const y of m.uniformNames)if(o[y]){const v=m.getBinding(t,o[y],y);c.push({name:y,property:d,binding:v})}}}return c}setUniforms(t,o,c,d){for(const{name:m,property:y,binding:v}of o)this.binders[y].setUniform(v,d,c.get(y),m)}updatePaintBuffers(t){this._buffers=[];for(const o in this.binders){const c=this.binders[o];if(t&&c instanceof zs){const d=t.fromScale===2?c.zoomInPaintVertexBuffer:c.zoomOutPaintVertexBuffer;d&&this._buffers.push(d)}else(c instanceof Zo||c instanceof Ga)&&c.paintVertexBuffer&&this._buffers.push(c.paintVertexBuffer)}}upload(t){for(const o in this.binders){const c=this.binders[o];(c instanceof Zo||c instanceof Ga||c instanceof zs)&&c.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const o=this.binders[t];(o instanceof Zo||o instanceof Ga||o instanceof zs)&&o.destroy()}}}class Hl{constructor(t,o,c=()=>!0){this.programConfigurations={};for(const d of t)this.programConfigurations[d.id]=new ks(d,o,c);this.needsUpload=!1,this._featureMap=new cg,this._bufferOffset=0}populatePaintArrays(t,o,c,d,m,y,v){for(const w in this.programConfigurations)this.programConfigurations[w].populatePaintArrays(t,o,d,m,y,v);o.id!==void 0&&this._featureMap.add(o.id,c,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,o,c,d,m){for(const y of c)this.needsUpload=this.programConfigurations[y.id].updatePaintArrays(t,this._featureMap,o,y,d,m)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const o in this.programConfigurations)this.programConfigurations[o].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const FL={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function OL(a,t){return FL[a]||[a.replace(`${t}-`,"").replace(/-/g,"_")]}const NL={"line-pattern":{source:Qe,composite:Qe},"fill-pattern":{source:Qe,composite:Qe},"fill-extrusion-pattern":{source:Qe,composite:Qe},"line-dasharray":{source:at,composite:at}},UL={color:{source:vi,composite:Fe},number:{source:Yt,composite:vi}};function K1(a,t,o){const c=NL[a];return c&&c[o]||UL[t][o]}jt(sp,"ConstantBinder"),jt(Bu,"CrossFadedConstantBinder"),jt(Zo,"SourceExpressionBinder"),jt(zs,"CrossFadedCompositeBinder"),jt(Ga,"CompositeExpressionBinder"),jt(ks,"ProgramConfiguration",{omit:["_buffers"]}),jt(Hl,"ProgramConfigurationSet");const dg="-transition";class Ha extends ze{constructor(t,o){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,t.type!=="custom"&&(this.metadata=(t=t).metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&t.type!=="sky"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),o.layout&&(this._unevaluatedLayout=new g(o.layout)),o.paint)){this._transitionablePaint=new f(o.paint);for(const c in t.paint)this.setPaintProperty(c,t.paint[c],{validate:!1});for(const c in t.layout)this.setLayoutProperty(c,t.layout[c],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new b(o.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,o,c={}){o!=null&&this._validate(jy,`layers.${this.id}.layout.${t}`,t,o,c)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,o):this.visibility=o)}getPaintProperty(t){return gt(t,dg)?this._transitionablePaint.getTransition(t.slice(0,-dg.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,o,c={}){if(o!=null&&this._validate(Wy,`layers.${this.id}.paint.${t}`,t,o,c))return!1;if(gt(t,dg))return this._transitionablePaint.setTransition(t.slice(0,-dg.length),o||void 0),!1;{const d=this._transitionablePaint._values[t],m=d.property.specification["property-type"]==="cross-faded-data-driven",y=d.value.isDataDriven(),v=d.value;this._transitionablePaint.setValue(t,o),this._handleSpecialPaintPropertyUpdate(t);const w=this._transitionablePaint._values[t].value;return w.isDataDriven()||y||m||this._handleOverridablePaintPropertyUpdate(t,v,w)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,o,c){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,o){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,o)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,o)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Dt(t,(o,c)=>!(o===void 0||c==="layout"&&!Object.keys(o).length||c==="paint"&&!Object.keys(o).length))}_validate(t,o,c,d,m={}){return(!m||m.validate!==!1)&&jm(this,t.call(zl,{key:o,layerType:this.type,objectKey:c,value:d,styleSpec:xe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const o=this.paint.get(t);if(o instanceof x&&Es(o.property.specification)&&(o.value.kind==="source"||o.value.kind==="composite")&&o.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=lo(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const VL=Ae([{name:"a_pos",components:2,type:"Int16"}],4),GL=Ae([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"},{name:"a_scale",components:1,type:"Float32"}]);class Ei{constructor(t=[]){this.segments=t}prepareSegment(t,o,c,d){let m=this.segments[this.segments.length-1];return t>Ei.MAX_VERTEX_ARRAY_LENGTH&&ge(`Max vertices per segment is ${Ei.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!m||m.vertexLength+t>Ei.MAX_VERTEX_ARRAY_LENGTH||m.sortKey!==d)&&(m={vertexOffset:o.length,primitiveOffset:c.length,vertexLength:0,primitiveLength:0},d!==void 0&&(m.sortKey=d),this.segments.push(m)),m}get(){return this.segments}destroy(){for(const t of this.segments)for(const o in t.vaos)t.vaos[o].destroy()}static simpleSegment(t,o,c,d){return new Ei([{vertexOffset:t,primitiveOffset:o,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0}])}}Ei.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,jt(Ei,"SegmentVector");var In=8192;class Bs{constructor(t,o){t&&(o?this.setSouthWest(t).setNorthEast(o):t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof ti?new ti(t.lng,t.lat):ti.convert(t),this}setSouthWest(t){return this._sw=t instanceof ti?new ti(t.lng,t.lat):ti.convert(t),this}extend(t){const o=this._sw,c=this._ne;let d,m;if(t instanceof ti)d=t,m=t;else{if(!(t instanceof Bs))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Bs.convert(t)):this.extend(ti.convert(t)):this;if(d=t._sw,m=t._ne,!d||!m)return this}return o||c?(o.lng=Math.min(d.lng,o.lng),o.lat=Math.min(d.lat,o.lat),c.lng=Math.max(m.lng,c.lng),c.lat=Math.max(m.lat,c.lat)):(this._sw=new ti(d.lng,d.lat),this._ne=new ti(m.lng,m.lat)),this}getCenter(){return new ti((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new ti(this.getWest(),this.getNorth())}getSouthEast(){return new ti(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:o,lat:c}=ti.convert(t);let d=this._sw.lng<=o&&o<=this._ne.lng;return this._sw.lng>this._ne.lng&&(d=this._sw.lng>=o&&o>=this._ne.lng),this._sw.lat<=c&&c<=this._ne.lat&&d}static convert(t){return!t||t instanceof Bs?t:new Bs(t)}}const Jy=63710088e-1;class ti{constructor(t,o){if(isNaN(t)||isNaN(o))throw new Error(`Invalid LngLat object: (${t}, ${o})`);if(this.lng=+t,this.lat=+o,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ti(ae(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const o=Math.PI/180,c=this.lat*o,d=t.lat*o,m=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((t.lng-this.lng)*o);return Jy*Math.acos(Math.min(m,1))}toBounds(t=0){const o=360*t/40075017,c=o/Math.cos(Math.PI/180*this.lat);return new Bs(new ti(this.lng-c,this.lat-o),new ti(this.lng+c,this.lat+o))}static convert(t){if(t instanceof ti)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new ti(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new ti(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Q1=2*Math.PI*Jy;function Ky(a){return Q1*Math.cos(a*Math.PI/180)}function lp(a){return(180+a)/360}function Fu(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function Ou(a,t){return a/Ky(t)}function Ta(a){return 360*a-180}function rr(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function eb(a,t){return a*Ky(rr(t))}const mo=85.051129;class pg{constructor(t,o,c=0){this.x=+t,this.y=+o,this.z=+c}static fromLngLat(t,o=0){const c=ti.convert(t);return new pg(lp(c.lng),Fu(c.lat),Ou(o,c.lat))}toLngLat(){return new ti(Ta(this.x),rr(this.y))}toAltitude(){return eb(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Q1*(t=rr(this.y),1/Math.cos(t*Math.PI/180));var t}}function Qy(a,t,o,c,d,m,y,v,w){const A=(t+c)/2,D=(o+d)/2,R=new E(A,D);v(R),function(k,V,j,$,ne,me){const ke=j-ne,He=$-me;return Math.abs(($-V)*ke-(j-k)*He)/Math.hypot(ke,He)}(R.x,R.y,m.x,m.y,y.x,y.y)>=w?(Qy(a,t,o,A,D,m,R,v,w),Qy(a,A,D,c,d,R,y,v,w)):a.push(y)}function HL(a,t,o){let c=a[0],d=c.x,m=c.y;t(c);const y=[c];for(let v=1;v<a.length;v++){const w=a[v],{x:A,y:D}=w;t(w),Qy(y,d,m,A,D,c,w,t,o),d=A,m=D,c=w}return y}const ev=Math.pow(2,14)-1,tb=-ev-1;function WL(a,t){const o=Math.round(a.x*t),c=Math.round(a.y*t);return a.x=ie(o,tb,ev),a.y=ie(c,tb,ev),(o<a.x||o>a.x+1||c<a.y||c>a.y+1)&&ge("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function Xo(a,t,o){const c=a.loadGeometry(),d=a.extent,m=In/d;if(t&&o&&o.projection.isReprojectedInTileSpace){const y=1<<t.z,{scale:v,x:w,y:A,projection:D}=o,R=k=>{const V=Ta((t.x+k.x/d)/y),j=rr((t.y+k.y/d)/y),$=D.project(V,j);k.x=($.x*v-w)*d,k.y=($.y*v-A)*d};for(let k=0;k<c.length;k++)if(a.type!==1)c[k]=HL(c[k],R,1);else{const V=[];for(const j of c[k])j.x<0||j.x>=d||j.y<0||j.y>=d||(R(j),V.push(j));c[k]=V}}for(const y of c)for(const v of y)WL(v,m);return c}function Wl(a,t){return{type:a.type,id:a.id,properties:a.properties,geometry:t?Xo(a):[]}}function fg(a,t,o,c,d){a.emplaceBack(2*t+(c+1)/2,2*o+(d+1)/2)}function mg(a,t,o,c){a.emplaceBack(t.x,t.y,t.z,o[0]*16384,o[1]*16384,o[2]*16384,c)}class tv{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Te,this.indexArray=new qt,this.segments=new Ei,this.programConfigurations=new Hl(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(t,o,c,d){const m=this.layers[0],y=[];let v=null;m.type==="circle"&&(v=m.layout.get("circle-sort-key"));for(const{feature:A,id:D,index:R,sourceLayerIndex:k}of t){const V=this.layers[0]._featureFilter.needGeometry,j=Wl(A,V);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),j,c))continue;const $=v?v.evaluate(j,{},c):void 0,ne={id:D,properties:A.properties,type:A.type,sourceLayerIndex:k,index:R,geometry:V?j.geometry:Xo(A,c,d),patterns:{},sortKey:$};y.push(ne)}v&&y.sort((A,D)=>A.sortKey-D.sortKey);let w=null;d.projection.name==="globe"&&(this.globeExtVertexArray=new jo,w=d.projection);for(const A of y){const{geometry:D,index:R,sourceLayerIndex:k}=A,V=t[R].feature;this.addFeature(A,D,R,o.availableImages,c,w),o.featureIndex.insert(V,D,R,k,this.index)}}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,VL.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,GL.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,o,c,d,m,y){for(const v of o)for(const w of v){const A=w.x,D=w.y;if(A<0||A>=In||D<0||D>=In)continue;if(y){const V=y.projectTilePoint(A,D,m),j=y.upVector(m,A,D),$=rr((D/In+m.y)/(1<<m.z)),ne=y.pixelsPerMeter($,1)/Ou(1,$),me=this.globeExtVertexArray;mg(me,V,j,ne),mg(me,V,j,ne),mg(me,V,j,ne),mg(me,V,j,ne)}const R=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),k=R.vertexLength;fg(this.layoutVertexArray,A,D,-1,-1),fg(this.layoutVertexArray,A,D,1,-1),fg(this.layoutVertexArray,A,D,1,1),fg(this.layoutVertexArray,A,D,-1,1),this.indexArray.emplaceBack(k,k+1,k+2),this.indexArray.emplaceBack(k,k+3,k+2),R.vertexLength+=4,R.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,{},d,m)}}function nb(a,t){for(let o=0;o<a.length;o++)if(Nu(t,a[o]))return!0;for(let o=0;o<t.length;o++)if(Nu(a,t[o]))return!0;return!!nv(a,t)}function jL(a,t,o){return!!Nu(a,t)||!!iv(t,a,o)}function ib(a,t){if(a.length===1)return ab(t,a[0]);for(let o=0;o<t.length;o++){const c=t[o];for(let d=0;d<c.length;d++)if(Nu(a,c[d]))return!0}for(let o=0;o<a.length;o++)if(ab(t,a[o]))return!0;for(let o=0;o<t.length;o++)if(nv(a,t[o]))return!0;return!1}function qL(a,t,o){if(a.length>1){if(nv(a,t))return!0;for(let c=0;c<t.length;c++)if(iv(t[c],a,o))return!0}for(let c=0;c<a.length;c++)if(iv(a[c],t,o))return!0;return!1}function nv(a,t){if(a.length===0||t.length===0)return!1;for(let o=0;o<a.length-1;o++){const c=a[o],d=a[o+1];for(let m=0;m<t.length-1;m++)if(ZL(c,d,t[m],t[m+1]))return!0}return!1}function ZL(a,t,o,c){return Ve(a,o,c)!==Ve(t,o,c)&&Ve(a,t,o)!==Ve(a,t,c)}function iv(a,t,o){const c=o*o;if(t.length===1)return a.distSqr(t[0])<c;for(let d=1;d<t.length;d++)if(rb(a,t[d-1],t[d])<c)return!0;return!1}function rb(a,t,o){const c=t.distSqr(o);if(c===0)return a.distSqr(t);const d=((a.x-t.x)*(o.x-t.x)+(a.y-t.y)*(o.y-t.y))/c;return a.distSqr(d<0?t:d>1?o:o.sub(t)._mult(d)._add(t))}function ab(a,t){let o,c,d,m=!1;for(let y=0;y<a.length;y++){o=a[y];for(let v=0,w=o.length-1;v<o.length;w=v++)c=o[v],d=o[w],c.y>t.y!=d.y>t.y&&t.x<(d.x-c.x)*(t.y-c.y)/(d.y-c.y)+c.x&&(m=!m)}return m}function Nu(a,t){let o=!1;for(let c=0,d=a.length-1;c<a.length;d=c++){const m=a[c],y=a[d];m.y>t.y!=y.y>t.y&&t.x<(y.x-m.x)*(t.y-m.y)/(y.y-m.y)+m.x&&(o=!o)}return o}function ob(a,t,o,c,d){for(const y of a)if(t<=y.x&&o<=y.y&&c>=y.x&&d>=y.y)return!0;const m=[new E(t,o),new E(t,d),new E(c,d),new E(c,o)];if(a.length>2){for(const y of m)if(Nu(a,y))return!0}for(let y=0;y<a.length-1;y++)if(XL(a[y],a[y+1],m))return!0;return!1}function XL(a,t,o){const c=o[0],d=o[2];if(a.x<c.x&&t.x<c.x||a.x>d.x&&t.x>d.x||a.y<c.y&&t.y<c.y||a.y>d.y&&t.y>d.y)return!1;const m=Ve(a,t,o[0]);return m!==Ve(a,t,o[1])||m!==Ve(a,t,o[2])||m!==Ve(a,t,o[3])}function Uu(a,t,o){const c=t.paint.get(a).value;return c.kind==="constant"?c.value:o.programConfigurations.get(t.id).getMaxValue(a)}function gg(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function sb(a,t,o,c,d){if(!t[0]&&!t[1])return a;const m=E.convert(t)._mult(d);o==="viewport"&&m._rotate(-c);const y=[];for(let v=0;v<a.length;v++)y.push(a[v].sub(m));return y}function lb(a,t,o,c){const d=E.convert(a)._mult(c);return t==="viewport"&&d._rotate(-o),d}jt(tv,"CircleBucket",{omit:["layers"]});const YL=new H({"circle-sort-key":new P(xe.layout_circle["circle-sort-key"])});var $L={paint:new H({"circle-radius":new P(xe.paint_circle["circle-radius"]),"circle-color":new P(xe.paint_circle["circle-color"]),"circle-blur":new P(xe.paint_circle["circle-blur"]),"circle-opacity":new P(xe.paint_circle["circle-opacity"]),"circle-translate":new S(xe.paint_circle["circle-translate"]),"circle-translate-anchor":new S(xe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new S(xe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new S(xe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new P(xe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new P(xe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new P(xe.paint_circle["circle-stroke-opacity"])}),layout:YL},rv=1e-6,Xr=typeof Float32Array!="undefined"?Float32Array:Array;function cb(){var a=new Xr(9);return Xr!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function go(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function av(a,t,o){var c=t[0],d=t[1],m=t[2],y=t[3],v=t[4],w=t[5],A=t[6],D=t[7],R=t[8],k=t[9],V=t[10],j=t[11],$=t[12],ne=t[13],me=t[14],ke=t[15],He=o[0],Ze=o[1],Xe=o[2],Ye=o[3];return a[0]=He*c+Ze*v+Xe*R+Ye*$,a[1]=He*d+Ze*w+Xe*k+Ye*ne,a[2]=He*m+Ze*A+Xe*V+Ye*me,a[3]=He*y+Ze*D+Xe*j+Ye*ke,a[4]=(He=o[4])*c+(Ze=o[5])*v+(Xe=o[6])*R+(Ye=o[7])*$,a[5]=He*d+Ze*w+Xe*k+Ye*ne,a[6]=He*m+Ze*A+Xe*V+Ye*me,a[7]=He*y+Ze*D+Xe*j+Ye*ke,a[8]=(He=o[8])*c+(Ze=o[9])*v+(Xe=o[10])*R+(Ye=o[11])*$,a[9]=He*d+Ze*w+Xe*k+Ye*ne,a[10]=He*m+Ze*A+Xe*V+Ye*me,a[11]=He*y+Ze*D+Xe*j+Ye*ke,a[12]=(He=o[12])*c+(Ze=o[13])*v+(Xe=o[14])*R+(Ye=o[15])*$,a[13]=He*d+Ze*w+Xe*k+Ye*ne,a[14]=He*m+Ze*A+Xe*V+Ye*me,a[15]=He*y+Ze*D+Xe*j+Ye*ke,a}function jl(a,t,o){var c,d,m,y,v,w,A,D,R,k,V,j,$=o[0],ne=o[1],me=o[2];return t===a?(a[12]=t[0]*$+t[4]*ne+t[8]*me+t[12],a[13]=t[1]*$+t[5]*ne+t[9]*me+t[13],a[14]=t[2]*$+t[6]*ne+t[10]*me+t[14],a[15]=t[3]*$+t[7]*ne+t[11]*me+t[15]):(d=t[1],m=t[2],y=t[3],v=t[4],w=t[5],A=t[6],D=t[7],R=t[8],k=t[9],V=t[10],j=t[11],a[0]=c=t[0],a[1]=d,a[2]=m,a[3]=y,a[4]=v,a[5]=w,a[6]=A,a[7]=D,a[8]=R,a[9]=k,a[10]=V,a[11]=j,a[12]=c*$+v*ne+R*me+t[12],a[13]=d*$+w*ne+k*me+t[13],a[14]=m*$+A*ne+V*me+t[14],a[15]=y*$+D*ne+j*me+t[15]),a}function Fs(a,t,o){var c=o[0],d=o[1],m=o[2];return a[0]=t[0]*c,a[1]=t[1]*c,a[2]=t[2]*c,a[3]=t[3]*c,a[4]=t[4]*d,a[5]=t[5]*d,a[6]=t[6]*d,a[7]=t[7]*d,a[8]=t[8]*m,a[9]=t[9]*m,a[10]=t[10]*m,a[11]=t[11]*m,a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15],a}function ov(a,t,o){var c=Math.sin(o),d=Math.cos(o),m=t[4],y=t[5],v=t[6],w=t[7],A=t[8],D=t[9],R=t[10],k=t[11];return t!==a&&(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]),a[4]=m*d+A*c,a[5]=y*d+D*c,a[6]=v*d+R*c,a[7]=w*d+k*c,a[8]=A*d-m*c,a[9]=D*d-y*c,a[10]=R*d-v*c,a[11]=k*d-w*c,a}function sv(a,t,o){var c=Math.sin(o),d=Math.cos(o),m=t[0],y=t[1],v=t[2],w=t[3],A=t[8],D=t[9],R=t[10],k=t[11];return t!==a&&(a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]),a[0]=m*d-A*c,a[1]=y*d-D*c,a[2]=v*d-R*c,a[3]=w*d-k*c,a[8]=m*c+A*d,a[9]=y*c+D*d,a[10]=v*c+R*d,a[11]=w*c+k*d,a}Math.hypot||(Math.hypot=function(){for(var a=0,t=arguments.length;t--;)a+=arguments[t]*arguments[t];return Math.sqrt(a)});var JL=av;function lv(){var a=new Xr(3);return Xr!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function ub(a){var t=new Xr(3);return t[0]=a[0],t[1]=a[1],t[2]=a[2],t}function hb(a){return Math.hypot(a[0],a[1],a[2])}function cp(a,t,o){var c=new Xr(3);return c[0]=a,c[1]=t,c[2]=o,c}function db(a,t,o){return a[0]=t[0]+o[0],a[1]=t[1]+o[1],a[2]=t[2]+o[2],a}function pb(a,t,o){return a[0]=t[0]-o[0],a[1]=t[1]-o[1],a[2]=t[2]-o[2],a}function fb(a,t,o){return a[0]=t[0]*o[0],a[1]=t[1]*o[1],a[2]=t[2]*o[2],a}function cv(a,t,o){return a[0]=Math.min(t[0],o[0]),a[1]=Math.min(t[1],o[1]),a[2]=Math.min(t[2],o[2]),a}function uv(a,t,o){return a[0]=Math.max(t[0],o[0]),a[1]=Math.max(t[1],o[1]),a[2]=Math.max(t[2],o[2]),a}function up(a,t,o){return a[0]=t[0]*o,a[1]=t[1]*o,a[2]=t[2]*o,a}function hv(a,t,o,c){return a[0]=t[0]+o[0]*c,a[1]=t[1]+o[1]*c,a[2]=t[2]+o[2]*c,a}function hp(a,t){var o=t[0],c=t[1],d=t[2],m=o*o+c*c+d*d;return m>0&&(m=1/Math.sqrt(m)),a[0]=t[0]*m,a[1]=t[1]*m,a[2]=t[2]*m,a}function dp(a,t){return a[0]*t[0]+a[1]*t[1]+a[2]*t[2]}function mb(a,t,o){var c=t[0],d=t[1],m=t[2],y=o[0],v=o[1],w=o[2];return a[0]=d*w-m*v,a[1]=m*y-c*w,a[2]=c*v-d*y,a}function ql(a,t,o){var c=t[0],d=t[1],m=t[2],y=o[3]*c+o[7]*d+o[11]*m+o[15];return a[0]=(o[0]*c+o[4]*d+o[8]*m+o[12])/(y=y||1),a[1]=(o[1]*c+o[5]*d+o[9]*m+o[13])/y,a[2]=(o[2]*c+o[6]*d+o[10]*m+o[14])/y,a}function gb(a,t,o){var c=o[0],d=o[1],m=o[2],y=t[0],v=t[1],w=t[2],A=d*w-m*v,D=m*y-c*w,R=c*v-d*y,k=d*R-m*D,V=m*A-c*R,j=c*D-d*A,$=2*o[3];return D*=$,R*=$,V*=2,j*=2,a[0]=y+(A*=$)+(k*=2),a[1]=v+D+V,a[2]=w+R+j,a}var pp,Vu=pb,KL=fb,QL=hb;function Gu(a,t,o){var c=t[0],d=t[1],m=t[2],y=t[3];return a[0]=o[0]*c+o[4]*d+o[8]*m+o[12]*y,a[1]=o[1]*c+o[5]*d+o[9]*m+o[13]*y,a[2]=o[2]*c+o[6]*d+o[10]*m+o[14]*y,a[3]=o[3]*c+o[7]*d+o[11]*m+o[15]*y,a}function _b(){var a=new Xr(4);return Xr!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function yb(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function vb(a,t,o){o*=.5;var c=t[0],d=t[1],m=t[2],y=t[3],v=Math.sin(o),w=Math.cos(o);return a[0]=c*w+y*v,a[1]=d*w+m*v,a[2]=m*w-d*v,a[3]=y*w-c*v,a}lv(),pp=new Xr(4),Xr!=Float32Array&&(pp[0]=0,pp[1]=0,pp[2]=0,pp[3]=0),lv(),cp(1,0,0),cp(0,1,0),_b(),_b(),cb();class dv{constructor(t,o){this.points=t,this.planes=o}static fromInvProjectionMatrix(t,o,c,d){const m=Math.pow(2,c),y=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(w=>{const A=Gu([],w,t),D=1/A[3]/o*m;return function(R,k,V){return R[0]=k[0]*V[0],R[1]=k[1]*V[1],R[2]=k[2]*V[2],R[3]=k[3]*V[3],R}(A,A,[D,D,d?1/A[3]:D,D])}),v=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(w=>{const A=hp([],mb([],Vu([],y[w[0]],y[w[1]]),Vu([],y[w[2]],y[w[1]]))),D=-dp(A,y[w[1]]);return A.concat(D)});return new dv(y,v)}}class ga{constructor(t,o){this.min=t,this.max=o,this.center=up([],db([],this.min,this.max),.5)}quadrant(t){const o=[t%2==0,t<2],c=ub(this.min),d=ub(this.max);for(let m=0;m<o.length;m++)c[m]=o[m]?this.min[m]:this.center[m],d[m]=o[m]?this.center[m]:this.max[m];return d[2]=this.max[2],new ga(c,d)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,o=this.max;return[[t[0],t[1],t[2]],[o[0],t[1],t[2]],[o[0],o[1],t[2]],[t[0],o[1],t[2]],[t[0],t[1],o[2]],[o[0],t[1],o[2]],[o[0],o[1],o[2]],[t[0],o[1],o[2]]]}intersects(t){const o=this.getCorners();let c=!0;for(let d=0;d<t.planes.length;d++){const m=t.planes[d];let y=0;for(let v=0;v<o.length;v++)y+=dp(m,o[v])+m[3]>=0;if(y===0)return 0;y!==o.length&&(c=!1)}if(c)return 2;for(let d=0;d<3;d++){let m=Number.MAX_VALUE,y=-Number.MAX_VALUE;for(let v=0;v<t.points.length;v++){const w=t.points[v][d]-this.min[d];m=Math.min(m,w),y=Math.max(y,w)}if(y<0||m>this.max[d]-this.min[d])return 0}return 1}}function xb(a,t,o,c,d,m,y,v,w){if(m&&a.queryGeometry.isAboveHorizon)return!1;m&&(w*=a.pixelToTileUnitsFactor);for(const A of t)for(const D of A){const R=D.add(v),k=d&&o.elevation?o.elevation.exaggeration()*d.getElevationAt(R.x,R.y,!0):0,V=m?R:eD(R,k,c),j=m?a.tilespaceRays.map(ne=>nD(ne,k)):a.queryGeometry.screenGeometry,$=Gu([],[D.x,D.y,k,1],c);if(!y&&m?w*=$[3]/o.cameraToCenterDistance:y&&!m&&(w*=o.cameraToCenterDistance/$[3]),jL(j,V,w))return!0}return!1}function eD(a,t,o){const c=Gu([],[a.x,a.y,t,1],o);return new E(c[0]/c[3],c[1]/c[3])}const bb=cp(0,0,0),tD=cp(0,0,1);function nD(a,t){const o=lv();return bb[2]=t,a.intersectsPlane(bb,tD,o),new E(o[0],o[1])}class wb extends tv{}function Mb(a,{width:t,height:o},c,d){if(d){if(d instanceof Uint8ClampedArray)d=new Uint8Array(d.buffer);else if(d.length!==t*o*c)throw new RangeError("mismatched image size")}else d=new Uint8Array(t*o*c);return a.width=t,a.height=o,a.data=d,a}function Tb(a,t,o){const{width:c,height:d}=t;c===a.width&&d===a.height||(pv(a,t,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,c),height:Math.min(a.height,d)},o),a.width=c,a.height=d,a.data=t.data)}function pv(a,t,o,c,d,m){if(d.width===0||d.height===0)return t;if(d.width>a.width||d.height>a.height||o.x>a.width-d.width||o.y>a.height-d.height)throw new RangeError("out of range source coordinates for image copy");if(d.width>t.width||d.height>t.height||c.x>t.width-d.width||c.y>t.height-d.height)throw new RangeError("out of range destination coordinates for image copy");const y=a.data,v=t.data;for(let w=0;w<d.height;w++){const A=((o.y+w)*a.width+o.x)*m,D=((c.y+w)*t.width+c.x)*m;for(let R=0;R<d.width*m;R++)v[D+R]=y[A+R]}return t}jt(wb,"HeatmapBucket",{omit:["layers"]});class Yo{constructor(t,o){Mb(this,t,1,o)}resize(t){Tb(this,new Yo(t),1)}clone(){return new Yo({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,o,c,d,m){pv(t,o,c,d,m,1)}}class Yr{constructor(t,o){Mb(this,t,4,o)}resize(t){Tb(this,new Yr(t),4)}replace(t,o){o?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Yr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,o,c,d,m){pv(t,o,c,d,m,4)}}jt(Yo,"AlphaImage"),jt(Yr,"RGBAImage");var iD={paint:new H({"heatmap-radius":new P(xe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new P(xe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new S(xe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new N(xe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new S(xe.paint_heatmap["heatmap-opacity"])})};function fv(a){const t={},o=a.resolution||256,c=a.clips?a.clips.length:1,d=a.image||new Yr({width:o,height:c}),m=(y,v,w)=>{t[a.evaluationKey]=w;const A=a.expression.evaluate(t);d.data[y+v+0]=Math.floor(255*A.r/A.a),d.data[y+v+1]=Math.floor(255*A.g/A.a),d.data[y+v+2]=Math.floor(255*A.b/A.a),d.data[y+v+3]=Math.floor(255*A.a)};if(a.clips)for(let y=0,v=0;y<c;++y,v+=4*o)for(let w=0,A=0;w<o;w++,A+=4){const D=w/(o-1),{start:R,end:k}=a.clips[y];m(v,A,R*(1-D)+k*D)}else for(let y=0,v=0;y<o;y++,v+=4)m(0,v,y/(o-1));return d}var rD={paint:new H({"hillshade-illumination-direction":new S(xe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new S(xe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new S(xe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new S(xe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new S(xe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new S(xe.paint_hillshade["hillshade-accent-color"])})};const aD=Ae([{name:"a_pos",components:2,type:"Int16"}],4),{members:oD}=aD;var _g=yg,sD=yg;function yg(a,t,o){o=o||2;var c,d,m,y,v,w,A,D=t&&t.length,R=D?t[0]*o:a.length,k=Eb(a,0,R,o,!0),V=[];if(!k||k.next===k.prev)return V;if(D&&(k=function($,ne,me,ke){var He,Ze,Xe,Ye=[];for(He=0,Ze=ne.length;He<Ze;He++)(Xe=Eb($,ne[He]*ke,He<Ze-1?ne[He+1]*ke:$.length,ke,!1))===Xe.next&&(Xe.steiner=!0),Ye.push(mD(Xe));for(Ye.sort(dD),He=0;He<Ye.length;He++)me=Os(me=pD(Ye[He],me),me.next);return me}(a,t,k,o)),a.length>80*o){c=m=a[0],d=y=a[1];for(var j=o;j<R;j+=o)(v=a[j])<c&&(c=v),(w=a[j+1])<d&&(d=w),v>m&&(m=v),w>y&&(y=w);A=(A=Math.max(m-c,y-d))!==0?1/A:0}return fp(k,V,o,c,d,A),V}function Eb(a,t,o,c,d){var m,y;if(d===_v(a,t,o,c)>0)for(m=t;m<o;m+=c)y=Cb(m,a[m],a[m+1],y);else for(m=o-c;m>=t;m-=c)y=Cb(m,a[m],a[m+1],y);return y&&vg(y,y.next)&&(gp(y),y=y.next),y}function Os(a,t){if(!a)return a;t||(t=a);var o,c=a;do if(o=!1,c.steiner||!vg(c,c.next)&&Di(c.prev,c,c.next)!==0)c=c.next;else{if(gp(c),(c=t=c.prev)===c.next)break;o=!0}while(o||c!==t);return t}function fp(a,t,o,c,d,m,y){if(a){!y&&m&&function(D,R,k,V){var j=D;do j.z===null&&(j.z=mv(j.x,j.y,R,k,V)),j.prevZ=j.prev,j.nextZ=j.next,j=j.next;while(j!==D);j.prevZ.nextZ=null,j.prevZ=null,function($){var ne,me,ke,He,Ze,Xe,Ye,lt,ht=1;do{for(me=$,$=null,Ze=null,Xe=0;me;){for(Xe++,ke=me,Ye=0,ne=0;ne<ht&&(Ye++,ke=ke.nextZ);ne++);for(lt=ht;Ye>0||lt>0&&ke;)Ye!==0&&(lt===0||!ke||me.z<=ke.z)?(He=me,me=me.nextZ,Ye--):(He=ke,ke=ke.nextZ,lt--),Ze?Ze.nextZ=He:$=He,He.prevZ=Ze,Ze=He;me=ke}Ze.nextZ=null,ht*=2}while(Xe>1)}(j)}(a,c,d,m);for(var v,w,A=a;a.prev!==a.next;)if(v=a.prev,w=a.next,m?cD(a,c,d,m):lD(a))t.push(v.i/o),t.push(a.i/o),t.push(w.i/o),gp(a),a=w.next,A=w.next;else if((a=w)===A){y?y===1?fp(a=uD(Os(a),t,o),t,o,c,d,m,2):y===2&&hD(a,t,o,c,d,m):fp(Os(a),t,o,c,d,m,1);break}}}function lD(a){var t=a.prev,o=a,c=a.next;if(Di(t,o,c)>=0)return!1;for(var d=a.next.next;d!==a.prev;){if(Hu(t.x,t.y,o.x,o.y,c.x,c.y,d.x,d.y)&&Di(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function cD(a,t,o,c){var d=a.prev,m=a,y=a.next;if(Di(d,m,y)>=0)return!1;for(var v=d.x>m.x?d.x>y.x?d.x:y.x:m.x>y.x?m.x:y.x,w=d.y>m.y?d.y>y.y?d.y:y.y:m.y>y.y?m.y:y.y,A=mv(d.x<m.x?d.x<y.x?d.x:y.x:m.x<y.x?m.x:y.x,d.y<m.y?d.y<y.y?d.y:y.y:m.y<y.y?m.y:y.y,t,o,c),D=mv(v,w,t,o,c),R=a.prevZ,k=a.nextZ;R&&R.z>=A&&k&&k.z<=D;){if(R!==a.prev&&R!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,R.x,R.y)&&Di(R.prev,R,R.next)>=0||(R=R.prevZ,k!==a.prev&&k!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,k.x,k.y)&&Di(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;R&&R.z>=A;){if(R!==a.prev&&R!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,R.x,R.y)&&Di(R.prev,R,R.next)>=0)return!1;R=R.prevZ}for(;k&&k.z<=D;){if(k!==a.prev&&k!==a.next&&Hu(d.x,d.y,m.x,m.y,y.x,y.y,k.x,k.y)&&Di(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function uD(a,t,o){var c=a;do{var d=c.prev,m=c.next.next;!vg(d,m)&&Sb(d,c,c.next,m)&&mp(d,m)&&mp(m,d)&&(t.push(d.i/o),t.push(c.i/o),t.push(m.i/o),gp(c),gp(c.next),c=a=m),c=c.next}while(c!==a);return Os(c)}function hD(a,t,o,c,d,m){var y=a;do{for(var v=y.next.next;v!==y.prev;){if(y.i!==v.i&&gD(y,v)){var w=Ab(y,v);return y=Os(y,y.next),w=Os(w,w.next),fp(y,t,o,c,d,m),void fp(w,t,o,c,d,m)}v=v.next}y=y.next}while(y!==a)}function dD(a,t){return a.x-t.x}function pD(a,t){var o=function(m,y){var v,w=y,A=m.x,D=m.y,R=-1/0;do{if(D<=w.y&&D>=w.next.y&&w.next.y!==w.y){var k=w.x+(D-w.y)*(w.next.x-w.x)/(w.next.y-w.y);if(k<=A&&k>R){if(R=k,k===A){if(D===w.y)return w;if(D===w.next.y)return w.next}v=w.x<w.next.x?w:w.next}}w=w.next}while(w!==y);if(!v)return null;if(A===R)return v;var V,j=v,$=v.x,ne=v.y,me=1/0;w=v;do A>=w.x&&w.x>=$&&A!==w.x&&Hu(D<ne?A:R,D,$,ne,D<ne?R:A,D,w.x,w.y)&&(V=Math.abs(D-w.y)/(A-w.x),mp(w,m)&&(V<me||V===me&&(w.x>v.x||w.x===v.x&&fD(v,w)))&&(v=w,me=V)),w=w.next;while(w!==j);return v}(a,t);if(!o)return t;var c=Ab(o,a),d=Os(o,o.next);return Os(c,c.next),t===o?d:t}function fD(a,t){return Di(a.prev,a,t.prev)<0&&Di(t.next,a,a.next)<0}function mv(a,t,o,c,d){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-o)*d)|a<<8))|a<<4))|a<<2))|a<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-c)*d)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function mD(a){var t=a,o=a;do(t.x<o.x||t.x===o.x&&t.y<o.y)&&(o=t),t=t.next;while(t!==a);return o}function Hu(a,t,o,c,d,m,y,v){return(d-y)*(t-v)-(a-y)*(m-v)>=0&&(a-y)*(c-v)-(o-y)*(t-v)>=0&&(o-y)*(m-v)-(d-y)*(c-v)>=0}function gD(a,t){return a.next.i!==t.i&&a.prev.i!==t.i&&!function(o,c){var d=o;do{if(d.i!==o.i&&d.next.i!==o.i&&d.i!==c.i&&d.next.i!==c.i&&Sb(d,d.next,o,c))return!0;d=d.next}while(d!==o);return!1}(a,t)&&(mp(a,t)&&mp(t,a)&&function(o,c){var d=o,m=!1,y=(o.x+c.x)/2,v=(o.y+c.y)/2;do d.y>v!=d.next.y>v&&d.next.y!==d.y&&y<(d.next.x-d.x)*(v-d.y)/(d.next.y-d.y)+d.x&&(m=!m),d=d.next;while(d!==o);return m}(a,t)&&(Di(a.prev,a,t.prev)||Di(a,t.prev,t))||vg(a,t)&&Di(a.prev,a,a.next)>0&&Di(t.prev,t,t.next)>0)}function Di(a,t,o){return(t.y-a.y)*(o.x-t.x)-(t.x-a.x)*(o.y-t.y)}function vg(a,t){return a.x===t.x&&a.y===t.y}function Sb(a,t,o,c){var d=bg(Di(a,t,o)),m=bg(Di(a,t,c)),y=bg(Di(o,c,a)),v=bg(Di(o,c,t));return d!==m&&y!==v||!(d!==0||!xg(a,o,t))||!(m!==0||!xg(a,c,t))||!(y!==0||!xg(o,a,c))||!(v!==0||!xg(o,t,c))}function xg(a,t,o){return t.x<=Math.max(a.x,o.x)&&t.x>=Math.min(a.x,o.x)&&t.y<=Math.max(a.y,o.y)&&t.y>=Math.min(a.y,o.y)}function bg(a){return a>0?1:a<0?-1:0}function mp(a,t){return Di(a.prev,a,a.next)<0?Di(a,t,a.next)>=0&&Di(a,a.prev,t)>=0:Di(a,t,a.prev)<0||Di(a,a.next,t)<0}function Ab(a,t){var o=new gv(a.i,a.x,a.y),c=new gv(t.i,t.x,t.y),d=a.next,m=t.prev;return a.next=t,t.prev=a,o.next=d,d.prev=o,c.next=o,o.prev=c,m.next=c,c.prev=m,c}function Cb(a,t,o,c){var d=new gv(a,t,o);return c?(d.next=c.next,d.prev=c,c.next.prev=d,c.next=d):(d.prev=d,d.next=d),d}function gp(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function gv(a,t,o){this.i=a,this.x=t,this.y=o,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _v(a,t,o,c){for(var d=0,m=t,y=o-c;m<o;m+=c)d+=(a[y]-a[m])*(a[m+1]+a[y+1]),y=m;return d}function _D(a,t,o,c,d){Pb(a,t,o||0,c||a.length-1,d||yD)}function Pb(a,t,o,c,d){for(;c>o;){if(c-o>600){var m=c-o+1,y=t-o+1,v=Math.log(m),w=.5*Math.exp(2*v/3),A=.5*Math.sqrt(v*w*(m-w)/m)*(y-m/2<0?-1:1);Pb(a,t,Math.max(o,Math.floor(t-y*w/m+A)),Math.min(c,Math.floor(t+(m-y)*w/m+A)),d)}var D=a[t],R=o,k=c;for(_p(a,o,t),d(a[c],D)>0&&_p(a,o,c);R<k;){for(_p(a,R,k),R++,k--;d(a[R],D)<0;)R++;for(;d(a[k],D)>0;)k--}d(a[o],D)===0?_p(a,o,k):_p(a,++k,c),k<=t&&(o=k+1),t<=k&&(c=k-1)}}function _p(a,t,o){var c=a[t];a[t]=a[o],a[o]=c}function yD(a,t){return a<t?-1:a>t?1:0}function yv(a,t){const o=a.length;if(o<=1)return[a];const c=[];let d,m;for(let y=0;y<o;y++){const v=Ne(a[y]);v!==0&&(a[y].area=Math.abs(v),m===void 0&&(m=v<0),m===v<0?(d&&c.push(d),d=[a[y]]):d.push(a[y]))}if(d&&c.push(d),t>1)for(let y=0;y<c.length;y++)c[y].length<=t||(_D(c[y],t,1,c[y].length-1,vD),c[y]=c[y].slice(0,t));return c}function vD(a,t){return t.area-a.area}function vv(a,t,o){const c=o.patternDependencies;let d=!1;for(const m of t){const y=m.paint.get(`${a}-pattern`);y.isConstant()||(d=!0);const v=y.constantOr(null);v&&(d=!0,c[v.to]=!0,c[v.from]=!0)}return d}function xv(a,t,o,c,d){const m=d.patternDependencies;for(const y of t){const v=y.paint.get(`${a}-pattern`).value;if(v.kind!=="constant"){let w=v.evaluate({zoom:c-1},o,{},d.availableImages),A=v.evaluate({zoom:c},o,{},d.availableImages),D=v.evaluate({zoom:c+1},o,{},d.availableImages);w=w&&w.name?w.name:w,A=A&&A.name?A.name:A,D=D&&D.name?D.name:D,m[w]=!0,m[A]=!0,m[D]=!0,o.patterns[y.id]={min:w,mid:A,max:D}}}return o}yg.deviation=function(a,t,o,c){var d=t&&t.length,m=Math.abs(_v(a,0,d?t[0]*o:a.length,o));if(d)for(var y=0,v=t.length;y<v;y++)m-=Math.abs(_v(a,t[y]*o,y<v-1?t[y+1]*o:a.length,o));var w=0;for(y=0;y<c.length;y+=3){var A=c[y]*o,D=c[y+1]*o,R=c[y+2]*o;w+=Math.abs((a[A]-a[R])*(a[D+1]-a[A+1])-(a[A]-a[D])*(a[R+1]-a[A+1]))}return m===0&&w===0?0:Math.abs((w-m)/m)},yg.flatten=function(a){for(var t=a[0][0].length,o={vertices:[],holes:[],dimensions:t},c=0,d=0;d<a.length;d++){for(var m=0;m<a[d].length;m++)for(var y=0;y<t;y++)o.vertices.push(a[d][m][y]);d>0&&o.holes.push(c+=a[d-1].length)}return o},_g.default=sD;class wg{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Te,this.indexArray=new qt,this.indexArray2=new Mn,this.programConfigurations=new Hl(t.layers,t.zoom),this.segments=new Ei,this.segments2=new Ei,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.projection=t.projection}populate(t,o,c,d){this.hasPattern=vv("fill",this.layers,o);const m=this.layers[0].layout.get("fill-sort-key"),y=[];for(const{feature:v,id:w,index:A,sourceLayerIndex:D}of t){const R=this.layers[0]._featureFilter.needGeometry,k=Wl(v,R);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),k,c))continue;const V=m?m.evaluate(k,{},c,o.availableImages):void 0,j={id:w,properties:v.properties,type:v.type,sourceLayerIndex:D,index:A,geometry:R?k.geometry:Xo(v,c,d),patterns:{},sortKey:V};y.push(j)}m&&y.sort((v,w)=>v.sortKey-w.sortKey);for(const v of y){const{geometry:w,index:A,sourceLayerIndex:D}=v;if(this.hasPattern){const R=xv("fill",this.layers,v,this.zoom,o);this.patternFeatures.push(R)}else this.addFeature(v,w,A,c,{},o.availableImages);o.featureIndex.insert(t[A].feature,w,A,D,this.index)}}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}addFeatures(t,o,c,d,m){for(const y of this.patternFeatures)this.addFeature(y,y.geometry,y.index,o,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,oD),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,o,c,d,m,y=[]){for(const v of yv(o,500)){let w=0;for(const j of v)w+=j.length;const A=this.segments.prepareSegment(w,this.layoutVertexArray,this.indexArray),D=A.vertexLength,R=[],k=[];for(const j of v){if(j.length===0)continue;j!==v[0]&&k.push(R.length/2);const $=this.segments2.prepareSegment(j.length,this.layoutVertexArray,this.indexArray2),ne=$.vertexLength;this.layoutVertexArray.emplaceBack(j[0].x,j[0].y),this.indexArray2.emplaceBack(ne+j.length-1,ne),R.push(j[0].x),R.push(j[0].y);for(let me=1;me<j.length;me++)this.layoutVertexArray.emplaceBack(j[me].x,j[me].y),this.indexArray2.emplaceBack(ne+me-1,ne+me),R.push(j[me].x),R.push(j[me].y);$.vertexLength+=j.length,$.primitiveLength+=j.length}const V=_g(R,k);for(let j=0;j<V.length;j+=3)this.indexArray.emplaceBack(D+V[j],D+V[j+1],D+V[j+2]);A.vertexLength+=w,A.primitiveLength+=V.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,m,y,d)}}jt(wg,"FillBucket",{omit:["layers","patternFeatures"]});const xD=new H({"fill-sort-key":new P(xe.layout_fill["fill-sort-key"])});var bD={paint:new H({"fill-antialias":new S(xe.paint_fill["fill-antialias"]),"fill-opacity":new P(xe.paint_fill["fill-opacity"]),"fill-color":new P(xe.paint_fill["fill-color"]),"fill-outline-color":new P(xe.paint_fill["fill-outline-color"]),"fill-translate":new S(xe.paint_fill["fill-translate"]),"fill-translate-anchor":new S(xe.paint_fill["fill-translate-anchor"]),"fill-pattern":new z(xe.paint_fill["fill-pattern"])}),layout:xD};const wD=Ae([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),MD=Ae([{name:"a_centroid_pos",components:2,type:"Uint16"}]),TD=Ae([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ED}=wD;var Lb=Wu;function Wu(a,t,o,c,d){this.properties={},this.extent=o,this.type=0,this._pbf=a,this._geometry=-1,this._keys=c,this._values=d,a.readFields(SD,this,t)}function SD(a,t,o){a==1?t.id=o.readVarint():a==2?function(c,d){for(var m=c.readVarint()+c.pos;c.pos<m;){var y=d._keys[c.readVarint()],v=d._values[c.readVarint()];d.properties[y]=v}}(o,t):a==3?t.type=o.readVarint():a==4&&(t._geometry=o.pos)}function AD(a){for(var t,o,c=0,d=0,m=a.length,y=m-1;d<m;y=d++)c+=((o=a[y]).x-(t=a[d]).x)*(t.y+o.y);return c}Wu.types=["Unknown","Point","LineString","Polygon"],Wu.prototype.loadGeometry=function(){var a=this._pbf;a.pos=this._geometry;for(var t,o=a.readVarint()+a.pos,c=1,d=0,m=0,y=0,v=[];a.pos<o;){if(d<=0){var w=a.readVarint();c=7&w,d=w>>3}if(d--,c===1||c===2)m+=a.readSVarint(),y+=a.readSVarint(),c===1&&(t&&v.push(t),t=[]),t.push(new E(m,y));else{if(c!==7)throw new Error("unknown command "+c);t&&t.push(t[0].clone())}}return t&&v.push(t),v},Wu.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var t=a.readVarint()+a.pos,o=1,c=0,d=0,m=0,y=1/0,v=-1/0,w=1/0,A=-1/0;a.pos<t;){if(c<=0){var D=a.readVarint();o=7&D,c=D>>3}if(c--,o===1||o===2)(d+=a.readSVarint())<y&&(y=d),d>v&&(v=d),(m+=a.readSVarint())<w&&(w=m),m>A&&(A=m);else if(o!==7)throw new Error("unknown command "+o)}return[y,w,v,A]},Wu.prototype.toGeoJSON=function(a,t,o){var c,d,m=this.extent*Math.pow(2,o),y=this.extent*a,v=this.extent*t,w=this.loadGeometry(),A=Wu.types[this.type];function D(V){for(var j=0;j<V.length;j++){var $=V[j];V[j]=[360*($.x+y)/m-180,360/Math.PI*Math.atan(Math.exp((180-360*($.y+v)/m)*Math.PI/180))-90]}}switch(this.type){case 1:var R=[];for(c=0;c<w.length;c++)R[c]=w[c][0];D(w=R);break;case 2:for(c=0;c<w.length;c++)D(w[c]);break;case 3:for(w=function(V){var j=V.length;if(j<=1)return[V];for(var $,ne,me=[],ke=0;ke<j;ke++){var He=AD(V[ke]);He!==0&&(ne===void 0&&(ne=He<0),ne===He<0?($&&me.push($),$=[V[ke]]):$.push(V[ke]))}return $&&me.push($),me}(w),c=0;c<w.length;c++)for(d=0;d<w[c].length;d++)D(w[c][d])}w.length===1?w=w[0]:A="Multi"+A;var k={type:"Feature",geometry:{type:A,coordinates:w},properties:this.properties};return"id"in this&&(k.id=this.id),k};var Db=Ib;function Ib(a,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=a,this._keys=[],this._values=[],this._features=[],a.readFields(CD,this,t),this.length=this._features.length}function CD(a,t,o){a===15?t.version=o.readVarint():a===1?t.name=o.readString():a===5?t.extent=o.readVarint():a===2?t._features.push(o.pos):a===3?t._keys.push(o.readString()):a===4&&t._values.push(function(c){for(var d=null,m=c.readVarint()+c.pos;c.pos<m;){var y=c.readVarint()>>3;d=y===1?c.readString():y===2?c.readFloat():y===3?c.readDouble():y===4?c.readVarint64():y===5?c.readVarint():y===6?c.readSVarint():y===7?c.readBoolean():null}return d}(o))}function PD(a,t,o){if(a===3){var c=new Db(o,o.readVarint()+o.pos);c.length&&(t[c.name]=c)}}Ib.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var t=this._pbf.readVarint()+this._pbf.pos;return new Lb(this._pbf,t,this.extent,this._keys,this._values)};var Zl={VectorTile:function(a,t){this.layers=a.readFields(PD,{},t)},VectorTileFeature:Lb,VectorTileLayer:Db};function Mg(a,t,o,c){const d=[],m=c===0?(y,v,w,A,D,R)=>{y.push(new E(R,w+(R-v)/(A-v)*(D-w)))}:(y,v,w,A,D,R)=>{y.push(new E(v+(R-w)/(D-w)*(A-v),R))};for(const y of a){const v=[];for(const w of y){if(w.length<=2)continue;const A=[];for(let k=0;k<w.length-1;k++){const V=w[k].x,j=w[k].y,$=w[k+1].x,ne=w[k+1].y,me=c===0?V:j,ke=c===0?$:ne;me<t?ke>t&&m(A,V,j,$,ne,t):me>o?ke<o&&m(A,V,j,$,ne,o):A.push(w[k]),ke<t&&me>=t&&m(A,V,j,$,ne,t),ke>o&&me<=o&&m(A,V,j,$,ne,o)}let D=w[w.length-1];const R=c===0?D.x:D.y;R>=t&&R<=o&&A.push(D),A.length&&(D=A[A.length-1],A[0].x===D.x&&A[0].y===D.y||A.push(A[0]),v.push(A))}v.length&&d.push(v)}return d}const LD=Zl.VectorTileFeature.types,DD=Math.pow(2,13);function yp(a,t,o,c,d,m,y,v){a.emplaceBack((t<<1)+y,(o<<1)+m,(Math.floor(c*DD)<<1)+d,Math.round(v))}function vp(a,t,o){a.emplaceBack(t.x,t.y,t.z,o[0]*16384,o[1]*16384,o[2]*16384)}class Rb{constructor(){this.acc=new E(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new E(t.x,t.y),this.max=new E(t.x,t.y))}append(t,o){this.currentPolyCount.edges++,this.acc._add(t);const c=this.min,d=this.max;t.x<c.x?c.x=t.x:t.x>d.x&&(d.x=t.x),t.y<c.y?c.y=t.y:t.y>d.y&&(d.y=t.y),((t.x===0||t.x===In)&&t.x===o.x)!=((t.y===0||t.y===In)&&t.y===o.y)&&this.processBorderOverlap(t,o),o.x<0!=t.x<0&&this.addBorderIntersection(0,gn(o.y,t.y,(0-o.x)/(t.x-o.x))),o.x>In!=t.x>In&&this.addBorderIntersection(1,gn(o.y,t.y,(In-o.x)/(t.x-o.x))),o.y<0!=t.y<0&&this.addBorderIntersection(2,gn(o.x,t.x,(0-o.y)/(t.y-o.y))),o.y>In!=t.y>In&&this.addBorderIntersection(3,gn(o.x,t.x,(In-o.y)/(t.y-o.y)))}addBorderIntersection(t,o){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const c=this.borders[t];o<c[0]&&(c[0]=o),o>c[1]&&(c[1]=o)}processBorderOverlap(t,o){if(t.x===o.x){if(t.y===o.y)return;const c=t.x===0?0:1;this.addBorderIntersection(c,o.y),this.addBorderIntersection(c,t.y)}else{const c=t.y===0?2:3;this.addBorderIntersection(c,o.x),this.addBorderIntersection(c,t.x)}}centroid(){const t=this.polyCount.reduce((o,c)=>o+c.edges,0);return t!==0?this.acc.div(t)._round():new E(0,0)}span(){return new E(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((t,o)=>t+ +(o[0]!==Number.MAX_VALUE),0)}}class xp{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Re,this.centroidVertexArray=new Gl,this.indexArray=new qt,this.programConfigurations=new Hl(t.layers,t.zoom),this.segments=new Ei,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.enableTerrain=t.enableTerrain}populate(t,o,c,d){this.features=[],this.hasPattern=vv("fill-extrusion",this.layers,o),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(m){const y=Math.exp(Math.PI*(1-m.y/(1<<m.z)*2));return 80150034*y/(y*y+1)/In/(1<<m.z)}(c);for(const{feature:m,id:y,index:v,sourceLayerIndex:w}of t){const A=this.layers[0]._featureFilter.needGeometry,D=Wl(m,A);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),D,c))continue;const R={id:y,sourceLayerIndex:w,index:v,geometry:A?D.geometry:Xo(m,c,d),properties:m.properties,type:m.type,patterns:{}},k=this.layoutVertexArray.length;this.hasPattern?this.features.push(xv("fill-extrusion",this.layers,R,this.zoom,o)):this.addFeature(R,R.geometry,v,c,{},o.availableImages,d),o.featureIndex.insert(m,R.geometry,v,w,this.index,k)}this.sortBorders()}addFeatures(t,o,c,d,m){for(const y of this.features){const{geometry:v}=y;this.addFeature(y,v,y.index,o,c,d,m)}this.sortBorders()}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ED),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,TD.members,!0))),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,MD.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,o,c,d,m,y,v){const w=[new E(0,0),new E(In,In)],A=v.projection,D=A.name==="globe",R=this.enableTerrain&&!D?new Rb:null;D&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Rr);const k=yv(o,500);for(let $=k.length-1;$>=0;$--){const ne=k[$];(ne.length===0||(V=ne[0]).every(me=>me.x<=0)||V.every(me=>me.x>=In)||V.every(me=>me.y<=0)||V.every(me=>me.y>=In))&&k.splice($,1)}var V;let j;if(D){const ne=1<<d.z,me=Ta(d.x/ne),ke=Ta((d.x+1)/ne),He=rr(d.y/ne),Ze=rr((d.y+1)/ne);j=function(Xe,Ye,lt,ht,vt=0,Tt){const rt=[];if(!Xe.length||!lt||!ht)return rt;const ft=(An,Bn)=>{for(const Kt of An)rt.push({polygon:Kt,bounds:Bn})},Ct=Math.ceil(Math.log2(lt)),Bt=Math.ceil(Math.log2(ht)),It=Ct-Bt,kt=[];for(let An=0;An<Math.abs(It);An++)kt.push(It>0?0:1);for(let An=0;An<Math.min(Ct,Bt);An++)kt.push(0),kt.push(1);let En=Xe;if(En=Mg(En,Ye[0].y-vt,Ye[1].y+vt,1),En=Mg(En,Ye[0].x-vt,Ye[1].x+vt,0),!En.length)return rt;const Un=[];for(kt.length?Un.push({polygons:En,bounds:Ye,depth:0}):ft(En,Ye);Un.length;){const An=Un.pop(),Bn=An.depth,Kt=kt[Bn],Wt=An.bounds[0],Vn=An.bounds[1],Jn=Kt===0?Wt.x:Wt.y,Fi=Kt===0?Vn.x:Vn.y,ui=Tt?Tt(Kt,Jn,Fi):.5*(Jn+Fi),Oi=Mg(An.polygons,Jn-vt,ui+vt,Kt),Kn=Mg(An.polygons,ui-vt,Fi+vt,Kt);if(Oi.length){const Hn=[Wt,new E(Kt===0?ui:Vn.x,Kt===1?ui:Vn.y)];kt.length>Bn+1?Un.push({polygons:Oi,bounds:Hn,depth:Bn+1}):ft(Oi,Hn)}if(Kn.length){const Hn=[new E(Kt===0?ui:Wt.x,Kt===1?ui:Wt.y),Vn];kt.length>Bn+1?Un.push({polygons:Kn,bounds:Hn,depth:Bn+1}):ft(Kn,Hn)}}return rt}(k,w,Math.ceil((ke-me)/11.25),Math.ceil((He-Ze)/11.25),1,(Xe,Ye,lt)=>{if(Xe===0)return .5*(Ye+lt);{const ht=rr((d.y+Ye/In)/ne);return(Fu(.5*(rr((d.y+lt/In)/ne)+ht))*ne-d.y)*In}})}else{j=[];for(const $ of k)j.push({polygon:$,bounds:w})}for(const $ of j){const ne=$.polygon;let me=0,ke=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let lt=0;lt<ne.length;lt++){const ht=ne[lt];if(ht.length===0)continue;me+=ht.length;let vt=0;R&&R.startRing(ht[0]);for(let Tt=0;Tt<ht.length;Tt++){const rt=ht[Tt];if(Tt>=1){const ft=ht[Tt-1];if(!ID(rt,ft,$.bounds)){R&&R.append(rt,ft),ke.vertexLength+4>Ei.MAX_VERTEX_ARRAY_LENGTH&&(ke=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Ct=rt.sub(ft)._perp(),Bt=Ct.x/(Math.abs(Ct.x)+Math.abs(Ct.y)),It=Ct.y>0?1:0,kt=ft.dist(rt);vt+kt>32768&&(vt=0),yp(this.layoutVertexArray,rt.x,rt.y,Bt,It,0,0,vt),yp(this.layoutVertexArray,rt.x,rt.y,Bt,It,0,1,vt),vt+=kt,yp(this.layoutVertexArray,ft.x,ft.y,Bt,It,0,0,vt),yp(this.layoutVertexArray,ft.x,ft.y,Bt,It,0,1,vt);const En=ke.vertexLength;if(this.indexArray.emplaceBack(En,En+2,En+1),this.indexArray.emplaceBack(En+1,En+2,En+3),ke.vertexLength+=4,ke.primitiveLength+=2,D){const Un=this.layoutVertexExtArray,An=A.projectTilePoint(rt.x,rt.y,d),Bn=A.projectTilePoint(ft.x,ft.y,d),Kt=A.upVector(d,rt.x,rt.y),Wt=A.upVector(d,ft.x,ft.y);vp(Un,An,Kt),vp(Un,An,Kt),vp(Un,Bn,Wt),vp(Un,Bn,Wt)}}}}}if(ke.vertexLength+me>Ei.MAX_VERTEX_ARRAY_LENGTH&&(ke=this.segments.prepareSegment(me,this.layoutVertexArray,this.indexArray)),LD[t.type]!=="Polygon")continue;const He=[],Ze=[],Xe=ke.vertexLength;for(let lt=0;lt<ne.length;lt++){const ht=ne[lt];if(ht.length!==0){ht!==ne[0]&&Ze.push(He.length/2);for(let vt=0;vt<ht.length;vt++){const Tt=ht[vt];yp(this.layoutVertexArray,Tt.x,Tt.y,0,0,1,1,0),He.push(Tt.x),He.push(Tt.y),R&&R.currentPolyCount.top++,D&&vp(this.layoutVertexExtArray,A.projectTilePoint(Tt.x,Tt.y,d),A.upVector(d,Tt.x,Tt.y))}}}const Ye=_g(He,Ze);for(let lt=0;lt<Ye.length;lt+=3)this.indexArray.emplaceBack(Xe+Ye[lt],Xe+Ye[lt+2],Xe+Ye[lt+1]);ke.primitiveLength+=Ye.length/3,ke.vertexLength+=me}if(R&&R.polyCount.length>0){if(R.borders){R.vertexArrayOffset=this.centroidVertexArray.length;const $=R.borders,ne=this.featuresOnBorder.push(R)-1;for(let me=0;me<4;me++)$[me][0]!==Number.MAX_VALUE&&this.borders[me].push(ne)}this.encodeCentroid(R.borders?void 0:R.centroid(),R)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,m,y,d)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort((o,c)=>this.featuresOnBorder[o].borders[t][0]-this.featuresOnBorder[c].borders[t][0])}encodeCentroid(t,o,c=!0){let d,m;if(t)if(t.y!==0){const v=o.span()._mult(this.tileToMeter);d=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(v.x/10)),m=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(v.y/10))}else d=Math.ceil(7*(t.x+450)),m=0;else d=0,m=+c;let y=c?this.centroidVertexArray.length:o.vertexArrayOffset;for(const v of o.polyCount){c&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*v.edges+v.top);for(let w=0;w<2*v.edges;w++)this.centroidVertexArray.emplace(y++,0,m),this.centroidVertexArray.emplace(y++,d,m);for(let w=0;w<v.top;w++)this.centroidVertexArray.emplace(y++,d,m)}}}function ID(a,t,o){return a.x===t.x&&(a.x<o[0].x||a.x>o[1].x)||a.y===t.y&&(a.y<o[0].y||a.y>o[1].y)}jt(xp,"FillExtrusionBucket",{omit:["layers","features"]}),jt(Rb,"PartMetadata");var RD={paint:new H({"fill-extrusion-opacity":new S(xe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new P(xe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new S(xe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new S(xe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new z(xe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new P(xe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new P(xe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new S(xe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function bp(a,t){return a.x*t.x+a.y*t.y}function zb(a,t){if(a.length===1){let o=0;const c=t[o++];let d;for(;!d||c.equals(d);)if(d=t[o++],!d)return 1/0;for(;o<t.length;o++){const m=t[o],y=a[0],v=d.sub(c),w=m.sub(c),A=y.sub(c),D=bp(v,v),R=bp(v,w),k=bp(w,w),V=bp(A,v),j=bp(A,w),$=D*k-R*R,ne=(k*V-R*j)/$,me=(D*j-R*V)/$,ke=c.z*(1-ne-me)+d.z*ne+m.z*me;if(isFinite(ke))return ke}return 1/0}{let o=1/0;for(const c of t)o=Math.min(o,c.z);return o}}function kb(a){const t=new E(a[0],a[1]);return t.z=a[2],t}function zD(a,t,o,c,d,m,y,v){const w=y*d.getElevationAt(a,t,!0,!0),A=m[0]!==0,D=A?m[1]===0?y*(m[0]/7-450):y*function(R,k,V){const j=Math.floor(k[0]/8),$=Math.floor(k[1]/8),ne=10*(k[0]-8*j),me=10*(k[1]-8*$),ke=R.getElevationAt(j,$,!0,!0),He=R.getMeterToDEM(V),Ze=Math.floor(.5*(ne*He-1)),Xe=Math.floor(.5*(me*He-1)),Ye=R.tileCoordToPixel(j,$),lt=2*Ze+1,ht=2*Xe+1,vt=function(It,kt,En,Un,An){return[It.getElevationAtPixel(kt,En,!0),It.getElevationAtPixel(kt+An,En,!0),It.getElevationAtPixel(kt,En+An,!0),It.getElevationAtPixel(kt+Un,En+An,!0)]}(R,Ye.x-Ze,Ye.y-Xe,lt,ht),Tt=Math.abs(vt[0]-vt[1]),rt=Math.abs(vt[2]-vt[3]),ft=Math.abs(vt[0]-vt[2])+Math.abs(vt[1]-vt[3]),Ct=Math.min(.25,.5*He*(Tt+rt)/lt),Bt=Math.min(.25,.5*He*ft/ht);return ke+Math.max(Ct*ne,Bt*me)}(d,m,v):w;return{base:w+(o===0)?-1:o,top:A?Math.max(D+c,w+o+2):w+c}}const kD=Ae([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:BD}=kD,FD=Ae([{name:"a_packed",components:3,type:"Float32"}]),{members:OD}=FD,ND=Zl.VectorTileFeature.types,UD=Math.cos(Math.PI/180*37.5);class Tg{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(o=>o.id),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(o=>{this.gradients[o.id]={}}),this.layoutVertexArray=new be,this.layoutVertexArray2=new Rt,this.indexArray=new qt,this.programConfigurations=new Hl(t.layers,t.zoom),this.segments=new Ei,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(t,o,c,d){this.hasPattern=vv("line",this.layers,o);const m=this.layers[0].layout.get("line-sort-key"),y=[];for(const{feature:D,id:R,index:k,sourceLayerIndex:V}of t){const j=this.layers[0]._featureFilter.needGeometry,$=Wl(D,j);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),$,c))continue;const ne=m?m.evaluate($,{},c):void 0,me={id:R,properties:D.properties,type:D.type,sourceLayerIndex:V,index:k,geometry:j?$.geometry:Xo(D,c,d),patterns:{},sortKey:ne};y.push(me)}m&&y.sort((D,R)=>D.sortKey-R.sortKey);const{lineAtlas:v,featureIndex:w}=o,A=this.addConstantDashes(v);for(const D of y){const{geometry:R,index:k,sourceLayerIndex:V}=D;if(A&&this.addFeatureDashes(D,v),this.hasPattern){const j=xv("line",this.layers,D,this.zoom,o);this.patternFeatures.push(j)}else this.addFeature(D,R,k,c,v.positions,o.availableImages);w.insert(t[k].feature,R,k,V,this.index)}}addConstantDashes(t){let o=!1;for(const c of this.layers){const d=c.paint.get("line-dasharray").value,m=c.layout.get("line-cap").value;if(d.kind!=="constant"||m.kind!=="constant")o=!0;else{const y=m.value,v=d.value;if(!v)continue;t.addDash(v.from,y),t.addDash(v.to,y),v.other&&t.addDash(v.other,y)}}return o}addFeatureDashes(t,o){const c=this.zoom;for(const d of this.layers){const m=d.paint.get("line-dasharray").value,y=d.layout.get("line-cap").value;if(m.kind==="constant"&&y.kind==="constant")continue;let v,w,A,D,R,k;if(m.kind==="constant"){const ne=m.value;if(!ne)continue;v=ne.other||ne.to,w=ne.to,A=ne.from}else v=m.evaluate({zoom:c-1},t),w=m.evaluate({zoom:c},t),A=m.evaluate({zoom:c+1},t);y.kind==="constant"?D=R=k=y.value:(D=y.evaluate({zoom:c-1},t),R=y.evaluate({zoom:c},t),k=y.evaluate({zoom:c+1},t)),o.addDash(v,D),o.addDash(w,R),o.addDash(A,k);const V=o.getKey(v,D),j=o.getKey(w,R),$=o.getKey(A,k);t.patterns[d.id]={min:V,mid:j,max:$}}}update(t,o,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,o,this.stateDependentLayers,c,d)}addFeatures(t,o,c,d,m){for(const y of this.patternFeatures)this.addFeature(y,y.geometry,y.index,o,c,d)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,OD)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,BD),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,o,c,d,m,y){const v=this.layers[0].layout,w=v.get("line-join").evaluate(t,{}),A=v.get("line-cap").evaluate(t,{}),D=v.get("line-miter-limit"),R=v.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const k of o)this.addLine(k,t,w,A,D,R);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,m,y,d)}addLine(t,o,c,d,m,y){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let me=0;me<t.length-1;me++)this.totalDistance+=t[me].dist(t[me+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const v=ND[o.type]==="Polygon";let w=t.length;for(;w>=2&&t[w-1].equals(t[w-2]);)w--;let A=0;for(;A<w-1&&t[A].equals(t[A+1]);)A++;if(w<(v?3:2))return;c==="bevel"&&(m=1.05);const D=this.overscaling<=16?122880/(512*this.overscaling):0,R=this.segments.prepareSegment(10*w,this.layoutVertexArray,this.indexArray);let k,V,j,$,ne;this.e1=this.e2=-1,v&&(k=t[w-2],ne=t[A].sub(k)._unit()._perp());for(let me=A;me<w;me++){if(j=me===w-1?v?t[A+1]:void 0:t[me+1],j&&t[me].equals(j))continue;ne&&($=ne),k&&(V=k),k=t[me],ne=j?j.sub(k)._unit()._perp():$,$=$||ne;let ke=$.add(ne);ke.x===0&&ke.y===0||ke._unit();const He=$.x*ne.x+$.y*ne.y,Ze=ke.x*ne.x+ke.y*ne.y,Xe=Ze!==0?1/Ze:1/0,Ye=2*Math.sqrt(2-2*Ze),lt=Ze<UD&&V&&j,ht=$.x*ne.y-$.y*ne.x>0;if(lt&&me>A){const rt=k.dist(V);if(rt>2*D){const ft=k.sub(k.sub(V)._mult(D/rt)._round());this.updateDistance(V,ft),this.addCurrentVertex(ft,$,0,0,R),V=ft}}const vt=V&&j;let Tt=vt?c:v?"butt":d;if(vt&&Tt==="round"&&(Xe<y?Tt="miter":Xe<=2&&(Tt="fakeround")),Tt==="miter"&&Xe>m&&(Tt="bevel"),Tt==="bevel"&&(Xe>2&&(Tt="flipbevel"),Xe<m&&(Tt="miter")),V&&this.updateDistance(V,k),Tt==="miter")ke._mult(Xe),this.addCurrentVertex(k,ke,0,0,R);else if(Tt==="flipbevel"){if(Xe>100)ke=ne.mult(-1);else{const rt=Xe*$.add(ne).mag()/$.sub(ne).mag();ke._perp()._mult(rt*(ht?-1:1))}this.addCurrentVertex(k,ke,0,0,R),this.addCurrentVertex(k,ke.mult(-1),0,0,R)}else if(Tt==="bevel"||Tt==="fakeround"){const rt=-Math.sqrt(Xe*Xe-1),ft=ht?rt:0,Ct=ht?0:rt;if(V&&this.addCurrentVertex(k,$,ft,Ct,R),Tt==="fakeround"){const Bt=Math.round(180*Ye/Math.PI/20);for(let It=1;It<Bt;It++){let kt=It/Bt;if(kt!==.5){const Un=kt-.5;kt+=kt*Un*(kt-1)*((1.0904+He*(He*(3.55645-1.43519*He)-3.2452))*Un*Un+(.848013+He*(.215638*He-1.06021)))}const En=ne.sub($)._mult(kt)._add($)._unit()._mult(ht?-1:1);this.addHalfVertex(k,En.x,En.y,!1,ht,0,R)}}j&&this.addCurrentVertex(k,ne,-ft,-Ct,R)}else if(Tt==="butt")this.addCurrentVertex(k,ke,0,0,R);else if(Tt==="square"){const rt=V?1:-1;V||this.addCurrentVertex(k,ke,rt,rt,R),this.addCurrentVertex(k,ke,0,0,R),V&&this.addCurrentVertex(k,ke,rt,rt,R)}else Tt==="round"&&(V&&(this.addCurrentVertex(k,$,0,0,R),this.addCurrentVertex(k,$,1,1,R,!0)),j&&(this.addCurrentVertex(k,ne,-1,-1,R,!0),this.addCurrentVertex(k,ne,0,0,R)));if(lt&&me<w-1){const rt=k.dist(j);if(rt>2*D){const ft=k.add(j.sub(k)._mult(D/rt)._round());this.updateDistance(k,ft),this.addCurrentVertex(ft,ne,0,0,R),k=ft}}}}addCurrentVertex(t,o,c,d,m,y=!1){const v=o.y*d-o.x,w=-o.y-o.x*d;this.addHalfVertex(t,o.x+o.y*c,o.y-o.x*c,y,!1,c,m),this.addHalfVertex(t,v,w,y,!0,-d,m)}addHalfVertex({x:t,y:o},c,d,m,y,v,w){this.layoutVertexArray.emplaceBack((t<<1)+(m?1:0),(o<<1)+(y?1:0),Math.round(63*c)+128,Math.round(63*d)+128,1+(v===0?0:v<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const A=w.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,A),w.primitiveLength++),y?this.e2=A:this.e1=A}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,o){this.distance+=t.dist(o),this.updateScaledDistance()}}jt(Tg,"LineBucket",{omit:["layers","patternFeatures"]});const VD=new H({"line-cap":new P(xe.layout_line["line-cap"]),"line-join":new P(xe.layout_line["line-join"]),"line-miter-limit":new S(xe.layout_line["line-miter-limit"]),"line-round-limit":new S(xe.layout_line["line-round-limit"]),"line-sort-key":new P(xe.layout_line["line-sort-key"])});var Bb={paint:new H({"line-opacity":new P(xe.paint_line["line-opacity"]),"line-color":new P(xe.paint_line["line-color"]),"line-translate":new S(xe.paint_line["line-translate"]),"line-translate-anchor":new S(xe.paint_line["line-translate-anchor"]),"line-width":new P(xe.paint_line["line-width"]),"line-gap-width":new P(xe.paint_line["line-gap-width"]),"line-offset":new P(xe.paint_line["line-offset"]),"line-blur":new P(xe.paint_line["line-blur"]),"line-dasharray":new z(xe.paint_line["line-dasharray"]),"line-pattern":new z(xe.paint_line["line-pattern"]),"line-gradient":new N(xe.paint_line["line-gradient"])}),layout:VD};const Fb=new class extends P{possiblyEvaluate(a,t){return t=new ci(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(a,t)}evaluate(a,t,o,c){return t=ye({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(a,t,o,c)}}(Bb.paint.properties["line-width"].specification);function Ob(a,t){return t>0?t+2*a:a}Fb.useIntegerZoom=!0;const GD=Ae([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),HD=Ae([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ae([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const WD=Ae([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),jD=Ae([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ae([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Nb=Ae([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),qD=Ae([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ae([{name:"triangle",components:3,type:"Uint16"}]),Ae([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Ae([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ae([{type:"Float32",name:"offsetX"}]),Ae([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var ar=24;const _o=128;function bv(a,t){const{expression:o}=t;if(o.kind==="constant")return{kind:"constant",layoutSize:o.evaluate(new ci(a+1))};if(o.kind==="source")return{kind:"source"};{const{zoomStops:c,interpolationType:d}=o;let m=0;for(;m<c.length&&c[m]<=a;)m++;m=Math.max(0,m-1);let y=m;for(;y<c.length&&c[y]<a+1;)y++;y=Math.min(c.length-1,y);const v=c[m],w=c[y];return o.kind==="composite"?{kind:"composite",minZoom:v,maxZoom:w,interpolationType:d}:{kind:"camera",minZoom:v,maxZoom:w,minSize:o.evaluate(new ci(v)),maxSize:o.evaluate(new ci(w)),interpolationType:d}}}function Eg(a,{uSize:t,uSizeT:o},{lowerSize:c,upperSize:d}){return a.kind==="source"?c/_o:a.kind==="composite"?gn(c/_o,d/_o,o):t}function ju(a,t){let o=0,c=0;if(a.kind==="constant")c=a.layoutSize;else if(a.kind!=="source"){const{interpolationType:d,minZoom:m,maxZoom:y}=a,v=d?ie(Lr.interpolationFactor(d,t,m,y),0,1):0;a.kind==="camera"?c=gn(a.minSize,a.maxSize,v):o=v}return{uSizeT:o,uSize:c}}var ZD=Object.freeze({__proto__:null,getSizeData:bv,evaluateSizeForFeature:Eg,evaluateSizeForZoom:ju,SIZE_PACK_FACTOR:_o});function XD(a,t,o){return a.sections.forEach(c=>{c.text=function(d,m,y){const v=m.layout.get("text-transform").evaluate(y,{});return v==="uppercase"?d=d.toLocaleUpperCase():v==="lowercase"&&(d=d.toLocaleLowerCase()),qr.applyArabicShaping&&(d=qr.applyArabicShaping(d)),d}(c.text,t,o)}),a}const wp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function YD(a){return a==="︶"||a==="﹈"||a==="︸"||a==="﹄"||a==="﹂"||a==="︾"||a==="︼"||a==="︺"||a==="︘"||a==="﹀"||a==="︐"||a==="︓"||a==="︔"||a==="`"||a===" ̄"||a==="︑"||a==="︒"}function $D(a){return a==="︵"||a==="﹇"||a==="︷"||a==="﹃"||a==="﹁"||a==="︽"||a==="︻"||a==="︹"||a==="︗"||a==="︿"}var Ub=function(a,t,o,c,d){var m,y,v=8*d-c-1,w=(1<<v)-1,A=w>>1,D=-7,R=o?d-1:0,k=o?-1:1,V=a[t+R];for(R+=k,m=V&(1<<-D)-1,V>>=-D,D+=v;D>0;m=256*m+a[t+R],R+=k,D-=8);for(y=m&(1<<-D)-1,m>>=-D,D+=c;D>0;y=256*y+a[t+R],R+=k,D-=8);if(m===0)m=1-A;else{if(m===w)return y?NaN:1/0*(V?-1:1);y+=Math.pow(2,c),m-=A}return(V?-1:1)*y*Math.pow(2,m-c)},Vb=function(a,t,o,c,d,m){var y,v,w,A=8*m-d-1,D=(1<<A)-1,R=D>>1,k=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,V=c?0:m-1,j=c?1:-1,$=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(v=isNaN(t)?1:0,y=D):(y=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-y))<1&&(y--,w*=2),(t+=y+R>=1?k/w:k*Math.pow(2,1-R))*w>=2&&(y++,w/=2),y+R>=D?(v=0,y=D):y+R>=1?(v=(t*w-1)*Math.pow(2,d),y+=R):(v=t*Math.pow(2,R-1)*Math.pow(2,d),y=0));d>=8;a[o+V]=255&v,V+=j,v/=256,d-=8);for(y=y<<d|v,A+=d;A>0;a[o+V]=255&y,V+=j,y/=256,A-=8);a[o+V-j]|=128*$},Mp=si;function si(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}si.Varint=0,si.Fixed64=1,si.Bytes=2,si.Fixed32=5;var wv=4294967296,Gb=1/wv,Hb=typeof TextDecoder=="undefined"?null:new TextDecoder("utf8");function $o(a){return a.type===si.Bytes?a.readVarint()+a.pos:a.pos+1}function qu(a,t,o){return o?4294967296*t+(a>>>0):4294967296*(t>>>0)+(a>>>0)}function Wb(a,t,o){var c=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));o.realloc(c);for(var d=o.pos-1;d>=a;d--)o.buf[d+c]=o.buf[d]}function JD(a,t){for(var o=0;o<a.length;o++)t.writeVarint(a[o])}function KD(a,t){for(var o=0;o<a.length;o++)t.writeSVarint(a[o])}function QD(a,t){for(var o=0;o<a.length;o++)t.writeFloat(a[o])}function eI(a,t){for(var o=0;o<a.length;o++)t.writeDouble(a[o])}function tI(a,t){for(var o=0;o<a.length;o++)t.writeBoolean(a[o])}function nI(a,t){for(var o=0;o<a.length;o++)t.writeFixed32(a[o])}function iI(a,t){for(var o=0;o<a.length;o++)t.writeSFixed32(a[o])}function rI(a,t){for(var o=0;o<a.length;o++)t.writeFixed64(a[o])}function aI(a,t){for(var o=0;o<a.length;o++)t.writeSFixed64(a[o])}function Sg(a,t){return(a[t]|a[t+1]<<8|a[t+2]<<16)+16777216*a[t+3]}function Zu(a,t,o){a[o]=t,a[o+1]=t>>>8,a[o+2]=t>>>16,a[o+3]=t>>>24}function jb(a,t){return(a[t]|a[t+1]<<8|a[t+2]<<16)+(a[t+3]<<24)}function oI(a,t,o){t.glyphs=[],a===1&&o.readMessage(sI,t)}function sI(a,t,o){if(a===3){const{id:c,bitmap:d,width:m,height:y,left:v,top:w,advance:A}=o.readMessage(lI,{});t.glyphs.push({id:c,bitmap:new Yo({width:m+6,height:y+6},d),metrics:{width:m,height:y,left:v,top:w,advance:A}})}else a===4?t.ascender=o.readSVarint():a===5&&(t.descender=o.readSVarint())}function lI(a,t,o){a===1?t.id=o.readVarint():a===2?t.bitmap=o.readBytes():a===3?t.width=o.readVarint():a===4?t.height=o.readVarint():a===5?t.left=o.readSVarint():a===6?t.top=o.readSVarint():a===7&&(t.advance=o.readVarint())}function Mv(a){let t=0,o=0;for(const y of a)t+=y.w*y.h,o=Math.max(o,y.w);a.sort((y,v)=>v.h-y.h);const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),o),h:1/0}];let d=0,m=0;for(const y of a)for(let v=c.length-1;v>=0;v--){const w=c[v];if(!(y.w>w.w||y.h>w.h)){if(y.x=w.x,y.y=w.y,m=Math.max(m,y.y+y.h),d=Math.max(d,y.x+y.w),y.w===w.w&&y.h===w.h){const A=c.pop();v<c.length&&(c[v]=A)}else y.h===w.h?(w.x+=y.w,w.w-=y.w):y.w===w.w?(w.y+=y.h,w.h-=y.h):(c.push({x:w.x+y.w,y:w.y,w:w.w-y.w,h:y.h}),w.y+=y.h,w.h-=y.h);break}}return{w:d,h:m,fill:t/(d*m)||0}}si.prototype={destroy:function(){this.buf=null},readFields:function(a,t,o){for(o=o||this.length;this.pos<o;){var c=this.readVarint(),d=c>>3,m=this.pos;this.type=7&c,a(d,t,this),this.pos===m&&this.skip(c)}return t},readMessage:function(a,t){return this.readFields(a,t,this.readVarint()+this.pos)},readFixed32:function(){var a=Sg(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=jb(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=Sg(this.buf,this.pos)+Sg(this.buf,this.pos+4)*wv;return this.pos+=8,a},readSFixed64:function(){var a=Sg(this.buf,this.pos)+jb(this.buf,this.pos+4)*wv;return this.pos+=8,a},readFloat:function(){var a=Ub(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=Ub(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var t,o,c=this.buf;return t=127&(o=c[this.pos++]),o<128?t:(t|=(127&(o=c[this.pos++]))<<7,o<128?t:(t|=(127&(o=c[this.pos++]))<<14,o<128?t:(t|=(127&(o=c[this.pos++]))<<21,o<128?t:function(d,m,y){var v,w,A=y.buf;if(v=(112&(w=A[y.pos++]))>>4,w<128||(v|=(127&(w=A[y.pos++]))<<3,w<128)||(v|=(127&(w=A[y.pos++]))<<10,w<128)||(v|=(127&(w=A[y.pos++]))<<17,w<128)||(v|=(127&(w=A[y.pos++]))<<24,w<128)||(v|=(1&(w=A[y.pos++]))<<31,w<128))return qu(d,v,m);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(o=c[this.pos]))<<28,a,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?(a+1)/-2:a/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var a=this.readVarint()+this.pos,t=this.pos;return this.pos=a,a-t>=12&&Hb?function(o,c,d){return Hb.decode(o.subarray(c,d))}(this.buf,t,a):function(o,c,d){for(var m="",y=c;y<d;){var v,w,A,D=o[y],R=null,k=D>239?4:D>223?3:D>191?2:1;if(y+k>d)break;k===1?D<128&&(R=D):k===2?(192&(v=o[y+1]))==128&&(R=(31&D)<<6|63&v)<=127&&(R=null):k===3?(w=o[y+2],(192&(v=o[y+1]))==128&&(192&w)==128&&((R=(15&D)<<12|(63&v)<<6|63&w)<=2047||R>=55296&&R<=57343)&&(R=null)):k===4&&(w=o[y+2],A=o[y+3],(192&(v=o[y+1]))==128&&(192&w)==128&&(192&A)==128&&((R=(15&D)<<18|(63&v)<<12|(63&w)<<6|63&A)<=65535||R>=1114112)&&(R=null)),R===null?(R=65533,k=1):R>65535&&(R-=65536,m+=String.fromCharCode(R>>>10&1023|55296),R=56320|1023&R),m+=String.fromCharCode(R),y+=k}return m}(this.buf,t,a)},readBytes:function(){var a=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,a);return this.pos=a,t},readPackedVarint:function(a,t){if(this.type!==si.Bytes)return a.push(this.readVarint(t));var o=$o(this);for(a=a||[];this.pos<o;)a.push(this.readVarint(t));return a},readPackedSVarint:function(a){if(this.type!==si.Bytes)return a.push(this.readSVarint());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readSVarint());return a},readPackedBoolean:function(a){if(this.type!==si.Bytes)return a.push(this.readBoolean());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readBoolean());return a},readPackedFloat:function(a){if(this.type!==si.Bytes)return a.push(this.readFloat());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readFloat());return a},readPackedDouble:function(a){if(this.type!==si.Bytes)return a.push(this.readDouble());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readDouble());return a},readPackedFixed32:function(a){if(this.type!==si.Bytes)return a.push(this.readFixed32());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readFixed32());return a},readPackedSFixed32:function(a){if(this.type!==si.Bytes)return a.push(this.readSFixed32());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readSFixed32());return a},readPackedFixed64:function(a){if(this.type!==si.Bytes)return a.push(this.readFixed64());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readFixed64());return a},readPackedSFixed64:function(a){if(this.type!==si.Bytes)return a.push(this.readSFixed64());var t=$o(this);for(a=a||[];this.pos<t;)a.push(this.readSFixed64());return a},skip:function(a){var t=7&a;if(t===si.Varint)for(;this.buf[this.pos++]>127;);else if(t===si.Bytes)this.pos=this.readVarint()+this.pos;else if(t===si.Fixed32)this.pos+=4;else{if(t!==si.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(a,t){this.writeVarint(a<<3|t)},realloc:function(a){for(var t=this.length||16;t<this.pos+a;)t*=2;if(t!==this.length){var o=new Uint8Array(t);o.set(this.buf),this.buf=o,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(a){this.realloc(4),Zu(this.buf,a,this.pos),this.pos+=4},writeSFixed32:function(a){this.realloc(4),Zu(this.buf,a,this.pos),this.pos+=4},writeFixed64:function(a){this.realloc(8),Zu(this.buf,-1&a,this.pos),Zu(this.buf,Math.floor(a*Gb),this.pos+4),this.pos+=8},writeSFixed64:function(a){this.realloc(8),Zu(this.buf,-1&a,this.pos),Zu(this.buf,Math.floor(a*Gb),this.pos+4),this.pos+=8},writeVarint:function(a){(a=+a||0)>268435455||a<0?function(t,o){var c,d;if(t>=0?(c=t%4294967296|0,d=t/4294967296|0):(d=~(-t/4294967296),4294967295^(c=~(-t%4294967296))?c=c+1|0:(c=0,d=d+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");o.realloc(10),function(m,y,v){v.buf[v.pos++]=127&m|128,m>>>=7,v.buf[v.pos++]=127&m|128,m>>>=7,v.buf[v.pos++]=127&m|128,m>>>=7,v.buf[v.pos++]=127&m|128,v.buf[v.pos]=127&(m>>>=7)}(c,0,o),function(m,y){var v=(7&m)<<4;y.buf[y.pos++]|=v|((m>>>=3)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m|((m>>>=7)?128:0),m&&(y.buf[y.pos++]=127&m)))))}(d,o)}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?2*-a-1:2*a)},writeBoolean:function(a){this.writeVarint(!!a)},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var t=this.pos;this.pos=function(c,d,m){for(var y,v,w=0;w<d.length;w++){if((y=d.charCodeAt(w))>55295&&y<57344){if(!v){y>56319||w+1===d.length?(c[m++]=239,c[m++]=191,c[m++]=189):v=y;continue}if(y<56320){c[m++]=239,c[m++]=191,c[m++]=189,v=y;continue}y=v-55296<<10|y-56320|65536,v=null}else v&&(c[m++]=239,c[m++]=191,c[m++]=189,v=null);y<128?c[m++]=y:(y<2048?c[m++]=y>>6|192:(y<65536?c[m++]=y>>12|224:(c[m++]=y>>18|240,c[m++]=y>>12&63|128),c[m++]=y>>6&63|128),c[m++]=63&y|128)}return m}(this.buf,a,this.pos);var o=this.pos-t;o>=128&&Wb(t,o,this),this.pos=t-1,this.writeVarint(o),this.pos+=o},writeFloat:function(a){this.realloc(4),Vb(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),Vb(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var t=a.length;this.writeVarint(t),this.realloc(t);for(var o=0;o<t;o++)this.buf[this.pos++]=a[o]},writeRawMessage:function(a,t){this.pos++;var o=this.pos;a(t,this);var c=this.pos-o;c>=128&&Wb(o,c,this),this.pos=o-1,this.writeVarint(c),this.pos+=c},writeMessage:function(a,t,o){this.writeTag(a,si.Bytes),this.writeRawMessage(t,o)},writePackedVarint:function(a,t){t.length&&this.writeMessage(a,JD,t)},writePackedSVarint:function(a,t){t.length&&this.writeMessage(a,KD,t)},writePackedBoolean:function(a,t){t.length&&this.writeMessage(a,tI,t)},writePackedFloat:function(a,t){t.length&&this.writeMessage(a,QD,t)},writePackedDouble:function(a,t){t.length&&this.writeMessage(a,eI,t)},writePackedFixed32:function(a,t){t.length&&this.writeMessage(a,nI,t)},writePackedSFixed32:function(a,t){t.length&&this.writeMessage(a,iI,t)},writePackedFixed64:function(a,t){t.length&&this.writeMessage(a,rI,t)},writePackedSFixed64:function(a,t){t.length&&this.writeMessage(a,aI,t)},writeBytesField:function(a,t){this.writeTag(a,si.Bytes),this.writeBytes(t)},writeFixed32Field:function(a,t){this.writeTag(a,si.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(a,t){this.writeTag(a,si.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(a,t){this.writeTag(a,si.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(a,t){this.writeTag(a,si.Fixed64),this.writeSFixed64(t)},writeVarintField:function(a,t){this.writeTag(a,si.Varint),this.writeVarint(t)},writeSVarintField:function(a,t){this.writeTag(a,si.Varint),this.writeSVarint(t)},writeStringField:function(a,t){this.writeTag(a,si.Bytes),this.writeString(t)},writeFloatField:function(a,t){this.writeTag(a,si.Fixed32),this.writeFloat(t)},writeDoubleField:function(a,t){this.writeTag(a,si.Fixed64),this.writeDouble(t)},writeBooleanField:function(a,t){this.writeVarintField(a,!!t)}};class Tv{constructor(t,{pixelRatio:o,version:c,stretchX:d,stretchY:m,content:y}){this.paddedRect=t,this.pixelRatio=o,this.stretchX=d,this.stretchY=m,this.content=y,this.version=c}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class qb{constructor(t,o){const c={},d={};this.haveRenderCallbacks=[];const m=[];this.addImages(t,c,m),this.addImages(o,d,m);const{w:y,h:v}=Mv(m),w=new Yr({width:y||1,height:v||1});for(const A in t){const D=t[A],R=c[A].paddedRect;Yr.copy(D.data,w,{x:0,y:0},{x:R.x+1,y:R.y+1},D.data)}for(const A in o){const D=o[A],R=d[A].paddedRect,k=R.x+1,V=R.y+1,j=D.data.width,$=D.data.height;Yr.copy(D.data,w,{x:0,y:0},{x:k,y:V},D.data),Yr.copy(D.data,w,{x:0,y:$-1},{x:k,y:V-1},{width:j,height:1}),Yr.copy(D.data,w,{x:0,y:0},{x:k,y:V+$},{width:j,height:1}),Yr.copy(D.data,w,{x:j-1,y:0},{x:k-1,y:V},{width:1,height:$}),Yr.copy(D.data,w,{x:0,y:0},{x:k+j,y:V},{width:1,height:$})}this.image=w,this.iconPositions=c,this.patternPositions=d}addImages(t,o,c){for(const d in t){const m=t[d],y={x:0,y:0,w:m.data.width+2,h:m.data.height+2};c.push(y),o[d]=new Tv(y,m),m.hasRenderCallback&&this.haveRenderCallbacks.push(d)}}patchUpdatedImages(t,o){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(c=>t.hasImage(c)),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const c in t.updatedImages)this.patchUpdatedImage(this.iconPositions[c],t.getImage(c),o),this.patchUpdatedImage(this.patternPositions[c],t.getImage(c),o)}patchUpdatedImage(t,o,c){if(!t||!o||t.version===o.version)return;t.version=o.version;const[d,m]=t.tl;c.update(o.data,void 0,{x:d,y:m})}}jt(Tv,"ImagePosition"),jt(qb,"ImageAtlas");const _a={horizontal:1,vertical:2,horizontalOnly:3};class Tp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,o){const c=new Tp;return c.scale=t||1,c.fontStack=o,c}static forImage(t){const o=new Tp;return o.imageName=t,o}}class Xu{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,o){const c=new Xu;for(let d=0;d<t.sections.length;d++){const m=t.sections[d];m.image?c.addImageSection(m):c.addTextSection(m,o)}return c}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSections(){return this.sections}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(t){this.text=function(o,c){let d="";for(let m=0;m<o.length;m++){const y=o.charCodeAt(m+1)||null,v=o.charCodeAt(m-1)||null;d+=!c&&(y&&Ru(y)&&!wp[o[m+1]]||v&&Ru(v)&&!wp[o[m-1]])||!wp[o[m]]?o[m]:wp[o[m]]}return d}(this.text,t)}trim(){let t=0;for(let c=0;c<this.text.length&&Ag[this.text.charCodeAt(c)];c++)t++;let o=this.text.length;for(let c=this.text.length-1;c>=0&&c>=t&&Ag[this.text.charCodeAt(c)];c--)o--;this.text=this.text.substring(t,o),this.sectionIndex=this.sectionIndex.slice(t,o)}substring(t,o){const c=new Xu;return c.text=this.text.substring(t,o),c.sectionIndex=this.sectionIndex.slice(t,o),c.sections=this.sections,c}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,o)=>Math.max(t,this.sections[o].scale),0)}addTextSection(t,o){this.text+=t.text,this.sections.push(Tp.forText(t.scale,t.fontStack||o));const c=this.sections.length-1;for(let d=0;d<t.text.length;++d)this.sectionIndex.push(c)}addImageSection(t){const o=t.image?t.image.name:"";if(o.length===0)return void ge("Can't add FormattedSection with an empty image.");const c=this.getNextImageSectionCharCode();c?(this.text+=String.fromCharCode(c),this.sections.push(Tp.forImage(o)),this.sectionIndex.push(this.sections.length-1)):ge("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ev(a,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$){const ne=Xu.fromFeature(a,d);let me;R===_a.vertical&&ne.verticalizePunctuation(k);const{processBidirectionalText:ke,processStyledBidirectionalText:He}=qr;if(ke&&ne.sections.length===1){me=[];const Ye=ke(ne.toString(),Sv(ne,A,m,t,c,V,j));for(const lt of Ye){const ht=new Xu;ht.text=lt,ht.sections=ne.sections;for(let vt=0;vt<lt.length;vt++)ht.sectionIndex.push(0);me.push(ht)}}else if(He){me=[];const Ye=He(ne.text,ne.sectionIndex,Sv(ne,A,m,t,c,V,j));for(const lt of Ye){const ht=new Xu;ht.text=lt[0],ht.sectionIndex=lt[1],ht.sections=ne.sections,me.push(ht)}}else me=function(Ye,lt){const ht=[],vt=Ye.text;let Tt=0;for(const rt of lt)ht.push(Ye.substring(Tt,rt)),Tt=rt;return Tt<vt.length&&ht.push(Ye.substring(Tt,vt.length)),ht}(ne,Sv(ne,A,m,t,c,V,j));const Ze=[],Xe={positionedLines:Ze,text:ne.toString(),top:D[1],bottom:D[1],left:D[0],right:D[0],writingMode:R,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(Ye,lt,ht,vt,Tt,rt,ft,Ct,Bt,It,kt,En){let Un=0,An=0,Bn=0;const Kt=Ct==="right"?1:Ct==="left"?0:.5;let Wt=!1;for(const Kn of Tt){const Hn=Kn.getSections();for(const ni of Hn){if(ni.imageName)continue;const wi=lt[ni.fontStack];if(wi&&(Wt=wi.ascender!==void 0&&wi.descender!==void 0,!Wt))break}if(!Wt)break}let Vn=0;for(const Kn of Tt){Kn.trim();const Hn=Kn.getMaxScale(),ni=(Hn-1)*ar,wi={positionedGlyphs:[],lineOffset:0};Ye.positionedLines[Vn]=wi;const Si=wi.positionedGlyphs;let Ni=0;if(!Kn.length()){An+=rt,++Vn;continue}let Yi=0,Kr=0;for(let ii=0;ii<Kn.length();ii++){const vr=Kn.getSection(ii),Qr=Kn.getSectionIndex(ii),er=Kn.getCharCode(ii);let $i=vr.scale,fi=null,hi=null,Fr=null,xr=ar,Ii=0;const br=!(Bt===_a.horizontal||!kt&&!Iu(er)||kt&&(Ag[er]||(Jn=er,Zm(Jn)||Au(Jn)||Bl(Jn)||Qd(Jn)||Lu(Jn))));if(vr.imageName){const hr=vt[vr.imageName];if(!hr)continue;Fr=vr.imageName,Ye.iconsInText=Ye.iconsInText||!0,hi=hr.paddedRect;const Ji=hr.displaySize;$i=$i*ar/En,fi={width:Ji[0],height:Ji[1],left:1,top:-3,advance:br?Ji[1]:Ji[0],localGlyph:!1},Ii=Wt?-fi.height*$i:Hn*ar-17-Ji[1]*$i,xr=fi.advance;const Sa=(br?Ji[0]:Ji[1])*$i-ar*Hn;Sa>0&&Sa>Ni&&(Ni=Sa)}else{const hr=ht[vr.fontStack];if(!hr)continue;hr[er]&&(hi=hr[er]);const Ji=lt[vr.fontStack];if(!Ji)continue;const Sa=Ji.glyphs[er];if(!Sa)continue;if(fi=Sa.metrics,xr=er!==8203?ar:0,Wt){const js=Ji.ascender!==void 0?Math.abs(Ji.ascender):0,zp=Ji.descender!==void 0?Math.abs(Ji.descender):0,kp=(js+zp)*$i;Yi<kp&&(Yi=kp,Kr=(js-zp)/2*$i),Ii=-js*$i}else Ii=(Hn-$i)*ar-17}br?(Ye.verticalizable=!0,Si.push({glyph:er,imageName:Fr,x:Un,y:An+Ii,vertical:br,scale:$i,localGlyph:fi.localGlyph,fontStack:vr.fontStack,sectionIndex:Qr,metrics:fi,rect:hi}),Un+=xr*$i+It):(Si.push({glyph:er,imageName:Fr,x:Un,y:An+Ii,vertical:br,scale:$i,localGlyph:fi.localGlyph,fontStack:vr.fontStack,sectionIndex:Qr,metrics:fi,rect:hi}),Un+=fi.advance*$i+It)}Si.length!==0&&(Bn=Math.max(Un-It,Bn),Wt?Jb(Si,Kt,Ni,Kr,rt*Hn/2):Jb(Si,Kt,Ni,0,rt/2)),Un=0;const Br=rt*Hn+Ni;wi.lineOffset=Math.max(Ni,ni),An+=Br,++Vn}var Jn;const Fi=An,{horizontalAlign:ui,verticalAlign:Oi}=Av(ft);(function(Kn,Hn,ni,wi,Si,Ni){const Yi=(Hn-ni)*Si,Kr=-Ni*wi;for(const Br of Kn)for(const ii of Br.positionedGlyphs)ii.x+=Yi,ii.y+=Kr})(Ye.positionedLines,Kt,ui,Oi,Bn,Fi),Ye.top+=-Oi*Fi,Ye.bottom=Ye.top+Fi,Ye.left+=-ui*Bn,Ye.right=Ye.left+Bn,Ye.hasBaseline=Wt}(Xe,t,o,c,me,y,v,w,R,A,k,$),!function(Ye){for(const lt of Ye)if(lt.positionedGlyphs.length!==0)return!1;return!0}(Ze)&&Xe}const Ag={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},cI={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Zb(a,t,o,c,d,m){if(t.imageName){const y=c[t.imageName];return y?y.displaySize[0]*t.scale*ar/m+d:0}{const y=o[t.fontStack],v=y&&y.glyphs[a];return v?v.metrics.advance*t.scale+d:0}}function Xb(a,t,o,c){const d=Math.pow(a-t,2);return c?a<t?d/2:2*d:d+Math.abs(o)*o}function uI(a,t,o){let c=0;return a===10&&(c-=1e4),o&&(c+=150),a!==40&&a!==65288||(c+=50),t!==41&&t!==65289||(c+=50),c}function Yb(a,t,o,c,d,m){let y=null,v=Xb(t,o,d,m);for(const w of c){const A=Xb(t-w.x,o,d,m)+w.badness;A<=v&&(y=w,v=A)}return{index:a,x:t,priorBreak:y,badness:v}}function $b(a){return a?$b(a.priorBreak).concat(a.index):[]}function Sv(a,t,o,c,d,m,y){if(m!=="point")return[];if(!a)return[];const v=[],w=function(k,V,j,$,ne,me){let ke=0;for(let He=0;He<k.length();He++){const Ze=k.getSection(He);ke+=Zb(k.getCharCode(He),Ze,$,ne,V,me)}return ke/Math.max(1,Math.ceil(ke/j))}(a,t,o,c,d,y),A=a.text.indexOf("​")>=0;let D=0;for(let k=0;k<a.length();k++){const V=a.getSection(k),j=a.getCharCode(k);if(Ag[j]||(D+=Zb(j,V,c,d,t,y)),k<a.length()-1){const $=!((R=j)<11904||!($m(R)||Ym(R)||Ls(R)||Ol(R)||Qm(R)||Yd(R)||Jm(R)||Cu(R)||eg(R)||Kd(R)||Km(R)||ep(R)||Fl(R)||$d(R)||Xm(R)||Jd(R)||Pu(R)||rg(R)||ng(R)||tg(R)));(cI[j]||$||V.imageName)&&v.push(Yb(k+1,D,w,v,uI(j,a.getCharCode(k+1),$&&A),!1))}}var R;return $b(Yb(a.length(),D,w,v,0,!0))}function Av(a){let t=.5,o=.5;switch(a){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(a){case"bottom":case"bottom-right":case"bottom-left":o=1;break;case"top":case"top-right":case"top-left":o=0}return{horizontalAlign:t,verticalAlign:o}}function Jb(a,t,o,c,d){if(!(t||o||c||d))return;const m=a.length-1,y=a[m],v=(y.x+y.metrics.advance*y.scale)*t;for(let w=0;w<=m;w++)a[w].x-=v,a[w].y+=o+c+d}function hI(a,t,o){const{horizontalAlign:c,verticalAlign:d}=Av(o),m=t[0]-a.displaySize[0]*c,y=t[1]-a.displaySize[1]*d;return{image:a,top:y,bottom:y+a.displaySize[1],left:m,right:m+a.displaySize[0]}}function Kb(a,t,o,c,d,m){const y=a.image;let v;if(y.content){const ne=y.content,me=y.pixelRatio||1;v=[ne[0]/me,ne[1]/me,y.displaySize[0]-ne[2]/me,y.displaySize[1]-ne[3]/me]}const w=t.left*m,A=t.right*m;let D,R,k,V;o==="width"||o==="both"?(V=d[0]+w-c[3],R=d[0]+A+c[1]):(V=d[0]+(w+A-y.displaySize[0])/2,R=V+y.displaySize[0]);const j=t.top*m,$=t.bottom*m;return o==="height"||o==="both"?(D=d[1]+j-c[0],k=d[1]+$+c[2]):(D=d[1]+(j+$-y.displaySize[1])/2,k=D+y.displaySize[1]),{image:y,top:D,right:R,bottom:k,left:V,collisionPadding:v}}class Jo extends E{constructor(t,o,c,d,m){super(t,o),this.angle=d,this.z=c,m!==void 0&&(this.segment=m)}clone(){return new Jo(this.x,this.y,this.z,this.angle,this.segment)}}function Qb(a,t,o,c,d){if(t.segment===void 0)return!0;let m=t,y=t.segment+1,v=0;for(;v>-o/2;){if(y--,y<0)return!1;v-=a[y].dist(m),m=a[y]}v+=a[y].dist(a[y+1]),y++;const w=[];let A=0;for(;v<o/2;){const D=a[y],R=a[y+1];if(!R)return!1;let k=a[y-1].angleTo(D)-D.angleTo(R);for(k=Math.abs((k+3*Math.PI)%(2*Math.PI)-Math.PI),w.push({distance:v,angleDelta:k}),A+=k;v-w[0].distance>c;)A-=w.shift().angleDelta;if(A>d)return!1;y++,v+=D.dist(R)}return!0}function ew(a){let t=0;for(let o=0;o<a.length-1;o++)t+=a[o].dist(a[o+1]);return t}function tw(a,t,o){return a?.6*t*o:0}function nw(a,t){return Math.max(a?a.right-a.left:0,t?t.right-t.left:0)}function dI(a,t,o,c,d,m){const y=tw(o,d,m),v=nw(o,c)*m;let w=0;const A=ew(a)/2;for(let D=0;D<a.length-1;D++){const R=a[D],k=a[D+1],V=R.dist(k);if(w+V>A){const j=(A-w)/V,$=gn(R.x,k.x,j),ne=gn(R.y,k.y,j),me=new Jo($,ne,0,k.angleTo(R),D);return!y||Qb(a,me,v,y,t)?me:void 0}w+=V}}function pI(a,t,o,c,d,m,y,v,w){const A=tw(c,m,y),D=nw(c,d),R=D*y,k=a[0].x===0||a[0].x===w||a[0].y===0||a[0].y===w;return t-R<t/4&&(t=R+t/4),iw(a,k?t/2*v%t:(D/2+2*m)*y*v%t,t,A,o,R,k,!1,w)}function iw(a,t,o,c,d,m,y,v,w){const A=m/2,D=ew(a);let R=0,k=t-o,V=[];for(let j=0;j<a.length-1;j++){const $=a[j],ne=a[j+1],me=$.dist(ne),ke=ne.angleTo($);for(;k+o<R+me;){k+=o;const He=(k-R)/me,Ze=gn($.x,ne.x,He),Xe=gn($.y,ne.y,He);if(Ze>=0&&Ze<w&&Xe>=0&&Xe<w&&k-A>=0&&k+A<=D){const Ye=new Jo(Ze,Xe,0,ke,j);Ye._round(),c&&!Qb(a,Ye,m,c,d)||V.push(Ye)}}R+=me}return v||V.length||y||(V=iw(a,R/2,o,c,d,m,y,!0,w)),V}function rw(a,t,o,c,d){const m=[];for(let y=0;y<a.length;y++){const v=a[y];let w;for(let A=0;A<v.length-1;A++){let D=v[A],R=v[A+1];D.x<t&&R.x<t||(D.x<t?D=new E(t,D.y+(t-D.x)/(R.x-D.x)*(R.y-D.y))._round():R.x<t&&(R=new E(t,D.y+(t-D.x)/(R.x-D.x)*(R.y-D.y))._round()),D.y<o&&R.y<o||(D.y<o?D=new E(D.x+(o-D.y)/(R.y-D.y)*(R.x-D.x),o)._round():R.y<o&&(R=new E(D.x+(o-D.y)/(R.y-D.y)*(R.x-D.x),o)._round()),D.x>=c&&R.x>=c||(D.x>=c?D=new E(c,D.y+(c-D.x)/(R.x-D.x)*(R.y-D.y))._round():R.x>=c&&(R=new E(c,D.y+(c-D.x)/(R.x-D.x)*(R.y-D.y))._round()),D.y>=d&&R.y>=d||(D.y>=d?D=new E(D.x+(d-D.y)/(R.y-D.y)*(R.x-D.x),d)._round():R.y>=d&&(R=new E(D.x+(d-D.y)/(R.y-D.y)*(R.x-D.x),d)._round()),w&&D.equals(w[w.length-1])||(w=[D],m.push(w)),w.push(R)))))}}return m}jt(Jo,"Anchor");const Ep=1e20;function aw(a,t,o,c,d,m,y,v,w){for(let A=t;A<t+c;A++)ow(a,o*m+A,m,d,y,v,w);for(let A=o;A<o+d;A++)ow(a,A*m+t,1,c,y,v,w)}function ow(a,t,o,c,d,m,y){m[0]=0,y[0]=-Ep,y[1]=Ep,d[0]=a[t];for(let v=1,w=0,A=0;v<c;v++){d[v]=a[t+v*o];const D=v*v;do{const R=m[w];A=(d[v]-d[R]+D-R*R)/(v-R)/2}while(A<=y[w]&&--w>-1);w++,m[w]=v,y[w]=A,y[w+1]=Ep}for(let v=0,w=0;v<c;v++){for(;y[w+1]<v;)w++;const A=m[w],D=v-A;a[t+v*o]=d[A]+D*D}}const Cv={none:0,ideographs:1,all:2};class Yu{constructor(t,o,c){this.requestManager=t,this.localGlyphMode=o,this.localFontFamily=c,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,o){const c=[];for(const d in t)for(const m of t[d])c.push({stack:d,id:m});le(c,({stack:d,id:m},y)=>{let v=this.entries[d];v||(v=this.entries[d]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let w=v.glyphs[m];if(w!==void 0)return void y(null,{stack:d,id:m,glyph:w});if(w=this._tinySDF(v,d,m),w)return v.glyphs[m]=w,void y(null,{stack:d,id:m,glyph:w});const A=Math.floor(m/256);if(256*A>65535)return void y(new Error("glyphs > 65535 not supported"));if(v.ranges[A])return void y(null,{stack:d,id:m,glyph:w});let D=v.requests[A];D||(D=v.requests[A]=[],Yu.loadGlyphRange(d,A,this.url,this.requestManager,(R,k)=>{if(k){v.ascender=k.ascender,v.descender=k.descender;for(const V in k.glyphs)this._doesCharSupportLocalGlyph(+V)||(v.glyphs[+V]=k.glyphs[+V]);v.ranges[A]=!0}for(const V of D)V(R,k);delete v.requests[A]})),D.push((R,k)=>{R?y(R):k&&y(null,{stack:d,id:m,glyph:k.glyphs[m]||null})})},(d,m)=>{if(d)o(d);else if(m){const y={};for(const{stack:v,id:w,glyph:A}of m)y[v]===void 0&&(y[v]={}),y[v].glyphs===void 0&&(y[v].glyphs={}),y[v].glyphs[w]=A&&{id:A.id,bitmap:A.bitmap.clone(),metrics:A.metrics},y[v].ascender=this.entries[v].ascender,y[v].descender=this.entries[v].descender;o(null,y)}})}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Cv.none&&(this.localGlyphMode===Cv.all?!!this.localFontFamily:!!this.localFontFamily&&(Kd(t)||ig(t)||Fl(t)||Pu(t)||Cu(t)))}_tinySDF(t,o,c){const d=this.localFontFamily;if(!d||!this._doesCharSupportLocalGlyph(c))return;let m=t.tinySDF;if(!m){let $="400";/bold/i.test(o)?$="900":/medium/i.test(o)?$="500":/light/i.test(o)&&($="200"),m=t.tinySDF=new Yu.TinySDF({fontFamily:d,fontWeight:$,fontSize:48,buffer:6,radius:16}),m.fontWeight=$}if(this.localGlyphs[m.fontWeight][c])return this.localGlyphs[m.fontWeight][c];const y=String.fromCharCode(c),{data:v,width:w,height:A,glyphWidth:D,glyphHeight:R,glyphLeft:k,glyphTop:V,glyphAdvance:j}=m.draw(y);return this.localGlyphs[m.fontWeight][c]={id:c,bitmap:new Yo({width:w,height:A},v),metrics:{width:D/2,height:R/2,left:k/2,top:V/2-27,advance:j/2,localGlyph:!0}}}}function sw(a,t,o,c){const d=[],m=a.image,y=m.pixelRatio,v=m.paddedRect.w-2,w=m.paddedRect.h-2,A=a.right-a.left,D=a.bottom-a.top,R=m.stretchX||[[0,v]],k=m.stretchY||[[0,w]],V=(rt,ft)=>rt+ft[1]-ft[0],j=R.reduce(V,0),$=k.reduce(V,0),ne=v-j,me=w-$;let ke=0,He=j,Ze=0,Xe=$,Ye=0,lt=ne,ht=0,vt=me;if(m.content&&c){const rt=m.content;ke=Cg(R,0,rt[0]),Ze=Cg(k,0,rt[1]),He=Cg(R,rt[0],rt[2]),Xe=Cg(k,rt[1],rt[3]),Ye=rt[0]-ke,ht=rt[1]-Ze,lt=rt[2]-rt[0]-He,vt=rt[3]-rt[1]-Xe}const Tt=(rt,ft,Ct,Bt)=>{const It=Pg(rt.stretch-ke,He,A,a.left),kt=Lg(rt.fixed-Ye,lt,rt.stretch,j),En=Pg(ft.stretch-Ze,Xe,D,a.top),Un=Lg(ft.fixed-ht,vt,ft.stretch,$),An=Pg(Ct.stretch-ke,He,A,a.left),Bn=Lg(Ct.fixed-Ye,lt,Ct.stretch,j),Kt=Pg(Bt.stretch-Ze,Xe,D,a.top),Wt=Lg(Bt.fixed-ht,vt,Bt.stretch,$),Vn=new E(It,En),Jn=new E(An,En),Fi=new E(An,Kt),ui=new E(It,Kt),Oi=new E(kt/y,Un/y),Kn=new E(Bn/y,Wt/y),Hn=t*Math.PI/180;if(Hn){const Si=Math.sin(Hn),Ni=Math.cos(Hn),Yi=[Ni,-Si,Si,Ni];Vn._matMult(Yi),Jn._matMult(Yi),ui._matMult(Yi),Fi._matMult(Yi)}const ni=rt.stretch+rt.fixed,wi=ft.stretch+ft.fixed;return{tl:Vn,tr:Jn,bl:ui,br:Fi,tex:{x:m.paddedRect.x+1+ni,y:m.paddedRect.y+1+wi,w:Ct.stretch+Ct.fixed-ni,h:Bt.stretch+Bt.fixed-wi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Oi,pixelOffsetBR:Kn,minFontScaleX:lt/y/A,minFontScaleY:vt/y/D,isSDF:o}};if(c&&(m.stretchX||m.stretchY)){const rt=lw(R,ne,j),ft=lw(k,me,$);for(let Ct=0;Ct<rt.length-1;Ct++){const Bt=rt[Ct],It=rt[Ct+1];for(let kt=0;kt<ft.length-1;kt++)d.push(Tt(Bt,ft[kt],It,ft[kt+1]))}}else d.push(Tt({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:v+1},{fixed:0,stretch:w+1}));return d}function Cg(a,t,o){let c=0;for(const d of a)c+=Math.max(t,Math.min(o,d[1]))-Math.max(t,Math.min(o,d[0]));return c}function lw(a,t,o){const c=[{fixed:-1,stretch:0}];for(const[d,m]of a){const y=c[c.length-1];c.push({fixed:d-y.stretch,stretch:y.stretch}),c.push({fixed:d-y.stretch,stretch:y.stretch+(m-d)})}return c.push({fixed:t+1,stretch:o}),c}function Pg(a,t,o,c){return a/t*o+c}function Lg(a,t,o,c){return a-t*o/c}function fI(a,t,o,c){const d=t+a.positionedLines[c].lineOffset;return c===0?o+d/2:o+(d+(t+a.positionedLines[c-1].lineOffset))/2}Yu.loadGlyphRange=function(a,t,o,c,d){const m=256*t,y=m+255,v=c.transformRequest(c.normalizeGlyphsURL(o).replace("{fontstack}",a).replace("{range}",`${m}-${y}`),_e.Glyphs);Le(v,(w,A)=>{if(w)d(w);else if(A){const D={},R=function(k){return new Mp(k).readFields(oI,{})}(A);for(const k of R.glyphs)D[k.id]=k;d(null,{glyphs:D,ascender:R.ascender,descender:R.descender})}})},Yu.TinySDF=class{constructor({fontSize:a=24,buffer:t=3,radius:o=8,cutoff:c=.25,fontFamily:d="sans-serif",fontWeight:m="normal",fontStyle:y="normal"}){this.buffer=t,this.cutoff=c,this.radius=o;const v=this.size=a+4*t,w=this._createCanvas(v),A=this.ctx=w.getContext("2d",{willReadFrequently:!0});A.font=`${y} ${m} ${a}px ${d}`,A.textBaseline="alphabetic",A.textAlign="left",A.fillStyle="black",this.gridOuter=new Float64Array(v*v),this.gridInner=new Float64Array(v*v),this.f=new Float64Array(v),this.z=new Float64Array(v+1),this.v=new Uint16Array(v)}_createCanvas(a){const t=document.createElement("canvas");return t.width=t.height=a,t}draw(a){const{width:t,actualBoundingBoxAscent:o,actualBoundingBoxDescent:c,actualBoundingBoxLeft:d,actualBoundingBoxRight:m}=this.ctx.measureText(a),y=Math.floor(o),v=Math.min(this.size-this.buffer,Math.ceil(m-d)),w=Math.min(this.size-this.buffer,Math.ceil(o)+Math.ceil(c)),A=v+2*this.buffer,D=w+2*this.buffer,R=A*D,k=new Uint8ClampedArray(R),V={data:k,width:A,height:D,glyphWidth:v,glyphHeight:w,glyphTop:y,glyphLeft:0,glyphAdvance:t};if(v===0||w===0)return V;const{ctx:j,buffer:$,gridInner:ne,gridOuter:me}=this;j.clearRect($,$,v,w),j.fillText(a,$,$+y+1);const ke=j.getImageData($,$,v,w);me.fill(Ep,0,R),ne.fill(0,0,R);for(let He=0;He<w;He++)for(let Ze=0;Ze<v;Ze++){const Xe=ke.data[4*(He*v+Ze)+3]/255;if(Xe===0)continue;const Ye=(He+$)*A+Ze+$;if(Xe===1)me[Ye]=0,ne[Ye]=Ep;else{const lt=.5-Xe;me[Ye]=lt>0?lt*lt:0,ne[Ye]=lt<0?lt*lt:0}}aw(me,0,0,A,D,A,this.f,this.v,this.z),aw(ne,$,$,v,w,A,this.f,this.v,this.z);for(let He=0;He<R;He++){const Ze=Math.sqrt(me[He])-Math.sqrt(ne[He]);k[He]=Math.round(255-255*(Ze/this.radius+this.cutoff))}return V}};class mI{constructor(t=[],o=gI){if(this.data=t,this.length=this.data.length,this.compare=o,this.length>0)for(let c=(this.length>>1)-1;c>=0;c--)this._down(c)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:o,compare:c}=this,d=o[t];for(;t>0;){const m=t-1>>1,y=o[m];if(c(d,y)>=0)break;o[t]=y,t=m}o[t]=d}_down(t){const{data:o,compare:c}=this,d=this.length>>1,m=o[t];for(;t<d;){let y=1+(t<<1),v=o[y];const w=y+1;if(w<this.length&&c(o[w],v)<0&&(y=w,v=o[w]),c(v,m)>=0)break;o[t]=v,t=y}o[t]=m}}function gI(a,t){return a<t?-1:a>t?1:0}function _I(a,t=1,o=!1){let c=1/0,d=1/0,m=-1/0,y=-1/0;const v=a[0];for(let V=0;V<v.length;V++){const j=v[V];(!V||j.x<c)&&(c=j.x),(!V||j.y<d)&&(d=j.y),(!V||j.x>m)&&(m=j.x),(!V||j.y>y)&&(y=j.y)}const w=Math.min(m-c,y-d);let A=w/2;const D=new mI([],yI);if(w===0)return new E(c,d);for(let V=c;V<m;V+=w)for(let j=d;j<y;j+=w)D.push(new $u(V+A,j+A,A,a));let R=function(V){let j=0,$=0,ne=0;const me=V[0];for(let ke=0,He=me.length,Ze=He-1;ke<He;Ze=ke++){const Xe=me[ke],Ye=me[Ze],lt=Xe.x*Ye.y-Ye.x*Xe.y;$+=(Xe.x+Ye.x)*lt,ne+=(Xe.y+Ye.y)*lt,j+=3*lt}return new $u($/j,ne/j,0,V)}(a),k=D.length;for(;D.length;){const V=D.pop();(V.d>R.d||!R.d)&&(R=V,o&&console.log("found best %d after %d probes",Math.round(1e4*V.d)/1e4,k)),V.max-R.d<=t||(A=V.h/2,D.push(new $u(V.p.x-A,V.p.y-A,A,a)),D.push(new $u(V.p.x+A,V.p.y-A,A,a)),D.push(new $u(V.p.x-A,V.p.y+A,A,a)),D.push(new $u(V.p.x+A,V.p.y+A,A,a)),k+=4)}return o&&(console.log(`num probes: ${k}`),console.log(`best distance: ${R.d}`)),R.p}function yI(a,t){return t.max-a.max}function $u(a,t,o,c){this.p=new E(a,t),this.h=o,this.d=function(d,m){let y=!1,v=1/0;for(let w=0;w<m.length;w++){const A=m[w];for(let D=0,R=A.length,k=R-1;D<R;k=D++){const V=A[D],j=A[k];V.y>d.y!=j.y>d.y&&d.x<(j.x-V.x)*(d.y-V.y)/(j.y-V.y)+V.x&&(y=!y),v=Math.min(v,rb(d,V,j))}}return(y?1:-1)*Math.sqrt(v)}(this.p,c),this.max=this.d+this.h*Math.SQRT2}const Pv=Number.POSITIVE_INFINITY,vI=Math.sqrt(2);function cw(a,t){return t[1]!==Pv?function(o,c,d){let m=0,y=0;switch(c=Math.abs(c),d=Math.abs(d),o){case"top-right":case"top-left":case"top":y=d-7;break;case"bottom-right":case"bottom-left":case"bottom":y=7-d}switch(o){case"top-right":case"bottom-right":case"right":m=-c;break;case"top-left":case"bottom-left":case"left":m=c}return[m,y]}(a,t[0],t[1]):function(o,c){let d=0,m=0;c<0&&(c=0);const y=c/vI;switch(o){case"top-right":case"top-left":m=y-7;break;case"bottom-right":case"bottom-left":m=7-y;break;case"bottom":m=7-c;break;case"top":m=c-7}switch(o){case"top-right":case"bottom-right":d=-y;break;case"top-left":case"bottom-left":d=y;break;case"left":d=c;break;case"right":d=-c}return[d,m]}(a,t[0])}function xI(a,t,o,c,d,m,y,v,w,A){a.createArrays(),a.tilePixelRatio=In/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const D=a.layers[0].layout,R=a.layers[0]._unevaluatedLayout._values,k={};if(a.textSizeData.kind==="composite"){const{minZoom:$,maxZoom:ne}=a.textSizeData;k.compositeTextSizes=[R["text-size"].possiblyEvaluate(new ci($),v),R["text-size"].possiblyEvaluate(new ci(ne),v)]}if(a.iconSizeData.kind==="composite"){const{minZoom:$,maxZoom:ne}=a.iconSizeData;k.compositeIconSizes=[R["icon-size"].possiblyEvaluate(new ci($),v),R["icon-size"].possiblyEvaluate(new ci(ne),v)]}k.layoutTextSize=R["text-size"].possiblyEvaluate(new ci(w+1),v),k.layoutIconSize=R["icon-size"].possiblyEvaluate(new ci(w+1),v),k.textMaxSize=R["text-size"].possiblyEvaluate(new ci(18),v);const V=D.get("text-rotation-alignment")==="map"&&D.get("symbol-placement")!=="point",j=D.get("text-size");for(const $ of a.features){const ne=D.get("text-font").evaluate($,{},v).join(","),me=j.evaluate($,{},v),ke=k.layoutTextSize.evaluate($,{},v),He=(k.layoutIconSize.evaluate($,{},v),{horizontal:{},vertical:void 0}),Ze=$.text;let Xe,Ye=[0,0];if(Ze){const vt=Ze.toString(),Tt=D.get("text-letter-spacing").evaluate($,{},v)*ar,rt=D.get("text-line-height").evaluate($,{},v)*ar,ft=og(vt)?Tt:0,Ct=D.get("text-anchor").evaluate($,{},v),Bt=D.get("text-variable-anchor");if(!Bt){const Bn=D.get("text-radial-offset").evaluate($,{},v);Ye=Bn?cw(Ct,[Bn*ar,Pv]):D.get("text-offset").evaluate($,{},v).map(Kt=>Kt*ar)}let It=V?"center":D.get("text-justify").evaluate($,{},v);const kt=D.get("symbol-placement"),En=kt==="point",Un=kt==="point"?D.get("text-max-width").evaluate($,{},v)*ar:0,An=Bn=>{a.allowVerticalPlacement&&Du(vt)&&(He.vertical=Ev(Ze,t,o,d,ne,Un,rt,Ct,Bn,ft,Ye,_a.vertical,!0,kt,ke,me))};if(!V&&Bt){const Bn=It==="auto"?Bt.map(Wt=>Lv(Wt)):[It];let Kt=!1;for(let Wt=0;Wt<Bn.length;Wt++){const Vn=Bn[Wt];if(!He.horizontal[Vn])if(Kt)He.horizontal[Vn]=He.horizontal[0];else{const Jn=Ev(Ze,t,o,d,ne,Un,rt,"center",Vn,ft,Ye,_a.horizontal,!1,kt,ke,me);Jn&&(He.horizontal[Vn]=Jn,Kt=Jn.positionedLines.length===1)}}An("left")}else{if(It==="auto"&&(It=Lv(Ct)),En||D.get("text-writing-mode").indexOf("horizontal")>=0||!Du(vt)){const Bn=Ev(Ze,t,o,d,ne,Un,rt,Ct,It,ft,Ye,_a.horizontal,!1,kt,ke,me);Bn&&(He.horizontal[It]=Bn)}An(kt==="point"?"left":It)}}let lt=!1;if($.icon&&$.icon.name){const vt=c[$.icon.name];vt&&(Xe=hI(d[$.icon.name],D.get("icon-offset").evaluate($,{},v),D.get("icon-anchor").evaluate($,{},v)),lt=vt.sdf,a.sdfIcons===void 0?a.sdfIcons=vt.sdf:a.sdfIcons!==vt.sdf&&ge("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(vt.pixelRatio!==a.pixelRatio||D.get("icon-rotate").constantOr(1)!==0)&&(a.iconsNeedLinear=!0))}const ht=hw(He.horizontal)||He.vertical;a.iconsInText||(a.iconsInText=!!ht&&ht.iconsInText),(ht||Xe)&&bI(a,$,He,Xe,c,k,ke,0,Ye,lt,y,v,A)}m&&a.generateCollisionDebugBuffers(w,a.collisionBoxArray)}function Lv(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function bI(a,t,o,c,d,m,y,v,w,A,D,R,k){let V=m.textMaxSize.evaluate(t,{},R);V===void 0&&(V=y);const j=a.layers[0].layout,$=j.get("icon-offset").evaluate(t,{},R),ne=hw(o.horizontal)||o.vertical,me=y/24,ke=a.tilePixelRatio*V/24,He=(rt=a.overscaling,a.zoom>18&&rt>2&&(rt>>=1),Math.max(In/(512*rt),1)*j.get("symbol-spacing")),Ze=j.get("text-padding")*a.tilePixelRatio,Xe=j.get("icon-padding")*a.tilePixelRatio,Ye=U(j.get("text-max-angle")),lt=j.get("text-rotation-alignment")==="map"&&j.get("symbol-placement")!=="point",ht=j.get("icon-rotation-alignment")==="map"&&j.get("symbol-placement")!=="point",vt=j.get("symbol-placement"),Tt=He/2;var rt;const ft=j.get("icon-text-fit");let Ct;c&&ft!=="none"&&(a.allowVerticalPlacement&&o.vertical&&(Ct=Kb(c,o.vertical,ft,j.get("icon-text-fit-padding"),$,me)),ne&&(c=Kb(c,ne,ft,j.get("icon-text-fit-padding"),$,me)));const Bt=(It,kt,En)=>{if(kt.x<0||kt.x>=In||kt.y<0||kt.y>=In)return;const{x:Un,y:An,z:Bn}=k.projectTilePoint(kt.x,kt.y,En),Kt=new Jo(Un,An,Bn,0,void 0);(function(Wt,Vn,Jn,Fi,ui,Oi,Kn,Hn,ni,wi,Si,Ni,Yi,Kr,Br,ii,vr,Qr,er,$i,fi,hi,Fr,xr,Ii){const br=Wt.addToLineVertexArray(Vn,Fi);let hr,Ji,Sa,js,zp,kp,Zw,Xw=0,Yw=0,$w=0,Jw=0,Zv=-1,Xv=-1;const bo={};let Kw=fo(""),Yv=0,$v=0;if(ni._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Yv,$v]=ni.layout.get("text-offset").evaluate(fi,{},Ii).map(ea=>ea*ar):(Yv=ni.layout.get("text-radial-offset").evaluate(fi,{},Ii)*ar,$v=Pv),Wt.allowVerticalPlacement&&ui.vertical){const ea=ui.vertical;if(Br)kp=Dv(ea),Hn&&(Zw=Dv(Hn));else{const ta=ni.layout.get("text-rotate").evaluate(fi,{},Ii)+90;Sa=Dg(wi,Jn,Vn,Si,Ni,Yi,ea,Kr,ta,ii),Hn&&(js=Dg(wi,Jn,Vn,Si,Ni,Yi,Hn,Qr,ta))}}if(Oi){const ea=ni.layout.get("icon-rotate").evaluate(fi,{},Ii),ta=ni.layout.get("icon-text-fit")!=="none",Bp=sw(Oi,ea,Fr,ta),Kv=Hn?sw(Hn,ea,Fr,ta):void 0;Ji=Dg(wi,Jn,Vn,Si,Ni,Yi,Oi,Qr,ea),Xw=4*Bp.length;const Qw=Wt.iconSizeData;let $l=null;Qw.kind==="source"?($l=[_o*ni.layout.get("icon-size").evaluate(fi,{},Ii)],$l[0]>Ns&&ge(`${Wt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Qw.kind==="composite"&&($l=[_o*hi.compositeIconSizes[0].evaluate(fi,{},Ii),_o*hi.compositeIconSizes[1].evaluate(fi,{},Ii)],($l[0]>Ns||$l[1]>Ns)&&ge(`${Wt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Wt.addSymbols(Wt.icon,Bp,$l,$i,er,fi,!1,Jn,Vn,br.lineStartIndex,br.lineLength,-1,xr,Ii),Zv=Wt.icon.placedSymbolArray.length-1,Kv&&(Yw=4*Kv.length,Wt.addSymbols(Wt.icon,Kv,$l,$i,er,fi,_a.vertical,Jn,Vn,br.lineStartIndex,br.lineLength,-1,xr,Ii),Xv=Wt.icon.placedSymbolArray.length-1)}for(const ea in ui.horizontal){const ta=ui.horizontal[ea];hr||(Kw=fo(ta.text),Br?zp=Dv(ta):hr=Dg(wi,Jn,Vn,Si,Ni,Yi,ta,Kr,ni.layout.get("text-rotate").evaluate(fi,{},Ii),ii));const Bp=ta.positionedLines.length===1;if($w+=uw(Wt,Jn,Vn,ta,Kn,ni,Br,fi,ii,br,ui.vertical?_a.horizontal:_a.horizontalOnly,Bp?Object.keys(ui.horizontal):[ea],bo,Zv,hi,xr,Ii),Bp)break}ui.vertical&&(Jw+=uw(Wt,Jn,Vn,ui.vertical,Kn,ni,Br,fi,ii,br,_a.vertical,["vertical"],bo,Xv,hi,xr,Ii));let qs=-1;const Jv=(ea,ta)=>ea?Math.max(ea,ta):ta;qs=Jv(zp,qs),qs=Jv(kp,qs),qs=Jv(Zw,qs);const tR=qs>-1?1:0;Wt.glyphOffsetArray.length>=Us.MAX_GLYPHS&&ge("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),fi.sortKey!==void 0&&Wt.addToSortKeyRanges(Wt.symbolInstances.length,fi.sortKey),Wt.symbolInstances.emplaceBack(Jn.x,Jn.y,Jn.z,Vn.x,Vn.y,bo.right>=0?bo.right:-1,bo.center>=0?bo.center:-1,bo.left>=0?bo.left:-1,bo.vertical>=0?bo.vertical:-1,Zv,Xv,Kw,hr!==void 0?hr:Wt.collisionBoxArray.length,hr!==void 0?hr+1:Wt.collisionBoxArray.length,Sa!==void 0?Sa:Wt.collisionBoxArray.length,Sa!==void 0?Sa+1:Wt.collisionBoxArray.length,Ji!==void 0?Ji:Wt.collisionBoxArray.length,Ji!==void 0?Ji+1:Wt.collisionBoxArray.length,js||Wt.collisionBoxArray.length,js?js+1:Wt.collisionBoxArray.length,Si,$w,Jw,Xw,Yw,tR,0,Yv,$v,qs)})(a,kt,Kt,It,o,c,d,Ct,a.layers[0],a.collisionBoxArray,t.index,t.sourceLayerIndex,a.index,Ze,lt,w,0,Xe,ht,$,t,m,A,D,R)};if(vt==="line")for(const It of rw(t.geometry,0,0,In,In)){const kt=pI(It,He,Ye,o.vertical||ne,c,24,ke,a.overscaling,In);for(const En of kt){const Un=ne;Un&&wI(a,Un.text,Tt,En)||Bt(It,En,R)}}else if(vt==="line-center"){for(const It of t.geometry)if(It.length>1){const kt=dI(It,Ye,o.vertical||ne,c,24,ke);kt&&Bt(It,kt,R)}}else if(t.type==="Polygon")for(const It of yv(t.geometry,0)){const kt=_I(It,16);Bt(It[0],new Jo(kt.x,kt.y,0,0,void 0),R)}else if(t.type==="LineString")for(const It of t.geometry)Bt(It,new Jo(It[0].x,It[0].y,0,0,void 0),R);else if(t.type==="Point")for(const It of t.geometry)for(const kt of It)Bt([kt],new Jo(kt.x,kt.y,0,0,void 0),R)}const Ns=32640;function uw(a,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$,ne){const me=function(Ze,Xe,Ye,lt,ht,vt,Tt,rt){const ft=[];if(Xe.positionedLines.length===0)return ft;const Ct=lt.layout.get("text-rotate").evaluate(vt,{})*Math.PI/180,Bt=function(An){const Bn=An[0],Kt=An[1],Wt=Bn*Kt;return Wt>0?[Bn,-Kt]:Wt<0?[-Bn,Kt]:Bn===0?[Kt,Bn]:[Kt,-Bn]}(Ye);let It=Math.abs(Xe.top-Xe.bottom);for(const An of Xe.positionedLines)It-=An.lineOffset;const kt=Xe.positionedLines.length,En=It/kt;let Un=Xe.top-Ye[1];for(let An=0;An<kt;++An){const Bn=Xe.positionedLines[An];Un=fI(Xe,En,Un,An);for(const Kt of Bn.positionedGlyphs){if(!Kt.rect)continue;const Wt=Kt.rect||{};let Vn=4,Jn=!0,Fi=1,ui=0;if(Kt.imageName){const hi=Tt[Kt.imageName];if(!hi)continue;if(hi.sdf){ge("SDF images are not supported in formatted text and will be ignored.");continue}Jn=!1,Fi=hi.pixelRatio,Vn=1/Fi}const Oi=(ht||rt)&&Kt.vertical,Kn=Kt.metrics.advance*Kt.scale/2,Hn=Kt.metrics,ni=Kt.rect;if(ni===null)continue;rt&&Xe.verticalizable&&(ui=Kt.imageName?Kn-Kt.metrics.width*Kt.scale/2:0);const wi=ht?[Kt.x+Kn,Kt.y]:[0,0];let Si=[0,0],Ni=[0,0],Yi=!1;ht||(Oi?(Ni=[Kt.x+Kn+Bt[0],Kt.y+Bt[1]-ui],Yi=!0):Si=[Kt.x+Kn+Ye[0],Kt.y+Ye[1]-ui]);const Kr=ni.w*Kt.scale/(Fi*(Kt.localGlyph?2:1)),Br=ni.h*Kt.scale/(Fi*(Kt.localGlyph?2:1));let ii,vr,Qr,er;if(Oi){const hi=Kt.y-Un,Fr=new E(-Kn,Kn-hi),xr=-Math.PI/2,Ii=new E(...Ni);ii=new E(-Kn+Si[0],Si[1]),ii._rotateAround(xr,Fr)._add(Ii),ii.x+=-hi+Kn,ii.y-=(Hn.left-Vn)*Kt.scale;const br=Kt.imageName?Hn.advance*Kt.scale:ar*Kt.scale,hr=String.fromCharCode(Kt.glyph);YD(hr)?ii.x+=(1-Vn)*Kt.scale:$D(hr)?ii.x+=br-Hn.height*Kt.scale+(-Vn-1)*Kt.scale:ii.x+=Kt.imageName||Hn.width+2*Vn===ni.w&&Hn.height+2*Vn===ni.h?(br-Br)/2:(br-(Hn.height+2*Vn)*Kt.scale)/2,vr=new E(ii.x,ii.y-Kr),Qr=new E(ii.x+Br,ii.y),er=new E(ii.x+Br,ii.y-Kr)}else{const hi=(Hn.left-Vn)*Kt.scale-Kn+Si[0],Fr=(-Hn.top-Vn)*Kt.scale+Si[1],xr=hi+Kr,Ii=Fr+Br;ii=new E(hi,Fr),vr=new E(xr,Fr),Qr=new E(hi,Ii),er=new E(xr,Ii)}if(Ct){let hi;hi=ht?new E(0,0):Yi?new E(Bt[0],Bt[1]):new E(Ye[0],Ye[1]),ii._rotateAround(Ct,hi),vr._rotateAround(Ct,hi),Qr._rotateAround(Ct,hi),er._rotateAround(Ct,hi)}const $i=new E(0,0),fi=new E(0,0);ft.push({tl:ii,tr:vr,bl:Qr,br:er,tex:Wt,writingMode:Xe.writingMode,glyphOffset:wi,sectionIndex:Kt.sectionIndex,isSDF:Jn,pixelOffsetTL:$i,pixelOffsetBR:fi,minFontScaleX:0,minFontScaleY:0})}}return ft}(0,c,w,m,y,v,d,a.allowVerticalPlacement),ke=a.textSizeData;let He=null;ke.kind==="source"?(He=[_o*m.layout.get("text-size").evaluate(v,{},ne)],He[0]>Ns&&ge(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):ke.kind==="composite"&&(He=[_o*j.compositeTextSizes[0].evaluate(v,{},ne),_o*j.compositeTextSizes[1].evaluate(v,{},ne)],(He[0]>Ns||He[1]>Ns)&&ge(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),a.addSymbols(a.text,me,He,w,y,v,D,t,o,A.lineStartIndex,A.lineLength,V,$,ne);for(const Ze of R)k[Ze]=a.text.placedSymbolArray.length-1;return 4*me.length}function hw(a){for(const t in a)return a[t];return null}function Dg(a,t,o,c,d,m,y,v,w,A){let D=y.top,R=y.bottom,k=y.left,V=y.right;const j=y.collisionPadding;if(j&&(k-=j[0],D-=j[1],V+=j[2],R+=j[3]),w){const $=new E(k,D),ne=new E(V,D),me=new E(k,R),ke=new E(V,R),He=U(w);let Ze=new E(0,0);A&&(Ze=new E(A[0],A[1])),$._rotateAround(He,Ze),ne._rotateAround(He,Ze),me._rotateAround(He,Ze),ke._rotateAround(He,Ze),k=Math.min($.x,ne.x,me.x,ke.x),V=Math.max($.x,ne.x,me.x,ke.x),D=Math.min($.y,ne.y,me.y,ke.y),R=Math.max($.y,ne.y,me.y,ke.y)}return a.emplaceBack(t.x,t.y,t.z,o.x,o.y,k,D,V,R,v,c,d,m),a.length-1}function Dv(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const t=a.bottom-a.top;return t>0?Math.max(10,t):null}function wI(a,t,o,c){const d=a.compareText;if(t in d){const m=d[t];for(let y=m.length-1;y>=0;y--)if(c.dist(m[y])<o)return!0}else d[t]=[];return d[t].push(c),!1}const MI=Zl.VectorTileFeature.types,TI=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Ig(a,t,o,c,d,m,y,v,w,A,D,R,k,V,j,$){const ne=D?Math.min(Ns,Math.round(D[0])):0,me=D?Math.min(Ns,Math.round(D[1])):0;a.emplaceBack(t,o,Math.round(32*y),Math.round(32*v),w,A,(ne<<1)+(R?1:0),me,16*k,16*V,256*j,256*$,c,d,m,0)}function Iv(a,t,o){a.emplaceBack(t.x,t.y,o),a.emplaceBack(t.x,t.y,o),a.emplaceBack(t.x,t.y,o),a.emplaceBack(t.x,t.y,o)}function EI(a){for(const t of a.sections)if(Zy(t.text))return!0;return!1}class Rv{constructor(t){this.layoutVertexArray=new ut,this.indexArray=new qt,this.programConfigurations=t,this.segments=new Ei,this.dynamicLayoutVertexArray=new Rt,this.opacityVertexArray=new et,this.placedSymbolArray=new Va}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,o,c,d){this.isEmpty()||(c&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,GD.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,o),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,HD.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,TI,!0),this.opacityVertexBuffer.itemSize=1),(c||d)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}jt(Rv,"SymbolBuffers");class zv{constructor(t,o,c){this.layoutVertexArray=new t,this.layoutAttributes=o,this.indexArray=new c,this.segments=new Ei,this.collisionVertexArray=new pt,this.collisionVertexArrayExt=new Rt}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,WD.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,jD.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}jt(zv,"CollisionBuffers");class Us{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(y=>y.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=go([]),this.placementViewportMatrix=go([]);const o=this.layers[0]._unevaluatedLayout._values;this.textSizeData=bv(this.zoom,o["text-size"]),this.iconSizeData=bv(this.zoom,o["icon-size"]);const c=this.layers[0].layout,d=c.get("symbol-sort-key"),m=c.get("symbol-z-order");this.canOverlap=c.get("text-allow-overlap")||c.get("icon-allow-overlap")||c.get("text-ignore-placement")||c.get("icon-ignore-placement"),this.sortFeaturesByKey=m!=="viewport-y"&&d.constantOr(1)!==void 0,this.sortFeaturesByY=(m==="viewport-y"||m==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=c.get("text-writing-mode").map(y=>_a[y]),this.stateDependentLayerIds=this.layers.filter(y=>y.isStateDependent()).map(y=>y.id),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Rv(new Hl(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Rv(new Hl(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new $n,this.lineVertexArray=new Li,this.symbolInstances=new Ti}calculateGlyphDependencies(t,o,c,d,m){for(let y=0;y<t.length;y++)if(o[t.charCodeAt(y)]=!0,d&&m){const v=wp[t.charAt(y)];v&&(o[v.charCodeAt(0)]=!0)}}populate(t,o,c,d){const m=this.layers[0],y=m.layout,v=y.get("text-font"),w=y.get("text-field"),A=y.get("icon-image"),D=(w.value.kind!=="constant"||w.value.value instanceof Bi&&!w.value.value.isEmpty()||w.value.value.toString().length>0)&&(v.value.kind!=="constant"||v.value.value.length>0),R=A.value.kind!=="constant"||!!A.value.value||Object.keys(A.parameters).length>0,k=y.get("symbol-sort-key");if(this.features=[],!D&&!R)return;const V=o.iconDependencies,j=o.glyphDependencies,$=o.availableImages,ne=new ci(this.zoom);for(const{feature:me,id:ke,index:He,sourceLayerIndex:Ze}of t){const Xe=m._featureFilter.needGeometry,Ye=Wl(me,Xe);if(!m._featureFilter.filter(ne,Ye,c))continue;let lt,ht;if(Xe||(Ye.geometry=Xo(me,c,d)),D){const Tt=m.getValueAndResolveTokens("text-field",Ye,c,$),rt=Bi.factory(Tt);EI(rt)&&(this.hasRTLText=!0),(!this.hasRTLText||ku()==="unavailable"||this.hasRTLText&&qr.isParsed())&&(lt=XD(rt,m,Ye))}if(R){const Tt=m.getValueAndResolveTokens("icon-image",Ye,c,$);ht=Tt instanceof Cr?Tt:Cr.fromString(Tt)}if(!lt&&!ht)continue;const vt=this.sortFeaturesByKey?k.evaluate(Ye,{},c):void 0;if(this.features.push({id:ke,text:lt,icon:ht,index:He,sourceLayerIndex:Ze,geometry:Ye.geometry,properties:me.properties,type:MI[me.type],sortKey:vt}),ht&&(V[ht.name]=!0),lt){const Tt=v.evaluate(Ye,{},c).join(","),rt=y.get("text-rotation-alignment")==="map"&&y.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(_a.vertical)>=0;for(const ft of lt.sections)if(ft.image)V[ft.image.name]=!0;else{const Ct=Du(lt.toString()),Bt=ft.fontStack||Tt,It=j[Bt]=j[Bt]||{};this.calculateGlyphDependencies(ft.text,It,rt,this.allowVerticalPlacement,Ct)}}}y.get("symbol-placement")==="line"&&(this.features=function(me){const ke={},He={},Ze=[];let Xe=0;function Ye(Tt){Ze.push(me[Tt]),Xe++}function lt(Tt,rt,ft){const Ct=He[Tt];return delete He[Tt],He[rt]=Ct,Ze[Ct].geometry[0].pop(),Ze[Ct].geometry[0]=Ze[Ct].geometry[0].concat(ft[0]),Ct}function ht(Tt,rt,ft){const Ct=ke[rt];return delete ke[rt],ke[Tt]=Ct,Ze[Ct].geometry[0].shift(),Ze[Ct].geometry[0]=ft[0].concat(Ze[Ct].geometry[0]),Ct}function vt(Tt,rt,ft){const Ct=ft?rt[0][rt[0].length-1]:rt[0][0];return`${Tt}:${Ct.x}:${Ct.y}`}for(let Tt=0;Tt<me.length;Tt++){const rt=me[Tt],ft=rt.geometry,Ct=rt.text?rt.text.toString():null;if(!Ct){Ye(Tt);continue}const Bt=vt(Ct,ft),It=vt(Ct,ft,!0);if(Bt in He&&It in ke&&He[Bt]!==ke[It]){const kt=ht(Bt,It,ft),En=lt(Bt,It,Ze[kt].geometry);delete ke[Bt],delete He[It],He[vt(Ct,Ze[En].geometry,!0)]=En,Ze[kt].geometry=null}else Bt in He?lt(Bt,It,ft):It in ke?ht(Bt,It,ft):(Ye(Tt),ke[Bt]=Xe-1,He[It]=Xe-1)}return Ze.filter(Tt=>Tt.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((me,ke)=>me.sortKey-ke.sortKey)}update(t,o,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,o,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(t,o,this.layers,c,d))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,o){const c=this.lineVertexArray.length,d=t.segment;if(d!==void 0){let m=t.dist(o[d+1]),y=t.dist(o[d]);const v={};for(let w=d+1;w<o.length;w++)v[w]={x:o[w].x,y:o[w].y,tileUnitDistanceFromAnchor:m},w<o.length-1&&(m+=o[w+1].dist(o[w]));for(let w=d||0;w>=0;w--)v[w]={x:o[w].x,y:o[w].y,tileUnitDistanceFromAnchor:y},w>0&&(y+=o[w-1].dist(o[w]));for(let w=0;w<o.length;w++){const A=v[w];this.lineVertexArray.emplaceBack(A.x,A.y,A.tileUnitDistanceFromAnchor)}}return{lineStartIndex:c,lineLength:this.lineVertexArray.length-c}}addSymbols(t,o,c,d,m,y,v,w,A,D,R,k,V,j){const $=t.indexArray,ne=t.layoutVertexArray,me=t.segments.prepareSegment(4*o.length,ne,$,this.canOverlap?y.sortKey:void 0),ke=this.glyphOffsetArray.length,He=me.vertexLength,Ze=this.allowVerticalPlacement&&v===_a.vertical?Math.PI/2:0,Xe=y.text&&y.text.sections;for(let Ye=0;Ye<o.length;Ye++){const{tl:lt,tr:ht,bl:vt,br:Tt,tex:rt,pixelOffsetTL:ft,pixelOffsetBR:Ct,minFontScaleX:Bt,minFontScaleY:It,glyphOffset:kt,isSDF:En,sectionIndex:Un}=o[Ye],An=me.vertexLength,Bn=kt[1];Ig(ne,w.x,w.y,w.z,A.x,A.y,lt.x,Bn+lt.y,rt.x,rt.y,c,En,ft.x,ft.y,Bt,It),Ig(ne,w.x,w.y,w.z,A.x,A.y,ht.x,Bn+ht.y,rt.x+rt.w,rt.y,c,En,Ct.x,ft.y,Bt,It),Ig(ne,w.x,w.y,w.z,A.x,A.y,vt.x,Bn+vt.y,rt.x,rt.y+rt.h,c,En,ft.x,Ct.y,Bt,It),Ig(ne,w.x,w.y,w.z,A.x,A.y,Tt.x,Bn+Tt.y,rt.x+rt.w,rt.y+rt.h,c,En,Ct.x,Ct.y,Bt,It),Iv(t.dynamicLayoutVertexArray,w,Ze),$.emplaceBack(An,An+1,An+2),$.emplaceBack(An+1,An+2,An+3),me.vertexLength+=4,me.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(kt[0]),Ye!==o.length-1&&Un===o[Ye+1].sectionIndex||t.programConfigurations.populatePaintArrays(ne.length,y,y.index,{},V,j,Xe&&Xe[Un])}t.placedSymbolArray.emplaceBack(w.x,w.y,w.z,A.x,A.y,ke,this.glyphOffsetArray.length-ke,He,D,R,A.segment,c?c[0]:0,c?c[1]:0,d[0],d[1],v,0,!1,0,k,0)}_commitLayoutVertex(t,o,c,d,m,y,v){t.emplaceBack(o,c,d,m,y,Math.round(v.x),Math.round(v.y))}_addCollisionDebugVertices(t,o,c,d,m,y,v){const w=c.segments.prepareSegment(4,c.layoutVertexArray,c.indexArray),A=w.vertexLength,D=v.tileAnchorX,R=v.tileAnchorY;for(let V=0;V<4;V++)c.collisionVertexArray.emplaceBack(0,0,0,0);c.collisionVertexArrayExt.emplaceBack(o,-t.padding,-t.padding),c.collisionVertexArrayExt.emplaceBack(o,t.padding,-t.padding),c.collisionVertexArrayExt.emplaceBack(o,t.padding,t.padding),c.collisionVertexArrayExt.emplaceBack(o,-t.padding,t.padding),this._commitLayoutVertex(c.layoutVertexArray,d,m,y,D,R,new E(t.x1,t.y1)),this._commitLayoutVertex(c.layoutVertexArray,d,m,y,D,R,new E(t.x2,t.y1)),this._commitLayoutVertex(c.layoutVertexArray,d,m,y,D,R,new E(t.x2,t.y2)),this._commitLayoutVertex(c.layoutVertexArray,d,m,y,D,R,new E(t.x1,t.y2)),w.vertexLength+=4;const k=c.indexArray;k.emplaceBack(A,A+1),k.emplaceBack(A+1,A+2),k.emplaceBack(A+2,A+3),k.emplaceBack(A+3,A),w.primitiveLength+=4}_addTextDebugCollisionBoxes(t,o,c,d,m,y){for(let v=d;v<m;v++){const w=c.get(v),A=this.getSymbolInstanceTextSize(t,y,o,v);this._addCollisionDebugVertices(w,A,this.textCollisionBox,w.projectedAnchorX,w.projectedAnchorY,w.projectedAnchorZ,y)}}_addIconDebugCollisionBoxes(t,o,c,d,m,y){for(let v=d;v<m;v++){const w=c.get(v),A=this.getSymbolInstanceIconSize(t,o,v);this._addCollisionDebugVertices(w,A,this.iconCollisionBox,w.projectedAnchorX,w.projectedAnchorY,w.projectedAnchorZ,y)}}generateCollisionDebugBuffers(t,o){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new zv(Pt,Nb.members,Mn),this.iconCollisionBox=new zv(Pt,Nb.members,Mn);const c=ju(this.iconSizeData,t),d=ju(this.textSizeData,t);for(let m=0;m<this.symbolInstances.length;m++){const y=this.symbolInstances.get(m);this._addTextDebugCollisionBoxes(d,t,o,y.textBoxStartIndex,y.textBoxEndIndex,y),this._addTextDebugCollisionBoxes(d,t,o,y.verticalTextBoxStartIndex,y.verticalTextBoxEndIndex,y),this._addIconDebugCollisionBoxes(c,t,o,y.iconBoxStartIndex,y.iconBoxEndIndex,y),this._addIconDebugCollisionBoxes(c,t,o,y.verticalIconBoxStartIndex,y.verticalIconBoxEndIndex,y)}}getSymbolInstanceTextSize(t,o,c,d){const m=this.text.placedSymbolArray.get(o.rightJustifiedTextSymbolIndex>=0?o.rightJustifiedTextSymbolIndex:o.centerJustifiedTextSymbolIndex>=0?o.centerJustifiedTextSymbolIndex:o.leftJustifiedTextSymbolIndex>=0?o.leftJustifiedTextSymbolIndex:o.verticalPlacedTextSymbolIndex>=0?o.verticalPlacedTextSymbolIndex:d),y=Eg(this.textSizeData,t,m)/ar;return this.tilePixelRatio*y}getSymbolInstanceIconSize(t,o,c){const d=this.icon.placedSymbolArray.get(c),m=Eg(this.iconSizeData,t,d);return this.tilePixelRatio*m}_commitDebugCollisionVertexUpdate(t,o,c){t.emplaceBack(o,-c,-c),t.emplaceBack(o,c,-c),t.emplaceBack(o,c,c),t.emplaceBack(o,-c,c)}_updateTextDebugCollisionBoxes(t,o,c,d,m,y){for(let v=d;v<m;v++){const w=c.get(v),A=this.getSymbolInstanceTextSize(t,y,o,v);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,A,w.padding)}}_updateIconDebugCollisionBoxes(t,o,c,d,m){for(let y=d;y<m;y++){const v=c.get(y),w=this.getSymbolInstanceIconSize(t,o,y);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,w,v.padding)}}updateCollisionDebugBuffers(t,o){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const c=ju(this.iconSizeData,t),d=ju(this.textSizeData,t);for(let m=0;m<this.symbolInstances.length;m++){const y=this.symbolInstances.get(m);this._updateTextDebugCollisionBoxes(d,t,o,y.textBoxStartIndex,y.textBoxEndIndex,y),this._updateTextDebugCollisionBoxes(d,t,o,y.verticalTextBoxStartIndex,y.verticalTextBoxEndIndex,y),this._updateIconDebugCollisionBoxes(c,t,o,y.iconBoxStartIndex,y.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(c,t,o,y.verticalIconBoxStartIndex,y.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(t,o,c,d,m,y,v,w,A){const D={};for(let R=o;R<c;R++){const k=t.get(R);D.textBox={x1:k.x1,y1:k.y1,x2:k.x2,y2:k.y2,padding:k.padding,projectedAnchorX:k.projectedAnchorX,projectedAnchorY:k.projectedAnchorY,projectedAnchorZ:k.projectedAnchorZ,tileAnchorX:k.tileAnchorX,tileAnchorY:k.tileAnchorY},D.textFeatureIndex=k.featureIndex;break}for(let R=d;R<m;R++){const k=t.get(R);D.verticalTextBox={x1:k.x1,y1:k.y1,x2:k.x2,y2:k.y2,padding:k.padding,projectedAnchorX:k.projectedAnchorX,projectedAnchorY:k.projectedAnchorY,projectedAnchorZ:k.projectedAnchorZ,tileAnchorX:k.tileAnchorX,tileAnchorY:k.tileAnchorY},D.verticalTextFeatureIndex=k.featureIndex;break}for(let R=y;R<v;R++){const k=t.get(R);D.iconBox={x1:k.x1,y1:k.y1,x2:k.x2,y2:k.y2,padding:k.padding,projectedAnchorX:k.projectedAnchorX,projectedAnchorY:k.projectedAnchorY,projectedAnchorZ:k.projectedAnchorZ,tileAnchorX:k.tileAnchorX,tileAnchorY:k.tileAnchorY},D.iconFeatureIndex=k.featureIndex;break}for(let R=w;R<A;R++){const k=t.get(R);D.verticalIconBox={x1:k.x1,y1:k.y1,x2:k.x2,y2:k.y2,padding:k.padding,projectedAnchorX:k.projectedAnchorX,projectedAnchorY:k.projectedAnchorY,projectedAnchorZ:k.projectedAnchorZ,tileAnchorX:k.tileAnchorX,tileAnchorY:k.tileAnchorY},D.verticalIconFeatureIndex=k.featureIndex;break}return D}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let o=0;o<this.symbolInstances.length;o++){const c=this.symbolInstances.get(o);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,c.textBoxStartIndex,c.textBoxEndIndex,c.verticalTextBoxStartIndex,c.verticalTextBoxEndIndex,c.iconBoxStartIndex,c.iconBoxEndIndex,c.verticalIconBoxStartIndex,c.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,o){const c=t.placedSymbolArray.get(o),d=c.vertexStartIndex+4*c.numGlyphs;for(let m=c.vertexStartIndex;m<d;m+=4)t.indexArray.emplaceBack(m,m+1,m+2),t.indexArray.emplaceBack(m+1,m+2,m+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const o=Math.sin(t),c=Math.cos(t),d=[],m=[],y=[];for(let v=0;v<this.symbolInstances.length;++v){y.push(v);const w=this.symbolInstances.get(v);d.push(0|Math.round(o*w.tileAnchorX+c*w.tileAnchorY)),m.push(w.featureIndex)}return y.sort((v,w)=>d[v]-d[w]||m[w]-m[v]),y}addToSortKeyRanges(t,o){const c=this.sortKeyRanges[this.sortKeyRanges.length-1];c&&c.sortKey===o?c.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:o,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const o of this.symbolInstanceIndexes){const c=this.symbolInstances.get(o);this.featureSortOrder.push(c.featureIndex),[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach((d,m,y)=>{d>=0&&y.indexOf(d)===m&&this.addIndicesForPlacedSymbol(this.text,d)}),c.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,c.verticalPlacedTextSymbolIndex),c.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.placedIconSymbolIndex),c.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}jt(Us,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Us.MAX_GLYPHS=65535,Us.addDynamicAttributes=Iv;const SI=new H({"symbol-placement":new S(xe.layout_symbol["symbol-placement"]),"symbol-spacing":new S(xe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new S(xe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new P(xe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new S(xe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new S(xe.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new S(xe.layout_symbol["icon-ignore-placement"]),"icon-optional":new S(xe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new S(xe.layout_symbol["icon-rotation-alignment"]),"icon-size":new P(xe.layout_symbol["icon-size"]),"icon-text-fit":new S(xe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new S(xe.layout_symbol["icon-text-fit-padding"]),"icon-image":new P(xe.layout_symbol["icon-image"]),"icon-rotate":new P(xe.layout_symbol["icon-rotate"]),"icon-padding":new S(xe.layout_symbol["icon-padding"]),"icon-keep-upright":new S(xe.layout_symbol["icon-keep-upright"]),"icon-offset":new P(xe.layout_symbol["icon-offset"]),"icon-anchor":new P(xe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new S(xe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new S(xe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new S(xe.layout_symbol["text-rotation-alignment"]),"text-field":new P(xe.layout_symbol["text-field"]),"text-font":new P(xe.layout_symbol["text-font"]),"text-size":new P(xe.layout_symbol["text-size"]),"text-max-width":new P(xe.layout_symbol["text-max-width"]),"text-line-height":new P(xe.layout_symbol["text-line-height"]),"text-letter-spacing":new P(xe.layout_symbol["text-letter-spacing"]),"text-justify":new P(xe.layout_symbol["text-justify"]),"text-radial-offset":new P(xe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new S(xe.layout_symbol["text-variable-anchor"]),"text-anchor":new P(xe.layout_symbol["text-anchor"]),"text-max-angle":new S(xe.layout_symbol["text-max-angle"]),"text-writing-mode":new S(xe.layout_symbol["text-writing-mode"]),"text-rotate":new P(xe.layout_symbol["text-rotate"]),"text-padding":new S(xe.layout_symbol["text-padding"]),"text-keep-upright":new S(xe.layout_symbol["text-keep-upright"]),"text-transform":new P(xe.layout_symbol["text-transform"]),"text-offset":new P(xe.layout_symbol["text-offset"]),"text-allow-overlap":new S(xe.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new S(xe.layout_symbol["text-ignore-placement"]),"text-optional":new S(xe.layout_symbol["text-optional"])});var kv={paint:new H({"icon-opacity":new P(xe.paint_symbol["icon-opacity"]),"icon-color":new P(xe.paint_symbol["icon-color"]),"icon-halo-color":new P(xe.paint_symbol["icon-halo-color"]),"icon-halo-width":new P(xe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new P(xe.paint_symbol["icon-halo-blur"]),"icon-translate":new S(xe.paint_symbol["icon-translate"]),"icon-translate-anchor":new S(xe.paint_symbol["icon-translate-anchor"]),"text-opacity":new P(xe.paint_symbol["text-opacity"]),"text-color":new P(xe.paint_symbol["text-color"],{runtimeType:fn,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new P(xe.paint_symbol["text-halo-color"]),"text-halo-width":new P(xe.paint_symbol["text-halo-width"]),"text-halo-blur":new P(xe.paint_symbol["text-halo-blur"]),"text-translate":new S(xe.paint_symbol["text-translate"]),"text-translate-anchor":new S(xe.paint_symbol["text-translate-anchor"])}),layout:SI};class dw{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Dn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const o=this.defaultValue.property.overrides;if(o&&o.hasOverride(t.formattedSection))return o.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}jt(dw,"FormatSectionOverride",{omit:["defaultValue"]});class Rg extends Ha{constructor(t){super(t,kv)}recalculate(t,o){super.recalculate(t,o),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const c=this.layout.get("text-writing-mode");if(c){const d=[];for(const m of c)d.indexOf(m)<0&&d.push(m);this.layout._values["text-writing-mode"]=d}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,o,c,d){const m=this.layout.get(t).evaluate(o,{},c,d),y=this._unevaluatedLayout._values[t];return y.isDataDriven()||Ss(y.value)||!m?m:function(v,w){return w.replace(/{([^{}]+)}/g,(A,D)=>D in v?String(v[D]):"")}(o.properties,m)}createBucket(t){return new Us(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of kv.paint.overridableProperties){if(!Rg.hasPaintOverride(this.layout,t))continue;const o=this.paint.get(t),c=new dw(o),d=new bu(c,o.property.specification);let m=null;m=o.value.kind==="constant"||o.value.kind==="source"?new Nd("source",d):new Ud("composite",d,o.value.zoomStops,o.value._interpolationType),this.paint._values[t]=new x(o.property,m,o.parameters)}}_handleOverridablePaintPropertyUpdate(t,o,c){return!(!this.layout||o.isDataDriven()||c.isDataDriven())&&Rg.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,o){const c=t.get("text-field"),d=kv.paint.properties[o];let m=!1;const y=v=>{for(const w of v)if(d.overrides&&d.overrides.hasOverride(w))return void(m=!0)};if(c.value.kind==="constant"&&c.value.value instanceof Bi)y(c.value.value.sections);else if(c.value.kind==="source"){const v=A=>{m||(A instanceof Ba&&Pi(A.value)===Ar?y(A.value.sections):A instanceof bs?y(A.sections):A.eachChild(v))},w=c.value;w._styleExpression&&v(w._styleExpression.expression)}return m}getProgramConfiguration(t){return new ks(this,t)}}var AI={paint:new H({"background-color":new S(xe.paint_background["background-color"]),"background-pattern":new F(xe.paint_background["background-pattern"]),"background-opacity":new S(xe.paint_background["background-opacity"])})},CI={paint:new H({"raster-opacity":new S(xe.paint_raster["raster-opacity"]),"raster-hue-rotate":new S(xe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new S(xe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new S(xe.paint_raster["raster-brightness-max"]),"raster-saturation":new S(xe.paint_raster["raster-saturation"]),"raster-contrast":new S(xe.paint_raster["raster-contrast"]),"raster-resampling":new S(xe.paint_raster["raster-resampling"]),"raster-fade-duration":new S(xe.paint_raster["raster-fade-duration"])})};class PI extends Ha{constructor(t){super(t,{}),this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var LI={paint:new H({"sky-type":new S(xe.paint_sky["sky-type"]),"sky-atmosphere-sun":new S(xe.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new S(xe.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new S(xe.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new S(xe.paint_sky["sky-gradient-radius"]),"sky-gradient":new N(xe.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new S(xe.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new S(xe.paint_sky["sky-atmosphere-color"]),"sky-opacity":new S(xe.paint_sky["sky-opacity"])})};function Bv(a,t,o){const c=[0,0,1],d=yb([]);return function(m,y,v){v*=.5;var w=y[0],A=y[1],D=y[2],R=y[3],k=Math.sin(v),V=Math.cos(v);m[0]=w*V-D*k,m[1]=A*V+R*k,m[2]=D*V+w*k,m[3]=R*V-A*k}(d,d,o?-U(a)+Math.PI:U(a)),vb(d,d,-U(t)),gb(c,c,d),hp(c,c)}const DI={circle:class extends Ha{constructor(a){super(a,$L)}createBucket(a){return new tv(a)}queryRadius(a){const t=a;return Uu("circle-radius",this,t)+Uu("circle-stroke-width",this,t)+gg(this.paint.get("circle-translate"))}queryIntersectsFeature(a,t,o,c,d,m,y,v){const w=lb(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),A=this.paint.get("circle-radius").evaluate(t,o)+this.paint.get("circle-stroke-width").evaluate(t,o);return xb(a,c,m,y,v,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",w,A)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new ks(this,a)}},heatmap:class extends Ha{createBucket(a){return new wb(a)}constructor(a){super(a,iD),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){a==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=fv({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(a){return Uu("heatmap-radius",this,a)}queryIntersectsFeature(a,t,o,c,d,m,y,v){const w=this.paint.get("heatmap-radius").evaluate(t,o);return xb(a,c,m,y,v,!0,!0,new E(0,0),w)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new ks(this,a)}},hillshade:class extends Ha{constructor(a){super(a,rD)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Ha{constructor(a){super(a,bD)}getProgramIds(){const a=this.paint.get("fill-pattern"),t=a&&a.constantOr(1),o=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&o.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),o}getProgramConfiguration(a){return new ks(this,a)}recalculate(a,t){super.recalculate(a,t);const o=this.paint._values["fill-outline-color"];o.value.kind==="constant"&&o.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new wg(a)}queryRadius(){return gg(this.paint.get("fill-translate"))}queryIntersectsFeature(a,t,o,c,d,m){return!a.queryGeometry.isAboveHorizon&&ib(sb(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),c)}isTileClipped(){return!0}},"fill-extrusion":class extends Ha{constructor(a){super(a,RD)}createBucket(a){return new xp(a)}queryRadius(){return gg(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(a){return new ks(this,a)}queryIntersectsFeature(a,t,o,c,d,m,y,v,w){const A=lb(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),D=this.paint.get("fill-extrusion-height").evaluate(t,o),R=this.paint.get("fill-extrusion-base").evaluate(t,o),k=[0,0],V=v&&m.elevation,j=m.elevation?m.elevation.exaggeration():1,$=a.tile.getBucket(this);if(V&&$ instanceof xp){const ke=$.centroidVertexArray,He=w+1;if(He<ke.length){const Ze=ke.get(He);k[0]=Ze.a_centroid_pos0,k[1]=Ze.a_centroid_pos1}}if(k[0]===0&&k[1]===1)return!1;const ne=function(ke,He,Ze,Xe,Ye,lt,ht,vt,Tt){return lt?function(rt,ft,Ct,Bt,It,kt,En,Un,An){const Bn=[],Kt=[],Wt=[0,0,0,1];for(const Vn of rt){const Jn=[],Fi=[];for(const ui of Vn){const Oi=ui.x+Bt.x,Kn=ui.y+Bt.y,Hn=zD(Oi,Kn,ft,Ct,kt,En,Un,An);Wt[0]=Oi,Wt[1]=Kn,Wt[2]=Hn.base,Wt[3]=1,Gu(Wt,Wt,It),Wt[3]=Math.max(Wt[3],1e-5);const ni=kb([Wt[0]/Wt[3],Wt[1]/Wt[3],Wt[2]/Wt[3]]);Wt[0]=Oi,Wt[1]=Kn,Wt[2]=Hn.top,Wt[3]=1,Gu(Wt,Wt,It),Wt[3]=Math.max(Wt[3],1e-5);const wi=kb([Wt[0]/Wt[3],Wt[1]/Wt[3],Wt[2]/Wt[3]]);Jn.push(ni),Fi.push(wi)}Bn.push(Jn),Kt.push(Fi)}return[Bn,Kt]}(ke,He,Ze,Xe,Ye,lt,ht,vt,Tt):function(rt,ft,Ct,Bt,It){const kt=[],En=[],Un=It[8]*ft,An=It[9]*ft,Bn=It[10]*ft,Kt=It[11]*ft,Wt=It[8]*Ct,Vn=It[9]*Ct,Jn=It[10]*Ct,Fi=It[11]*Ct;for(const ui of rt){const Oi=[],Kn=[];for(const Hn of ui){const ni=Hn.x+Bt.x,wi=Hn.y+Bt.y,Si=It[0]*ni+It[4]*wi+It[12],Ni=It[1]*ni+It[5]*wi+It[13],Yi=It[2]*ni+It[6]*wi+It[14],Kr=It[3]*ni+It[7]*wi+It[15],Br=Si+Un,ii=Ni+An,vr=Yi+Bn,Qr=Math.max(Kr+Kt,1e-5),er=Si+Wt,$i=Ni+Vn,fi=Yi+Jn,hi=Math.max(Kr+Fi,1e-5),Fr=new E(Br/Qr,ii/Qr);Fr.z=vr/Qr,Oi.push(Fr);const xr=new E(er/hi,$i/hi);xr.z=fi/hi,Kn.push(xr)}kt.push(Oi),En.push(Kn)}return[kt,En]}(ke,He,Ze,Xe,Ye)}(c,R,D,A,y,V?v:null,k,j,m.center.lat),me=a.queryGeometry;return function(ke,He,Ze){let Xe=1/0;ib(Ze,He)&&(Xe=zb(Ze,He[0]));for(let Ye=0;Ye<He.length;Ye++){const lt=He[Ye],ht=ke[Ye];for(let vt=0;vt<lt.length-1;vt++){const Tt=lt[vt],rt=[Tt,lt[vt+1],ht[vt+1],ht[vt],Tt];nb(Ze,rt)&&(Xe=Math.min(Xe,zb(Ze,rt)))}}return Xe!==1/0&&Xe}(ne[0],ne[1],me.isPointQuery()?me.screenBounds:me.screenGeometry)}},line:class extends Ha{constructor(a){super(a,Bb),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(a){if(a==="line-gradient"){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof bl,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(a,t){super.recalculate(a,t),this.paint._values["line-floorwidth"]=Fb.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,a)}createBucket(a){return new Tg(a)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(a){return new ks(this,a)}queryRadius(a){const t=a,o=Ob(Uu("line-width",this,t),Uu("line-gap-width",this,t)),c=Uu("line-offset",this,t);return o/2+Math.abs(c)+gg(this.paint.get("line-translate"))}queryIntersectsFeature(a,t,o,c,d,m){if(a.queryGeometry.isAboveHorizon)return!1;const y=sb(a.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),m.angle,a.pixelToTileUnitsFactor),v=a.pixelToTileUnitsFactor/2*Ob(this.paint.get("line-width").evaluate(t,o),this.paint.get("line-gap-width").evaluate(t,o)),w=this.paint.get("line-offset").evaluate(t,o);return w&&(c=function(A,D){const R=[],k=new E(0,0);for(let V=0;V<A.length;V++){const j=A[V],$=[];for(let ne=0;ne<j.length;ne++){const me=j[ne-1],ke=j[ne],He=j[ne+1],Ze=ne===0?k:ke.sub(me)._unit()._perp(),Xe=ne===j.length-1?k:He.sub(ke)._unit()._perp(),Ye=Ze._add(Xe)._unit();Ye._mult(1/(Ye.x*Xe.x+Ye.y*Xe.y)),$.push(Ye._mult(D)._add(ke))}R.push($)}return R}(c,w*a.pixelToTileUnitsFactor)),function(A,D,R){for(let k=0;k<D.length;k++){const V=D[k];if(A.length>=3){for(let j=0;j<V.length;j++)if(Nu(A,V[j]))return!0}if(qL(A,V,R))return!0}return!1}(y,c,v)}isTileClipped(){return!0}},symbol:Rg,background:class extends Ha{constructor(a){super(a,AI)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Ha{constructor(a){super(a,CI)}getProgramIds(){return["raster"]}},sky:class extends Ha{constructor(a){super(a,LI),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){a==="sky-gradient"?this._updateColorRamp():a!=="sky-atmosphere-sun"&&a!=="sky-atmosphere-halo-color"&&a!=="sky-atmosphere-color"&&a!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=fv({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(a){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=a.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(a,t){if(this.paint.get("sky-type")==="atmosphere"){const c=this.paint.get("sky-atmosphere-sun"),d=!c,m=a.style.light,y=m.properties.get("position");return d&&m.properties.get("anchor")==="viewport"&&ge("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),d?Bv(y.azimuthal,90-y.polar,t):Bv(c[0],90-c[1],t)}const o=this.paint.get("sky-gradient-center");return Bv(o[0],90-o[1],t)}is3D(){return!1}isSky(){return!0}markSkyboxValid(a){this._skyboxInvalidated=!1,this._lightPosition=a.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const a=this.paint.get("sky-type");return a==="atmosphere"?["skyboxCapture","skybox"]:a==="gradient"?["skyboxGradient"]:null}}};class Sp{constructor(t,o,c,d){this.context=t,this.format=c,this.texture=t.gl.createTexture(),this.update(o,d)}update(t,o,c){const{width:d,height:m}=t,{context:y}=this,{gl:v}=y,{HTMLImageElement:w,HTMLCanvasElement:A,HTMLVideoElement:D,ImageData:R,ImageBitmap:k}=I;if(v.bindTexture(v.TEXTURE_2D,this.texture),y.pixelStoreUnpackFlipY.set(!1),y.pixelStoreUnpack.set(1),y.pixelStoreUnpackPremultiplyAlpha.set(this.format===v.RGBA&&(!o||o.premultiply!==!1)),c||this.size&&this.size[0]===d&&this.size[1]===m){const{x:V,y:j}=c||{x:0,y:0};t instanceof w||t instanceof A||t instanceof D||t instanceof R||k&&t instanceof k?v.texSubImage2D(v.TEXTURE_2D,0,V,j,v.RGBA,v.UNSIGNED_BYTE,t):v.texSubImage2D(v.TEXTURE_2D,0,V,j,d,m,v.RGBA,v.UNSIGNED_BYTE,t.data)}else this.size=[d,m],t instanceof w||t instanceof A||t instanceof D||t instanceof R||k&&t instanceof k?v.texImage2D(v.TEXTURE_2D,0,this.format,this.format,v.UNSIGNED_BYTE,t):v.texImage2D(v.TEXTURE_2D,0,this.format,d,m,0,this.format,v.UNSIGNED_BYTE,t.data);this.useMipmap=!!(o&&o.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&v.generateMipmap(v.TEXTURE_2D)}bind(t,o){const{context:c}=this,{gl:d}=c;d.bindTexture(d.TEXTURE_2D,this.texture),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,this.useMipmap?t===d.NEAREST?d.NEAREST_MIPMAP_NEAREST:d.LINEAR_MIPMAP_NEAREST:t),this.filter=t),o!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,o),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,o),this.wrap=o)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Fv{constructor(t,o){this.width=t,this.height=o,this.nextRow=0,this.image=new Yo({width:t,height:o}),this.positions={},this.uploaded=!1}getDash(t,o){const c=this.getKey(t,o);return this.positions[c]}trim(){const t=this.width,o=this.height=We(this.nextRow);this.image.resize({width:t,height:o})}getKey(t,o){return t.join(",")+o}getDashRanges(t,o,c){const d=[];let m=t.length%2==1?-t[t.length-1]*c:0,y=t[0]*c,v=!0;d.push({left:m,right:y,isDash:v,zeroLength:t[0]===0});let w=t[0];for(let A=1;A<t.length;A++){v=!v;const D=t[A];m=w*c,w+=D,y=w*c,d.push({left:m,right:y,isDash:v,zeroLength:D===0})}return d}addRoundDash(t,o,c){const d=o/2;for(let m=-c;m<=c;m++){const y=this.width*(this.nextRow+c+m);let v=0,w=t[v];for(let A=0;A<this.width;A++){A/w.right>1&&(w=t[++v]);const D=Math.abs(A-w.left),R=Math.abs(A-w.right),k=Math.min(D,R);let V;const j=m/c*(d+1);if(w.isDash){const $=d-Math.abs(j);V=Math.sqrt(k*k+$*$)}else V=d-Math.sqrt(k*k+j*j);this.image.data[y+A]=Math.max(0,Math.min(255,V+128))}}}addRegularDash(t,o){for(let w=t.length-1;w>=0;--w){const A=t[w],D=t[w+1];A.zeroLength?t.splice(w,1):D&&D.isDash===A.isDash&&(D.left=A.left,t.splice(w,1))}const c=t[0],d=t[t.length-1];c.isDash===d.isDash&&(c.left=d.left-this.width,d.right=c.right+this.width);const m=this.width*this.nextRow;let y=0,v=t[y];for(let w=0;w<this.width;w++){w/v.right>1&&(v=t[++y]);const A=Math.abs(w-v.left),D=Math.abs(w-v.right),R=Math.min(A,D);this.image.data[m+w]=Math.max(0,Math.min(255,(v.isDash?R:-R)+o+128))}}addDash(t,o){const c=this.getKey(t,o);if(this.positions[c])return this.positions[c];const d=o==="round",m=d?7:0,y=2*m+1;if(this.nextRow+y>this.height)return ge("LineAtlas out of space"),null;t.length===0&&t.push(1);let v=0;for(let D=0;D<t.length;D++)t[D]<0&&(ge("Negative value is found in line dasharray, replacing values with 0"),t[D]=0),v+=t[D];if(v!==0){const D=this.width/v,R=this.getDashRanges(t,this.width,D);d?this.addRoundDash(R,D,m):this.addRegularDash(R,o==="square"?.5*D:0)}const w=this.nextRow+m;this.nextRow+=y;const A={tl:[w,m],br:[v,0]};return this.positions[c]=A,A}}jt(Fv,"LineAtlas");class II{constructor(t){this._callback=t,this._triggered=!1,typeof MessageChannel!="undefined"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}const RI=I.performance;function pw(a){const t=a?a.url.toString():void 0;return RI.getEntriesByName(t)}class zI{constructor(){this.tasks={},this.taskQueue=[],St(["process"],this),this.invoker=new II(this.process),this.nextId=0}add(t,o){const c=this.nextId++,d=function({type:m,isSymbolTile:y,zoom:v}){return v=v||0,m==="message"?0:m!=="maybePrepare"||y?m!=="parseTile"||y?m==="parseTile"&&y?300-v:m==="maybePrepare"&&y?400-v:500:200-v:100-v}(o);if(d===0){Ie();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[c]={fn:t,metadata:o,priority:d,id:c},this.taskQueue.push(c),this.invoker.trigger(),{cancel:()=>{delete this.tasks[c]}}}process(){Ie();try{if(this.taskQueue=this.taskQueue.filter(c=>!!this.tasks[c]),!this.taskQueue.length)return;const t=this.pick();if(t===null)return;const o=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!o)return;o.fn()}finally{}}pick(){let t=null,o=1/0;for(let d=0;d<this.taskQueue.length;d++){const m=this.tasks[this.taskQueue[d]];m.priority<o&&(o=m.priority,t=d)}if(t===null)return null;const c=this.taskQueue[t];return this.taskQueue.splice(t,1),c}remove(){this.invoker.remove()}}const kI=Ae([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),BI=Ae([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:fw}=kI,mw=Ae([{name:"a_pos_3",components:3,type:"Int16"}]);var Ap=Ae([{name:"a_pos",type:"Int16",components:2}]);const Ju=In/Math.PI/2,$r=-Ju,Jr=Ju,FI=[new ga([$r,$r,$r],[Jr,Jr,Jr]),new ga([$r,$r,$r],[0,0,Jr]),new ga([0,$r,$r],[Jr,0,Jr]),new ga([$r,0,$r],[0,Jr,Jr]),new ga([0,0,$r],[Jr,Jr,Jr])];class OI{constructor(t,o,c){this.a=Vu([],t,c),this.b=Vu([],o,c),this.center=c;const d=hp([],this.a),m=hp([],this.b);this.angle=Math.acos(dp(d,m))}}function Ov(a,t){if(a.angle===0)return null;let o;return o=a.a[t]===0?1/a.angle*.5*Math.PI:1/a.angle*Math.atan(a.b[t]/a.a[t]/Math.sin(a.angle)-1/Math.tan(a.angle)),o<0||o>1?null:function(c,d,m,y){const v=Math.sin(m);return c*(Math.sin((1-y)*m)/v)+d*(Math.sin(y*m)/v)}(a.a[t],a.b[t],a.angle,ie(o,0,1))+a.center[t]}function Cp(a){if(a.z<=1)return FI[a.z+2*a.y+a.x];const[t,o]=Nv(a),c=[Ko(t[0],t[1]),Ko(t[0],o[1]),Ko(o[0],t[1]),Ko(o[0],o[1])],d=[Jr,Jr,Jr],m=[$r,$r,$r];for(const y of c)d[0]=Math.min(d[0],y[0]),d[1]=Math.min(d[1],y[1]),d[2]=Math.min(d[2],y[2]),m[0]=Math.max(m[0],y[0]),m[1]=Math.max(m[1],y[1]),m[2]=Math.max(m[2],y[2]);return new ga(d,m)}function NI(a,t,o){const c=t/a.worldSize,d=(ft,Ct)=>{up(ft,ft,c),up(Ct,Ct,c)},m=Number.MAX_VALUE,y=[-m,-m,-m],v=[m,m,m],w=xw(a);if(o.z<=1){const ft=Cp(o).getCorners();for(let Ct=0;Ct<ft.length;Ct++)ql(ft[Ct],ft[Ct],w),cv(v,v,ft[Ct]),uv(y,y,ft[Ct]);return d(v,y),new ga(v,y)}const[A,D]=Nv(o),R=new Bs;R.setSouthWest([A[1],D[0]]),R.setNorthEast([D[1],A[0]]);const k=[Ko(R.getSouth(),R.getWest()),Ko(R.getSouth(),R.getEast()),Ko(R.getNorth(),R.getEast()),Ko(R.getNorth(),R.getWest())];for(let ft=0;ft<k.length;ft++)ql(k[ft],k[ft],w),cv(v,v,k[ft]),uv(y,y,k[ft]);if(R.contains(a.center))return y[2]=0,d(v,y),new ga(v,y);const V=[w[12],w[13],w[14]],j=a.center.lng,$=ie(a.center.lat,-85.051129,mo),ne=[lp(j),Fu($)],me=R.getCenter().lng,ke=ie(R.getCenter().lat,-85.051129,mo),He=[lp(me),Fu(ke)];let Ze=new Array(3),Xe=0;const Ye=ne[0]-He[0],lt=ne[1]-He[1];if(Math.abs(Ye)>Math.abs(lt))Xe=Ye>=0?1:3,Ze=V;else{Xe=lt>=0?0:2;const ft=[w[4],w[5],w[6]];let Ct;Ct=lt>=0?-Math.sin(U(R.getSouth()))*Ju:-Math.sin(U(R.getNorth()))*Ju,Ze=hv(Ze,V,ft,Ct)}const ht=k[Xe],vt=k[(Xe+1)%4],Tt=new OI(ht,vt,Ze),rt=[Ov(Tt,0)||ht[0],Ov(Tt,1)||ht[1],Ov(Tt,2)||ht[2]];return v[2]=Math.min(ht[2],vt[2]),cv(v,v,rt),uv(y,y,rt),d(v,y),new ga(v,y)}function Nv(a){const t=1<<a.z,o=a.x/t,c=(a.x+1)/t,d=(a.y+1)/t;return[[rr(a.y/t),Ta(o)],[rr(d),Ta(c)]]}function gw(a,t,o,c=Ju){return o=U(o),[a*Math.sin(o)*c,-t*c,a*Math.cos(o)*c]}function Ko(a,t,o){return gw(Math.cos(U(a)),Math.sin(U(a)),t,o)}function _w(a,t,o){const c=Math.pow(2,o.z),d=(a/In+o.x)/c;return Ko(rr((t/In+o.y)/c),Ta(d))}function Uv(a){return 16383/Math.max(...Vu([],a.max,a.min))}function yw(a){const t=go(new Float64Array(16)),o=Uv(a);var c,d;return Fs(t,t,[o,o,o]),jl(t,t,((c=[])[0]=-(d=a.min)[0],c[1]=-d[1],c[2]=-d[2],c)),t}function vw(a,t,o,c,d){const m=function(w){const A=In/(2*Math.PI);return w/(2*Math.PI)/A}(o),y=[a,t,-o/(2*Math.PI)],v=go(new Float64Array(16));return jl(v,v,y),Fs(v,v,[m,m,m]),ov(v,v,U(-d)),sv(v,v,U(-c)),v}function xw(a){const{x:t,y:o}=a.point,{lng:c,lat:d}=a._center;return vw(t,o,a.worldSize,c,d)}const bw=U(85),UI=Math.cos(bw),VI=Math.sin(bw);function ww(a,t,o){var c=2*Math.PI*6378137/256/Math.pow(2,o);return[a*c-2*Math.PI*6378137/2,t*c-2*Math.PI*6378137/2]}class zg{constructor(t,o,c){this.z=t,this.x=o,this.y=c,this.key=Pp(0,t,t,o,c)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,o){const c=function(m,y,v){var w=ww(256*m,256*(y=Math.pow(2,v)-y-1),v),A=ww(256*(m+1),256*(y+1),v);return w[0]+","+w[1]+","+A[0]+","+A[1]}(this.x,this.y,this.z),d=function(m,y,v){let w,A="";for(let D=m;D>0;D--)w=1<<D-1,A+=(y&w?1:0)+(v&w?2:0);return A}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String(o==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",d).replace("{bbox-epsg-3857}",c)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Mw{constructor(t,o){this.wrap=t,this.canonical=o,this.key=Pp(t,o.z,o.z,o.x,o.y)}}class yr{constructor(t,o,c,d,m){this.overscaledZ=t,this.wrap=o,this.canonical=new zg(c,+d,+m),this.key=o===0&&t===c?this.canonical.key:Pp(o,t,c,d,m)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const o=this.canonical.z-t;return t>this.canonical.z?new yr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yr(t,this.wrap,t,this.canonical.x>>o,this.canonical.y>>o)}calculateScaledKey(t,o=!0){if(this.overscaledZ===t&&o)return this.key;if(t>this.canonical.z)return Pp(this.wrap*+o,t,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-t;return Pp(this.wrap*+o,t,t,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const o=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>o&&t.canonical.y===this.canonical.y>>o}children(t){if(this.overscaledZ>=t)return[new yr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const o=this.canonical.z+1,c=2*this.canonical.x,d=2*this.canonical.y;return[new yr(o,this.wrap,o,c,d),new yr(o,this.wrap,o,c+1,d),new yr(o,this.wrap,o,c,d+1),new yr(o,this.wrap,o,c+1,d+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new yr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new yr(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Mw(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Pp(a,t,o,c,d){const m=1<<Math.min(o,22);let y=m*(d%m)+c%m;return a&&o<22&&(y+=m*m*((a<0?-2*a-1:2*a)%(1<<2*(22-o)))),16*(32*y+o)+(t-o)}function Xl(a,t){if(!t.isReprojectedInTileSpace)return{scale:1<<a.z,x:a.x,y:a.y,x2:a.x+1,y2:a.y+1,projection:t};const o=Math.pow(2,-a.z),c=a.x*o,d=(a.x+1)*o,m=a.y*o,y=(a.y+1)*o,v=Ta(c),w=Ta(d),A=rr(m),D=rr(y),R=t.project(v,A),k=t.project(w,A),V=t.project(w,D),j=t.project(v,D);let $=Math.min(R.x,k.x,V.x,j.x),ne=Math.min(R.y,k.y,V.y,j.y),me=Math.max(R.x,k.x,V.x,j.x),ke=Math.max(R.y,k.y,V.y,j.y);const He=o/16;function Ze(Ye,lt,ht,vt,Tt,rt){const ft=(ht+Tt)/2,Ct=(vt+rt)/2,Bt=t.project(Ta(ft),rr(Ct)),It=Math.max(0,$-Bt.x,ne-Bt.y,Bt.x-me,Bt.y-ke);$=Math.min($,Bt.x),me=Math.max(me,Bt.x),ne=Math.min(ne,Bt.y),ke=Math.max(ke,Bt.y),It>He&&(Ze(Ye,Bt,ht,vt,ft,Ct),Ze(Bt,lt,ft,Ct,Tt,rt))}Ze(R,k,c,m,d,m),Ze(k,V,d,m,d,y),Ze(V,j,d,y,c,y),Ze(j,R,c,y,c,m),$-=He,ne-=He,me+=He,ke+=He;const Xe=1/Math.max(me-$,ke-ne);return{scale:Xe,x:$*Xe,y:ne*Xe,x2:me*Xe,y2:ke*Xe,projection:t}}jt(zg,"CanonicalTileID"),jt(yr,"OverscaledTileID",{omit:["projMatrix"]});class Tw{constructor(t){this._stringToNumber={},this._numberToString=[];for(let o=0;o<t.length;o++){const c=t[o];this._stringToNumber[c]=o,this._numberToString[o]=c}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}const GI=["tile","layer","source","sourceLayer","state"];class Ew{constructor(t,o,c,d,m){this.type="Feature",this._vectorTileFeature=t,this._z=o,this._x=c,this._y=d,this.properties=t.properties,this.id=m}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",geometry:this.geometry,properties:this.properties};this.id!==void 0&&(t.id=this.id);for(const o of GI)this[o]!==void 0&&(t[o]=this[o]);return t}}const Ea=32,yo=33,Vs=new Uint16Array(8184);for(let a=0;a<2046;a++){let t=a+2,o=0,c=0,d=0,m=0,y=0,v=0;for(1&t?d=m=y=Ea:o=c=v=Ea;(t>>=1)>1;){const A=o+d>>1,D=c+m>>1;1&t?(d=o,m=c,o=y,c=v):(o=d,c=m,d=y,m=v),y=A,v=D}const w=4*a;Vs[w+0]=o,Vs[w+1]=c,Vs[w+2]=d,Vs[w+3]=m}const vo=new Uint16Array(2178),Gs=new Uint8Array(1089),kg=new Uint16Array(1089);function Sw(a){return a===0?-.03125:a===32?.03125:0}var Aw=Ae([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Cw={type:2,extent:In,loadGeometry:()=>[[new E(0,0),new E(8193,0),new E(8193,8193),new E(0,8193),new E(0,0)]]};class Vv{constructor(t,o,c,d,m){this.tileID=t,this.uid=Ue(),this.uses=0,this.tileSize=o,this.tileZoom=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=m,this.expiredRequestCount=0,this.state="loading",d&&d.transform&&(this.projection=d.transform.projection)}registerFadeDuration(t){const o=t+this.timeAdded;o<bt.now()||this.fadeEndTime&&o<this.fadeEndTime||(this.fadeEndTime=o)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Xl(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,o,c){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(d,m){const y={};if(!m)return y;for(const v of d){const w=v.layerIds.map(A=>m.getLayer(A)).filter(Boolean);if(w.length!==0){v.layers=w,v.stateDependentLayerIds&&(v.stateDependentLayers=v.stateDependentLayerIds.map(A=>w.filter(D=>D.id===A)[0]));for(const A of w)y[A.id]=v}}return y}(t.buckets,o.style),this.hasSymbolBuckets=!1;for(const d in this.buckets){const m=this.buckets[d];if(m instanceof Us){if(this.hasSymbolBuckets=!0,!c)break;m.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const d in this.buckets){const m=this.buckets[d];if(m instanceof Us&&m.hasRTLText){this.hasRTLText=!0,qr.isLoading()||qr.isLoaded()||ku()!=="deferred"||Ds();break}}this.queryPadding=0;for(const d in this.buckets){const m=this.buckets[d];this.queryPadding=Math.max(this.queryPadding,o.style.getLayer(d).queryRadius(m))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new Ua}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const c in this.buckets){const d=this.buckets[c];d.uploadPending()&&d.upload(t)}const o=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Sp(t,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Sp(t,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Sp(t,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,o,c,d,m,y,v,w){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:v,transform:y,params:m,tileTransform:this.tileTransform},t,o,c):{}}querySourceFeatures(t,o){const c=this.latestFeatureIndex;if(!c||!c.rawTileData)return;const d=c.loadVTLayers(),m=o?o.sourceLayer:"",y=d._geojsonTileLayer||d[m];if(!y)return;const v=lo(o&&o.filter),{z:w,x:A,y:D}=this.tileID.canonical,R={z:w,x:A,y:D};for(let k=0;k<y.length;k++){const V=y.feature(k);if(v.needGeometry){const ne=Wl(V,!0);if(!v.filter(new ci(this.tileID.overscaledZ),ne,this.tileID.canonical))continue}else if(!v.filter(new ci(this.tileID.overscaledZ),V))continue;const j=c.getId(V,m),$=new Ew(V,w,A,D,j);$.tile=R,t.push($)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const o=this.expirationTime;if(t.cacheControl){const c=it(t.cacheControl);c["max-age"]&&(this.expirationTime=Date.now()+1e3*c["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const c=Date.now();let d=!1;if(this.expirationTime>c)d=!1;else if(o)if(this.expirationTime<o)d=!0;else{const m=this.expirationTime-o;m?this.expirationTime=c+Math.max(m,3e4):d=!0}else d=!0;d?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,o){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0||!o)return;const c=this.latestFeatureIndex.loadVTLayers(),d=o.style.listImages();for(const m in this.buckets){if(!o.style.hasLayer(m))continue;const y=this.buckets[m],v=y.layers[0].sourceLayer||"_geojsonTileLayer",w=c[v],A=t[v];if(!w||!A||Object.keys(A).length===0)continue;if(y.update(A,w,d,this.imageAtlas&&this.imageAtlas.patternPositions||{}),y instanceof Tg||y instanceof wg){const R=o.style._getSourceCache(y.layers[0].source);o._terrain&&o._terrain.enabled&&R&&y.programConfigurations.needsUpload&&o._terrain._clearRenderCacheForTile(R.id,this.tileID)}const D=o&&o.style&&o.style.getLayer(m);D&&(this.queryPadding=Math.max(this.queryPadding,D.queryRadius(y)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<bt.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=bt.now()+t}setTexture(t,o){const c=o.context,d=c.gl;this.texture=o.getTileTexture(t.width),this.texture?this.texture.update(t,{useMipmap:!0}):(this.texture=new Sp(c,t,d.RGBA,{useMipmap:!0}),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&d.texParameterf(d.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax))}setDependencies(t,o){const c={};for(const d of o)c[d]=!0;this.dependencies[t]=c}hasDependency(t,o){for(const c of t){const d=this.dependencies[c];if(d){for(const m of o)if(d[m])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,o){if(!o||o.name==="mercator"||this._tileDebugBuffer)return;const c=Xo(Cw,this.tileID.canonical,this.tileTransform)[0],d=new Te,m=new qn;for(let y=0;y<c.length;y++){const{x:v,y:w}=c[y];d.emplaceBack(v,w),m.emplaceBack(y)}m.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(m),this._tileDebugBuffer=t.createVertexBuffer(d,Ap.members),this._tileDebugSegments=Ei.simpleSegment(0,0,d.length,m.length)}_makeTileBoundsBuffers(t,o){if(this._tileBoundsBuffer||!o||o.name==="mercator")return;const c=Xo(Cw,this.tileID.canonical,this.tileTransform)[0];let d,m;if(this.isRaster){const y=function(v,w){const A=Xl(v,w),D=Math.pow(2,v.z);for(let ne=0;ne<yo;ne++)for(let me=0;me<yo;me++){const ke=Ta((v.x+(me+Sw(me))/Ea)/D),He=rr((v.y+(ne+Sw(ne))/Ea)/D),Ze=w.project(ke,He),Xe=ne*yo+me;vo[2*Xe+0]=Math.round((Ze.x*A.scale-A.x)*In),vo[2*Xe+1]=Math.round((Ze.y*A.scale-A.y)*In)}Gs.fill(0),kg.fill(0);for(let ne=2045;ne>=0;ne--){const me=4*ne,ke=Vs[me+0],He=Vs[me+1],Ze=Vs[me+2],Xe=Vs[me+3],Ye=ke+Ze>>1,lt=He+Xe>>1,ht=Ye+lt-He,vt=lt+ke-Ye,Tt=He*yo+ke,rt=Xe*yo+Ze,ft=lt*yo+Ye,Ct=Math.hypot((vo[2*Tt+0]+vo[2*rt+0])/2-vo[2*ft+0],(vo[2*Tt+1]+vo[2*rt+1])/2-vo[2*ft+1])>=16;if(Gs[ft]=Gs[ft]||(Ct?1:0),ne<1022){const Bt=(He+vt>>1)*yo+(ke+ht>>1),It=(Xe+vt>>1)*yo+(Ze+ht>>1);Gs[ft]=Gs[ft]||Gs[Bt]||Gs[It]}}const R=new Re,k=new qt;let V=0;function j(ne,me){const ke=me*yo+ne;return kg[ke]===0&&(R.emplaceBack(vo[2*ke+0],vo[2*ke+1],ne*In/Ea,me*In/Ea),kg[ke]=++V),kg[ke]-1}function $(ne,me,ke,He,Ze,Xe){const Ye=ne+ke>>1,lt=me+He>>1;if(Math.abs(ne-Ze)+Math.abs(me-Xe)>1&&Gs[lt*yo+Ye])$(Ze,Xe,ne,me,Ye,lt),$(ke,He,Ze,Xe,Ye,lt);else{const ht=j(ne,me),vt=j(ke,He),Tt=j(Ze,Xe);k.emplaceBack(ht,vt,Tt)}}return $(0,0,Ea,Ea,Ea,0),$(Ea,Ea,0,0,0,Ea),{vertices:R,indices:k}}(this.tileID.canonical,o);d=y.vertices,m=y.indices}else{d=new Re,m=new qt;for(const{x:v,y:w}of c)d.emplaceBack(v,w,0,0);const y=_g(d.int16,void 0,4);for(let v=0;v<y.length;v+=3)m.emplaceBack(y[v],y[v+1],y[v+2])}this._tileBoundsBuffer=t.createVertexBuffer(d,Aw.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(m),this._tileBoundsSegments=Ei.simpleSegment(0,0,d.length,m.length)}_makeGlobeTileDebugBuffers(t,o){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!o||o.name!=="globe")return;const c=this.tileID.canonical,d=yw(Cp(c));this._makeGlobeTileDebugBorderBuffer(t,c,d),this._makeGlobeTileDebugTextBuffer(t,c,d)}_makeGlobeTileDebugBorderBuffer(t,o,c){const d=new Te,m=new qn,y=new Se,v=(A,D,R,k,V)=>{const j=(R-A)/(V-1),$=(k-D)/(V-1),ne=d.length;for(let me=0;me<V;me++){const ke=A+me*j,He=D+me*$;d.emplaceBack(ke,He);const Ze=_w(ke,He,o),Xe=ql(Ze,Ze,c);y.emplaceBack(Xe[0],Xe[1],Xe[2]),m.emplaceBack(ne+me)}},w=In;v(0,0,w,0,16),v(w,0,w,w,16),v(w,w,0,w,16),v(0,w,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(m),this._tileDebugBuffer=t.createVertexBuffer(d,Ap.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(y,mw.members),this._tileDebugSegments=Ei.simpleSegment(0,0,d.length,m.length)}_makeGlobeTileDebugTextBuffer(t,o,c){const d=new Te,m=new qt,y=new Se,v=25;m.reserve(32),d.reserve(v),y.reserve(v);const w=(A,D)=>v*A+D;for(let A=0;A<v;A++){const D=2048*A;for(let R=0;R<v;R++){const k=2048*R;d.emplaceBack(k,D);const V=_w(k,D,o),j=ql(V,V,c);y.emplaceBack(j[0],j[1],j[2])}}for(let A=0;A<4;A++)for(let D=0;D<4;D++){const R=w(A,D),k=w(A,D+1),V=w(A+1,D),j=w(A+1,D+1);m.emplaceBack(R,k,V),m.emplaceBack(V,k,j)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(m),this._tileDebugTextBuffer=t.createVertexBuffer(d,Ap.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(y,mw.members),this._tileDebugTextSegments=Ei.simpleSegment(0,0,v,32)}}class HI{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,o,c){const d=String(o);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][d]=this.stateChanges[t][d]||{},ye(this.stateChanges[t][d],c),this.deletedStates[t]===null){this.deletedStates[t]={};for(const m in this.state[t])m!==d&&(this.deletedStates[t][m]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][d]===null){this.deletedStates[t][d]={};for(const m in this.state[t][d])c[m]||(this.deletedStates[t][d][m]=null)}else for(const m in c)this.deletedStates[t]&&this.deletedStates[t][d]&&this.deletedStates[t][d][m]===null&&delete this.deletedStates[t][d][m]}removeFeatureState(t,o,c){if(this.deletedStates[t]===null)return;const d=String(o);if(this.deletedStates[t]=this.deletedStates[t]||{},c&&o!==void 0)this.deletedStates[t][d]!==null&&(this.deletedStates[t][d]=this.deletedStates[t][d]||{},this.deletedStates[t][d][c]=null);else if(o!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][d])for(c in this.deletedStates[t][d]={},this.stateChanges[t][d])this.deletedStates[t][d][c]=null;else this.deletedStates[t][d]=null;else this.deletedStates[t]=null}getState(t,o){const c=String(o),d=ye({},(this.state[t]||{})[c],(this.stateChanges[t]||{})[c]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const m=this.deletedStates[t][o];if(m===null)return{};for(const y in m)delete d[y]}return d}initializeTileState(t,o){t.setFeatureState(this.state,o)}coalesceChanges(t,o){const c={};for(const d in this.stateChanges){this.state[d]=this.state[d]||{};const m={};for(const y in this.stateChanges[d])this.state[d][y]||(this.state[d][y]={}),ye(this.state[d][y],this.stateChanges[d][y]),m[y]=this.state[d][y];c[d]=m}for(const d in this.deletedStates){this.state[d]=this.state[d]||{};const m={};if(this.deletedStates[d]===null)for(const y in this.state[d])m[y]={},this.state[d][y]={};else for(const y in this.deletedStates[d]){if(this.deletedStates[d][y]===null)this.state[d][y]={};else for(const v of Object.keys(this.deletedStates[d][y]))delete this.state[d][y][v];m[y]=this.state[d][y]}c[d]=c[d]||{},ye(c[d],m)}if(this.stateChanges={},this.deletedStates={},Object.keys(c).length!==0)for(const d in t)t[d].setFeatureState(c,o)}}class Pw{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,o){const c=this.toIdx(t,o);return{min:this.minimums[c],max:this.maximums[c]}}isLeaf(t,o){return this.leaves[this.toIdx(t,o)]}toIdx(t,o){return o*this.size+t}}function Lw(a,t,o,c){let d=0,m=Number.MAX_VALUE;for(let y=0;y<3;y++)if(Math.abs(c[y])<1e-15){if(o[y]<a[y]||o[y]>t[y])return null}else{const v=1/c[y];let w=(a[y]-o[y])*v,A=(t[y]-o[y])*v;if(w>A){const D=w;w=A,A=D}if(w>d&&(d=w),A<m&&(m=A),d>m)return null}return d}function Dw(a,t,o,c,d,m,y,v,w,A,D){const R=c-a,k=d-t,V=m-o,j=y-a,$=v-t,ne=w-o,me=D[1]*ne-D[2]*$,ke=D[2]*j-D[0]*ne,He=D[0]*$-D[1]*j,Ze=R*me+k*ke+V*He;if(Math.abs(Ze)<1e-15)return null;const Xe=1/Ze,Ye=A[0]-a,lt=A[1]-t,ht=A[2]-o,vt=(Ye*me+lt*ke+ht*He)*Xe;if(vt<0||vt>1)return null;const Tt=lt*V-ht*k,rt=ht*R-Ye*V,ft=Ye*k-lt*R,Ct=(D[0]*Tt+D[1]*rt+D[2]*ft)*Xe;return Ct<0||vt+Ct>1?null:(j*Tt+$*rt+ne*ft)*Xe}function Iw(a,t,o){return(a-t)/(o-t)}function Rw(a,t,o,c,d,m,y,v,w){const A=1<<o,D=m-c,R=y-d,k=(a+1)/A*D+c,V=(t+0)/A*R+d,j=(t+1)/A*R+d;v[0]=(a+0)/A*D+c,v[1]=V,w[0]=k,w[1]=j}class zw{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const o=function(m){const y=Math.ceil(Math.log2(m.dim/8)),v=[];let w=Math.ceil(Math.pow(2,y));const A=1/w,D=(V,j,$,ne,me)=>{const ke=ne?1:0,He=(V+1)*$-ke,Ze=j*$,Xe=(j+1)*$-ke;me[0]=V*$,me[1]=Ze,me[2]=He,me[3]=Xe};let R=new Pw(w);const k=[];for(let V=0;V<w*w;V++){D(V%w,Math.floor(V/w),A,!1,k);const j=Hs(k[0],k[1],m),$=Hs(k[2],k[1],m),ne=Hs(k[2],k[3],m),me=Hs(k[0],k[3],m);R.minimums.push(Math.min(j,$,ne,me)),R.maximums.push(Math.max(j,$,ne,me)),R.leaves.push(1)}for(v.push(R),w/=2;w>=1;w/=2){const V=v[v.length-1];R=new Pw(w);for(let j=0;j<w*w;j++){D(j%w,Math.floor(j/w),2,!0,k);const $=V.getElevation(k[0],k[1]),ne=V.getElevation(k[2],k[1]),me=V.getElevation(k[2],k[3]),ke=V.getElevation(k[0],k[3]),He=V.isLeaf(k[0],k[1]),Ze=V.isLeaf(k[2],k[1]),Xe=V.isLeaf(k[2],k[3]),Ye=V.isLeaf(k[0],k[3]),lt=Math.min($.min,ne.min,me.min,ke.min),ht=Math.max($.max,ne.max,me.max,ke.max),vt=He&&Ze&&Xe&&Ye;R.maximums.push(ht),R.minimums.push(lt),R.leaves.push(ht-lt<=5&&vt?1:0)}v.push(R)}return v}(this.dem),c=o.length-1,d=o[c];this._addNode(d.minimums[0],d.maximums[0],d.leaves[0]),this._construct(o,0,0,c,0)}raycastRoot(t,o,c,d,m,y,v=1){return Lw([t,o,-100],[c,d,this.maximums[0]*v],m,y)}raycast(t,o,c,d,m,y,v=1){if(!this.nodeCount)return null;const w=this.raycastRoot(t,o,c,d,m,y,v);if(w==null)return null;const A=[],D=[],R=[],k=[],V=[{idx:0,t:w,nodex:0,nodey:0,depth:0}];for(;V.length>0;){const{idx:j,t:$,nodex:ne,nodey:me,depth:ke}=V.pop();if(this.leaves[j]){Rw(ne,me,ke,t,o,c,d,R,k);const Ze=1<<ke,Xe=(ne+0)/Ze,Ye=(ne+1)/Ze,lt=(me+0)/Ze,ht=(me+1)/Ze,vt=Hs(Xe,lt,this.dem)*v,Tt=Hs(Ye,lt,this.dem)*v,rt=Hs(Ye,ht,this.dem)*v,ft=Hs(Xe,ht,this.dem)*v,Ct=Dw(R[0],R[1],vt,k[0],R[1],Tt,k[0],k[1],rt,m,y),Bt=Dw(k[0],k[1],rt,R[0],k[1],ft,R[0],R[1],vt,m,y),It=Math.min(Ct!==null?Ct:Number.MAX_VALUE,Bt!==null?Bt:Number.MAX_VALUE);if(It!==Number.MAX_VALUE)return It;{const kt=hv([],m,y,$);if(kw(vt,Tt,ft,rt,Iw(kt[0],R[0],k[0]),Iw(kt[1],R[1],k[1]))>=kt[2])return $}continue}let He=0;for(let Ze=0;Ze<this._siblingOffset.length;Ze++){Rw((ne<<1)+this._siblingOffset[Ze][0],(me<<1)+this._siblingOffset[Ze][1],ke+1,t,o,c,d,R,k),R[2]=-100,k[2]=this.maximums[this.childOffsets[j]+Ze]*v;const Xe=Lw(R,k,m,y);if(Xe!=null){const Ye=Xe;A[Ze]=Ye;let lt=!1;for(let ht=0;ht<He&&!lt;ht++)Ye>=A[D[ht]]&&(D.splice(ht,0,Ze),lt=!0);lt||(D[He]=Ze),He++}}for(let Ze=0;Ze<He;Ze++){const Xe=D[Ze];V.push({idx:this.childOffsets[j]+Xe,t:A[Xe],nodex:(ne<<1)+this._siblingOffset[Xe][0],nodey:(me<<1)+this._siblingOffset[Xe][1],depth:ke+1})}}return null}_addNode(t,o,c){return this.minimums.push(t),this.maximums.push(o),this.leaves.push(c),this.childOffsets.push(0),this.nodeCount++}_construct(t,o,c,d,m){if(t[d].isLeaf(o,c)===1)return;this.childOffsets[m]||(this.childOffsets[m]=this.nodeCount);const y=d-1,v=t[y];let w=0,A=0;for(let D=0;D<this._siblingOffset.length;D++){const R=2*o+this._siblingOffset[D][0],k=2*c+this._siblingOffset[D][1],V=v.getElevation(R,k),j=v.isLeaf(R,k),$=this._addNode(V.min,V.max,j);j&&(w|=1<<D),A||(A=$)}for(let D=0;D<this._siblingOffset.length;D++)w&1<<D||this._construct(t,2*o+this._siblingOffset[D][0],2*c+this._siblingOffset[D][1],y,A+D)}}function kw(a,t,o,c,d,m){return gn(gn(a,o,m),gn(t,c,m),d)}function Hs(a,t,o){const c=o.dim,d=ie(a*c-.5,0,c-1),m=ie(t*c-.5,0,c-1),y=Math.floor(d),v=Math.floor(m),w=Math.min(y+1,c-1),A=Math.min(v+1,c-1);return kw(o.get(y,v),o.get(w,v),o.get(y,A),o.get(w,A),d-y,m-v)}const Bw={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Bg{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,o,c,d=!1,m=!1){if(this.uid=t,o.height!==o.width)throw new RangeError("DEM tiles must be square");if(c&&c!=="mapbox"&&c!=="terrarium")return ge(`"${c}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=o.height;const y=this.dim=o.height-2,v=new Uint32Array(o.data.buffer);if(this.pixels=new Uint8Array(o.data.buffer),this.encoding=c||"mapbox",this.borderReady=d,!d){for(let w=0;w<y;w++)v[this._idx(-1,w)]=v[this._idx(0,w)],v[this._idx(y,w)]=v[this._idx(y-1,w)],v[this._idx(w,-1)]=v[this._idx(w,0)],v[this._idx(w,y)]=v[this._idx(w,y-1)];v[this._idx(-1,-1)]=v[this._idx(0,0)],v[this._idx(y,-1)]=v[this._idx(y-1,0)],v[this._idx(-1,y)]=v[this._idx(0,y-1)],v[this._idx(y,y)]=v[this._idx(y-1,y-1)],m&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new zw(this)}get(t,o,c=!1){c&&(t=ie(t,-1,this.dim),o=ie(o,-1,this.dim));const d=4*this._idx(t,o);return(this.encoding==="terrarium"?this._unpackTerrarium:this._unpackMapbox)(this.pixels[d],this.pixels[d+1],this.pixels[d+2])}static getUnpackVector(t){return Bw[t]}get unpackVector(){return Bw[this.encoding]}_idx(t,o){if(t<-1||t>=this.dim+1||o<-1||o>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(o+1)*this.stride+(t+1)}_unpackMapbox(t,o,c){return(256*t*256+256*o+c)/10-1e4}_unpackTerrarium(t,o,c){return 256*t+o+c/256-32768}static pack(t,o){const c=[0,0,0,0],d=Bg.getUnpackVector(o);let m=Math.floor((t+d[3])/d[2]);return c[2]=m%256,m=Math.floor(m/256),c[1]=m%256,m=Math.floor(m/256),c[0]=m,c}getPixels(){return new Yr({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,o,c){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let d=o*this.dim,m=o*this.dim+this.dim,y=c*this.dim,v=c*this.dim+this.dim;switch(o){case-1:d=m-1;break;case 1:m=d+1}switch(c){case-1:y=v-1;break;case 1:v=y+1}const w=-o*this.dim,A=-c*this.dim;for(let D=y;D<v;D++)for(let R=d;R<m;R++){const k=4*this._idx(R,D),V=4*this._idx(R+w,D+A);this.pixels[k+0]=t.pixels[V+0],this.pixels[k+1]=t.pixels[V+1],this.pixels[k+2]=t.pixels[V+2],this.pixels[k+3]=t.pixels[V+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}jt(Bg,"DEMData"),jt(zw,"DemMinMaxQuadTree",{omit:["dem"]});class WI{constructor(t,o){this.max=t,this.onRemove=o,this.reset()}reset(){for(const t in this.data)for(const o of this.data[t])o.timeout&&clearTimeout(o.timeout),this.onRemove(o.value);return this.data={},this.order=[],this}add(t,o,c){const d=t.wrapped().key;this.data[d]===void 0&&(this.data[d]=[]);const m={value:o,timeout:void 0};if(c!==void 0&&(m.timeout=setTimeout(()=>{this.remove(t,m)},c)),this.data[d].push(m),this.order.push(d),this.order.length>this.max){const y=this._getAndRemoveByKey(this.order[0]);y&&this.onRemove(y)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const o=this.data[t].shift();return o.timeout&&clearTimeout(o.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),o.value}getByKey(t){const o=this.data[t];return o?o[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,o){if(!this.has(t))return this;const c=t.wrapped().key,d=o===void 0?0:this.data[c].indexOf(o),m=this.data[c][d];return this.data[c].splice(d,1),m.timeout&&clearTimeout(m.timeout),this.data[c].length===0&&delete this.data[c],this.onRemove(m.value),this.order.splice(this.order.indexOf(c),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(t){const o=[];for(const c in this.data)for(const d of this.data[c])t(d.value)||o.push(d);for(const c of o)this.remove(c.value.tileID,c)}}class Ku{constructor(t,o,c){this.func=t,this.mask=o,this.range=c}}Ku.ReadOnly=!1,Ku.ReadWrite=!0,Ku.disabled=new Ku(519,Ku.ReadOnly,[0,1]);const Gv=7680;class Hv{constructor(t,o,c,d,m,y){this.test=t,this.ref=o,this.mask=c,this.fail=d,this.depthFail=m,this.pass=y}}Hv.disabled=new Hv({func:519,mask:0},0,0,Gv,Gv,Gv);class xo{constructor(t,o,c){this.blendFunction=t,this.blendColor=o,this.mask=c}}xo.Replace=[1,0],xo.disabled=new xo(xo.Replace,Xn.transparent,[!1,!1,!1,!1]),xo.unblended=new xo(xo.Replace,Xn.transparent,[!0,!0,!0,!0]),xo.alphaBlended=new xo([1,771],Xn.transparent,[!0,!0,!0,!0]);const Wv=1029,jv=2305;class Wa{constructor(t,o,c){this.enable=t,this.mode=o,this.frontFace=c}}Wa.disabled=new Wa(!1,Wv,jv),Wa.backCCW=new Wa(!0,Wv,jv),Wa.backCW=new Wa(!0,Wv,2304),Wa.frontCW=new Wa(!0,1028,2304),Wa.frontCCW=new Wa(!0,1028,jv);class Yl extends ze{constructor(t,o,c){super(),this.id=t,this._onlySymbols=c,o.on("data",d=>{d.dataType==="source"&&d.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&d.dataType==="source"&&d.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new WI(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new HI,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(t){this.map=t,this._minTileCacheSize=this._minTileCacheSize===void 0&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles){const o=this._tiles[t];if(o.state!=="loaded"&&o.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,o){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,o)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,()=>{})}serialize(){return this._source.serialize()}prepare(t){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const o in this._tiles){const c=this._tiles[o];this._source.prepareTile(c)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,c.tileID),c.upload(t),c.prepare(this.map.style.imageManager)}else for(const o in this._tiles){const c=this._tiles[o];c.upload(t),c.prepare(this.map.style.imageManager)}}getIds(){return De(this._tiles).map(t=>t.tileID).sort(Fw).map(t=>t.key)}getRenderableIds(t){const o=[];for(const c in this._tiles)this._isIdRenderable(+c,t)&&o.push(this._tiles[c]);return t?o.sort((c,d)=>{const m=c.tileID,y=d.tileID,v=new E(m.canonical.x,m.canonical.y)._rotate(this.transform.angle),w=new E(y.canonical.x,y.canonical.y)._rotate(this.transform.angle);return m.overscaledZ-y.overscaledZ||w.y-v.y||w.x-v.x}).map(c=>c.tileID.key):o.map(c=>c.tileID).sort(Fw).map(c=>c.key)}hasRenderableParent(t){const o=this.findLoadedParent(t,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(t,o){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(o||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(+t,"reloading")}}_reloadTile(t,o){const c=this._tiles[t];c&&(c.state!=="loading"&&(c.state=o),this._loadTile(c,this._tileLoaded.bind(this,c,t,o)))}_tileLoaded(t,o,c,d){if(d)if(t.state="errored",d.status!==404)this._source.fire(new Y(d,{tile:t}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const m=this.map.painter.terrain;this.update(this.transform,m.getScaledDemTileSize(),!0),m.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=bt.now(),c==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(o,t),this._source.type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new W("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const o=this.getRenderableIds();for(let d=0;d<o.length;d++){const m=o[d];if(t.neighboringTiles&&t.neighboringTiles[m]){const y=this.getTileByID(m);c(t,y),c(y,t)}}function c(d,m){if(!d.dem||d.dem.borderReady)return;d.needsHillshadePrepare=!0,d.needsDEMTextureUpload=!0;let y=m.tileID.canonical.x-d.tileID.canonical.x;const v=m.tileID.canonical.y-d.tileID.canonical.y,w=Math.pow(2,d.tileID.canonical.z),A=m.tileID.key;y===0&&v===0||Math.abs(v)>1||(Math.abs(y)>1&&(Math.abs(y+w)===1?y+=w:Math.abs(y-w)===1&&(y-=w)),m.dem&&d.dem&&(d.dem.backfillBorder(m.dem,y,v),d.neighboringTiles&&d.neighboringTiles[A]&&(d.neighboringTiles[A].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,o,c,d){for(const m in this._tiles){let y=this._tiles[m];if(d[m]||!y.hasData()||y.tileID.overscaledZ<=o||y.tileID.overscaledZ>c)continue;let v=y.tileID;for(;y&&y.tileID.overscaledZ>o+1;){const A=y.tileID.scaledTo(y.tileID.overscaledZ-1);y=this._tiles[A.key],y&&y.hasData()&&(v=A)}let w=v;for(;w.overscaledZ>o;)if(w=w.scaledTo(w.overscaledZ-1),t[w.key]){d[v.key]=v;break}}}findLoadedParent(t,o){if(t.key in this._loadedParentTiles){const c=this._loadedParentTiles[t.key];return c&&c.tileID.overscaledZ>=o?c:null}for(let c=t.overscaledZ-1;c>=o;c--){const d=t.scaledTo(c),m=this._getLoadedTile(d);if(m)return m}}_getLoadedTile(t){const o=this._tiles[t.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,o){o=o||this._source.tileSize;const c=Math.ceil(t.width/o)+1,d=Math.ceil(t.height/o)+1,m=Math.floor(c*d*5),y=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,m):m,v=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,y):y;this._cache.setMaxSize(v)}handleWrapJump(t){const o=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,o){const c={};for(const d in this._tiles){const m=this._tiles[d];m.tileID=m.tileID.unwrapTo(m.tileID.wrap+o),c[m.tileID.key]=m}this._tiles=c;for(const d in this._timers)clearTimeout(this._timers[d]),delete this._timers[d];for(const d in this._tiles)this._setTileReloadTimer(+d,this._tiles[d])}}update(t,o,c){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!c)return;let d;this.updateCacheSize(t,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?d=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(v=>new yr(v.canonical.z,v.wrap,v.canonical.z,v.canonical.x,v.canonical.y)):(d=t.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(d=d.filter(v=>this._source.hasTile(v)))):d=[];const m=this._updateRetainedTiles(d);if(Ow(this._source.type)&&d.length!==0){const v={},w={},A=Object.keys(m);for(const R of A){const k=m[R],V=this._tiles[R];if(!V||V.fadeEndTime&&V.fadeEndTime<=bt.now())continue;const j=this.findLoadedParent(k,Math.max(k.overscaledZ-Yl.maxOverzooming,this._source.minzoom));j&&(this._addTile(j.tileID),v[j.tileID.key]=j.tileID),w[R]=k}const D=d[d.length-1].overscaledZ;for(const R in this._tiles){const k=this._tiles[R];if(m[R]||!k.hasData())continue;let V=k.tileID;for(;V.overscaledZ>D;){V=V.scaledTo(V.overscaledZ-1);const j=this._tiles[V.key];if(j&&j.hasData()&&w[V.key]){m[R]=k.tileID;break}}}for(const R in v)m[R]||(this._coveredTiles[R]=!0,m[R]=v[R])}for(const v in m)this._tiles[v].clearFadeHold();const y=function(v,w){const A=[];for(const D in v)D in w||A.push(D);return A}(this._tiles,m);for(const v of y){const w=this._tiles[v];w.hasSymbolBuckets&&!w.holdingForFade()?w.setHoldDuration(this.map._fadeDuration):w.hasSymbolBuckets&&!w.symbolFadeFinished()||this._removeTile(+v)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const o={};if(t.length===0)return o;const c={},d=t.reduce((A,D)=>Math.min(A,D.overscaledZ),1/0),m=t[0].overscaledZ,y=Math.max(m-Yl.maxOverzooming,this._source.minzoom),v=Math.max(m+Yl.maxUnderzooming,this._source.minzoom),w={};for(const A of t){const D=this._addTile(A);o[A.key]=A,D.hasData()||d<this._source.maxzoom&&(w[A.key]=A)}this._retainLoadedChildren(w,d,v,o);for(const A of t){let D=this._tiles[A.key];if(D.hasData())continue;if(A.canonical.z>=this._source.maxzoom){const k=A.children(this._source.maxzoom)[0],V=this.getTile(k);if(V&&V.hasData()){o[k.key]=k;continue}}else{const k=A.children(this._source.maxzoom);if(o[k[0].key]&&o[k[1].key]&&o[k[2].key]&&o[k[3].key])continue}let R=D.wasRequested();for(let k=A.overscaledZ-1;k>=y;--k){const V=A.scaledTo(k);if(c[V.key]||(c[V.key]=!0,D=this.getTile(V),!D&&R&&(D=this._addTile(V)),D&&(o[V.key]=V,R=D.wasRequested(),D.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const o=[];let c,d=this._tiles[t].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){c=this._loadedParentTiles[d.key];break}o.push(d.key);const m=d.scaledTo(d.overscaledZ-1);if(c=this._getLoadedTile(m),c)break;d=m}for(const m of o)this._loadedParentTiles[m]=c}}_addTile(t){let o=this._tiles[t.key];if(o)return this._source.prepareTile&&this._source.prepareTile(o),o;o=this._cache.getAndRemove(t),o&&(this._setTileReloadTimer(t.key,o),o.tileID=t,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,o)));const c=!!o;if(!c){const d=this.map?this.map.painter:null;o=new Vv(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,d,this._isRaster),this._source.prepareTile&&this._source.prepareTile(o)||this._loadTile(o,this._tileLoaded.bind(this,o,t.key,o.state))}return o?(o.uses++,this._tiles[t.key]=o,c||this._source.fire(new W("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o):null}_setTileReloadTimer(t,o){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const c=o.getExpiryTimeout();c&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},c))}_removeTile(t){const o=this._tiles[t];o&&(o.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),o.uses>0||(o.hasData()&&o.state!=="reloading"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,o,c){const d=[],m=this.transform;if(!m)return d;for(const y in this._tiles){const v=this._tiles[y];if(c&&v.clearQueryDebugViz(),v.holdingForFade())continue;const w=t.containsTile(v,m,o);w&&d.push(w)}return d}getVisibleCoordinates(t){const o=this.getRenderableIds(t).map(c=>this._tiles[c].tileID);for(const c of o)c.projMatrix=this.transform.calculateProjMatrix(c.toUnwrapped());return o}hasTransition(){if(this._source.hasTransition())return!0;if(Ow(this._source.type))for(const t in this._tiles){const o=this._tiles[t];if(o.fadeEndTime!==void 0&&o.fadeEndTime>=bt.now())return!0}return!1}setFeatureState(t,o,c){this._state.updateState(t=t||"_geojsonTileLayer",o,c)}removeFeatureState(t,o,c){this._state.removeFeatureState(t=t||"_geojsonTileLayer",o,c)}getFeatureState(t,o){return this._state.getState(t=t||"_geojsonTileLayer",o)}setDependencies(t,o,c){const d=this._tiles[t];d&&d.setDependencies(o,c)}reloadTilesForDependencies(t,o){for(const c in this._tiles)this._tiles[c].hasDependency(t,o)&&this._reloadTile(+c,"reloading");this._cache.filter(c=>!c.hasDependency(t,o))}_preloadTiles(t,o){const c=new Map,d=Array.isArray(t)?t:[t],m=this.map.painter.terrain,y=this.usedForTerrain&&m?m.getScaledDemTileSize():this._source.tileSize;for(const v of d){const w=v.coveringTiles({tileSize:y,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const A of w)c.set(A.key,A);this.usedForTerrain&&v.updateElevation(!1)}le(Array.from(c.values()),(v,w)=>{const A=new Vv(v,this._source.tileSize*v.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(A,D=>{this._source.type==="raster-dem"&&A.dem&&this._backfillDEM(A),w(D,A)})},o)}}function Fw(a,t){const o=Math.abs(2*a.wrap)-+(a.wrap<0),c=Math.abs(2*t.wrap)-+(t.wrap<0);return a.overscaledZ-t.overscaledZ||c-o||t.canonical.y-a.canonical.y||t.canonical.x-a.canonical.x}function Ow(a){return a==="raster"||a==="image"||a==="video"}Yl.maxOverzooming=10,Yl.maxUnderzooming=3;class Fg{constructor(t,o,c){this._demTile=t,this._dem=this._demTile.dem,this._scale=o,this._offset=c}static create(t,o,c){const d=c||t.findDEMTileFor(o);if(!d||!d.dem)return;const m=d.dem,y=d.tileID,v=1<<o.canonical.z-y.canonical.z;return new Fg(d,d.tileSize/In/v,[(o.canonical.x/v-y.canonical.x)*m.dim,(o.canonical.y/v-y.canonical.y)*m.dim])}tileCoordToPixel(t,o){const c=o*this._scale+this._offset[1],d=Math.floor(t*this._scale+this._offset[0]),m=Math.floor(c);return new E(d,m)}getElevationAt(t,o,c,d){const m=t*this._scale+this._offset[0],y=o*this._scale+this._offset[1],v=Math.floor(m),w=Math.floor(y),A=this._dem;return d=!!d,c?gn(gn(A.get(v,w,d),A.get(v,w+1,d),y-w),gn(A.get(v+1,w,d),A.get(v+1,w+1,d),y-w),m-v):A.get(v,w,d)}getElevationAtPixel(t,o,c){return this._dem.get(t,o,!!c)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*Ou(1,t)*this._dem.stride}}class Nw{constructor(t,o){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ho(In,16,0),this.featureIndexArray=new xi,this.promoteId=o}insert(t,o,c,d,m,y=0){const v=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(c,d,m,y);const w=this.grid;for(let A=0;A<o.length;A++){const D=o[A],R=[1/0,1/0,-1/0,-1/0];for(let k=0;k<D.length;k++){const V=D[k];R[0]=Math.min(R[0],V.x),R[1]=Math.min(R[1],V.y),R[2]=Math.max(R[2],V.x),R[3]=Math.max(R[3],V.y)}R[0]<In&&R[1]<In&&R[2]>=0&&R[3]>=0&&w.insert(v,R[0],R[1],R[2],R[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Zl.VectorTile(new Mp(this.rawTileData)).layers,this.sourceLayerCoder=new Tw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,o,c,d){this.loadVTLayers();const m=t.params||{},y=lo(m.filter),v=t.tileResult,w=t.transform,A=v.bufferedTilespaceBounds,D=this.grid.query(A.min.x,A.min.y,A.max.x,A.max.y,(j,$,ne,me)=>ob(v.bufferedTilespaceGeometry,j,$,ne,me));D.sort(jI);let R=null;w.elevation&&D.length>0&&(R=Fg.create(w.elevation,this.tileID));const k={};let V;for(let j=0;j<D.length;j++){const $=D[j];if($===V)continue;V=$;const ne=this.featureIndexArray.get($);let me=null;this.loadMatchingFeature(k,ne,y,m.layers,m.availableImages,o,c,d,(ke,He,Ze,Xe=0)=>(me||(me=Xo(ke,this.tileID.canonical,t.tileTransform)),He.queryIntersectsFeature(v,ke,Ze,me,this.z,t.transform,t.pixelPosMatrix,R,Xe)))}return k}loadMatchingFeature(t,o,c,d,m,y,v,w,A){const{featureIndex:D,bucketIndex:R,sourceLayerIndex:k,layoutVertexArrayOffset:V}=o,j=this.bucketLayerIDs[R];if(d&&!function(ke,He){for(let Ze=0;Ze<ke.length;Ze++)if(He.indexOf(ke[Ze])>=0)return!0;return!1}(d,j))return;const $=this.sourceLayerCoder.decode(k),ne=this.vtLayers[$].feature(D);if(c.needGeometry){const ke=Wl(ne,!0);if(!c.filter(new ci(this.tileID.overscaledZ),ke,this.tileID.canonical))return}else if(!c.filter(new ci(this.tileID.overscaledZ),ne))return;const me=this.getId(ne,$);for(let ke=0;ke<j.length;ke++){const He=j[ke];if(d&&d.indexOf(He)<0)continue;const Ze=y[He];if(!Ze)continue;let Xe={};me!==void 0&&w&&(Xe=w.getState(Ze.sourceLayer||"_geojsonTileLayer",me));const Ye=ye({},v[He]);Ye.paint=Uw(Ye.paint,Ze.paint,ne,Xe,m),Ye.layout=Uw(Ye.layout,Ze.layout,ne,Xe,m);const lt=!A||A(ne,Ze,Xe,V);if(!lt)continue;const ht=new Ew(ne,this.z,this.x,this.y,me);ht.layer=Ye;let vt=t[He];vt===void 0&&(vt=t[He]=[]),vt.push({featureIndex:D,feature:ht,intersectionZ:lt})}}lookupSymbolFeatures(t,o,c,d,m,y,v,w){const A={};this.loadVTLayers();const D=lo(m);for(const R of t)this.loadMatchingFeature(A,{bucketIndex:c,sourceLayerIndex:d,featureIndex:R,layoutVertexArrayOffset:0},D,y,v,w,o);return A}loadFeature(t){const{featureIndex:o,sourceLayerIndex:c}=t;this.loadVTLayers();const d=this.sourceLayerCoder.decode(c),m=this.vtFeatures[d];if(m[o])return m[o];const y=this.vtLayers[d].feature(o);return m[o]=y,y}hasLayer(t){for(const o of this.bucketLayerIDs)for(const c of o)if(t===c)return!0;return!1}getId(t,o){let c=t.id;return this.promoteId&&(c=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[o]],typeof c=="boolean"&&(c=Number(c))),c}}function Uw(a,t,o,c,d){return At(a,(m,y)=>{const v=t instanceof b?t.get(y):null;return v&&v.evaluate?v.evaluate(o,c,d):v})}function jI(a,t){return t-a}jt(Nw,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Vw{constructor(t){const o={},c=[];for(const v in t){const w=t[v],A=o[v]={};for(const D in w.glyphs){const R=w.glyphs[+D];if(!R||R.bitmap.width===0||R.bitmap.height===0)continue;const k=R.metrics.localGlyph?2:1,V={x:0,y:0,w:R.bitmap.width+2*k,h:R.bitmap.height+2*k};c.push(V),A[D]=V}}const{w:d,h:m}=Mv(c),y=new Yo({width:d||1,height:m||1});for(const v in t){const w=t[v];for(const A in w.glyphs){const D=w.glyphs[+A];if(!D||D.bitmap.width===0||D.bitmap.height===0)continue;const R=o[v][A],k=D.metrics.localGlyph?2:1;Yo.copy(D.bitmap,y,{x:0,y:0},{x:R.x+k,y:R.y+k},D.bitmap)}}this.image=y,this.positions=o}}jt(Vw,"GlyphAtlas");class qI{constructor(t){this.tileID=new yr(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=Xl(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,o,c,d,m){this.status="parsing",this.data=t,this.collisionBoxArray=new Ua;const y=new Tw(Object.keys(t.layers).sort()),v=new Nw(this.tileID,this.promoteId);v.bucketLayerIDs=[];const w={},A=new Fv(256,256),D={featureIndex:v,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:A,availableImages:c},R=o.familiesBySource[this.source];for(const Xe in R){const Ye=t.layers[Xe];if(!Ye)continue;let lt=!1,ht=!1;for(const rt of R[Xe])rt[0].type==="symbol"?lt=!0:ht=!0;if(this.isSymbolTile===!0&&!lt||this.isSymbolTile===!1&&!ht)continue;Ye.version===1&&ge(`Vector tile source "${this.source}" layer "${Xe}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const vt=y.encode(Xe),Tt=[];for(let rt=0;rt<Ye.length;rt++){const ft=Ye.feature(rt),Ct=v.getId(ft,Xe);Tt.push({feature:ft,id:Ct,index:rt,sourceLayerIndex:vt})}for(const rt of R[Xe]){const ft=rt[0];this.isSymbolTile!==void 0&&ft.type==="symbol"!==this.isSymbolTile||ft.minzoom&&this.zoom<Math.floor(ft.minzoom)||ft.maxzoom&&this.zoom>=ft.maxzoom||ft.visibility!=="none"&&(qv(rt,this.zoom,c),(w[ft.id]=ft.createBucket({index:v.bucketLayerIDs.length,layers:rt,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:vt,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.name,availableImages:c})).populate(Tt,D,this.tileID.canonical,this.tileTransform),v.bucketLayerIDs.push(rt.map(Ct=>Ct.id)))}}let k,V,j,$;A.trim();const ne={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},me=At(D.glyphDependencies,Xe=>Object.keys(Xe).map(Number));Object.keys(me).length?d.send("getGlyphs",{uid:this.uid,stacks:me},(Xe,Ye)=>{k||(k=Xe,V=Ye,Ze.call(this))},void 0,!1,ne):V={};const ke=Object.keys(D.iconDependencies);ke.length?d.send("getImages",{icons:ke,source:this.source,tileID:this.tileID,type:"icons"},(Xe,Ye)=>{k||(k=Xe,j=Ye,Ze.call(this))},void 0,!1,ne):j={};const He=Object.keys(D.patternDependencies);function Ze(){if(k)return m(k);if(V&&j&&$){const Xe=new Vw(V),Ye=new qb(j,$);for(const lt in w){const ht=w[lt];ht instanceof Us?(qv(ht.layers,this.zoom,c),xI(ht,V,Xe.positions,j,Ye.iconPositions,this.showCollisionBoxes,c,this.tileID.canonical,this.tileZoom,this.projection)):ht.hasPattern&&(ht instanceof Tg||ht instanceof wg||ht instanceof xp)&&(qv(ht.layers,this.zoom,c),ht.addFeatures(D,this.tileID.canonical,Ye.patternPositions,c,this.tileTransform))}this.status="done",m(null,{buckets:De(w).filter(lt=>!lt.isEmpty()),featureIndex:v,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Xe.image,lineAtlas:A,imageAtlas:Ye,glyphMap:this.returnDependencies?V:null,iconMap:this.returnDependencies?j:null,glyphPositions:this.returnDependencies?Xe.positions:null})}}He.length?d.send("getImages",{icons:He,source:this.source,tileID:this.tileID,type:"patterns"},(Xe,Ye)=>{k||(k=Xe,$=Ye,Ze.call(this))},void 0,!1,ne):$={},Ze.call(this)}}function qv(a,t,o){const c=new ci(t);for(const d of a)d.recalculate(c,o)}class Gw{constructor(t){this.entries={},this.scheduler=t}request(t,o,c,d){const m=this.entries[t]=this.entries[t]||{callbacks:[]};if(m.result){const[y,v]=m.result;return this.scheduler?this.scheduler.add(()=>{d(y,v)},o):d(y,v),()=>{}}return m.callbacks.push(d),m.cancel||(m.cancel=c((y,v)=>{m.result=[y,v];for(const w of m.callbacks)this.scheduler?this.scheduler.add(()=>{w(y,v)},o):w(y,v);setTimeout(()=>delete this.entries[t],3e3)})),()=>{m.result||(m.callbacks=m.callbacks.filter(y=>y!==d),m.callbacks.length||(m.cancel(),delete this.entries[t]))}}}function Hw(a,t,o){const c=JSON.stringify(a.request);return a.data&&(this.deduped.entries[c]={result:[null,a.data]}),this.deduped.request(c,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},d=>{const m=Le(a.request,(y,v,w,A)=>{y?d(y):v&&d(null,{vectorTile:o?void 0:new Zl.VectorTile(new Mp(v)),rawData:v,cacheControl:w,expires:A})});return()=>{m.cancel(),d()}},t)}const ZI=go(new Float32Array(16));class Ws{constructor(t){this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,o){return{x:0,y:0,z:0}}unproject(t,o){return new ti(0,0)}projectTilePoint(t,o,c){return{x:t,y:o,z:0}}locationPoint(t,o){return t._coordinatePoint(t.locationCoordinate(o),!1)}pixelsPerMeter(t,o){return Ou(1,t)*o}farthestPixelDistance(t){return function(o,c){const d=o.fovAboveCenter,m=o.elevation?o.elevation.getMinElevationBelowMSL()*c:0,y=(o._camera.position[2]*o.worldSize-m)/Math.cos(o._pitch),v=Math.sin(d)*y/Math.sin(Math.max(Math.PI/2-o._pitch-d,.01)),w=Math.sin(o._pitch)*v+y;return Math.min(1.01*w,y*(1/o._horizonShift))}(t,t.pixelsPerMeter)}pointCoordinate(t,o,c,d){const m=t.horizonLineFromTop(!1),y=new E(o,Math.max(m,c));return t.rayIntersectionCoordinate(t.pointRayIntersection(y,d))}createInversionMatrix(t,o){return ZI}createTileMatrix(t,o,c){let d,m,y;const v=c.canonical,w=go(new Float64Array(16));if(this.isReprojectedInTileSpace){const A=Xl(v,this);d=1,m=A.x+c.wrap*A.scale,y=A.y,Fs(w,w,[d/A.scale,d/A.scale,t.pixelsPerMeter/o])}else d=o/t.zoomScale(v.z),m=(v.x+Math.pow(2,v.z)*c.wrap)*d,y=v.y*d;return jl(w,w,[m,y,0]),Fs(w,w,[d/In,d/In,1]),w}upVector(t,o,c){return[0,0,1]}upVectorScale(t,o,c){return{metersToTile:1,metersToLabelSpace:1}}}class XI extends Ws{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,o){return{x:lp(t),y:Fu(o),z:0}}unproject(t,o){const c=Ta(t),d=rr(o);return new ti(c,d)}}class YI extends Ws{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[o,c]=this.parallels=t.parallels||[29.5,45.5],d=Math.sin(U(o));this.n=(d+Math.sin(U(c)))/2,this.c=1+d*(2*this.n-d),this.r0=Math.sqrt(this.c)/this.n}project(t,o){const{n:c,c:d,r0:m}=this,y=U(t-this.center[0]),v=U(o),w=Math.sqrt(d-2*c*Math.sin(v))/c;return{x:w*Math.sin(y*c),y:w*Math.cos(y*c)-m,z:0}}unproject(t,o){const{n:c,c:d,r0:m}=this,y=m+o;let v=Math.atan2(t,Math.abs(y))*Math.sign(y);y*c<0&&(v-=Math.PI*Math.sign(t)*Math.sign(y));const w=U(this.center[0])*c;v=ae(v,-Math.PI-w,Math.PI-w);const A=q(v/c)+this.center[0],D=Math.asin(ie((d-(t*t+y*y)*c*c)/(2*c),-1,1)),R=ie(q(D),-85.051129,mo);return new ti(A,R)}}const Lp=1.340264,Dp=-.081106,Ip=893e-6,Rp=.003796,Og=Math.sqrt(3)/2;class $I extends Ws{project(t,o){o=o/180*Math.PI,t=t/180*Math.PI;const c=Math.asin(Og*Math.sin(o)),d=c*c,m=d*d*d;return{x:.5*(t*Math.cos(c)/(Og*(Lp+3*Dp*d+m*(7*Ip+9*Rp*d)))/Math.PI+.5),y:1-.5*(c*(Lp+Dp*d+m*(Ip+Rp*d))/Math.PI+1),z:0}}unproject(t,o){t=(2*t-.5)*Math.PI;let c=o=(2*(1-o)-1)*Math.PI,d=c*c,m=d*d*d;for(let D,R,k,V=0;V<12&&(R=c*(Lp+Dp*d+m*(Ip+Rp*d))-o,k=Lp+3*Dp*d+m*(7*Ip+9*Rp*d),D=R/k,c=ie(c-D,-Math.PI/3,Math.PI/3),d=c*c,m=d*d*d,!(Math.abs(D)<1e-12));++V);const y=Og*t*(Lp+3*Dp*d+m*(7*Ip+9*Rp*d))/Math.cos(c),v=Math.asin(Math.sin(c)/Og),w=ie(180*y/Math.PI,-180,180),A=ie(180*v/Math.PI,-85.051129,mo);return new ti(w,A)}}class JI extends Ws{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,o){return{x:.5+t/360,y:.5-o/360,z:0}}unproject(t,o){const c=360*(t-.5),d=ie(360*(.5-o),-85.051129,mo);return new ti(c,d)}}const Qu=Math.PI/2;function Ng(a){return Math.tan((Qu+a)/2)}class KI extends Ws{constructor(t){super(t),this.center=t.center||[0,30];const[o,c]=this.parallels=t.parallels||[30,30],d=U(o),m=U(c),y=Math.cos(d);this.n=d===m?Math.sin(d):Math.log(y/Math.cos(m))/Math.log(Ng(m)/Ng(d)),this.f=y*Math.pow(Ng(d),this.n)/this.n}project(t,o){o=U(o),t=U(t-this.center[0]);const c=1e-6,{n:d,f:m}=this;m>0?o<-Qu+c&&(o=-Qu+c):o>Qu-c&&(o=Qu-c);const y=m/Math.pow(Ng(o),d),v=y*Math.sin(d*t),w=m-y*Math.cos(d*t);return{x:.5*(v/Math.PI+.5),y:1-.5*(w/Math.PI+.5),z:0}}unproject(t,o){t=(2*t-.5)*Math.PI,o=(2*(1-o)-.5)*Math.PI;const{n:c,f:d}=this,m=d-o,y=Math.sign(m),v=Math.sign(c)*Math.sqrt(t*t+m*m);let w=Math.atan2(t,Math.abs(m))*y;m*c<0&&(w-=Math.PI*Math.sign(t)*y);const A=ie(q(w/c)+this.center[0],-180,180),D=ie(q(2*Math.atan(Math.pow(d/v,1/c))-Qu),-85.051129,mo);return new ti(A,D)}}const Ww=U(mo);class QI extends Ws{project(t,o){const c=(o=U(o))*o,d=c*c;return{x:.5*((t=U(t))*(.8707-.131979*c+d*(d*(.003971*c-.001529*d)-.013791))/Math.PI+.5),y:1-.5*(o*(1.007226+c*(.015085+d*(.028874*c-.044475-.005916*d)))/Math.PI+1),z:0}}unproject(t,o){t=(2*t-.5)*Math.PI;let c=o=(2*(1-o)-1)*Math.PI,d=25,m=0,y=c*c;do{y=c*c;const A=y*y;m=(c*(1.007226+y*(.015085+A*(.028874*y-.044475-.005916*A)))-o)/(1.007226+y*(.045255+A*(.259866*y-.311325-.06507600000000001*A))),c=ie(c-m,-Ww,Ww)}while(Math.abs(m)>1e-6&&--d>0);y=c*c;const v=ie(q(t/(.8707+y*(y*(y*y*y*(.003971-.001529*y)-.013791)-.131979))),-180,180),w=q(c);return new ti(v,w)}}const jw=U(mo);class eR extends Ws{project(t,o){o=U(o),t=U(t);const c=Math.cos(o),d=2/Math.PI,m=Math.acos(c*Math.cos(t/2)),y=Math.sin(m)/m,v=.5*(t*d+2*c*Math.sin(t/2)/y)||0,w=.5*(o+Math.sin(o)/y)||0;return{x:.5*(v/Math.PI+.5),y:1-.5*(w/Math.PI+1),z:0}}unproject(t,o){let c=t=(2*t-.5)*Math.PI,d=o=(2*(1-o)-1)*Math.PI,m=25;const y=1e-6;let v=0,w=0;do{const A=Math.cos(d),D=Math.sin(d),R=2*D*A,k=D*D,V=A*A,j=Math.cos(c/2),$=Math.sin(c/2),ne=2*j*$,me=$*$,ke=1-V*j*j,He=ke?1/ke:0,Ze=ke?Math.acos(A*j)*Math.sqrt(1/ke):0,Xe=.5*(2*Ze*A*$+2*c/Math.PI)-t,Ye=.5*(Ze*D+d)-o,lt=.5*He*(V*me+Ze*A*j*k)+1/Math.PI,ht=He*(ne*R/4-Ze*D*$),vt=.125*He*(R*$-Ze*D*V*ne),Tt=.5*He*(k*j+Ze*me*A)+.5,rt=ht*vt-Tt*lt;v=(Ye*ht-Xe*Tt)/rt,w=(Xe*vt-Ye*lt)/rt,c=ie(c-v,-Math.PI,Math.PI),d=ie(d-w,-jw,jw)}while((Math.abs(v)>y||Math.abs(w)>y)&&--m>0);return new ti(q(c),q(d))}}class qw extends Ws{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(U(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,o){const{scale:c,cosPhi:d}=this;return{x:U(t)*d*c+.5,y:-Math.sin(U(o))/d*c+.5,z:0}}unproject(t,o){const{scale:c,cosPhi:d}=this,m=-(o-.5)/c,y=ie(q((t-.5)/c)/d,-180,180),v=Math.asin(ie(m*d,-1,1)),w=ie(q(v),-85.051129,mo);return new ti(y,w)}}s.ARRAY_TYPE=Xr,s.AUTH_ERR_MSG=bn,s.Aabb=ga,s.Actor=class{constructor(a,t,o){this.target=a,this.parent=t,this.mapId=o,this.callbacks={},this.cancelCallbacks={},St(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=Ie()?a:I,this.scheduler=new zI}send(a,t,o,c,d=!1,m){const y=Math.round(1e18*Math.random()).toString(36).substring(0,10);o&&(o.metadata=m,this.callbacks[y]=o);const v=$e(this.globalScope)?void 0:[];return this.target.postMessage({id:y,type:a,hasCallback:!!o,targetMapId:c,mustQueue:d,sourceMapId:this.mapId,data:kl(t,v)},v),{cancel:()=>{o&&delete this.callbacks[y],this.target.postMessage({id:y,type:"<cancel>",targetMapId:c,sourceMapId:this.mapId})}}}receive(a){const t=a.data,o=t.id;if(o&&(!t.targetMapId||this.mapId===t.targetMapId))if(t.type==="<cancel>"){const c=this.cancelCallbacks[o];delete this.cancelCallbacks[o],c&&c.cancel()}else if(t.mustQueue||Ie()){const c=this.callbacks[o];this.cancelCallbacks[o]=this.scheduler.add(()=>this.processTask(o,t),c&&c.metadata||{type:"message"})}else this.processTask(o,t)}processTask(a,t){if(t.type==="<response>"){const o=this.callbacks[a];delete this.callbacks[a],o&&(t.error?o(Ps(t.error)):o(null,Ps(t.data)))}else{const o=$e(this.globalScope)?void 0:[],c=t.hasCallback?(m,y)=>{delete this.cancelCallbacks[a],this.target.postMessage({id:a,type:"<response>",sourceMapId:this.mapId,error:m?kl(m):null,data:kl(y,o)},o)}:m=>{},d=Ps(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,d,c);else if(this.parent.getWorkerSource){const m=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,m[0],d.source)[m[1]](d,c)}else c(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},s.CanonicalTileID=zg,s.Color=Xn,s.ColorMode=xo,s.CullFaceMode=Wa,s.DEMData=Bg,s.DataConstantProperty=S,s.DedupedRequest=Gw,s.DepthMode=Ku,s.EXTENT=In,s.Elevation=class{isDataAvailableAtPoint(a){const t=this._source();if(!t||a.y<0||a.y>1)return!1;const o=t.getSource().maxzoom,c=1<<o,d=Math.floor(a.x),m=Math.floor((a.x-d)*c),y=Math.floor(a.y*c),v=this.findDEMTileFor(new yr(o,d,o,m,y));return!(!v||!v.dem)}getAtPointOrZero(a,t=0){return this.getAtPoint(a,t)||0}getAtPoint(a,t,o=!0){t==null&&(t=null);const c=this._source();if(!c||a.y<0||a.y>1)return t;const d=c.getSource().maxzoom,m=1<<d,y=Math.floor(a.x),v=a.x-y,w=new yr(d,y,d,Math.floor(v*m),Math.floor(a.y*m)),A=this.findDEMTileFor(w);if(!A||!A.dem)return t;const D=A.dem,R=1<<A.tileID.canonical.z,k=(v*R-A.tileID.canonical.x)*D.dim,V=(a.y*R-A.tileID.canonical.y)*D.dim,j=Math.floor(k),$=Math.floor(V);return(o?this.exaggeration():1)*gn(gn(D.get(j,$),D.get(j,$+1),V-$),gn(D.get(j+1,$),D.get(j+1,$+1),V-$),k-j)}getAtTileOffset(a,t,o){const c=1<<a.canonical.z;return this.getAtPointOrZero(new pg(a.wrap+(a.canonical.x+t/In)/c,(a.canonical.y+o/In)/c))}getAtTileOffsetFunc(a,t,o,c){return d=>{const m=this.getAtTileOffset(a,d.x,d.y),y=c.upVector(a.canonical,d.x,d.y);return up(y,y,m*c.upVectorScale(a.canonical,t,o).metersToTile),y}}getForTilePoints(a,t,o,c){const d=Fg.create(this,a,c);return!!d&&(t.forEach(m=>{m[2]=this.exaggeration()*d.getElevationAt(m[0],m[1],o)}),!0)}getMinMaxForTile(a){const t=this.findDEMTileFor(a);if(!t||!t.dem)return null;const o=t.dem.tree,c=t.tileID,d=1<<a.canonical.z-c.canonical.z;let m=a.canonical.x/d-c.canonical.x,y=a.canonical.y/d-c.canonical.y,v=0;for(let w=0;w<a.canonical.z-c.canonical.z&&!o.leaves[v];w++){m*=2,y*=2;const A=2*Math.floor(y)+Math.floor(m);v=o.childOffsets[v]+A,m%=1,y%=1}return{min:this.exaggeration()*o.minimums[v],max:this.exaggeration()*o.maximums[v]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(a,t,o){throw new Error("Pure virtual method called.")}pointCoordinate(a){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(a){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},s.ErrorEvent=Y,s.EvaluationParameters=ci,s.Event=W,s.Evented=ze,s.FillExtrusionBucket=xp,s.Frustum=dv,s.GLOBE_RADIUS=Ju,s.GlobeSharedBuffers=class{constructor(a){this._createGrid(a),this._createPoles(a),this._createAtmosphere(a)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const a of this._poleSegments)a.destroy();this._gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this._wireframeIndexBuffer&&(this._wireframeIndexBuffer.destroy(),this._wireframeSegments.destroy())}_createGrid(a){const t=new Te,o=new qt,c=65;for(let d=0;d<c;d++)for(let m=0;m<c;m++)t.emplaceBack(m,d);for(let d=0;d<64;d++)for(let m=0;m<64;m++){const y=d*c+m;o.emplaceBack(y+1,y,y+c),o.emplaceBack(y+c,y+c+1,y+1)}this._gridBuffer=a.createVertexBuffer(t,Ap.members),this._gridIndexBuffer=a.createIndexBuffer(o,!0),this._gridSegments=Ei.simpleSegment(0,0,4225,8192)}_createPoles(a){const t=new qt;for(let d=0;d<=64;d++)t.emplaceBack(0,d+1,d+2);this._poleIndexBuffer=a.createIndexBuffer(t,!0);const o=new vn,c=new vn;this._poleSegments=[];for(let d=0,m=0;d<5;d++){const y=1<<d,v=512*y/Math.PI/2,w=360/y;o.emplaceBack(0,-v,0,0,0,.5,0),c.emplaceBack(0,-v,0,0,0,.5,1);for(let A=0;A<=64;A++){const D=A/64,R=gn(0,w,D),[k,V,j]=gw(UI,VI,R,v);o.emplaceBack(k,V,j,0,0,D,0),c.emplaceBack(k,V,j,0,0,D,1)}this._poleSegments.push(Ei.simpleSegment(m,0,66,64)),m+=66}this._poleNorthVertexBuffer=a.createVertexBuffer(o,fw,!1),this._poleSouthVertexBuffer=a.createVertexBuffer(c,fw,!1)}_createAtmosphere(a){const t=new kn;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const o=new qt;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.atmosphereVertexBuffer=a.createVertexBuffer(t,BI.members),this.atmosphereIndexBuffer=a.createIndexBuffer(o),this.atmosphereSegments=Ei.simpleSegment(0,0,4,2)}getGridBuffers(){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments]}getPoleBuffers(a){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[a]]}getWirefameBuffers(a){if(!this._wireframeSegments){const t=new Mn,o=64,c=o+1;for(let d=0;d<o;d++)for(let m=0;m<o;m++){const y=d*c+m;t.emplaceBack(y,y+1),t.emplaceBack(y,y+c),t.emplaceBack(y,y+c+1)}this._wireframeIndexBuffer=a.createIndexBuffer(t),this._wireframeSegments=Ei.simpleSegment(0,0,o*o,t.length)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments]}},s.GlyphManager=Yu,s.ImagePosition=Tv,s.LineAtlas=Fv,s.LngLat=ti,s.LngLatBounds=Bs,s.LocalGlyphMode=Cv,s.MAX_MERCATOR_LATITUDE=mo,s.MercatorCoordinate=pg,s.ONE_EM=ar,s.OverscaledTileID=yr,s.Properties=H,s.RGBAImage=Yr,s.Ray=class{constructor(a,t){this.pos=a,this.dir=t}intersectsPlane(a,t,o){const c=dp(t,this.dir);if(Math.abs(c)<1e-6)return!1;const d=((a[0]-this.pos[0])*t[0]+(a[1]-this.pos[1])*t[1]+(a[2]-this.pos[2])*t[2])/c;return o[0]=this.pos[0]+this.dir[0]*d,o[1]=this.pos[1]+this.dir[1]*d,o[2]=this.pos[2]+this.dir[2]*d,!0}closestPointOnSphere(a,t,o){if(function(k,V){var j=k[0],$=k[1],ne=k[2],me=V[0],ke=V[1],He=V[2];return Math.abs(j-me)<=rv*Math.max(1,Math.abs(j),Math.abs(me))&&Math.abs($-ke)<=rv*Math.max(1,Math.abs($),Math.abs(ke))&&Math.abs(ne-He)<=rv*Math.max(1,Math.abs(ne),Math.abs(He))}(this.pos,a)||t===0)return o[0]=o[1]=o[2]=0,!1;const[c,d,m]=this.dir,y=this.pos[0]-a[0],v=this.pos[1]-a[1],w=this.pos[2]-a[2],A=c*c+d*d+m*m,D=2*(y*c+v*d+w*m),R=D*D-4*A*(y*y+v*v+w*w-t*t);if(R<0){const k=Math.max(-D/2,0),V=y+c*k,j=v+d*k,$=w+m*k,ne=Math.hypot(V,j,$);return o[0]=V*t/ne,o[1]=j*t/ne,o[2]=$*t/ne,!1}{const k=(-D-Math.sqrt(R))/(2*A);if(k<0){const V=Math.hypot(y,v,w);return o[0]=y*t/V,o[1]=v*t/V,o[2]=w*t/V,!1}return o[0]=y+c*k,o[1]=v+d*k,o[2]=w+m*k,!0}}},s.RequestManager=class{constructor(a,t,o){this._transformRequestFn=a,this._customAccessToken=t,this._silenceAuthErrors=!!o,this._createSkuToken()}_createSkuToken(){const a=function(){let t="";for(let o=0;o<10;o++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",dn,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,t){return this._transformRequestFn&&this._transformRequestFn(a,t)||{url:a}}normalizeStyleURL(a,t){if(!ln(a))return a;const o=Zt(a);return o.path=`/styles/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||t)}normalizeGlyphsURL(a,t){if(!ln(a))return a;const o=Zt(a);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||t)}normalizeSourceURL(a,t){if(!ln(a))return a;const o=Zt(a);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),this._makeAPIURL(o,this._customAccessToken||t)}normalizeSpriteURL(a,t,o,c){const d=Zt(a);return ln(a)?(d.path=`/styles/v1${d.path}/sprite${t}${o}`,this._makeAPIURL(d,this._customAccessToken||c)):(d.path+=`${t}${o}`,qe(d))}normalizeTileURL(a,t,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),a&&!ln(a))return a;const c=Zt(a);c.path=c.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||o&&c.authority!=="raster"&&o===512?"@2x":""}${ve.supported?".webp":"$1"}`),c.authority==="raster"?c.path=`/${oe.RASTER_URL_PREFIX}${c.path}`:(c.path=c.path.replace(/^.+\/v4\//,"/"),c.path=`/${oe.TILE_URL_VERSION}${c.path}`);const d=this._customAccessToken||function(m){for(const y of m){const v=y.match(/^access_token=(.*)$/);if(v)return v[1]}return null}(c.params)||oe.ACCESS_TOKEN;return oe.REQUIRE_ACCESS_TOKEN&&d&&this._skuToken&&c.params.push(`sku=${this._skuToken}`),this._makeAPIURL(c,d)}canonicalizeTileURL(a,t){const o=Zt(a);if(!o.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!o.path.match(/\.[\w]+$/))return a;let c="mapbox://";o.path.match(/^\/raster\/v1\//)?c+=`raster/${o.path.replace(`/${oe.RASTER_URL_PREFIX}/`,"")}`:c+=`tiles/${o.path.replace(`/${oe.TILE_URL_VERSION}/`,"")}`;let d=o.params;return t&&(d=d.filter(m=>!m.match(/^access_token=/))),d.length&&(c+=`?${d.join("&")}`),c}canonicalizeTileset(a,t){const o=!!t&&ln(t),c=[];for(const d of a.tiles||[])Gt(d)?c.push(this.canonicalizeTileURL(d,o)):c.push(d);return c}_makeAPIURL(a,t){const o="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",c=Zt(oe.API_URL);if(a.protocol=c.protocol,a.authority=c.authority,a.protocol==="http"){const d=a.params.indexOf("secure");d>=0&&a.params.splice(d,1)}if(c.path!=="/"&&(a.path=`${c.path}${a.path}`),!oe.REQUIRE_ACCESS_TOKEN)return qe(a);if(t=t||oe.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if(t[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return a.params=a.params.filter(d=>d.indexOf("access_token")===-1),a.params.push(`access_token=${t||""}`),qe(a)}},s.ResourceType=_e,s.SegmentVector=Ei,s.SourceCache=Yl,s.StencilMode=Hv,s.StructArrayLayout1ui2=qn,s.StructArrayLayout2f1f2i16=Jt,s.StructArrayLayout2i4=Te,s.StructArrayLayout2ui4=Mn,s.StructArrayLayout3f12=Rt,s.StructArrayLayout3ui6=qt,s.StructArrayLayout4i8=Re,s.Texture=Sp,s.Tile=Vv,s.Transitionable=f,s.Uniform1f=hg,s.Uniform1i=class extends qo{constructor(a,t){super(a,t),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},s.Uniform2f=class extends qo{constructor(a,t){super(a,t),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},s.Uniform3f=class extends qo{constructor(a,t){super(a,t),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},s.Uniform4f=$1,s.UniformColor=J1,s.UniformMatrix2f=class extends qo{constructor(a,t){super(a,t),this.current=BL}set(a){for(let t=0;t<4;t++)if(a[t]!==this.current[t]){this.current=a,this.gl.uniformMatrix2fv(this.location,!1,a);break}}},s.UniformMatrix3f=class extends qo{constructor(a,t){super(a,t),this.current=kL}set(a){for(let t=0;t<9;t++)if(a[t]!==this.current[t]){this.current=a,this.gl.uniformMatrix3fv(this.location,!1,a);break}}},s.UniformMatrix4f=class extends qo{constructor(a,t){super(a,t),this.current=zL}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let t=1;t<16;t++)if(a[t]!==this.current[t]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},s.UnwrappedTileID=Mw,s.ValidationError=Ht,s.VectorTileWorkerSource=class extends ze{constructor(a,t,o,c,d){super(),this.actor=a,this.layerIndex=t,this.availableImages=o,this.loadVectorData=d||Hw,this.loading={},this.loaded={},this.deduped=new Gw(a.scheduler),this.isSpriteLoaded=c,this.scheduler=a.scheduler}loadTile(a,t){const o=a.uid,c=a&&a.request,d=c&&c.collectResourceTiming,m=this.loading[o]=new qI(a);m.abort=this.loadVectorData(a,(y,v)=>{const w=!this.loading[o];if(delete this.loading[o],w||y||!v)return m.status="done",w||(this.loaded[o]=m),t(y);const A=v.rawData,D={};v.expires&&(D.expires=v.expires),v.cacheControl&&(D.cacheControl=v.cacheControl),m.vectorTile=v.vectorTile||new Zl.VectorTile(new Mp(A));const R=()=>{m.parse(m.vectorTile,this.layerIndex,this.availableImages,this.actor,(k,V)=>{if(k||!V)return t(k);const j={};if(d){const $=pw(c);$.length>0&&(j.resourceTiming=JSON.parse(JSON.stringify($)))}t(null,ye({rawTileData:A.slice(0)},V,D,j))})};this.isSpriteLoaded?R():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(R,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):R()}),this.loaded=this.loaded||{},this.loaded[o]=m})}reloadTile(a,t){const o=this.loaded,c=a.uid,d=this;if(o&&o[c]){const m=o[c];m.showCollisionBoxes=a.showCollisionBoxes,m.enableTerrain=!!a.enableTerrain,m.projection=a.projection,m.tileTransform=Xl(a.tileID.canonical,a.projection);const y=(v,w)=>{const A=m.reloadCallback;A&&(delete m.reloadCallback,m.parse(m.vectorTile,d.layerIndex,this.availableImages,d.actor,A)),t(v,w)};m.status==="parsing"?m.reloadCallback=y:m.status==="done"&&(m.vectorTile?m.parse(m.vectorTile,this.layerIndex,this.availableImages,this.actor,y):y())}}abortTile(a,t){const o=a.uid,c=this.loading[o];c&&(c.abort&&c.abort(),delete this.loading[o]),t()}removeTile(a,t){const o=this.loaded,c=a.uid;o&&o[c]&&delete o[c],t()}},s.WritingMode=_a,s.ZoomHistory=Xd,s.add=db,s.addDynamicAttributes=Iv,s.adjoint=function(a,t){var o=t[0],c=t[1],d=t[2],m=t[3],y=t[4],v=t[5],w=t[6],A=t[7],D=t[8];return a[0]=y*D-v*A,a[1]=d*A-c*D,a[2]=c*v-d*y,a[3]=v*w-m*D,a[4]=o*D-d*w,a[5]=d*m-o*v,a[6]=m*A-y*w,a[7]=c*w-o*A,a[8]=o*y-c*m,a},s.asyncAll=le,s.bezier=Ce,s.bindAll=St,s.boundsAttributes=Aw,s.bufferConvexPolygon=function(a,t){const o=[];for(let c=0;c<a.length;c++){const d=ae(c-1,-1,a.length-1),m=ae(c+1,-1,a.length-1),y=a[c],v=a[m],w=a[d].sub(y).unit(),A=v.sub(y).unit(),D=A.angleWithSep(w.x,w.y),R=w.add(A).unit().mult(-1*t/Math.sin(D/2));o.push(y.add(R))}return o},s.cacheEntryPossiblyAdded=function(a){Sr++,Sr>Hr&&(a.getActor().send("enforceCacheSizeLimit",yi),Sr=0)},s.calculateGlobeLabelMatrix=function(a,t){const{lng:o,lat:c}=a._center,d=vw(0,0,a.worldSize/a._projectionScaler,o,c);return av(d,d,function(m){const y=go(new Float64Array(16)),v=1/Uv(m);return jl(y,y,m.min),Fs(y,y,[v,v,v]),y}(Cp(t)))},s.calculateGlobeMatrix=xw,s.calculateGlobeMercatorMatrix=function(a){const t=a.worldSize,o=a.point,c=Ou(1,a.center.lat)*t,d=a.pixelsPerMeter,m=t/(c/a.pixelsPerMeter),y=go(new Float64Array(16));return jl(y,y,[o.x,o.y,0]),Fs(y,y,[m,m,d]),Float32Array.from(y)},s.circumferenceAtLatitude=Ky,s.clamp=ie,s.clearTileCache=function(a){const t=I.caches.delete(Ci);a&&t.catch(a).then(()=>a())},s.clipLine=rw,s.clone=function(a){var t=new Xr(16);return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],t[6]=a[6],t[7]=a[7],t[8]=a[8],t[9]=a[9],t[10]=a[10],t[11]=a[11],t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15],t},s.clone$1=Ot,s.collisionCircleLayout=qD,s.config=oe,s.conjugate=function(a,t){return a[0]=-t[0],a[1]=-t[1],a[2]=-t[2],a[3]=t[3],a},s.create=function(){var a=new Xr(16);return Xr!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},s.create$1=cb,s.createExpression=Al,s.createLayout=Ae,s.createStyleLayer=function(a){return a.type==="custom"?new PI(a):new DI[a.type](a)},s.cross=mb,s.degToRad=U,s.div=function(a,t,o){return a[0]=t[0]/o[0],a[1]=t[1]/o[1],a[2]=t[2]/o[2],a},s.dot=dp,s.earthRadius=Jy,s.ease=K,s.easeCubicInOut=he,s.emitValidationErrors=jm,s.endsWith=gt,s.enforceCacheSizeLimit=function(a){ki(),ei&&ei.then(t=>{t.keys().then(o=>{for(let c=0;c<o.length-a;c++)t.delete(o[c])})})},s.evaluateSizeForFeature=Eg,s.evaluateSizeForZoom=ju,s.evaluateVariableOffset=cw,s.evented=rp,s.exactEquals=function(a,t){return a[0]===t[0]&&a[1]===t[1]&&a[2]===t[2]&&a[3]===t[3]},s.exactEquals$1=function(a,t){return a[0]===t[0]&&a[1]===t[1]&&a[2]===t[2]},s.exported=bt,s.exported$1=ve,s.extend=ye,s.extend$1=Mt,s.filterObject=Dt,s.fromMat4=function(a,t){return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[4],a[4]=t[5],a[5]=t[6],a[6]=t[8],a[7]=t[9],a[8]=t[10],a},s.fromQuat=function(a,t){var o=t[0],c=t[1],d=t[2],m=t[3],y=o+o,v=c+c,w=d+d,A=o*y,D=c*y,R=c*v,k=d*y,V=d*v,j=d*w,$=m*y,ne=m*v,me=m*w;return a[0]=1-R-j,a[1]=D+me,a[2]=k-ne,a[3]=0,a[4]=D-me,a[5]=1-A-j,a[6]=V+$,a[7]=0,a[8]=k+ne,a[9]=V-$,a[10]=1-A-R,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},s.fromRotation=function(a,t){var o=Math.sin(t),c=Math.cos(t);return a[0]=c,a[1]=o,a[2]=0,a[3]=-o,a[4]=c,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},s.fromScaling=function(a,t){return a[0]=t[0],a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=t[1],a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=t[2],a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},s.furthestTileCorner=function(a){const t=Math.round((a+45+360)%360/90)%4;return ee[t]},s.getAABBPointSquareDist=function(a,t,o){let c=0;for(let d=0;d<2;++d){const m=o?o[d]:0;a[d]>m&&(c+=(a[d]-m)*(a[d]-m)),t[d]<m&&(c+=(m-t[d])*(m-t[d]))}return c},s.getAnchorAlignment=Av,s.getAnchorJustification=Lv,s.getBounds=function(a){let t=1/0,o=1/0,c=-1/0,d=-1/0;for(const m of a)t=Math.min(t,m.x),o=Math.min(o,m.y),c=Math.max(c,m.x),d=Math.max(d,m.y);return{min:new E(t,o),max:new E(c,d)}},s.getColumn=function(a,t){return[a[4*t],a[4*t+1],a[4*t+2],a[4*t+3]]},s.getGridMatrix=function(a,t){const[o,c]=t,d=.015625;return[0,(c[1]-o[1])*d,1<<a.z,(c[0]-o[0])*d,0,a.y,o[0],o[1],d]},s.getImage=Ut,s.getJSON=function(a,t){return de(ye(a,{type:"json"}),t)},s.getMapSessionAPI=Wi,s.getPerformanceMeasurement=pw,s.getProjection=function(a){const t=a.parallels,o=!!t&&Math.abs(t[0]+t[1])<.01;switch(a.name){case"mercator":return new XI(a);case"equirectangular":return new JI(a);case"naturalEarth":return new QI(a);case"equalEarth":return new $I(a);case"winkelTripel":return new eR(a);case"albers":return o?new qw(a):new YI(a);case"lambertConformalConic":return o?new qw(a):new KI(a)}throw new Error(`Invalid projection name: ${a.name}`)},s.getRTLTextPluginStatus=ku,s.getReferrer=Z,s.getTilePoint=function(a,{x:t,y:o},c=0){return new E(((t-c)*a.scale-a.x)*In,(o*a.scale-a.y)*In)},s.getTileVec3=function(a,t,o=0){return cp(((t.x-o)*a.scale-a.x)*In,(t.y*a.scale-a.y)*In,eb(t.z,t.y))},s.getVideo=function(a,t){const o=I.document.createElement("video");o.muted=!0,o.onloadstart=function(){t(null,o)};for(let c=0;c<a.length;c++){const d=I.document.createElement("source");Ke(a[c])||(o.crossOrigin="Anonymous"),d.src=a[c],o.appendChild(d)}return{cancel:()=>{}}},s.globeECEFOrigin=function(a,t){const o=[0,0,0];return ql(o,o,yw(Cp(t.canonical))),ql(o,o,a),o},s.globePixelsToTileUnits=function(a,t){return In/(512*Math.pow(2,a))*Uv(Cp(t))},s.globePoleMatrixForTile=function(a,t,o){const c=go(new Float64Array(16)),d=1<<a,m=360*(t/d-.5),y=o.point,v=o.worldSize/(o.tileSize*d);return jl(c,c,[y.x,y.y,-o.worldSize/Math.PI/2]),Fs(c,c,[v,v,v]),ov(c,c,U(-o._center.lat)),sv(c,c,U(-o._center.lng+m)),Float32Array.from(c)},s.globeTileLatLngCorners=Nv,s.globeToMercatorTransition=function(a){return ue(5,6,a)},s.identity=go,s.identity$1=yb,s.invert=function(a,t){var o=t[0],c=t[1],d=t[2],m=t[3],y=t[4],v=t[5],w=t[6],A=t[7],D=t[8],R=t[9],k=t[10],V=t[11],j=t[12],$=t[13],ne=t[14],me=t[15],ke=o*v-c*y,He=o*w-d*y,Ze=o*A-m*y,Xe=c*w-d*v,Ye=c*A-m*v,lt=d*A-m*w,ht=D*$-R*j,vt=D*ne-k*j,Tt=D*me-V*j,rt=R*ne-k*$,ft=R*me-V*$,Ct=k*me-V*ne,Bt=ke*Ct-He*ft+Ze*rt+Xe*Tt-Ye*vt+lt*ht;return Bt?(a[0]=(v*Ct-w*ft+A*rt)*(Bt=1/Bt),a[1]=(d*ft-c*Ct-m*rt)*Bt,a[2]=($*lt-ne*Ye+me*Xe)*Bt,a[3]=(k*Ye-R*lt-V*Xe)*Bt,a[4]=(w*Tt-y*Ct-A*vt)*Bt,a[5]=(o*Ct-d*Tt+m*vt)*Bt,a[6]=(ne*Ze-j*lt-me*He)*Bt,a[7]=(D*lt-k*Ze+V*He)*Bt,a[8]=(y*ft-v*Tt+A*ht)*Bt,a[9]=(c*Tt-o*ft-m*ht)*Bt,a[10]=(j*Ye-$*Ze+me*ke)*Bt,a[11]=(R*Ze-D*Ye-V*ke)*Bt,a[12]=(v*vt-y*rt-w*ht)*Bt,a[13]=(o*rt-c*vt+d*ht)*Bt,a[14]=($*He-j*Xe-ne*ke)*Bt,a[15]=(D*Xe-R*He+k*ke)*Bt,a):null},s.isMapAuthenticated=function(a){return Nn.has(a)},s.isMapboxURL=ln,s.isSafariWithAntialiasingBug=function(a){const t=a.navigator?a.navigator.userAgent:null;return!!$e(a)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},s.latFromMercatorY=rr,s.len=QL,s.length=hb,s.length$1=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},s.loadVectorTile=Hw,s.makeRequest=de,s.mercatorXfromLng=lp,s.mercatorYfromLat=Fu,s.mercatorZfromAltitude=Ou,s.mul=JL,s.mul$1=KL,s.multiply=function(a,t,o){var c=t[0],d=t[1],m=t[2],y=t[3],v=t[4],w=t[5],A=t[6],D=t[7],R=t[8],k=o[0],V=o[1],j=o[2],$=o[3],ne=o[4],me=o[5],ke=o[6],He=o[7],Ze=o[8];return a[0]=k*c+V*y+j*A,a[1]=k*d+V*v+j*D,a[2]=k*m+V*w+j*R,a[3]=$*c+ne*y+me*A,a[4]=$*d+ne*v+me*D,a[5]=$*m+ne*w+me*R,a[6]=ke*c+He*y+Ze*A,a[7]=ke*d+He*v+Ze*D,a[8]=ke*m+He*w+Ze*R,a},s.multiply$1=av,s.multiply$2=fb,s.nextPowerOfTwo=We,s.normalize=hp,s.normalize$1=function(a,t){var o=t[0],c=t[1],d=t[2],m=t[3],y=o*o+c*c+d*d+m*m;return y>0&&(y=1/Math.sqrt(y)),a[0]=o*y,a[1]=c*y,a[2]=d*y,a[3]=m*y,a},s.number=gn,s.ortho=function(a,t,o,c,d,m,y){var v=1/(t-o),w=1/(c-d),A=1/(m-y);return a[0]=-2*v,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*w,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*A,a[11]=0,a[12]=(t+o)*v,a[13]=(d+c)*w,a[14]=(y+m)*A,a[15]=1,a},s.pbf=Mp,s.perspective=function(a,t,o,c,d){var m,y=1/Math.tan(t/2);return a[0]=y/o,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=y,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,d!=null&&d!==1/0?(a[10]=(d+c)*(m=1/(c-d)),a[14]=2*d*c*m):(a[10]=-1,a[14]=-2*c),a},s.pick=function(a,t){const o={};for(let c=0;c<t.length;c++){const d=t[c];d in a&&(o[d]=a[d])}return o},s.plugin=qr,s.pointGeometry=E,s.polygonIntersectsBox=ob,s.polygonIntersectsPolygon=nb,s.polygonizeBounds=function(a,t,o=0,c=!0){const d=new E(o,o),m=a.sub(d),y=t.add(d),v=[m,new E(y.x,m.y),y,new E(m.x,y.y)];return c&&v.push(m),v},s.posAttributes=Ap,s.postMapLoadEvent=Gn,s.postTurnstileEvent=pn,s.potpack=Mv,s.prevPowerOfTwo=function(a){return a<=1?1:Math.pow(2,Math.floor(Math.log(a)/Math.LN2))},s.radToDeg=q,s.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],s.registerForPluginStateChange=function(a){return a({pluginStatus:_r,pluginURL:Ir}),rp.on("pluginStateChange",a),a},s.removeAuthState=function(a){Nn.delete(a)},s.renderColorRamp=fv,s.rotateX=ov,s.rotateX$1=vb,s.rotateY=sv,s.rotateZ=function(a,t,o){var c=Math.sin(o),d=Math.cos(o),m=t[0],y=t[1],v=t[2],w=t[3],A=t[4],D=t[5],R=t[6],k=t[7];return t!==a&&(a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15]),a[0]=m*d+A*c,a[1]=y*d+D*c,a[2]=v*d+R*c,a[3]=w*d+k*c,a[4]=A*d-m*c,a[5]=D*d-y*c,a[6]=R*d-v*c,a[7]=k*d-w*c,a},s.rotateZ$1=function(a,t,o){o*=.5;var c=t[0],d=t[1],m=t[2],y=t[3],v=Math.sin(o),w=Math.cos(o);return a[0]=c*w+d*v,a[1]=d*w-c*v,a[2]=m*w+y*v,a[3]=y*w-m*v,a},s.scale=Fs,s.scale$1=function(a,t,o){return a[0]=t[0]*o,a[1]=t[1]*o,a[2]=t[2]*o,a[3]=t[3]*o,a},s.scale$2=up,s.scaleAndAdd=hv,s.setCacheLimits=function(a,t){yi=a,Hr=t},s.setColumn=function(a,t,o){a[4*t+0]=o[0],a[4*t+1]=o[1],a[4*t+2]=o[2],a[4*t+3]=o[3]},s.setRTLTextPlugin=function(a,t,o=!1){if(_r===tp||_r===Nl||_r===np)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ir=bt.resolveURL(a),_r=tp,ip=t,Wo(),o||Ds()},s.smoothstep=ue,s.spec=xe,s.storeAuthState=function(a,t){t?Nn.add(a):Nn.delete(a)},s.sub=Vu,s.subtract=pb,s.symbolSize=ZD,s.tileAABB=function(a,t,o,c,d,m,y,v,w){if(w.name==="globe")return NI(a,t,new zg(o,c,d));const A=Xl({z:o,x:c,y:d},w);return new ga([(m+A.x/A.scale)*t,t*(A.y/A.scale),y],[(m+A.x2/A.scale)*t,t*(A.y2/A.scale),v])},s.tileTransform=Xl,s.transformMat3=function(a,t,o){var c=t[0],d=t[1],m=t[2];return a[0]=c*o[0]+d*o[3]+m*o[6],a[1]=c*o[1]+d*o[4]+m*o[7],a[2]=c*o[2]+d*o[5]+m*o[8],a},s.transformMat4=ql,s.transformMat4$1=Gu,s.transformQuat=gb,s.translate=jl,s.transpose=function(a,t){if(a===t){var o=t[1],c=t[2],d=t[5];a[1]=t[3],a[2]=t[6],a[3]=o,a[5]=t[7],a[6]=c,a[7]=d}else a[0]=t[0],a[1]=t[3],a[2]=t[6],a[3]=t[1],a[4]=t[4],a[5]=t[7],a[6]=t[2],a[7]=t[5],a[8]=t[8];return a},s.triggerPluginCompletionEvent=Ul,s.uniqueId=Ue,s.validateCustomStyleLayer=function(a){const t=[],o=a.id;return o===void 0&&t.push({message:`layers.${o}: missing required property "id"`}),a.render===void 0&&t.push({message:`layers.${o}: missing required method "render"`}),a.renderingMode&&a.renderingMode!=="2d"&&a.renderingMode!=="3d"&&t.push({message:`layers.${o}: property "renderingMode" must be either "2d" or "3d"`}),t},s.validateFilter=a=>Na(uo(a)),s.validateFog=a=>Na(Wm(a)),s.validateLayer=a=>Na(Nm(a)),s.validateLight=a=>Na(Gm(a)),s.validateSource=a=>Na(Vm(a)),s.validateStyle=zl,s.validateTerrain=a=>Na(Hm(a)),s.values=De,s.vectorTile=Zl,s.version=M,s.warnOnce=ge,s.window=I,s.wrap=ae}),p(["./shared"],function(s){function M(_e){if(typeof _e=="number"||typeof _e=="boolean"||typeof _e=="string"||_e==null)return JSON.stringify(_e);if(Array.isArray(_e)){let Z="[";for(const de of _e)Z+=`${M(de)},`;return`${Z}]`}let G="{";for(const Z of Object.keys(_e).sort())G+=`${Z}:${M(_e[Z])},`;return`${G}}`}function T(_e){let G="";for(const Z of s.refProperties)G+=`/${M(_e[Z])}`;return G}class C{constructor(G){this.keyCache={},G&&this.replace(G)}replace(G){this._layerConfigs={},this._layers={},this.update(G,[])}update(G,Z){for(const Le of G)this._layerConfigs[Le.id]=Le,(this._layers[Le.id]=s.createStyleLayer(Le)).compileFilter(),this.keyCache[Le.id]&&delete this.keyCache[Le.id];for(const Le of Z)delete this.keyCache[Le],delete this._layerConfigs[Le],delete this._layers[Le];this.familiesBySource={};const de=function(Le,Ge){const Je={};for(let je=0;je<Le.length;je++){const nt=Ge&&Ge[Le[je].id]||T(Le[je]);Ge&&(Ge[Le[je].id]=nt);let yt=Je[nt];yt||(yt=Je[nt]=[]),yt.push(Le[je])}const Ke=[];for(const je in Je)Ke.push(Je[je]);return Ke}(s.values(this._layerConfigs),this.keyCache);for(const Le of de){const Ge=Le.map(Ut=>this._layers[Ut.id]),Je=Ge[0];if(Je.visibility==="none")continue;const Ke=Je.source||"";let je=this.familiesBySource[Ke];je||(je=this.familiesBySource[Ke]={});const nt=Je.sourceLayer||"_geojsonTileLayer";let yt=je[nt];yt||(yt=je[nt]=[]),yt.push(Ge)}}}class E{loadTile(G,Z){const{uid:de,encoding:Le,rawImageData:Ge,padding:Je,buildQuadTree:Ke}=G,je=s.window.ImageBitmap&&Ge instanceof s.window.ImageBitmap?this.getImageData(Ge,Je):Ge;Z(null,new s.DEMData(de,je,Le,Je<1,Ke))}getImageData(G,Z){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(G.width,G.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=G.width,this.offscreenCanvas.height=G.height,this.offscreenCanvasContext.drawImage(G,0,0,G.width,G.height);const de=this.offscreenCanvasContext.getImageData(-Z,-Z,G.width+2*Z,G.height+2*Z);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),de}}var L=function _e(G,Z){var de,Le=G&&G.type;if(Le==="FeatureCollection")for(de=0;de<G.features.length;de++)_e(G.features[de],Z);else if(Le==="GeometryCollection")for(de=0;de<G.geometries.length;de++)_e(G.geometries[de],Z);else if(Le==="Feature")_e(G.geometry,Z);else if(Le==="Polygon")I(G.coordinates,Z);else if(Le==="MultiPolygon")for(de=0;de<G.coordinates.length;de++)I(G.coordinates[de],Z);return G};function I(_e,G){if(_e.length!==0){B(_e[0],G);for(var Z=1;Z<_e.length;Z++)B(_e[Z],!G)}}function B(_e,G){for(var Z=0,de=0,Le=0,Ge=_e.length,Je=Ge-1;Le<Ge;Je=Le++){var Ke=(_e[Le][0]-_e[Je][0])*(_e[Je][1]+_e[Le][1]),je=Z+Ke;de+=Math.abs(Z)>=Math.abs(Ke)?Z-je+Ke:Ke-je+Z,Z=je}Z+de>=0!=!!G&&_e.reverse()}const O=s.vectorTile.VectorTileFeature.prototype.toGeoJSON;class U{constructor(G){this._feature=G,this.extent=s.EXTENT,this.type=G.type,this.properties=G.tags,"id"in G&&!isNaN(G.id)&&(this.id=parseInt(G.id,10))}loadGeometry(){if(this._feature.type===1){const G=[];for(const Z of this._feature.geometry)G.push([new s.pointGeometry(Z[0],Z[1])]);return G}{const G=[];for(const Z of this._feature.geometry){const de=[];for(const Le of Z)de.push(new s.pointGeometry(Le[0],Le[1]));G.push(de)}return G}}toGeoJSON(G,Z,de){return O.call(this,G,Z,de)}}class q{constructor(G){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=s.EXTENT,this.length=G.length,this._features=G}feature(G){return new U(this._features[G])}}var ee=s.vectorTile.VectorTileFeature,he=Ce;function Ce(_e,G){this.options=G||{},this.features=_e,this.length=_e.length}function K(_e,G){this.id=typeof _e.id=="number"?_e.id:void 0,this.type=_e.type,this.rawGeometry=_e.type===1?[_e.geometry]:_e.geometry,this.properties=_e.tags,this.extent=G||4096}Ce.prototype.feature=function(_e){return new K(this.features[_e],this.options.extent)},K.prototype.loadGeometry=function(){var _e=this.rawGeometry;this.geometry=[];for(var G=0;G<_e.length;G++){for(var Z=_e[G],de=[],Le=0;Le<Z.length;Le++)de.push(new s.pointGeometry(Z[Le][0],Z[Le][1]));this.geometry.push(de)}return this.geometry},K.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var _e=this.geometry,G=1/0,Z=-1/0,de=1/0,Le=-1/0,Ge=0;Ge<_e.length;Ge++)for(var Je=_e[Ge],Ke=0;Ke<Je.length;Ke++){var je=Je[Ke];G=Math.min(G,je.x),Z=Math.max(Z,je.x),de=Math.min(de,je.y),Le=Math.max(Le,je.y)}return[G,de,Z,Le]},K.prototype.toGeoJSON=ee.prototype.toGeoJSON;var ie=ae,ue=he;function ae(_e){var G=new s.pbf;return function(Z,de){for(var Le in Z.layers)de.writeMessage(3,le,Z.layers[Le])}(_e,G),G.finish()}function le(_e,G){var Z;G.writeVarintField(15,_e.version||1),G.writeStringField(1,_e.name||""),G.writeVarintField(5,_e.extent||4096);var de={keys:[],values:[],keycache:{},valuecache:{}};for(Z=0;Z<_e.length;Z++)de.feature=_e.feature(Z),G.writeMessage(2,De,de);var Le=de.keys;for(Z=0;Z<Le.length;Z++)G.writeStringField(3,Le[Z]);var Ge=de.values;for(Z=0;Z<Ge.length;Z++)G.writeMessage(4,We,Ge[Z])}function De(_e,G){var Z=_e.feature;Z.id!==void 0&&G.writeVarintField(1,Z.id),G.writeMessage(2,ye,_e),G.writeVarintField(3,Z.type),G.writeMessage(4,Oe,Z)}function ye(_e,G){var Z=_e.feature,de=_e.keys,Le=_e.values,Ge=_e.keycache,Je=_e.valuecache;for(var Ke in Z.properties){var je=Z.properties[Ke],nt=Ge[Ke];if(je!==null){nt===void 0&&(de.push(Ke),Ge[Ke]=nt=de.length-1),G.writeVarint(nt);var yt=typeof je;yt!=="string"&&yt!=="boolean"&&yt!=="number"&&(je=JSON.stringify(je));var Ut=yt+":"+je,Et=Je[Ut];Et===void 0&&(Le.push(je),Je[Ut]=Et=Le.length-1),G.writeVarint(Et)}}}function se(_e,G){return(G<<3)+(7&_e)}function Ue(_e){return _e<<1^_e>>31}function Oe(_e,G){for(var Z=_e.loadGeometry(),de=_e.type,Le=0,Ge=0,Je=Z.length,Ke=0;Ke<Je;Ke++){var je=Z[Ke],nt=1;de===1&&(nt=je.length),G.writeVarint(se(1,nt));for(var yt=de===3?je.length-1:je.length,Ut=0;Ut<yt;Ut++){Ut===1&&de!==1&&G.writeVarint(se(2,yt-1));var Et=je[Ut].x-Le,_n=je[Ut].y-Ge;G.writeVarint(Ue(Et)),G.writeVarint(Ue(_n)),Le+=Et,Ge+=_n}de===3&&G.writeVarint(se(7,1))}}function We(_e,G){var Z=typeof _e;Z==="string"?G.writeStringField(1,_e):Z==="boolean"?G.writeBooleanField(7,_e):Z==="number"&&(_e%1!=0?G.writeDoubleField(3,_e):_e<0?G.writeSVarintField(6,_e):G.writeVarintField(5,_e))}function st(_e,G,Z,de,Le,Ge){if(Le-de<=Z)return;const Je=de+Le>>1;St(_e,G,Je,de,Le,Ge%2),st(_e,G,Z,de,Je-1,Ge+1),st(_e,G,Z,Je+1,Le,Ge+1)}function St(_e,G,Z,de,Le,Ge){for(;Le>de;){if(Le-de>600){const nt=Le-de+1,yt=Z-de+1,Ut=Math.log(nt),Et=.5*Math.exp(2*Ut/3),_n=.5*Math.sqrt(Ut*Et*(nt-Et)/nt)*(yt-nt/2<0?-1:1);St(_e,G,Z,Math.max(de,Math.floor(Z-yt*Et/nt+_n)),Math.min(Le,Math.floor(Z+(nt-yt)*Et/nt+_n)),Ge)}const Je=G[2*Z+Ge];let Ke=de,je=Le;for(gt(_e,G,de,Z),G[2*Le+Ge]>Je&&gt(_e,G,de,Le);Ke<je;){for(gt(_e,G,Ke,je),Ke++,je--;G[2*Ke+Ge]<Je;)Ke++;for(;G[2*je+Ge]>Je;)je--}G[2*de+Ge]===Je?gt(_e,G,de,je):(je++,gt(_e,G,je,Le)),je<=Z&&(de=je+1),Z<=je&&(Le=je-1)}}function gt(_e,G,Z,de){At(_e,Z,de),At(G,2*Z,2*de),At(G,2*Z+1,2*de+1)}function At(_e,G,Z){const de=_e[G];_e[G]=_e[Z],_e[Z]=de}function Dt(_e,G,Z,de){const Le=_e-Z,Ge=G-de;return Le*Le+Ge*Ge}ie.fromVectorTileJs=ae,ie.fromGeojsonVt=function(_e,G){G=G||{};var Z={};for(var de in _e)Z[de]=new he(_e[de].features,G),Z[de].name=de,Z[de].version=G.version,Z[de].extent=G.extent;return ae({layers:Z})},ie.GeoJSONWrapper=ue;const Ot=_e=>_e[0],Pe=_e=>_e[1];class ge{constructor(G,Z=Ot,de=Pe,Le=64,Ge=Float64Array){this.nodeSize=Le,this.points=G;const Je=G.length<65536?Uint16Array:Uint32Array,Ke=this.ids=new Je(G.length),je=this.coords=new Ge(2*G.length);for(let nt=0;nt<G.length;nt++)Ke[nt]=nt,je[2*nt]=Z(G[nt]),je[2*nt+1]=de(G[nt]);st(Ke,je,Le,0,Ke.length-1,0)}range(G,Z,de,Le){return function(Ge,Je,Ke,je,nt,yt,Ut){const Et=[0,Ge.length-1,0],_n=[];let W,Y;for(;Et.length;){const ze=Et.pop(),xe=Et.pop(),Mt=Et.pop();if(xe-Mt<=Ut){for(let nn=Mt;nn<=xe;nn++)W=Je[2*nn],Y=Je[2*nn+1],W>=Ke&&W<=nt&&Y>=je&&Y<=yt&&_n.push(Ge[nn]);continue}const _t=Math.floor((Mt+xe)/2);W=Je[2*_t],Y=Je[2*_t+1],W>=Ke&&W<=nt&&Y>=je&&Y<=yt&&_n.push(Ge[_t]);const Ft=(ze+1)%2;(ze===0?Ke<=W:je<=Y)&&(Et.push(Mt),Et.push(_t-1),Et.push(Ft)),(ze===0?nt>=W:yt>=Y)&&(Et.push(_t+1),Et.push(xe),Et.push(Ft))}return _n}(this.ids,this.coords,G,Z,de,Le,this.nodeSize)}within(G,Z,de){return function(Le,Ge,Je,Ke,je,nt){const yt=[0,Le.length-1,0],Ut=[],Et=je*je;for(;yt.length;){const _n=yt.pop(),W=yt.pop(),Y=yt.pop();if(W-Y<=nt){for(let Ft=Y;Ft<=W;Ft++)Dt(Ge[2*Ft],Ge[2*Ft+1],Je,Ke)<=Et&&Ut.push(Le[Ft]);continue}const ze=Math.floor((Y+W)/2),xe=Ge[2*ze],Mt=Ge[2*ze+1];Dt(xe,Mt,Je,Ke)<=Et&&Ut.push(Le[ze]);const _t=(_n+1)%2;(_n===0?Je-je<=xe:Ke-je<=Mt)&&(yt.push(Y),yt.push(ze-1),yt.push(_t)),(_n===0?Je+je>=xe:Ke+je>=Mt)&&(yt.push(ze+1),yt.push(W),yt.push(_t))}return Ut}(this.ids,this.coords,G,Z,de,this.nodeSize)}}const Ve={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:_e=>_e},Ne=Math.fround||(Ie=new Float32Array(1),_e=>(Ie[0]=+_e,Ie[0]));var Ie;class it{constructor(G){this.options=bt(Object.create(Ve),G),this.trees=new Array(this.options.maxZoom+1)}load(G){const{log:Z,minZoom:de,maxZoom:Le,nodeSize:Ge}=this.options;Z&&console.time("total time");const Je=`prepare ${G.length} points`;Z&&console.time(Je),this.points=G;let Ke=[];for(let je=0;je<G.length;je++)G[je].geometry&&Ke.push(we(G[je],je));this.trees[Le+1]=new ge(Ke,Vt,oe,Ge,Float32Array),Z&&console.timeEnd(Je);for(let je=Le;je>=de;je--){const nt=+Date.now();Ke=this._cluster(Ke,je),this.trees[je]=new ge(Ke,Vt,oe,Ge,Float32Array),Z&&console.log("z%d: %d clusters in %dms",je,Ke.length,+Date.now()-nt)}return Z&&console.timeEnd("total time"),this}getClusters(G,Z){let de=((G[0]+180)%360+360)%360-180;const Le=Math.max(-90,Math.min(90,G[1]));let Ge=G[2]===180?180:((G[2]+180)%360+360)%360-180;const Je=Math.max(-90,Math.min(90,G[3]));if(G[2]-G[0]>=360)de=-180,Ge=180;else if(de>Ge){const yt=this.getClusters([de,Le,180,Je],Z),Ut=this.getClusters([-180,Le,Ge,Je],Z);return yt.concat(Ut)}const Ke=this.trees[this._limitZoom(Z)],je=Ke.range(Be(de),$e(Je),Be(Ge),$e(Le)),nt=[];for(const yt of je){const Ut=Ke.points[yt];nt.push(Ut.numPoints?Me(Ut):this.points[Ut.index])}return nt}getChildren(G){const Z=this._getOriginId(G),de=this._getOriginZoom(G),Le="No cluster with the specified id.",Ge=this.trees[de];if(!Ge)throw new Error(Le);const Je=Ge.points[Z];if(!Je)throw new Error(Le);const Ke=this.options.radius/(this.options.extent*Math.pow(2,de-1)),je=Ge.within(Je.x,Je.y,Ke),nt=[];for(const yt of je){const Ut=Ge.points[yt];Ut.parentId===G&&nt.push(Ut.numPoints?Me(Ut):this.points[Ut.index])}if(nt.length===0)throw new Error(Le);return nt}getLeaves(G,Z,de){const Le=[];return this._appendLeaves(Le,G,Z=Z||10,de=de||0,0),Le}getTile(G,Z,de){const Le=this.trees[this._limitZoom(G)],Ge=Math.pow(2,G),{extent:Je,radius:Ke}=this.options,je=Ke/Je,nt=(de-je)/Ge,yt=(de+1+je)/Ge,Ut={features:[]};return this._addTileFeatures(Le.range((Z-je)/Ge,nt,(Z+1+je)/Ge,yt),Le.points,Z,de,Ge,Ut),Z===0&&this._addTileFeatures(Le.range(1-je/Ge,nt,1,yt),Le.points,Ge,de,Ge,Ut),Z===Ge-1&&this._addTileFeatures(Le.range(0,nt,je/Ge,yt),Le.points,-1,de,Ge,Ut),Ut.features.length?Ut:null}getClusterExpansionZoom(G){let Z=this._getOriginZoom(G)-1;for(;Z<=this.options.maxZoom;){const de=this.getChildren(G);if(Z++,de.length!==1)break;G=de[0].properties.cluster_id}return Z}_appendLeaves(G,Z,de,Le,Ge){const Je=this.getChildren(Z);for(const Ke of Je){const je=Ke.properties;if(je&&je.cluster?Ge+je.point_count<=Le?Ge+=je.point_count:Ge=this._appendLeaves(G,je.cluster_id,de,Le,Ge):Ge<Le?Ge++:G.push(Ke),G.length===de)break}return Ge}_addTileFeatures(G,Z,de,Le,Ge,Je){for(const Ke of G){const je=Z[Ke],nt=je.numPoints;let yt,Ut,Et;if(nt)yt=pe(je),Ut=je.x,Et=je.y;else{const Y=this.points[je.index];yt=Y.properties,Ut=Be(Y.geometry.coordinates[0]),Et=$e(Y.geometry.coordinates[1])}const _n={type:1,geometry:[[Math.round(this.options.extent*(Ut*Ge-de)),Math.round(this.options.extent*(Et*Ge-Le))]],tags:yt};let W;nt?W=je.id:this.options.generateId?W=je.index:this.points[je.index].id&&(W=this.points[je.index].id),W!==void 0&&(_n.id=W),Je.features.push(_n)}}_limitZoom(G){return Math.max(this.options.minZoom,Math.min(+G,this.options.maxZoom+1))}_cluster(G,Z){const de=[],{radius:Le,extent:Ge,reduce:Je,minPoints:Ke}=this.options,je=Le/(Ge*Math.pow(2,Z));for(let nt=0;nt<G.length;nt++){const yt=G[nt];if(yt.zoom<=Z)continue;yt.zoom=Z;const Ut=this.trees[Z+1],Et=Ut.within(yt.x,yt.y,je),_n=yt.numPoints||1;let W=_n;for(const Y of Et){const ze=Ut.points[Y];ze.zoom>Z&&(W+=ze.numPoints||1)}if(W>_n&&W>=Ke){let Y=yt.x*_n,ze=yt.y*_n,xe=Je&&_n>1?this._map(yt,!0):null;const Mt=(nt<<5)+(Z+1)+this.points.length;for(const _t of Et){const Ft=Ut.points[_t];if(Ft.zoom<=Z)continue;Ft.zoom=Z;const nn=Ft.numPoints||1;Y+=Ft.x*nn,ze+=Ft.y*nn,Ft.parentId=Mt,Je&&(xe||(xe=this._map(yt,!0)),Je(xe,this._map(Ft)))}yt.parentId=Mt,de.push(ce(Y/W,ze/W,Mt,W,xe))}else if(de.push(yt),W>1)for(const Y of Et){const ze=Ut.points[Y];ze.zoom<=Z||(ze.zoom=Z,de.push(ze))}}return de}_getOriginId(G){return G-this.points.length>>5}_getOriginZoom(G){return(G-this.points.length)%32}_map(G,Z){if(G.numPoints)return Z?bt({},G.properties):G.properties;const de=this.points[G.index].properties,Le=this.options.map(de);return Z&&Le===de?bt({},Le):Le}}function ce(_e,G,Z,de,Le){return{x:Ne(_e),y:Ne(G),zoom:1/0,id:Z,parentId:-1,numPoints:de,properties:Le}}function we(_e,G){const[Z,de]=_e.geometry.coordinates;return{x:Ne(Be(Z)),y:Ne($e(de)),zoom:1/0,index:G,parentId:-1}}function Me(_e){return{type:"Feature",id:_e.id,properties:pe(_e),geometry:{type:"Point",coordinates:[(G=_e.x,360*(G-.5)),ot(_e.y)]}};var G}function pe(_e){const G=_e.numPoints,Z=G>=1e4?`${Math.round(G/1e3)}k`:G>=1e3?Math.round(G/100)/10+"k":G;return bt(bt({},_e.properties),{cluster:!0,cluster_id:_e.id,point_count:G,point_count_abbreviated:Z})}function Be(_e){return _e/360+.5}function $e(_e){const G=Math.sin(_e*Math.PI/180),Z=.5-.25*Math.log((1+G)/(1-G))/Math.PI;return Z<0?0:Z>1?1:Z}function ot(_e){const G=(180-360*_e)*Math.PI/180;return 360*Math.atan(Math.exp(G))/Math.PI-90}function bt(_e,G){for(const Z in G)_e[Z]=G[Z];return _e}function Vt(_e){return _e.x}function oe(_e){return _e.y}function ve(_e,G,Z,de){for(var Le,Ge=de,Je=Z-G>>1,Ke=Z-G,je=_e[G],nt=_e[G+1],yt=_e[Z],Ut=_e[Z+1],Et=G+3;Et<Z;Et+=3){var _n=xt(_e[Et],_e[Et+1],je,nt,yt,Ut);if(_n>Ge)Le=Et,Ge=_n;else if(_n===Ge){var W=Math.abs(Et-Je);W<Ke&&(Le=Et,Ke=W)}}Ge>de&&(Le-G>3&&ve(_e,G,Le,de),_e[Le+2]=Ge,Z-Le>3&&ve(_e,Le,Z,de))}function xt(_e,G,Z,de,Le,Ge){var Je=Le-Z,Ke=Ge-de;if(Je!==0||Ke!==0){var je=((_e-Z)*Je+(G-de)*Ke)/(Je*Je+Ke*Ke);je>1?(Z=Le,de=Ge):je>0&&(Z+=Je*je,de+=Ke*je)}return(Je=_e-Z)*Je+(Ke=G-de)*Ke}function mt(_e,G,Z,de){var Le={id:_e===void 0?null:_e,type:G,geometry:Z,tags:de,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Ge){var Je=Ge.geometry,Ke=Ge.type;if(Ke==="Point"||Ke==="MultiPoint"||Ke==="LineString")xn(Ge,Je);else if(Ke==="Polygon"||Ke==="MultiLineString")for(var je=0;je<Je.length;je++)xn(Ge,Je[je]);else if(Ke==="MultiPolygon")for(je=0;je<Je.length;je++)for(var nt=0;nt<Je[je].length;nt++)xn(Ge,Je[je][nt])}(Le),Le}function xn(_e,G){for(var Z=0;Z<G.length;Z+=3)_e.minX=Math.min(_e.minX,G[Z]),_e.minY=Math.min(_e.minY,G[Z+1]),_e.maxX=Math.max(_e.maxX,G[Z]),_e.maxY=Math.max(_e.maxY,G[Z+1])}function un(_e,G,Z,de){if(G.geometry){var Le=G.geometry.coordinates,Ge=G.geometry.type,Je=Math.pow(Z.tolerance/((1<<Z.maxZoom)*Z.extent),2),Ke=[],je=G.id;if(Z.promoteId?je=G.properties[Z.promoteId]:Z.generateId&&(je=de||0),Ge==="Point")tn(Le,Ke);else if(Ge==="MultiPoint")for(var nt=0;nt<Le.length;nt++)tn(Le[nt],Ke);else if(Ge==="LineString")dn(Le,Ke,Je,!1);else if(Ge==="MultiLineString"){if(Z.lineMetrics){for(nt=0;nt<Le.length;nt++)dn(Le[nt],Ke=[],Je,!1),_e.push(mt(je,"LineString",Ke,G.properties));return}bn(Le,Ke,Je,!1)}else if(Ge==="Polygon")bn(Le,Ke,Je,!0);else{if(Ge!=="MultiPolygon"){if(Ge==="GeometryCollection"){for(nt=0;nt<G.geometry.geometries.length;nt++)un(_e,{id:je,geometry:G.geometry.geometries[nt],properties:G.properties},Z,de);return}throw new Error("Input data is not a valid GeoJSON object.")}for(nt=0;nt<Le.length;nt++){var yt=[];bn(Le[nt],yt,Je,!0),Ke.push(yt)}}_e.push(mt(je,Ge,Ke,G.properties))}}function tn(_e,G){G.push(ln(_e[0])),G.push(Gt(_e[1])),G.push(0)}function dn(_e,G,Z,de){for(var Le,Ge,Je=0,Ke=0;Ke<_e.length;Ke++){var je=ln(_e[Ke][0]),nt=Gt(_e[Ke][1]);G.push(je),G.push(nt),G.push(0),Ke>0&&(Je+=de?(Le*nt-je*Ge)/2:Math.sqrt(Math.pow(je-Le,2)+Math.pow(nt-Ge,2))),Le=je,Ge=nt}var yt=G.length-3;G[2]=1,ve(G,0,yt,Z),G[yt+2]=1,G.size=Math.abs(Je),G.start=0,G.end=G.size}function bn(_e,G,Z,de){for(var Le=0;Le<_e.length;Le++){var Ge=[];dn(_e[Le],Ge,Z,de),G.push(Ge)}}function ln(_e){return _e/360+.5}function Gt(_e){var G=Math.sin(_e*Math.PI/180),Z=.5-.25*Math.log((1+G)/(1-G))/Math.PI;return Z<0?0:Z>1?1:Z}function on(_e,G,Z,de,Le,Ge,Je,Ke){if(de/=G,Ge>=(Z/=G)&&Je<de)return _e;if(Je<Z||Ge>=de)return null;for(var je=[],nt=0;nt<_e.length;nt++){var yt=_e[nt],Ut=yt.geometry,Et=yt.type,_n=Le===0?yt.minX:yt.minY,W=Le===0?yt.maxX:yt.maxY;if(_n>=Z&&W<de)je.push(yt);else if(!(W<Z||_n>=de)){var Y=[];if(Et==="Point"||Et==="MultiPoint")Zt(Ut,Y,Z,de,Le);else if(Et==="LineString")qe(Ut,Y,Z,de,Le,!1,Ke.lineMetrics);else if(Et==="MultiLineString")Qt(Ut,Y,Z,de,Le,!1);else if(Et==="Polygon")Qt(Ut,Y,Z,de,Le,!0);else if(Et==="MultiPolygon")for(var ze=0;ze<Ut.length;ze++){var xe=[];Qt(Ut[ze],xe,Z,de,Le,!0),xe.length&&Y.push(xe)}if(Y.length){if(Ke.lineMetrics&&Et==="LineString"){for(ze=0;ze<Y.length;ze++)je.push(mt(yt.id,Et,Y[ze],yt.tags));continue}Et!=="LineString"&&Et!=="MultiLineString"||(Y.length===1?(Et="LineString",Y=Y[0]):Et="MultiLineString"),Et!=="Point"&&Et!=="MultiPoint"||(Et=Y.length===3?"Point":"MultiPoint"),je.push(mt(yt.id,Et,Y,yt.tags))}}}return je.length?je:null}function Zt(_e,G,Z,de,Le){for(var Ge=0;Ge<_e.length;Ge+=3){var Je=_e[Ge+Le];Je>=Z&&Je<=de&&(G.push(_e[Ge]),G.push(_e[Ge+1]),G.push(_e[Ge+2]))}}function qe(_e,G,Z,de,Le,Ge,Je){for(var Ke,je,nt=Nt(_e),yt=Le===0?pn:On,Ut=_e.start,Et=0;Et<_e.length-3;Et+=3){var _n=_e[Et],W=_e[Et+1],Y=_e[Et+2],ze=_e[Et+3],xe=_e[Et+4],Mt=Le===0?_n:W,_t=Le===0?ze:xe,Ft=!1;Je&&(Ke=Math.sqrt(Math.pow(_n-ze,2)+Math.pow(W-xe,2))),Mt<Z?_t>Z&&(je=yt(nt,_n,W,ze,xe,Z),Je&&(nt.start=Ut+Ke*je)):Mt>de?_t<de&&(je=yt(nt,_n,W,ze,xe,de),Je&&(nt.start=Ut+Ke*je)):Pn(nt,_n,W,Y),_t<Z&&Mt>=Z&&(je=yt(nt,_n,W,ze,xe,Z),Ft=!0),_t>de&&Mt<=de&&(je=yt(nt,_n,W,ze,xe,de),Ft=!0),!Ge&&Ft&&(Je&&(nt.end=Ut+Ke*je),G.push(nt),nt=Nt(_e)),Je&&(Ut+=Ke)}var nn=_e.length-3;_n=_e[nn],W=_e[nn+1],Y=_e[nn+2],(Mt=Le===0?_n:W)>=Z&&Mt<=de&&Pn(nt,_n,W,Y),nn=nt.length-3,Ge&&nn>=3&&(nt[nn]!==nt[0]||nt[nn+1]!==nt[1])&&Pn(nt,nt[0],nt[1],nt[2]),nt.length&&G.push(nt)}function Nt(_e){var G=[];return G.size=_e.size,G.start=_e.start,G.end=_e.end,G}function Qt(_e,G,Z,de,Le,Ge){for(var Je=0;Je<_e.length;Je++)qe(_e[Je],G,Z,de,Le,Ge,!1)}function Pn(_e,G,Z,de){_e.push(G),_e.push(Z),_e.push(de)}function pn(_e,G,Z,de,Le,Ge){var Je=(Ge-G)/(de-G);return _e.push(Ge),_e.push(Z+(Le-Z)*Je),_e.push(1),Je}function On(_e,G,Z,de,Le,Ge){var Je=(Ge-Z)/(Le-Z);return _e.push(G+(de-G)*Je),_e.push(Ge),_e.push(1),Je}function Gn(_e,G){for(var Z=[],de=0;de<_e.length;de++){var Le,Ge=_e[de],Je=Ge.type;if(Je==="Point"||Je==="MultiPoint"||Je==="LineString")Le=Zn(Ge.geometry,G);else if(Je==="MultiLineString"||Je==="Polygon"){Le=[];for(var Ke=0;Ke<Ge.geometry.length;Ke++)Le.push(Zn(Ge.geometry[Ke],G))}else if(Je==="MultiPolygon")for(Le=[],Ke=0;Ke<Ge.geometry.length;Ke++){for(var je=[],nt=0;nt<Ge.geometry[Ke].length;nt++)je.push(Zn(Ge.geometry[Ke][nt],G));Le.push(je)}Z.push(mt(Ge.id,Je,Le,Ge.tags))}return Z}function Zn(_e,G){var Z=[];Z.size=_e.size,_e.start!==void 0&&(Z.start=_e.start,Z.end=_e.end);for(var de=0;de<_e.length;de+=3)Z.push(_e[de]+G,_e[de+1],_e[de+2]);return Z}function Wi(_e,G){if(_e.transformed)return _e;var Z,de,Le,Ge=1<<_e.z,Je=_e.x,Ke=_e.y;for(Z=0;Z<_e.features.length;Z++){var je=_e.features[Z],nt=je.geometry,yt=je.type;if(je.geometry=[],yt===1)for(de=0;de<nt.length;de+=2)je.geometry.push(Nn(nt[de],nt[de+1],G,Ge,Je,Ke));else for(de=0;de<nt.length;de++){var Ut=[];for(Le=0;Le<nt[de].length;Le+=2)Ut.push(Nn(nt[de][Le],nt[de][Le+1],G,Ge,Je,Ke));je.geometry.push(Ut)}}return _e.transformed=!0,_e}function Nn(_e,G,Z,de,Le,Ge){return[Math.round(Z*(_e*de-Le)),Math.round(Z*(G*de-Ge))]}function Ci(_e,G,Z,de,Le){for(var Ge=G===Le.maxZoom?0:Le.tolerance/((1<<G)*Le.extent),Je={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:Z,y:de,z:G,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},Ke=0;Ke<_e.length;Ke++){Je.numFeatures++,ei(Je,_e[Ke],Ge,Le);var je=_e[Ke].minX,nt=_e[Ke].minY,yt=_e[Ke].maxX,Ut=_e[Ke].maxY;je<Je.minX&&(Je.minX=je),nt<Je.minY&&(Je.minY=nt),yt>Je.maxX&&(Je.maxX=yt),Ut>Je.maxY&&(Je.maxY=Ut)}return Je}function ei(_e,G,Z,de){var Le=G.geometry,Ge=G.type,Je=[];if(Ge==="Point"||Ge==="MultiPoint")for(var Ke=0;Ke<Le.length;Ke+=3)Je.push(Le[Ke]),Je.push(Le[Ke+1]),_e.numPoints++,_e.numSimplified++;else if(Ge==="LineString")Ki(Je,Le,_e,Z,!1,!1);else if(Ge==="MultiLineString"||Ge==="Polygon")for(Ke=0;Ke<Le.length;Ke++)Ki(Je,Le[Ke],_e,Z,Ge==="Polygon",Ke===0);else if(Ge==="MultiPolygon")for(var je=0;je<Le.length;je++){var nt=Le[je];for(Ke=0;Ke<nt.length;Ke++)Ki(Je,nt[Ke],_e,Z,!0,Ke===0)}if(Je.length){var yt=G.tags||null;if(Ge==="LineString"&&de.lineMetrics){for(var Ut in yt={},G.tags)yt[Ut]=G.tags[Ut];yt.mapbox_clip_start=Le.start/Le.size,yt.mapbox_clip_end=Le.end/Le.size}var Et={geometry:Je,type:Ge==="Polygon"||Ge==="MultiPolygon"?3:Ge==="LineString"||Ge==="MultiLineString"?2:1,tags:yt};G.id!==null&&(Et.id=G.id),_e.features.push(Et)}}function Ki(_e,G,Z,de,Le,Ge){var Je=de*de;if(de>0&&G.size<(Le?Je:de))Z.numPoints+=G.length/3;else{for(var Ke=[],je=0;je<G.length;je+=3)(de===0||G[je+2]>Je)&&(Z.numSimplified++,Ke.push(G[je]),Ke.push(G[je+1])),Z.numPoints++;Le&&function(nt,yt){for(var Ut=0,Et=0,_n=nt.length,W=_n-2;Et<_n;W=Et,Et+=2)Ut+=(nt[Et]-nt[W])*(nt[Et+1]+nt[W+1]);if(Ut>0===yt)for(Et=0,_n=nt.length;Et<_n/2;Et+=2){var Y=nt[Et],ze=nt[Et+1];nt[Et]=nt[_n-2-Et],nt[Et+1]=nt[_n-1-Et],nt[_n-2-Et]=Y,nt[_n-1-Et]=ze}}(Ke,Ge),_e.push(Ke)}}function yi(_e,G){var Z=(G=this.options=function(Le,Ge){for(var Je in Ge)Le[Je]=Ge[Je];return Le}(Object.create(this.options),G)).debug;if(Z&&console.time("preprocess data"),G.maxZoom<0||G.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(G.promoteId&&G.generateId)throw new Error("promoteId and generateId cannot be used together.");var de=function(Le,Ge){var Je=[];if(Le.type==="FeatureCollection")for(var Ke=0;Ke<Le.features.length;Ke++)un(Je,Le.features[Ke],Ge,Ke);else un(Je,Le.type==="Feature"?Le:{geometry:Le},Ge);return Je}(_e,G);this.tiles={},this.tileCoords=[],Z&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",G.indexMaxZoom,G.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(de=function(Le,Ge){var Je=Ge.buffer/Ge.extent,Ke=Le,je=on(Le,1,-1-Je,Je,0,-1,2,Ge),nt=on(Le,1,1-Je,2+Je,0,-1,2,Ge);return(je||nt)&&(Ke=on(Le,1,-Je,1+Je,0,-1,2,Ge)||[],je&&(Ke=Gn(je,1).concat(Ke)),nt&&(Ke=Ke.concat(Gn(nt,-1)))),Ke}(de,G)).length&&this.splitTile(de,0,0,0),Z&&(de.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function Hr(_e,G,Z){return 32*((1<<_e)*Z+G)+_e}function ki(_e,G){const Z=_e.tileID.canonical;if(!this._geoJSONIndex)return G(null,null);const de=this._geoJSONIndex.getTile(Z.z,Z.x,Z.y);if(!de)return G(null,null);const Le=new q(de.features);let Ge=ie(Le);Ge.byteOffset===0&&Ge.byteLength===Ge.buffer.byteLength||(Ge=new Uint8Array(Ge)),G(null,{vectorTile:Le,rawData:Ge.buffer})}yi.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},yi.prototype.splitTile=function(_e,G,Z,de,Le,Ge,Je){for(var Ke=[_e,G,Z,de],je=this.options,nt=je.debug;Ke.length;){de=Ke.pop(),Z=Ke.pop(),G=Ke.pop(),_e=Ke.pop();var yt=1<<G,Ut=Hr(G,Z,de),Et=this.tiles[Ut];if(!Et&&(nt>1&&console.time("creation"),Et=this.tiles[Ut]=Ci(_e,G,Z,de,je),this.tileCoords.push({z:G,x:Z,y:de}),nt)){nt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",G,Z,de,Et.numFeatures,Et.numPoints,Et.numSimplified),console.timeEnd("creation"));var _n="z"+G;this.stats[_n]=(this.stats[_n]||0)+1,this.total++}if(Et.source=_e,Le){if(G===je.maxZoom||G===Le)continue;var W=1<<Le-G;if(Z!==Math.floor(Ge/W)||de!==Math.floor(Je/W))continue}else if(G===je.indexMaxZoom||Et.numPoints<=je.indexMaxPoints)continue;if(Et.source=null,_e.length!==0){nt>1&&console.time("clipping");var Y,ze,xe,Mt,_t,Ft,nn=.5*je.buffer/je.extent,Ln=.5-nn,Dn=.5+nn,wt=1+nn;Y=ze=xe=Mt=null,_t=on(_e,yt,Z-nn,Z+Dn,0,Et.minX,Et.maxX,je),Ft=on(_e,yt,Z+Ln,Z+wt,0,Et.minX,Et.maxX,je),_e=null,_t&&(Y=on(_t,yt,de-nn,de+Dn,1,Et.minY,Et.maxY,je),ze=on(_t,yt,de+Ln,de+wt,1,Et.minY,Et.maxY,je),_t=null),Ft&&(xe=on(Ft,yt,de-nn,de+Dn,1,Et.minY,Et.maxY,je),Mt=on(Ft,yt,de+Ln,de+wt,1,Et.minY,Et.maxY,je),Ft=null),nt>1&&console.timeEnd("clipping"),Ke.push(Y||[],G+1,2*Z,2*de),Ke.push(ze||[],G+1,2*Z,2*de+1),Ke.push(xe||[],G+1,2*Z+1,2*de),Ke.push(Mt||[],G+1,2*Z+1,2*de+1)}}},yi.prototype.getTile=function(_e,G,Z){var de=this.options,Le=de.extent,Ge=de.debug;if(_e<0||_e>24)return null;var Je=1<<_e,Ke=Hr(_e,G=(G%Je+Je)%Je,Z);if(this.tiles[Ke])return Wi(this.tiles[Ke],Le);Ge>1&&console.log("drilling down to z%d-%d-%d",_e,G,Z);for(var je,nt=_e,yt=G,Ut=Z;!je&&nt>0;)nt--,yt=Math.floor(yt/2),Ut=Math.floor(Ut/2),je=this.tiles[Hr(nt,yt,Ut)];return je&&je.source?(Ge>1&&console.log("found parent tile z%d-%d-%d",nt,yt,Ut),Ge>1&&console.time("drilling down"),this.splitTile(je.source,nt,yt,Ut,_e,G,Z),Ge>1&&console.timeEnd("drilling down"),this.tiles[Ke]?Wi(this.tiles[Ke],Le):null):null};class Wr extends s.VectorTileWorkerSource{constructor(G,Z,de,Le,Ge){super(G,Z,de,Le,ki),Ge&&(this.loadGeoJSON=Ge)}loadData(G,Z){const de=G&&G.request,Le=de&&de.collectResourceTiming;this.loadGeoJSON(G,(Ge,Je)=>{if(Ge||!Je)return Z(Ge);if(typeof Je!="object")return Z(new Error(`Input data given to '${G.source}' is not a valid GeoJSON object.`));{L(Je,!0);try{if(G.filter){const je=s.createExpression(G.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(je.result==="error")throw new Error(je.value.map(yt=>`${yt.key}: ${yt.message}`).join(", "));Je={type:"FeatureCollection",features:Je.features.filter(yt=>je.value.evaluate({zoom:0},yt))}}this._geoJSONIndex=G.cluster?new it(function({superclusterOptions:je,clusterProperties:nt}){if(!nt||!je)return je;const yt={},Ut={},Et={accumulated:null,zoom:0},_n={properties:null},W=Object.keys(nt);for(const Y of W){const[ze,xe]=nt[Y],Mt=s.createExpression(xe),_t=s.createExpression(typeof ze=="string"?[ze,["accumulated"],["get",Y]]:ze);yt[Y]=Mt.value,Ut[Y]=_t.value}return je.map=Y=>{_n.properties=Y;const ze={};for(const xe of W)ze[xe]=yt[xe].evaluate(Et,_n);return ze},je.reduce=(Y,ze)=>{_n.properties=ze;for(const xe of W)Et.accumulated=Y[xe],Y[xe]=Ut[xe].evaluate(Et,_n)},je}(G)).load(Je.features):function(je,nt){return new yi(je,nt)}(Je,G.geojsonVtOptions)}catch(je){return Z(je)}this.loaded={};const Ke={};if(Le){const je=s.getPerformanceMeasurement(de);je&&(Ke.resourceTiming={},Ke.resourceTiming[G.source]=JSON.parse(JSON.stringify(je)))}Z(null,Ke)}})}reloadTile(G,Z){const de=this.loaded;return de&&de[G.uid]?super.reloadTile(G,Z):this.loadTile(G,Z)}loadGeoJSON(G,Z){if(G.request)s.getJSON(G.request,Z);else{if(typeof G.data!="string")return Z(new Error(`Input data given to '${G.source}' is not a valid GeoJSON object.`));try{return Z(null,JSON.parse(G.data))}catch(de){return Z(new Error(`Input data given to '${G.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(G,Z){try{Z(null,this._geoJSONIndex.getClusterExpansionZoom(G.clusterId))}catch(de){Z(de)}}getClusterChildren(G,Z){try{Z(null,this._geoJSONIndex.getChildren(G.clusterId))}catch(de){Z(de)}}getClusterLeaves(G,Z){try{Z(null,this._geoJSONIndex.getLeaves(G.clusterId,G.limit,G.offset))}catch(de){Z(de)}}}class Sr{constructor(G){this.self=G,this.actor=new s.Actor(G,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=s.getProjection({name:"mercator"}),this.workerSourceTypes={vector:s.VectorTileWorkerSource,geojson:Wr},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(Z,de)=>{if(this.workerSourceTypes[Z])throw new Error(`Worker source with name "${Z}" already registered.`);this.workerSourceTypes[Z]=de},this.self.registerRTLTextPlugin=Z=>{if(s.plugin.isParsed())throw new Error("RTL text plugin already registered.");s.plugin.applyArabicShaping=Z.applyArabicShaping,s.plugin.processBidirectionalText=Z.processBidirectionalText,s.plugin.processStyledBidirectionalText=Z.processStyledBidirectionalText}}clearCaches(G,Z,de){delete this.layerIndexes[G],delete this.availableImages[G],delete this.workerSources[G],delete this.demWorkerSources[G],de()}checkIfReady(G,Z,de){de()}setReferrer(G,Z){this.referrer=Z}spriteLoaded(G,Z){this.isSpriteLoaded[G]=Z;for(const de in this.workerSources[G]){const Le=this.workerSources[G][de];for(const Ge in Le)Le[Ge]instanceof s.VectorTileWorkerSource&&(Le[Ge].isSpriteLoaded=Z,Le[Ge].fire(new s.Event("isSpriteLoaded")))}}setImages(G,Z,de){this.availableImages[G]=Z;for(const Le in this.workerSources[G]){const Ge=this.workerSources[G][Le];for(const Je in Ge)Ge[Je].availableImages=Z}de()}enableTerrain(G,Z,de){this.terrain=Z,de()}setProjection(G,Z){this.projections[G]=s.getProjection(Z)}setLayers(G,Z,de){this.getLayerIndex(G).replace(Z),de()}updateLayers(G,Z,de){this.getLayerIndex(G).update(Z.layers,Z.removedIds),de()}loadTile(G,Z,de){const Le=this.enableTerrain?s.extend({enableTerrain:this.terrain},Z):Z;Le.projection=this.projections[G]||this.defaultProjection,this.getWorkerSource(G,Z.type,Z.source).loadTile(Le,de)}loadDEMTile(G,Z,de){const Le=this.enableTerrain?s.extend({buildQuadTree:this.terrain},Z):Z;this.getDEMWorkerSource(G,Z.source).loadTile(Le,de)}reloadTile(G,Z,de){const Le=this.enableTerrain?s.extend({enableTerrain:this.terrain},Z):Z;Le.projection=this.projections[G]||this.defaultProjection,this.getWorkerSource(G,Z.type,Z.source).reloadTile(Le,de)}abortTile(G,Z,de){this.getWorkerSource(G,Z.type,Z.source).abortTile(Z,de)}removeTile(G,Z,de){this.getWorkerSource(G,Z.type,Z.source).removeTile(Z,de)}removeSource(G,Z,de){if(!this.workerSources[G]||!this.workerSources[G][Z.type]||!this.workerSources[G][Z.type][Z.source])return;const Le=this.workerSources[G][Z.type][Z.source];delete this.workerSources[G][Z.type][Z.source],Le.removeSource!==void 0?Le.removeSource(Z,de):de()}loadWorkerSource(G,Z,de){try{this.self.importScripts(Z.url),de()}catch(Le){de(Le.toString())}}syncRTLPluginState(G,Z,de){try{s.plugin.setState(Z);const Le=s.plugin.getPluginURL();if(s.plugin.isLoaded()&&!s.plugin.isParsed()&&Le!=null){this.self.importScripts(Le);const Ge=s.plugin.isParsed();de(Ge?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Le}`),Ge)}}catch(Le){de(Le.toString())}}getAvailableImages(G){let Z=this.availableImages[G];return Z||(Z=[]),Z}getLayerIndex(G){let Z=this.layerIndexes[G];return Z||(Z=this.layerIndexes[G]=new C),Z}getWorkerSource(G,Z,de){return this.workerSources[G]||(this.workerSources[G]={}),this.workerSources[G][Z]||(this.workerSources[G][Z]={}),this.workerSources[G][Z][de]||(this.workerSources[G][Z][de]=new this.workerSourceTypes[Z]({send:(Le,Ge,Je,Ke,je,nt)=>{this.actor.send(Le,Ge,Je,G,je,nt)},scheduler:this.actor.scheduler},this.getLayerIndex(G),this.getAvailableImages(G),this.isSpriteLoaded[G])),this.workerSources[G][Z][de]}getDEMWorkerSource(G,Z){return this.demWorkerSources[G]||(this.demWorkerSources[G]={}),this.demWorkerSources[G][Z]||(this.demWorkerSources[G][Z]=new E),this.demWorkerSources[G][Z]}enforceCacheSizeLimit(G,Z){s.enforceCacheSizeLimit(Z)}getWorkerPerformanceMetrics(G,Z,de){de(void 0,void 0)}}return typeof WorkerGlobalScope!="undefined"&&typeof self!="undefined"&&self instanceof WorkerGlobalScope&&(self.worker=new Sr(self)),Sr}),p(["./shared"],function(s){var M=T;function T(f){return!function(r){return typeof window=="undefined"||typeof document=="undefined"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var g,x,b=new Blob([""],{type:"text/javascript"}),S=URL.createObjectURL(b);try{x=new Worker(S),g=!0}catch(P){g=!1}return x&&x.terminate(),URL.revokeObjectURL(S),g}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var g=document.createElement("canvas");g.width=g.height=1;var x=g.getContext("2d");if(!x)return!1;var b=x.getImageData(0,0,1,1);return b&&b.width===g.width}()?(C[u=r&&r.failIfMajorPerformanceCaveat]===void 0&&(C[u]=function(g){var x,b=function(S){var P=document.createElement("canvas"),z=Object.create(T.webGLContextAttributes);return z.failIfMajorPerformanceCaveat=S,P.getContext("webgl",z)||P.getContext("experimental-webgl",z)}(g);if(!b)return!1;try{x=b.createShader(b.VERTEX_SHADER)}catch(S){return!1}return!(!x||b.isContextLost())&&(b.shaderSource(x,"void main() {}"),b.compileShader(x),b.getShaderParameter(x,b.COMPILE_STATUS)===!0)}(u)),C[u]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var u}(f)}var C={};function E(f,r){if(Array.isArray(f)){if(!Array.isArray(r)||f.length!==r.length)return!1;for(let u=0;u<f.length;u++)if(!E(f[u],r[u]))return!1;return!0}if(typeof f=="object"&&f!==null&&r!==null){if(typeof r!="object"||Object.keys(f).length!==Object.keys(r).length)return!1;for(const u in f)if(!E(f[u],r[u]))return!1;return!0}return f===r}function L(f,r,u){const g=s.window.document.createElement(f);return r!==void 0&&(g.className=r),u&&u.appendChild(g),g}function I(f,r,u){const g=s.window.document.createElementNS("http://www.w3.org/2000/svg",f);for(const x of Object.keys(r))g.setAttributeNS(null,x,r[x]);return u&&u.appendChild(g),g}T.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const B=s.window.document&&s.window.document.documentElement.style,O=B&&B.userSelect!==void 0?"userSelect":"WebkitUserSelect";let U;function q(){B&&O&&(U=B[O],B[O]="none")}function ee(){B&&O&&(B[O]=U)}function he(f){f.preventDefault(),f.stopPropagation(),s.window.removeEventListener("click",he,!0)}function Ce(){s.window.addEventListener("click",he,!0),s.window.setTimeout(()=>{s.window.removeEventListener("click",he,!0)},0)}function K(f,r){const u=f.getBoundingClientRect();return ae(f,u,r)}function ie(f,r){const u=f.getBoundingClientRect(),g=[];for(let x=0;x<r.length;x++)g.push(ae(f,u,r[x]));return g}function ue(f){return s.window.InstallTrigger!==void 0&&f.button===2&&f.ctrlKey&&s.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:f.button}function ae(f,r,u){const g=f.offsetWidth===r.width?1:f.offsetWidth/r.width;return new s.pointGeometry((u.clientX-r.left)*g,(u.clientY-r.top)*g)}function le(f,r){var u=r[0],g=r[1],x=r[2],b=r[3],S=u*b-x*g;return S?(f[0]=b*(S=1/S),f[1]=-g*S,f[2]=-x*S,f[3]=u*S,f):null}function De(f){const{userImage:r}=f;return!!(r&&r.render&&r.render())&&(f.data.replace(new Uint8Array(r.data.buffer)),!0)}class ye extends s.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new s.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(r){if(this.loaded!==r&&(this.loaded=r,r)){for(const{ids:u,callback:g}of this.requestors)this._notify(u,g);this.requestors=[]}}hasImage(r){return!!this.getImage(r)}getImage(r){return this.images[r]}addImage(r,u){this._validate(r,u)&&(this.images[r]=u)}_validate(r,u){let g=!0;return this._validateStretch(u.stretchX,u.data&&u.data.width)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "stretchX" value`))),g=!1),this._validateStretch(u.stretchY,u.data&&u.data.height)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "stretchY" value`))),g=!1),this._validateContent(u.content,u)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "content" value`))),g=!1),g}_validateStretch(r,u){if(!r)return!0;let g=0;for(const x of r){if(x[0]<g||x[1]<x[0]||u<x[1])return!1;g=x[1]}return!0}_validateContent(r,u){return!(r&&(r.length!==4||r[0]<0||u.data.width<r[0]||r[1]<0||u.data.height<r[1]||r[2]<0||u.data.width<r[2]||r[3]<0||u.data.height<r[3]||r[2]<r[0]||r[3]<r[1]))}updateImage(r,u){u.version=this.images[r].version+1,this.images[r]=u,this.updatedImages[r]=!0}removeImage(r){const u=this.images[r];delete this.images[r],delete this.patterns[r],u.userImage&&u.userImage.onRemove&&u.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(r,u){let g=!0;if(!this.isLoaded())for(const x of r)this.images[x]||(g=!1);this.isLoaded()||g?this._notify(r,u):this.requestors.push({ids:r,callback:u})}_notify(r,u){const g={};for(const x of r){this.images[x]||this.fire(new s.Event("styleimagemissing",{id:x}));const b=this.images[x];b?g[x]={data:b.data.clone(),pixelRatio:b.pixelRatio,sdf:b.sdf,version:b.version,stretchX:b.stretchX,stretchY:b.stretchY,content:b.content,hasRenderCallback:!!(b.userImage&&b.userImage.render)}:s.warnOnce(`Image "${x}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}u(null,g)}getPixelSize(){const{width:r,height:u}=this.atlasImage;return{width:r,height:u}}getPattern(r){const u=this.patterns[r],g=this.getImage(r);if(!g)return null;if(u&&u.position.version===g.version)return u.position;if(u)u.position.version=g.version;else{const x={w:g.data.width+2,h:g.data.height+2,x:0,y:0},b=new s.ImagePosition(x,g);this.patterns[r]={bin:x,position:b}}return this._updatePatternAtlas(),this.patterns[r].position}bind(r){const u=r.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new s.Texture(r,this.atlasImage,u.RGBA),this.atlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE)}_updatePatternAtlas(){const r=[];for(const b in this.patterns)r.push(this.patterns[b].bin);const{w:u,h:g}=s.potpack(r),x=this.atlasImage;x.resize({width:u||1,height:g||1});for(const b in this.patterns){const{bin:S}=this.patterns[b],P=S.x+1,z=S.y+1,F=this.images[b].data,N=F.width,H=F.height;s.RGBAImage.copy(F,x,{x:0,y:0},{x:P,y:z},{width:N,height:H}),s.RGBAImage.copy(F,x,{x:0,y:H-1},{x:P,y:z-1},{width:N,height:1}),s.RGBAImage.copy(F,x,{x:0,y:0},{x:P,y:z+H},{width:N,height:1}),s.RGBAImage.copy(F,x,{x:N-1,y:0},{x:P-1,y:z},{width:1,height:H}),s.RGBAImage.copy(F,x,{x:0,y:0},{x:P+N,y:z},{width:1,height:H})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(r){for(const u of r){if(this.callbackDispatchedThisFrame[u])continue;this.callbackDispatchedThisFrame[u]=!0;const g=this.images[u];De(g)&&this.updateImage(u,g)}}}const se=new s.Properties({anchor:new s.DataConstantProperty(s.spec.light.anchor),position:new class{constructor(){this.specification=s.spec.light.position}possiblyEvaluate(f,r){return function([u,g,x]){const b=s.degToRad(g+90),S=s.degToRad(x);return{x:u*Math.cos(b)*Math.sin(S),y:u*Math.sin(b)*Math.sin(S),z:u*Math.cos(S),azimuthal:g,polar:x}}(f.expression.evaluate(r))}interpolate(f,r,u){return{x:s.number(f.x,r.x,u),y:s.number(f.y,r.y,u),z:s.number(f.z,r.z,u),azimuthal:s.number(f.azimuthal,r.azimuthal,u),polar:s.number(f.polar,r.polar,u)}}},color:new s.DataConstantProperty(s.spec.light.color),intensity:new s.DataConstantProperty(s.spec.light.intensity)}),Ue="-transition";class Oe extends s.Evented{constructor(r){super(),this._transitionable=new s.Transitionable(se),this.setLight(r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(r,u={}){if(!this._validate(s.validateLight,r,u))for(const g in r){const x=r[g];s.endsWith(g,Ue)?this._transitionable.setTransition(g.slice(0,-Ue.length),x):this._transitionable.setValue(g,x)}}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,u,g){return(!g||g.validate!==!1)&&s.emitValidationErrors(this,r.call(s.validateStyle,s.extend({value:u,style:{glyphs:!0,sprite:!0},styleSpec:s.spec})))}}const We=new s.Properties({source:new s.DataConstantProperty(s.spec.terrain.source),exaggeration:new s.DataConstantProperty(s.spec.terrain.exaggeration)}),st="-transition";class St extends s.Evented{constructor(r,u){super(),this._transitionable=new s.Transitionable(We),this.set(r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=u}get(){return this._transitionable.serialize()}set(r){for(const u in r){const g=r[u];s.endsWith(u,st)?this._transitionable.setTransition(u.slice(0,-st.length),g):this._transitionable.setValue(u,g)}}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}}function gt(f,r,u,g){const x=s.smoothstep(45,65,u),[b,S]=At(f,g),P=s.length(r);let z=1-Math.min(1,Math.exp((P-b)/(S-b)*-6));return z*=z*z,z=Math.min(1,1.00747*z),z*x*f.alpha}function At(f,r){const u=.5/Math.tan(.5*r);return[f.range[0]+u,f.range[1]+u]}const Dt=new s.Properties({range:new s.DataConstantProperty(s.spec.fog.range),color:new s.DataConstantProperty(s.spec.fog.color),"horizon-blend":new s.DataConstantProperty(s.spec.fog["horizon-blend"])}),Ot="-transition";class Pe extends s.Evented{constructor(r,u){super(),this._transitionable=new s.Transitionable(Dt),this.set(r),this._transitioning=this._transitionable.untransitioned(),this._transform=u}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(r,u={}){if(!this._validate(s.validateFog,r,u))for(const g in r){const x=r[g];s.endsWith(g,Ot)?this._transitionable.setTransition(g.slice(0,-Ot.length),x):this._transitionable.setValue(g,x)}}getOpacity(r){if(!this._transform.projection.supportsFog)return 0;const u=this.properties&&this.properties.get("color")||1;return s.smoothstep(45,65,r)*u.a}getOpacityAtLatLng(r,u){return this._transform.projection.supportsFog?function(g,x,b){const S=s.MercatorCoordinate.fromLngLat(x),P=b.elevation?b.elevation.getAtPointOrZero(S):0,z=[S.x,S.y,P];return s.transformMat4(z,z,b.mercatorFogMatrix),gt(g,z,b.pitch,b._fov)}(this.state,r,u):0}getFovAdjustedRange(r){return this._transform.projection.supportsFog?At(this.state,r):[0,1]}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,u,g){return(!g||g.validate!==!1)&&s.emitValidationErrors(this,r.call(s.validateStyle,s.extend({value:u,style:{glyphs:!0,sprite:!0},styleSpec:s.spec})))}}class ge{constructor(r,u){this.workerPool=r,this.actors=[],this.currentActor=0,this.id=s.uniqueId();const g=this.workerPool.acquire(this.id);for(let x=0;x<g.length;x++){const b=new ge.Actor(g[x],u,this.id);b.name=`Worker ${x}`,this.actors.push(b)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(r,u,g){s.asyncAll(this.actors,(x,b)=>{x.send(r,u,b)},g=g||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(r=>{r.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Ve(f,r,u){return r*(s.EXTENT/(f.tileSize*Math.pow(2,u-f.tileID.overscaledZ)))}ge.Actor=s.Actor;class Ne{constructor(r,u,g,x){this.screenBounds=r,this.cameraPoint=u,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=g,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(b=>x.pointCoordinate3D(b)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,u){let g,x;if(r instanceof s.pointGeometry||typeof r[0]=="number"){const b=s.pointGeometry.convert(r);g=[s.pointGeometry.convert(r)],x=u.isPointAboveHorizon(b)}else{const b=s.pointGeometry.convert(r[0]),S=s.pointGeometry.convert(r[1]);g=[b,S],x=s.polygonizeBounds(b,S).every(P=>u.isPointAboveHorizon(P))}return new Ne(g,u.getCameraPoint(),x,u)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(r){return s.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const u=this.screenBounds[0],g=this.screenBounds.length===1?this.screenBounds[0].add(new s.pointGeometry(1,1)):this.screenBounds[1],x=s.polygonizeBounds(u,g,0,!1);return this.cameraPoint.y>g.y&&(this.cameraPoint.x>u.x&&this.cameraPoint.x<g.x?x.splice(3,0,this.cameraPoint):this.cameraPoint.x>=g.x?x[2]=this.cameraPoint:this.cameraPoint.x<=u.x&&(x[3]=this.cameraPoint)),s.bufferConvexPolygon(x,r)}containsTile(r,u,g){const x=r.queryPadding+1,b=r.tileID.wrap,S=g?this._bufferedCameraMercator(x,u).map(Q=>s.getTilePoint(r.tileTransform,Q,b)):this._bufferedScreenMercator(x,u).map(Q=>s.getTilePoint(r.tileTransform,Q,b)),P=this.screenGeometryMercator.map(Q=>s.getTileVec3(r.tileTransform,Q,b)),z=P.map(Q=>new s.pointGeometry(Q[0],Q[1])),F=u.getFreeCameraOptions().position||new s.MercatorCoordinate(0,0,0),N=s.getTileVec3(r.tileTransform,F,b),H=P.map(Q=>{const X=s.sub(Q,Q,N);return s.normalize(X,X),new s.Ray(N,X)}),J=Ve(r,1,u.zoom);if(s.polygonIntersectsBox(S,0,0,s.EXTENT,s.EXTENT))return{queryGeometry:this,tilespaceGeometry:z,tilespaceRays:H,bufferedTilespaceGeometry:S,bufferedTilespaceBounds:(re=s.getBounds(S),re.min.x=s.clamp(re.min.x,0,s.EXTENT),re.min.y=s.clamp(re.min.y,0,s.EXTENT),re.max.x=s.clamp(re.max.x,0,s.EXTENT),re.max.y=s.clamp(re.max.y,0,s.EXTENT),re),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:J};var re}_bufferedScreenMercator(r,u){const g=Ie(r);if(this._screenRaycastCache[g])return this._screenRaycastCache[g];{const x=this.bufferedScreenGeometry(r).map(b=>u.pointCoordinate3D(b));return this._screenRaycastCache[g]=x,x}}_bufferedCameraMercator(r,u){const g=Ie(r);if(this._cameraRaycastCache[g])return this._cameraRaycastCache[g];{const x=this.bufferedCameraGeometry(r).map(b=>u.pointCoordinate3D(b));return this._cameraRaycastCache[g]=x,x}}}function Ie(f){return 100*f|0}function it(f,r,u){const g=function(x,b){if(x)return u(x);if(b){const S=s.pick(s.extend(b,f),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);b.vector_layers&&(S.vectorLayers=b.vector_layers,S.vectorLayerIds=S.vectorLayers.map(P=>P.id)),S.tiles=r.canonicalizeTileset(S,f.url),u(null,S)}};return f.url?s.getJSON(r.transformRequest(r.normalizeSourceURL(f.url),s.ResourceType.Source),g):s.exported.frame(()=>g(null,f))}class ce{constructor(r,u,g){this.bounds=s.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=u||0,this.maxzoom=g||24}validateBounds(r){return Array.isArray(r)&&r.length===4?[Math.max(-180,r[0]),Math.max(-90,r[1]),Math.min(180,r[2]),Math.min(90,r[3])]:[-180,-90,180,90]}contains(r){const u=Math.pow(2,r.z),g=Math.floor(s.mercatorXfromLng(this.bounds.getWest())*u),x=Math.floor(s.mercatorYfromLat(this.bounds.getNorth())*u),b=Math.ceil(s.mercatorXfromLng(this.bounds.getEast())*u),S=Math.ceil(s.mercatorYfromLat(this.bounds.getSouth())*u);return r.x>=g&&r.x<b&&r.y>=x&&r.y<S}}class we{constructor(r,u,g){this.context=r;const x=r.gl;this.buffer=x.createBuffer(),this.dynamicDraw=!!g,this.context.unbindVAO(),r.bindElementBuffer.set(this.buffer),x.bufferData(x.ELEMENT_ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?x.DYNAMIC_DRAW:x.STATIC_DRAW),this.dynamicDraw||u.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(r){const u=this.context.gl;this.context.unbindVAO(),this.bind(),u.bufferSubData(u.ELEMENT_ARRAY_BUFFER,0,r.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Me={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class pe{constructor(r,u,g,x){this.length=u.length,this.attributes=g,this.itemSize=u.bytesPerElement,this.dynamicDraw=x,this.context=r;const b=r.gl;this.buffer=b.createBuffer(),r.bindVertexBuffer.set(this.buffer),b.bufferData(b.ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.STATIC_DRAW),this.dynamicDraw||u.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(r){const u=this.context.gl;this.bind(),u.bufferSubData(u.ARRAY_BUFFER,0,r.arrayBuffer)}enableAttributes(r,u){for(let g=0;g<this.attributes.length;g++){const x=u.attributes[this.attributes[g].name];x!==void 0&&r.enableVertexAttribArray(x)}}setVertexAttribPointers(r,u,g){for(let x=0;x<this.attributes.length;x++){const b=this.attributes[x],S=u.attributes[b.name];S!==void 0&&r.vertexAttribPointer(S,b.components,r[Me[b.type]],!1,this.itemSize,b.offset+this.itemSize*(g||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Be{constructor(r){this.gl=r.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(r){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class $e extends Be{getDefault(){return s.Color.transparent}set(r){const u=this.current;(r.r!==u.r||r.g!==u.g||r.b!==u.b||r.a!==u.a||this.dirty)&&(this.gl.clearColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class ot extends Be{getDefault(){return 1}set(r){(r!==this.current||this.dirty)&&(this.gl.clearDepth(r),this.current=r,this.dirty=!1)}}class bt extends Be{getDefault(){return 0}set(r){(r!==this.current||this.dirty)&&(this.gl.clearStencil(r),this.current=r,this.dirty=!1)}}class Vt extends Be{getDefault(){return[!0,!0,!0,!0]}set(r){const u=this.current;(r[0]!==u[0]||r[1]!==u[1]||r[2]!==u[2]||r[3]!==u[3]||this.dirty)&&(this.gl.colorMask(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class oe extends Be{getDefault(){return!0}set(r){(r!==this.current||this.dirty)&&(this.gl.depthMask(r),this.current=r,this.dirty=!1)}}class ve extends Be{getDefault(){return 255}set(r){(r!==this.current||this.dirty)&&(this.gl.stencilMask(r),this.current=r,this.dirty=!1)}}class xt extends Be{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(r){const u=this.current;(r.func!==u.func||r.ref!==u.ref||r.mask!==u.mask||this.dirty)&&(this.gl.stencilFunc(r.func,r.ref,r.mask),this.current=r,this.dirty=!1)}}class mt extends Be{getDefault(){const r=this.gl;return[r.KEEP,r.KEEP,r.KEEP]}set(r){const u=this.current;(r[0]!==u[0]||r[1]!==u[1]||r[2]!==u[2]||this.dirty)&&(this.gl.stencilOp(r[0],r[1],r[2]),this.current=r,this.dirty=!1)}}class xn extends Be{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;r?u.enable(u.STENCIL_TEST):u.disable(u.STENCIL_TEST),this.current=r,this.dirty=!1}}class un extends Be{getDefault(){return[0,1]}set(r){const u=this.current;(r[0]!==u[0]||r[1]!==u[1]||this.dirty)&&(this.gl.depthRange(r[0],r[1]),this.current=r,this.dirty=!1)}}class tn extends Be{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;r?u.enable(u.DEPTH_TEST):u.disable(u.DEPTH_TEST),this.current=r,this.dirty=!1}}class dn extends Be{getDefault(){return this.gl.LESS}set(r){(r!==this.current||this.dirty)&&(this.gl.depthFunc(r),this.current=r,this.dirty=!1)}}class bn extends Be{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;r?u.enable(u.BLEND):u.disable(u.BLEND),this.current=r,this.dirty=!1}}class ln extends Be{getDefault(){const r=this.gl;return[r.ONE,r.ZERO]}set(r){const u=this.current;(r[0]!==u[0]||r[1]!==u[1]||this.dirty)&&(this.gl.blendFunc(r[0],r[1]),this.current=r,this.dirty=!1)}}class Gt extends Be{getDefault(){return s.Color.transparent}set(r){const u=this.current;(r.r!==u.r||r.g!==u.g||r.b!==u.b||r.a!==u.a||this.dirty)&&(this.gl.blendColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class on extends Be{getDefault(){return this.gl.FUNC_ADD}set(r){(r!==this.current||this.dirty)&&(this.gl.blendEquation(r),this.current=r,this.dirty=!1)}}class Zt extends Be{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;r?u.enable(u.CULL_FACE):u.disable(u.CULL_FACE),this.current=r,this.dirty=!1}}class qe extends Be{getDefault(){return this.gl.BACK}set(r){(r!==this.current||this.dirty)&&(this.gl.cullFace(r),this.current=r,this.dirty=!1)}}class Nt extends Be{getDefault(){return this.gl.CCW}set(r){(r!==this.current||this.dirty)&&(this.gl.frontFace(r),this.current=r,this.dirty=!1)}}class Qt extends Be{getDefault(){return null}set(r){(r!==this.current||this.dirty)&&(this.gl.useProgram(r),this.current=r,this.dirty=!1)}}class Pn extends Be{getDefault(){return this.gl.TEXTURE0}set(r){(r!==this.current||this.dirty)&&(this.gl.activeTexture(r),this.current=r,this.dirty=!1)}}class pn extends Be{getDefault(){const r=this.gl;return[0,0,r.drawingBufferWidth,r.drawingBufferHeight]}set(r){const u=this.current;(r[0]!==u[0]||r[1]!==u[1]||r[2]!==u[2]||r[3]!==u[3]||this.dirty)&&(this.gl.viewport(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class On extends Be{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.bindFramebuffer(u.FRAMEBUFFER,r),this.current=r,this.dirty=!1}}class Gn extends Be{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.bindRenderbuffer(u.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Zn extends Be{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.bindTexture(u.TEXTURE_2D,r),this.current=r,this.dirty=!1}}class Wi extends Be{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.bindBuffer(u.ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Nn extends Be{getDefault(){return null}set(r){const u=this.gl;u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Ci extends Be{constructor(r){super(r),this.vao=r.extVertexArrayObject}getDefault(){return null}set(r){this.vao&&(r!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(r),this.current=r,this.dirty=!1)}}class ei extends Be{getDefault(){return 4}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.pixelStorei(u.UNPACK_ALIGNMENT,r),this.current=r,this.dirty=!1}}class Ki extends Be{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this.current=r,this.dirty=!1}}class yi extends Be{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const u=this.gl;u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,r),this.current=r,this.dirty=!1}}class Hr extends Be{constructor(r,u){super(r),this.context=r,this.parent=u}getDefault(){return null}}class ki extends Hr{setDirty(){this.dirty=!0}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const u=this.gl;u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class Wr extends Hr{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const u=this.gl;u.framebufferRenderbuffer(u.FRAMEBUFFER,this.attachment(),u.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Sr extends Wr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class _e{constructor(r,u,g,x){this.context=r,this.width=u,this.height=g;const b=this.framebuffer=r.gl.createFramebuffer();this.colorAttachment=new ki(r,b),x&&(this.depthAttachment=new Wr(r,b))}destroy(){const r=this.context.gl,u=this.colorAttachment.get();if(u&&r.deleteTexture(u),this.depthAttachment){const g=this.depthAttachment.get();g&&r.deleteRenderbuffer(g)}r.deleteFramebuffer(this.framebuffer)}}class G{constructor(r){this.gl=r,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new $e(this),this.clearDepth=new ot(this),this.clearStencil=new bt(this),this.colorMask=new Vt(this),this.depthMask=new oe(this),this.stencilMask=new ve(this),this.stencilFunc=new xt(this),this.stencilOp=new mt(this),this.stencilTest=new xn(this),this.depthRange=new un(this),this.depthTest=new tn(this),this.depthFunc=new dn(this),this.blend=new bn(this),this.blendFunc=new ln(this),this.blendColor=new Gt(this),this.blendEquation=new on(this),this.cullFace=new Zt(this),this.cullFaceSide=new qe(this),this.frontFace=new Nt(this),this.program=new Qt(this),this.activeTexture=new Pn(this),this.viewport=new pn(this),this.bindFramebuffer=new On(this),this.bindRenderbuffer=new Gn(this),this.bindTexture=new Zn(this),this.bindVertexBuffer=new Wi(this),this.bindElementBuffer=new Nn(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new Ci(this),this.pixelStoreUnpack=new ei(this),this.pixelStoreUnpackPremultiplyAlpha=new Ki(this),this.pixelStoreUnpackFlipY=new yi(this),this.extTextureFilterAnisotropic=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=r.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=r.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(r.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=r.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=r.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(r,u){return new we(this,r,u)}createVertexBuffer(r,u,g){return new pe(this,r,u,g)}createRenderbuffer(r,u,g){const x=this.gl,b=x.createRenderbuffer();return this.bindRenderbuffer.set(b),x.renderbufferStorage(x.RENDERBUFFER,r,u,g),this.bindRenderbuffer.set(null),b}createFramebuffer(r,u,g){return new _e(this,r,u,g)}clear({color:r,depth:u,stencil:g}){const x=this.gl;let b=0;r&&(b|=x.COLOR_BUFFER_BIT,this.clearColor.set(r),this.colorMask.set([!0,!0,!0,!0])),u!==void 0&&(b|=x.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(u),this.depthMask.set(!0)),g!==void 0&&(b|=x.STENCIL_BUFFER_BIT,this.clearStencil.set(g),this.stencilMask.set(255)),x.clear(b)}setCullFace(r){r.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(r.mode),this.frontFace.set(r.frontFace))}setDepthMode(r){r.func!==this.gl.ALWAYS||r.mask?(this.depthTest.set(!0),this.depthFunc.set(r.func),this.depthMask.set(r.mask),this.depthRange.set(r.range)):this.depthTest.set(!1)}setStencilMode(r){r.test.func!==this.gl.ALWAYS||r.mask?(this.stencilTest.set(!0),this.stencilMask.set(r.mask),this.stencilOp.set([r.fail,r.depthFail,r.pass]),this.stencilFunc.set({func:r.test.func,ref:r.ref,mask:r.test.mask})):this.stencilTest.set(!1)}setColorMode(r){E(r.blendFunction,s.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor)),this.colorMask.set(r.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Z extends s.Evented{constructor(r,u,g,x){super(),this.id=r,this.dispatcher=g,this.setEventedParent(x),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=s.extend({type:"raster"},u),s.extend(this,s.pick(u,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=it(this._options,this.map._requestManager,(r,u)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new s.ErrorEvent(r)):u&&(s.extend(this,u),u.bounds&&(this.tileBounds=new ce(u.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(u.tiles),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return s.extend({},this._options)}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}loadTile(r,u){const g=s.exported.devicePixelRatio>=2,x=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),g,this.tileSize);r.request=s.getImage(this.map._requestManager.transformRequest(x,s.ResourceType.Tile),(b,S,P,z)=>(delete r.request,r.aborted?(r.state="unloaded",u(null)):b?(r.state="errored",u(b)):S?(this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:P,expires:z}),r.setTexture(S,this.map.painter),r.state="loaded",s.cacheEntryPossiblyAdded(this.dispatcher),void u(null)):u(null)))}static loadTileData(r,u,g){r.setTexture(u,g)}static unloadTileData(r,u){r.texture&&u.saveTileTexture(r.texture)}abortTile(r,u){r.request&&(r.request.cancel(),delete r.request),u()}unloadTile(r,u){r.texture&&this.map.painter.saveTileTexture(r.texture),u()}hasTransition(){return!1}}let de;function Le(f,r,u,g,x,b,S,P){const z=[f,u,x,r,g,b,1,1,1],F=[S,P,1],N=s.adjoint([],z),[H,J,re]=s.transformMat3(F,F,s.transpose(N,N));return s.multiply(z,[H,0,0,0,J,0,0,0,re],z)}class Ge extends s.Evented{constructor(r,u,g,x){super(),this.id=r,this.dispatcher=g,this.coordinates=u.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(x),this.options=u}load(r){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this.url=this.options.url,s.getImage(this.map._requestManager.transformRequest(this.url,s.ResourceType.Image),(u,g)=>{if(this._loaded=!0,u)this.fire(new s.ErrorEvent(u));else if(g){const{HTMLImageElement:x}=s.window;this.image=g instanceof x?s.exported.getImageData(g):g,this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),this._finishLoading()}})}loaded(){return this._loaded}updateImage(r){return this.image&&r.url?(this.options.url=r.url,this.load(r.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(r){this.map=r,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(r){this.coordinates=r,this._boundsArray=void 0;const u=r.map(s.MercatorCoordinate.fromLngLat);return this.tileID=function(g){let x=1/0,b=1/0,S=-1/0,P=-1/0;for(const H of g)x=Math.min(x,H.x),b=Math.min(b,H.y),S=Math.max(S,H.x),P=Math.max(P,H.y);const z=Math.max(S-x,P-b),F=Math.max(0,Math.floor(-Math.log(z)/Math.LN2)),N=Math.pow(2,F);return new s.CanonicalTileID(F,Math.floor((x+S)/2*N),Math.floor((b+P)/2*N))}(u),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(r){for(const z in this.tiles){const F=this.tiles[z];F.state!=="loaded"&&(F.state="loaded",F.texture=this.texture)}if(this._boundsArray)return;const u=s.tileTransform(this.tileID,this.map.transform.projection),[g,x,b,S]=this.coordinates.map(z=>{const F=u.projection.project(z[0],z[1]);return s.getTilePoint(u,F)._round()});this.perspectiveTransform=function(z,F,N,H,J,re,Q,X,Ae,fe){const Te=Le(0,0,z,0,0,F,z,F),Se=Le(N,H,J,re,Q,X,Ae,fe);return s.multiply(Se,s.adjoint(Te,Te),Se),[Se[6]/Se[8]*z/s.EXTENT,Se[7]/Se[8]*F/s.EXTENT]}(this.width,this.height,g.x,g.y,x.x,x.y,S.x,S.y,b.x,b.y);const P=this._boundsArray=new s.StructArrayLayout4i8;P.emplaceBack(g.x,g.y,0,0),P.emplaceBack(x.x,x.y,s.EXTENT,0),P.emplaceBack(S.x,S.y,0,s.EXTENT),P.emplaceBack(b.x,b.y,s.EXTENT,s.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=r.createVertexBuffer(P,s.boundsAttributes.members),this.boundsSegments=s.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const r=this.map.painter.context,u=r.gl;this.texture?this.texture.update(this.image):(this.texture=new s.Texture(r,this.image,u.RGBA),this.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE)),this._prepareData(r)}loadTile(r,u){this.tileID&&this.tileID.equals(r.tileID.canonical)?(this.tiles[String(r.tileID.wrap)]=r,r.buckets={},u(null)):(r.state="errored",u(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Je={vector:class extends s.Evented{constructor(f,r,u,g){if(super(),this.id=f,this.dispatcher=u,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.extend(this,s.pick(r,["url","scheme","tileSize","promoteId"])),this._options=s.extend({type:"vector"},r),this._collectResourceTiming=r.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(g),this._tileWorkers={},this._deduped=new s.DedupedRequest}load(){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=it(this._options,this.map._requestManager,(f,r)=>{this._tileJSONRequest=null,this._loaded=!0,f?this.fire(new s.ErrorEvent(f)):r&&(s.extend(this,r),r.bounds&&(this.tileBounds=new ce(r.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(r.tiles,this.map._requestManager._customAccessToken),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(f){return!this.tileBounds||this.tileBounds.contains(f.canonical)}onAdd(f){this.map=f,this.load()}setSourceProperty(f){this._tileJSONRequest&&this._tileJSONRequest.cancel(),f();const r=this.map.style._getSourceCaches(this.id);for(const u of r)u.clearTiles();this.load()}setTiles(f){return this.setSourceProperty(()=>{this._options.tiles=f}),this}setUrl(f){return this.setSourceProperty(()=>{this.url=f,this._options.url=f}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return s.extend({},this._options)}loadTile(f,r){const u=this.map._requestManager.normalizeTileURL(f.tileID.canonical.url(this.tiles,this.scheme)),g={request:this.map._requestManager.transformRequest(u,s.ResourceType.Tile),data:void 0,uid:f.uid,tileID:f.tileID,tileZoom:f.tileZoom,zoom:f.tileID.overscaledZ,tileSize:this.tileSize*f.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:f.isSymbolTile};if(g.request.collectResourceTiming=this._collectResourceTiming,f.actor&&f.state!=="expired")f.state==="loading"?f.reloadCallback=r:f.request=f.actor.send("reloadTile",g,x.bind(this));else if(f.actor=this._tileWorkers[u]=this._tileWorkers[u]||this.dispatcher.getActor(),this.dispatcher.ready)f.request=f.actor.send("loadTile",g,x.bind(this),void 0,!0);else{const b=s.loadVectorTile.call({deduped:this._deduped},g,(S,P)=>{S||!P?x.call(this,S):(g.data={cacheControl:P.cacheControl,expires:P.expires,rawData:P.rawData.slice(0)},f.actor&&f.actor.send("loadTile",g,x.bind(this),void 0,!0))},!0);f.request={cancel:b}}function x(b,S){return delete f.request,f.aborted?r(null):b&&b.status!==404?r(b):(S&&S.resourceTiming&&(f.resourceTiming=S.resourceTiming),this.map._refreshExpiredTiles&&S&&f.setExpiryData(S),f.loadVectorData(S,this.map.painter),s.cacheEntryPossiblyAdded(this.dispatcher),r(null),void(f.reloadCallback&&(this.loadTile(f,f.reloadCallback),f.reloadCallback=null)))}}abortTile(f){f.request&&(f.request.cancel(),delete f.request),f.actor&&f.actor.send("abortTile",{uid:f.uid,type:this.type,source:this.id})}unloadTile(f){f.unloadVectorData(),f.actor&&f.actor.send("removeTile",{uid:f.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Z,"raster-dem":class extends Z{constructor(f,r,u,g){super(f,r,u,g),this.type="raster-dem",this.maxzoom=22,this._options=s.extend({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(f,r){const u=this.map._requestManager.normalizeTileURL(f.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function g(x,b){x&&(f.state="errored",r(x)),b&&(f.dem=b,f.dem.onDeserialize(),f.needsHillshadePrepare=!0,f.needsDEMTextureUpload=!0,f.state="loaded",r(null))}f.request=s.getImage(this.map._requestManager.transformRequest(u,s.ResourceType.Tile),function(x,b,S,P){if(delete f.request,f.aborted)f.state="unloaded",r(null);else if(x)f.state="errored",r(x);else if(b){this.map._refreshExpiredTiles&&f.setExpiryData({cacheControl:S,expires:P});const z=s.window.ImageBitmap&&b instanceof s.window.ImageBitmap&&(de==null&&(de=s.window.OffscreenCanvas&&new s.window.OffscreenCanvas(1,1).getContext("2d")&&typeof s.window.createImageBitmap=="function"),de),F=1-(b.width-s.prevPowerOfTwo(b.width))/2;F<1||f.neighboringTiles||(f.neighboringTiles=this._getNeighboringTiles(f.tileID));const N=z?b:s.exported.getImageData(b,F),H={uid:f.uid,coord:f.tileID,source:this.id,rawImageData:N,encoding:this.encoding,padding:F};f.actor&&f.state!=="expired"||(f.actor=this.dispatcher.getActor(),f.actor.send("loadDEMTile",H,g.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(f){const r=f.canonical,u=Math.pow(2,r.z),g=(r.x-1+u)%u,x=r.x===0?f.wrap-1:f.wrap,b=(r.x+1+u)%u,S=r.x+1===u?f.wrap+1:f.wrap,P={};return P[new s.OverscaledTileID(f.overscaledZ,x,r.z,g,r.y).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,S,r.z,b,r.y).key]={backfilled:!1},r.y>0&&(P[new s.OverscaledTileID(f.overscaledZ,x,r.z,g,r.y-1).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,f.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,S,r.z,b,r.y-1).key]={backfilled:!1}),r.y+1<u&&(P[new s.OverscaledTileID(f.overscaledZ,x,r.z,g,r.y+1).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,f.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},P[new s.OverscaledTileID(f.overscaledZ,S,r.z,b,r.y+1).key]={backfilled:!1}),P}unloadTile(f){f.demTexture&&this.map.painter.saveTileTexture(f.demTexture),f.fbo&&(f.fbo.destroy(),delete f.fbo),f.dem&&delete f.dem,delete f.neighboringTiles,f.state="unloaded"}},geojson:class extends s.Evented{constructor(f,r,u,g){super(),this.id=f,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=u.getActor(),this.setEventedParent(g),this._data=r.data,this._options=s.extend({},r),this._collectResourceTiming=r.collectResourceTiming,r.maxzoom!==void 0&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const x=s.EXTENT/this.tileSize;this.workerOptions=s.extend({source:this.id,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(r.buffer!==void 0?r.buffer:128)*x,tolerance:(r.tolerance!==void 0?r.tolerance:.375)*x,extent:s.EXTENT,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:r.clusterMaxZoom!==void 0?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:s.EXTENT,radius:(r.clusterRadius!==void 0?r.clusterRadius:50)*x,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}onAdd(f){this.map=f,this.setData(this._data)}setData(f){return this._data=f,this._updateWorkerData(),this}getClusterExpansionZoom(f,r){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:f,source:this.id},r),this}getClusterChildren(f,r){return this.actor.send("geojson.getClusterChildren",{clusterId:f,source:this.id},r),this}getClusterLeaves(f,r,u,g){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:f,limit:r,offset:u},g),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new s.Event("dataloading",{dataType:"source"})),this._loaded=!1;const f=s.extend({},this.workerOptions),r=this._data;typeof r=="string"?(f.request=this.map._requestManager.transformRequest(s.exported.resolveURL(r),s.ResourceType.Source),f.request.collectResourceTiming=this._collectResourceTiming):f.data=JSON.stringify(r),this._pendingLoad=this.actor.send(`${this.type}.loadData`,f,(u,g)=>{if(this._loaded=!0,this._pendingLoad=null,u)this.fire(new s.ErrorEvent(u));else{const x={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&g&&g.resourceTiming&&g.resourceTiming[this.id]&&(x.resourceTiming=g.resourceTiming[this.id]),this.fire(new s.Event("data",x)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(f,r){const u=f.actor?"reloadTile":"loadTile";f.actor=this.actor,f.request=this.actor.send(u,{type:this.type,uid:f.uid,tileID:f.tileID,tileZoom:f.tileZoom,zoom:f.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(g,x)=>(delete f.request,f.unloadVectorData(),f.aborted?r(null):g?r(g):(f.loadVectorData(x,this.map.painter,u==="reloadTile"),r(null))),void 0,u==="loadTile")}abortTile(f){f.request&&(f.request.cancel(),delete f.request),f.aborted=!0}unloadTile(f){f.unloadVectorData(),this.actor.send("removeTile",{uid:f.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return s.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ge{constructor(f,r,u,g){super(f,r,u,g),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const f=this.options;this.urls=[];for(const r of f.urls)this.urls.push(this.map._requestManager.transformRequest(r,s.ResourceType.Source).url);s.getVideo(this.urls,(r,u)=>{this._loaded=!0,r?this.fire(new s.ErrorEvent(r)):u&&(this.video=u,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(f){if(this.video){const r=this.video.seekable;f<r.start(0)||f>r.end(0)?this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=f}}getVideo(){return this.video}onAdd(f){this.map||(this.map=f,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const f=this.map.painter.context,r=f.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new s.Texture(f,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(f)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ge,canvas:class extends Ge{constructor(f,r,u,g){super(f,r,u,g),r.coordinates?Array.isArray(r.coordinates)&&r.coordinates.length===4&&!r.coordinates.some(x=>!Array.isArray(x)||x.length!==2||x.some(b=>typeof b!="number"))||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'missing required property "coordinates"'))),r.animate&&typeof r.animate!="boolean"&&this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'optional "animate" property must be a boolean value'))),r.canvas?typeof r.canvas=="string"||r.canvas instanceof s.window.HTMLCanvasElement||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${f}`,null,'missing required property "canvas"'))),this.options=r,this.animate=r.animate===void 0||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof s.window.HTMLCanvasElement?this.options.canvas:s.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new s.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(f){this.map=f,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let f=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,f=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,f=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const r=this.map.painter.context;this.texture?(f||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new s.Texture(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const f of[this.canvas.width,this.canvas.height])if(isNaN(f)||f<=0)return!0;return!1}},custom:class extends s.Evented{constructor(f,r,u,g){super(),this.id=f,this.type="custom",this._dataType="raster",this._dispatcher=u,this._implementation=r,this.setEventedParent(g),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new s.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new s.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ce(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.coveringTiles=this._coveringTiles.bind(this),s.extend(this,s.pick(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return s.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(f){this._map=f,this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(f),this.load()}onRemove(f){this._implementation.onRemove&&this._implementation.onRemove(f)}hasTile(f){if(this._implementation.hasTile){const{x:r,y:u,z:g}=f.canonical;return this._implementation.hasTile({x:r,y:u,z:g})}return!this.tileBounds||this.tileBounds.contains(f.canonical)}loadTile(f,r){const{x:u,y:g,z:x}=f.tileID.canonical,b=new s.window.AbortController,S=this._implementation.loadTile({x:u,y:g,z:x},{signal:b.signal});if(!S)return this.loadTileData(f,{width:this.tileSize,height:this.tileSize,data:null}),f.state="loaded",r(null);S.cancel=()=>b.abort(),f.request=S.then(function(P){return delete f.request,f.aborted?(f.state="unloaded",r(null)):P?function(z){return z instanceof s.window.ImageData||z instanceof s.window.ImageBitmap||z instanceof s.window.HTMLCanvasElement}(P)?(this.loadTileData(f,P),f.state="loaded",void r(null)):(f.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(f,{width:this.tileSize,height:this.tileSize,data:null}),f.state="loaded",r(null))}.bind(this)).catch(P=>{P.code!==20&&(f.state="errored",r(P))})}loadTileData(f,r){Z.loadTileData(f,r,this._map.painter)}unloadTileData(f){Z.unloadTileData(f,this._map.painter)}prepareTile(f){if(!this._implementation.prepareTile)return null;const{x:r,y:u,z:g}=f.tileID.canonical,x=this._implementation.prepareTile({x:r,y:u,z:g});return x?(this.loadTileData(f,x),f.state="loaded",x):null}unloadTile(f,r){if(this.unloadTileData(f),this._implementation.unloadTile){const{x:u,y:g,z:x}=f.tileID.canonical;this._implementation.unloadTile({x:u,y:g,z:x})}r()}abortTile(f,r){f.request&&f.request.cancel&&(f.request.cancel(),delete f.request),r()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(f=>({x:f.canonical.x,y:f.canonical.y,z:f.canonical.z}))}_update(){this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Ke=function(f,r,u,g){const x=new Je[r.type](f,r,u,g);if(x.id!==f)throw new Error(`Expected Source id to be ${f} instead of ${x.id}`);return s.bindAll(["load","abort","unload","serialize","prepare"],x),x};function je(f,r){const u=s.identity([]);return s.scale(u,u,[.5*f.width,.5*-f.height,1]),s.translate(u,u,[1,-1,0]),s.multiply$1(u,u,f.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(u)}function nt(f,r,u,g,x,b,S,P=!1){const z=f.tilesIn(g,S,P);z.sort(Ut);const F=[];for(const H of z)F.push({wrappedTileID:H.tile.tileID.wrapped().key,queryResults:H.tile.queryRenderedFeatures(r,u,f._state,H,x,b,je(f.transform,H.tile.tileID),P)});const N=function(H){const J={},re={};for(const Q of H){const X=Q.queryResults,Ae=Q.wrappedTileID,fe=re[Ae]=re[Ae]||{};for(const Te in X){const Se=X[Te],Re=fe[Te]=fe[Te]||{},be=J[Te]=J[Te]||[];for(const Fe of Se)Re[Fe.featureIndex]||(Re[Fe.featureIndex]=!0,be.push(Fe))}}return J}(F);for(const H in N)N[H].forEach(J=>{const re=J.feature,Q=re.layer;Q&&Q.type!=="background"&&Q.type!=="sky"&&(re.source=Q.source,Q["source-layer"]&&(re.sourceLayer=Q["source-layer"]),re.state=re.id!==void 0?f.getFeatureState(Q["source-layer"],re.id):{})});return N}function yt(f,r){const u=f.getRenderableIds().map(b=>f.getTileByID(b)),g=[],x={};for(let b=0;b<u.length;b++){const S=u[b],P=S.tileID.canonical.key;x[P]||(x[P]=!0,S.querySourceFeatures(g,r))}return g}function Ut(f,r){const u=f.tileID,g=r.tileID;return u.overscaledZ-g.overscaledZ||u.canonical.y-g.canonical.y||u.wrap-g.wrap||u.canonical.x-g.canonical.x}function Et(){return Is.workerClass!=null?new Is.workerClass:new s.window.Worker(Is.workerUrl)}const _n="mapboxgl_preloaded_worker_pool";class W{constructor(){this.active={}}acquire(r){if(!this.workers)for(this.workers=[];this.workers.length<W.workerCount;)this.workers.push(new Et);return this.active[r]=!0,this.workers.slice()}release(r){delete this.active[r],this.numActive()===0&&(this.workers.forEach(u=>{u.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[_n]}numActive(){return Object.keys(this.active).length}}let Y;function ze(){return Y||(Y=new W),Y}function xe(f,r){const u={};for(const g in f)g!=="ref"&&(u[g]=f[g]);return s.refProperties.forEach(g=>{g in r&&(u[g]=r[g])}),u}function Mt(f){f=f.slice();const r=Object.create(null);for(let u=0;u<f.length;u++)r[f[u].id]=f[u];for(let u=0;u<f.length;u++)"ref"in f[u]&&(f[u]=xe(f[u],r[f[u].ref]));return f}W.workerCount=2;const _t={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function Ft(f,r,u){u.push({command:_t.addSource,args:[f,r[f]]})}function nn(f,r,u){r.push({command:_t.removeSource,args:[f]}),u[f]=!0}function Ln(f,r,u,g){nn(f,u,g),Ft(f,r,u)}function Dn(f,r,u){let g;for(g in f[u])if(f[u].hasOwnProperty(g)&&g!=="data"&&!E(f[u][g],r[u][g]))return!1;for(g in r[u])if(r[u].hasOwnProperty(g)&&g!=="data"&&!E(f[u][g],r[u][g]))return!1;return!0}function wt(f,r,u,g,x,b){let S;for(S in r=r||{},f=f||{})f.hasOwnProperty(S)&&(E(f[S],r[S])||u.push({command:b,args:[g,S,r[S],x]}));for(S in r)r.hasOwnProperty(S)&&!f.hasOwnProperty(S)&&(E(f[S],r[S])||u.push({command:b,args:[g,S,r[S],x]}))}function cn(f){return f.id}function $t(f,r){return f[r.id]=r,f}class fn{constructor(r,u){this.reset(r,u)}reset(r,u){this.points=r||[],this._distances=[0];for(let g=1;g<this.points.length;g++)this._distances[g]=this._distances[g-1]+this.points[g].dist(this.points[g-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(u||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(r){if(this.points.length===1)return this.points[0];r=s.clamp(r,0,1);let u=1,g=this._distances[u];const x=r*this.paddedLength+this.padding;for(;g<x&&u<this._distances.length;)g=this._distances[++u];const b=u-1,S=this._distances[b],P=g-S,z=P>0?(x-S)/P:0;return this.points[b].mult(1-z).add(this.points[u].mult(z))}}class Tn{constructor(r,u,g){const x=this.boxCells=[],b=this.circleCells=[];this.xCellCount=Math.ceil(r/g),this.yCellCount=Math.ceil(u/g);for(let S=0;S<this.xCellCount*this.yCellCount;S++)x.push([]),b.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=r,this.height=u,this.xScale=this.xCellCount/r,this.yScale=this.yCellCount/u,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(r,u,g,x,b){this._forEachCell(u,g,x,b,this._insertBoxCell,this.boxUid++),this.boxKeys.push(r),this.bboxes.push(u),this.bboxes.push(g),this.bboxes.push(x),this.bboxes.push(b)}insertCircle(r,u,g,x){this._forEachCell(u-x,g-x,u+x,g+x,this._insertCircleCell,this.circleUid++),this.circleKeys.push(r),this.circles.push(u),this.circles.push(g),this.circles.push(x)}_insertBoxCell(r,u,g,x,b,S){this.boxCells[b].push(S)}_insertCircleCell(r,u,g,x,b,S){this.circleCells[b].push(S)}_query(r,u,g,x,b,S){if(g<0||r>this.width||x<0||u>this.height)return!b&&[];const P=[];if(r<=0&&u<=0&&this.width<=g&&this.height<=x){if(b)return!0;for(let z=0;z<this.boxKeys.length;z++)P.push({key:this.boxKeys[z],x1:this.bboxes[4*z],y1:this.bboxes[4*z+1],x2:this.bboxes[4*z+2],y2:this.bboxes[4*z+3]});for(let z=0;z<this.circleKeys.length;z++){const F=this.circles[3*z],N=this.circles[3*z+1],H=this.circles[3*z+2];P.push({key:this.circleKeys[z],x1:F-H,y1:N-H,x2:F+H,y2:N+H})}return S?P.filter(S):P}return this._forEachCell(r,u,g,x,this._queryCell,P,{hitTest:b,seenUids:{box:{},circle:{}}},S),b?P.length>0:P}_queryCircle(r,u,g,x,b){const S=r-g,P=r+g,z=u-g,F=u+g;if(P<0||S>this.width||F<0||z>this.height)return!x&&[];const N=[];return this._forEachCell(S,z,P,F,this._queryCellCircle,N,{hitTest:x,circle:{x:r,y:u,radius:g},seenUids:{box:{},circle:{}}},b),x?N.length>0:N}query(r,u,g,x,b){return this._query(r,u,g,x,!1,b)}hitTest(r,u,g,x,b){return this._query(r,u,g,x,!0,b)}hitTestCircle(r,u,g,x){return this._queryCircle(r,u,g,!0,x)}_queryCell(r,u,g,x,b,S,P,z){const F=P.seenUids,N=this.boxCells[b];if(N!==null){const J=this.bboxes;for(const re of N)if(!F.box[re]){F.box[re]=!0;const Q=4*re;if(r<=J[Q+2]&&u<=J[Q+3]&&g>=J[Q+0]&&x>=J[Q+1]&&(!z||z(this.boxKeys[re]))){if(P.hitTest)return S.push(!0),!0;S.push({key:this.boxKeys[re],x1:J[Q],y1:J[Q+1],x2:J[Q+2],y2:J[Q+3]})}}}const H=this.circleCells[b];if(H!==null){const J=this.circles;for(const re of H)if(!F.circle[re]){F.circle[re]=!0;const Q=3*re;if(this._circleAndRectCollide(J[Q],J[Q+1],J[Q+2],r,u,g,x)&&(!z||z(this.circleKeys[re]))){if(P.hitTest)return S.push(!0),!0;{const X=J[Q],Ae=J[Q+1],fe=J[Q+2];S.push({key:this.circleKeys[re],x1:X-fe,y1:Ae-fe,x2:X+fe,y2:Ae+fe})}}}}}_queryCellCircle(r,u,g,x,b,S,P,z){const F=P.circle,N=P.seenUids,H=this.boxCells[b];if(H!==null){const re=this.bboxes;for(const Q of H)if(!N.box[Q]){N.box[Q]=!0;const X=4*Q;if(this._circleAndRectCollide(F.x,F.y,F.radius,re[X+0],re[X+1],re[X+2],re[X+3])&&(!z||z(this.boxKeys[Q])))return S.push(!0),!0}}const J=this.circleCells[b];if(J!==null){const re=this.circles;for(const Q of J)if(!N.circle[Q]){N.circle[Q]=!0;const X=3*Q;if(this._circlesCollide(re[X],re[X+1],re[X+2],F.x,F.y,F.radius)&&(!z||z(this.circleKeys[Q])))return S.push(!0),!0}}}_forEachCell(r,u,g,x,b,S,P,z){const F=this._convertToXCellCoord(r),N=this._convertToYCellCoord(u),H=this._convertToXCellCoord(g),J=this._convertToYCellCoord(x);for(let re=F;re<=H;re++)for(let Q=N;Q<=J;Q++)if(b.call(this,r,u,g,x,this.xCellCount*Q+re,S,P,z))return}_convertToXCellCoord(r){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(r*this.xScale)))}_convertToYCellCoord(r){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(r*this.yScale)))}_circlesCollide(r,u,g,x,b,S){const P=x-r,z=b-u,F=g+S;return F*F>P*P+z*z}_circleAndRectCollide(r,u,g,x,b,S,P){const z=(S-x)/2,F=Math.abs(r-(x+z));if(F>z+g)return!1;const N=(P-b)/2,H=Math.abs(u-(b+N));if(H>N+g)return!1;if(F<=z||H<=N)return!0;const J=F-z,re=H-N;return J*J+re*re<=g*g}}const Sn=Math.tan(85*Math.PI/180);function di(f,r,u,g,x,b){const S=s.create();if(u){if(x.projection.name==="globe")s.multiply$1(S,S,s.calculateGlobeLabelMatrix(x,r));else{const P=le([],b);S[0]=P[0],S[1]=P[1],S[4]=P[2],S[5]=P[3]}g||s.rotateZ(S,S,x.angle)}else s.multiply$1(S,x.labelPlaneMatrix,f);return S}function Ar(f,r,u,g,x,b){if(u){if(x.projection.name==="globe"){const S=di(f,r,u,g,x,b);return s.invert(S,S),s.multiply$1(S,f,S),S}{const S=s.clone(f),P=s.identity([]);return P[0]=b[0],P[1]=b[1],P[4]=b[2],P[5]=b[3],s.multiply$1(S,S,P),g||s.rotateZ(S,S,-x.angle),S}}return x.glCoordMatrix}function ai(f,r,u=0){const g=[f.x,f.y,u,1];u?s.transformMat4$1(g,g,r):Cr(g,g,r);const x=g[3];return{point:new s.pointGeometry(g[0]/x,g[1]/x),signedDistanceFromCamera:x}}function li(f,r){const u=[f[0],f[1],f[2],1];s.transformMat4$1(u,u,r);const g=u[3];return{point:new s.pointGeometry(u[0]/g,u[1]/g),signedDistanceFromCamera:g}}function oi(f,r){return Math.min(.5+f/r*.5,1.5)}function ys(f,r){const u=f[0]/f[3],g=f[1]/f[3];return u>=-r[0]&&u<=r[0]&&g>=-r[1]&&g<=r[1]}function za(f,r,u,g,x,b,S,P,z,F){const N=u.transform,H=g?f.textSizeData:f.iconSizeData,J=s.evaluateSizeForZoom(H,u.transform.zoom),re=[256/u.width*2+1,256/u.height*2+1],Q=g?f.text.dynamicLayoutVertexArray:f.icon.dynamicLayoutVertexArray;Q.clear();const X=f.lineVertexArray,Ae=g?f.text.placedSymbolArray:f.icon.placedSymbolArray,fe=u.transform.width/u.transform.height;let Te=!1;for(let Se=0;Se<Ae.length;Se++){const Re=Ae.get(Se);if(Re.writingMode!==s.WritingMode.vertical||Te||Se!==0&&Ae.get(Se-1).writingMode===s.WritingMode.horizontal||(Te=!0),(Re.hidden||Re.writingMode===s.WritingMode.vertical)&&!Te){Bi(Re.numGlyphs,Q);continue}Te=!1;const be=new s.pointGeometry(Re.tileAnchorX,Re.tileAnchorY),Fe=z?z(be):[0,0,0],Qe=N.projection.projectTilePoint(be.x,be.y,F.canonical),at=[Qe.x+Fe[0],Qe.y+Fe[1],Qe.z+Fe[2]],dt=[...at,1];if(s.transformMat4$1(dt,dt,r),!ys(dt,re)){Bi(Re.numGlyphs,Q);continue}const ut=oi(u.transform.cameraToCenterDistance,dt[3]),Rt=s.evaluateSizeForFeature(H,J,Re),et=S?Rt/ut:Rt*ut,zt=ai(new s.pointGeometry(at[0],at[1]),x,at[2]);if(zt.signedDistanceFromCamera<=0){Bi(Re.numGlyphs,Q);continue}let Pt={};const Jt=S?null:z,pt=ru(Re,et,!1,P,r,x,b,f.glyphOffsetArray,X,Q,zt.point,be,Pt,fe,Jt,N.projection,F);Te=pt.useVertical,Jt&&pt.needsFlipping&&(Pt={}),(pt.notEnoughRoom||Te||pt.needsFlipping&&ru(Re,et,!0,P,r,x,b,f.glyphOffsetArray,X,Q,zt.point,be,Pt,fe,Jt,N.projection,F).notEnoughRoom)&&Bi(Re.numGlyphs,Q)}g?f.text.dynamicLayoutVertexBuffer.updateData(Q):f.icon.dynamicLayoutVertexBuffer.updateData(Q)}function iu(f,r,u,g,x,b,S,P,z,F,N,H,J,re,Q){const X=P.glyphStartIndex+P.numGlyphs,Ae=P.lineStartIndex,fe=P.lineStartIndex+P.lineLength,Te=r.getoffsetX(P.glyphStartIndex),Se=r.getoffsetX(X-1),Re=xs(f*Te,u,g,x,b,S,P.segment,Ae,fe,z,F,N,H,J,!0,re,Q);if(!Re)return null;const be=xs(f*Se,u,g,x,b,S,P.segment,Ae,fe,z,F,N,H,J,!0,re,Q);return be?{first:Re,last:be}:null}function vs(f,r,u,g){return f.writingMode===s.WritingMode.horizontal&&Math.abs(u.y-r.y)>Math.abs(u.x-r.x)*g?{useVertical:!0}:f.writingMode===s.WritingMode.vertical?r.y<u.y?{needsFlipping:!0}:null:f.flipState!==0&&function(x,b,S){const P=(b.x-x.x)*S;return P===0||Math.abs((b.y-x.y)/P)>Sn}(r,u,g)?f.flipState===1?{needsFlipping:!0}:null:r.x>u.x?{needsFlipping:!0}:null}function ru(f,r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae){const fe=r/24,Te=f.lineOffsetX*fe,Se=f.lineOffsetY*fe;let Re;if(f.numGlyphs>1){const be=f.glyphStartIndex+f.numGlyphs,Fe=f.lineStartIndex,Qe=f.lineStartIndex+f.lineLength,at=iu(fe,P,Te,Se,u,N,H,f,z,b,J,Q,!1,X,Ae);if(!at)return{notEnoughRoom:!0};const dt=ai(at.first.point,S).point,ut=ai(at.last.point,S).point;if(g&&!u){const Rt=vs(f,dt,ut,re);if(f.flipState=Rt&&Rt.needsFlipping?1:2,Rt)return Rt}Re=[at.first];for(let Rt=f.glyphStartIndex+1;Rt<be-1;Rt++)Re.push(xs(fe*P.getoffsetX(Rt),Te,Se,u,N,H,f.segment,Fe,Qe,z,b,J,Q,!1,!1,X,Ae));Re.push(at.last)}else{if(g&&!u){const Fe=ai(H,x).point,Qe=f.lineStartIndex+f.segment+1,at=new s.pointGeometry(z.getx(Qe),z.gety(Qe)),dt=ai(at,x),ut=vs(f,Fe,dt.signedDistanceFromCamera>0?dt.point:Xn(H,at,Fe,1,x,void 0,X,Ae.canonical),re);if(f.flipState=ut&&ut.needsFlipping?1:2,ut)return ut}const be=xs(fe*P.getoffsetX(f.glyphStartIndex),Te,Se,u,N,H,f.segment,f.lineStartIndex,f.lineStartIndex+f.lineLength,z,b,J,Q,!1,!1,X,Ae);if(!be)return{notEnoughRoom:!0};Re=[be]}for(const be of Re)s.addDynamicAttributes(F,be.point,be.angle);return{}}function xd(f,r,u,g,x){const b=g.projectTilePoint(f.x,f.y,r);if(!x)return ai(b,u,b.z);const S=x(f);return ai(new s.pointGeometry(b.x+S[0],b.y+S[1]),u,b.z+S[2])}function Xn(f,r,u,g,x,b,S,P){const z=xd(f.add(f.sub(r)._unit()),P,x,S,b).point,F=u.sub(z);return u.add(F._mult(g/F.mag()))}function xs(f,r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae){const fe=g?f-r:f+r;let Te=fe>0?1:-1,Se=0;g&&(Te*=-1,Se=Math.PI),Te<0&&(Se+=Math.PI);let Re=Te>0?P+S:P+S+1,be=x,Fe=x,Qe=0,at=0;const dt=Math.abs(fe),ut=[],Rt=[];let et=b;const zt=()=>{const Xt=Re-Te;return Qe===0?b:new s.pointGeometry(F.getx(Xt),F.gety(Xt))},Pt=()=>Xn(zt(),et,Fe,dt-Qe+1,N,J,X,Ae.canonical);for(;Qe+at<=dt;){if(Re+=Te,Re<P||Re>=z)return null;if(Fe=be,ut.push(be),re&&Rt.push(et||zt()),be=H[Re],be===void 0){et=new s.pointGeometry(F.getx(Re),F.gety(Re));const Xt=xd(et,Ae.canonical,N,X,J);be=Xt.signedDistanceFromCamera>0?H[Re]=Xt.point:Pt()}else et=null;Qe+=at,at=Fe.dist(be)}Q&&J&&(et=et||new s.pointGeometry(F.getx(Re),F.gety(Re)),H[Re]=be=H[Re]===void 0?be:Pt(),at=Fe.dist(be));const Jt=(dt-Qe)/at,pt=be.sub(Fe),qt=pt.mult(Jt)._add(Fe);u&&qt._add(pt._unit()._perp()._mult(u*Te));const mn=Se+Math.atan2(be.y-Fe.y,be.x-Fe.x);return ut.push(qt),re&&(et=et||new s.pointGeometry(F.getx(Re),F.gety(Re)),Rt.push(function(Xt,Yt,vn){const kn=1-vn;return new s.pointGeometry(Xt.x*kn+Yt.x*vn,Xt.y*kn+Yt.y*vn)}(Rt.length>0?Rt[Rt.length-1]:et,et,Jt))),{point:qt,angle:mn,path:ut,tilePath:Rt}}const bd=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Bi(f,r){for(let u=0;u<f;u++){const g=r.length;r.resize(g+4),r.float32.set(bd,3*g)}}function Cr(f,r,u){const g=r[0],x=r[1];return f[0]=u[0]*g+u[4]*x+u[12],f[1]=u[1]*g+u[5]*x+u[13],f[3]=u[3]*g+u[7]*x+u[15],f}const da=100;class au{constructor(r,u,g=new Tn(r.width+200,r.height+200,25),x=new Tn(r.width+200,r.height+200,25)){this.transform=r,this.grid=g,this.ignoredGrid=x,this.pitchfactor=Math.cos(r._pitch)*r.cameraToCenterDistance,this.screenRightBoundary=r.width+da,this.screenBottomBoundary=r.height+da,this.gridRightBoundary=r.width+200,this.gridBottomBoundary=r.height+200,this.fogState=u}placeCollisionBox(r,u,g,x,b,S,P){let z=u.projectedAnchorX,F=u.projectedAnchorY,N=u.projectedAnchorZ;const H=u.elevation,J=u.tileID;if(H&&J){const Re=this.transform.projection.upVector(J.canonical,u.tileAnchorX,u.tileAnchorY),be=this.transform.projection.upVectorScale(J.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;z+=Re[0]*H*be,F+=Re[1]*H*be,N+=Re[2]*H*be}const re=this.projectAndGetPerspectiveRatio(S,[z,F,N],u.tileID,this.transform.projection.name==="globe"||!!H||this.transform.pitch>0),Q=b*re.perspectiveRatio,X=(u.x1*r+g.x-u.padding)*Q+re.point.x,Ae=(u.y1*r+g.y-u.padding)*Q+re.point.y,fe=(u.x2*r+g.x+u.padding)*Q+re.point.x,Te=(u.y2*r+g.y+u.padding)*Q+re.point.y,Se=re.perspectiveRatio<=.55||re.occluded;return!this.isInsideGrid(X,Ae,fe,Te)||!x&&this.grid.hitTest(X,Ae,fe,Te,P)||Se?{box:[],offscreen:!1,occluded:re.occluded}:{box:[X,Ae,fe,Te],offscreen:this.isOffscreen(X,Ae,fe,Te),occluded:!1}}placeCollisionCircles(r,u,g,x,b,S,P,z,F,N,H,J,re,Q){const X=[],Ae=this.transform.elevation,fe=Ae?Ae.getAtTileOffsetFunc(Q,this.transform.center.lat,this.transform.worldSize,this.transform.projection):Pt=>[0,0,0],Te=new s.pointGeometry(u.tileAnchorX,u.tileAnchorY),Se=this.transform.projection.projectTilePoint(u.tileAnchorX,u.tileAnchorY,Q.canonical),Re=fe(Te),be=[Se.x+Re[0],Se.y+Re[1],Se.z+Re[2]],Fe=this.projectAndGetPerspectiveRatio(S,[be[0],be[1],be[2]],Q,this.transform.projection.name==="globe"||!!Ae||this.transform.pitch>0),{perspectiveRatio:Qe}=Fe,at=(N?b/Qe:b*Qe)/s.ONE_EM,dt=ai(new s.pointGeometry(be[0],be[1]),P,be[2]).point,ut=Fe.signedDistanceFromCamera>0?iu(at,x,u.lineOffsetX*at,u.lineOffsetY*at,!1,dt,Te,u,g,P,{},Ae&&!N?fe:null,N&&!!Ae,this.transform.projection,Q):null;let Rt=!1,et=!1,zt=!0;if(ut&&!Fe.occluded){const Pt=.5*J*Qe+re,Jt=new s.pointGeometry(-100,-100),pt=new s.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),qt=new fn,mn=ut.first,Xt=ut.last;let Yt=[];for(let hn=mn.path.length-1;hn>=1;hn--)Yt.push(mn.path[hn]);for(let hn=1;hn<Xt.path.length;hn++)Yt.push(Xt.path[hn]);const vn=2.5*Pt;if(z){const hn=Yt.map(Ae?(Mn,qn)=>{const vi=fe(qn<mn.path.length-1?mn.tilePath[mn.path.length-1-qn]:Xt.tilePath[qn-mn.path.length+2]);return ai(Mn,z,vi[2])}:Mn=>ai(Mn,z));Yt=hn.some(Mn=>Mn.signedDistanceFromCamera<=0)?[]:hn.map(Mn=>Mn.point)}let kn=[];if(Yt.length>0){const hn=Yt[0].clone(),Mn=Yt[0].clone();for(let qn=1;qn<Yt.length;qn++)hn.x=Math.min(hn.x,Yt[qn].x),hn.y=Math.min(hn.y,Yt[qn].y),Mn.x=Math.max(Mn.x,Yt[qn].x),Mn.y=Math.max(Mn.y,Yt[qn].y);kn=hn.x>=Jt.x&&Mn.x<=pt.x&&hn.y>=Jt.y&&Mn.y<=pt.y?[Yt]:Mn.x<Jt.x||hn.x>pt.x||Mn.y<Jt.y||hn.y>pt.y?[]:s.clipLine([Yt],Jt.x,Jt.y,pt.x,pt.y)}for(const hn of kn){qt.reset(hn,.25*Pt);let Mn=0;Mn=qt.length<=.5*Pt?1:Math.ceil(qt.paddedLength/vn)+1;for(let qn=0;qn<Mn;qn++){const vi=qn/Math.max(Mn-1,1),nr=qt.lerp(vi),ir=nr.x+da,Rr=nr.y+da;X.push(ir,Rr,Pt,0);const ma=ir-Pt,Ua=Rr-Pt,po=ir+Pt,Va=Rr+Pt;if(zt=zt&&this.isOffscreen(ma,Ua,po,Va),et=et||this.isInsideGrid(ma,Ua,po,Va),!r&&this.grid.hitTestCircle(ir,Rr,Pt,H)&&(Rt=!0,!F))return{circles:[],offscreen:!1,collisionDetected:Rt,occluded:!1}}}}return{circles:!F&&Rt||!et?[]:X,offscreen:zt,collisionDetected:Rt,occluded:Fe.occluded}}queryRenderedSymbols(r){if(r.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const u=[];let g=1/0,x=1/0,b=-1/0,S=-1/0;for(const N of r){const H=new s.pointGeometry(N.x+da,N.y+da);g=Math.min(g,H.x),x=Math.min(x,H.y),b=Math.max(b,H.x),S=Math.max(S,H.y),u.push(H)}const P=this.grid.query(g,x,b,S).concat(this.ignoredGrid.query(g,x,b,S)),z={},F={};for(const N of P){const H=N.key;if(z[H.bucketInstanceId]===void 0&&(z[H.bucketInstanceId]={}),z[H.bucketInstanceId][H.featureIndex])continue;const J=[new s.pointGeometry(N.x1,N.y1),new s.pointGeometry(N.x2,N.y1),new s.pointGeometry(N.x2,N.y2),new s.pointGeometry(N.x1,N.y2)];s.polygonIntersectsPolygon(u,J)&&(z[H.bucketInstanceId][H.featureIndex]=!0,F[H.bucketInstanceId]===void 0&&(F[H.bucketInstanceId]=[]),F[H.bucketInstanceId].push(H.featureIndex))}return F}insertCollisionBox(r,u,g,x,b){(u?this.ignoredGrid:this.grid).insert({bucketInstanceId:g,featureIndex:x,collisionGroupID:b},r[0],r[1],r[2],r[3])}insertCollisionCircles(r,u,g,x,b){const S=u?this.ignoredGrid:this.grid,P={bucketInstanceId:g,featureIndex:x,collisionGroupID:b};for(let z=0;z<r.length;z+=4)S.insertCircle(P,r[z],r[z+1],r[z+2])}projectAndGetPerspectiveRatio(r,u,g,x){const b=[u[0],u[1],u[2],1];let S=!1;return u[2]||this.transform.pitch>0?(s.transformMat4$1(b,b,r),this.fogState&&g&&(S=function(P,z,F,N,H,J){const re=J.calculateFogTileMatrix(H),Q=[z,F,N];return s.transformMat4(Q,Q,re),gt(P,Q,J.pitch,J._fov)}(this.fogState,u[0],u[1],u[2],g.toUnwrapped(),this.transform)>.9)):Cr(b,b,r),{point:new s.pointGeometry((b[0]/b[3]+1)/2*this.transform.width+da,(-b[1]/b[3]+1)/2*this.transform.height+da),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/b[3]*.5,1.5),signedDistanceFromCamera:b[3],occluded:x&&b[2]>b[3]||S}}isOffscreen(r,u,g,x){return g<da||r>=this.screenRightBoundary||x<da||u>this.screenBottomBoundary}isInsideGrid(r,u,g,x){return g>=0&&r<this.gridRightBoundary&&x>=0&&u<this.gridBottomBoundary}getViewportMatrix(){const r=s.identity([]);return s.translate(r,r,[-100,-100,0]),r}}class Pi{constructor(r,u,g,x){this.opacity=r?Math.max(0,Math.min(1,r.opacity+(r.placed?u:-u))):x&&g?1:0,this.placed=g}isHidden(){return this.opacity===0&&!this.placed}}class ka{constructor(r,u,g,x,b,S=!1){this.text=new Pi(r?r.text:null,u,g,b),this.icon=new Pi(r?r.icon:null,u,x,b),this.clipped=S}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ba{constructor(r,u,g,x=!1){this.text=r,this.icon=u,this.skipFade=g,this.clipped=x}}class Qi{constructor(){this.invProjMatrix=s.create(),this.viewportMatrix=s.create(),this.circles=[]}}class wd{constructor(r,u,g,x,b){this.bucketInstanceId=r,this.featureIndex=u,this.sourceLayerIndex=g,this.bucketIndex=x,this.tileID=b}}class pa{constructor(r){this.crossSourceCollisions=r,this.maxGroupID=0,this.collisionGroups={}}get(r){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[r]){const u=++this.maxGroupID;this.collisionGroups[r]={ID:u,predicate:g=>g.collisionGroupID===u}}return this.collisionGroups[r]}}function bs(f,r,u,g,x){const{horizontalAlign:b,verticalAlign:S}=s.getAnchorAlignment(f),P=-(b-.5)*r,z=-(S-.5)*u,F=s.evaluateVariableOffset(f,g);return new s.pointGeometry(P+F[0]*x,z+F[1]*x)}function ws(f,r,u,g,x){const b=new s.pointGeometry(f,r);return u&&b._rotate(g?x:-x),b}class Dy{constructor(r,u,g,x,b){this.transform=r.clone(),this.collisionIndex=new au(this.transform,b),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=u,this.retainedQueryData={},this.collisionGroups=new pa(g),this.collisionCircleArrays={},this.prevPlacement=x,x&&(x.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,u,g,x){const b=g.getBucket(u),S=g.latestFeatureIndex;if(!b||!S||u.id!==b.layerIds[0])return;const P=b.layers[0].layout,z=g.collisionBoxArray,F=Math.pow(2,this.transform.zoom-g.tileID.overscaledZ),N=g.tileSize/s.EXTENT,H=g.tileID.toUnwrapped(),J=this.transform.calculateProjMatrix(H),re=P.get("text-pitch-alignment")==="map",Q=P.get("text-rotation-alignment")==="map";u.compileFilter();const X=u.dynamicFilter(),Ae=u.dynamicFilterNeedsFeature(),fe=this.transform.calculatePixelsToTileUnitsMatrix(g),Te=di(J,g.tileID.canonical,re,Q,this.transform,fe);let Se=null;if(re){const Fe=Ar(J,g.tileID.canonical,re,Q,this.transform,fe);Se=s.multiply$1([],this.transform.labelPlaneMatrix,Fe)}let Re=null;X&&g.latestFeatureIndex&&(Re={unwrappedTileID:H,dynamicFilter:X,dynamicFilterNeedsFeature:Ae,featureIndex:g.latestFeatureIndex}),this.retainedQueryData[b.bucketInstanceId]=new wd(b.bucketInstanceId,S,b.sourceLayerIndex,b.index,g.tileID);const be={bucket:b,layout:P,posMatrix:J,textLabelPlaneMatrix:Te,labelToScreenMatrix:Se,clippingData:Re,scale:F,textPixelRatio:N,holdingForFade:g.holdingForFade(),collisionBoxArray:z,partiallyEvaluatedTextSize:s.evaluateSizeForZoom(b.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:s.evaluateSizeForZoom(b.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(b.sourceID)};if(x)for(const Fe of b.sortKeyRanges){const{sortKey:Qe,symbolInstanceStart:at,symbolInstanceEnd:dt}=Fe;r.push({sortKey:Qe,symbolInstanceStart:at,symbolInstanceEnd:dt,parameters:be})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:b.symbolInstances.length,parameters:be})}attemptAnchorPlacement(r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae,fe,Te){const Se=[J.textOffset0,J.textOffset1],Re=bs(r,g,x,Se,b),be=this.collisionIndex.placeCollisionBox(b,u,ws(Re.x,Re.y,S,P,this.transform.angle),H,z,F,N.predicate);if((!Ae||this.collisionIndex.placeCollisionBox(Q.getSymbolInstanceIconSize(Te,this.transform.zoom,re),Ae,ws(Re.x,Re.y,S,P,this.transform.angle),H,z,F,N.predicate).box.length!==0)&&be.box.length>0){let Fe;return this.prevPlacement&&this.prevPlacement.variableOffsets[J.crossTileID]&&this.prevPlacement.placements[J.crossTileID]&&this.prevPlacement.placements[J.crossTileID].text&&(Fe=this.prevPlacement.variableOffsets[J.crossTileID].anchor),this.variableOffsets[J.crossTileID]={textOffset:Se,width:g,height:x,anchor:r,textScale:b,prevAnchor:Fe},this.markUsedJustification(Q,r,J,X),Q.allowVerticalPlacement&&(this.markUsedOrientation(Q,X,J),this.placedOrientations[J.crossTileID]=X),{shift:Re,placedGlyphBoxes:be}}}placeLayerBucketPart(r,u,g,x){const{bucket:b,layout:S,posMatrix:P,textLabelPlaneMatrix:z,labelToScreenMatrix:F,clippingData:N,textPixelRatio:H,holdingForFade:J,collisionBoxArray:re,partiallyEvaluatedTextSize:Q,partiallyEvaluatedIconSize:X,collisionGroup:Ae}=r.parameters,fe=S.get("text-optional"),Te=S.get("icon-optional"),Se=S.get("text-allow-overlap"),Re=S.get("icon-allow-overlap"),be=S.get("text-rotation-alignment")==="map",Fe=S.get("text-pitch-alignment")==="map",Qe=S.get("icon-text-fit")!=="none",at=S.get("symbol-z-order")==="viewport-y";let dt=Se&&(Re||!b.hasIconData()||Te),ut=Re&&(Se||!b.hasTextData()||fe);!b.collisionArrays&&re&&b.deserializeCollisionBoxes(re),g&&x&&b.updateCollisionDebugBuffers(this.transform.zoom,re);const Rt=(et,zt,Pt)=>{if(N){const bi={zoom:this.transform.zoom,pitch:this.transform.pitch};let Ti=null;if(N.dynamicFilterNeedsFeature){const $n=this.retainedQueryData[b.bucketInstanceId];Ti=N.featureIndex.loadFeature({featureIndex:et.featureIndex,bucketIndex:$n.bucketIndex,sourceLayerIndex:$n.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,N.dynamicFilter)(bi,Ti,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new s.pointGeometry(et.tileAnchorX,et.tileAnchorY),this.transform.calculateDistanceTileData(N.unwrappedTileID)))return this.placements[et.crossTileID]=new Ba(!1,!1,!1,!0),void(u[et.crossTileID]=!0)}if(u[et.crossTileID])return;if(J)return void(this.placements[et.crossTileID]=new Ba(!1,!1,!1));let Jt=!1,pt=!1,qt=!0,mn=!1,Xt=!1,Yt=null,vn={box:null,offscreen:null,occluded:null},kn={box:null,offscreen:null,occluded:null},hn=null,Mn=null,qn=null,vi=0,nr=0,ir=0;Pt.textFeatureIndex?vi=Pt.textFeatureIndex:et.useRuntimeCollisionCircles&&(vi=et.featureIndex),Pt.verticalTextFeatureIndex&&(nr=Pt.verticalTextFeatureIndex);const Rr=bi=>{bi.tileID=this.retainedQueryData[b.bucketInstanceId].tileID,(this.transform.elevation||bi.elevation)&&(bi.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[b.bucketInstanceId].tileID,bi.tileAnchorX,bi.tileAnchorY):0)},ma=Pt.textBox;if(ma){Rr(ma);const bi=$n=>{let Li=s.WritingMode.horizontal;if(b.allowVerticalPlacement&&!$n&&this.prevPlacement){const zr=this.prevPlacement.placedOrientations[et.crossTileID];zr&&(this.placedOrientations[et.crossTileID]=zr,Li=zr,this.markUsedOrientation(b,Li,et))}return Li},Ti=($n,Li)=>{if(b.allowVerticalPlacement&&et.numVerticalGlyphVertices>0&&Pt.verticalTextBox){for(const zr of b.writingModes)if(zr===s.WritingMode.vertical?(vn=Li(),kn=vn):vn=$n(),vn&&vn.box&&vn.box.length)break}else vn=$n()};if(S.get("text-variable-anchor")){let $n=S.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[et.crossTileID]){const xi=this.prevPlacement.variableOffsets[et.crossTileID];$n.indexOf(xi.anchor)>0&&($n=$n.filter(Zr=>Zr!==xi.anchor),$n.unshift(xi.anchor))}const Li=(xi,Zr,Gl)=>{const kr=b.getSymbolInstanceTextSize(Q,et,this.transform.zoom,zt),jo=(xi.x2-xi.x1)*kr+2*xi.padding,lg=(xi.y2-xi.y1)*kr+2*xi.padding,ap=Qe&&!Re?Zr:null;ap&&Rr(ap);let Rs={box:[],offscreen:!1,occluded:!1};const Xy=Se?2*$n.length:$n.length;for(let fo=0;fo<Xy;++fo){const op=this.attemptAnchorPlacement($n[fo%$n.length],xi,jo,lg,kr,be,Fe,H,P,Ae,fo>=$n.length,et,zt,b,Gl,ap,Q,X);if(op&&(Rs=op.placedGlyphBoxes,Rs&&Rs.box&&Rs.box.length)){Jt=!0,Yt=op.shift;break}}return Rs};Ti(()=>Li(ma,Pt.iconBox,s.WritingMode.horizontal),()=>{const xi=Pt.verticalTextBox;return xi&&Rr(xi),b.allowVerticalPlacement&&!(vn&&vn.box&&vn.box.length)&&et.numVerticalGlyphVertices>0&&xi?Li(xi,Pt.verticalIconBox,s.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),vn&&(Jt=vn.box,qt=vn.offscreen,mn=vn.occluded);const zr=bi(vn&&vn.box);if(!Jt&&this.prevPlacement){const xi=this.prevPlacement.variableOffsets[et.crossTileID];xi&&(this.variableOffsets[et.crossTileID]=xi,this.markUsedJustification(b,xi.anchor,et,zr))}}else{const $n=(Li,zr)=>{const xi=b.getSymbolInstanceTextSize(Q,et,this.transform.zoom,zt),Zr=this.collisionIndex.placeCollisionBox(xi,Li,new s.pointGeometry(0,0),Se,H,P,Ae.predicate);return Zr&&Zr.box&&Zr.box.length&&(this.markUsedOrientation(b,zr,et),this.placedOrientations[et.crossTileID]=zr),Zr};Ti(()=>$n(ma,s.WritingMode.horizontal),()=>{const Li=Pt.verticalTextBox;return b.allowVerticalPlacement&&et.numVerticalGlyphVertices>0&&Li?(Rr(Li),$n(Li,s.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),bi(vn&&vn.box&&vn.box.length)}}if(hn=vn,Jt=hn&&hn.box&&hn.box.length>0,qt=hn&&hn.offscreen,mn=hn&&hn.occluded,et.useRuntimeCollisionCircles){const bi=b.text.placedSymbolArray.get(et.centerJustifiedTextSymbolIndex>=0?et.centerJustifiedTextSymbolIndex:et.verticalPlacedTextSymbolIndex),Ti=s.evaluateSizeForFeature(b.textSizeData,Q,bi),$n=S.get("text-padding");Mn=this.collisionIndex.placeCollisionCircles(Se,bi,b.lineVertexArray,b.glyphOffsetArray,Ti,P,z,F,g,Fe,Ae.predicate,et.collisionCircleDiameter*Ti/s.ONE_EM,$n,this.retainedQueryData[b.bucketInstanceId].tileID),Jt=Se||Mn.circles.length>0&&!Mn.collisionDetected,qt=qt&&Mn.offscreen,mn=Mn.occluded}if(Pt.iconFeatureIndex&&(ir=Pt.iconFeatureIndex),Pt.iconBox){const bi=Ti=>{Rr(Ti);const $n=Qe&&Yt?ws(Yt.x,Yt.y,be,Fe,this.transform.angle):new s.pointGeometry(0,0),Li=b.getSymbolInstanceIconSize(X,this.transform.zoom,zt);return this.collisionIndex.placeCollisionBox(Li,Ti,$n,Re,H,P,Ae.predicate)};kn&&kn.box&&kn.box.length&&Pt.verticalIconBox?(qn=bi(Pt.verticalIconBox),pt=qn.box.length>0):(qn=bi(Pt.iconBox),pt=qn.box.length>0),qt=qt&&qn.offscreen,Xt=qn.occluded}const Ua=fe||et.numHorizontalGlyphVertices===0&&et.numVerticalGlyphVertices===0,po=Te||et.numIconVertices===0;if(Ua||po?po?Ua||(pt=pt&&Jt):Jt=pt&&Jt:pt=Jt=pt&&Jt,Jt&&hn&&hn.box&&this.collisionIndex.insertCollisionBox(hn.box,S.get("text-ignore-placement"),b.bucketInstanceId,kn&&kn.box&&nr?nr:vi,Ae.ID),pt&&qn&&this.collisionIndex.insertCollisionBox(qn.box,S.get("icon-ignore-placement"),b.bucketInstanceId,ir,Ae.ID),Mn&&(Jt&&this.collisionIndex.insertCollisionCircles(Mn.circles,S.get("text-ignore-placement"),b.bucketInstanceId,vi,Ae.ID),g)){const bi=b.bucketInstanceId;let Ti=this.collisionCircleArrays[bi];Ti===void 0&&(Ti=this.collisionCircleArrays[bi]=new Qi);for(let $n=0;$n<Mn.circles.length;$n+=4)Ti.circles.push(Mn.circles[$n+0]),Ti.circles.push(Mn.circles[$n+1]),Ti.circles.push(Mn.circles[$n+2]),Ti.circles.push(Mn.collisionDetected?1:0)}const Va=this.transform.projection.name!=="globe";dt=dt&&(Va||!mn),ut=ut&&(Va||!Xt),this.placements[et.crossTileID]=new Ba(Jt||dt,pt||ut,qt||b.justReloaded),u[et.crossTileID]=!0};if(at){const et=b.getSortedSymbolIndexes(this.transform.angle);for(let zt=et.length-1;zt>=0;--zt){const Pt=et[zt];Rt(b.symbolInstances.get(Pt),Pt,b.collisionArrays[Pt])}}else for(let et=r.symbolInstanceStart;et<r.symbolInstanceEnd;et++)Rt(b.symbolInstances.get(et),et,b.collisionArrays[et]);if(g&&b.bucketInstanceId in this.collisionCircleArrays){const et=this.collisionCircleArrays[b.bucketInstanceId];s.invert(et.invProjMatrix,P),et.viewportMatrix=this.collisionIndex.getViewportMatrix()}b.justReloaded=!1}markUsedJustification(r,u,g,x){let b;b=x===s.WritingMode.vertical?g.verticalPlacedTextSymbolIndex:{left:g.leftJustifiedTextSymbolIndex,center:g.centerJustifiedTextSymbolIndex,right:g.rightJustifiedTextSymbolIndex}[s.getAnchorJustification(u)];const S=[g.leftJustifiedTextSymbolIndex,g.centerJustifiedTextSymbolIndex,g.rightJustifiedTextSymbolIndex,g.verticalPlacedTextSymbolIndex];for(const P of S)P>=0&&(r.text.placedSymbolArray.get(P).crossTileID=b>=0&&P!==b?0:g.crossTileID)}markUsedOrientation(r,u,g){const x=u===s.WritingMode.horizontal||u===s.WritingMode.horizontalOnly?u:0,b=u===s.WritingMode.vertical?u:0,S=[g.leftJustifiedTextSymbolIndex,g.centerJustifiedTextSymbolIndex,g.rightJustifiedTextSymbolIndex];for(const P of S)r.text.placedSymbolArray.get(P).placedOrientation=x;g.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(g.verticalPlacedTextSymbolIndex).placedOrientation=b)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const u=this.prevPlacement;let g=!1;this.prevZoomAdjustment=u?u.zoomAdjustment(this.transform.zoom):0;const x=u?u.symbolFadeChange(r):1,b=u?u.opacities:{},S=u?u.variableOffsets:{},P=u?u.placedOrientations:{};for(const z in this.placements){const F=this.placements[z],N=b[z];N?(this.opacities[z]=new ka(N,x,F.text,F.icon,null,F.clipped),g=g||F.text!==N.text.placed||F.icon!==N.icon.placed):(this.opacities[z]=new ka(null,x,F.text,F.icon,F.skipFade,F.clipped),g=g||F.text||F.icon)}for(const z in b){const F=b[z];if(!this.opacities[z]){const N=new ka(F,x,!1,!1);N.isHidden()||(this.opacities[z]=N,g=g||F.text.placed||F.icon.placed)}}for(const z in S)this.variableOffsets[z]||!this.opacities[z]||this.opacities[z].isHidden()||(this.variableOffsets[z]=S[z]);for(const z in P)this.placedOrientations[z]||!this.opacities[z]||this.opacities[z].isHidden()||(this.placedOrientations[z]=P[z]);g?this.lastPlacementChangeTime=r:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=u?u.lastPlacementChangeTime:r)}updateLayerOpacities(r,u){const g={};for(const x of u){const b=x.getBucket(r);b&&x.latestFeatureIndex&&r.id===b.layerIds[0]&&this.updateBucketOpacities(b,g,x.collisionBoxArray)}}updateBucketOpacities(r,u,g){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const x=r.layers[0].layout,b=!!r.layers[0].dynamicFilter(),S=new ka(null,0,!1,!1,!0),P=x.get("text-allow-overlap"),z=x.get("icon-allow-overlap"),F=x.get("text-variable-anchor"),N=x.get("text-rotation-alignment")==="map",H=x.get("text-pitch-alignment")==="map",J=x.get("icon-text-fit")!=="none",re=new ka(null,0,P&&(z||!r.hasIconData()||x.get("icon-optional")),z&&(P||!r.hasTextData()||x.get("text-optional")),!0);!r.collisionArrays&&g&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(g);const Q=(Ae,fe,Te)=>{for(let Se=0;Se<fe/4;Se++)Ae.opacityVertexArray.emplaceBack(Te)};let X=0;for(let Ae=0;Ae<r.symbolInstances.length;Ae++){const fe=r.symbolInstances.get(Ae),{numHorizontalGlyphVertices:Te,numVerticalGlyphVertices:Se,crossTileID:Re}=fe;let be=this.opacities[Re];u[Re]?be=S:be||(be=re,this.opacities[Re]=be),u[Re]=!0;const Fe=Te>0||Se>0,Qe=fe.numIconVertices>0,at=this.placedOrientations[fe.crossTileID],dt=at===s.WritingMode.vertical,ut=at===s.WritingMode.horizontal||at===s.WritingMode.horizontalOnly;if(!Fe&&!Qe||be.isHidden()||X++,Fe){const Rt=_m(be.text);Q(r.text,Te,dt?lu:Rt),Q(r.text,Se,ut?lu:Rt);const et=be.text.isHidden();[fe.rightJustifiedTextSymbolIndex,fe.centerJustifiedTextSymbolIndex,fe.leftJustifiedTextSymbolIndex].forEach(Jt=>{Jt>=0&&(r.text.placedSymbolArray.get(Jt).hidden=et||dt?1:0)}),fe.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(fe.verticalPlacedTextSymbolIndex).hidden=et||ut?1:0);const zt=this.variableOffsets[fe.crossTileID];zt&&this.markUsedJustification(r,zt.anchor,fe,at);const Pt=this.placedOrientations[fe.crossTileID];Pt&&(this.markUsedJustification(r,"left",fe,Pt),this.markUsedOrientation(r,Pt,fe))}if(Qe){const Rt=_m(be.icon);fe.placedIconSymbolIndex>=0&&(Q(r.icon,fe.numIconVertices,dt?lu:Rt),r.icon.placedSymbolArray.get(fe.placedIconSymbolIndex).hidden=be.icon.isHidden()),fe.verticalPlacedIconSymbolIndex>=0&&(Q(r.icon,fe.numVerticalIconVertices,ut?lu:Rt),r.icon.placedSymbolArray.get(fe.verticalPlacedIconSymbolIndex).hidden=be.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const Rt=r.collisionArrays[Ae];if(Rt){let et=new s.pointGeometry(0,0),zt=!0;if(Rt.textBox||Rt.verticalTextBox){if(F){const Jt=this.variableOffsets[Re];Jt?(et=bs(Jt.anchor,Jt.width,Jt.height,Jt.textOffset,Jt.textScale),N&&et._rotate(H?this.transform.angle:-this.transform.angle)):zt=!1}b&&(zt=!be.clipped),Rt.textBox&&fa(r.textCollisionBox.collisionVertexArray,be.text.placed,!zt||dt,et.x,et.y),Rt.verticalTextBox&&fa(r.textCollisionBox.collisionVertexArray,be.text.placed,!zt||ut,et.x,et.y)}const Pt=zt&&!!(!ut&&Rt.verticalIconBox);Rt.iconBox&&fa(r.iconCollisionBox.collisionVertexArray,be.icon.placed,Pt,J?et.x:0,J?et.y:0),Rt.verticalIconBox&&fa(r.iconCollisionBox.collisionVertexArray,be.icon.placed,!Pt,J?et.x:0,J?et.y:0)}}}if(r.fullyClipped=X===0,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const Ae=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=Ae.invProjMatrix,r.placementViewportMatrix=Ae.viewportMatrix,r.collisionCircleArray=Ae.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return this.fadeDuration===0?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return this.stale||r-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(r,u){const g=this.zoomAtLastRecencyCheck===u?1-this.zoomAdjustment(u):1;return this.zoomAtLastRecencyCheck=u,this.commitTime+this.fadeDuration*g>r}setStale(){this.stale=!0}}function fa(f,r,u,g,x){f.emplaceBack(r?1:0,u?1:0,g||0,x||0),f.emplaceBack(r?1:0,u?1:0,g||0,x||0),f.emplaceBack(r?1:0,u?1:0,g||0,x||0),f.emplaceBack(r?1:0,u?1:0,g||0,x||0)}const Iy=Math.pow(2,25),gm=Math.pow(2,24),Pr=Math.pow(2,17),ou=Math.pow(2,16),io=Math.pow(2,9),Md=Math.pow(2,8),su=Math.pow(2,1);function _m(f){if(f.opacity===0&&!f.placed)return 0;if(f.opacity===1&&f.placed)return 4294967295;const r=f.placed?1:0,u=Math.floor(127*f.opacity);return u*Iy+r*gm+u*Pr+r*ou+u*io+r*Md+u*su+r}const lu=0;class Td{constructor(r){this._sortAcrossTiles=r.layout.get("symbol-z-order")!=="viewport-y"&&r.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(r,u,g,x,b){const S=this._bucketParts;for(;this._currentTileIndex<r.length;)if(u.getBucketParts(S,x,r[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,b())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,S.sort((P,z)=>P.sortKey-z.sortKey));this._currentPartIndex<S.length;){const P=S[this._currentPartIndex];if(u.placeLayerBucketPart(P,this._seenCrossTileIDs,g,P.symbolInstanceStart===0),this._currentPartIndex++,b())return!0}return!1}}class Ry{constructor(r,u,g,x,b,S,P,z){this.placement=new Dy(r,b,S,P,z),this._currentPlacementIndex=u.length-1,this._forceFullPlacement=g,this._showCollisionBoxes=x,this._done=!1}isDone(){return this._done}continuePlacement(r,u,g){const x=s.exported.now(),b=()=>{const S=s.exported.now()-x;return!this._forceFullPlacement&&S>2};for(;this._currentPlacementIndex>=0;){const S=u[r[this._currentPlacementIndex]],P=this.placement.collisionIndex.transform.zoom;if(S.type==="symbol"&&(!S.minzoom||S.minzoom<=P)&&(!S.maxzoom||S.maxzoom>P)){if(this._inProgressLayer||(this._inProgressLayer=new Td(S)),this._inProgressLayer.continuePlacement(g[S.source],this.placement,this._showCollisionBoxes,S,b))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(r){return this.placement.commit(r),this.placement}}const ym=512/s.EXTENT/2;class zy{constructor(r,u,g){this.tileID=r,this.indexedSymbolInstances={},this.bucketInstanceId=g;for(let x=0;x<u.length;x++){const b=u.get(x),S=b.key;this.indexedSymbolInstances[S]||(this.indexedSymbolInstances[S]=[]),this.indexedSymbolInstances[S].push({crossTileID:b.crossTileID,coord:this.getScaledCoordinates(b,r)})}}getScaledCoordinates(r,u){const g=ym/Math.pow(2,u.canonical.z-this.tileID.canonical.z);return{x:Math.floor((u.canonical.x*s.EXTENT+r.tileAnchorX)*g),y:Math.floor((u.canonical.y*s.EXTENT+r.tileAnchorY)*g)}}findMatches(r,u,g){const x=this.tileID.canonical.z<u.canonical.z?1:Math.pow(2,this.tileID.canonical.z-u.canonical.z);for(let b=0;b<r.length;b++){const S=r.get(b);if(S.crossTileID)continue;const P=this.indexedSymbolInstances[S.key];if(!P)continue;const z=this.getScaledCoordinates(S,u);for(const F of P)if(Math.abs(F.coord.x-z.x)<=x&&Math.abs(F.coord.y-z.y)<=x&&!g[F.crossTileID]){g[F.crossTileID]=!0,S.crossTileID=F.crossTileID;break}}}}class vm{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ky{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(r){const u=Math.round((r-this.lng)/360);if(u!==0)for(const g in this.indexes){const x=this.indexes[g],b={};for(const S in x){const P=x[S];P.tileID=P.tileID.unwrapTo(P.tileID.wrap+u),b[P.tileID.key]=P}this.indexes[g]=b}this.lng=r}addBucket(r,u,g){if(this.indexes[r.overscaledZ]&&this.indexes[r.overscaledZ][r.key]){if(this.indexes[r.overscaledZ][r.key].bucketInstanceId===u.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(r.overscaledZ,this.indexes[r.overscaledZ][r.key])}for(let b=0;b<u.symbolInstances.length;b++)u.symbolInstances.get(b).crossTileID=0;this.usedCrossTileIDs[r.overscaledZ]||(this.usedCrossTileIDs[r.overscaledZ]={});const x=this.usedCrossTileIDs[r.overscaledZ];for(const b in this.indexes){const S=this.indexes[b];if(Number(b)>r.overscaledZ)for(const P in S){const z=S[P];z.tileID.isChildOf(r)&&z.findMatches(u.symbolInstances,r,x)}else{const P=S[r.scaledTo(Number(b)).key];P&&P.findMatches(u.symbolInstances,r,x)}}for(let b=0;b<u.symbolInstances.length;b++){const S=u.symbolInstances.get(b);S.crossTileID||(S.crossTileID=g.generate(),x[S.crossTileID]=!0)}return this.indexes[r.overscaledZ]===void 0&&(this.indexes[r.overscaledZ]={}),this.indexes[r.overscaledZ][r.key]=new zy(r,u.symbolInstances,u.bucketInstanceId),!0}removeBucketCrossTileIDs(r,u){for(const g in u.indexedSymbolInstances)for(const x of u.indexedSymbolInstances[g])delete this.usedCrossTileIDs[r][x.crossTileID]}removeStaleBuckets(r){let u=!1;for(const g in this.indexes){const x=this.indexes[g];for(const b in x)r[x[b].bucketInstanceId]||(this.removeBucketCrossTileIDs(g,x[b]),delete x[b],u=!0)}return u}}class cu{constructor(){this.layerIndexes={},this.crossTileIDs=new vm,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(r,u,g,x){let b=this.layerIndexes[r.id];b===void 0&&(b=this.layerIndexes[r.id]=new ky);let S=!1;const P={};x.name!=="globe"&&b.handleWrapJump(g);for(const z of u){const F=z.getBucket(r);F&&r.id===F.layerIds[0]&&(F.bucketInstanceId||(F.bucketInstanceId=++this.maxBucketInstanceId),b.addBucket(z.tileID,F,this.crossTileIDs)&&(S=!0),P[F.bucketInstanceId]=!0)}return b.removeStaleBuckets(P)&&(S=!0),S}pruneUnusedLayers(r){const u={};r.forEach(g=>{u[g]=!0});for(const g in this.layerIndexes)u[g]||delete this.layerIndexes[g]}}const _l=(f,r)=>s.emitValidationErrors(f,r&&r.filter(u=>u.identifier!=="source.canvas")),xm=s.pick(_t,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),bm=s.pick(_t,["setCenter","setZoom","setBearing","setPitch"]),wm={version:8,layers:[],sources:{}},No={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class gr extends s.Evented{constructor(r,u={}){super(),this.map=r,this.dispatcher=new ge(ze(),this),this.imageManager=new ye,this.imageManager.setEventedParent(this),this.glyphManager=new s.GlyphManager(r._requestManager,u.localFontFamily?s.LocalGlyphMode.all:u.localIdeographFontFamily?s.LocalGlyphMode.ideographs:s.LocalGlyphMode.none,u.localFontFamily||u.localIdeographFontFamily),this.lineAtlas=new s.LineAtlas(256,512),this.crossTileSymbolIndex=new cu,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new s.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",s.getReferrer());const g=this;this._rtlTextPluginCallback=gr.registerForPluginStateChange(x=>{g.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:x.pluginStatus,pluginURL:x.pluginURL},(b,S)=>{if(s.triggerPluginCompletionEvent(b),S&&S.every(P=>P))for(const P in g._sourceCaches){const z=g._sourceCaches[P],F=z.getSource().type;F!=="vector"&&F!=="geojson"||z.reload()}})}),this.on("data",x=>{if(x.dataType!=="source"||x.sourceDataType!=="metadata")return;const b=this.getSource(x.sourceId);if(b&&b.vectorLayerIds)for(const S in this._layers){const P=this._layers[S];P.source===b.id&&this._validateLayer(P)}})}loadURL(r,u={}){this.fire(new s.Event("dataloading",{dataType:"style"}));const g=typeof u.validate=="boolean"?u.validate:!s.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,u.accessToken);const x=this.map._requestManager.transformRequest(r,s.ResourceType.Style);this._request=s.getJSON(x,(b,S)=>{this._request=null,b?this.fire(new s.ErrorEvent(b)):S&&this._load(S,g)})}loadJSON(r,u={}){this.fire(new s.Event("dataloading",{dataType:"style"})),this._request=s.exported.frame(()=>{this._request=null,this._load(r,u.validate!==!1)})}loadEmpty(){this.fire(new s.Event("dataloading",{dataType:"style"})),this._load(wm,!1)}_updateLayerCount(r,u){const g=u?1:-1;r.is3D()&&(this._num3DLayers+=g),r.type==="circle"&&(this._numCircleLayers+=g),r.type==="symbol"&&(this._numSymbolLayers+=g)}_load(r,u){if(u&&_l(this,s.validateStyle(r)))return;this._loaded=!0,this.stylesheet=r,this._updateMapProjection();for(const x in r.sources)this.addSource(x,r.sources[x],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const g=Mt(this.stylesheet.layers);this._order=g.map(x=>x.id),this._layers={},this._serializedLayers={};for(let x of g)x=s.createStyleLayer(x),x.setEventedParent(this,{layer:{id:x.id}}),this._layers[x.id]=x,this._serializedLayers[x.id]=x.serialize(),this._updateLayerCount(x,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Oe(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new s.Event("data",{dataType:"style"})),this.fire(new s.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(r){r?this.stylesheet.projection=r:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(r){this._spriteRequest=function(u,g,x){let b,S,P;const z=s.exported.devicePixelRatio>1?"@2x":"";let F=s.getJSON(g.transformRequest(g.normalizeSpriteURL(u,z,".json"),s.ResourceType.SpriteJSON),(J,re)=>{F=null,P||(P=J,b=re,H())}),N=s.getImage(g.transformRequest(g.normalizeSpriteURL(u,z,".png"),s.ResourceType.SpriteImage),(J,re)=>{N=null,P||(P=J,S=re,H())});function H(){if(P)x(P);else if(b&&S){const J=s.exported.getImageData(S),re={};for(const Q in b){const{width:X,height:Ae,x:fe,y:Te,sdf:Se,pixelRatio:Re,stretchX:be,stretchY:Fe,content:Qe}=b[Q],at=new s.RGBAImage({width:X,height:Ae});s.RGBAImage.copy(J,at,{x:fe,y:Te},{x:0,y:0},{width:X,height:Ae}),re[Q]={data:at,pixelRatio:Re,sdf:Se,stretchX:be,stretchY:Fe,content:Qe}}x(null,re)}}return{cancel(){F&&(F.cancel(),F=null),N&&(N.cancel(),N=null)}}}(r,this.map._requestManager,(u,g)=>{if(this._spriteRequest=null,u)this.fire(new s.ErrorEvent(u));else if(g)for(const x in g)this.imageManager.addImage(x,g[x]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new s.Event("data",{dataType:"style"}))})}_validateLayer(r){const u=this.getSource(r.source);if(!u)return;const g=r.sourceLayer;g&&(u.type==="geojson"||u.vectorLayerIds&&u.vectorLayerIds.indexOf(g)===-1)&&this.fire(new s.ErrorEvent(new Error(`Source layer "${g}" does not exist on source "${u.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const r in this._sourceCaches)if(!this._sourceCaches[r].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(r){const u=[];for(const g of r){const x=this._layers[g];x.type!=="custom"&&u.push(x.serialize())}return u}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const r in this._sourceCaches)if(this._sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(r){return!!this.terrain&&No[r.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(r){if(!this._loaded)return;const u=this._changed;if(this._changed){const x=Object.keys(this._updatedLayers),b=Object.keys(this._removedLayers);(x.length||b.length)&&this._updateWorkerLayers(x,b);for(const S in this._updatedSources){const P=this._updatedSources[S];P==="reload"?this._reloadSource(S):P==="clear"&&this._clearSource(S)}this._updateTilesForChangedImages();for(const S in this._updatedPaintProps)this._layers[S].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const g={};for(const x in this._sourceCaches){const b=this._sourceCaches[x];g[x]=b.used,b.used=!1}for(const x of this._order){const b=this._layers[x];if(b.recalculate(r,this._availableImages),!b.isHidden(r.zoom)){const P=this._getLayerSourceCache(b);P&&(P.used=!0)}const S=this.map.painter;if(S){const P=b.getProgramIds();if(!P)continue;const z=b.getProgramConfiguration(r.zoom);for(const F of P)S.useProgram(F,z)}}for(const x in g){const b=this._sourceCaches[x];g[x]!==b.used&&b.getSource().fire(new s.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),u&&this.fire(new s.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const r=Object.keys(this._changedImages);if(r.length){for(const u in this._sourceCaches)this._sourceCaches[u].reloadTilesForDependencies(["icons","patterns"],r);this._changedImages={}}}_updateWorkerLayers(r,u){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(r),removedIds:u})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),_l(this,s.validateStyle(r)))return!1;(r=s.clone$1(r)).layers=Mt(r.layers);const u=function(x,b){if(!x)return[{command:_t.setStyle,args:[b]}];let S=[];try{if(!E(x.version,b.version))return[{command:_t.setStyle,args:[b]}];E(x.center,b.center)||S.push({command:_t.setCenter,args:[b.center]}),E(x.zoom,b.zoom)||S.push({command:_t.setZoom,args:[b.zoom]}),E(x.bearing,b.bearing)||S.push({command:_t.setBearing,args:[b.bearing]}),E(x.pitch,b.pitch)||S.push({command:_t.setPitch,args:[b.pitch]}),E(x.sprite,b.sprite)||S.push({command:_t.setSprite,args:[b.sprite]}),E(x.glyphs,b.glyphs)||S.push({command:_t.setGlyphs,args:[b.glyphs]}),E(x.transition,b.transition)||S.push({command:_t.setTransition,args:[b.transition]}),E(x.light,b.light)||S.push({command:_t.setLight,args:[b.light]}),E(x.fog,b.fog)||S.push({command:_t.setFog,args:[b.fog]}),E(x.projection,b.projection)||S.push({command:_t.setProjection,args:[b.projection]});const P={},z=[];(function(H,J,re,Q){let X;for(X in J=J||{},H=H||{})H.hasOwnProperty(X)&&(J.hasOwnProperty(X)||nn(X,re,Q));for(X in J)J.hasOwnProperty(X)&&(H.hasOwnProperty(X)?E(H[X],J[X])||(H[X].type==="geojson"&&J[X].type==="geojson"&&Dn(H,J,X)?re.push({command:_t.setGeoJSONSourceData,args:[X,J[X].data]}):Ln(X,J,re,Q)):Ft(X,J,re))})(x.sources,b.sources,z,P);const F=[];x.layers&&x.layers.forEach(H=>{H.source&&P[H.source]?S.push({command:_t.removeLayer,args:[H.id]}):F.push(H)});let N=x.terrain;N&&P[N.source]&&(S.push({command:_t.setTerrain,args:[void 0]}),N=void 0),S=S.concat(z),E(N,b.terrain)||S.push({command:_t.setTerrain,args:[b.terrain]}),function(H,J,re){J=J||[];const Q=(H=H||[]).map(cn),X=J.map(cn),Ae=H.reduce($t,{}),fe=J.reduce($t,{}),Te=Q.slice(),Se=Object.create(null);let Re,be,Fe,Qe,at,dt,ut;for(Re=0,be=0;Re<Q.length;Re++)Fe=Q[Re],fe.hasOwnProperty(Fe)?be++:(re.push({command:_t.removeLayer,args:[Fe]}),Te.splice(Te.indexOf(Fe,be),1));for(Re=0,be=0;Re<X.length;Re++)Fe=X[X.length-1-Re],Te[Te.length-1-Re]!==Fe&&(Ae.hasOwnProperty(Fe)?(re.push({command:_t.removeLayer,args:[Fe]}),Te.splice(Te.lastIndexOf(Fe,Te.length-be),1)):be++,dt=Te[Te.length-Re],re.push({command:_t.addLayer,args:[fe[Fe],dt]}),Te.splice(Te.length-Re,0,Fe),Se[Fe]=!0);for(Re=0;Re<X.length;Re++)if(Fe=X[Re],Qe=Ae[Fe],at=fe[Fe],!Se[Fe]&&!E(Qe,at))if(E(Qe.source,at.source)&&E(Qe["source-layer"],at["source-layer"])&&E(Qe.type,at.type)){for(ut in wt(Qe.layout,at.layout,re,Fe,null,_t.setLayoutProperty),wt(Qe.paint,at.paint,re,Fe,null,_t.setPaintProperty),E(Qe.filter,at.filter)||re.push({command:_t.setFilter,args:[Fe,at.filter]}),E(Qe.minzoom,at.minzoom)&&E(Qe.maxzoom,at.maxzoom)||re.push({command:_t.setLayerZoomRange,args:[Fe,at.minzoom,at.maxzoom]}),Qe)Qe.hasOwnProperty(ut)&&ut!=="layout"&&ut!=="paint"&&ut!=="filter"&&ut!=="metadata"&&ut!=="minzoom"&&ut!=="maxzoom"&&(ut.indexOf("paint.")===0?wt(Qe[ut],at[ut],re,Fe,ut.slice(6),_t.setPaintProperty):E(Qe[ut],at[ut])||re.push({command:_t.setLayerProperty,args:[Fe,ut,at[ut]]}));for(ut in at)at.hasOwnProperty(ut)&&!Qe.hasOwnProperty(ut)&&ut!=="layout"&&ut!=="paint"&&ut!=="filter"&&ut!=="metadata"&&ut!=="minzoom"&&ut!=="maxzoom"&&(ut.indexOf("paint.")===0?wt(Qe[ut],at[ut],re,Fe,ut.slice(6),_t.setPaintProperty):E(Qe[ut],at[ut])||re.push({command:_t.setLayerProperty,args:[Fe,ut,at[ut]]}))}else re.push({command:_t.removeLayer,args:[Fe]}),dt=Te[Te.lastIndexOf(Fe)+1],re.push({command:_t.addLayer,args:[at,dt]})}(F,b.layers,S)}catch(P){console.warn("Unable to compute style diff:",P),S=[{command:_t.setStyle,args:[b]}]}return S}(this.serialize(),r).filter(x=>!(x.command in bm));if(u.length===0)return!1;const g=u.filter(x=>!(x.command in xm));if(g.length>0)throw new Error(`Unimplemented: ${g.map(x=>x.command).join(", ")}.`);return u.forEach(x=>{x.command!=="setTransition"&&this[x.command].apply(this,x.args)}),this.stylesheet=r,this._updateMapProjection(),!0}addImage(r,u){return this.getImage(r)?this.fire(new s.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(r,u),this._afterImageUpdated(r),this)}updateImage(r,u){this.imageManager.updateImage(r,u)}getImage(r){return this.imageManager.getImage(r)}removeImage(r){return this.getImage(r)?(this.imageManager.removeImage(r),this._afterImageUpdated(r),this):this.fire(new s.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,u,g={}){if(this._checkLoaded(),this.getSource(r)!==void 0)throw new Error("There is already a source with this ID");if(!u.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(u).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(u.type)>=0&&this._validate(s.validateSource,`sources.${r}`,u,null,g))return;this.map&&this.map._collectResourceTiming&&(u.collectResourceTiming=!0);const x=Ke(r,u,this.dispatcher,this);x.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r),source:x.serialize(),sourceId:r}));const b=S=>{const P=(S?"symbol:":"other:")+r,z=this._sourceCaches[P]=new s.SourceCache(P,x,S);(S?this._symbolSourceCaches:this._otherSourceCaches)[r]=z,z.style=this,z.onAdd(this.map)};b(!1),u.type!=="vector"&&u.type!=="geojson"||b(!0),x.onAdd&&x.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const u=this.getSource(r);if(!u)throw new Error("There is no source with this ID");for(const x in this._layers)if(this._layers[x].source===r)return this.fire(new s.ErrorEvent(new Error(`Source "${r}" cannot be removed while layer "${x}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new s.ErrorEvent(new Error(`Source "${r}" cannot be removed while terrain is using it.`)));const g=this._getSourceCaches(r);for(const x of g)delete this._sourceCaches[x.id],delete this._updatedSources[x.id],x.fire(new s.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:x.getSource().id})),x.setEventedParent(null),x.clearTiles();return delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],u.setEventedParent(null),u.onRemove&&u.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(r,u){this._checkLoaded(),this.getSource(r).setData(u),this._changed=!0}getSource(r){const u=this._getSourceCache(r);return u&&u.getSource()}addLayer(r,u,g={}){this._checkLoaded();const x=r.id;if(this.getLayer(x))return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${x}" already exists on this map`)));let b;if(r.type==="custom"){if(_l(this,s.validateCustomStyleLayer(r)))return;b=s.createStyleLayer(r)}else{if(typeof r.source=="object"&&(this.addSource(x,r.source),r=s.clone$1(r),r=s.extend(r,{source:x})),this._validate(s.validateLayer,`layers.${x}`,r,{arrayIndex:-1},g))return;b=s.createStyleLayer(r),this._validateLayer(b),b.setEventedParent(this,{layer:{id:x}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const S=u?this._order.indexOf(u):this._order.length;if(u&&S===-1)return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${u}" does not exist on this map.`)));this._order.splice(S,0,x),this._layerOrderChanged=!0,this._layers[x]=b;const P=this._getLayerSourceCache(b);if(this._removedLayers[x]&&b.source&&P&&b.type!=="custom"){const z=this._removedLayers[x];delete this._removedLayers[x],z.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",P.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,u){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===u)return;const g=this._order.indexOf(r);this._order.splice(g,1);const x=u?this._order.indexOf(u):this._order.length;u&&x===-1?this.fire(new s.ErrorEvent(new Error(`Layer with id "${u}" does not exist on this map.`))):(this._order.splice(x,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const u=this._layers[r];if(!u)return void this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));u.setEventedParent(null),this._updateLayerCount(u,!1);const g=this._order.indexOf(r);this._order.splice(g,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=u,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],u.onRemove&&u.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(r){return this._layers[r]}hasLayer(r){return r in this._layers}hasLayerType(r){for(const u in this._layers)if(this._layers[u].type===r)return!0;return!1}setLayerZoomRange(r,u,g){this._checkLoaded();const x=this.getLayer(r);x?x.minzoom===u&&x.maxzoom===g||(u!=null&&(x.minzoom=u),g!=null&&(x.maxzoom=g),this._updateLayer(x)):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,u,g={}){this._checkLoaded();const x=this.getLayer(r);if(x){if(!E(x.filter,u))return u==null?(x.filter=void 0,void this._updateLayer(x)):void(this._validate(s.validateFilter,`layers.${x.id}.filter`,u,{layerType:x.type},g)||(x.filter=s.clone$1(u),this._updateLayer(x)))}else this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){const u=this.getLayer(r);return u&&s.clone$1(u.filter)}setLayoutProperty(r,u,g,x={}){this._checkLoaded();const b=this.getLayer(r);b?E(b.getLayoutProperty(u),g)||(b.setLayoutProperty(u,g,x),this._updateLayer(b)):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,u){const g=this.getLayer(r);if(g)return g.getLayoutProperty(u);this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,u,g,x={}){this._checkLoaded();const b=this.getLayer(r);b?E(b.getPaintProperty(u),g)||(b.setPaintProperty(u,g,x)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(r,u){const g=this.getLayer(r);return g&&g.getPaintProperty(u)}setFeatureState(r,u){this._checkLoaded();const g=r.source,x=r.sourceLayer,b=this.getSource(g);if(!b)return void this.fire(new s.ErrorEvent(new Error(`The source '${g}' does not exist in the map's style.`)));const S=b.type;if(S==="geojson"&&x)return void this.fire(new s.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(S==="vector"&&!x)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));r.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided.")));const P=this._getSourceCaches(g);for(const z of P)z.setFeatureState(x,r.id,u)}removeFeatureState(r,u){this._checkLoaded();const g=r.source,x=this.getSource(g);if(!x)return void this.fire(new s.ErrorEvent(new Error(`The source '${g}' does not exist in the map's style.`)));const b=x.type,S=b==="vector"?r.sourceLayer:void 0;if(b==="vector"&&!S)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(u&&typeof r.id!="string"&&typeof r.id!="number")return void this.fire(new s.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const P=this._getSourceCaches(g);for(const z of P)z.removeFeatureState(S,r.id,u)}getFeatureState(r){this._checkLoaded();const u=r.source,g=r.sourceLayer,x=this.getSource(u);if(x){if(x.type!=="vector"||g)return r.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(u)[0].getFeatureState(g,r.id);this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new s.ErrorEvent(new Error(`The source '${u}' does not exist in the map's style.`)))}getTransition(){return s.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const u in this._sourceCaches){const g=this._sourceCaches[u].getSource();r[g.id]||(r[g.id]=g.serialize())}return s.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:r,layers:this._serializeLayers(this._order)},u=>u!==void 0)}_updateLayer(r){this._updatedLayers[r.id]=!0;const u=this._getLayerSourceCache(r);r.source&&!this._updatedSources[r.source]&&u&&u.getSource().type!=="raster"&&(this._updatedSources[r.source]="reload",u.pause()),this._changed=!0,r.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(r){const u=S=>this._layers[S].type==="fill-extrusion",g={},x=[];for(let S=this._order.length-1;S>=0;S--){const P=this._order[S];if(u(P)){g[P]=S;for(const z of r){const F=z[P];if(F)for(const N of F)x.push(N)}}}x.sort((S,P)=>P.intersectionZ-S.intersectionZ);const b=[];for(let S=this._order.length-1;S>=0;S--){const P=this._order[S];if(u(P))for(let z=x.length-1;z>=0;z--){const F=x[z].feature;if(g[F.layer.id]<S)break;b.push(F),x.pop()}else for(const z of r){const F=z[P];if(F)for(const N of F)b.push(N.feature)}}return b}queryRenderedFeatures(r,u,g){u&&u.filter&&this._validate(s.validateFilter,"queryRenderedFeatures.filter",u.filter,null,u);const x={};if(u&&u.layers){if(!Array.isArray(u.layers))return this.fire(new s.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const z of u.layers){const F=this._layers[z];if(!F)return this.fire(new s.ErrorEvent(new Error(`The layer '${z}' does not exist in the map's style and cannot be queried for features.`))),[];x[F.source]=!0}}const b=[];u.availableImages=this._availableImages;const S=u&&u.layers?u.layers.some(z=>{const F=this.getLayer(z);return F&&F.is3D()}):this.has3DLayers(),P=Ne.createFromScreenPoints(r,g);for(const z in this._sourceCaches){const F=this._sourceCaches[z].getSource().id;u.layers&&!x[F]||b.push(nt(this._sourceCaches[z],this._layers,this._serializedLayers,P,u,g,S,!!this.map._showQueryGeometry))}return this.placement&&b.push(function(z,F,N,H,J,re,Q){const X={},Ae=re.queryRenderedSymbols(H),fe=[];for(const Te of Object.keys(Ae).map(Number))fe.push(Q[Te]);fe.sort(Ut);for(const Te of fe){const Se=Te.featureIndex.lookupSymbolFeatures(Ae[Te.bucketInstanceId],F,Te.bucketIndex,Te.sourceLayerIndex,J.filter,J.layers,J.availableImages,z);for(const Re in Se){const be=X[Re]=X[Re]||[],Fe=Se[Re];Fe.sort((Qe,at)=>{const dt=Te.featureSortOrder;if(dt){const ut=dt.indexOf(Qe.featureIndex);return dt.indexOf(at.featureIndex)-ut}return at.featureIndex-Qe.featureIndex});for(const Qe of Fe)be.push(Qe)}}for(const Te in X)X[Te].forEach(Se=>{const Re=Se.feature,be=N(z[Te]).getFeatureState(Re.layer["source-layer"],Re.id);Re.source=Re.layer.source,Re.layer["source-layer"]&&(Re.sourceLayer=Re.layer["source-layer"]),Re.state=be});return X}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),P.screenGeometry,u,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(b)}querySourceFeatures(r,u){u&&u.filter&&this._validate(s.validateFilter,"querySourceFeatures.filter",u.filter,null,u);const g=this._getSourceCaches(r);let x=[];for(const b of g)x=x.concat(yt(b,u));return x}addSourceType(r,u,g){return gr.getSourceType(r)?g(new Error(`A source type called "${r}" already exists.`)):(gr.setSourceType(r,u),u.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:r,url:u.workerSourceURL},g):g(null,null))}getLight(){return this.light.getLight()}setLight(r,u={}){this._checkLoaded();const g=this.light.getLight();let x=!1;for(const S in r)if(!E(r[S],g[S])){x=!0;break}if(!x)return;const b={now:s.exported.now(),transition:s.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(r,u),this.light.updateTransitions(b)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,u=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(u===1){if(typeof r.source=="object"){const g="terrain-dem-src";this.addSource(g,r.source),r=s.clone$1(r),r=s.extend(r,{source:g})}if(this._validate(s.validateTerrain,"terrain",r))return}if(!this.terrain||this.terrain&&u!==this.terrain.drapeRenderMode)this._createTerrain(r,u);else{const g=this.terrain,x=g.get();for(const b in r)if(!E(r[b],x[b])){g.set(r),this.stylesheet.terrain=r;const S={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};g.updateTransitions(S);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const u=this.fog=new Pe(r,this.map.transform);this.stylesheet.fog=r;const g={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};u.updateTransitions(g)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const r of this.map._markers)r._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const u=this.fog,g=u.get();for(const x in r)if(!E(r[x],g[x])){u.set(r),this.stylesheet.fog=r;const b={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};u.updateTransitions(b);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const r=this._order.filter(g=>this.isLayerDraped(this._layers[g])),u=this._order.filter(g=>!this.isLayerDraped(this._layers[g]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...r),this._drapedFirstOrder.push(...u)}_createTerrain(r,u){const g=this.terrain=new St(r,u);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const x={now:s.exported.now(),transition:s.extend({duration:0},this.stylesheet.transition)};g.updateTransitions(x)}_force3DLayerUpdate(){for(const r in this._layers){const u=this._layers[r];u.type==="fill-extrusion"&&this._updateLayer(u)}}_forceSymbolLayerUpdate(){for(const r in this._layers){const u=this._layers[r];u.type==="symbol"&&this._updateLayer(u)}}_validate(r,u,g,x,b={}){return(!b||b.validate!==!1)&&_l(this,r.call(s.validateStyle,s.extend({key:u,style:this.serialize(),value:g,styleSpec:s.spec},x)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const r in this._layers)this._layers[r].setEventedParent(null);for(const r in this._sourceCaches)this._sourceCaches[r].clearTiles(),this._sourceCaches[r].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(r){const u=this._getSourceCaches(r);for(const g of u)g.clearTiles()}_reloadSource(r){const u=this._getSourceCaches(r);for(const g of u)g.resume(),g.reload()}_updateSources(r){for(const u in this._sourceCaches)this._sourceCaches[u].update(r)}_generateCollisionBoxes(){for(const r in this._sourceCaches){const u=this._sourceCaches[r];u.resume(),u.reload()}}_updatePlacement(r,u,g,x,b=!1){let S=!1,P=!1;const z={};for(const F of this._order){const N=this._layers[F];if(N.type!=="symbol")continue;if(!z[N.source]){const J=this._getLayerSourceCache(N);if(!J)continue;z[N.source]=J.getRenderableIds(!0).map(re=>J.getTileByID(re)).sort((re,Q)=>Q.tileID.overscaledZ-re.tileID.overscaledZ||(re.tileID.isLessThan(Q.tileID)?-1:1))}const H=this.crossTileSymbolIndex.addLayer(N,z[N.source],r.center.lng,r.projection);S=S||H}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),b=b||this._layerOrderChanged||g===0,this._layerOrderChanged&&this.fire(new s.Event("neworder")),(b||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.exported.now(),r.zoom))&&(this.pauseablePlacement=new Ry(r,this._order,b,u,g,x,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,z),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.exported.now()),P=!0),S&&this.pauseablePlacement.placement.setStale()),P||S)for(const F of this._order){const N=this._layers[F];N.type==="symbol"&&this.placement.updateLayerOpacities(N,z[N.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.exported.now())}_releaseSymbolFadeTiles(){for(const r in this._sourceCaches)this._sourceCaches[r].releaseSymbolFadeTiles()}getImages(r,u,g){this.imageManager.getImages(u.icons,g),this._updateTilesForChangedImages();const x=b=>{b&&b.setDependencies(u.tileID.key,u.type,u.icons)};x(this._otherSourceCaches[u.source]),x(this._symbolSourceCaches[u.source])}getGlyphs(r,u,g){this.glyphManager.getGlyphs(u.stacks,g)}getResource(r,u,g){return s.makeRequest(u,g)}_getSourceCache(r){return this._otherSourceCaches[r]}_getLayerSourceCache(r){return r.type==="symbol"?this._symbolSourceCaches[r.source]:this._otherSourceCaches[r.source]}_getSourceCaches(r){const u=[];return this._otherSourceCaches[r]&&u.push(this._otherSourceCaches[r]),this._symbolSourceCaches[r]&&u.push(this._symbolSourceCaches[r]),u}_isSourceCacheLoaded(r){const u=this._getSourceCaches(r);return u.length===0?(this.fire(new s.ErrorEvent(new Error(`There is no source with ID '${r}'`))),!1):u.every(g=>g.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}gr.getSourceType=function(f){return Je[f]},gr.setSourceType=function(f,r){Je[f]=r},gr.registerForPluginStateChange=s.registerForPluginStateChange;var yl=`
  2891. #define EPSILON 0.0000001
  2892. #define PI 3.141592653589793
  2893. #define EXTENT 8192.0
  2894. #define HALF_PI PI/2.0
  2895. #define QUARTER_PI PI/4.0
  2896. #define RAD_TO_DEG 180.0/PI
  2897. #define DEG_TO_RAD PI/180.0
  2898. #define GLOBE_RADIUS EXTENT/PI/2.0
  2899. #ifdef FOG
  2900. uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}
  2901. #endif`,vl="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let Uo={},ro={};Uo=gn("",`
  2902. #define ELEVATION_SCALE 7.0
  2903. #define ELEVATION_OFFSET 450.0
  2904. #ifdef PROJECTION_GLOBE_VIEW
  2905. uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
  2906. mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
  2907. #else
  2908. vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
  2909. #endif
  2910. #ifdef TERRAIN
  2911. #ifdef TERRAIN_DEM_FLOAT_FORMAT
  2912. uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
  2913. #else
  2914. uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
  2915. #endif
  2916. uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
  2917. #ifdef TERRAIN_DEM_FLOAT_FORMAT
  2918. vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
  2919. #else
  2920. float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
  2921. #ifdef TERRAIN_DEM_NEAREST_FILTER
  2922. return u_exaggeration*tl;
  2923. #endif
  2924. float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
  2925. #endif
  2926. }float prevElevation(vec2 apos) {
  2927. #ifdef TERRAIN_DEM_FLOAT_FORMAT
  2928. vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
  2929. #else
  2930. float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
  2931. #endif
  2932. }
  2933. #ifdef TERRAIN_VERTEX_MORPHING
  2934. float elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
  2935. #else
  2936. float elevation(vec2 apos) {return currentElevation(apos);}
  2937. #endif
  2938. float unpack_depth(vec4 rgba_depth)
  2939. {const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
  2940. unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
  2941. );return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
  2942. #ifdef TERRAIN_DEM_FLOAT_FORMAT
  2943. float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
  2944. #else
  2945. vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
  2946. #endif
  2947. return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
  2948. #else
  2949. float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
  2950. #endif`,!0),ro=gn(`#ifdef FOG
  2951. uniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
  2952. #endif`,`#ifdef FOG
  2953. uniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
  2954. #endif`,!0);const uu=gn(`
  2955. highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}
  2956. #ifdef TERRAIN
  2957. highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
  2958. #endif`,`
  2959. float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
  2960. #ifdef PROJECTION_GLOBE_VIEW
  2961. vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
  2962. #ifndef PROJECTED_POS_ON_VIEWPORT
  2963. float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
  2964. #else
  2965. return vec3(0.0);
  2966. #endif
  2967. }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
  2968. #endif
  2969. vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(
  2970. unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
  2971. );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),xl=yl;var bl={background:gn(`uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;
  2972. #ifdef FOG
  2973. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  2974. #endif
  2975. gl_FragColor=out_color*u_opacity;
  2976. #ifdef OVERDRAW_INSPECTOR
  2977. gl_FragColor=vec4(1.0);
  2978. #endif
  2979. }`,`attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
  2980. #ifdef FOG
  2981. v_fog_pos=fog_position(a_pos);
  2982. #endif
  2983. }`),backgroundPattern:gn(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);
  2984. #ifdef FOG
  2985. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  2986. #endif
  2987. gl_FragColor=out_color*u_opacity;
  2988. #ifdef OVERDRAW_INSPECTOR
  2989. gl_FragColor=vec4(1.0);
  2990. #endif
  2991. }`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);
  2992. #ifdef FOG
  2993. v_fog_pos=fog_position(a_pos);
  2994. #endif
  2995. }`),circle:gn(`varying vec3 v_data;varying float v_visibility;
  2996. #pragma mapbox: define highp vec4 color
  2997. #pragma mapbox: define mediump float radius
  2998. #pragma mapbox: define lowp float blur
  2999. #pragma mapbox: define lowp float opacity
  3000. #pragma mapbox: define highp vec4 stroke_color
  3001. #pragma mapbox: define mediump float stroke_width
  3002. #pragma mapbox: define lowp float stroke_opacity
  3003. void main() {
  3004. #pragma mapbox: initialize highp vec4 color
  3005. #pragma mapbox: initialize mediump float radius
  3006. #pragma mapbox: initialize lowp float blur
  3007. #pragma mapbox: initialize lowp float opacity
  3008. #pragma mapbox: initialize highp vec4 stroke_color
  3009. #pragma mapbox: initialize mediump float stroke_width
  3010. #pragma mapbox: initialize lowp float stroke_opacity
  3011. vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
  3012. antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
  3013. );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
  3014. #ifdef FOG
  3015. out_color=fog_apply_premultiplied(out_color,v_fog_pos);
  3016. #endif
  3017. gl_FragColor=out_color*(v_visibility*opacity_t);
  3018. #ifdef OVERDRAW_INSPECTOR
  3019. gl_FragColor=vec4(1.0);
  3020. #endif
  3021. }`,`#define NUM_VISIBILITY_RINGS 2
  3022. #define INV_SQRT2 0.70710678
  3023. #define ELEVATION_BIAS 0.0001
  3024. #define NUM_SAMPLES_PER_RING 16
  3025. uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
  3026. #ifdef PROJECTION_GLOBE_VIEW
  3027. attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
  3028. #endif
  3029. varying vec3 v_data;varying float v_visibility;
  3030. #pragma mapbox: define highp vec4 color
  3031. #pragma mapbox: define mediump float radius
  3032. #pragma mapbox: define lowp float blur
  3033. #pragma mapbox: define lowp float opacity
  3034. #pragma mapbox: define highp vec4 stroke_color
  3035. #pragma mapbox: define mediump float stroke_width
  3036. #pragma mapbox: define lowp float stroke_opacity
  3037. vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
  3038. #if defined(TERRAIN)
  3039. return elevation(pos)+ELEVATION_BIAS;
  3040. #else
  3041. return 0.0;
  3042. #endif
  3043. }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
  3044. #ifdef PITCH_WITH_MAP
  3045. #ifdef PROJECTION_GLOBE_VIEW
  3046. return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
  3047. #else
  3048. return u_matrix*( world_center+vec4(sample_offset,0,0) );
  3049. #endif
  3050. #else
  3051. return projected_center+vec4(sample_offset,0,0);
  3052. #endif
  3053. }float get_sample_step() {
  3054. #ifdef PITCH_WITH_MAP
  3055. return 2.0*PI/float(NUM_SAMPLES_PER_RING);
  3056. #else
  3057. return PI/float(NUM_SAMPLES_PER_RING);
  3058. #endif
  3059. }void main(void) {
  3060. #pragma mapbox: initialize highp vec4 color
  3061. #pragma mapbox: initialize mediump float radius
  3062. #pragma mapbox: initialize lowp float blur
  3063. #pragma mapbox: initialize lowp float opacity
  3064. #pragma mapbox: initialize highp vec4 stroke_color
  3065. #pragma mapbox: initialize mediump float stroke_width
  3066. #pragma mapbox: initialize lowp float stroke_opacity
  3067. vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);
  3068. #ifdef PROJECTION_GLOBE_VIEW
  3069. vec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);
  3070. #else
  3071. mat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);
  3072. #endif
  3073. vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
  3074. #ifdef PITCH_WITH_MAP
  3075. #ifdef SCALE_WITH_MAP
  3076. view_scale=1.0;
  3077. #else
  3078. view_scale=projected_center.w/u_camera_to_center_distance;
  3079. #endif
  3080. #else
  3081. #ifdef SCALE_WITH_MAP
  3082. view_scale=u_camera_to_center_distance;
  3083. #else
  3084. view_scale=projected_center.w;
  3085. #endif
  3086. #endif
  3087. #if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)
  3088. view_scale*=a_scale;
  3089. #endif
  3090. gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
  3091. #ifdef TERRAIN
  3092. float step=get_sample_step();
  3093. #ifdef PITCH_WITH_MAP
  3094. float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;
  3095. #else
  3096. vec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;
  3097. #endif
  3098. for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
  3099. #else
  3100. visibility=1.0;
  3101. #endif
  3102. #ifdef PROJECTION_GLOBE_VIEW
  3103. visibility=1.0;
  3104. #endif
  3105. v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
  3106. #ifdef FOG
  3107. v_fog_pos=fog_position(world_center.xyz);
  3108. #endif
  3109. }`),clippingMask:gn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:gn(`uniform highp float u_intensity;varying vec2 v_extrude;
  3110. #pragma mapbox: define highp float weight
  3111. #define GAUSS_COEF 0.3989422804014327
  3112. void main() {
  3113. #pragma mapbox: initialize highp float weight
  3114. float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
  3115. #ifdef FOG
  3116. gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);
  3117. #endif
  3118. #ifdef OVERDRAW_INSPECTOR
  3119. gl_FragColor=vec4(1.0);
  3120. #endif
  3121. }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
  3122. #ifdef PROJECTION_GLOBE_VIEW
  3123. attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
  3124. #endif
  3125. varying vec2 v_extrude;
  3126. #pragma mapbox: define highp float weight
  3127. #pragma mapbox: define mediump float radius
  3128. const highp float ZERO=1.0/255.0/16.0;
  3129. #define GAUSS_COEF 0.3989422804014327
  3130. void main(void) {
  3131. #pragma mapbox: initialize highp float weight
  3132. #pragma mapbox: initialize mediump float radius
  3133. vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);
  3134. #ifdef PROJECTION_GLOBE_VIEW
  3135. extrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
  3136. #else
  3137. vec3 pos=vec3(tilePos+extrude,elevation(tilePos));
  3138. #endif
  3139. gl_Position=u_matrix*vec4(pos,1);
  3140. #ifdef FOG
  3141. v_fog_pos=fog_position(pos);
  3142. #endif
  3143. }`),heatmapTexture:gn(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
  3144. #ifdef OVERDRAW_INSPECTOR
  3145. gl_FragColor=vec4(0.0);
  3146. #endif
  3147. }`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:gn("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
  3148. 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:gn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
  3149. mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
  3150. 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:gn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos;
  3151. #ifdef PROJECTION_GLOBE_VIEW
  3152. attribute vec3 a_pos_3;
  3153. #endif
  3154. varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
  3155. #ifdef PROJECTION_GLOBE_VIEW
  3156. gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
  3157. #else
  3158. gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
  3159. #endif
  3160. }`),fill:gn(`#pragma mapbox: define highp vec4 color
  3161. #pragma mapbox: define lowp float opacity
  3162. void main() {
  3163. #pragma mapbox: initialize highp vec4 color
  3164. #pragma mapbox: initialize lowp float opacity
  3165. vec4 out_color=color;
  3166. #ifdef FOG
  3167. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  3168. #endif
  3169. gl_FragColor=out_color*opacity;
  3170. #ifdef OVERDRAW_INSPECTOR
  3171. gl_FragColor=vec4(1.0);
  3172. #endif
  3173. }`,`attribute vec2 a_pos;uniform mat4 u_matrix;
  3174. #pragma mapbox: define highp vec4 color
  3175. #pragma mapbox: define lowp float opacity
  3176. void main() {
  3177. #pragma mapbox: initialize highp vec4 color
  3178. #pragma mapbox: initialize lowp float opacity
  3179. gl_Position=u_matrix*vec4(a_pos,0,1);
  3180. #ifdef FOG
  3181. v_fog_pos=fog_position(a_pos);
  3182. #endif
  3183. }`),fillOutline:gn(`varying vec2 v_pos;
  3184. #pragma mapbox: define highp vec4 outline_color
  3185. #pragma mapbox: define lowp float opacity
  3186. void main() {
  3187. #pragma mapbox: initialize highp vec4 outline_color
  3188. #pragma mapbox: initialize lowp float opacity
  3189. float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
  3190. #ifdef FOG
  3191. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  3192. #endif
  3193. gl_FragColor=out_color*(alpha*opacity);
  3194. #ifdef OVERDRAW_INSPECTOR
  3195. gl_FragColor=vec4(1.0);
  3196. #endif
  3197. }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
  3198. #pragma mapbox: define highp vec4 outline_color
  3199. #pragma mapbox: define lowp float opacity
  3200. void main() {
  3201. #pragma mapbox: initialize highp vec4 outline_color
  3202. #pragma mapbox: initialize lowp float opacity
  3203. gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
  3204. #ifdef FOG
  3205. v_fog_pos=fog_position(a_pos);
  3206. #endif
  3207. }`),fillOutlinePattern:gn(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
  3208. #pragma mapbox: define lowp float opacity
  3209. #pragma mapbox: define lowp vec4 pattern_from
  3210. #pragma mapbox: define lowp vec4 pattern_to
  3211. void main() {
  3212. #pragma mapbox: initialize lowp float opacity
  3213. #pragma mapbox: initialize mediump vec4 pattern_from
  3214. #pragma mapbox: initialize mediump vec4 pattern_to
  3215. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);
  3216. #ifdef FOG
  3217. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  3218. #endif
  3219. gl_FragColor=out_color*(alpha*opacity);
  3220. #ifdef OVERDRAW_INSPECTOR
  3221. gl_FragColor=vec4(1.0);
  3222. #endif
  3223. }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
  3224. #pragma mapbox: define lowp float opacity
  3225. #pragma mapbox: define lowp vec4 pattern_from
  3226. #pragma mapbox: define lowp vec4 pattern_to
  3227. #pragma mapbox: define lowp float pixel_ratio_from
  3228. #pragma mapbox: define lowp float pixel_ratio_to
  3229. void main() {
  3230. #pragma mapbox: initialize lowp float opacity
  3231. #pragma mapbox: initialize mediump vec4 pattern_from
  3232. #pragma mapbox: initialize mediump vec4 pattern_to
  3233. #pragma mapbox: initialize lowp float pixel_ratio_from
  3234. #pragma mapbox: initialize lowp float pixel_ratio_to
  3235. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
  3236. #ifdef FOG
  3237. v_fog_pos=fog_position(a_pos);
  3238. #endif
  3239. }`),fillPattern:gn(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
  3240. #pragma mapbox: define lowp float opacity
  3241. #pragma mapbox: define lowp vec4 pattern_from
  3242. #pragma mapbox: define lowp vec4 pattern_to
  3243. void main() {
  3244. #pragma mapbox: initialize lowp float opacity
  3245. #pragma mapbox: initialize mediump vec4 pattern_from
  3246. #pragma mapbox: initialize mediump vec4 pattern_to
  3247. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);
  3248. #ifdef FOG
  3249. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  3250. #endif
  3251. gl_FragColor=out_color*opacity;
  3252. #ifdef OVERDRAW_INSPECTOR
  3253. gl_FragColor=vec4(1.0);
  3254. #endif
  3255. }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;
  3256. #pragma mapbox: define lowp float opacity
  3257. #pragma mapbox: define lowp vec4 pattern_from
  3258. #pragma mapbox: define lowp vec4 pattern_to
  3259. #pragma mapbox: define lowp float pixel_ratio_from
  3260. #pragma mapbox: define lowp float pixel_ratio_to
  3261. void main() {
  3262. #pragma mapbox: initialize lowp float opacity
  3263. #pragma mapbox: initialize mediump vec4 pattern_from
  3264. #pragma mapbox: initialize mediump vec4 pattern_to
  3265. #pragma mapbox: initialize lowp float pixel_ratio_from
  3266. #pragma mapbox: initialize lowp float pixel_ratio_to
  3267. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);
  3268. #ifdef FOG
  3269. v_fog_pos=fog_position(a_pos);
  3270. #endif
  3271. }`),fillExtrusion:gn(`varying vec4 v_color;void main() {vec4 color=v_color;
  3272. #ifdef FOG
  3273. color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
  3274. #endif
  3275. gl_FragColor=color;
  3276. #ifdef OVERDRAW_INSPECTOR
  3277. gl_FragColor=vec4(1.0);
  3278. #endif
  3279. }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
  3280. #ifdef PROJECTION_GLOBE_VIEW
  3281. attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
  3282. #endif
  3283. varying vec4 v_color;
  3284. #pragma mapbox: define highp float base
  3285. #pragma mapbox: define highp float height
  3286. #pragma mapbox: define highp vec4 color
  3287. void main() {
  3288. #pragma mapbox: initialize highp float base
  3289. #pragma mapbox: initialize highp float height
  3290. #pragma mapbox: initialize highp vec4 color
  3291. vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
  3292. #if defined(HAS_CENTROID) || defined(TERRAIN)
  3293. centroid_pos=a_centroid_pos;
  3294. #endif
  3295. #ifdef TERRAIN
  3296. bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);
  3297. #else
  3298. vec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
  3299. #endif
  3300. #ifdef PROJECTION_GLOBE_VIEW
  3301. float lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
  3302. #endif
  3303. float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(
  3304. (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
  3305. #ifdef FOG
  3306. v_fog_pos=fog_position(pos);
  3307. #endif
  3308. }`),fillExtrusionPattern:gn(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
  3309. #pragma mapbox: define lowp float base
  3310. #pragma mapbox: define lowp float height
  3311. #pragma mapbox: define lowp vec4 pattern_from
  3312. #pragma mapbox: define lowp vec4 pattern_to
  3313. #pragma mapbox: define lowp float pixel_ratio_from
  3314. #pragma mapbox: define lowp float pixel_ratio_to
  3315. void main() {
  3316. #pragma mapbox: initialize lowp float base
  3317. #pragma mapbox: initialize lowp float height
  3318. #pragma mapbox: initialize mediump vec4 pattern_from
  3319. #pragma mapbox: initialize mediump vec4 pattern_to
  3320. #pragma mapbox: initialize lowp float pixel_ratio_from
  3321. #pragma mapbox: initialize lowp float pixel_ratio_to
  3322. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;
  3323. #ifdef FOG
  3324. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  3325. #endif
  3326. gl_FragColor=out_color;
  3327. #ifdef OVERDRAW_INSPECTOR
  3328. gl_FragColor=vec4(1.0);
  3329. #endif
  3330. }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
  3331. #ifdef PROJECTION_GLOBE_VIEW
  3332. attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
  3333. #endif
  3334. varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
  3335. #pragma mapbox: define lowp float base
  3336. #pragma mapbox: define lowp float height
  3337. #pragma mapbox: define lowp vec4 pattern_from
  3338. #pragma mapbox: define lowp vec4 pattern_to
  3339. #pragma mapbox: define lowp float pixel_ratio_from
  3340. #pragma mapbox: define lowp float pixel_ratio_to
  3341. void main() {
  3342. #pragma mapbox: initialize lowp float base
  3343. #pragma mapbox: initialize lowp float height
  3344. #pragma mapbox: initialize mediump vec4 pattern_from
  3345. #pragma mapbox: initialize mediump vec4 pattern_to
  3346. #pragma mapbox: initialize lowp float pixel_ratio_from
  3347. #pragma mapbox: initialize lowp float pixel_ratio_to
  3348. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
  3349. #if defined(HAS_CENTROID) || defined(TERRAIN)
  3350. centroid_pos=a_centroid_pos;
  3351. #endif
  3352. #ifdef TERRAIN
  3353. bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);
  3354. #else
  3355. vec3 p=vec3(pos_nx.xy,z);
  3356. #endif
  3357. #ifdef PROJECTION_GLOBE_VIEW
  3358. float lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
  3359. #endif
  3360. float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
  3361. ? pos_nx.xy
  3362. : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(
  3363. (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
  3364. #ifdef FOG
  3365. v_fog_pos=fog_position(p);
  3366. #endif
  3367. }`),hillshadePrepare:gn(`#ifdef GL_ES
  3368. precision highp float;
  3369. #endif
  3370. uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
  3371. #ifdef TERRAIN_DEM_FLOAT_FORMAT
  3372. return texture2D(u_image,coord).a/4.0;
  3373. #else
  3374. vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
  3375. #endif
  3376. }void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(
  3377. (c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)
  3378. )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
  3379. deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
  3380. #ifdef OVERDRAW_INSPECTOR
  3381. gl_FragColor=vec4(1.0);
  3382. #endif
  3383. }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:gn(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
  3384. #ifdef FOG
  3385. gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
  3386. #endif
  3387. #ifdef OVERDRAW_INSPECTOR
  3388. gl_FragColor=vec4(1.0);
  3389. #endif
  3390. }`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;
  3391. #ifdef FOG
  3392. v_fog_pos=fog_position(a_pos);
  3393. #endif
  3394. }`),line:gn(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
  3395. #ifdef RENDER_LINE_DASH
  3396. uniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
  3397. #endif
  3398. #ifdef RENDER_LINE_GRADIENT
  3399. uniform sampler2D u_gradient_image;varying highp vec2 v_uv;
  3400. #endif
  3401. #pragma mapbox: define highp vec4 color
  3402. #pragma mapbox: define lowp float floorwidth
  3403. #pragma mapbox: define lowp vec4 dash_from
  3404. #pragma mapbox: define lowp vec4 dash_to
  3405. #pragma mapbox: define lowp float blur
  3406. #pragma mapbox: define lowp float opacity
  3407. void main() {
  3408. #pragma mapbox: initialize highp vec4 color
  3409. #pragma mapbox: initialize lowp float floorwidth
  3410. #pragma mapbox: initialize lowp vec4 dash_from
  3411. #pragma mapbox: initialize lowp vec4 dash_to
  3412. #pragma mapbox: initialize lowp float blur
  3413. #pragma mapbox: initialize lowp float opacity
  3414. float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);
  3415. #ifdef RENDER_LINE_DASH
  3416. float sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
  3417. #endif
  3418. #ifdef RENDER_LINE_GRADIENT
  3419. vec4 out_color=texture2D(u_gradient_image,v_uv);
  3420. #else
  3421. vec4 out_color=color;
  3422. #endif
  3423. #ifdef FOG
  3424. out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
  3425. #endif
  3426. #ifdef RENDER_LINE_ALPHA_DISCARD
  3427. if (alpha < u_alpha_discard_threshold) {discard;}
  3428. #endif
  3429. gl_FragColor=out_color*(alpha*opacity);
  3430. #ifdef OVERDRAW_INSPECTOR
  3431. gl_FragColor=vec4(1.0);
  3432. #endif
  3433. }`,`
  3434. #define EXTRUDE_SCALE 0.015873016
  3435. attribute vec2 a_pos_normal;attribute vec4 a_data;
  3436. #ifdef RENDER_LINE_GRADIENT
  3437. attribute vec3 a_packed;
  3438. #else
  3439. attribute float a_linesofar;
  3440. #endif
  3441. uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;
  3442. #ifdef RENDER_LINE_DASH
  3443. uniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
  3444. #endif
  3445. #ifdef RENDER_LINE_GRADIENT
  3446. uniform float u_image_height;varying highp vec2 v_uv;
  3447. #endif
  3448. #pragma mapbox: define highp vec4 color
  3449. #pragma mapbox: define lowp float floorwidth
  3450. #pragma mapbox: define lowp vec4 dash_from
  3451. #pragma mapbox: define lowp vec4 dash_to
  3452. #pragma mapbox: define lowp float blur
  3453. #pragma mapbox: define lowp float opacity
  3454. #pragma mapbox: define mediump float gapwidth
  3455. #pragma mapbox: define lowp float offset
  3456. #pragma mapbox: define mediump float width
  3457. void main() {
  3458. #pragma mapbox: initialize highp vec4 color
  3459. #pragma mapbox: initialize lowp float floorwidth
  3460. #pragma mapbox: initialize lowp vec4 dash_from
  3461. #pragma mapbox: initialize lowp vec4 dash_to
  3462. #pragma mapbox: initialize lowp float blur
  3463. #pragma mapbox: initialize lowp float opacity
  3464. #pragma mapbox: initialize mediump float gapwidth
  3465. #pragma mapbox: initialize lowp float offset
  3466. #pragma mapbox: initialize mediump float width
  3467. float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
  3468. #ifndef RENDER_TO_TEXTURE
  3469. float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
  3470. #else
  3471. v_gamma_scale=1.0;
  3472. #endif
  3473. #ifdef RENDER_LINE_GRADIENT
  3474. float a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);
  3475. #endif
  3476. #ifdef RENDER_LINE_DASH
  3477. float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);
  3478. #endif
  3479. v_width2=vec2(outset,inset);
  3480. #ifdef FOG
  3481. v_fog_pos=fog_position(pos);
  3482. #endif
  3483. }`),linePattern:gn(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
  3484. #pragma mapbox: define lowp vec4 pattern_from
  3485. #pragma mapbox: define lowp vec4 pattern_to
  3486. #pragma mapbox: define lowp float pixel_ratio_from
  3487. #pragma mapbox: define lowp float pixel_ratio_to
  3488. #pragma mapbox: define lowp float blur
  3489. #pragma mapbox: define lowp float opacity
  3490. void main() {
  3491. #pragma mapbox: initialize mediump vec4 pattern_from
  3492. #pragma mapbox: initialize mediump vec4 pattern_to
  3493. #pragma mapbox: initialize lowp float pixel_ratio_from
  3494. #pragma mapbox: initialize lowp float pixel_ratio_to
  3495. #pragma mapbox: initialize lowp float blur
  3496. #pragma mapbox: initialize lowp float opacity
  3497. vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);
  3498. #ifdef FOG
  3499. color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
  3500. #endif
  3501. gl_FragColor=color*(alpha*opacity);
  3502. #ifdef OVERDRAW_INSPECTOR
  3503. gl_FragColor=vec4(1.0);
  3504. #endif
  3505. }`,`
  3506. #define scale 0.015873016
  3507. attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
  3508. #pragma mapbox: define lowp float blur
  3509. #pragma mapbox: define lowp float opacity
  3510. #pragma mapbox: define lowp float offset
  3511. #pragma mapbox: define mediump float gapwidth
  3512. #pragma mapbox: define mediump float width
  3513. #pragma mapbox: define lowp float floorwidth
  3514. #pragma mapbox: define lowp vec4 pattern_from
  3515. #pragma mapbox: define lowp vec4 pattern_to
  3516. #pragma mapbox: define lowp float pixel_ratio_from
  3517. #pragma mapbox: define lowp float pixel_ratio_to
  3518. void main() {
  3519. #pragma mapbox: initialize lowp float blur
  3520. #pragma mapbox: initialize lowp float opacity
  3521. #pragma mapbox: initialize lowp float offset
  3522. #pragma mapbox: initialize mediump float gapwidth
  3523. #pragma mapbox: initialize mediump float width
  3524. #pragma mapbox: initialize lowp float floorwidth
  3525. #pragma mapbox: initialize mediump vec4 pattern_from
  3526. #pragma mapbox: initialize mediump vec4 pattern_to
  3527. #pragma mapbox: initialize lowp float pixel_ratio_from
  3528. #pragma mapbox: initialize lowp float pixel_ratio_to
  3529. float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
  3530. #ifndef RENDER_TO_TEXTURE
  3531. float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
  3532. #else
  3533. v_gamma_scale=1.0;
  3534. #endif
  3535. v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
  3536. #ifdef FOG
  3537. v_fog_pos=fog_position(pos);
  3538. #endif
  3539. }`),raster:gn(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(
  3540. dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
  3541. #ifdef FOG
  3542. out_color=fog_dither(fog_apply(out_color,v_fog_pos));
  3543. #endif
  3544. gl_FragColor=vec4(out_color*color.a,color.a);
  3545. #ifdef OVERDRAW_INSPECTOR
  3546. gl_FragColor=vec4(1.0);
  3547. #endif
  3548. }`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
  3549. #ifdef FOG
  3550. v_fog_pos=fog_position(a_pos);
  3551. #endif
  3552. }`),symbolIcon:gn(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
  3553. #pragma mapbox: define lowp float opacity
  3554. void main() {
  3555. #pragma mapbox: initialize lowp float opacity
  3556. lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
  3557. #ifdef OVERDRAW_INSPECTOR
  3558. gl_FragColor=vec4(1.0);
  3559. #endif
  3560. }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;
  3561. #ifdef PROJECTION_GLOBE_VIEW
  3562. uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
  3563. #endif
  3564. varying vec2 v_tex;varying float v_fade_opacity;
  3565. #pragma mapbox: define lowp float opacity
  3566. void main() {
  3567. #pragma mapbox: initialize lowp float opacity
  3568. vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
  3569. #ifdef PROJECTION_GLOBE_VIEW
  3570. vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
  3571. #else
  3572. vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
  3573. #endif
  3574. vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
  3575. camera_to_anchor_distance/u_camera_to_center_distance :
  3576. u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
  3577. 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}
  3578. #ifdef PROJECTION_GLOBE_VIEW
  3579. vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
  3580. #else
  3581. vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
  3582. #endif
  3583. #ifdef PROJECTED_POS_ON_VIEWPORT
  3584. vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
  3585. #else
  3586. vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
  3587. #endif
  3588. highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
  3589. #ifdef PITCH_WITH_MAP_TERRAIN
  3590. vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
  3591. #endif
  3592. float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;
  3593. #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
  3594. projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
  3595. #endif
  3596. v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:gn(`#define SDF_PX 8.0
  3597. uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
  3598. #pragma mapbox: define highp vec4 fill_color
  3599. #pragma mapbox: define highp vec4 halo_color
  3600. #pragma mapbox: define lowp float opacity
  3601. #pragma mapbox: define lowp float halo_width
  3602. #pragma mapbox: define lowp float halo_blur
  3603. void main() {
  3604. #pragma mapbox: initialize highp vec4 fill_color
  3605. #pragma mapbox: initialize highp vec4 halo_color
  3606. #pragma mapbox: initialize lowp float opacity
  3607. #pragma mapbox: initialize lowp float halo_width
  3608. #pragma mapbox: initialize lowp float halo_blur
  3609. float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
  3610. #ifdef OVERDRAW_INSPECTOR
  3611. gl_FragColor=vec4(1.0);
  3612. #endif
  3613. }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;
  3614. #ifdef PROJECTION_GLOBE_VIEW
  3615. uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
  3616. #endif
  3617. varying vec2 v_data0;varying vec3 v_data1;
  3618. #pragma mapbox: define highp vec4 fill_color
  3619. #pragma mapbox: define highp vec4 halo_color
  3620. #pragma mapbox: define lowp float opacity
  3621. #pragma mapbox: define lowp float halo_width
  3622. #pragma mapbox: define lowp float halo_blur
  3623. void main() {
  3624. #pragma mapbox: initialize highp vec4 fill_color
  3625. #pragma mapbox: initialize highp vec4 halo_color
  3626. #pragma mapbox: initialize lowp float opacity
  3627. #pragma mapbox: initialize lowp float halo_width
  3628. #pragma mapbox: initialize lowp float halo_blur
  3629. vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
  3630. #ifdef PROJECTION_GLOBE_VIEW
  3631. vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
  3632. #else
  3633. vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
  3634. #endif
  3635. vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
  3636. camera_to_anchor_distance/u_camera_to_center_distance :
  3637. u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
  3638. 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}
  3639. #ifdef PROJECTION_GLOBE_VIEW
  3640. vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
  3641. #else
  3642. vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
  3643. #endif
  3644. #ifdef PROJECTED_POS_ON_VIEWPORT
  3645. vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
  3646. #else
  3647. vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
  3648. #endif
  3649. highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
  3650. #ifdef PITCH_WITH_MAP_TERRAIN
  3651. vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
  3652. #endif
  3653. float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
  3654. #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
  3655. projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
  3656. #endif
  3657. vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:gn(`#define SDF_PX 8.0
  3658. #define SDF 1.0
  3659. #define ICON 0.0
  3660. uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
  3661. #pragma mapbox: define highp vec4 fill_color
  3662. #pragma mapbox: define highp vec4 halo_color
  3663. #pragma mapbox: define lowp float opacity
  3664. #pragma mapbox: define lowp float halo_width
  3665. #pragma mapbox: define lowp float halo_blur
  3666. void main() {
  3667. #pragma mapbox: initialize highp vec4 fill_color
  3668. #pragma mapbox: initialize highp vec4 halo_color
  3669. #pragma mapbox: initialize lowp float opacity
  3670. #pragma mapbox: initialize lowp float halo_width
  3671. #pragma mapbox: initialize lowp float halo_blur
  3672. float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
  3673. #ifdef OVERDRAW_INSPECTOR
  3674. gl_FragColor=vec4(1.0);
  3675. #endif
  3676. return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
  3677. #ifdef OVERDRAW_INSPECTOR
  3678. gl_FragColor=vec4(1.0);
  3679. #endif
  3680. }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;
  3681. #ifdef PROJECTION_GLOBE_VIEW
  3682. uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
  3683. #endif
  3684. varying vec4 v_data0;varying vec4 v_data1;
  3685. #pragma mapbox: define highp vec4 fill_color
  3686. #pragma mapbox: define highp vec4 halo_color
  3687. #pragma mapbox: define lowp float opacity
  3688. #pragma mapbox: define lowp float halo_width
  3689. #pragma mapbox: define lowp float halo_blur
  3690. void main() {
  3691. #pragma mapbox: initialize highp vec4 fill_color
  3692. #pragma mapbox: initialize highp vec4 halo_color
  3693. #pragma mapbox: initialize lowp float opacity
  3694. #pragma mapbox: initialize lowp float halo_width
  3695. #pragma mapbox: initialize lowp float halo_blur
  3696. vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
  3697. #ifdef PROJECTION_GLOBE_VIEW
  3698. vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
  3699. #else
  3700. vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
  3701. #endif
  3702. vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
  3703. camera_to_anchor_distance/u_camera_to_center_distance :
  3704. u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
  3705. 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}
  3706. #ifdef PROJECTION_GLOBE_VIEW
  3707. vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
  3708. #else
  3709. vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
  3710. #endif
  3711. #ifdef PROJECTED_POS_ON_VIEWPORT
  3712. vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
  3713. #else
  3714. vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
  3715. #endif
  3716. highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);
  3717. #ifdef PITCH_WITH_MAP_TERRAIN
  3718. vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
  3719. #endif
  3720. float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
  3721. #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
  3722. projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
  3723. #endif
  3724. v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:gn(`uniform sampler2D u_image0;varying vec2 v_pos0;
  3725. #ifdef FOG
  3726. varying float v_fog_opacity;
  3727. #endif
  3728. void main() {vec4 color=texture2D(u_image0,v_pos0);
  3729. #ifdef FOG
  3730. color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
  3731. #endif
  3732. gl_FragColor=color;
  3733. #ifdef TERRAIN_WIREFRAME
  3734. gl_FragColor=vec4(1.0,0.0,0.0,0.8);
  3735. #endif
  3736. #ifdef OVERDRAW_INSPECTOR
  3737. gl_FragColor=vec4(1.0);
  3738. #endif
  3739. }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;
  3740. #ifdef FOG
  3741. varying float v_fog_opacity;
  3742. #endif
  3743. const float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;
  3744. #ifdef TERRAIN_WIREFRAME
  3745. elevation+=u_skirt_height*u_skirt_height*wireframeOffset;
  3746. #endif
  3747. vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
  3748. #ifdef FOG
  3749. v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
  3750. #endif
  3751. }`),terrainDepth:gn(`#ifdef GL_ES
  3752. precision highp float;
  3753. #endif
  3754. varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:gn(`
  3755. varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
  3756. cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
  3757. #ifdef FOG
  3758. sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
  3759. #endif
  3760. sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
  3761. #ifdef OVERDRAW_INSPECTOR
  3762. gl_FragColor=vec4(1.0);
  3763. #endif
  3764. }`,vl),skyboxGradient:gn(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
  3765. #ifdef FOG
  3766. color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
  3767. #endif
  3768. color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
  3769. #ifdef OVERDRAW_INSPECTOR
  3770. gl_FragColor=vec4(1.0);
  3771. #endif
  3772. }`,vl),skyboxCapture:gn(`
  3773. varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
  3774. #ifdef GL_ES
  3775. precision highp float;
  3776. #endif
  3777. #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
  3778. #define BETA_M vec3(21e-6,21e-6,21e-6)
  3779. #define MIE_G 0.76
  3780. #define DENSITY_HEIGHT_SCALE_R 8000.0
  3781. #define DENSITY_HEIGHT_SCALE_M 1200.0
  3782. #define PLANET_RADIUS 6360e3
  3783. #define ATMOSPHERE_RADIUS 6420e3
  3784. #define SAMPLE_STEPS 10
  3785. #define DENSITY_STEPS 4
  3786. float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:gn(`uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);
  3787. #ifdef TERRAIN_WIREFRAME
  3788. gl_FragColor=vec4(1.0,0.0,0.0,0.8);
  3789. #endif
  3790. #ifdef OVERDRAW_INSPECTOR
  3791. gl_FragColor=vec4(1.0);
  3792. #endif
  3793. }`,`uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;
  3794. #ifdef GLOBE_POLES
  3795. attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;
  3796. #else
  3797. attribute vec2 a_pos;
  3798. #endif
  3799. varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {
  3800. #ifdef GLOBE_POLES
  3801. vec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;
  3802. #else
  3803. float tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
  3804. #endif
  3805. v_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);
  3806. #ifdef TERRAIN_WIREFRAME
  3807. height+=wireframeOffset;
  3808. #endif
  3809. vec4 globe=u_globe_matrix*vec4(globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}`),globeAtmosphere:gn(`uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;varying highp vec3 v_ray_dir;void main() {highp vec3 dir=normalize(v_ray_dir);highp vec3 closest_point=abs(dot(u_globe_pos,dir))*dir;float norm_dist_from_center=length(closest_point-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 1.0)
  3810. discard;float t=clamp(1.0-sqrt(norm_dist_from_center-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}`,"attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;varying highp vec3 v_ray_dir;void main() {v_ray_dir=mix(mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);gl_Position=vec4(a_pos,1.0);}")};function gn(f,r,u){const g=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,x=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,b=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),S=f.match(x),P=r.match(x),z=yl.match(x);let F=P?P.concat(S):S;u||(Uo.staticUniforms&&(F=Uo.staticUniforms.concat(F)),ro.staticUniforms&&(F=ro.staticUniforms.concat(F))),F&&(F=F.concat(z));const N={};return{fragmentSource:f=f.replace(g,(H,J,re,Q,X)=>(N[X]=!0,J==="define"?`
  3811. #ifndef HAS_UNIFORM_u_${X}
  3812. varying ${re} ${Q} ${X};
  3813. #else
  3814. uniform ${re} ${Q} u_${X};
  3815. #endif
  3816. `:`
  3817. #ifdef HAS_UNIFORM_u_${X}
  3818. ${re} ${Q} ${X} = u_${X};
  3819. #endif
  3820. `)),vertexSource:r=r.replace(g,(H,J,re,Q,X)=>{const Ae=Q==="float"?"vec2":"vec4",fe=X.match(/color/)?"color":Ae;return N[X]?J==="define"?`
  3821. #ifndef HAS_UNIFORM_u_${X}
  3822. uniform lowp float u_${X}_t;
  3823. attribute ${re} ${Ae} a_${X};
  3824. varying ${re} ${Q} ${X};
  3825. #else
  3826. uniform ${re} ${Q} u_${X};
  3827. #endif
  3828. `:fe==="vec4"?`
  3829. #ifndef HAS_UNIFORM_u_${X}
  3830. ${X} = a_${X};
  3831. #else
  3832. ${re} ${Q} ${X} = u_${X};
  3833. #endif
  3834. `:`
  3835. #ifndef HAS_UNIFORM_u_${X}
  3836. ${X} = unpack_mix_${fe}(a_${X}, u_${X}_t);
  3837. #else
  3838. ${re} ${Q} ${X} = u_${X};
  3839. #endif
  3840. `:J==="define"?`
  3841. #ifndef HAS_UNIFORM_u_${X}
  3842. uniform lowp float u_${X}_t;
  3843. attribute ${re} ${Ae} a_${X};
  3844. #else
  3845. uniform ${re} ${Q} u_${X};
  3846. #endif
  3847. `:fe==="vec4"?`
  3848. #ifndef HAS_UNIFORM_u_${X}
  3849. ${re} ${Q} ${X} = a_${X};
  3850. #else
  3851. ${re} ${Q} ${X} = u_${X};
  3852. #endif
  3853. `:`
  3854. #ifndef HAS_UNIFORM_u_${X}
  3855. ${re} ${Q} ${X} = unpack_mix_${fe}(a_${X}, u_${X}_t);
  3856. #else
  3857. ${re} ${Q} ${X} = u_${X};
  3858. #endif
  3859. `}),staticAttributes:b,staticUniforms:F}}class hu{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(r,u,g,x,b,S,P,z){this.context=r;let F=this.boundPaintVertexBuffers.length!==x.length;for(let N=0;!F&&N<x.length;N++)this.boundPaintVertexBuffers[N]!==x[N]&&(F=!0);r.extVertexArrayObject&&this.vao&&this.boundProgram===u&&this.boundLayoutVertexBuffer===g&&!F&&this.boundIndexBuffer===b&&this.boundVertexOffset===S&&this.boundDynamicVertexBuffer===P&&this.boundDynamicVertexBuffer2===z?(r.bindVertexArrayOES.set(this.vao),P&&P.bind(),b&&b.dynamicDraw&&b.bind(),z&&z.bind()):this.freshBind(u,g,x,b,S,P,z)}freshBind(r,u,g,x,b,S,P){let z;const F=r.numAttributes,N=this.context,H=N.gl;if(N.extVertexArrayObject)this.vao&&this.destroy(),this.vao=N.extVertexArrayObject.createVertexArrayOES(),N.bindVertexArrayOES.set(this.vao),z=0,this.boundProgram=r,this.boundLayoutVertexBuffer=u,this.boundPaintVertexBuffers=g,this.boundIndexBuffer=x,this.boundVertexOffset=b,this.boundDynamicVertexBuffer=S,this.boundDynamicVertexBuffer2=P;else{z=N.currentNumAttributes||0;for(let J=F;J<z;J++)H.disableVertexAttribArray(J)}u.enableAttributes(H,r);for(const J of g)J.enableAttributes(H,r);S&&S.enableAttributes(H,r),P&&P.enableAttributes(H,r),u.bind(),u.setVertexAttribPointers(H,r,b);for(const J of g)J.bind(),J.setVertexAttribPointers(H,r,b);S&&(S.bind(),S.setVertexAttribPointers(H,r,b)),x&&x.bind(),P&&(P.bind(),P.setVertexAttribPointers(H,r,b)),N.currentNumAttributes=F}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Mm(f,r){const u=Math.pow(2,r.canonical.z),g=r.canonical.y;return[new s.MercatorCoordinate(0,g/u).toLngLat().lat,new s.MercatorCoordinate(0,(g+1)/u).toLngLat().lat]}function Tm(f,r,u,g,x,b,S){const P=f.context,z=P.gl,F=u.fbo;if(!F)return;f.prepareDrawTile();const N=f.useProgram("hillshade");P.activeTexture.set(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,F.colorAttachment.get());const H=((X,Ae,fe,Te)=>{const Se=fe.paint.get("hillshade-shadow-color"),Re=fe.paint.get("hillshade-highlight-color"),be=fe.paint.get("hillshade-accent-color");let Fe=fe.paint.get("hillshade-illumination-direction")*(Math.PI/180);fe.paint.get("hillshade-illumination-anchor")==="viewport"&&(Fe-=X.transform.angle);const Qe=!X.options.moving;return{u_matrix:Te||X.transform.calculateProjMatrix(Ae.tileID.toUnwrapped(),Qe),u_image:0,u_latrange:Mm(0,Ae.tileID),u_light:[fe.paint.get("hillshade-exaggeration"),Fe],u_shadow:Se,u_highlight:Re,u_accent:be}})(f,u,g,f.terrain?r.projMatrix:null);f.prepareDrawProgram(P,N,r.toUnwrapped());const{tileBoundsBuffer:J,tileBoundsIndexBuffer:re,tileBoundsSegments:Q}=f.getTileBoundsBuffers(u);N.draw(P,z.TRIANGLES,x,b,S,s.CullFaceMode.disabled,H,g.id,J,re,Q)}function Ed(f,r,u){if(!r.needsDEMTextureUpload)return;const g=f.context,x=g.gl;g.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||f.getTileTexture(u.stride);const b=u.getPixels();r.demTexture?r.demTexture.update(b,{premultiply:!1}):r.demTexture=new s.Texture(g,b,x.RGBA,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Sd(f,r,u,g,x,b){const S=f.context,P=S.gl;if(!r.dem)return;const z=r.dem;if(S.activeTexture.set(P.TEXTURE1),Ed(f,r,z),!r.demTexture)return;r.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);const F=z.dim;S.activeTexture.set(P.TEXTURE0);let N=r.fbo;if(!N){const Q=new s.Texture(S,{width:F,height:F,data:null},P.RGBA);Q.bind(P.LINEAR,P.CLAMP_TO_EDGE),N=r.fbo=S.createFramebuffer(F,F,!0),N.colorAttachment.set(Q.texture)}S.bindFramebuffer.set(N.framebuffer),S.viewport.set([0,0,F,F]);const{tileBoundsBuffer:H,tileBoundsIndexBuffer:J,tileBoundsSegments:re}=f.getMercatorTileBoundsBuffers();f.useProgram("hillshadePrepare").draw(S,P.TRIANGLES,g,x,b,s.CullFaceMode.disabled,((Q,X)=>{const Ae=X.stride,fe=s.create();return s.ortho(fe,0,s.EXTENT,-s.EXTENT,0,0,1),s.translate(fe,fe,[0,-s.EXTENT,0]),{u_matrix:fe,u_image:1,u_dimension:[Ae,Ae],u_zoom:Q.overscaledZ,u_unpack:X.unpackVector}})(r.tileID,z),u.id,H,J,re),r.needsHillshadePrepare=!1}const Ad=(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image0:new s.Uniform1i(f,r.u_image0),u_skirt_height:new s.Uniform1f(f,r.u_skirt_height)}),Em=(f,r)=>({u_matrix:f,u_image0:0,u_skirt_height:r}),Sm=(f,r,u,g,x,b)=>({u_proj_matrix:Float32Array.from(f),u_globe_matrix:r,u_merc_matrix:u,u_zoom_transition:g,u_merc_center:x,u_image0:0,u_grid_matrix:b?Float32Array.from(b):new Float32Array(9)});function du(f,r){return f!=null&&r!=null&&!(!f.hasData()||!r.hasData())&&f.demTexture!=null&&r.demTexture!=null&&f.tileID.key!==r.tileID.key}const ao=new class{constructor(){this.operations={}}newMorphing(f,r,u,g,x){if(f in this.operations){const b=this.operations[f];b.to.tileID.key!==u.tileID.key&&(b.queued=u)}else this.operations[f]={startTime:g,phase:0,duration:x,from:r,to:u,queued:null}}getMorphValuesForProxy(f){if(!(f in this.operations))return null;const r=this.operations[f];return{from:r.from,to:r.to,phase:r.phase}}update(f){for(const r in this.operations){const u=this.operations[r];for(u.phase=(f-u.startTime)/u.duration;u.phase>=1||!this._validOp(u);)if(!this._nextOp(u,f)){delete this.operations[r];break}}}_nextOp(f,r){return!!f.queued&&(f.from=f.to,f.to=f.queued,f.queued=null,f.phase=0,f.startTime=r,!0)}_validOp(f){return f.from.hasData()&&f.to.hasData()}},Ms={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Cd(f,r){const u=1<<f.z;return!r&&(f.x===0||f.x===u-1)||f.y===0||f.y===u-1}const pu=f=>({u_matrix:f});function Pd(f,r,u,g,x){if(x>0){const b=s.exported.now(),S=(b-f.timeAdded)/x,P=r?(b-r.timeAdded)/x:-1,z=u.getSource(),F=g.coveringZoomLevel({tileSize:z.tileSize,roundZoom:z.roundZoom}),N=!r||Math.abs(r.tileID.overscaledZ-F)>Math.abs(f.tileID.overscaledZ-F),H=N&&f.refreshedUponExpiration?1:s.clamp(N?S:1-P,0,1);return f.refreshedUponExpiration&&S>=1&&(f.refreshedUponExpiration=!1),r?{opacity:1,mix:1-H}:{opacity:H,mix:0}}return{opacity:1,mix:0}}const By=2*s.mercatorZfromAltitude(1,0)*s.GLOBE_RADIUS*Math.PI;class wl extends s.SourceCache{constructor(r){const u={type:"raster-dem",maxzoom:r.transform.maxZoom},g=new ge(ze(),null),x=Ke("mock-dem",u,g,r.style);super("mock-dem",x,!1),x.setEventedParent(this),this._sourceLoaded=!0}_loadTile(r,u){r.state="loaded",u(null)}}class Ml extends s.SourceCache{constructor(r){const u=Ke("proxy",{type:"geojson",maxzoom:r.transform.maxZoom},new ge(ze(),null),r.style);super("proxy",u,!1),u.setEventedParent(this),this.map=this.getSource().map=r,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,u,g){if(r.freezeTileCoverage)return;this.transform=r;const x=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((b,S)=>{if(b[S.key]="",!this._tiles[S.key]){const P=new s.Tile(S,this._source.tileSize*S.overscaleFactor(),r.tileZoom);P.state="loaded",this._tiles[S.key]=P}return b},{});for(const b in this._tiles)b in x||(this.freeFBO(b),this._tiles[b].unloadVectorData(),delete this._tiles[b])}freeFBO(r){const u=this.proxyCachedFBO[r];if(u!==void 0){const g=Object.values(u);this.renderCachePool.push(...g),delete this.proxyCachedFBO[r]}}deallocRenderCache(){this.renderCache.forEach(r=>r.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ld extends s.OverscaledTileID{constructor(r,u,g){super(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y),this.proxyTileKey=u,this.projMatrix=g}}class Lr extends s.Elevation{constructor(r,u){super(),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[g,x,b]=function(z){const F=new s.StructArrayLayout4i8,N=new s.StructArrayLayout3ui6,H=131;F.reserve(17161),N.reserve(33800);const J=s.EXTENT/128,re=s.EXTENT+J/2,Q=re+J;for(let Ae=-J;Ae<Q;Ae+=J)for(let fe=-J;fe<Q;fe+=J){const Te=fe<0||fe>re||Ae<0||Ae>re?24575:0,Se=s.clamp(Math.round(fe),0,s.EXTENT),Re=s.clamp(Math.round(Ae),0,s.EXTENT);F.emplaceBack(Se+Te,Re,Se,Re)}const X=(Ae,fe)=>{const Te=fe*H+Ae;N.emplaceBack(Te+1,Te,Te+H),N.emplaceBack(Te+H,Te+H+1,Te+1)};for(let Ae=1;Ae<129;Ae++)for(let fe=1;fe<129;fe++)X(fe,Ae);return[0,129].forEach(Ae=>{for(let fe=0;fe<130;fe++)X(fe,Ae),X(Ae,fe)}),[F,N,32768]}(),S=r.context;this.gridBuffer=S.createVertexBuffer(g,s.boundsAttributes.members),this.gridIndexBuffer=S.createIndexBuffer(x),this.gridSegments=s.SegmentVector.simpleSegment(0,0,g.length,x.length),this.gridNoSkirtSegments=s.SegmentVector.simpleSegment(0,0,g.length,b),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ml(u.map),this.orthoMatrix=s.create(),s.ortho(this.orthoMatrix,0,s.EXTENT,0,s.EXTENT,0,1);const P=S.gl;this._overlapStencilMode=new s.StencilMode({func:P.GEQUAL,mask:255},0,255,P.KEEP,P.KEEP,P.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=u,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new wl(u.map)}set style(r){r.on("data",this._onStyleDataEvent.bind(this)),r.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=r,this._checkRenderCacheEfficiency()}update(r,u,g){if(r&&r.terrain){this._style!==r&&(this.style=r),this.enabled=!0;const x=r.terrain.properties;this.sourceCache=r.terrain.drapeRenderMode===0?this._mockSourceCache:r._getSourceCache(x.get("source")),this._exaggeration=x.get("exaggeration");const b=()=>{this.sourceCache.used&&s.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
  3860. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const S=this.getScaledDemTileSize();this.sourceCache.update(u,S,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,b(),this._initializing=!0),b(),u.updateElevation(!g),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(u),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(r){this._findCoveringTileCache[r]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const r=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||r.efficiency!==100&&s.warnOnce(`Terrain render cache efficiency is not optimal (${r.efficiency}%) and performance
  3861. may be affected negatively, consider placing all background, fill and line layers before layer
  3862. with id '${r.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(r){r.coord&&r.dataType==="source"?this._clearRenderCacheForTile(r.sourceCacheId,r.coord):r.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const r in this._style._sourceCaches)this._style._sourceCaches[r].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(r=>r.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const r=2*this.proxySourceCache.getSource().tileSize;return[r,r]}set useVertexMorphing(r){this._useVertexMorphing=r}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const u=this.proxySourceCache,g=this.painter.transform;this._initializing&&(this._initializing=g._centerAltitude===0&&this.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(g.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const x=this.proxyCoords=u.getIds().map(z=>{const F=u.getTileByID(z).tileID;return F.projMatrix=g.calculateProjMatrix(F.toUnwrapped()),F});(function(z,F){const N=F.transform.pointCoordinate(F.transform.getCameraPoint()),H=new s.pointGeometry(N.x,N.y);z.sort((J,re)=>{if(re.overscaledZ-J.overscaledZ)return re.overscaledZ-J.overscaledZ;const Q=new s.pointGeometry(J.canonical.x+(1<<J.canonical.z)*J.wrap,J.canonical.y),X=new s.pointGeometry(re.canonical.x+(1<<re.canonical.z)*re.wrap,re.canonical.y),Ae=H.mult(1<<J.canonical.z);return Ae.x-=.5,Ae.y-=.5,Ae.distSqr(Q)-Ae.distSqr(X)})})(x,this.painter),this._previousZoom=g.zoom;const b=this.proxyToSource||{};this.proxyToSource={},x.forEach(z=>{this.proxyToSource[z.key]={}}),this.terrainTileForTile={};const S=this._style._sourceCaches;for(const z in S){const F=S[z];if(!F.used||(F!==this.sourceCache&&this.resetTileLookupCache(F.id),this._setupProxiedCoordsForOrtho(F,r[z],b),F.usedForTerrain))continue;const N=r[z];F.getSource().reparseOverscaled&&this._assignTerrainTiles(N)}this.proxiedCoords[u.id]=x.map(z=>new Ld(z,z.key,this.orthoMatrix)),this._assignTerrainTiles(x),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(b),this.renderingToTexture=!1,this._updateTimestamp=s.exported.now();const P={};this._visibleDemTiles=[];for(const z of this.proxyCoords){const F=this.terrainTileForTile[z.key];if(!F)continue;const N=F.tileID.key;N in P||(this._visibleDemTiles.push(F),P[N]=N)}}_assignTerrainTiles(r){this._initializing||r.forEach(u=>{if(this.terrainTileForTile[u.key])return;const g=this._findTileCoveringTileID(u,this.sourceCache);g&&(this.terrainTileForTile[u.key]=g)})}_prepareDEMTextures(){const r=this.painter.context,u=r.gl;for(const g in this.terrainTileForTile){const x=this.terrainTileForTile[g],b=x.dem;!b||x.demTexture&&!x.needsDEMTextureUpload||(r.activeTexture.set(u.TEXTURE1),Ed(this.painter,x,b))}}_prepareDemTileUniforms(r,u,g,x){if(!u||u.demTexture==null)return!1;const b=r.tileID.canonical,S=Math.pow(2,u.tileID.canonical.z-b.z),P=x||"";return g[`u_dem_tl${P}`]=[b.x*S%1,b.y*S%1],g[`u_dem_scale${P}`]=S,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,u=r.gl;if(!this._emptyDepthBufferTexture){const g=new s.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new s.Texture(r,g,u.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let r=0;const u=this._visibleDemTiles.reduce((g,x)=>{if(!x.dem)return g;const b=x.dem.tree.minimums[0];return b>0&&r++,g+b},0);return r?u/r:0}_updateEmptyDEMTexture(){const r=this.painter.context,u=r.gl;r.activeTexture.set(u.TEXTURE2);const g=this._getLoadedAreaMinimum(),x=new s.RGBAImage({width:1,height:1},new Uint8Array(s.DEMData.pack(g,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(x,{premultiply:!1}):b=this._emptyDEMTexture=new s.Texture(r,x,u.RGBA,{premultiply:!1}),b}setupElevationDraw(r,u,g){const x=this.painter.context,b=x.gl,S=(P=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:s.DEMData.getUnpackVector(P),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var P;S.u_dem_size=this.sourceCache.getSource().tileSize,S.u_exaggeration=this.exaggeration();const z=this.painter.transform,F=z.projection,N=r.tileID.canonical;S.u_tile_tl_up=F.upVector(N,0,0),S.u_tile_tr_up=F.upVector(N,s.EXTENT,0),S.u_tile_br_up=F.upVector(N,s.EXTENT,s.EXTENT),S.u_tile_bl_up=F.upVector(N,0,s.EXTENT),S.u_tile_up_scale=g&&g.useDenormalizedUpVectorScale?By:F.upVectorScale(N,z.center.lat,z.worldSize).metersToTile;let H=null,J=null,re=1;if(g&&g.morphing&&this._useVertexMorphing){const Q=g.morphing.srcDemTile,X=g.morphing.dstDemTile;re=g.morphing.phase,Q&&X&&(this._prepareDemTileUniforms(r,Q,S,"_prev")&&(J=Q),this._prepareDemTileUniforms(r,X,S)&&(H=X))}if(J&&H?(x.activeTexture.set(b.TEXTURE2),H.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),x.activeTexture.set(b.TEXTURE4),J.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),S.u_dem_lerp=re):(H=this.terrainTileForTile[r.tileID.key],x.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(r,H,S)?H.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),x.activeTexture.set(b.TEXTURE3),g&&g.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),this._depthFBO&&(S.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),S.u_depth_size_inv=[1,1]),g&&g.useMeterToDem&&H){const Q=(1<<H.tileID.canonical.z)*s.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;S.u_meter_to_dem=Q}g&&g.labelPlaneMatrixInv&&(S.u_label_plane_matrix_inv=g.labelPlaneMatrixInv),u.setTerrainUniformValues(x,S)}renderToBackBuffer(r){const u=this.painter,g=this.painter.context;r.length!==0&&(g.bindFramebuffer.set(null),g.viewport.set([0,0,u.width,u.height]),this.renderingToTexture=!1,function(x,b,S,P,z){if(x.transform.projection.name==="globe")(function(F,N,H,J,re){const Q=F.context,X=Q.gl;let Ae,fe;const Te=F.options.showTerrainWireframe?2:0,Se=(ut,Rt)=>{if(fe===ut)return;const et=[Ms[ut],"PROJECTION_GLOBE_VIEW"];Rt&&et.push(Ms[Te]),Ae=F.useProgram("globeRaster",null,et),fe=ut},Re=F.colorModeForRenderPass(),be=new s.DepthMode(X.LEQUAL,s.DepthMode.ReadWrite,F.depthRangeFor3D);ao.update(re);const Fe=F.transform,Qe=s.calculateGlobeMercatorMatrix(Fe),at=[s.mercatorXfromLng(Fe.center.lng),s.mercatorYfromLat(Fe.center.lat)],dt=F.globeSharedBuffers;if((Te?[!1,!0]:[!1]).forEach(ut=>{fe=-1;const Rt=ut?X.LINES:X.TRIANGLES;for(const et of J){const zt=H.getTile(et),Pt=s.StencilMode.disabled,Jt=N.prevTerrainTileForTile[et.key],pt=N.terrainTileForTile[et.key];du(Jt,pt)&&ao.newMorphing(et.key,Jt,pt,re,250),Q.activeTexture.set(X.TEXTURE0),zt.texture.bind(X.LINEAR,X.CLAMP_TO_EDGE);const qt=ao.getMorphValuesForProxy(et.key),mn=qt?1:0,Xt={useDenormalizedUpVectorScale:!0};qt&&s.extend$1(Xt,{morphing:{srcDemTile:qt.from,dstDemTile:qt.to,phase:s.easeCubicInOut(qt.phase)}});const Yt=Float32Array.from(Fe.globeMatrix),vn=s.globeTileLatLngCorners(et.canonical),kn=s.getGridMatrix(et.canonical,vn),hn=Sm(Fe.projMatrix,Yt,Qe,s.globeToMercatorTransition(Fe.zoom),at,kn);if(Se(mn,ut),N.setupElevationDraw(zt,Ae,Xt),F.prepareDrawProgram(Q,Ae,et.toUnwrapped()),dt){const[Mn,qn,vi]=ut?dt.getWirefameBuffers(F.context):dt.getGridBuffers();Ae.draw(Q,Rt,be,Pt,Re,s.CullFaceMode.backCCW,hn,"globe_raster",Mn,qn,vi)}}}),dt){Ae=F.useProgram("globeRaster",null,["GLOBE_POLES","PROJECTION_GLOBE_VIEW"]);for(const ut of J){const{x:Rt,y:et,z:zt}=ut.canonical,Pt=et===0,Jt=et===(1<<zt)-1,[pt,qt,mn,Xt]=dt.getPoleBuffers(zt);if(Xt&&(Pt||Jt)){const Yt=H.getTile(ut);Q.activeTexture.set(X.TEXTURE0),Yt.texture.bind(X.LINEAR,X.CLAMP_TO_EDGE);let vn=s.globePoleMatrixForTile(zt,Rt,Fe);const kn=(hn,Mn)=>hn.draw(Q,X.TRIANGLES,be,s.StencilMode.disabled,Re,s.CullFaceMode.disabled,Sm(Fe.projMatrix,vn,vn,0,at),"globe_pole_raster",Mn,mn,Xt);N.setupElevationDraw(Yt,Ae,{}),F.prepareDrawProgram(Q,Ae,ut.toUnwrapped()),Pt&&kn(Ae,pt),Jt&&(vn=s.scale(s.create(),vn,[1,-1,1]),kn(Ae,qt))}}}})(x,b,S,P,z);else{const F=x.context,N=F.gl;let H,J;const re=x.options.showTerrainWireframe?2:0,Q=(Se,Re)=>{if(J===Se)return;const be=[Ms[Se]];Re&&be.push(Ms[re]),H=x.useProgram("terrainRaster",null,be),J=Se},X=x.colorModeForRenderPass(),Ae=new s.DepthMode(N.LEQUAL,s.DepthMode.ReadWrite,x.depthRangeFor3D);ao.update(z);const fe=x.transform,Te=6*Math.pow(1.5,22-fe.zoom)*b.exaggeration();(re?[!1,!0]:[!1]).forEach(Se=>{J=-1;const Re=Se?N.LINES:N.TRIANGLES,[be,Fe]=Se?b.getWirefameBuffer():[b.gridIndexBuffer,b.gridSegments];for(const Qe of P){const at=S.getTile(Qe),dt=s.StencilMode.disabled,ut=b.prevTerrainTileForTile[Qe.key],Rt=b.terrainTileForTile[Qe.key];du(ut,Rt)&&ao.newMorphing(Qe.key,ut,Rt,z,250),F.activeTexture.set(N.TEXTURE0),at.texture.bind(N.LINEAR,N.CLAMP_TO_EDGE,N.LINEAR_MIPMAP_NEAREST);const et=ao.getMorphValuesForProxy(Qe.key),zt=et?1:0;let Pt;et&&(Pt={morphing:{srcDemTile:et.from,dstDemTile:et.to,phase:s.easeCubicInOut(et.phase)}});const Jt=Em(Qe.projMatrix,Cd(Qe.canonical,fe.renderWorldCopies)?Te/10:Te);Q(zt,Se),b.setupElevationDraw(at,H,Pt),x.prepareDrawProgram(F,H,Qe.toUnwrapped()),H.draw(F,Re,Ae,dt,X,s.CullFaceMode.backCCW,Jt,"terrain_raster",b.gridBuffer,be,Fe)}})}}(u,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,r.splice(0,r.length))}renderBatch(r){if(this._drapedRenderBatches.length===0)return r+1;this.renderingToTexture=!0;const u=this.painter,g=this.painter.context,x=this.proxySourceCache,b=this.proxiedCoords[x.id],S=this._drapedRenderBatches.shift(),P=[],z=u.style.order;let F=0;for(const N of b){const H=x.getTileByID(N.proxyTileKey),J=x.proxyCachedFBO[N.key]?x.proxyCachedFBO[N.key][r]:void 0,re=J!==void 0?x.renderCache[J]:this.pool[F++],Q=J!==void 0;if(H.texture=re.tex,Q&&!re.dirty){P.push(H.tileID);continue}let X;g.bindFramebuffer.set(re.fb.framebuffer),this.renderedToTile=!1,re.dirty&&(g.clear({color:s.Color.transparent,stencil:0}),re.dirty=!1);for(let Ae=S.start;Ae<=S.end;++Ae){const fe=u.style._layers[z[Ae]];if(fe.isHidden(u.transform.zoom))continue;const Te=u.style._getLayerSourceCache(fe),Se=Te?this.proxyToSource[N.key][Te.id]:[N];if(!Se)continue;const Re=Se;g.viewport.set([0,0,re.fb.width,re.fb.height]),X!==(Te?Te.id:null)&&(this._setupStencil(re,Se,fe,Te),X=Te?Te.id:null),u.renderLayer(u,Te,fe,Re)}this.renderedToTile?(re.dirty=!0,P.push(H.tileID)):Q||--F,F===5&&(F=0,this.renderToBackBuffer(P))}return this.renderToBackBuffer(P),this.renderingToTexture=!1,g.bindFramebuffer.set(null),g.viewport.set([0,0,u.width,u.height]),S.end+1}postRender(){}renderCacheEfficiency(r){const u=r.order.length;if(u===0)return{efficiency:100};let g,x=0,b=0,S=!1;for(let P=0;P<u;++P){const z=r._layers[r.order[P]];this._style.isLayerDraped(z)?(S&&++x,++b):S||(S=!0,g=z.id)}return b===0?{efficiency:100}:{efficiency:100*(1-x/b),firstUndrapedLayer:g}}getMinElevationBelowMSL(){let r=0;return this._visibleDemTiles.filter(u=>u.dem).forEach(u=>{r=Math.min(r,u.dem.tree.minimums[0])}),r===0?r:(r-30)*this._exaggeration}raycast(r,u,g){if(!this._visibleDemTiles)return null;const x=this._visibleDemTiles.filter(b=>b.dem).map(b=>{const S=b.tileID,P=Math.pow(2,S.overscaledZ),{x:z,y:F}=S.canonical,N=z/P,H=(z+1)/P,J=F/P,re=(F+1)/P;return{minx:N,miny:J,maxx:H,maxy:re,t:b.dem.tree.raycastRoot(N,J,H,re,r,u,g),tile:b}});x.sort((b,S)=>(b.t!==null?b.t:Number.MAX_VALUE)-(S.t!==null?S.t:Number.MAX_VALUE));for(const b of x){if(b.t==null)return null;const S=b.tile.dem.tree.raycast(b.minx,b.miny,b.maxx,b.maxy,r,u,g);if(S!=null)return S}return null}_createFBO(){const r=this.painter.context,u=r.gl,g=this.drapeBufferSize;r.activeTexture.set(u.TEXTURE0);const x=new s.Texture(r,{width:g[0],height:g[1],data:null},u.RGBA);x.bind(u.LINEAR,u.CLAMP_TO_EDGE);const b=r.createFramebuffer(g[0],g[1],!1);return b.colorAttachment.set(x.texture),b.depthAttachment=new Sr(r,b.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,g[0],g[1]),this._stencilRef=0,b.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):b.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&!r.extTextureFilterAnisotropicForceOff&&u.texParameterf(u.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:b,tex:x,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const r in this._style._sourceCaches)if(this._style._sourceCaches[r].hasTransition())return!0;return this._style.order.some(r=>{const u=this._style._layers[r],g=u.isHidden(this.painter.transform.zoom),x=u.getCrossfadeParameters(),b=!!x&&x.t!==1,S=u.hasTransition();return u.type!=="custom"&&!g&&(b||S)})}_clearRasterFadeFromRenderCache(){let r=!1;for(const u in this._style._sourceCaches)if(this._style._sourceCaches[u]._source instanceof Z){r=!0;break}if(r)for(let u=0;u<this._style.order.length;++u){const g=this._style._layers[this._style.order[u]],x=g.isHidden(this.painter.transform.zoom),b=this._style._getLayerSourceCache(g);if(g.type!=="raster"||x||!b)continue;const S=g.paint.get("raster-fade-duration");for(const P of this.proxyCoords){const z=this.proxyToSource[P.key][b.id];if(z)for(const F of z){const N=Pd(b.getTile(F),b.findLoadedParent(F,0),b,this.painter.transform,S);(N.opacity!==1||N.mix!==0)&&this._clearRenderCacheForTile(b.id,F)}}}}_setupDrapedRenderBatches(){const r=this._style.order,u=r.length;if(u===0)return;const g=[];let x,b=0,S=this._style._layers[r[b]];for(;!this._style.isLayerDraped(S)&&S.isHidden(this.painter.transform.zoom)&&++b<u;)S=this._style._layers[r[b]];for(;b<u;++b){const P=this._style._layers[r[b]];P.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(P)?x===void 0&&(x=b):x!==void 0&&(g.push({start:x,end:b-1}),x=void 0))}x!==void 0&&g.push({start:x,end:b-1}),this._drapedRenderBatches=g}_setupRenderCache(r){const u=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,u.renderCache.length>u.renderCachePool.length){const S=Object.values(u.proxyCachedFBO);u.proxyCachedFBO={};for(let P=0;P<S.length;++P){const z=Object.values(S[P]);u.renderCachePool.push(...z)}}return}this._clearRasterFadeFromRenderCache();const g=this.proxyCoords,x=this._tilesDirty;for(let S=g.length-1;S>=0;S--){const P=g[S];if(u.getTileByID(P.key),u.proxyCachedFBO[P.key]!==void 0){const z=r[P.key],F=this.proxyToSource[P.key];let N=0;for(const H in F){const J=F[H],re=z[H];if(!re||re.length!==J.length||J.some((Q,X)=>Q!==re[X]||x[H]&&x[H].hasOwnProperty(Q.key))){N=-1;break}++N}for(const H in u.proxyCachedFBO[P.key])u.renderCache[u.proxyCachedFBO[P.key][H]].dirty=N<0||N!==Object.values(z).length}}const b=[...this._drapedRenderBatches];b.sort((S,P)=>P.end-P.start-(S.end-S.start));for(const S of b)for(const P of g){if(u.proxyCachedFBO[P.key])continue;let z=u.renderCachePool.pop();z===void 0&&u.renderCache.length<50&&(z=u.renderCache.length,u.renderCache.push(this._createFBO())),z!==void 0&&(u.proxyCachedFBO[P.key]={},u.proxyCachedFBO[P.key][S.start]=z,u.renderCache[z].dirty=!0)}this._tilesDirty={}}_setupStencil(r,u,g,x){if(!x||!this._sourceTilesOverlap[x.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const b=this.painter.context,S=b.gl;if(u.length<=1)return void(this._overlapStencilType=!1);let P;if(g.isTileClipped())P=u.length,this._overlapStencilMode.test={func:S.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(u[0].overscaledZ>u[u.length-1].overscaledZ))return void(this._overlapStencilType=!1);P=1,this._overlapStencilMode.test={func:S.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+P>255&&(b.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=P,this._overlapStencilMode.ref=this._stencilRef,g.isTileClipped()&&this._renderTileClippingMasks(u,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(r.key)||0),this._overlapStencilMode):s.StencilMode.disabled}_renderTileClippingMasks(r,u){const g=this.painter,x=this.painter.context,b=x.gl;g._tileClippingMaskIDs.clear(),x.setColorMode(s.ColorMode.disabled),x.setDepthMode(s.DepthMode.disabled);const S=g.useProgram("clippingMask");for(const P of r){const z=--u;g._tileClippingMaskIDs.set(P.key,z),S.draw(x,b.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:b.ALWAYS,mask:0},z,255,b.KEEP,b.KEEP,b.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,pu(P.projMatrix),"$clipping",g.tileExtentBuffer,g.quadTriangleIndexBuffer,g.tileExtentSegments)}}pointCoordinate(r){const u=this.painter.transform;if(r.x<0||r.x>u.width||r.y<0||r.y>u.height)return null;const g=[r.x,r.y,1,1];s.transformMat4$1(g,g,u.pixelMatrixInverse),s.scale$1(g,g,1/g[3]),g[0]/=u.worldSize,g[1]/=u.worldSize;const x=u._camera.position,b=s.mercatorZfromAltitude(1,u.center.lat),S=[x[0],x[1],x[2]/b,0],P=s.subtract([],g.slice(0,3),S);s.normalize(P,P);const z=this.raycast(S,P,this._exaggeration);return z!==null&&z?(s.scaleAndAdd(S,S,P,z),S[3]=S[2],S[2]*=b,S):null}drawDepth(){const r=this.painter,u=r.context,g=this.proxySourceCache,x=Math.ceil(r.width),b=Math.ceil(r.height);if(!this._depthFBO||this._depthFBO.width===x&&this._depthFBO.height===b||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const S=u.gl,P=u.createFramebuffer(x,b,!0);u.activeTexture.set(S.TEXTURE0);const z=new s.Texture(u,{width:x,height:b,data:null},S.RGBA);z.bind(S.NEAREST,S.CLAMP_TO_EDGE),P.colorAttachment.set(z.texture);const F=u.createRenderbuffer(u.gl.DEPTH_COMPONENT16,x,b);P.depthAttachment.set(F),this._depthFBO=P,this._depthTexture=z}u.bindFramebuffer.set(this._depthFBO.framebuffer),u.viewport.set([0,0,x,b]),function(S,P,z,F){if(S.transform.projection.name==="globe")return;const N=S.context,H=N.gl;N.clear({depth:1});const J=S.useProgram("terrainDepth"),re=new s.DepthMode(H.LESS,s.DepthMode.ReadWrite,S.depthRangeFor3D);for(const Q of F){const X=z.getTile(Q),Ae=Em(Q.projMatrix,0);P.setupElevationDraw(X,J),J.draw(N,H.TRIANGLES,re,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.backCCW,Ae,"terrain_depth",P.gridBuffer,P.gridIndexBuffer,P.gridNoSkirtSegments)}}(r,this,g,this.proxyCoords)}_setupProxiedCoordsForOrtho(r,u,g){if(r.getSource()instanceof Ge)return this._setupProxiedCoordsForImageSource(r,u,g);this._findCoveringTileCache[r.id]=this._findCoveringTileCache[r.id]||{};const x=this.proxiedCoords[r.id]=[],b=this.proxyCoords;for(let P=0;P<b.length;P++){const z=b[P],F=this._findTileCoveringTileID(z,r);if(F){const N=this._createProxiedId(z,F,g[z.key]&&g[z.key][r.id]);x.push(N),this.proxyToSource[z.key][r.id]=[N]}}let S=!1;for(let P=0;P<u.length;P++){const z=r.getTile(u[P]);if(!z||!z.hasData())continue;const F=this._findTileCoveringTileID(z.tileID,this.proxySourceCache);if(F&&F.tileID.canonical.z!==z.tileID.canonical.z){const N=this.proxyToSource[F.tileID.key][r.id],H=this._createProxiedId(F.tileID,z,g[F.tileID.key]&&g[F.tileID.key][r.id]);N?N.splice(N.length-1,0,H):this.proxyToSource[F.tileID.key][r.id]=[H],x.push(H),S=!0}}this._sourceTilesOverlap[r.id]=S}_setupProxiedCoordsForImageSource(r,u,g){if(!r.getSource().loaded())return;const x=this.proxiedCoords[r.id]=[],b=this.proxyCoords,S=r.getSource(),P=new s.pointGeometry(S.tileID.x,S.tileID.y)._div(1<<S.tileID.z),z=S.coordinates.map(s.MercatorCoordinate.fromLngLat).reduce((N,H)=>(N.min.x=Math.min(N.min.x,H.x-P.x),N.min.y=Math.min(N.min.y,H.y-P.y),N.max.x=Math.max(N.max.x,H.x-P.x),N.max.y=Math.max(N.max.y,H.y-P.y),N),{min:new s.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new s.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),F=(N,H)=>{const J=N.wrap+N.canonical.x/(1<<N.canonical.z),re=N.canonical.y/(1<<N.canonical.z),Q=s.EXTENT/(1<<N.canonical.z),X=H.wrap+H.canonical.x/(1<<H.canonical.z),Ae=H.canonical.y/(1<<H.canonical.z);return J+Q<X+z.min.x||J>X+z.max.x||re+Q<Ae+z.min.y||re>Ae+z.max.y};for(let N=0;N<b.length;N++){const H=b[N];for(let J=0;J<u.length;J++){const re=r.getTile(u[J]);if(!re||!re.hasData()||F(H,re.tileID))continue;const Q=this._createProxiedId(H,re,g[H.key]&&g[H.key][r.id]),X=this.proxyToSource[H.key][r.id];X?X.push(Q):this.proxyToSource[H.key][r.id]=[Q],x.push(Q)}}}_createProxiedId(r,u,g){let x=this.orthoMatrix;if(g){const b=g.find(S=>S.key===u.tileID.key);if(b)return b}if(u.tileID.key!==r.key){const b=r.canonical.z-u.tileID.canonical.z;let S,P,z;x=s.create();const F=u.tileID.wrap-r.wrap<<r.overscaledZ;b>0?(S=s.EXTENT>>b,P=S*((u.tileID.canonical.x<<b)-r.canonical.x+F),z=S*((u.tileID.canonical.y<<b)-r.canonical.y)):(S=s.EXTENT<<-b,P=s.EXTENT*(u.tileID.canonical.x-(r.canonical.x+F<<-b)),z=s.EXTENT*(u.tileID.canonical.y-(r.canonical.y<<-b))),s.ortho(x,0,S,0,S,0,1),s.translate(x,x,[P,z,0])}return new Ld(u.tileID,r.key,x)}_findTileCoveringTileID(r,u){let g=u.getTile(r);if(g&&g.hasData())return g;const x=this._findCoveringTileCache[u.id],b=x[r.key];if(g=b?u.getTileByID(b):null,g&&g.hasData()||b===null)return g;let S=g?g.tileID:r,P=S.overscaledZ;const z=u.getSource().minzoom,F=[];if(!b){const H=u.getSource().maxzoom;if(r.canonical.z>=H){const J=r.canonical.z-H;u.getSource().reparseOverscaled?(P=Math.max(r.canonical.z+2,u.transform.tileZoom),S=new s.OverscaledTileID(P,r.wrap,H,r.canonical.x>>J,r.canonical.y>>J)):J!==0&&(P=H,S=new s.OverscaledTileID(P,r.wrap,H,r.canonical.x>>J,r.canonical.y>>J))}S.key!==r.key&&(F.push(S.key),g=u.getTile(S))}const N=H=>{F.forEach(J=>{x[J]=H}),F.length=0};for(P-=1;P>=z&&(!g||!g.hasData());P--){g&&N(g.tileID.key);const H=S.calculateScaledKey(P);if(g=u.getTileByID(H),g&&g.hasData())break;const J=x[H];if(J===null)break;J===void 0?F.push(H):g=u.getTileByID(J)}return N(g?g.tileID.key:null),g&&g.hasData()?g:null}findDEMTileFor(r){return this.enabled?this._findTileCoveringTileID(r,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(r,u){let g=this._tilesDirty[r];g||(g=this._tilesDirty[r]={}),g[u.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const r=function(u){let g=0;const x=new s.StructArrayLayout2ui4,b=131;for(let S=1;S<129;S++){for(let P=1;P<129;P++)g=S*b+P,x.emplaceBack(g,g+1),x.emplaceBack(g,g+b),x.emplaceBack(g+1,g+b),S===128&&x.emplaceBack(g+b,g+b+1);x.emplaceBack(g+1,g+1+b)}return x}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(r),this.wireframeSegments=s.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function fu(f){const r=[];for(let u=0;u<f.length;u++){if(f[u]===null)continue;const g=f[u].split(" ");r.push(g.pop())}return r}class Tl{static cacheKey(r,u,g){let x=`${r}${g?g.cacheKey:""}`;for(const b of u)x+=`/${b}`;return x}constructor(r,u,g,x,b,S){const P=r.gl;this.program=P.createProgram();const z=fu(g.staticAttributes),F=x?x.getBinderAttributes():[],N=z.concat(F),H=g.staticUniforms?fu(g.staticUniforms):[],J=x?x.getBinderUniforms():[],re=H.concat(J),Q=[];for(const be of re)Q.indexOf(be)<0&&Q.push(be);let X=x?x.defines():[];X=X.concat(S.map(be=>`#define ${be}`));const Ae=X.concat(`
  3863. #ifdef GL_ES
  3864. precision mediump float;
  3865. #else
  3866. #if !defined(lowp)
  3867. #define lowp
  3868. #endif
  3869. #if !defined(mediump)
  3870. #define mediump
  3871. #endif
  3872. #if !defined(highp)
  3873. #define highp
  3874. #endif
  3875. #endif`,xl,uu.fragmentSource,ro.fragmentSource,g.fragmentSource).join(`
  3876. `),fe=X.concat(`
  3877. #ifdef GL_ES
  3878. precision highp float;
  3879. #else
  3880. #if !defined(lowp)
  3881. #define lowp
  3882. #endif
  3883. #if !defined(mediump)
  3884. #define mediump
  3885. #endif
  3886. #if !defined(highp)
  3887. #define highp
  3888. #endif
  3889. #endif`,xl,uu.vertexSource,ro.vertexSource,Uo.vertexSource,g.vertexSource).join(`
  3890. `),Te=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);P.shaderSource(Te,Ae),P.compileShader(Te),P.attachShader(this.program,Te);const Se=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);P.shaderSource(Se,fe),P.compileShader(Se),P.attachShader(this.program,Se),this.attributes={};const Re={};this.numAttributes=N.length;for(let be=0;be<this.numAttributes;be++)N[be]&&(P.bindAttribLocation(this.program,be,N[be]),this.attributes[N[be]]=be);P.linkProgram(this.program),P.deleteShader(Se),P.deleteShader(Te);for(let be=0;be<Q.length;be++){const Fe=Q[be];if(Fe&&!Re[Fe]){const Qe=P.getUniformLocation(this.program,Fe);Qe&&(Re[Fe]=Qe)}}this.fixedUniforms=b(r,Re),this.binderUniforms=x?x.getUniforms(r,Re):[],S.indexOf("TERRAIN")!==-1&&(this.terrainUniforms=((be,Fe)=>({u_dem:new s.Uniform1i(be,Fe.u_dem),u_dem_prev:new s.Uniform1i(be,Fe.u_dem_prev),u_dem_unpack:new s.Uniform4f(be,Fe.u_dem_unpack),u_dem_tl:new s.Uniform2f(be,Fe.u_dem_tl),u_dem_scale:new s.Uniform1f(be,Fe.u_dem_scale),u_dem_tl_prev:new s.Uniform2f(be,Fe.u_dem_tl_prev),u_dem_scale_prev:new s.Uniform1f(be,Fe.u_dem_scale_prev),u_dem_size:new s.Uniform1f(be,Fe.u_dem_size),u_dem_lerp:new s.Uniform1f(be,Fe.u_dem_lerp),u_exaggeration:new s.Uniform1f(be,Fe.u_exaggeration),u_depth:new s.Uniform1i(be,Fe.u_depth),u_depth_size_inv:new s.Uniform2f(be,Fe.u_depth_size_inv),u_meter_to_dem:new s.Uniform1f(be,Fe.u_meter_to_dem),u_label_plane_matrix_inv:new s.UniformMatrix4f(be,Fe.u_label_plane_matrix_inv),u_tile_tl_up:new s.Uniform3f(be,Fe.u_tile_tl_up),u_tile_tr_up:new s.Uniform3f(be,Fe.u_tile_tr_up),u_tile_br_up:new s.Uniform3f(be,Fe.u_tile_br_up),u_tile_bl_up:new s.Uniform3f(be,Fe.u_tile_bl_up),u_tile_up_scale:new s.Uniform1f(be,Fe.u_tile_up_scale)}))(r,Re)),S.indexOf("FOG")!==-1&&(this.fogUniforms=((be,Fe)=>({u_fog_matrix:new s.UniformMatrix4f(be,Fe.u_fog_matrix),u_fog_range:new s.Uniform2f(be,Fe.u_fog_range),u_fog_color:new s.Uniform4f(be,Fe.u_fog_color),u_fog_horizon_blend:new s.Uniform1f(be,Fe.u_fog_horizon_blend),u_fog_temporal_offset:new s.Uniform1f(be,Fe.u_fog_temporal_offset)}))(r,Re))}setTerrainUniformValues(r,u){if(!this.terrainUniforms)return;const g=this.terrainUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const x in u)g[x].set(u[x])}}setFogUniformValues(r,u){if(!this.fogUniforms)return;const g=this.fogUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const x in u)g[x].location&&g[x].set(u[x])}}draw(r,u,g,x,b,S,P,z,F,N,H,J,re,Q,X,Ae){const fe=r.gl;if(this.failedToCreate)return;r.program.set(this.program),r.setDepthMode(g),r.setStencilMode(x),r.setColorMode(b),r.setCullFace(S);for(const Se of Object.keys(this.fixedUniforms))this.fixedUniforms[Se].set(P[Se]);Q&&Q.setUniforms(r,this.binderUniforms,J,{zoom:re});const Te={[fe.LINES]:2,[fe.TRIANGLES]:3,[fe.LINE_STRIP]:1}[u];for(const Se of H.get()){const Re=Se.vaos||(Se.vaos={});(Re[z]||(Re[z]=new hu)).bind(r,this,F,Q?Q.getPaintVertexBuffers():[],N,Se.vertexOffset,X,Ae),fe.drawElements(u,Se.primitiveLength*Te,fe.UNSIGNED_SHORT,Se.primitiveOffset*Te*2)}}}function El(f,r,u){const g=1/Ve(u,1,r.transform.tileZoom),x=Math.pow(2,u.tileID.overscaledZ),b=u.tileSize*Math.pow(2,r.transform.tileZoom)/x,S=b*(u.tileID.canonical.x+u.tileID.wrap*x),P=b*u.tileID.canonical.y;return{u_image:0,u_texsize:u.imageAtlasTexture.size,u_scale:[g,f.fromScale,f.toScale],u_fade:f.t,u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}const Dd=s.create(),mu=(f,r,u,g,x,b,S,P,z)=>{const F=r.style.light,N=F.properties.get("position"),H=[N.x,N.y,N.z],J=s.create$1();F.properties.get("anchor")==="viewport"&&(s.fromRotation(J,-r.transform.angle),s.transformMat3(H,H,J));const re=F.properties.get("color"),Q=r.transform,X={u_matrix:f,u_lightpos:H,u_lightintensity:F.properties.get("intensity"),u_lightcolor:[re.r,re.g,re.b],u_vertical_gradient:+u,u_opacity:g,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Dd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return Q.projection.name==="globe"&&(X.u_tile_id=[x.canonical.x,x.canonical.y,1<<x.canonical.z],X.u_zoom_transition=S,X.u_inv_rot_matrix=z,X.u_merc_center=P,X.u_up_dir=Q.projection.upVector(new s.CanonicalTileID(0,0,0),P[0]*s.EXTENT,P[1]*s.EXTENT),X.u_height_lift=b),X},gu=(f,r,u,g,x,b,S,P,z,F,N)=>{const H=mu(f,r,u,g,x,P,z,F,N),J={u_height_factor:-Math.pow(2,x.overscaledZ)/S.tileSize/8};return s.extend(H,El(b,r,S),J)},_u=f=>({u_matrix:f}),yu=(f,r,u,g)=>s.extend(_u(f),El(u,r,g)),vu=(f,r)=>({u_matrix:f,u_world:r}),Am=(f,r,u,g,x)=>s.extend(yu(f,r,u,g),{u_world:x}),Cm=s.create(),Ts=(f,r,u,g,x,b)=>{const S=f.transform,P=S.projection.name==="globe";let z;if(b.paint.get("circle-pitch-alignment")==="map")if(P){const N=s.globePixelsToTileUnits(S.zoom,r.canonical);z=Float32Array.from([N,0,0,N])}else z=S.calculatePixelsToTileUnitsMatrix(u);else z=new Float32Array([S.pixelsToGLUnits[0],0,0,S.pixelsToGLUnits[1]]);const F={u_camera_to_center_distance:S.cameraToCenterDistance,u_matrix:f.translatePosMatrix(r.projMatrix,u,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_device_pixel_ratio:s.exported.devicePixelRatio,u_extrude_scale:z,u_inv_rot_matrix:Cm,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return P&&(F.u_inv_rot_matrix=g,F.u_merc_center=x,F.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],F.u_zoom_transition=s.globeToMercatorTransition(S.zoom),F.u_up_dir=S.projection.upVector(r.canonical,x[0],x[1])),F},Fy=f=>{const r=[];return f.paint.get("circle-pitch-alignment")==="map"&&r.push("PITCH_WITH_MAP"),f.paint.get("circle-pitch-scale")==="map"&&r.push("SCALE_WITH_MAP"),r},Oy=(f,r,u)=>{const g=s.EXTENT/u.tileSize;return{u_matrix:f,u_camera_to_center_distance:r.cameraToCenterDistance,u_extrude_scale:[r.pixelsToGLUnits[0]/g,r.pixelsToGLUnits[1]/g]}},Pm=(f,r,u=1)=>({u_matrix:f,u_color:r,u_overlay:0,u_overlay_scale:u}),Ny=s.create(),Uy=(f,r,u,g,x,b,S)=>{const P=f.transform,z=P.projection.name==="globe",F=z?s.globePixelsToTileUnits(P.zoom,r.canonical):Ve(u,1,b),N={u_matrix:r.projMatrix,u_extrude_scale:F,u_intensity:S,u_inv_rot_matrix:Ny,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return z&&(N.u_inv_rot_matrix=g,N.u_merc_center=x,N.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],N.u_zoom_transition=s.globeToMercatorTransition(P.zoom),N.u_up_dir=P.projection.upVector(r.canonical,x[0],x[1])),N},Vy=(f,r,u,g,x,b,S)=>{const P=f.transform,z=P.calculatePixelsToTileUnitsMatrix(r),F={u_matrix:Vo(f,r,u,x),u_pixels_to_tile_units:z,u_device_pixel_ratio:S,u_units_to_pixels:[1/P.pixelsToGLUnits[0],1/P.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:b,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Rd(u)){const N=xu(r,f.transform);F.u_texsize=r.lineAtlasTexture.size,F.u_scale=[N,g.fromScale,g.toScale],F.u_mix=g.t}return F},Id=(f,r,u,g,x,b)=>{const S=f.transform,P=xu(r,S);return{u_matrix:Vo(f,r,u,x),u_texsize:r.imageAtlasTexture.size,u_pixels_to_tile_units:S.calculatePixelsToTileUnitsMatrix(r),u_device_pixel_ratio:b,u_image:0,u_scale:[P,g.fromScale,g.toScale],u_fade:g.t,u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function xu(f,r){return 1/Ve(f,1,r.tileZoom)}function Vo(f,r,u,g){return f.translatePosMatrix(g||r.tileID.projMatrix,r,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}function Rd(f){const r=f.paint.get("line-dasharray").value;return r.value||r.kind!=="constant"}const Lm=(f,r,u,g,x,b)=>{return{u_matrix:f,u_tl_parent:r,u_scale_parent:u,u_fade_t:g.mix,u_opacity:g.opacity*x.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:x.paint.get("raster-brightness-min"),u_brightness_high:x.paint.get("raster-brightness-max"),u_saturation_factor:(P=x.paint.get("raster-saturation"),P>0?1-1/(1.001-P):-P),u_contrast_factor:(S=x.paint.get("raster-contrast"),S>0?1/(1-S):1+S),u_spin_weights:zd(x.paint.get("raster-hue-rotate")),u_perspective_transform:b};var S,P};function zd(f){f*=Math.PI/180;const r=Math.sin(f),u=Math.cos(f);return[(2*u+1)/3,(-Math.sqrt(3)*r-u+1)/3,(Math.sqrt(3)*r-u+1)/3]}const oo=s.create(),kd=(f,r,u,g,x,b,S,P,z,F,N,H,J,re)=>{const Q=x.transform,X={u_is_size_zoom_constant:+(f==="constant"||f==="source"),u_is_size_feature_constant:+(f==="constant"||f==="camera"),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:Q.cameraToCenterDistance,u_rotate_symbol:+u,u_aspect_ratio:Q.width/Q.height,u_fade_change:x.options.fadeDuration?x.symbolFadeChange:1,u_matrix:b,u_label_plane_matrix:S,u_coord_matrix:P,u_is_text:+z,u_pitch_with_map:+g,u_texsize:F,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:oo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:oo};return Q.projection.name==="globe"&&(X.u_tile_id=[N.canonical.x,N.canonical.y,1<<N.canonical.z],X.u_zoom_transition=H,X.u_inv_rot_matrix=re,X.u_merc_center=J,X.u_camera_forward=Q._camera.forward(),X.u_ecef_origin=s.globeECEFOrigin(Q.globeMatrix,N.toUnwrapped()),X.u_tile_matrix=Float32Array.from(Q.globeMatrix)),X},Go=(f,r,u,g,x,b,S,P,z,F,N,H,J,re,Q)=>{const{cameraToCenterDistance:X,_pitch:Ae}=x.transform;return s.extend(kd(f,r,u,g,x,b,S,P,z,F,H,J,re,Q),{u_gamma_scale:g?X*Math.cos(x.terrain?0:Ae):1,u_device_pixel_ratio:s.exported.devicePixelRatio,u_is_halo:+N})},Es=(f,r,u,g,x,b,S,P,z,F,N,H,J,re)=>s.extend(Go(f,r,u,g,x,b,S,P,!0,z,!0,N,H,J,re),{u_texsize_icon:F,u_texture_icon:1}),Dm=(f,r,u)=>({u_matrix:f,u_opacity:r,u_color:u}),Bd=(f,r,u,g,x,b)=>s.extend(function(S,P,z,F){const N=z.imageManager.getPattern(S.from.toString()),H=z.imageManager.getPattern(S.to.toString()),{width:J,height:re}=z.imageManager.getPixelSize(),Q=Math.pow(2,F.tileID.overscaledZ),X=F.tileSize*Math.pow(2,z.transform.tileZoom)/Q,Ae=X*(F.tileID.canonical.x+F.tileID.wrap*Q),fe=X*F.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:N.tl,u_pattern_br_a:N.br,u_pattern_tl_b:H.tl,u_pattern_br_b:H.br,u_texsize:[J,re],u_mix:P.t,u_pattern_size_a:N.displaySize,u_pattern_size_b:H.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/Ve(F,1,z.transform.tileZoom),u_pixel_coord_upper:[Ae>>16,fe>>16],u_pixel_coord_lower:[65535&Ae,65535&fe]}}(g,b,u,x),{u_matrix:f,u_opacity:r}),Qn={fillExtrusion:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_lightpos:new s.Uniform3f(f,r.u_lightpos),u_lightintensity:new s.Uniform1f(f,r.u_lightintensity),u_lightcolor:new s.Uniform3f(f,r.u_lightcolor),u_vertical_gradient:new s.Uniform1f(f,r.u_vertical_gradient),u_opacity:new s.Uniform1f(f,r.u_opacity),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_up_dir:new s.Uniform3f(f,r.u_up_dir),u_height_lift:new s.Uniform1f(f,r.u_height_lift)}),fillExtrusionPattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_lightpos:new s.Uniform3f(f,r.u_lightpos),u_lightintensity:new s.Uniform1f(f,r.u_lightintensity),u_lightcolor:new s.Uniform3f(f,r.u_lightcolor),u_vertical_gradient:new s.Uniform1f(f,r.u_vertical_gradient),u_height_factor:new s.Uniform1f(f,r.u_height_factor),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_up_dir:new s.Uniform3f(f,r.u_up_dir),u_height_lift:new s.Uniform1f(f,r.u_height_lift),u_image:new s.Uniform1i(f,r.u_image),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade),u_opacity:new s.Uniform1f(f,r.u_opacity)}),fill:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix)}),fillPattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image:new s.Uniform1i(f,r.u_image),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade)}),fillOutline:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_world:new s.Uniform2f(f,r.u_world)}),fillOutlinePattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_world:new s.Uniform2f(f,r.u_world),u_image:new s.Uniform1i(f,r.u_image),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade)}),circle:(f,r)=>({u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_extrude_scale:new s.UniformMatrix2f(f,r.u_extrude_scale),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_up_dir:new s.Uniform3f(f,r.u_up_dir)}),collisionBox:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_extrude_scale:new s.Uniform2f(f,r.u_extrude_scale)}),collisionCircle:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_inv_matrix:new s.UniformMatrix4f(f,r.u_inv_matrix),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_viewport_size:new s.Uniform2f(f,r.u_viewport_size)}),debug:(f,r)=>({u_color:new s.UniformColor(f,r.u_color),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_overlay:new s.Uniform1i(f,r.u_overlay),u_overlay_scale:new s.Uniform1f(f,r.u_overlay_scale)}),clippingMask:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix)}),heatmap:(f,r)=>({u_extrude_scale:new s.Uniform1f(f,r.u_extrude_scale),u_intensity:new s.Uniform1f(f,r.u_intensity),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_up_dir:new s.Uniform3f(f,r.u_up_dir)}),heatmapTexture:(f,r)=>({u_image:new s.Uniform1i(f,r.u_image),u_color_ramp:new s.Uniform1i(f,r.u_color_ramp),u_opacity:new s.Uniform1f(f,r.u_opacity)}),hillshade:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image:new s.Uniform1i(f,r.u_image),u_latrange:new s.Uniform2f(f,r.u_latrange),u_light:new s.Uniform2f(f,r.u_light),u_shadow:new s.UniformColor(f,r.u_shadow),u_highlight:new s.UniformColor(f,r.u_highlight),u_accent:new s.UniformColor(f,r.u_accent)}),hillshadePrepare:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_image:new s.Uniform1i(f,r.u_image),u_dimension:new s.Uniform2f(f,r.u_dimension),u_zoom:new s.Uniform1f(f,r.u_zoom),u_unpack:new s.Uniform4f(f,r.u_unpack)}),line:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_pixels_to_tile_units:new s.UniformMatrix2f(f,r.u_pixels_to_tile_units),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_units_to_pixels:new s.Uniform2f(f,r.u_units_to_pixels),u_dash_image:new s.Uniform1i(f,r.u_dash_image),u_gradient_image:new s.Uniform1i(f,r.u_gradient_image),u_image_height:new s.Uniform1f(f,r.u_image_height),u_texsize:new s.Uniform2f(f,r.u_texsize),u_scale:new s.Uniform3f(f,r.u_scale),u_mix:new s.Uniform1f(f,r.u_mix),u_alpha_discard_threshold:new s.Uniform1f(f,r.u_alpha_discard_threshold)}),linePattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_texsize:new s.Uniform2f(f,r.u_texsize),u_pixels_to_tile_units:new s.UniformMatrix2f(f,r.u_pixels_to_tile_units),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_image:new s.Uniform1i(f,r.u_image),u_units_to_pixels:new s.Uniform2f(f,r.u_units_to_pixels),u_scale:new s.Uniform3f(f,r.u_scale),u_fade:new s.Uniform1f(f,r.u_fade),u_alpha_discard_threshold:new s.Uniform1f(f,r.u_alpha_discard_threshold)}),raster:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_tl_parent:new s.Uniform2f(f,r.u_tl_parent),u_scale_parent:new s.Uniform1f(f,r.u_scale_parent),u_fade_t:new s.Uniform1f(f,r.u_fade_t),u_opacity:new s.Uniform1f(f,r.u_opacity),u_image0:new s.Uniform1i(f,r.u_image0),u_image1:new s.Uniform1i(f,r.u_image1),u_brightness_low:new s.Uniform1f(f,r.u_brightness_low),u_brightness_high:new s.Uniform1f(f,r.u_brightness_high),u_saturation_factor:new s.Uniform1f(f,r.u_saturation_factor),u_contrast_factor:new s.Uniform1f(f,r.u_contrast_factor),u_spin_weights:new s.Uniform3f(f,r.u_spin_weights),u_perspective_transform:new s.Uniform2f(f,r.u_perspective_transform)}),symbolIcon:(f,r)=>({u_is_size_zoom_constant:new s.Uniform1i(f,r.u_is_size_zoom_constant),u_is_size_feature_constant:new s.Uniform1i(f,r.u_is_size_feature_constant),u_size_t:new s.Uniform1f(f,r.u_size_t),u_size:new s.Uniform1f(f,r.u_size),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_rotate_symbol:new s.Uniform1i(f,r.u_rotate_symbol),u_aspect_ratio:new s.Uniform1f(f,r.u_aspect_ratio),u_fade_change:new s.Uniform1f(f,r.u_fade_change),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_label_plane_matrix:new s.UniformMatrix4f(f,r.u_label_plane_matrix),u_coord_matrix:new s.UniformMatrix4f(f,r.u_coord_matrix),u_is_text:new s.Uniform1i(f,r.u_is_text),u_pitch_with_map:new s.Uniform1i(f,r.u_pitch_with_map),u_texsize:new s.Uniform2f(f,r.u_texsize),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_camera_forward:new s.Uniform3f(f,r.u_camera_forward),u_tile_matrix:new s.UniformMatrix4f(f,r.u_tile_matrix),u_ecef_origin:new s.Uniform3f(f,r.u_ecef_origin),u_texture:new s.Uniform1i(f,r.u_texture)}),symbolSDF:(f,r)=>({u_is_size_zoom_constant:new s.Uniform1i(f,r.u_is_size_zoom_constant),u_is_size_feature_constant:new s.Uniform1i(f,r.u_is_size_feature_constant),u_size_t:new s.Uniform1f(f,r.u_size_t),u_size:new s.Uniform1f(f,r.u_size),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_rotate_symbol:new s.Uniform1i(f,r.u_rotate_symbol),u_aspect_ratio:new s.Uniform1f(f,r.u_aspect_ratio),u_fade_change:new s.Uniform1f(f,r.u_fade_change),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_label_plane_matrix:new s.UniformMatrix4f(f,r.u_label_plane_matrix),u_coord_matrix:new s.UniformMatrix4f(f,r.u_coord_matrix),u_is_text:new s.Uniform1i(f,r.u_is_text),u_pitch_with_map:new s.Uniform1i(f,r.u_pitch_with_map),u_texsize:new s.Uniform2f(f,r.u_texsize),u_texture:new s.Uniform1i(f,r.u_texture),u_gamma_scale:new s.Uniform1f(f,r.u_gamma_scale),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_tile_id:new s.Uniform3f(f,r.u_tile_id),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_inv_rot_matrix:new s.UniformMatrix4f(f,r.u_inv_rot_matrix),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_camera_forward:new s.Uniform3f(f,r.u_camera_forward),u_tile_matrix:new s.UniformMatrix4f(f,r.u_tile_matrix),u_ecef_origin:new s.Uniform3f(f,r.u_ecef_origin),u_is_halo:new s.Uniform1i(f,r.u_is_halo)}),symbolTextAndIcon:(f,r)=>({u_is_size_zoom_constant:new s.Uniform1i(f,r.u_is_size_zoom_constant),u_is_size_feature_constant:new s.Uniform1i(f,r.u_is_size_feature_constant),u_size_t:new s.Uniform1f(f,r.u_size_t),u_size:new s.Uniform1f(f,r.u_size),u_camera_to_center_distance:new s.Uniform1f(f,r.u_camera_to_center_distance),u_rotate_symbol:new s.Uniform1i(f,r.u_rotate_symbol),u_aspect_ratio:new s.Uniform1f(f,r.u_aspect_ratio),u_fade_change:new s.Uniform1f(f,r.u_fade_change),u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_label_plane_matrix:new s.UniformMatrix4f(f,r.u_label_plane_matrix),u_coord_matrix:new s.UniformMatrix4f(f,r.u_coord_matrix),u_is_text:new s.Uniform1i(f,r.u_is_text),u_pitch_with_map:new s.Uniform1i(f,r.u_pitch_with_map),u_texsize:new s.Uniform2f(f,r.u_texsize),u_texsize_icon:new s.Uniform2f(f,r.u_texsize_icon),u_texture:new s.Uniform1i(f,r.u_texture),u_texture_icon:new s.Uniform1i(f,r.u_texture_icon),u_gamma_scale:new s.Uniform1f(f,r.u_gamma_scale),u_device_pixel_ratio:new s.Uniform1f(f,r.u_device_pixel_ratio),u_is_halo:new s.Uniform1i(f,r.u_is_halo)}),background:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_opacity:new s.Uniform1f(f,r.u_opacity),u_color:new s.UniformColor(f,r.u_color)}),backgroundPattern:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_opacity:new s.Uniform1f(f,r.u_opacity),u_image:new s.Uniform1i(f,r.u_image),u_pattern_tl_a:new s.Uniform2f(f,r.u_pattern_tl_a),u_pattern_br_a:new s.Uniform2f(f,r.u_pattern_br_a),u_pattern_tl_b:new s.Uniform2f(f,r.u_pattern_tl_b),u_pattern_br_b:new s.Uniform2f(f,r.u_pattern_br_b),u_texsize:new s.Uniform2f(f,r.u_texsize),u_mix:new s.Uniform1f(f,r.u_mix),u_pattern_size_a:new s.Uniform2f(f,r.u_pattern_size_a),u_pattern_size_b:new s.Uniform2f(f,r.u_pattern_size_b),u_scale_a:new s.Uniform1f(f,r.u_scale_a),u_scale_b:new s.Uniform1f(f,r.u_scale_b),u_pixel_coord_upper:new s.Uniform2f(f,r.u_pixel_coord_upper),u_pixel_coord_lower:new s.Uniform2f(f,r.u_pixel_coord_lower),u_tile_units_to_pixels:new s.Uniform1f(f,r.u_tile_units_to_pixels)}),terrainRaster:Ad,terrainDepth:Ad,skybox:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_sun_direction:new s.Uniform3f(f,r.u_sun_direction),u_cubemap:new s.Uniform1i(f,r.u_cubemap),u_opacity:new s.Uniform1f(f,r.u_opacity),u_temporal_offset:new s.Uniform1f(f,r.u_temporal_offset)}),skyboxGradient:(f,r)=>({u_matrix:new s.UniformMatrix4f(f,r.u_matrix),u_color_ramp:new s.Uniform1i(f,r.u_color_ramp),u_center_direction:new s.Uniform3f(f,r.u_center_direction),u_radius:new s.Uniform1f(f,r.u_radius),u_opacity:new s.Uniform1f(f,r.u_opacity),u_temporal_offset:new s.Uniform1f(f,r.u_temporal_offset)}),skyboxCapture:(f,r)=>({u_matrix_3f:new s.UniformMatrix3f(f,r.u_matrix_3f),u_sun_direction:new s.Uniform3f(f,r.u_sun_direction),u_sun_intensity:new s.Uniform1f(f,r.u_sun_intensity),u_color_tint_r:new s.Uniform4f(f,r.u_color_tint_r),u_color_tint_m:new s.Uniform4f(f,r.u_color_tint_m),u_luminance:new s.Uniform1f(f,r.u_luminance)}),globeRaster:(f,r)=>({u_proj_matrix:new s.UniformMatrix4f(f,r.u_proj_matrix),u_globe_matrix:new s.UniformMatrix4f(f,r.u_globe_matrix),u_merc_matrix:new s.UniformMatrix4f(f,r.u_merc_matrix),u_zoom_transition:new s.Uniform1f(f,r.u_zoom_transition),u_merc_center:new s.Uniform2f(f,r.u_merc_center),u_image0:new s.Uniform1i(f,r.u_image0),u_grid_matrix:new s.UniformMatrix3f(f,r.u_grid_matrix)}),globeAtmosphere:(f,r)=>({u_frustum_tl:new s.Uniform3f(f,r.u_frustum_tl),u_frustum_tr:new s.Uniform3f(f,r.u_frustum_tr),u_frustum_br:new s.Uniform3f(f,r.u_frustum_br),u_frustum_bl:new s.Uniform3f(f,r.u_frustum_bl),u_globe_pos:new s.Uniform3f(f,r.u_globe_pos),u_globe_radius:new s.Uniform1f(f,r.u_globe_radius),u_opacity:new s.Uniform1f(f,r.u_opacity),u_fadeout_range:new s.Uniform1f(f,r.u_fadeout_range),u_start_color:new s.Uniform3f(f,r.u_start_color),u_end_color:new s.Uniform3f(f,r.u_end_color)})};let Ho;function Im(f,r,u,g,x,b,S){const P=f.context,z=P.gl,F=f.useProgram("collisionBox"),N=[];let H=0,J=0;for(let Se=0;Se<g.length;Se++){const Re=g[Se],be=r.getTile(Re),Fe=be.getBucket(u);if(!Fe)continue;let Qe=Re.projMatrix;x[0]===0&&x[1]===0||(Qe=f.translatePosMatrix(Re.projMatrix,be,x,b));const at=S?Fe.textCollisionBox:Fe.iconCollisionBox,dt=Fe.collisionCircleArray;if(dt.length>0){const ut=s.create(),Rt=Qe;s.mul(ut,Fe.placementInvProjMatrix,f.transform.glCoordMatrix),s.mul(ut,ut,Fe.placementViewportMatrix),N.push({circleArray:dt,circleOffset:J,transform:Rt,invTransform:ut}),H+=dt.length/4,J=H}at&&(f.terrain&&f.terrain.setupElevationDraw(be,F),F.draw(P,z.LINES,s.DepthMode.disabled,s.StencilMode.disabled,f.colorModeForRenderPass(),s.CullFaceMode.disabled,Oy(Qe,f.transform,be),u.id,at.layoutVertexBuffer,at.indexBuffer,at.segments,null,f.transform.zoom,null,at.collisionVertexBuffer,at.collisionVertexBufferExt))}if(!S||!N.length)return;const re=f.useProgram("collisionCircle"),Q=new s.StructArrayLayout2f1f2i16;Q.resize(4*H),Q._trim();let X=0;for(const Se of N)for(let Re=0;Re<Se.circleArray.length/4;Re++){const be=4*Re,Fe=Se.circleArray[be+0],Qe=Se.circleArray[be+1],at=Se.circleArray[be+2],dt=Se.circleArray[be+3];Q.emplace(X++,Fe,Qe,at,dt,0),Q.emplace(X++,Fe,Qe,at,dt,1),Q.emplace(X++,Fe,Qe,at,dt,2),Q.emplace(X++,Fe,Qe,at,dt,3)}(!Ho||Ho.length<2*H)&&(Ho=function(Se){const Re=2*Se,be=new s.StructArrayLayout3ui6;be.resize(Re),be._trim();for(let Fe=0;Fe<Re;Fe++){const Qe=6*Fe;be.uint16[Qe+0]=4*Fe+0,be.uint16[Qe+1]=4*Fe+1,be.uint16[Qe+2]=4*Fe+2,be.uint16[Qe+3]=4*Fe+2,be.uint16[Qe+4]=4*Fe+3,be.uint16[Qe+5]=4*Fe+0}return be}(H));const Ae=P.createIndexBuffer(Ho,!0),fe=P.createVertexBuffer(Q,s.collisionCircleLayout.members,!0);for(const Se of N){const Re={u_matrix:Se.transform,u_inv_matrix:Se.invTransform,u_camera_to_center_distance:(Te=f.transform).cameraToCenterDistance,u_viewport_size:[Te.width,Te.height]};re.draw(P,z.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,f.colorModeForRenderPass(),s.CullFaceMode.disabled,Re,u.id,fe,Ae,s.SegmentVector.simpleSegment(0,2*Se.circleOffset,Se.circleArray.length,Se.circleArray.length/2),null,f.transform.zoom,null,null,null)}var Te;fe.destroy(),Ae.destroy()}const Fd=s.create();function Sl(f,r,u,g,x,b){const{horizontalAlign:S,verticalAlign:P}=s.getAnchorAlignment(f),z=-(S-.5)*r,F=-(P-.5)*u,N=s.evaluateVariableOffset(f,g);return new s.pointGeometry((z/x+N[0])*b,(F/x+N[1])*b)}function Gy(f,r,u,g,x,b,S,P,z,F,N,H){const J=f.text.placedSymbolArray,re=f.text.dynamicLayoutVertexArray,Q=f.icon.dynamicLayoutVertexArray,X={},Ae=P.projMatrix,fe=b.elevation,Te=H.upVectorScale(P.canonical,b.center.lat,b.worldSize);re.clear();for(let Se=0;Se<J.length;Se++){const Re=J.get(Se),be=f.allowVerticalPlacement&&!Re.placedOrientation,Fe=Re.hidden||!Re.crossTileID||be?null:g[Re.crossTileID];if(Fe){const Qe=new s.pointGeometry(Re.tileAnchorX,Re.tileAnchorY),at=H.upVector(P.canonical,Qe.x,Qe.y),dt=fe?fe.getAtTileOffset(P,Qe.x,Qe.y):0,ut=li([Re.projectedAnchorX+dt*at[0]*Te.metersToTile,Re.projectedAnchorY+dt*at[1]*Te.metersToTile,Re.projectedAnchorZ+dt*at[2]*Te.metersToTile],u?Ae:S),Rt=oi(b.cameraToCenterDistance,ut.signedDistanceFromCamera);let et=x.evaluateSizeForFeature(f.textSizeData,F,Re)*Rt/s.ONE_EM;u&&(et*=f.tilePixelRatio/z);const{width:zt,height:Pt,anchor:Jt,textOffset:pt,textScale:qt}=Fe,mn=Sl(Jt,zt,Pt,pt,qt,et),Xt=u?ai(Qe.add(mn),S,dt*Te.metersToLabelSpace).point:ut.point.add(r?mn.rotate(-b.angle):mn),Yt=f.allowVerticalPlacement&&Re.placedOrientation===s.WritingMode.vertical?Math.PI/2:0;for(let vn=0;vn<Re.numGlyphs;vn++)s.addDynamicAttributes(re,Xt,Yt);N&&Re.associatedIconIndex>=0&&(X[Re.associatedIconIndex]={shiftedAnchor:Xt,angle:Yt})}else Bi(Re.numGlyphs,re)}if(N){Q.clear();const Se=f.icon.placedSymbolArray;for(let Re=0;Re<Se.length;Re++){const be=Se.get(Re);if(be.hidden)Bi(be.numGlyphs,Q);else{const Fe=X[Re];if(Fe)for(let Qe=0;Qe<be.numGlyphs;Qe++)s.addDynamicAttributes(Q,Fe.shiftedAnchor,Fe.angle);else Bi(be.numGlyphs,Q)}}f.icon.dynamicLayoutVertexBuffer.updateData(Q)}f.text.dynamicLayoutVertexBuffer.updateData(re)}function Hy(f,r,u){return u.iconsInText&&r?"symbolTextAndIcon":f?"symbolSDF":"symbolIcon"}function Od(f,r,u,g,x,b,S,P,z,F,N,H){const J=f.context,re=J.gl,Q=f.transform,X=P==="map",Ae=z==="map",fe=X&&u.layout.get("symbol-placement")!=="point",Te=X&&!Ae&&!fe,Se=u.layout.get("symbol-sort-key").constantOr(1)!==void 0;let Re=!1;const be=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),Fe=[s.mercatorXfromLng(Q.center.lng),s.mercatorYfromLat(Q.center.lat)],Qe=u.layout.get("text-variable-anchor"),at=Q.projection.name==="globe",dt=at?s.globeToMercatorTransition(Q.zoom):0,ut=[],Rt=[];f.terrain&&Ae&&Rt.push("PITCH_WITH_MAP_TERRAIN"),at&&Rt.push("PROJECTION_GLOBE_VIEW");for(const et of g){const zt=r.getTile(et),Pt=zt.getBucket(u);if(!Pt||Pt.projection!==Q.projection.name)continue;const Jt=x?Pt.text:Pt.icon;if(!Jt||Pt.fullyClipped||!Jt.segments.get().length)continue;const pt=Jt.programConfigurations.get(u.id),qt=x||Pt.sdfIcons,mn=x?Pt.textSizeData:Pt.iconSizeData,Xt=Ae||Q.pitch!==0,Yt=s.evaluateSizeForZoom(mn,Q.zoom);let vn,kn,hn,Mn,qn=[0,0],vi=null;if(x){if(kn=zt.glyphAtlasTexture,hn=re.LINEAR,vn=zt.glyphAtlasTexture.size,Pt.iconsInText){qn=zt.imageAtlasTexture.size,vi=zt.imageAtlasTexture;const kr=mn.kind==="composite"||mn.kind==="camera";Mn=Xt||f.options.rotating||f.options.zooming||kr?re.LINEAR:re.NEAREST}}else{const kr=u.layout.get("icon-size").constantOr(0)!==1||Pt.iconsNeedLinear;kn=zt.imageAtlasTexture,hn=qt||f.options.rotating||f.options.zooming||kr||Xt?re.LINEAR:re.NEAREST,vn=zt.imageAtlasTexture.size}const nr=f.transform.calculatePixelsToTileUnitsMatrix(zt),ir=di(et.projMatrix,zt.tileID.canonical,Ae,X,f.transform,nr),Rr=f.terrain&&Ae&&fe?s.invert(s.create(),ir):Fd,ma=Ar(et.projMatrix,zt.tileID.canonical,Ae,X,f.transform,nr),Ua=Qe&&Pt.hasTextData(),po=u.layout.get("icon-text-fit")!=="none"&&Ua&&Pt.hasIconData();if(fe){const kr=Q.elevation,jo=kr?kr.getAtTileOffsetFunc(et,Q.center.lat,Q.worldSize,Q.projection):lg=>[0,0,0];za(Pt,et.projMatrix,f,x,ir,ma,Ae,F,jo,et)}const Va=fe||x&&Qe||po,bi=f.translatePosMatrix(et.projMatrix,zt,b,S),Ti=Va?Fd:ir,$n=f.translatePosMatrix(ma,zt,b,S,!0),Li=Q.projection.createInversionMatrix(Q,et.canonical),zr=Va?Rt.concat(["PROJECTED_POS_ON_VIEWPORT"]):Rt,xi=qt&&u.paint.get(x?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Zr;Zr=qt?Pt.iconsInText?Es(mn.kind,Yt,Te,Ae,f,bi,Ti,$n,vn,qn,et,dt,Fe,Li):Go(mn.kind,Yt,Te,Ae,f,bi,Ti,$n,x,vn,!0,et,dt,Fe,Li):kd(mn.kind,Yt,Te,Ae,f,bi,Ti,$n,x,vn,et,dt,Fe,Li);const Gl={program:f.useProgram(Hy(qt,x,Pt),pt,zr),buffers:Jt,uniformValues:Zr,atlasTexture:kn,atlasTextureIcon:vi,atlasInterpolation:hn,atlasInterpolationIcon:Mn,isSDF:qt,hasHalo:xi,tile:zt,labelPlaneMatrixInv:Rr};if(Se&&Pt.canOverlap){Re=!0;const kr=Jt.segments.get();for(const jo of kr)ut.push({segments:new s.SegmentVector([jo]),sortKey:jo.sortKey,state:Gl})}else ut.push({segments:Jt.segments,sortKey:0,state:Gl})}Re&&ut.sort((et,zt)=>et.sortKey-zt.sortKey);for(const et of ut){const zt=et.state;if(f.terrain&&f.terrain.setupElevationDraw(zt.tile,zt.program,{useDepthForOcclusion:!at,labelPlaneMatrixInv:zt.labelPlaneMatrixInv}),J.activeTexture.set(re.TEXTURE0),zt.atlasTexture.bind(zt.atlasInterpolation,re.CLAMP_TO_EDGE),zt.atlasTextureIcon&&(J.activeTexture.set(re.TEXTURE1),zt.atlasTextureIcon&&zt.atlasTextureIcon.bind(zt.atlasInterpolationIcon,re.CLAMP_TO_EDGE)),zt.isSDF){const Pt=zt.uniformValues;zt.hasHalo&&(Pt.u_is_halo=1,Rm(zt.buffers,et.segments,u,f,zt.program,be,N,H,Pt)),Pt.u_is_halo=0}Rm(zt.buffers,et.segments,u,f,zt.program,be,N,H,zt.uniformValues)}}function Rm(f,r,u,g,x,b,S,P,z){const F=g.context;x.draw(F,F.gl.TRIANGLES,b,S,P,s.CullFaceMode.disabled,z,u.id,f.layoutVertexBuffer,f.indexBuffer,r,u.paint,g.transform.zoom,f.programConfigurations.get(u.id),f.dynamicLayoutVertexBuffer,f.opacityVertexBuffer)}function bu(f,r,u,g,x,b,S){const P=f.context.gl,z=u.paint.get("fill-pattern"),F=z&&z.constantOr(1),N=u.getCrossfadeParameters();let H,J,re,Q,X;S?(J=F&&!u.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",H=P.LINES):(J=F?"fillPattern":"fill",H=P.TRIANGLES);for(const Ae of g){const fe=r.getTile(Ae);if(F&&!fe.patternsLoaded())continue;const Te=fe.getBucket(u);if(!Te)continue;f.prepareDrawTile();const Se=Te.programConfigurations.get(u.id),Re=f.useProgram(J,Se);F&&(f.context.activeTexture.set(P.TEXTURE0),fe.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),Se.updatePaintBuffers(N));const be=z.constantOr(null);if(be&&fe.imageAtlas){const Qe=fe.imageAtlas,at=Qe.patternPositions[be.to.toString()],dt=Qe.patternPositions[be.from.toString()];at&&dt&&Se.setConstantPatternPositions(at,dt)}const Fe=f.translatePosMatrix(Ae.projMatrix,fe,u.paint.get("fill-translate"),u.paint.get("fill-translate-anchor"));if(S){Q=Te.indexBuffer2,X=Te.segments2;const Qe=f.terrain&&f.terrain.renderingToTexture?f.terrain.drapeBufferSize:[P.drawingBufferWidth,P.drawingBufferHeight];re=J==="fillOutlinePattern"&&F?Am(Fe,f,N,fe,Qe):vu(Fe,Qe)}else Q=Te.indexBuffer,X=Te.segments,re=F?yu(Fe,f,N,fe):_u(Fe);f.prepareDrawProgram(f.context,Re,Ae.toUnwrapped()),Re.draw(f.context,H,x,f.stencilModeForClipping(Ae),b,s.CullFaceMode.disabled,re,u.id,Te.layoutVertexBuffer,Q,X,u.paint,f.transform.zoom,Se)}}function Ss(f,r,u,g,x,b,S){const P=f.context,z=P.gl,F=f.transform,N=u.paint.get("fill-extrusion-pattern"),H=N.constantOr(1),J=u.getCrossfadeParameters(),re=u.paint.get("fill-extrusion-opacity"),Q=function(Se){if(Se.projection.name!=="globe")return 0;const Re=Math.PI/32,be=Math.tan(Re),Fe=s.earthRadius;return Fe*Math.sqrt(1+2*be*be)-Fe}(F),X=F.projection.name==="globe",Ae=X?s.globeToMercatorTransition(F.zoom):0,fe=[s.mercatorXfromLng(F.center.lng),s.mercatorYfromLat(F.center.lat)],Te=[];X&&Te.push("PROJECTION_GLOBE_VIEW");for(const Se of g){const Re=r.getTile(Se),be=Re.getBucket(u);if(!be||be.projection!==F.projection.name)continue;const Fe=be.programConfigurations.get(u.id),Qe=f.useProgram(H?"fillExtrusionPattern":"fillExtrusion",Fe,Te);if(f.terrain){const zt=f.terrain;if(f.style.terrainSetForDrapingOnly())zt.setupElevationDraw(Re,Qe,{useMeterToDem:!0});else{if(!be.enableTerrain)continue;if(zt.setupElevationDraw(Re,Qe,{useMeterToDem:!0}),Al(P,r,Se,be,u,zt),!be.centroidVertexBuffer){const Pt=Qe.attributes.a_centroid_pos;Pt!==void 0&&z.vertexAttrib2f(Pt,0,0)}}}H&&(f.context.activeTexture.set(z.TEXTURE0),Re.imageAtlasTexture.bind(z.LINEAR,z.CLAMP_TO_EDGE),Fe.updatePaintBuffers(J));const at=N.constantOr(null);if(at&&Re.imageAtlas){const zt=Re.imageAtlas,Pt=zt.patternPositions[at.to.toString()],Jt=zt.patternPositions[at.from.toString()];Pt&&Jt&&Fe.setConstantPatternPositions(Pt,Jt)}const dt=f.translatePosMatrix(Se.projMatrix,Re,u.paint.get("fill-extrusion-translate"),u.paint.get("fill-extrusion-translate-anchor")),ut=F.projection.createInversionMatrix(F,Se.canonical),Rt=u.paint.get("fill-extrusion-vertical-gradient"),et=H?gu(dt,f,Rt,re,Se,J,Re,Q,Ae,fe,ut):mu(dt,f,Rt,re,Se,Q,Ae,fe,ut);f.prepareDrawProgram(P,Qe,Se.toUnwrapped()),Qe.draw(P,P.gl.TRIANGLES,x,b,S,s.CullFaceMode.backCCW,et,u.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,u.paint,f.transform.zoom,Fe,f.terrain?be.centroidVertexBuffer:null,X?be.layoutVertexExtBuffer:null)}}function Al(f,r,u,g,x,b){const S=[fe=>{let Te=fe.canonical.x-1,Se=fe.wrap;return Te<0&&(Te=(1<<fe.canonical.z)-1,Se--),new s.OverscaledTileID(fe.overscaledZ,Se,fe.canonical.z,Te,fe.canonical.y)},fe=>{let Te=fe.canonical.x+1,Se=fe.wrap;return Te===1<<fe.canonical.z&&(Te=0,Se++),new s.OverscaledTileID(fe.overscaledZ,Se,fe.canonical.z,Te,fe.canonical.y)},fe=>new s.OverscaledTileID(fe.overscaledZ,fe.wrap,fe.canonical.z,fe.canonical.x,(fe.canonical.y===0?1<<fe.canonical.z:fe.canonical.y)-1),fe=>new s.OverscaledTileID(fe.overscaledZ,fe.wrap,fe.canonical.z,fe.canonical.x,fe.canonical.y===(1<<fe.canonical.z)-1?0:fe.canonical.y+1)],P=fe=>{const Te=r.getSource().minzoom,Se=be=>{const Fe=r.getTileByID(be);if(Fe&&Fe.hasData())return Fe.getBucket(x)},Re=[0,-1,1];for(const be of Re){if(fe.overscaledZ+be<Te)continue;const Fe=Se(fe.calculateScaledKey(fe.overscaledZ+be));if(Fe)return Fe}},z=[0,0,0],F=(fe,Te)=>(z[0]=Math.min(fe.min.y,Te.min.y),z[1]=Math.max(fe.max.y,Te.max.y),z[2]=s.EXTENT-Te.min.x>fe.max.x?Te.min.x-s.EXTENT:fe.max.x,z),N=(fe,Te)=>(z[0]=Math.min(fe.min.x,Te.min.x),z[1]=Math.max(fe.max.x,Te.max.x),z[2]=s.EXTENT-Te.min.y>fe.max.y?Te.min.y-s.EXTENT:fe.max.y,z),H=[(fe,Te)=>F(fe,Te),(fe,Te)=>F(Te,fe),(fe,Te)=>N(fe,Te),(fe,Te)=>N(Te,fe)],J=new s.pointGeometry(0,0);let re,Q,X;const Ae=(fe,Te,Se,Re,be)=>{const Fe=[[Re?Se:fe,Re?fe:Se,0],[Re?Se:Te,Re?Te:Se,0]],Qe=be<0?s.EXTENT+be:be,at=[Re?Qe:(fe+Te)/2,Re?(fe+Te)/2:Qe,0];return Se===0&&be<0||Se!==0&&be>0?b.getForTilePoints(X,[at],!0,Q):Fe.push(at),b.getForTilePoints(u,Fe,!0,re),Math.max(Fe[0][2],Fe[1][2],at[2])/b.exaggeration()};for(let fe=0;fe<4;fe++){const Te=(fe<2?1:5)-fe,Se=g.borders[fe];if(Se.length===0)continue;const Re=X=S[fe](u),be=P(Re);if(!(be&&be instanceof s.FillExtrusionBucket&&be.enableTerrain)||g.borderDoneWithNeighborZ[fe]===be.canonical.z&&be.borderDoneWithNeighborZ[Te]===g.canonical.z||(Q=b.findDEMTileFor(Re),!Q||!Q.dem))continue;if(!re){const dt=b.findDEMTileFor(u);if(!dt||!dt.dem)return;re=dt}const Fe=be.borders[Te];let Qe=0;const at=be.borderDoneWithNeighborZ[Te]!==g.canonical.z;if(g.canonical.z===be.canonical.z){for(let dt=0;dt<Se.length;dt++){const ut=g.featuresOnBorder[Se[dt]],Rt=ut.borders[fe];let et;for(;Qe<Fe.length&&(et=be.featuresOnBorder[Fe[Qe]],!(et.borders[Te][1]>Rt[0]+3));)at&&be.encodeCentroid(void 0,et,!1),Qe++;if(et&&Qe<Fe.length){const zt=Qe;let Pt=0;for(;!(et.borders[Te][0]>Rt[1]-3)&&(Pt++,++Qe!==Fe.length);)et=be.featuresOnBorder[Fe[Qe]];if(et=be.featuresOnBorder[Fe[zt]],ut.intersectsCount()>1||et.intersectsCount()>1||Pt!==1){Pt!==1&&(Qe=zt),g.encodeCentroid(void 0,ut,!1),at&&be.encodeCentroid(void 0,et,!1);continue}const Jt=H[fe](ut,et),pt=fe%2?s.EXTENT-1:0;J.x=Ae(Jt[0],Math.min(s.EXTENT-1,Jt[1]),pt,fe<2,Jt[2]),J.y=0,g.encodeCentroid(J,ut,!1),at&&be.encodeCentroid(J,et,!1)}else g.encodeCentroid(void 0,ut,!1)}g.borderDoneWithNeighborZ[fe]=be.canonical.z,g.needsCentroidUpdate=!0,at&&(be.borderDoneWithNeighborZ[Te]=g.canonical.z,be.needsCentroidUpdate=!0)}else{for(const dt of Se)g.encodeCentroid(void 0,g.featuresOnBorder[dt],!1);if(at){for(const dt of Fe)be.encodeCentroid(void 0,be.featuresOnBorder[dt],!1);be.borderDoneWithNeighborZ[Te]=g.canonical.z,be.needsCentroidUpdate=!0}g.borderDoneWithNeighborZ[fe]=be.canonical.z,g.needsCentroidUpdate=!0}}(g.needsCentroidUpdate||!g.centroidVertexBuffer&&g.centroidVertexArray.length!==0)&&g.uploadCentroid(f)}const Nd=new s.Color(1,0,0,1),Ud=new s.Color(0,1,0,1),zm=new s.Color(0,0,1,1),wu=new s.Color(1,0,1,1),Mu=new s.Color(0,1,1,1);function Ht(f,r,u,g){Cl(f,0,r+u/2,f.transform.width,u,g)}function jr(f,r,u,g){Cl(f,r-u/2,0,u,f.transform.height,g)}function Cl(f,r,u,g,x,b){const S=f.context,P=S.gl;P.enable(P.SCISSOR_TEST),P.scissor(r*s.exported.devicePixelRatio,u*s.exported.devicePixelRatio,g*s.exported.devicePixelRatio,x*s.exported.devicePixelRatio),S.clear({color:b}),P.disable(P.SCISSOR_TEST)}function km(f,r,u){const g=f.context,x=g.gl,b=f.transform.projection.name==="globe",S=u.projMatrix,P=f.useProgram("debug",null,b?["PROJECTION_GLOBE_VIEW"]:null),z=r.getTileByID(u.key);f.terrain&&f.terrain.setupElevationDraw(z,P);const F=s.DepthMode.disabled,N=s.StencilMode.disabled,H=f.colorModeForRenderPass(),J="$debug";g.activeTexture.set(x.TEXTURE0),f.emptyTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),b?z._makeGlobeTileDebugBuffers(f.context,f.transform.projection):z._makeDebugTileBoundsBuffers(f.context,f.transform.projection);const re=z._tileDebugBuffer||f.debugBuffer,Q=z._tileDebugIndexBuffer||f.debugIndexBuffer,X=z._tileDebugSegments||f.debugSegments;P.draw(g,x.LINE_STRIP,F,N,H,s.CullFaceMode.disabled,Pm(S,s.Color.red),J,re,Q,X,null,null,null,z._globeTileDebugBorderBuffer);const Ae=z.latestRawTileData,fe=Math.floor((Ae&&Ae.byteLength||0)/1024),Te=r.getTile(u).tileSize,Se=512/Math.min(Te,512)*(u.overscaledZ/f.transform.zoom)*.5;let Re=u.canonical.toString();u.overscaledZ!==u.canonical.z&&(Re+=` => ${u.overscaledZ}`),function(at,dt){at.initDebugOverlayCanvas();const ut=at.debugOverlayCanvas,Rt=at.context.gl,et=at.debugOverlayCanvas.getContext("2d");et.clearRect(0,0,ut.width,ut.height),et.shadowColor="white",et.shadowBlur=2,et.lineWidth=1.5,et.strokeStyle="white",et.textBaseline="top",et.font="bold 36px Open Sans, sans-serif",et.fillText(dt,5,5),et.strokeText(dt,5,5),at.debugOverlayTexture.update(ut),at.debugOverlayTexture.bind(Rt.LINEAR,Rt.CLAMP_TO_EDGE)}(f,`${Re} ${fe}kb`);const be=z._tileDebugTextBuffer||f.debugBuffer,Fe=z._tileDebugTextIndexBuffer||f.quadTriangleIndexBuffer,Qe=z._tileDebugTextSegments||f.debugSegments;P.draw(g,x.TRIANGLES,F,N,s.ColorMode.alphaBlended,s.CullFaceMode.disabled,Pm(S,s.Color.transparent,Se),J,be,Fe,Qe,null,null,null,z._globeTileDebugTextBuffer)}const Bm=s.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:As}=Bm;function Fa(f,r,u,g){f.emplaceBack(r,u,g)}class Pl{constructor(r){this.vertexArray=new s.StructArrayLayout3f12,this.indices=new s.StructArrayLayout3ui6,Fa(this.vertexArray,-1,-1,1),Fa(this.vertexArray,1,-1,1),Fa(this.vertexArray,-1,1,1),Fa(this.vertexArray,1,1,1),Fa(this.vertexArray,-1,-1,-1),Fa(this.vertexArray,1,-1,-1),Fa(this.vertexArray,-1,1,-1),Fa(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=r.createVertexBuffer(this.vertexArray,As),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=s.SegmentVector.simpleSegment(0,0,36,12)}}function so(f,r,u,g,x,b){const S=f.gl,P=r.paint.get("sky-atmosphere-color"),z=r.paint.get("sky-atmosphere-halo-color"),F=r.paint.get("sky-atmosphere-sun-intensity"),N=((H,J,re,Q,X)=>({u_matrix_3f:H,u_sun_direction:J,u_sun_intensity:re,u_color_tint_r:[Q.r,Q.g,Q.b,Q.a],u_color_tint_m:[X.r,X.g,X.b,X.a],u_luminance:5e-5}))(s.fromMat4(s.create$1(),g),x,F,P,z);S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT0,S.TEXTURE_CUBE_MAP_POSITIVE_X+b,r.skyboxTexture,0),u.draw(f,S.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.frontCW,N,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}function lo(f,r){return s.transformMat4(f,f,r)}const Vd={symbol:function(f,r,u,g,x){if(f.renderPass!=="translucent")return;const b=s.StencilMode.disabled,S=f.colorModeForRenderPass();u.layout.get("text-variable-anchor")&&function(P,z,F,N,H,J,re){const Q=z.transform,X=H==="map",Ae=J==="map";for(const fe of P){const Te=N.getTile(fe),Se=Te.getBucket(F);if(!Se||Se.projection!==Q.projection.name||!Se.text||!Se.text.segments.get().length)continue;const Re=s.evaluateSizeForZoom(Se.textSizeData,Q.zoom),be=z.transform.calculatePixelsToTileUnitsMatrix(Te),Fe=di(fe.projMatrix,Te.tileID.canonical,Ae,X,z.transform,be),Qe=F.layout.get("icon-text-fit")!=="none"&&Se.hasIconData();if(Re){const at=Math.pow(2,Q.zoom-Te.tileID.overscaledZ);Gy(Se,X,Ae,re,s.symbolSize,Q,Fe,fe,at,Re,Qe,Q.projection)}}}(g,f,u,r,u.layout.get("text-rotation-alignment"),u.layout.get("text-pitch-alignment"),x),u.paint.get("icon-opacity").constantOr(1)!==0&&Od(f,r,u,g,!1,u.paint.get("icon-translate"),u.paint.get("icon-translate-anchor"),u.layout.get("icon-rotation-alignment"),u.layout.get("icon-pitch-alignment"),u.layout.get("icon-keep-upright"),b,S),u.paint.get("text-opacity").constantOr(1)!==0&&Od(f,r,u,g,!0,u.paint.get("text-translate"),u.paint.get("text-translate-anchor"),u.layout.get("text-rotation-alignment"),u.layout.get("text-pitch-alignment"),u.layout.get("text-keep-upright"),b,S),r.map.showCollisionBoxes&&(Im(f,r,u,g,u.paint.get("text-translate"),u.paint.get("text-translate-anchor"),!0),Im(f,r,u,g,u.paint.get("icon-translate"),u.paint.get("icon-translate-anchor"),!1))},circle:function(f,r,u,g){if(f.renderPass!=="translucent")return;const x=u.paint.get("circle-opacity"),b=u.paint.get("circle-stroke-width"),S=u.paint.get("circle-stroke-opacity"),P=u.layout.get("circle-sort-key").constantOr(1)!==void 0;if(x.constantOr(1)===0&&(b.constantOr(1)===0||S.constantOr(1)===0))return;const z=f.context,F=z.gl,N=f.transform,H=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),J=s.StencilMode.disabled,re=f.colorModeForRenderPass(),Q=N.projection.name==="globe",X=[s.mercatorXfromLng(N.center.lng),s.mercatorYfromLat(N.center.lat)],Ae=[];for(let Te=0;Te<g.length;Te++){const Se=g[Te],Re=r.getTile(Se),be=Re.getBucket(u);if(!be)continue;const Fe=be.programConfigurations.get(u.id),Qe=Fy(u);Q&&Qe.push("PROJECTION_GLOBE_VIEW");const at=f.useProgram("circle",Fe,Qe),dt=be.layoutVertexBuffer,ut=be.globeExtVertexBuffer,Rt=be.indexBuffer,et=N.projection.createInversionMatrix(N,Se.canonical),zt={programConfiguration:Fe,program:at,layoutVertexBuffer:dt,globeExtVertexBuffer:ut,indexBuffer:Rt,uniformValues:Ts(f,Se,Re,et,X,u),tile:Re};if(P){const Pt=be.segments.get();for(const Jt of Pt)Ae.push({segments:new s.SegmentVector([Jt]),sortKey:Jt.sortKey,state:zt})}else Ae.push({segments:be.segments,sortKey:0,state:zt})}P&&Ae.sort((Te,Se)=>Te.sortKey-Se.sortKey);const fe={useDepthForOcclusion:!Q};for(const Te of Ae){const{programConfiguration:Se,program:Re,layoutVertexBuffer:be,globeExtVertexBuffer:Fe,indexBuffer:Qe,uniformValues:at,tile:dt}=Te.state,ut=Te.segments;f.terrain&&f.terrain.setupElevationDraw(dt,Re,fe),f.prepareDrawProgram(z,Re,dt.tileID.toUnwrapped()),Re.draw(z,F.TRIANGLES,H,J,re,s.CullFaceMode.disabled,at,u.id,be,Qe,ut,u.paint,N.zoom,Se,Q?Fe:null)}},heatmap:function(f,r,u,g){if(u.paint.get("heatmap-opacity")!==0)if(f.renderPass==="offscreen"){const x=f.context,b=x.gl,S=s.StencilMode.disabled,P=new s.ColorMode([b.ONE,b.ONE],s.Color.transparent,[!0,!0,!0,!0]);(function(J,re,Q){const X=J.gl;J.activeTexture.set(X.TEXTURE1),J.viewport.set([0,0,re.width/4,re.height/4]);let Ae=Q.heatmapFbo;if(Ae)X.bindTexture(X.TEXTURE_2D,Ae.colorAttachment.get()),J.bindFramebuffer.set(Ae.framebuffer);else{const fe=X.createTexture();X.bindTexture(X.TEXTURE_2D,fe),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_S,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_T,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MIN_FILTER,X.LINEAR),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MAG_FILTER,X.LINEAR),Ae=Q.heatmapFbo=J.createFramebuffer(re.width/4,re.height/4,!1),function(Te,Se,Re,be){const Fe=Te.gl;Fe.texImage2D(Fe.TEXTURE_2D,0,Fe.RGBA,Se.width/4,Se.height/4,0,Fe.RGBA,Te.extRenderToTextureHalfFloat?Te.extTextureHalfFloat.HALF_FLOAT_OES:Fe.UNSIGNED_BYTE,null),be.colorAttachment.set(Re)}(J,re,fe,Ae)}})(x,f,u),x.clear({color:s.Color.transparent});const z=f.transform,F=z.projection.name==="globe",N=F?["PROJECTION_GLOBE_VIEW"]:null,H=[s.mercatorXfromLng(z.center.lng),s.mercatorYfromLat(z.center.lat)];for(let J=0;J<g.length;J++){const re=g[J];if(r.hasRenderableParent(re))continue;const Q=r.getTile(re),X=Q.getBucket(u);if(!X)continue;const Ae=X.programConfigurations.get(u.id),fe=f.useProgram("heatmap",Ae,N),{zoom:Te}=f.transform;f.terrain&&f.terrain.setupElevationDraw(Q,fe),f.prepareDrawProgram(x,fe,re.toUnwrapped());const Se=z.projection.createInversionMatrix(z,re.canonical);fe.draw(x,b.TRIANGLES,s.DepthMode.disabled,S,P,s.CullFaceMode.disabled,Uy(f,re,Q,Se,H,Te,u.paint.get("heatmap-intensity")),u.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,u.paint,f.transform.zoom,Ae,F?X.globeExtVertexBuffer:null)}x.viewport.set([0,0,f.width,f.height])}else f.renderPass==="translucent"&&(f.context.setColorMode(f.colorModeForRenderPass()),function(x,b){const S=x.context,P=S.gl,z=b.heatmapFbo;if(!z)return;S.activeTexture.set(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,z.colorAttachment.get()),S.activeTexture.set(P.TEXTURE1);let F=b.colorRampTexture;F||(F=b.colorRampTexture=new s.Texture(S,b.colorRamp,P.RGBA)),F.bind(P.LINEAR,P.CLAMP_TO_EDGE),x.useProgram("heatmapTexture").draw(S,P.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,x.colorModeForRenderPass(),s.CullFaceMode.disabled,((N,H,J,re)=>({u_image:0,u_color_ramp:1,u_opacity:H.paint.get("heatmap-opacity")}))(0,b),b.id,x.viewportBuffer,x.quadTriangleIndexBuffer,x.viewportSegments,b.paint,x.transform.zoom)}(f,u))},line:function(f,r,u,g){if(f.renderPass!=="translucent")return;const x=u.paint.get("line-opacity"),b=u.paint.get("line-width");if(x.constantOr(1)===0||b.constantOr(1)===0)return;const S=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),P=f.colorModeForRenderPass(),z=f.terrain&&f.terrain.renderingToTexture?1:s.exported.devicePixelRatio,F=u.paint.get("line-dasharray"),N=F.constantOr(1),H=u.layout.get("line-cap"),J=u.paint.get("line-pattern"),re=J.constantOr(1),Q=u.paint.get("line-gradient"),X=u.getCrossfadeParameters(),Ae=re?"linePattern":"line",fe=f.context,Te=fe.gl,Se=(be=>{const Fe=[];Rd(be)&&Fe.push("RENDER_LINE_DASH"),be.paint.get("line-gradient")&&Fe.push("RENDER_LINE_GRADIENT");const Qe=be.paint.get("line-pattern").constantOr(1),at=be.paint.get("line-opacity").constantOr(1)!==1;return!Qe&&at&&Fe.push("RENDER_LINE_ALPHA_DISCARD"),Fe})(u);let Re=Se.includes("RENDER_LINE_ALPHA_DISCARD");f.terrain&&f.terrain.clipOrMaskOverlapStencilType()&&(Re=!1);for(const be of g){const Fe=r.getTile(be);if(re&&!Fe.patternsLoaded())continue;const Qe=Fe.getBucket(u);if(!Qe)continue;f.prepareDrawTile();const at=Qe.programConfigurations.get(u.id),dt=f.useProgram(Ae,at,Se),ut=J.constantOr(null);if(ut&&Fe.imageAtlas){const pt=Fe.imageAtlas,qt=pt.patternPositions[ut.to.toString()],mn=pt.patternPositions[ut.from.toString()];qt&&mn&&at.setConstantPatternPositions(qt,mn)}const Rt=F.constantOr(null),et=H.constantOr(null);if(!re&&Rt&&et&&Fe.lineAtlas){const pt=Fe.lineAtlas,qt=pt.getDash(Rt.to,et),mn=pt.getDash(Rt.from,et);qt&&mn&&at.setConstantPatternPositions(qt,mn)}const zt=f.terrain?be.projMatrix:null,Pt=re?Id(f,Fe,u,X,zt,z):Vy(f,Fe,u,X,zt,Qe.lineClipsArray.length,z);if(Q){const pt=Qe.gradients[u.id];let qt=pt.texture;if(u.gradientVersion!==pt.version){let mn=256;if(u.stepInterpolant){const Xt=r.getSource().maxzoom,Yt=be.canonical.z===Xt?Math.ceil(1<<f.transform.maxZoom-be.canonical.z):1;mn=s.clamp(s.nextPowerOfTwo(Qe.maxLineLength/s.EXTENT*1024*Yt),256,fe.maxTextureSize)}pt.gradient=s.renderColorRamp({expression:u.gradientExpression(),evaluationKey:"lineProgress",resolution:mn,image:pt.gradient||void 0,clips:Qe.lineClipsArray}),pt.texture?pt.texture.update(pt.gradient):pt.texture=new s.Texture(fe,pt.gradient,Te.RGBA),pt.version=u.gradientVersion,qt=pt.texture}fe.activeTexture.set(Te.TEXTURE1),qt.bind(u.stepInterpolant?Te.NEAREST:Te.LINEAR,Te.CLAMP_TO_EDGE)}N&&(fe.activeTexture.set(Te.TEXTURE0),Fe.lineAtlasTexture.bind(Te.LINEAR,Te.REPEAT),at.updatePaintBuffers(X)),re&&(fe.activeTexture.set(Te.TEXTURE0),Fe.imageAtlasTexture.bind(Te.LINEAR,Te.CLAMP_TO_EDGE),at.updatePaintBuffers(X)),f.prepareDrawProgram(fe,dt,be.toUnwrapped());const Jt=pt=>{dt.draw(fe,Te.TRIANGLES,S,pt,P,s.CullFaceMode.disabled,Pt,u.id,Qe.layoutVertexBuffer,Qe.indexBuffer,Qe.segments,u.paint,f.transform.zoom,at,Qe.layoutVertexBuffer2)};if(Re){const pt=f.stencilModeForClipping(be).ref;pt===0&&f.terrain&&fe.clear({stencil:0});const qt={func:Te.EQUAL,mask:255};Pt.u_alpha_discard_threshold=.8,Jt(new s.StencilMode(qt,pt,255,Te.KEEP,Te.KEEP,Te.INVERT)),Pt.u_alpha_discard_threshold=0,Jt(new s.StencilMode(qt,pt,255,Te.KEEP,Te.KEEP,Te.KEEP))}else Jt(f.stencilModeForClipping(be))}Re&&(f.resetStencilClippingMasks(),f.terrain&&fe.clear({stencil:0}))},fill:function(f,r,u,g){const x=u.paint.get("fill-color"),b=u.paint.get("fill-opacity");if(b.constantOr(1)===0)return;const S=f.colorModeForRenderPass(),P=u.paint.get("fill-pattern"),z=f.opaquePassEnabledForLayer()&&!P.constantOr(1)&&x.constantOr(s.Color.transparent).a===1&&b.constantOr(0)===1?"opaque":"translucent";if(f.renderPass===z){const F=f.depthModeForSublayer(1,f.renderPass==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly);bu(f,r,u,g,F,S,!1)}if(f.renderPass==="translucent"&&u.paint.get("fill-antialias")){const F=f.depthModeForSublayer(u.getPaintProperty("fill-outline-color")?2:0,s.DepthMode.ReadOnly);bu(f,r,u,g,F,S,!0)}},"fill-extrusion":function(f,r,u,g){const x=u.paint.get("fill-extrusion-opacity");if(x!==0&&f.renderPass==="translucent"){const b=new s.DepthMode(f.context.gl.LEQUAL,s.DepthMode.ReadWrite,f.depthRangeFor3D);if(x!==1||u.paint.get("fill-extrusion-pattern").constantOr(1))Ss(f,r,u,g,b,s.StencilMode.disabled,s.ColorMode.disabled),Ss(f,r,u,g,b,f.stencilModeFor3D(),f.colorModeForRenderPass()),f.resetStencilClippingMasks();else{const S=f.colorModeForRenderPass();Ss(f,r,u,g,b,s.StencilMode.disabled,S)}}},hillshade:function(f,r,u,g){if(f.renderPass!=="offscreen"&&f.renderPass!=="translucent")return;const x=f.context,b=f.depthModeForSublayer(0,s.DepthMode.ReadOnly),S=f.colorModeForRenderPass(),P=f.terrain&&f.terrain.renderingToTexture,[z,F]=f.renderPass!=="translucent"||P?[{},g]:f.stencilConfigForOverlap(g);for(const N of F){const H=r.getTile(N);if(H.needsHillshadePrepare&&f.renderPass==="offscreen")Sd(f,H,u,b,s.StencilMode.disabled,S);else if(f.renderPass==="translucent"){const J=P&&f.terrain?f.terrain.stencilModeForRTTOverlap(N):z[N.overscaledZ];Tm(f,N,H,u,b,J,S)}}x.viewport.set([0,0,f.width,f.height]),f.resetStencilClippingMasks()},raster:function(f,r,u,g,x,b){if(f.renderPass!=="translucent"||u.paint.get("raster-opacity")===0||!g.length)return;const S=f.context,P=S.gl,z=r.getSource(),F=f.useProgram("raster"),N=f.colorModeForRenderPass(),H=f.terrain&&f.terrain.renderingToTexture,[J,re]=z instanceof Ge||H?[{},g]:f.stencilConfigForOverlap(g),Q=re[re.length-1].overscaledZ,X=!f.options.moving;for(const Ae of re){const fe=H?s.DepthMode.disabled:f.depthModeForSublayer(Ae.overscaledZ-Q,u.paint.get("raster-opacity")===1?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly,P.LESS),Te=Ae.toUnwrapped(),Se=r.getTile(Ae);if(H&&(!Se||!Se.hasData()))continue;const Re=H?Ae.projMatrix:f.transform.calculateProjMatrix(Te,X),be=f.terrain&&H?f.terrain.stencilModeForRTTOverlap(Ae):J[Ae.overscaledZ],Fe=b?0:u.paint.get("raster-fade-duration");Se.registerFadeDuration(Fe);const Qe=r.findLoadedParent(Ae,0),at=Pd(Se,Qe,r,f.transform,Fe);let dt,ut;f.terrain&&f.terrain.prepareDrawTile();const Rt=u.paint.get("raster-resampling")==="nearest"?P.NEAREST:P.LINEAR;S.activeTexture.set(P.TEXTURE0),Se.texture.bind(Rt,P.CLAMP_TO_EDGE),S.activeTexture.set(P.TEXTURE1),Qe?(Qe.texture.bind(Rt,P.CLAMP_TO_EDGE),dt=Math.pow(2,Qe.tileID.overscaledZ-Se.tileID.overscaledZ),ut=[Se.tileID.canonical.x*dt%1,Se.tileID.canonical.y*dt%1]):Se.texture.bind(Rt,P.CLAMP_TO_EDGE);const et=Lm(Re,ut||[0,0],dt||1,at,u,z instanceof Ge?z.perspectiveTransform:[0,0]);if(f.prepareDrawProgram(S,F,Te),z instanceof Ge)z.boundsBuffer&&z.boundsSegments&&F.draw(S,P.TRIANGLES,fe,s.StencilMode.disabled,N,s.CullFaceMode.disabled,et,u.id,z.boundsBuffer,f.quadTriangleIndexBuffer,z.boundsSegments);else{const{tileBoundsBuffer:zt,tileBoundsIndexBuffer:Pt,tileBoundsSegments:Jt}=f.getTileBoundsBuffers(Se);F.draw(S,P.TRIANGLES,fe,be,N,s.CullFaceMode.disabled,et,u.id,zt,Pt,Jt)}}f.resetStencilClippingMasks()},background:function(f,r,u,g){const x=u.paint.get("background-color"),b=u.paint.get("background-opacity");if(b===0)return;const S=f.context,P=S.gl,z=f.transform,F=z.tileSize,N=u.paint.get("background-pattern");if(f.isPatternMissing(N))return;const H=!N&&x.a===1&&b===1&&f.opaquePassEnabledForLayer()?"opaque":"translucent";if(f.renderPass!==H)return;const J=s.StencilMode.disabled,re=f.depthModeForSublayer(0,H==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly),Q=f.colorModeForRenderPass(),X=f.useProgram(N?"backgroundPattern":"background");let Ae,fe=g;fe||(Ae=f.getBackgroundTiles(),fe=Object.values(Ae).map(Se=>Se.tileID)),N&&(S.activeTexture.set(P.TEXTURE0),f.imageManager.bind(f.context));const Te=u.getCrossfadeParameters();for(const Se of fe){const Re=Se.toUnwrapped(),be=g?Se.projMatrix:f.transform.calculateProjMatrix(Re);f.prepareDrawTile();const Fe=r?r.getTile(Se):Ae?Ae[Se.key]:new s.Tile(Se,F,z.zoom,f),Qe=N?Bd(be,b,f,N,{tileID:Se,tileSize:F},Te):Dm(be,b,x);f.prepareDrawProgram(S,X,Re);const{tileBoundsBuffer:at,tileBoundsIndexBuffer:dt,tileBoundsSegments:ut}=f.getTileBoundsBuffers(Fe);X.draw(S,P.TRIANGLES,re,J,Q,s.CullFaceMode.disabled,Qe,u.id,at,dt,ut)}},sky:function(f,r,u){const g=f.transform,x=g.projection.name==="mercator"||g.projection.name==="globe"?1:s.smoothstep(7,8,g.zoom),b=u.paint.get("sky-opacity")*x;if(b===0)return;const S=f.context,P=u.paint.get("sky-type"),z=new s.DepthMode(S.gl.LEQUAL,s.DepthMode.ReadOnly,[0,1]),F=f.frameCounter/1e3%1;P==="atmosphere"?f.renderPass==="offscreen"?u.needsSkyboxCapture(f)&&(function(N,H,J,re){const Q=N.context,X=Q.gl;let Ae=H.skyboxFbo;if(!Ae){Ae=H.skyboxFbo=Q.createFramebuffer(32,32,!1),H.skyboxGeometry=new Pl(Q),H.skyboxTexture=Q.gl.createTexture(),X.bindTexture(X.TEXTURE_CUBE_MAP,H.skyboxTexture),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_WRAP_S,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_WRAP_T,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_MIN_FILTER,X.LINEAR),X.texParameteri(X.TEXTURE_CUBE_MAP,X.TEXTURE_MAG_FILTER,X.LINEAR);for(let Re=0;Re<6;++Re)X.texImage2D(X.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,X.RGBA,32,32,0,X.RGBA,X.UNSIGNED_BYTE,null)}Q.bindFramebuffer.set(Ae.framebuffer),Q.viewport.set([0,0,32,32]);const fe=H.getCenter(N,!0),Te=N.useProgram("skyboxCapture"),Se=new Float64Array(16);s.identity(Se),s.rotateY(Se,Se,.5*-Math.PI),so(Q,H,Te,Se,fe,0),s.identity(Se),s.rotateY(Se,Se,.5*Math.PI),so(Q,H,Te,Se,fe,1),s.identity(Se),s.rotateX(Se,Se,.5*-Math.PI),so(Q,H,Te,Se,fe,2),s.identity(Se),s.rotateX(Se,Se,.5*Math.PI),so(Q,H,Te,Se,fe,3),s.identity(Se),so(Q,H,Te,Se,fe,4),s.identity(Se),s.rotateY(Se,Se,Math.PI),so(Q,H,Te,Se,fe,5),Q.viewport.set([0,0,N.width,N.height])}(f,u),u.markSkyboxValid(f)):f.renderPass==="sky"&&function(N,H,J,re,Q){const X=N.context,Ae=X.gl,fe=N.transform,Te=N.useProgram("skybox");X.activeTexture.set(Ae.TEXTURE0),Ae.bindTexture(Ae.TEXTURE_CUBE_MAP,H.skyboxTexture);const Se=((Re,be,Fe,Qe,at)=>({u_matrix:Re,u_sun_direction:be,u_cubemap:0,u_opacity:Qe,u_temporal_offset:at}))(fe.skyboxMatrix,H.getCenter(N,!1),0,re,Q);N.prepareDrawProgram(X,Te),Te.draw(X,Ae.TRIANGLES,J,s.StencilMode.disabled,N.colorModeForRenderPass(),s.CullFaceMode.backCW,Se,"skybox",H.skyboxGeometry.vertexBuffer,H.skyboxGeometry.indexBuffer,H.skyboxGeometry.segment)}(f,u,z,b,F):P==="gradient"&&f.renderPass==="sky"&&function(N,H,J,re,Q){const X=N.context,Ae=X.gl,fe=N.transform,Te=N.useProgram("skyboxGradient");H.skyboxGeometry||(H.skyboxGeometry=new Pl(X)),X.activeTexture.set(Ae.TEXTURE0);let Se=H.colorRampTexture;Se||(Se=H.colorRampTexture=new s.Texture(X,H.colorRamp,Ae.RGBA)),Se.bind(Ae.LINEAR,Ae.CLAMP_TO_EDGE);const Re=((be,Fe,Qe,at,dt)=>({u_matrix:be,u_color_ramp:0,u_center_direction:Fe,u_radius:s.degToRad(Qe),u_opacity:at,u_temporal_offset:dt}))(fe.skyboxMatrix,H.getCenter(N,!1),H.paint.get("sky-gradient-radius"),re,Q);N.prepareDrawProgram(X,Te),Te.draw(X,Ae.TRIANGLES,J,s.StencilMode.disabled,N.colorModeForRenderPass(),s.CullFaceMode.backCW,Re,"skyboxGradient",H.skyboxGeometry.vertexBuffer,H.skyboxGeometry.indexBuffer,H.skyboxGeometry.segment)}(f,u,z,b,F)},debug:function(f,r,u){for(let g=0;g<u.length;g++)km(f,r,u[g])},custom:function(f,r,u){const g=f.context,x=u.implementation;if(f.transform.projection.unsupportedLayers&&f.transform.projection.unsupportedLayers.includes("custom"))s.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if(f.renderPass==="offscreen"){const b=x.prerender;b&&(f.setCustomLayerDefaults(),g.setColorMode(f.colorModeForRenderPass()),b.call(x,g.gl,f.transform.customLayerMatrix()),g.setDirty(),f.setBaseState())}else if(f.renderPass==="translucent"){f.setCustomLayerDefaults(),g.setColorMode(f.colorModeForRenderPass()),g.setStencilMode(s.StencilMode.disabled);const b=x.renderingMode==="3d"?new s.DepthMode(f.context.gl.LEQUAL,s.DepthMode.ReadWrite,f.depthRangeFor3D):f.depthModeForSublayer(0,s.DepthMode.ReadOnly);g.setDepthMode(b),x.render(g.gl,f.transform.customLayerMatrix()),g.setDirty(),f.setBaseState(),g.bindFramebuffer.set(null)}}};class Fm{constructor(r,u){this.context=new G(r),this.transform=u,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=s.SourceCache.maxUnderzooming+s.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new cu,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this._tileClippingMaskIDs=new Map,this._skippedStencilTileIDs=new Set}updateTerrain(r,u){const g=!!r&&!!r.terrain&&this.transform.projection.supportsTerrain;if(!(g||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Lr(this,r));const x=this._terrain;this.transform.elevation=g?x:null,x.update(r,this.transform,u)}_updateFog(r){const u=r.fog;if(!u||u.getOpacity(this.transform.pitch)<1||u.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[g,x]=u.getFovAdjustedRange(this.transform._fov);if(g>x)return void(this.transform.fogCullDistSq=null);const b=g+.78*(x-g);this.transform.fogCullDistSq=b*b}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(r,u){if(this.width=r*s.exported.devicePixelRatio,this.height=u*s.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const g of this.style.order)this.style._layers[g].resize()}setup(){const r=this.context,u=new s.StructArrayLayout2i4;u.emplaceBack(0,0),u.emplaceBack(s.EXTENT,0),u.emplaceBack(0,s.EXTENT),u.emplaceBack(s.EXTENT,s.EXTENT),this.tileExtentBuffer=r.createVertexBuffer(u,s.posAttributes.members),this.tileExtentSegments=s.SegmentVector.simpleSegment(0,0,4,2);const g=new s.StructArrayLayout2i4;g.emplaceBack(0,0),g.emplaceBack(s.EXTENT,0),g.emplaceBack(0,s.EXTENT),g.emplaceBack(s.EXTENT,s.EXTENT),this.debugBuffer=r.createVertexBuffer(g,s.posAttributes.members),this.debugSegments=s.SegmentVector.simpleSegment(0,0,4,5);const x=new s.StructArrayLayout2i4;x.emplaceBack(-1,-1),x.emplaceBack(1,-1),x.emplaceBack(-1,1),x.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(x,s.posAttributes.members),this.viewportSegments=s.SegmentVector.simpleSegment(0,0,4,2);const b=new s.StructArrayLayout4i8;b.emplaceBack(0,0,0,0),b.emplaceBack(s.EXTENT,0,s.EXTENT,0),b.emplaceBack(0,s.EXTENT,0,s.EXTENT),b.emplaceBack(s.EXTENT,s.EXTENT,s.EXTENT,s.EXTENT),this.mercatorBoundsBuffer=r.createVertexBuffer(b,s.boundsAttributes.members),this.mercatorBoundsSegments=s.SegmentVector.simpleSegment(0,0,4,2);const S=new s.StructArrayLayout3ui6;S.emplaceBack(0,1,2),S.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(S);const P=new s.StructArrayLayout1ui2;for(const F of[0,1,3,2,0])P.emplaceBack(F);this.debugIndexBuffer=r.createIndexBuffer(P),this.emptyTexture=new s.Texture(r,new s.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),r.gl.RGBA),this.identityMat=s.create();const z=this.context.gl;this.stencilClearMode=new s.StencilMode({func:z.ALWAYS,mask:0},0,255,z.ZERO,z.ZERO,z.ZERO),this.loadTimeStamps.push(s.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(r){return r._makeTileBoundsBuffers(this.context,this.transform.projection),r._tileBoundsBuffer?{tileBoundsBuffer:r._tileBoundsBuffer,tileBoundsIndexBuffer:r._tileBoundsIndexBuffer,tileBoundsSegments:r._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context,u=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(r,u.TRIANGLES,s.DepthMode.disabled,this.stencilClearMode,s.ColorMode.disabled,s.CullFaceMode.disabled,pu(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(r,u,g){if(!u||this.currentStencilSource===u.id||!r.isTileClipped()||!g||g.length===0)return;const x=[];let b=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(const N of g)if(this._tileClippingMaskIDs.has(N.key)||(b=!0),this._skippedStencilTileIDs.has(N.key)){if(!u.getTile(N).getBucket(r))continue;this._skippedStencilTileIDs.delete(N.key),x.push(N)}if(!b&&x.length===0)return}const S=this.context,P=S.gl;S.setColorMode(s.ColorMode.disabled),S.setDepthMode(s.DepthMode.disabled);const z=this.useProgram("clippingMask"),F=N=>{const H=u.getTile(N),{tileBoundsBuffer:J,tileBoundsIndexBuffer:re,tileBoundsSegments:Q}=this.getTileBoundsBuffers(H);z.draw(S,P.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:P.GREATER,mask:255},this._tileClippingMaskIDs.get(N.key)||0,255,P.KEEP,P.KEEP,P.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,pu(N.projMatrix),"$clipping",J,re,Q)};if(!b&&x.length>0)for(const N of x)F(N);else{(this._tileClippingMaskIDs.size===0||this.nextStencilID+g.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(const N of g)this._tileClippingMaskIDs.set(N.key,this.nextStencilID++),u.getTile(N).getBucket(r)?F(N):this._skippedStencilTileIDs.add(N.key)}this._skippedStencilTileIDs.size===0&&(this.currentStencilSource=u.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,u=this.context.gl;return new s.StencilMode({func:u.NOTEQUAL,mask:255},r,255,u.KEEP,u.KEEP,u.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const u=this.context.gl;return new s.StencilMode({func:u.EQUAL,mask:255},this._tileClippingMaskIDs.get(r.key)||0,0,u.KEEP,u.KEEP,u.REPLACE)}stencilConfigForOverlap(r){const u=this.context.gl,g=r.sort((S,P)=>P.overscaledZ-S.overscaledZ),x=g[g.length-1].overscaledZ,b=g[0].overscaledZ-x+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();const S={};for(let P=0;P<b;P++)S[P+x]=new s.StencilMode({func:u.GEQUAL,mask:255},P+this.nextStencilID,255,u.KEEP,u.KEEP,u.REPLACE);return this.nextStencilID+=b,[S,g]}return[{[x]:s.StencilMode.disabled},g]}colorModeForRenderPass(){const r=this.context.gl;return this._showOverdrawInspector?new s.ColorMode([r.CONSTANT_COLOR,r.ONE],new s.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?s.ColorMode.unblended:s.ColorMode.alphaBlended}depthModeForSublayer(r,u,g){if(!this.opaquePassEnabledForLayer())return s.DepthMode.disabled;const x=1-((1+this.currentLayer)*this.numSublayers+r)*this.depthEpsilon;return new s.DepthMode(g||this.context.gl.LEQUAL,u,[x,x])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(r,u){this.style=r,this.options=u,this.lineAtlas=r.lineAtlas,this.imageManager=r.imageManager,this.glyphManager=r.glyphManager,this.symbolFadeChange=r.placement.symbolFadeChange(s.exported.now()),this.imageManager.beginFrame();const g=this.style.order,x=this.style._sourceCaches;for(const F in x){const N=x[F];N.used&&N.prepare(this.context)}const b={},S={},P={};for(const F in x){const N=x[F];b[F]=N.getVisibleCoordinates(),S[F]=b[F].slice().reverse(),P[F]=N.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let F=0;F<g.length;F++)if(this.style._layers[g[F]].is3D()){this.opaquePassCutoff=F;break}if(this.terrain&&(this.terrain.updateTileBinding(P),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new s.GlobeSharedBuffers(this.context)),!s.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const F of g){const N=this.style._layers[F],H=r._getLayerSourceCache(N);if(!N.hasOffscreenPass()||N.isHidden(this.transform.zoom))continue;const J=H?S[H.id]:void 0;(N.type==="custom"||N.isSky()||J&&J.length)&&this.renderLayer(this,H,N,J)}this.depthRangeFor3D=[0,1-(r.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let z=s.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(z=this.style.fog.properties.get("color")),this.context.clear({color:u.showOverdrawInspector?s.Color.black:z,depth:1}),this.clearStencil(),this._showOverdrawInspector=u.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=g.length-1;this.currentLayer>=0;this.currentLayer--){const F=this.style._layers[g[this.currentLayer]],N=r._getLayerSourceCache(F);if(F.isSky())continue;const H=N?S[N.id]:void 0;this._renderTileClippingMasks(F,N,H),this.renderLayer(this,N,F,H)}if(this.renderPass="sky",(s.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<g.length;this.currentLayer++){const F=this.style._layers[g[this.currentLayer]],N=r._getLayerSourceCache(F);F.isSky()&&this.renderLayer(this,N,F,N?S[N.id]:void 0)}for(this.transform.projection.name==="globe"&&function(F){const N=F.context,H=N.gl,J=F.transform,re=new s.DepthMode(H.LEQUAL,s.DepthMode.ReadOnly,[0,1]),Q=F.useProgram("globeAtmosphere"),X=J.centerOffset,Ae=J._camera.getCameraToClipPerspective(J._fov,J.width/J.height,J._nearZ,J._farZ);Ae[8]=2*-X.x/J.width,Ae[9]=2*X.y/J.height;const fe=s.invert([],Ae),Te=s.mul([],fe,J.projMatrix),Se={u_frustum_tl:lo([-1,1,1],fe),u_frustum_tr:lo([1,1,1],fe),u_frustum_br:lo([1,-1,1],fe),u_frustum_bl:lo([-1,-1,1],fe),u_globe_pos:lo([J.globeMatrix[12],J.globeMatrix[13],J.globeMatrix[14]],Te),u_globe_radius:J.worldSize/2/Math.PI-1,u_opacity:1-s.globeToMercatorTransition(J.zoom),u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882]};F.prepareDrawProgram(N,Q);const Re=F.globeSharedBuffers;Re&&Q.draw(N,H.TRIANGLES,re,s.StencilMode.disabled,s.ColorMode.alphaBlended,s.CullFaceMode.backCW,Se,"skybox",Re.atmosphereVertexBuffer,Re.atmosphereIndexBuffer,Re.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<g.length;){const F=this.style._layers[g[this.currentLayer]],N=r._getLayerSourceCache(F);if(F.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(F)){if(F.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const H=N?(F.type==="symbol"?P:S)[N.id]:void 0;this._renderTileClippingMasks(F,N,N?b[N.id]:void 0),this.renderLayer(this,N,F,H),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let F=null;s.values(this.style._layers).forEach(N=>{const H=r._getLayerSourceCache(N);H&&!N.isHidden(this.transform.zoom)&&(!F||F.getSource().maxzoom<H.getSource().maxzoom)&&(F=H)}),F&&this.options.showTileBoundaries&&Vd.debug(this,F,F.getVisibleCoordinates())}this.options.showPadding&&function(F){const N=F.transform.padding;Ht(F,F.transform.height-(N.top||0),3,Nd),Ht(F,N.bottom||0,3,Ud),jr(F,N.left||0,3,zm),jr(F,F.transform.width-(N.right||0),3,wu);const H=F.transform.centerPoint;(function(J,re,Q,X){Cl(J,re-1,Q-10,2,20,X),Cl(J,re-10,Q-1,20,2,X)})(F,H.x,F.transform.height-H.y,Mu)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(s.window.performance.now()),this.saveCanvasCopy())}renderLayer(r,u,g,x){g.isHidden(this.transform.zoom)||(g.type==="background"||g.type==="sky"||g.type==="custom"||x&&x.length)&&(this.id=g.id,this.gpuTimingStart(g),r.transform.projection.unsupportedLayers&&r.transform.projection.unsupportedLayers.includes(g.type)||Vd[g.type](r,u,g,x,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(r){if(!this.options.gpuTiming)return;const u=this.context.extTimerQuery;let g=this.gpuTimers[r.id];g||(g=this.gpuTimers[r.id]={calls:0,cpuTime:0,query:u.createQueryEXT()}),g.calls++,u.beginQueryEXT(u.TIME_ELAPSED_EXT,g.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const r=this.context.extTimerQuery;r.endQueryEXT(r.TIME_ELAPSED_EXT)}collectGpuTimers(){const r=this.gpuTimers;return this.gpuTimers={},r}queryGpuTimers(r){const u={};for(const g in r){const x=r[g],b=this.context.extTimerQuery,S=b.getQueryObjectEXT(x.query,b.QUERY_RESULT_EXT)/1e6;b.deleteQueryEXT(x.query),u[g]=S}return u}translatePosMatrix(r,u,g,x,b){if(!g[0]&&!g[1])return r;const S=b?x==="map"?this.transform.angle:0:x==="viewport"?-this.transform.angle:0;if(S){const F=Math.sin(S),N=Math.cos(S);g=[g[0]*N-g[1]*F,g[0]*F+g[1]*N]}const P=[b?g[0]:Ve(u,g[0],this.transform.zoom),b?g[1]:Ve(u,g[1],this.transform.zoom),0],z=new Float32Array(16);return s.translate(z,r,P),z}saveTileTexture(r){const u=this._tileTextures[r.size[0]];u?u.push(r):this._tileTextures[r.size[0]]=[r]}getTileTexture(r){const u=this._tileTextures[r];return u&&u.length>0?u.pop():null}isPatternMissing(r){if(!r)return!1;if(!r.from||!r.to)return!0;const u=this.imageManager.getPattern(r.from.toString()),g=this.imageManager.getPattern(r.to.toString());return!u||!g}currentGlobalDefines(){const r=this.terrain&&this.terrain.renderingToTexture,u=this.style&&this.style.fog,g=[];return this.terrain&&!this.terrain.renderingToTexture&&g.push("TERRAIN"),u&&!r&&u.getOpacity(this.transform.pitch)!==0&&g.push("FOG"),r&&g.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&g.push("OVERDRAW_INSPECTOR"),g}useProgram(r,u,g){this.cache=this.cache||{};const x=g||[],b=this.currentGlobalDefines().concat(x),S=Tl.cacheKey(r,b,u);return this.cache[S]||(this.cache[S]=new Tl(this.context,r,bl[r],u,Qn[r],b)),this.cache[S]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=s.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new s.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(r,u,g){if(this.terrain&&this.terrain.renderingToTexture)return;const x=this.style.fog;if(x){const b=x.getOpacity(this.transform.pitch);b!==0&&u.setFogUniformValues(r,((S,P,z,F)=>{const N=P.properties.get("color"),H=S.frameCounter/1e3%1,J=[N.r/N.a,N.g/N.a,N.b/N.a,F];return{u_fog_matrix:z?S.transform.calculateFogTileMatrix(z):S.identityMat,u_fog_range:P.getFovAdjustedRange(S.transform._fov),u_fog_color:J,u_fog_horizon_blend:P.properties.get("horizon-blend"),u_fog_temporal_offset:H}})(this,x,g,b))}}setTileLoadedFlag(r){this.tileLoaded=r}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const r=this.context.gl,u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.copyTexImage2D(r.TEXTURE_2D,0,r.RGBA,0,0,r.drawingBufferWidth,r.drawingBufferHeight,0),u}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const r=this.style&&this.style.fog;return!!r&&r.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const r=this._backgroundTiles,u=this._backgroundTiles={},g=this.transform.coveringTiles({tileSize:512});for(const x of g)u[x.key]=r[x.key]||new s.Tile(x,512,this.transform.tileZoom,this);return u}clearBackgroundTiles(){this._backgroundTiles={}}}class co{constructor(r=0,u=0,g=0,x=0){if(isNaN(r)||r<0||isNaN(u)||u<0||isNaN(g)||g<0||isNaN(x)||x<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=r,this.bottom=u,this.left=g,this.right=x}interpolate(r,u,g){return u.top!=null&&r.top!=null&&(this.top=s.number(r.top,u.top,g)),u.bottom!=null&&r.bottom!=null&&(this.bottom=s.number(r.bottom,u.bottom,g)),u.left!=null&&r.left!=null&&(this.left=s.number(r.left,u.left,g)),u.right!=null&&r.right!=null&&(this.right=s.number(r.right,u.right,g)),this}getCenter(r,u){const g=s.clamp((this.left+r-this.right)/2,0,r),x=s.clamp((this.top+u-this.bottom)/2,0,u);return new s.pointGeometry(g,x)}equals(r){return this.top===r.top&&this.bottom===r.bottom&&this.left===r.left&&this.right===r.right}clone(){return new co(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Om(f,r){const u=s.getColumn(f,3);s.fromQuat(f,r),s.setColumn(f,3,u)}function Gd(f,r){const u=s.identity$1([]);return s.rotateZ$1(u,u,-r),s.rotateX$1(u,u,-f),u}function Tu(f,r){const u=[f[0],f[1],0],g=[r[0],r[1],0];if(s.length(u)>=1e-15){const S=s.normalize([],u);s.scale$2(g,S,s.dot(g,S)),r[0]=g[0],r[1]=g[1]}const x=s.cross([],r,f);if(s.len(x)<1e-15)return null;const b=Math.atan2(-x[1],x[0]);return Gd(Math.atan2(Math.sqrt(f[0]*f[0]+f[1]*f[1]),-f[2]),b)}class Ll{constructor(r,u){this.position=r,this.orientation=u}get position(){return this._position}set position(r){if(r){const u=r instanceof s.MercatorCoordinate?r:new s.MercatorCoordinate(r[0],r[1],r[2]);this._renderWorldCopies&&(u.x=s.wrap(u.x,0,1)),this._position=u}else this._position=null}lookAtPoint(r,u){if(this.orientation=null,!this.position)return;const g=this._elevation?this._elevation.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(r)):0,x=this.position,b=s.MercatorCoordinate.fromLngLat(r,g),S=[b.x-x.x,b.y-x.y,b.z-x.z];u||(u=[0,0,1]),u[2]=Math.abs(u[2]),this.orientation=Tu(S,u)}setPitchBearing(r,u){this.orientation=Gd(s.degToRad(r),s.degToRad(-u))}}class Dl{constructor(r,u){this._transform=s.identity([]),this.orientation=u,this.position=r}get mercatorPosition(){const r=this.position;return new s.MercatorCoordinate(r[0],r[1],r[2])}get position(){const r=s.getColumn(this._transform,3);return[r[0],r[1],r[2]]}set position(r){var u;r&&s.setColumn(this._transform,3,[(u=r)[0],u[1],u[2],1])}get orientation(){return this._orientation}set orientation(r){this._orientation=r||s.identity$1([]),r&&Om(this._transform,this._orientation)}getPitchBearing(){const r=this.forward(),u=this.right();return{bearing:Math.atan2(-u[1],u[0]),pitch:Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2])}}setPitchBearing(r,u){this._orientation=Gd(r,u),Om(this._transform,this._orientation)}forward(){const r=s.getColumn(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=s.getColumn(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=s.getColumn(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,u){const g=new Float64Array(16);return s.invert(g,this.getWorldToCamera(r,u)),g}getWorldToCameraPosition(r,u,g){const x=this.position;s.scale$2(x,x,-r);const b=new Float64Array(16);return s.fromScaling(b,[g,g,g]),s.translate(b,b,x),b[10]*=u,b}getWorldToCamera(r,u){const g=new Float64Array(16),x=new Float64Array(4),b=this.position;return s.conjugate(x,this._orientation),s.scale$2(b,b,-r),s.fromQuat(g,x),s.translate(g,g,b),g[1]*=-1,g[5]*=-1,g[9]*=-1,g[13]*=-1,g[8]*=u,g[9]*=u,g[10]*=u,g[11]*=u,g}getCameraToClipPerspective(r,u,g,x){const b=new Float64Array(16);return s.perspective(b,r,u,g,x),b}getDistanceToElevation(r){const u=r===0?0:s.mercatorZfromAltitude(r,this.position[1]),g=this.forward();return(u-this.position[2])/g[2]}clone(){return new Dl([...this.position],[...this.orientation])}}function Hd(f,r){const u=Il(f),g=function(b,S,P,z,F){const N=new s.LngLat(P.lng-180*uo,P.lat),H=new s.LngLat(P.lng+180*uo,P.lat),J=b.project(N.lng,N.lat),re=b.project(H.lng,H.lat),Q=-Math.atan2(re.y-J.y,re.x-J.x),X=s.MercatorCoordinate.fromLngLat(P);X.y=s.clamp(X.y,-.999975,.999975);const Ae=X.toLngLat(),fe=b.project(Ae.lng,Ae.lat),Te=s.MercatorCoordinate.fromLngLat(Ae);Te.x+=uo;const Se=Te.toLngLat(),Re=b.project(Se.lng,Se.lat),be=qd(Re.x-fe.x,Re.y-fe.y,Q),Fe=s.MercatorCoordinate.fromLngLat(Ae);Fe.y+=uo;const Qe=Fe.toLngLat(),at=b.project(Qe.lng,Qe.lat),dt=qd(at.x-fe.x,at.y-fe.y,Q),ut=Math.abs(be.x)/Math.abs(dt.y),Rt=s.identity([]);s.rotateZ(Rt,Rt,-Q*(1-(F?0:z)));const et=s.identity([]);return s.scale(et,et,[1,1-(1-ut)*z,1]),et[4]=-dt.x/dt.y*z,s.rotateZ(et,et,Q),s.multiply$1(et,Rt,et),et}(f.projection,0,f.center,u,r),x=Wd(f);return s.scale(g,g,[x,x,1]),g}function Wd(f){const r=f.projection,u=Il(f),g=jd(r,f.center),x=jd(r,s.LngLat.convert(r.center));return Math.pow(2,g*u+(1-u)*x)}function Il(f){const r=f.projection.range;if(!r)return 0;const u=Math.max(f.width,f.height),g=Math.log(u/1024)/Math.LN2;return s.smoothstep(r[0]+g,r[1]+g,f.zoom)}const uo=1/4e4;function jd(f,r){const u=s.clamp(r.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),g=new s.LngLat(r.lng-180*uo,u),x=new s.LngLat(r.lng+180*uo,u),b=f.project(g.lng,u),S=f.project(x.lng,u),P=s.MercatorCoordinate.fromLngLat(g),z=s.MercatorCoordinate.fromLngLat(x),F=S.x-b.x,N=S.y-b.y,H=z.x-P.x,J=z.y-P.y,re=Math.sqrt((H*H+J*J)/(F*F+N*N));return Math.log(re)/Math.LN2}function qd(f,r,u){const g=Math.cos(u),x=Math.sin(u);return{x:f*g-r*x,y:f*x+r*g}}class Eu{constructor(r,u,g,x,b,S,P){this.tileSize=512,this._renderWorldCopies=b===void 0||b,this._minZoom=r||0,this._maxZoom=u||22,this._minPitch=g==null?0:g,this._maxPitch=x==null?60:x,this.setProjection(S),this.setMaxBounds(P),this.width=0,this.height=0,this._center=new s.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new co,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Dl,this._centerAltitude=0,this._centerAltitudeValidForExaggeration=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const r=new Eu(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return r._elevation=this._elevation,r._centerAltitude=this._centerAltitude,r._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,r.tileSize=this.tileSize,r.width=this.width,r.height=this.height,r.cameraElevationReference=this.cameraElevationReference,r._center=this._center,r._setZoom(this.zoom),r._seaLevelZoom=this._seaLevelZoom,r.angle=this.angle,r._fov=this._fov,r._pitch=this._pitch,r._nearZ=this._nearZ,r._farZ=this._farZ,r._averageElevation=this._averageElevation,r._unmodified=this._unmodified,r._edgeInsets=this._edgeInsets.clone(),r._camera=this._camera.clone(),r._calcMatrices(),r.freezeTileCoverage=this.freezeTileCoverage,r}get elevation(){return this._elevation}set elevation(r){this._elevation!==r&&(this._elevation=r,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(r){const u=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||u)&&this._updateCameraOnTerrain(),(r||u)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return s.pick(this.projection,["name","center","parallels"])}setProjection(r){r==null&&(r={name:"mercator"}),this.projectionOptions=r;const u=this.projection?this.getProjection():void 0;this.projection=s.getProjection(r);const g=this.getProjection();return E(u,g)?null:(this._calcMatrices(),g)}get minZoom(){return this._minZoom}set minZoom(r){this._minZoom!==r&&(this._minZoom=r,this.zoom=Math.max(this.zoom,r))}get maxZoom(){return this._maxZoom}set maxZoom(r){this._maxZoom!==r&&(this._maxZoom=r,this.zoom=Math.min(this.zoom,r))}get minPitch(){return this._minPitch}set minPitch(r){this._minPitch!==r&&(this._minPitch=r,this.pitch=Math.max(this.pitch,r))}get maxPitch(){return this._maxPitch}set maxPitch(r){this._maxPitch!==r&&(this._maxPitch=r,this.pitch=Math.min(this.pitch,r))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(r){r===void 0?r=!0:r===null&&(r=!1),this._renderWorldCopies=r}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new s.pointGeometry(this.width,this.height)}get bearing(){return s.wrap(this.rotation,-180,180)}set bearing(r){this.rotation=r}get rotation(){return-this.angle/Math.PI*180}set rotation(r){const u=-r*Math.PI/180;var g;this.angle!==u&&(this._unmodified=!1,this.angle=u,this._calcMatrices(),this.rotationMatrix=(g=new s.ARRAY_TYPE(4),s.ARRAY_TYPE!=Float32Array&&(g[1]=0,g[2]=0),g[0]=1,g[3]=1,g),function(x,b,S){var P=b[0],z=b[1],F=b[2],N=b[3],H=Math.sin(S),J=Math.cos(S);x[0]=P*J+F*H,x[1]=z*J+N*H,x[2]=P*-H+F*J,x[3]=z*-H+N*J}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const u=s.clamp(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==u&&(this._unmodified=!1,this._pitch=u,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(r){r=Math.max(.01,Math.min(60,r)),this._fov!==r&&(this._unmodified=!1,this._fov=r/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(r){this._averageElevation=r,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(r){const u=Math.min(Math.max(r,this.minZoom),this.maxZoom);this._zoom!==u&&(this._unmodified=!1,this._setZoom(u),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(r){this._zoom=r,this.scale=this.zoomScale(r),this.tileZoom=Math.floor(r),this.zoomFraction=r-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=0);const r=this._elevation;this._centerAltitude=r.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=r.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const r=this._elevation,u=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],g=this.horizonLineFromTop();let x=0,b=0;for(let S=0;S<u.length;S++){const P=new s.pointGeometry(u[S][0]*this.width,g+u[S][1]*(this.height-g)),z=r.pointCoordinate(P);if(!z)continue;const F=1/Math.hypot(z[0]-this._camera.position[0],z[1]-this._camera.position[1]);x+=z[3]*F,b+=F}return b===0?NaN:x/b}get center(){return this._center}set center(r){r.lat===this._center.lat&&r.lng===this._center.lng||(this._unmodified=!1,this._center=r,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const r=this._seaLevelZoom,u=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),g=this.pixelsPerMeter/this.worldSize*u,x=this._mercatorZfromZoom(r),b=this._mercatorZfromZoom(this._maxZoom),S=Math.max(x-g,b);this._setZoom(this._zoomFromMercatorZ(S))}get padding(){return this._edgeInsets.toJSON()}set padding(r){this._edgeInsets.equals(r)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,r,1),this._calcMatrices())}computeZoomRelativeTo(r){const u=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,r.toAltitude()));let g;g=r.z<this._camera.position[2]?[u.x,u.y,u.z]:[r.x,r.y,r.z];const x=s.length(s.sub([],this._camera.position,g));return s.clamp(this._zoomFromMercatorZ(x),this._minZoom,this._maxZoom)}setFreeCameraOptions(r){if(!this.height||!r.position&&!r.orientation)return;this._updateCameraState();let u=!1;if(r.orientation&&!s.exactEquals(r.orientation,this._camera.orientation)&&(u=this._setCameraOrientation(r.orientation)),r.position){const g=[r.position.x,r.position.y,r.position.z];s.exactEquals$1(g,this._camera.position)||(this._setCameraPosition(g),u=!0)}u&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const r=this._camera.position,u=new Ll;return u.position=new s.MercatorCoordinate(r[0],r[1],r[2]),u.orientation=this._camera.orientation,u._elevation=this.elevation,u._renderWorldCopies=this.renderWorldCopies,u}_setCameraOrientation(r){if(!s.length$1(r))return!1;s.normalize$1(r,r);const u=s.transformQuat([],[0,0,-1],r),g=s.transformQuat([],[0,-1,0],r);if(g[2]<0)return!1;const x=Tu(u,g);return!!x&&(this._camera.orientation=x,!0)}_setCameraPosition(r){const u=this.zoomScale(this.minZoom)*this.tileSize,g=this.zoomScale(this.maxZoom)*this.tileSize,x=this.cameraToCenterDistance;r[2]=s.clamp(r[2],x/g,x/u),this._camera.position=r}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(r){return this._edgeInsets.equals(r)}interpolatePadding(r,u,g){this._unmodified=!1,this._edgeInsets.interpolate(r,u,g),this._constrain(),this._calcMatrices()}coveringZoomLevel(r){const u=(r.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/r.tileSize));return Math.max(0,u)}getVisibleUnwrappedCoordinates(r){const u=[new s.UnwrappedTileID(0,r)];if(this.renderWorldCopies){const g=this.pointCoordinate(new s.pointGeometry(0,0)),x=this.pointCoordinate(new s.pointGeometry(this.width,0)),b=this.pointCoordinate(new s.pointGeometry(this.width,this.height)),S=this.pointCoordinate(new s.pointGeometry(0,this.height)),P=Math.floor(Math.min(g.x,x.x,b.x,S.x)),z=Math.floor(Math.max(g.x,x.x,b.x,S.x)),F=1;for(let N=P-F;N<=z+F;N++)N!==0&&u.push(new s.UnwrappedTileID(N,r))}return u}coveringTiles(r){let u=this.coveringZoomLevel(r);const g=u,x=this.elevation&&!r.isTerrainDEM,b=this.projection.name==="mercator";if(r.minzoom!==void 0&&u<r.minzoom)return[];r.maxzoom!==void 0&&u>r.maxzoom&&(u=r.maxzoom);const S=this.locationCoordinate(this.center),P=this.center.lat,z=1<<u,F=[z*S.x,z*S.y,0],N=this.projection.name==="globe",H=!N,J=s.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,u,H),re=N?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),Q=z*s.mercatorZfromAltitude(1,this.center.lat),X=this._camera.position[2]/s.mercatorZfromAltitude(1,this.center.lat),Ae=[z*re.x,z*re.y,X*(H?1:Q)],fe=this.cameraToCenterDistance/r.tileSize*(r.roundZoom?1:.502),Te=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?u:0,Se=r.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,Re=r.isTerrainDEM?-Se:this._elevation?this._elevation.getMinElevationBelowMSL():0,be=this.projection.isReprojectedInTileSpace?Wd(this):1,Fe=pt=>{const mn=new s.MercatorCoordinate(pt.x+25e-6,pt.y,pt.z),Xt=new s.MercatorCoordinate(pt.x,pt.y+25e-6,pt.z),Yt=pt.toLngLat(),vn=mn.toLngLat(),kn=Xt.toLngLat(),hn=this.locationCoordinate(Yt),Mn=this.locationCoordinate(vn),qn=this.locationCoordinate(kn),vi=Math.hypot(Mn.x-hn.x,Mn.y-hn.y),nr=Math.hypot(qn.x-hn.x,qn.y-hn.y);return Math.sqrt(vi*nr)*be/25e-6},Qe=pt=>{const qt=Se,mn=Re;return{aabb:s.tileAABB(this,z,0,0,0,pt,mn,qt,this.projection),zoom:0,x:0,y:0,minZ:mn,maxZ:qt,wrap:pt,fullyVisible:!1}},at=[];let dt=[];const ut=u,Rt=r.reparseOverscaled?g:u,et=pt=>pt*pt,zt=et((X-this._centerAltitude)*Q),Pt=pt=>{if(!this._elevation||!pt.tileID||!b)return;const qt=this._elevation.getMinMaxForTile(pt.tileID),mn=pt.aabb;qt?(mn.min[2]=qt.min,mn.max[2]=qt.max,mn.center[2]=(mn.min[2]+mn.max[2])/2):(pt.shouldSplit=Jt(pt),pt.shouldSplit||(mn.min[2]=mn.max[2]=mn.center[2]=this._centerAltitude))},Jt=pt=>{if(pt.zoom<Te)return!0;if(pt.zoom===ut)return!1;if(pt.shouldSplit!=null)return pt.shouldSplit;const qt=pt.aabb.distanceX(Ae),mn=pt.aabb.distanceY(Ae);let Xt=zt,Yt=1;if(N){Xt=et(pt.aabb.distanceZ(Ae));const kn=Math.pow(2,pt.zoom),hn=s.latFromMercatorY((pt.y+1)/kn),Mn=s.latFromMercatorY(pt.y/kn),qn=Math.min(Math.max(P,hn),Mn),vi=s.circumferenceAtLatitude(qn)/s.circumferenceAtLatitude(P);Yt=Math.min(vi,1)}else if(x&&(Xt=et(pt.aabb.distanceZ(Ae)*Q)),this.projection.isReprojectedInTileSpace&&g<=5){const kn=Math.pow(2,pt.zoom),hn=Fe(new s.MercatorCoordinate((pt.x+.5)/kn,(pt.y+.5)/kn));Yt=hn>.85?1:hn}const vn=qt*qt+mn*mn+Xt;return vn<et((1<<ut-pt.zoom)*fe*Yt*((kn,hn)=>{if(hn*et(.707)<kn)return 1;const Mn=Math.sqrt(hn/kn);return Mn/(1.4144271570014144+(Math.pow(1.1,Mn-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Xt,zt),vn))};if(this.renderWorldCopies)for(let pt=1;pt<=3;pt++)at.push(Qe(-pt)),at.push(Qe(pt));for(at.push(Qe(0));at.length>0;){const pt=at.pop(),qt=pt.x,mn=pt.y;let Xt=pt.fullyVisible;if(!Xt){const Yt=pt.aabb.intersects(J);if(Yt===0)continue;Xt=Yt===2}if(pt.zoom!==ut&&Jt(pt))for(let Yt=0;Yt<4;Yt++){const vn=(qt<<1)+Yt%2,kn=(mn<<1)+(Yt>>1),hn={aabb:b?pt.aabb.quadrant(Yt):s.tileAABB(this,z,pt.zoom+1,vn,kn,pt.wrap,pt.minZ,pt.maxZ,this.projection),zoom:pt.zoom+1,x:vn,y:kn,wrap:pt.wrap,fullyVisible:Xt,tileID:void 0,shouldSplit:void 0,minZ:pt.minZ,maxZ:pt.maxZ};x&&!N&&(hn.tileID=new s.OverscaledTileID(pt.zoom+1===ut?Rt:pt.zoom+1,pt.wrap,pt.zoom+1,vn,kn),Pt(hn)),at.push(hn)}else{const Yt=pt.zoom===ut?Rt:pt.zoom;if(r.minzoom&&r.minzoom>Yt)continue;const vn=F[0]-(.5+qt+(pt.wrap<<pt.zoom))*(1<<u-pt.zoom),kn=F[1]-.5-mn,hn=pt.tileID?pt.tileID:new s.OverscaledTileID(Yt,pt.wrap,pt.zoom,qt,mn);dt.push({tileID:hn,distanceSq:vn*vn+kn*kn})}}if(this.fogCullDistSq){const pt=this.fogCullDistSq,qt=this.horizonLineFromTop();dt=dt.filter(mn=>{const Xt=[0,0,0,1],Yt=[s.EXTENT,s.EXTENT,0,1],vn=this.calculateFogTileMatrix(mn.tileID.toUnwrapped());s.transformMat4$1(Xt,Xt,vn),s.transformMat4$1(Yt,Yt,vn);const kn=s.getAABBPointSquareDist(Xt,Yt);if(kn===0)return!0;let hn=!1;const Mn=this._elevation;if(Mn&&kn>pt&&qt!==0){const qn=this.calculateProjMatrix(mn.tileID.toUnwrapped());let vi;r.isTerrainDEM||(vi=Mn.getMinMaxForTile(mn.tileID)),vi||(vi={min:Re,max:Se});const nr=s.furthestTileCorner(this.rotation),ir=[nr[0]*s.EXTENT,nr[1]*s.EXTENT,vi.max];s.transformMat4(ir,ir,qn),hn=(1-ir[1])*this.height*.5<qt}return kn<pt||hn})}return dt.sort((pt,qt)=>pt.distanceSq-qt.distanceSq).map(pt=>pt.tileID)}resize(r,u){this.width=r,this.height=u,this.pixelsToGLUnits=[2/r,-2/u],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(r){return Math.pow(2,r)}scaleZoom(r){return Math.log(r)/Math.LN2}project(r){const u=s.clamp(r.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),g=this.projection.project(r.lng,u);return new s.pointGeometry(g.x*this.worldSize,g.y*this.worldSize)}unproject(r){return this.projection.unproject(r.x/this.worldSize,r.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(r,u){let g,x;const b=this.centerPoint;if(this.projection.name==="globe"){const P=this.worldSize;g=(u.x-b.x)/P,x=(u.y-b.y)/P}else{const P=this.pointCoordinate(u),z=this.pointCoordinate(b);g=P.x-z.x,x=P.y-z.y}const S=this.locationCoordinate(r);this.setLocation(new s.MercatorCoordinate(S.x-g,S.y-x))}setLocation(r){this.center=this.coordinateLocation(r),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(r){return this.projection.locationPoint(this,r)}locationPoint3D(r){return this._coordinatePoint(this.locationCoordinate(r),!0)}pointLocation(r){return this.coordinateLocation(this.pointCoordinate(r))}pointLocation3D(r){return this.coordinateLocation(this.pointCoordinate3D(r))}locationCoordinate(r,u){const g=u?s.mercatorZfromAltitude(u,r.lat):void 0,x=this.projection.project(r.lng,r.lat);return new s.MercatorCoordinate(x.x,x.y,g)}coordinateLocation(r){return this.projection.unproject(r.x,r.y)}pointRayIntersection(r,u){const g=u!=null?u:this._centerAltitude,x=[r.x,r.y,0,1],b=[r.x,r.y,1,1];s.transformMat4$1(x,x,this.pixelMatrixInverse),s.transformMat4$1(b,b,this.pixelMatrixInverse);const S=b[3];s.scale$1(x,x,1/x[3]),s.scale$1(b,b,1/S);const P=x[2],z=b[2];return{p0:x,p1:b,t:P===z?0:(g-P)/(z-P)}}screenPointToMercatorRay(r){const u=[r.x,r.y,0,1],g=[r.x,r.y,1,1];return s.transformMat4$1(u,u,this.pixelMatrixInverse),s.transformMat4$1(g,g,this.pixelMatrixInverse),s.scale$1(u,u,1/u[3]),s.scale$1(g,g,1/g[3]),u[2]=s.mercatorZfromAltitude(u[2],this._center.lat)*this.worldSize,g[2]=s.mercatorZfromAltitude(g[2],this._center.lat)*this.worldSize,s.scale$1(u,u,1/this.worldSize),s.scale$1(g,g,1/this.worldSize),new s.Ray([u[0],u[1],u[2]],s.normalize([],s.sub([],g,u)))}rayIntersectionCoordinate(r){const{p0:u,p1:g,t:x}=r,b=s.mercatorZfromAltitude(u[2],this._center.lat),S=s.mercatorZfromAltitude(g[2],this._center.lat);return new s.MercatorCoordinate(s.number(u[0],g[0],x)/this.worldSize,s.number(u[1],g[1],x)/this.worldSize,s.number(b,S,x))}pointCoordinate(r,u=this._centerAltitude){return this.projection.pointCoordinate(this,r.x,r.y,u)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);const u=this.elevation;let g=this.elevation.pointCoordinate(r);if(g)return new s.MercatorCoordinate(g[0],g[1],g[2]);let x=0,b=this.horizonLineFromTop();if(r.y>b)return this.pointCoordinate(r);const S=.02*b,P=r.clone();for(let z=0;z<10&&b-x>S;z++){P.y=s.number(x,b,.66);const F=u.pointCoordinate(P);F?(b=P.y,g=F):x=P.y}return g?new s.MercatorCoordinate(g[0],g[1],g[2]):this.pointCoordinate(r)}isPointAboveHorizon(r){if(this.elevation)return!this.elevation.pointCoordinate(r);{const u=this.horizonLineFromTop();return r.y<u}}_coordinatePoint(r,u){const g=u&&this.elevation?this.elevation.getAtPointOrZero(r,this._centerAltitude):this._centerAltitude,x=[r.x*this.worldSize,r.y*this.worldSize,g+r.toAltitude(),1];return s.transformMat4$1(x,x,this.pixelMatrix),x[3]>0?new s.pointGeometry(x[0]/x[3],x[1]/x[3]):new s.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(r,u){const g=new s.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),x=new s.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),b=new s.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),S=new s.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let P=this.pointCoordinate(g,r),z=this.pointCoordinate(x,r);const F=this.pointCoordinate(b,u),N=this.pointCoordinate(S,u),H=(J,re)=>(re.y-J.y)/(re.x-J.x);return P.y>1&&z.y>=0?P=new s.MercatorCoordinate((1-N.y)/H(N,P)+N.x,1):P.y<0&&z.y<=1&&(P=new s.MercatorCoordinate(-N.y/H(N,P)+N.x,0)),z.y>1&&P.y>=0?z=new s.MercatorCoordinate((1-F.y)/H(F,z)+F.x,1):z.y<0&&P.y<=1&&(z=new s.MercatorCoordinate(-F.y/H(F,z)+F.x,0)),new s.LngLatBounds().extend(this.coordinateLocation(P)).extend(this.coordinateLocation(z)).extend(this.coordinateLocation(N)).extend(this.coordinateLocation(F))}_getBounds3D(){const r=this.elevation;if(!r.visibleDemTiles.length)return this._getBounds(0,0);const u=r.visibleDemTiles.reduce((g,x)=>{if(x.dem){const b=x.dem.tree;g.min=Math.min(g.min,b.minimums[0]),g.max=Math.max(g.max,b.maximums[0])}return g},{min:Number.MAX_VALUE,max:0});return this._getBounds(u.min*r.exaggeration(),u.max*r.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(r=!0){const u=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,g=this.height/2-u*(1-this._horizonShift);return r?Math.max(0,g):g}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-s.MAX_MERCATOR_LATITUDE,this.maxLat=s.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=s.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=s.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=s.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=s.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(r,u){return this.projection.createTileMatrix(this,u,r)}calculateDistanceTileData(r){const u=r.key,g=this._distanceTileDataCache;if(g[u])return g[u];const x=r.canonical,b=1/this.height,S=this.cameraWorldSize/this.zoomScale(x.z),P=(x.x+Math.pow(2,x.z)*r.wrap)*S,z=x.y*S,F=this.point,N=this.angle,H=Math.sin(-N),J=-Math.cos(-N);return g[u]={bearing:[H,J],center:[(F.x-P)*b,(F.y-z)*b],scale:S/s.EXTENT*b},g[u]}calculateFogTileMatrix(r){const u=r.key,g=this._fogTileMatrixCache;if(g[u])return g[u];const x=this.calculatePosMatrix(r,this.cameraWorldSize);return s.multiply$1(x,this.worldToFogMatrix,x),g[u]=new Float32Array(x),g[u]}calculateProjMatrix(r,u=!1){const g=r.key,x=u?this._alignedProjMatrixCache:this._projMatrixCache;if(x[g])return x[g];const b=this.calculatePosMatrix(r,this.worldSize);return s.multiply$1(b,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:u?this.alignedProjMatrix:this.projMatrix,b),x[g]=new Float32Array(b),x[g]}calculatePixelsToTileUnitsMatrix(r){const u=r.tileID.key,g=this._pixelsToTileUnitsCache;if(g[u])return g[u];const x=function(b,S){const{scale:P}=b.tileTransform,z=P*s.EXTENT/(b.tileSize*Math.pow(2,S.zoom-b.tileID.overscaledZ+b.tileID.canonical.z));return F=new Float32Array(4),J=(N=S.inverseAdjustmentMatrix)[1],re=N[2],Q=N[3],Ae=(H=[z,z])[1],F[0]=N[0]*(X=H[0]),F[1]=J*X,F[2]=re*Ae,F[3]=Q*Ae,F;var F,N,H,J,re,Q,X,Ae}(r,this);return g[u]=x,g[u]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const r=this._elevation;this._updateCameraState();const u=s.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,g=this._computeCameraPosition(u),x=this._camera.forward(),b=s.mercatorZfromAltitude(1,this._center.lat);g[2]/=b,x[2]/=b,s.normalize(x,x);const S=r.raycast(g,x,r.exaggeration());if(S){const P=s.scaleAndAdd([],g,x,S),z=new s.MercatorCoordinate(P[0],P[1],s.mercatorZfromAltitude(P[2],s.latFromMercatorY(P[1]))),F=(z.z+s.length([z.x-g[0],z.y-g[1],z.z-g[2]*b]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(F),this._centerAltitude=z.toAltitude(),this._center=this.coordinateLocation(z),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const r=this._elevation;this._updateCameraState();const u=s.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,g=this._computeCameraPosition(u),x=r.getAtPointOrZero(new s.MercatorCoordinate(...g)),b=this._minimumHeightOverTerrain()*Math.cos(s.degToRad(this._maxPitch)),S=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*x;if(S<b){const P=this.locationCoordinate(this._center,this._centerAltitude),z=[P.x-g[0],P.y-g[1],P.z-g[2]],F=s.length(z);z[2]-=(b-S)/this._projectionScaler;const N=s.length(z);if(N===0)return;s.scale$2(z,z,F/N*this._projectionScaler),this._camera.position=[P.x-z[0],P.y-z[1],P.z*this._projectionScaler-z[2]],this._camera.orientation=Tu(z,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const H=this.center;return H.lat=s.clamp(H.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(H.lng=s.clamp(H.lng,this.minLng,this.maxLng)),this.center=H,void(this._constraining=!1)}const r=this._unmodified,{x:u,y:g}=this.point;let x=0,b=u,S=g;const P=this.width/2,z=this.height/2,F=this.worldMinY*this.scale,N=this.worldMaxY*this.scale;if(g-z<F&&(S=F+z),g+z>N&&(S=N-z),N-F<this.height&&(x=Math.max(x,this.height/(N-F)),S=(N+F)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const H=this.worldMinX*this.scale,J=this.worldMaxX*this.scale,re=this.worldSize/2-(H+J)/2;b=(u+re+this.worldSize)%this.worldSize-re,b-P<H&&(b=H+P),b+P>J&&(b=J-P),J-H<this.width&&(x=Math.max(x,this.width/(J-H)),b=(J+H)/2)}b===u&&S===g||(this.center=this.unproject(new s.pointGeometry(b,S))),x&&(this.zoom+=this.scaleZoom(x)),this._constrainCameraAltitude(),this._unmodified=r,this._constraining=!1}_minZoomForBounds(){let r=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(r=Math.max(r,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),r}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const r=this._fov/2,u=this.centerOffset,g=this.pixelsPerMeter;this._projectionScaler=g/(s.mercatorZfromAltitude(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(r)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const x=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?g:1),b=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);b[8]=2*-u.x/this.width,b[9]=2*u.y/this.height;let S=s.mul([],b,x);if(this.projection.isReprojectedInTileSpace){const Re=this.locationCoordinate(this.center),be=s.identity([]);s.translate(be,be,[Re.x*this.worldSize,Re.y*this.worldSize,0]),s.multiply$1(be,be,Hd(this)),s.translate(be,be,[-Re.x*this.worldSize,-Re.y*this.worldSize,0]),s.multiply$1(S,S,be),this.inverseAdjustmentMatrix=function(Fe){const Qe=Hd(Fe,!0);return le([],[Qe[0],Qe[1],Qe[4],Qe[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=s.scale([],S,[this.worldSize,this.worldSize,this.worldSize/g,1]),this.projMatrix=S,this.invProjMatrix=s.invert(new Float64Array(16),this.projMatrix);const P=new Float32Array(16);s.identity(P),s.scale(P,P,[1,-1,1]),s.rotateX(P,P,this._pitch),s.rotateZ(P,P,this.angle);const z=s.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),F=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;z[8]=2*-u.x/this.width,z[9]=2*(u.y+F)/this.height,this.skyboxMatrix=s.multiply$1(P,z,P);const N=this.point,H=N.x,J=N.y,re=this.width%2/2,Q=this.height%2/2,X=Math.cos(this.angle),Ae=Math.sin(this.angle),fe=H-Math.round(H)+X*re+Ae*Q,Te=J-Math.round(J)+X*Q+Ae*re,Se=new Float64Array(S);if(s.translate(Se,Se,[fe>.5?fe-1:fe,Te>.5?Te-1:Te,0]),this.alignedProjMatrix=Se,S=s.create(),s.scale(S,S,[this.width/2,-this.height/2,1]),s.translate(S,S,[1,-1,0]),this.labelPlaneMatrix=S,S=s.create(),s.scale(S,S,[1,-1,1]),s.translate(S,S,[-1,-1,0]),s.scale(S,S,[2/this.width,2/this.height,1]),this.glCoordMatrix=S,this.pixelMatrix=s.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},S=s.invert(new Float64Array(16),this.pixelMatrix),!S)throw new Error("failed to invert matrix");this.pixelMatrixInverse=S,this.globeMatrix=this.projection.name==="globe"?s.calculateGlobeMatrix(this):S,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSize,u=this.cameraPixelsPerMeter,g=this._camera.position,x=1/this.height,b=[r,r,u];s.scale$2(b,b,x),s.scale$2(g,g,-1),s.multiply$2(g,g,b);const S=s.create();s.translate(S,S,g),s.scale(S,S,b),this.mercatorFogMatrix=S,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,u,x)}_computeCameraPosition(r){const u=(r=r||this.pixelsPerMeter)/this.pixelsPerMeter,g=this._camera.forward(),x=this.point,b=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*u-r/this.worldSize*this._centerAltitude;return[x.x/this.worldSize-g[0]*b,x.y/this.worldSize-g[1]*b,r/this.worldSize*this._centerAltitude-g[2]*b]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const u=this._maxCameraBoundsDistance()*Math.cos(this._pitch),g=r[2];let x=1;g>0&&(x=Math.min((u-this._camera.position[2])/g,1)),this._camera.position=s.scaleAndAdd([],this._camera.position,r,x),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const r=this._camera.position,u=this._camera.forward(),{pitch:g,bearing:x}=this._camera.getPitchBearing(),b=s.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,S=this._mercatorZfromZoom(this._maxZoom)*Math.cos(s.degToRad(this._maxPitch)),P=Math.max((r[2]-b)/Math.cos(g),S),z=this._zoomFromMercatorZ(P);s.scaleAndAdd(r,r,u,P),this._pitch=s.clamp(g,s.degToRad(this.minPitch),s.degToRad(this.maxPitch)),this.angle=s.wrap(x,-Math.PI,Math.PI),this._setZoom(s.clamp(z,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new s.MercatorCoordinate(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(r){return Math.pow(2,r)*this.tileSize}_mercatorZfromZoom(r){return this.cameraToCenterDistance/this._worldSizeFromZoom(r)}_minimumHeightOverTerrain(){const r=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(r)}_zoomFromMercatorZ(r){return this.scaleZoom(this.cameraToCenterDistance/(r*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(s.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(r,u){const g=Math.min(r.x,u.x),x=Math.max(r.x,u.x),b=Math.min(r.y,u.y),S=Math.max(r.y,u.y);if(b<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const P=[new s.pointGeometry(g,b),new s.pointGeometry(x,S),new s.pointGeometry(g,S),new s.pointGeometry(x,b)],z=this.renderWorldCopies?-3:0,F=this.renderWorldCopies?4:1;for(const N of P){const H=this.pointRayIntersection(N);if(H.t<0)return!0;const J=this.rayIntersectionCoordinate(H);if(J.x<z||J.y<0||J.x>F||J.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+s.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new s.pointGeometry(0,0),new s.pointGeometry(this.width,this.height))}zoomDeltaToMovement(r,u){const g=s.length(s.sub([],this._camera.position,r)),x=this._zoomFromMercatorZ(g)+u;return g-this._mercatorZfromZoom(x)}getCameraPoint(){const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.pointGeometry(0,r))}}function Zd(f,r){let u=!1,g=null;const x=()=>{g=null,u&&(f(),g=setTimeout(x,r),u=!1)};return()=>(u=!0,g||x(),g)}class Nm{constructor(r){this._hashName=r&&encodeURIComponent(r),s.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Zd(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,s.window.addEventListener("hashchange",this._onHashChange,!1),r.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),s.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(r){const u=this._map;if(!u)return"";const g=u.getCenter(),x=Math.round(100*u.getZoom())/100,b=Math.ceil((x*Math.LN2+Math.log(512/360/.5))/Math.LN10),S=Math.pow(10,b),P=Math.round(g.lng*S)/S,z=Math.round(g.lat*S)/S,F=u.getBearing(),N=u.getPitch();let H="";if(H+=r?`/${P}/${z}/${x}`:`${x}/${z}/${P}`,(F||N)&&(H+="/"+Math.round(10*F)/10),N&&(H+=`/${Math.round(N)}`),this._hashName){const J=this._hashName;let re=!1;const Q=s.window.location.hash.slice(1).split("&").map(X=>{const Ae=X.split("=")[0];return Ae===J?(re=!0,`${Ae}=${H}`):X}).filter(X=>X);return re||Q.push(`${J}=${H}`),`#${Q.join("&")}`}return`#${H}`}_getCurrentHash(){const r=s.window.location.hash.replace("#","");if(this._hashName){let u;return r.split("&").map(g=>g.split("=")).forEach(g=>{g[0]===this._hashName&&(u=g)}),(u&&u[1]||"").split("/")}return r.split("/")}_onHashChange(){const r=this._map;if(!r)return!1;const u=this._getCurrentHash();if(u.length>=3&&!u.some(g=>isNaN(g))){const g=r.dragRotate.isEnabled()&&r.touchZoomRotate.isEnabled()?+(u[3]||0):r.getBearing();return r.jumpTo({center:[+u[2],+u[1]],zoom:+u[0],bearing:g,pitch:+(u[4]||0)}),!0}return!1}_updateHashUnthrottled(){const r=s.window.location.href.replace(/(#.+)?$/,this.getHashString());s.window.history.replaceState(s.window.history.state,null,r)}}const Oa={linearity:.3,easing:s.bezier(0,0,.3,1)},Um=s.extend({deceleration:2500,maxSpeed:1400},Oa),Vm=s.extend({deceleration:20,maxSpeed:1400},Oa),Gm=s.extend({deceleration:1e3,maxSpeed:360},Oa),Hm=s.extend({deceleration:1e3,maxSpeed:90},Oa);class Wm{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.exported.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,u=s.exported.now();for(;r.length>0&&u-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const u={zoom:0,bearing:0,pitch:0,pan:new s.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:b}of this._inertiaBuffer)u.zoom+=b.zoomDelta||0,u.bearing+=b.bearingDelta||0,u.pitch+=b.pitchDelta||0,b.panDelta&&u.pan._add(b.panDelta),b.around&&(u.around=b.around),b.pinchAround&&(u.pinchAround=b.pinchAround);const g=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,x={};if(u.pan.mag()){const b=ji(u.pan.mag(),g,s.extend({},Um,r||{}));x.offset=u.pan.mult(b.amount/u.pan.mag()),x.center=this._map.transform.center,Rl(x,b)}if(u.zoom){const b=ji(u.zoom,g,Vm);x.zoom=this._map.transform.zoom+b.amount,Rl(x,b)}if(u.bearing){const b=ji(u.bearing,g,Gm);x.bearing=this._map.transform.bearing+s.clamp(b.amount,-179,179),Rl(x,b)}if(u.pitch){const b=ji(u.pitch,g,Hm);x.pitch=this._map.transform.pitch+b.amount,Rl(x,b)}if(x.zoom||x.bearing){const b=u.pinchAround===void 0?u.around:u.pinchAround;x.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),x.noMoveStart=!0,x}}function Rl(f,r){(!f.duration||f.duration<r.duration)&&(f.duration=r.duration,f.easing=r.easing)}function ji(f,r,u){const{maxSpeed:g,linearity:x,deceleration:b}=u,S=s.clamp(f*x/(r/1e3),-g,g),P=Math.abs(S)/(b*x);return{easing:u.easing,duration:1e3*P,amount:S*(P/2)}}class Dr extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,u,g,x={}){const b=K(u.getCanvasContainer(),g),S=u.unproject(b);super(r,s.extend({point:b,lngLat:S,originalEvent:g},x)),this._defaultPrevented=!1,this.target=u}}class zl extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,u,g){const x=r==="touchend"?g.changedTouches:g.touches,b=ie(u.getCanvasContainer(),x),S=b.map(z=>u.unproject(z)),P=b.reduce((z,F,N,H)=>z.add(F.div(H.length)),new s.pointGeometry(0,0));super(r,{points:b,point:P,lngLats:S,lngLat:u.unproject(P),originalEvent:g}),this._defaultPrevented=!1}}class Wy extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,u,g){super(r,{originalEvent:g}),this._defaultPrevented=!1}}class jy{constructor(r,u){this._map=r,this._clickTolerance=u.clickTolerance}reset(){this._mousedownPos=void 0}wheel(r){return this._firePreventable(new Wy(r.type,this._map,r))}mousedown(r,u){return this._mousedownPos=u,this._firePreventable(new Dr(r.type,this._map,r))}mouseup(r){this._map.fire(new Dr(r.type,this._map,r))}preclick(r){const u=s.extend({},r);u.type="preclick",this._map.fire(new Dr(u.type,this._map,u))}click(r,u){this._mousedownPos&&this._mousedownPos.dist(u)>=this._clickTolerance||(this.preclick(r),this._map.fire(new Dr(r.type,this._map,r)))}dblclick(r){return this._firePreventable(new Dr(r.type,this._map,r))}mouseover(r){this._map.fire(new Dr(r.type,this._map,r))}mouseout(r){this._map.fire(new Dr(r.type,this._map,r))}touchstart(r){return this._firePreventable(new zl(r.type,this._map,r))}touchmove(r){this._map.fire(new zl(r.type,this._map,r))}touchend(r){this._map.fire(new zl(r.type,this._map,r))}touchcancel(r){this._map.fire(new zl(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Na{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(r){this._map.fire(new Dr(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Dr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._map.fire(new Dr(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class jm{constructor(r,u){this._map=r,this._el=r.getCanvasContainer(),this._container=r.getContainer(),this._clickTolerance=u.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(r,u){this.isEnabled()&&r.shiftKey&&r.button===0&&(q(),this._startPos=this._lastPos=u,this._active=!0)}mousemoveWindow(r,u){if(!this._active)return;const g=u;if(this._lastPos.equals(g)||!this._box&&g.dist(this._startPos)<this._clickTolerance)return;const x=this._startPos;this._lastPos=g,this._box||(this._box=L("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",r));const b=Math.min(x.x,g.x),S=Math.max(x.x,g.x),P=Math.min(x.y,g.y),z=Math.max(x.y,g.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${b}px,${P}px)`,this._box.style.width=S-b+"px",this._box.style.height=z-P+"px")})}mouseupWindow(r,u){if(!this._active||r.button!==0)return;const g=this._startPos,x=u;if(this.reset(),Ce(),g.x!==x.x||g.y!==x.y)return this._map.fire(new s.Event("boxzoomend",{originalEvent:r})),{cameraAnimation:b=>b.fitScreenCoordinates(g,x,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}keydown(r){this._active&&r.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",r))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),ee(),delete this._startPos,delete this._lastPos}_fireEvent(r,u){return this._map.fire(new s.Event(r,{originalEvent:u}))}}function ho(f,r){const u={};for(let g=0;g<f.length;g++)u[f[g].identifier]=r[g];return u}class Ma{constructor(r){this.reset(),this.numTouches=r.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(r,u,g){(this.centroid||g.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=r.timeStamp),g.length===this.numTouches&&(this.centroid=function(x){const b=new s.pointGeometry(0,0);for(const S of x)b._add(S);return b.div(x.length)}(u),this.touches=ho(g,u)))}touchmove(r,u,g){if(this.aborted||!this.centroid)return;const x=ho(g,u);for(const b in this.touches){const S=this.touches[b],P=x[b];(!P||P.dist(S)>30)&&(this.aborted=!0)}}touchend(r,u,g){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),g.length===0){const x=!this.aborted&&this.centroid;if(this.reset(),x)return x}}}class Cs{constructor(r){this.singleTap=new Ma(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(r,u,g){this.singleTap.touchstart(r,u,g)}touchmove(r,u,g){this.singleTap.touchmove(r,u,g)}touchend(r,u,g){const x=this.singleTap.touchend(r,u,g);if(x){const b=r.timeStamp-this.lastTime<500,S=!this.lastTap||this.lastTap.dist(x)<30;if(b&&S||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=x,this.count===this.numTaps)return this.reset(),x}}}class jt{constructor(){this._zoomIn=new Cs({numTouches:1,numTaps:2}),this._zoomOut=new Cs({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,u,g){this._zoomIn.touchstart(r,u,g),this._zoomOut.touchstart(r,u,g)}touchmove(r,u,g){this._zoomIn.touchmove(r,u,g),this._zoomOut.touchmove(r,u,g)}touchend(r,u,g){const x=this._zoomIn.touchend(r,u,g),b=this._zoomOut.touchend(r,u,g);return x?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()+1,around:S.unproject(x)},{originalEvent:r})}):b?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()-1,around:S.unproject(b)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const qm={0:1,2:2};class Su{constructor(r){this.reset(),this._clickTolerance=r.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(r,u){return!1}_move(r,u){return{}}mousedown(r,u){if(this._lastPoint)return;const g=ue(r);this._correctButton(r,g)&&(this._lastPoint=u,this._eventButton=g)}mousemoveWindow(r,u){const g=this._lastPoint;if(g){if(r.preventDefault(),this._eventButton!=null&&function(x,b){const S=qm[b];return x.buttons===void 0||(x.buttons&S)!==S}(r,this._eventButton))this.reset();else if(this._moved||!(u.dist(g)<this._clickTolerance))return this._moved=!0,this._lastPoint=u,this._move(g,u)}}mouseupWindow(r){this._lastPoint&&ue(r)===this._eventButton&&(this._moved&&Ce(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class kl extends Su{mousedown(r,u){super.mousedown(r,u),this._lastPoint&&(this._active=!0)}_correctButton(r,u){return u===0&&!r.ctrlKey}_move(r,u){return{around:u,panDelta:u.sub(r)}}}class Ps extends Su{_correctButton(r,u){return u===0&&r.ctrlKey||u===2}_move(r,u){const g=.8*(u.x-r.x);if(g)return this._active=!0,{bearingDelta:g}}contextmenu(r){r.preventDefault()}}class Xd extends Su{_correctButton(r,u){return u===0&&r.ctrlKey||u===2}_move(r,u){const g=-.5*(u.y-r.y);if(g)return this._active=!0,{pitchDelta:g}}contextmenu(r){r.preventDefault()}}class Zm{constructor(r,u){this._map=r,this._el=r.getCanvasContainer(),this._minTouches=1,this._clickTolerance=u.clickTolerance||1,this.reset(),s.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new s.pointGeometry(0,0)}touchstart(r,u,g){return this._calculateTransform(r,u,g)}touchmove(r,u,g){if(this._active&&!(g.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(g.length===1)return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return r.preventDefault(),this._calculateTransform(r,u,g)}}touchend(r,u,g){this._calculateTransform(r,u,g),this._active&&g.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(r,u,g){g.length>0&&(this._active=!0);const x=ho(g,u),b=new s.pointGeometry(0,0),S=new s.pointGeometry(0,0);let P=0;for(const F in x){const N=x[F],H=this._touches[F];H&&(b._add(N),S._add(N.sub(H)),P++,x[F]=N)}if(this._touches=x,P<this._minTouches||!S.mag())return;const z=S.div(P);return this._sum._add(z),this._sum.mag()<this._clickTolerance?void 0:{around:b.div(P),panDelta:z}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=L("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class Au{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(r){}_move(r,u,g){return{}}touchstart(r,u,g){this._firstTwoTouches||g.length<2||(this._firstTwoTouches=[g[0].identifier,g[1].identifier],this._start([u[0],u[1]]))}touchmove(r,u,g){const x=this._firstTwoTouches;if(!x)return;r.preventDefault();const[b,S]=x,P=Bl(g,u,b),z=Bl(g,u,S);if(!P||!z)return;const F=this._aroundCenter?null:P.add(z).div(2);return this._move([P,z],F,r)}touchend(r,u,g){if(!this._firstTwoTouches)return;const[x,b]=this._firstTwoTouches,S=Bl(g,u,x),P=Bl(g,u,b);S&&P||(this._active&&Ce(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&r.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Bl(f,r,u){for(let g=0;g<f.length;g++)if(f[g].identifier===u)return r[g]}function Yd(f,r){return Math.log(f/r)/Math.LN2}class Xm extends Au{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(r){this._startDistance=this._distance=r[0].dist(r[1])}_move(r,u){const g=this._distance;if(this._distance=r[0].dist(r[1]),this._active||!(Math.abs(Yd(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Yd(this._distance,g),pinchAround:u}}}function $d(f,r){return 180*f.angleWith(r)/Math.PI}class Cu extends Au{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(r){this._startVector=this._vector=r[0].sub(r[1]),this._minDiameter=r[0].dist(r[1])}_move(r,u){const g=this._vector;if(this._vector=r[0].sub(r[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:$d(this._vector,g),pinchAround:u}}_isBelowThreshold(r){this._minDiameter=Math.min(this._minDiameter,r.mag());const u=25/(Math.PI*this._minDiameter)*360,g=$d(r,this._startVector);return Math.abs(g)<u}}function Fl(f){return Math.abs(f.y)>Math.abs(f.x)}class Pu extends Au{constructor(r){super(),this._map=r}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(r){this._lastPoints=r,Fl(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,u,g){const x=this._lastPoints;if(!x)return;const b=r[0].sub(x[0]),S=r[1].sub(x[1]);return this._map._cooperativeGestures&&g.touches.length<3||(this._valid=this.gestureBeginsVertically(b,S,g.timeStamp),!this._valid)?void 0:(this._lastPoints=r,this._active=!0,{pitchDelta:(b.y+S.y)/2*-.5})}gestureBeginsVertically(r,u,g){if(this._valid!==void 0)return this._valid;const x=r.mag()>=2,b=u.mag()>=2;if(!x&&!b)return;if(!x||!b)return this._firstMove==null&&(this._firstMove=g),g-this._firstMove<100&&void 0;const S=r.y>0==u.y>0;return Fl(r)&&Fl(u)&&S}}const Ym={panStep:100,bearingStep:15,pitchStep:10};class $m{constructor(){const r=Ym;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey)return;let u=0,g=0,x=0,b=0,S=0;switch(r.keyCode){case 61:case 107:case 171:case 187:u=1;break;case 189:case 109:case 173:u=-1;break;case 37:r.shiftKey?g=-1:(r.preventDefault(),b=-1);break;case 39:r.shiftKey?g=1:(r.preventDefault(),b=1);break;case 38:r.shiftKey?x=1:(r.preventDefault(),S=-1);break;case 40:r.shiftKey?x=-1:(r.preventDefault(),S=1);break;default:return}return this._rotationDisabled&&(g=0,x=0),{cameraAnimation:P=>{const z=P.getZoom();P.easeTo({duration:300,easeId:"keyboardHandler",easing:Jm,zoom:u?Math.round(z)+u*(r.shiftKey?2:1):z,bearing:P.getBearing()+g*this._bearingStep,pitch:P.getPitch()+x*this._pitchStep,offset:[-b*this._panStep,-S*this._panStep],center:P.getCenter()},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Jm(f){return f*(2-f)}const Jd=4.000244140625;class Km{constructor(r,u){this._map=r,this._el=r.getCanvasContainer(),this._handler=u,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,s.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&r.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let u=r.deltaMode===s.window.WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const g=s.exported.now(),x=g-(this._lastWheelEventTime||0);this._lastWheelEventTime=g,u!==0&&u%Jd==0?this._type="wheel":u!==0&&Math.abs(u)<4?this._type="trackpad":x>400?(this._type=null,this._lastValue=u,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(x*u)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,u+=this._lastValue)),r.shiftKey&&u&&(u/=4),this._type&&(this._lastWheelEvent=r,this._delta-=u,this._active||this._start(r)),r.preventDefault()}_onTimeout(r){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)}_start(r){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const u=K(this._el,r);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:u,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._map.transform,u=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(this._delta!==0){const z=this._type==="wheel"&&Math.abs(this._delta)>Jd?this._wheelZoomRate:this._defaultZoomRate;let F=2/(1+Math.exp(-Math.abs(this._delta*z)));this._delta<0&&F!==0&&(F=1/F);const N=u(),H=Math.pow(2,N),J=typeof this._targetZoom=="number"?r.zoomScale(this._targetZoom):H;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(J*F))),this._type==="wheel"&&(this._startZoom=u(),this._easing=this._smoothOutEasing(200)),this._delta=0}const g=typeof this._targetZoom=="number"?this._targetZoom:u(),x=this._startZoom,b=this._easing;let S,P=!1;if(this._type==="wheel"&&x&&b){const z=Math.min((s.exported.now()-this._lastWheelEventTime)/200,1),F=b(z);S=s.number(x,g,F),z<1?this._frameId||(this._frameId=!0):P=!0}else S=g,P=!0;return this._active=!0,P&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!P,zoomDelta:S-u(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let u=s.ease;if(this._prevEase){const g=this._prevEase,x=(s.exported.now()-g.start)/g.duration,b=g.easing(x+.01)-g.easing(x),S=.27/Math.sqrt(b*b+1e-4)*.01,P=Math.sqrt(.0729-S*S);u=s.bezier(S,P,.25,1)}return this._prevEase={start:s.exported.now(),duration:r,easing:u},u}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=L("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(s.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!s.window.document.fullscreenElement||!!s.window.document.webkitFullscreenElement}_showBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class Qm{constructor(r,u){this._clickZoom=r,this._tapZoom=u}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class eg{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(r,u){return r.preventDefault(),{cameraAnimation:g=>{g.easeTo({duration:300,zoom:g.getZoom()+(r.shiftKey?-1:1),around:g.unproject(u)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Kd{constructor(){this._tap=new Cs({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(r,u,g){this._swipePoint||(this._tapTime&&r.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?g.length>0&&(this._swipePoint=u[0],this._swipeTouch=g[0].identifier):this._tap.touchstart(r,u,g))}touchmove(r,u,g){if(this._tapTime){if(this._swipePoint){if(g[0].identifier!==this._swipeTouch)return;const x=u[0],b=x.y-this._swipePoint.y;return this._swipePoint=x,r.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(r,u,g)}touchend(r,u,g){this._tapTime?this._swipePoint&&g.length===0&&this.reset():this._tap.touchend(r,u,g)&&(this._tapTime=r.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tg{constructor(r,u,g){this._el=r,this._mousePan=u,this._touchPan=g}enable(r){this._inertiaOptions=r||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ng{constructor(r,u,g){this._pitchWithRotate=r.pitchWithRotate,this._mouseRotate=u,this._mousePitch=g}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class ig{constructor(r,u,g,x){this._el=r,this._touchZoom=u,this._touchRotate=g,this._tapDragZoom=x,this._rotationDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Ol=f=>f.zoom||f.drag||f.pitch||f.rotate;class Qd extends s.Event{}class rg{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,u){const g=s.sub([],u,r);this.radius=s.length(g[2]<0?s.div([],g,this.constants):[g[0],g[1],0])}projectRay(r){s.div(r,r,this.constants),s.normalize(r,r),s.mul$1(r,r,this.constants);const u=s.scale$2([],r,this.radius);if(u[2]>0){const g=s.scale$2([],[0,0,1],s.dot(u,[0,0,1])),x=s.scale$2([],s.normalize([],[u[0],u[1],0]),this.radius),b=s.add([],u,s.scale$2([],s.sub([],s.add([],x,g),u),2));u[0]=b[0],u[1]=b[1]}return u}}function Ls(f){return f.panDelta&&f.panDelta.mag()||f.zoomDelta||f.bearingDelta||f.pitchDelta}class ag{constructor(r,u){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wm(r),this._bearingSnap=u.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new rg,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(u),s.bindAll(["handleEvent","handleWindowEvent"],this);const g=this._el;this._listeners=[[g,"touchstart",{passive:!0}],[g,"touchmove",{passive:!1}],[g,"touchend",void 0],[g,"touchcancel",void 0],[g,"mousedown",void 0],[g,"mousemove",void 0],[g,"mouseup",void 0],[s.window.document,"mousemove",{capture:!0}],[s.window.document,"mouseup",void 0],[g,"mouseover",void 0],[g,"mouseout",void 0],[g,"dblclick",void 0],[g,"click",void 0],[g,"keydown",{capture:!1}],[g,"keyup",void 0],[g,"wheel",{passive:!1}],[g,"contextmenu",void 0],[s.window,"blur",void 0]];for(const[x,b,S]of this._listeners)x.addEventListener(b,x===s.window.document?this.handleWindowEvent:this.handleEvent,S)}destroy(){for(const[r,u,g]of this._listeners)r.removeEventListener(u,r===s.window.document?this.handleWindowEvent:this.handleEvent,g)}_addDefaultHandlers(r){const u=this._map,g=u.getCanvasContainer();this._add("mapEvent",new jy(u,r));const x=u.boxZoom=new jm(u,r);this._add("boxZoom",x);const b=new jt,S=new eg;u.doubleClickZoom=new Qm(S,b),this._add("tapZoom",b),this._add("clickZoom",S);const P=new Kd;this._add("tapDragZoom",P);const z=u.touchPitch=new Pu(u);this._add("touchPitch",z);const F=new Ps(r),N=new Xd(r);u.dragRotate=new ng(r,F,N),this._add("mouseRotate",F,["mousePitch"]),this._add("mousePitch",N,["mouseRotate"]);const H=new kl(r),J=new Zm(u,r);u.dragPan=new tg(g,H,J),this._add("mousePan",H),this._add("touchPan",J,["touchZoom","touchRotate"]);const re=new Cu,Q=new Xm;u.touchZoomRotate=new ig(g,Q,re,P),this._add("touchRotate",re,["touchPan","touchZoom"]),this._add("touchZoom",Q,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Na(u));const X=u.scrollZoom=new Km(u,this);this._add("scrollZoom",X,["mousePan"]);const Ae=u.keyboard=new $m;this._add("keyboard",Ae);for(const fe of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])r.interactive&&r[fe]&&u[fe].enable(r[fe])}_add(r,u,g){this._handlers.push({handlerName:r,handler:u,allowed:g}),this._handlersById[r]=u}stop(r){if(!this._updatingCamera){for(const{handler:u}of this._handlers)u.reset();this._inertia.clear(),this._fireEvents({},{},r),this._changes=[]}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ol(this._eventsInProgress)||this.isZooming()}_blockedByActive(r,u,g){for(const x in r)if(x!==g&&(!u||u.indexOf(x)<0))return!0;return!1}handleWindowEvent(r){this.handleEvent(r,`${r.type}Window`)}_getMapTouches(r){const u=[];for(const g of r)this._el.contains(g.target)&&u.push(g);return u}handleEvent(r,u){this._updatingCamera=!0;const g=r.type==="renderFrame",x=g?void 0:r,b={needsRenderFrame:!1},S={},P={},z=r.touches?this._getMapTouches(r.touches):void 0,F=z?ie(this._el,z):g?void 0:K(this._el,r);for(const{handlerName:J,handler:re,allowed:Q}of this._handlers){if(!re.isEnabled())continue;let X;this._blockedByActive(P,Q,J)?re.reset():re[u||r.type]&&(X=re[u||r.type](r,F,z),this.mergeHandlerResult(b,S,X,J,x),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||re.isActive())&&(P[J]=re)}const N={};for(const J in this._previousActiveHandlers)P[J]||(N[J]=x);this._previousActiveHandlers=P,(Object.keys(N).length||Ls(b))&&(this._changes.push([b,S,N]),this._triggerRenderFrame()),(Object.keys(P).length||Ls(b))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:H}=b;H&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],H(this._map))}mergeHandlerResult(r,u,g,x,b){if(!g)return;s.extend(r,g);const S={handlerName:x,originalEvent:g.originalEvent||b};g.zoomDelta!==void 0&&(u.zoom=S),g.panDelta!==void 0&&(u.drag=S),g.pitchDelta!==void 0&&(u.pitch=S),g.bearingDelta!==void 0&&(u.rotate=S)}_applyChanges(){const r={},u={},g={};for(const[x,b,S]of this._changes)x.panDelta&&(r.panDelta=(r.panDelta||new s.pointGeometry(0,0))._add(x.panDelta)),x.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+x.zoomDelta),x.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+x.bearingDelta),x.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+x.pitchDelta),x.around!==void 0&&(r.around=x.around),x.aroundCoord!==void 0&&(r.aroundCoord=x.aroundCoord),x.pinchAround!==void 0&&(r.pinchAround=x.pinchAround),x.noInertia&&(r.noInertia=x.noInertia),s.extend(u,b),s.extend(g,S);this._updateMapTransform(r,u,g),this._changes=[]}_updateMapTransform(r,u,g){const x=this._map,b=x.transform,S=Te=>[Te.x,Te.y,Te.z];if((Te=>{const Se=this._eventsInProgress.drag;return Se&&!this._handlersById[Se.handlerName].isActive()})()&&!Ls(r)){const Te=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",Te!==b.zoom&&this._map._update(!0)}if(!Ls(r))return void this._fireEvents(u,g,!0);let{panDelta:P,zoomDelta:z,bearingDelta:F,pitchDelta:N,around:H,aroundCoord:J,pinchAround:re}=r;re!==void 0&&(H=re),(Te=>u.drag&&!this._eventsInProgress.drag)()&&H&&(this._dragOrigin=S(b.pointCoordinate3D(H)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",x._stop(!0),H=H||x.transform.centerPoint,F&&(b.bearing+=F),N&&(b.pitch+=N),b._updateCameraState();const Q=[0,0,0];if(P){const Te=b.pointCoordinate(H);if(b.projection.name==="globe"){const Se=s.latFromMercatorY(Te.y),Re=b.center.lat,be=Math.min(s.mercatorZfromAltitude(1,Se)/s.mercatorZfromAltitude(1,Re),2);P=P.rotate(-b.angle),Q[0]=-P.x/b.worldSize*be,Q[1]=-P.y/b.worldSize*be}else{const Se=b.pointCoordinate(H.sub(P));Te&&Se&&(Q[0]=Se.x-Te.x,Q[1]=Se.y-Te.y)}}const X=b.zoom,Ae=[0,0,0];if(z){const Te=S(J||b.pointCoordinate3D(H)),Se={dir:s.normalize([],s.sub([],Te,b._camera.position))};if(Se.dir[2]<0){const Re=b.zoomDeltaToMovement(Te,z);s.scale$2(Ae,Se.dir,Re)}}const fe=s.add(Q,Q,Ae);b._translateCameraConstrained(fe),z&&Math.abs(b.zoom-X)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(u,g,!0)}_fireEvents(r,u,g){const x=Ol(this._eventsInProgress),b=Ol(r),S={};for(const N in r){const{originalEvent:H}=r[N];this._eventsInProgress[N]||(S[`${N}start`]=H),this._eventsInProgress[N]=r[N]}!x&&b&&this._fireEvent("movestart",b.originalEvent);for(const N in S)this._fireEvent(N,S[N]);b&&this._fireEvent("move",b.originalEvent);for(const N in r){const{originalEvent:H}=r[N];this._fireEvent(N,H)}const P={};let z;for(const N in this._eventsInProgress){const{handlerName:H,originalEvent:J}=this._eventsInProgress[N];this._handlersById[H].isActive()||(delete this._eventsInProgress[N],z=u[H]||J,P[`${N}end`]=z)}for(const N in P)this._fireEvent(N,P[N]);const F=Ol(this._eventsInProgress);if(g&&(x||b)&&!F){this._updatingCamera=!0;const N=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),H=J=>J!==0&&-this._bearingSnap<J&&J<this._bearingSnap;N?(H(N.bearing||this._map.getBearing())&&(N.bearing=0),this._map.easeTo(N,{originalEvent:z})):(this._map.fire(new s.Event("moveend",{originalEvent:z})),H(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(r,u){this._map.fire(new s.Event(r,u?{originalEvent:u}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(r=>{this._frameId=void 0,this.handleEvent(new Qd("renderFrame",{timeStamp:r})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Lu="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ep extends s.Evented{constructor(r,u){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=u.bearingSnap,s.bindAll(["_renderFrameCallback"],this)}getCenter(){return new s.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(r,u){return this.jumpTo({center:r},u)}panBy(r,u,g){return r=s.pointGeometry.convert(r).mult(-1),this.panTo(this.transform.center,s.extend({offset:r},u),g)}panTo(r,u,g){return this.easeTo(s.extend({center:r},u),g)}getZoom(){return this.transform.zoom}setZoom(r,u){return this.jumpTo({zoom:r},u),this}zoomTo(r,u,g){return this.easeTo(s.extend({zoom:r},u),g)}zoomIn(r,u){return this.zoomTo(this.getZoom()+1,r,u),this}zoomOut(r,u){return this.zoomTo(this.getZoom()-1,r,u),this}getBearing(){return this.transform.bearing}setBearing(r,u){return this.jumpTo({bearing:r},u),this}getPadding(){return this.transform.padding}setPadding(r,u){return this.jumpTo({padding:r},u),this}rotateTo(r,u,g){return this.easeTo(s.extend({bearing:r},u),g)}resetNorth(r,u){return this.rotateTo(0,s.extend({duration:1e3},r),u),this}resetNorthPitch(r,u){return this.easeTo(s.extend({bearing:0,pitch:0,duration:1e3},r),u),this}snapToNorth(r,u){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(r,u):this}getPitch(){return this.transform.pitch}setPitch(r,u){return this.jumpTo({pitch:r},u),this}cameraForBounds(r,u){r=s.LngLatBounds.convert(r);const g=u&&u.bearing||0;return this._cameraForBoxAndBearing(r.getNorthWest(),r.getSouthEast(),g,u)}_extendCameraOptions(r){const u={top:0,bottom:0,right:0,left:0};if(typeof(r=s.extend({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding=="number"){const g=r.padding;r.padding={top:g,bottom:g,right:g,left:g}}return r.padding=s.extend(u,r.padding),r}_cameraForBoxAndBearing(r,u,g,x){const b=this._extendCameraOptions(x),S=this.transform,P=S.padding,z=S.project(s.LngLat.convert(r)),F=S.project(s.LngLat.convert(u)),N=new s.pointGeometry(z.x,F.y),H=new s.pointGeometry(F.x,z.y),J=-s.degToRad(g),re=z.rotate(J),Q=F.rotate(J),X=N.rotate(J),Ae=H.rotate(J),fe=new s.pointGeometry(Math.max(re.x,Q.x,X.x,Ae.x),Math.max(re.y,Q.y,X.y,Ae.y)),Te=new s.pointGeometry(Math.min(re.x,Q.x,X.x,Ae.x),Math.min(re.y,Q.y,X.y,Ae.y)),Se=fe.sub(Te),Re=(S.width-((P.left||0)+(P.right||0)+b.padding.left+b.padding.right))/Se.x,be=(S.height-((P.top||0)+(P.bottom||0)+b.padding.top+b.padding.bottom))/Se.y;if(be<0||Re<0)return void s.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const Fe=Math.min(S.scaleZoom(S.scale*Math.min(Re,be)),b.maxZoom),Qe=typeof b.offset.x=="number"&&typeof b.offset.y=="number"?new s.pointGeometry(b.offset.x,b.offset.y):s.pointGeometry.convert(b.offset),at=new s.pointGeometry((b.padding.left-b.padding.right)/2,(b.padding.top-b.padding.bottom)/2).rotate(g*Math.PI/180),dt=Qe.add(at).mult(S.scale/S.zoomScale(Fe));return{center:S.unproject(z.add(F).div(2).sub(dt)),zoom:Fe,bearing:g}}_cameraForBox(r,u,g,x,b){const S=this._extendCameraOptions(b);g=g||0,x=x||0,r=s.LngLat.convert(r),u=s.LngLat.convert(u);const P=this.transform.clone();P.padding=S.padding;const z=this.getFreeCameraOptions(),F=new s.LngLat(.5*(r.lng+u.lng),.5*(r.lat+u.lat)),N=.5*(g+x);if(P._camera.position[2]<s.mercatorZfromAltitude(N,F.lat))return void s.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");z.lookAtPoint(F),P.setFreeCameraOptions(z);const H=s.MercatorCoordinate.fromLngLat(r),J=s.MercatorCoordinate.fromLngLat(u),re=P.pointRayIntersection(P.centerPoint,N),Q=[(X=P.rayIntersectionCoordinate(re)).x,X.y,X.z];var X;const Ae=P.screenPointToMercatorRay(P.centerPoint),fe=P.projection.name!=="globe";let Te,Se=0;do{const Re=Math.floor(P.zoom),be=1<<Re,Fe=Math.min(be*H.x,be*J.x),Qe=Math.min(be*H.y,be*J.y),at=Math.max(be*H.x,be*J.x),dt=Math.max(be*H.y,be*J.y),ut=new s.Aabb([Fe,Qe,g],[at,dt,x]),Rt=s.Frustum.fromInvProjectionMatrix(P.invProjMatrix,P.worldSize,Re,fe);if(ut.intersects(Rt)!==2){Te&&(P._camera.position=s.scaleAndAdd([],P._camera.position,Ae.dir,-Te),P._updateStateFromCamera());break}const et=s.sub([],P._camera.position,Q);Te=.5*s.length(et),P._camera.position=s.scaleAndAdd([],P._camera.position,Ae.dir,Te);try{P._updateStateFromCamera()}catch(zt){return void s.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++Se<10);return{center:P.center,zoom:P.zoom,bearing:P.bearing,pitch:P.pitch}}fitBounds(r,u,g){return this._fitInternal(this.cameraForBounds(r,u),u,g)}_raycastElevationBox(r,u){const g=this.transform.elevation;if(!g)return;const x=new s.pointGeometry(r.x,u.y),b=new s.pointGeometry(u.x,r.y),S=g.pointCoordinate(r);if(!S)return;const P=g.pointCoordinate(u);if(!P)return;const z=g.pointCoordinate(x);if(!z)return;const F=g.pointCoordinate(b);if(!F)return;const N=new s.MercatorCoordinate(S[0],S[1]).toLngLat(),H=new s.MercatorCoordinate(P[0],P[1]).toLngLat(),J=new s.MercatorCoordinate(z[0],z[1]).toLngLat(),re=new s.MercatorCoordinate(F[0],F[1]).toLngLat(),Q=Math.min(N.lng,Math.min(H.lng,Math.min(J.lng,re.lng))),X=Math.min(N.lat,Math.min(H.lat,Math.min(J.lat,re.lat))),Ae=Math.max(N.lng,Math.max(H.lng,Math.max(J.lng,re.lng))),fe=Math.max(N.lat,Math.max(H.lat,Math.max(J.lat,re.lat))),Te=Math.min(S[3],Math.min(P[3],Math.min(z[3],F[3]))),Se=Math.max(S[3],Math.max(P[3],Math.max(z[3],F[3])));return{minLngLat:new s.LngLat(Q,X),maxLngLat:new s.LngLat(Ae,fe),minAltitude:Te,maxAltitude:Se}}fitScreenCoordinates(r,u,g,x,b){let S,P,z,F;const N=s.pointGeometry.convert(r),H=s.pointGeometry.convert(u),J=this._raycastElevationBox(N,H);if(J)S=J.minLngLat,P=J.maxLngLat,z=J.minAltitude,F=J.maxAltitude;else{if(this.transform.anyCornerOffEdge(N,H))return this;S=this.transform.pointLocation(N),P=this.transform.pointLocation(H)}return this._fitInternal(this.transform.pitch===0?this._cameraForBoxAndBearing(this.transform.pointLocation(s.pointGeometry.convert(r)),this.transform.pointLocation(s.pointGeometry.convert(u)),g,x):this._cameraForBox(S,P,z,F,x),x,b)}_fitInternal(r,u,g){return r?(delete(u=s.extend(r,u)).padding,u.linear?this.easeTo(u,g):this.flyTo(u,g)):this}jumpTo(r,u){this.stop();const g=r.preloadOnly?this.transform.clone():this.transform;let x=!1,b=!1,S=!1;return"zoom"in r&&g.zoom!==+r.zoom&&(x=!0,g.zoom=+r.zoom),r.center!==void 0&&(g.center=s.LngLat.convert(r.center)),"bearing"in r&&g.bearing!==+r.bearing&&(b=!0,g.bearing=+r.bearing),"pitch"in r&&g.pitch!==+r.pitch&&(S=!0,g.pitch=+r.pitch),r.padding==null||g.isPaddingEqual(r.padding)||(g.padding=r.padding),r.preloadOnly?(this._preloadTiles(g),this):(this.fire(new s.Event("movestart",u)).fire(new s.Event("move",u)),x&&this.fire(new s.Event("zoomstart",u)).fire(new s.Event("zoom",u)).fire(new s.Event("zoomend",u)),b&&this.fire(new s.Event("rotatestart",u)).fire(new s.Event("rotate",u)).fire(new s.Event("rotateend",u)),S&&this.fire(new s.Event("pitchstart",u)).fire(new s.Event("pitch",u)).fire(new s.Event("pitchend",u)),this.fire(new s.Event("moveend",u)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||s.warnOnce(Lu),this.transform.getFreeCameraOptions()}setFreeCameraOptions(r,u){const g=this.transform;if(!g.projection.supportsFreeCamera)return s.warnOnce(Lu),this;this.stop();const x=g.zoom,b=g.pitch,S=g.bearing;g.setFreeCameraOptions(r);const P=x!==g.zoom,z=b!==g.pitch,F=S!==g.bearing;return this.fire(new s.Event("movestart",u)).fire(new s.Event("move",u)),P&&this.fire(new s.Event("zoomstart",u)).fire(new s.Event("zoom",u)).fire(new s.Event("zoomend",u)),F&&this.fire(new s.Event("rotatestart",u)).fire(new s.Event("rotate",u)).fire(new s.Event("rotateend",u)),z&&this.fire(new s.Event("pitchstart",u)).fire(new s.Event("pitch",u)).fire(new s.Event("pitchend",u)),this.fire(new s.Event("moveend",u)),this}easeTo(r,u){this._stop(!1,r.easeId),((r=s.extend({offset:[0,0],duration:500,easing:s.ease},r)).animate===!1||!r.essential&&s.exported.prefersReducedMotion)&&(r.duration=0);const g=this.transform,x=this.getZoom(),b=this.getBearing(),S=this.getPitch(),P=this.getPadding(),z="zoom"in r?+r.zoom:x,F="bearing"in r?this._normalizeBearing(r.bearing,b):b,N="pitch"in r?+r.pitch:S,H="padding"in r?r.padding:g.padding,J=s.pointGeometry.convert(r.offset);let re,Q,X;if(g.projection.name==="globe"){const dt=s.MercatorCoordinate.fromLngLat(g.center),ut=J.rotate(-g.angle);dt.x+=ut.x/g.worldSize,dt.y+=ut.y/g.worldSize;const Rt=dt.toLngLat(),et=s.LngLat.convert(r.center||Rt);this._normalizeCenter(et),re=g.centerPoint.add(ut),Q=new s.pointGeometry(dt.x,dt.y).mult(g.worldSize),X=new s.pointGeometry(s.mercatorXfromLng(et.lng),s.mercatorYfromLat(et.lat)).mult(g.worldSize).sub(Q)}else{re=g.centerPoint.add(J);const dt=g.pointLocation(re),ut=s.LngLat.convert(r.center||dt);this._normalizeCenter(ut),Q=g.project(dt),X=g.project(ut).sub(Q)}const Ae=g.zoomScale(z-x);let fe,Te;r.around&&(fe=s.LngLat.convert(r.around),Te=g.locationPoint(fe));const Se=this._zooming||z!==x,Re=this._rotating||b!==F,be=this._pitching||N!==S,Fe=!g.isPaddingEqual(H),Qe=dt=>ut=>{if(Se&&(dt.zoom=s.number(x,z,ut)),Re&&(dt.bearing=s.number(b,F,ut)),be&&(dt.pitch=s.number(S,N,ut)),Fe&&(dt.interpolatePadding(P,H,ut),re=dt.centerPoint.add(J)),fe)dt.setLocationAtPoint(fe,Te);else{const Rt=dt.zoomScale(dt.zoom-x),et=z>x?Math.min(2,Ae):Math.max(.5,Ae),zt=Math.pow(et,1-ut),Pt=dt.unproject(Q.add(X.mult(ut*zt)).mult(Rt));dt.setLocationAtPoint(dt.renderWorldCopies?Pt.wrap():Pt,re)}return r.preloadOnly||this._fireMoveEvents(u),dt};if(r.preloadOnly){const dt=this._emulate(Qe,r.duration,g);return this._preloadTiles(dt),this}const at={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Se,this._rotating=Re,this._pitching=be,this._padding=Fe,this._easeId=r.easeId,this._prepareEase(u,r.noMoveStart,at),this._ease(Qe(g),dt=>{g.recenterOnTerrain(),this._afterEase(u,dt)},r),this}_prepareEase(r,u,g={}){this._moving=!0,this.transform.cameraElevationReference="sea",u||g.moving||this.fire(new s.Event("movestart",r)),this._zooming&&!g.zooming&&this.fire(new s.Event("zoomstart",r)),this._rotating&&!g.rotating&&this.fire(new s.Event("rotatestart",r)),this._pitching&&!g.pitching&&this.fire(new s.Event("pitchstart",r))}_fireMoveEvents(r){this.fire(new s.Event("move",r)),this._zooming&&this.fire(new s.Event("zoom",r)),this._rotating&&this.fire(new s.Event("rotate",r)),this._pitching&&this.fire(new s.Event("pitch",r))}_afterEase(r,u){if(this._easeId&&u&&this._easeId===u)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const g=this._zooming,x=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,g&&this.fire(new s.Event("zoomend",r)),x&&this.fire(new s.Event("rotateend",r)),b&&this.fire(new s.Event("pitchend",r)),this.fire(new s.Event("moveend",r))}flyTo(r,u){if(!r.essential&&s.exported.prefersReducedMotion){const Xt=s.pick(r,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Xt,u)}this.stop(),r=s.extend({offset:[0,0],speed:1.2,curve:1.42,easing:s.ease},r);const g=this.transform,x=this.getZoom(),b=this.getBearing(),S=this.getPitch(),P=this.getPadding(),z="zoom"in r?s.clamp(+r.zoom,g.minZoom,g.maxZoom):x,F="bearing"in r?this._normalizeBearing(r.bearing,b):b,N="pitch"in r?+r.pitch:S,H="padding"in r?r.padding:g.padding,J=g.zoomScale(z-x),re=s.pointGeometry.convert(r.offset);let Q=g.centerPoint.add(re);const X=g.pointLocation(Q),Ae=s.LngLat.convert(r.center||X);this._normalizeCenter(Ae);const fe=g.project(X),Te=g.project(Ae).sub(fe);let Se=r.curve;const Re=Math.max(g.width,g.height),be=Re/J,Fe=Te.mag();if("minZoom"in r){const Xt=s.clamp(Math.min(r.minZoom,x,z),g.minZoom,g.maxZoom),Yt=Re/g.zoomScale(Xt-x);Se=Math.sqrt(Yt/Fe*2)}const Qe=Se*Se;function at(Xt){const Yt=(be*be-Re*Re+(Xt?-1:1)*Qe*Qe*Fe*Fe)/(2*(Xt?be:Re)*Qe*Fe);return Math.log(Math.sqrt(Yt*Yt+1)-Yt)}function dt(Xt){return(Math.exp(Xt)-Math.exp(-Xt))/2}function ut(Xt){return(Math.exp(Xt)+Math.exp(-Xt))/2}const Rt=at(0);let et=function(Xt){return ut(Rt)/ut(Rt+Se*Xt)},zt=function(Xt){return Re*((ut(Rt)*(dt(Yt=Rt+Se*Xt)/ut(Yt))-dt(Rt))/Qe)/Fe;var Yt},Pt=(at(1)-Rt)/Se;if(Math.abs(Fe)<1e-6||!isFinite(Pt)){if(Math.abs(Re-be)<1e-6)return this.easeTo(r,u);const Xt=be<Re?-1:1;Pt=Math.abs(Math.log(be/Re))/Se,zt=function(){return 0},et=function(Yt){return Math.exp(Xt*Se*Yt)}}r.duration="duration"in r?+r.duration:1e3*Pt/("screenSpeed"in r?+r.screenSpeed/Se:+r.speed),r.maxDuration&&r.duration>r.maxDuration&&(r.duration=0);const Jt=b!==F,pt=N!==S,qt=!g.isPaddingEqual(H),mn=Xt=>Yt=>{const vn=Yt*Pt,kn=1/et(vn);Xt.zoom=Yt===1?z:x+Xt.scaleZoom(kn),Jt&&(Xt.bearing=s.number(b,F,Yt)),pt&&(Xt.pitch=s.number(S,N,Yt)),qt&&(Xt.interpolatePadding(P,H,Yt),Q=Xt.centerPoint.add(re));const hn=Yt===1?Ae:Xt.unproject(fe.add(Te.mult(zt(vn))).mult(kn));return Xt.setLocationAtPoint(Xt.renderWorldCopies?hn.wrap():hn,Q),Xt._updateCameraOnTerrain(),r.preloadOnly||this._fireMoveEvents(u),Xt};if(r.preloadOnly){const Xt=this._emulate(mn,r.duration,g);return this._preloadTiles(Xt),this}return this._zooming=!0,this._rotating=Jt,this._pitching=pt,this._padding=qt,this._prepareEase(u,!1),this._ease(mn(g),()=>this._afterEase(u),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(r,u){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const g=this._onEaseEnd;this._onEaseEnd=void 0,g.call(this,u)}if(!r){const g=this.handlers;g&&g.stop(!1)}return this}_ease(r,u,g){g.animate===!1||g.duration===0?(r(1),u()):(this._easeStart=s.exported.now(),this._easeOptions=g,this._onEaseFrame=r,this._onEaseEnd=u,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((s.exported.now()-this._easeStart)/this._easeOptions.duration,1),u=this._onEaseFrame;u&&u(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,u){r=s.wrap(r,-180,180);const g=Math.abs(r-u);return Math.abs(r-360-u)<g&&(r-=360),Math.abs(r+360-u)<g&&(r+=360),r}_normalizeCenter(r){const u=this.transform;if(!u.renderWorldCopies||u.maxBounds)return;const g=r.lng-u.center.lng;r.lng+=g>180?-360:g<-180?360:0}_emulate(r,u,g){const x=Math.ceil(15*u/1e3),b=[],S=r(g.clone());for(let P=0;P<=x;P++){const z=S(P/x);b.push(z.clone())}return b}}class Du{constructor(r={}){this.options=r,s.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(r){const u=this.options&&this.options.compact;return this._map=r,this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=L("button","mapboxgl-ctrl-attrib-button",this._container),L("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=L("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),u&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),u===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(r,u){const g=this._map._getUIString(`AttributionControl.${u}`);r.setAttribute("aria-label",g),r.removeAttribute("title"),r.firstElementChild&&r.firstElementChild.setAttribute("title",g)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const u=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||s.config.ACCESS_TOKEN}];if(r){const g=u.reduce((x,b,S)=>(b.value&&(x+=`${b.key}=${b.value}${S<u.length-1?"&":""}`),x),"?");r.href=`${s.config.FEEDBACK_URL}/${g}${this._map._hash?this._map._hash.getHashString(!0):""}`,r.rel="noopener nofollow",this._setElementTitle(r,"MapFeedback")}}_updateData(r){!r||r.sourceDataType!=="metadata"&&r.sourceDataType!=="visibility"&&r.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let r=[];if(this._map.style.stylesheet){const x=this._map.style.stylesheet;this.styleOwner=x.owner,this.styleId=x.id}const u=this._map.style._sourceCaches;for(const x in u){const b=u[x];if(b.used){const S=b.getSource();S.attribution&&r.indexOf(S.attribution)<0&&r.push(S.attribution)}}r.sort((x,b)=>x.length-b.length),r=r.filter((x,b)=>{for(let S=b+1;S<r.length;S++)if(r[S].indexOf(x)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const g=r.join(" | ");g!==this._attribHTML&&(this._attribHTML=g,r.length?(this._innerContainer.innerHTML=g,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class og{constructor(){s.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(r){this._map=r,this._container=L("div","mapboxgl-ctrl");const u=L("a","mapboxgl-ctrl-logo");return u.target="_blank",u.rel="noopener nofollow",u.href="https://www.mapbox.com/",u.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),u.setAttribute("rel","noopener nofollow"),this._container.appendChild(u),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(r){r&&r.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const r=this._map.style._sourceCaches;if(Object.entries(r).length===0)return!0;for(const u in r){const g=r[u].getSource();if(g.hasOwnProperty("mapbox_logo")&&!g.mapbox_logo)return!1}return!0}_updateCompact(){const r=this._container.children;if(r.length){const u=r[0];this._map.getCanvasContainer().offsetWidth<250?u.classList.add("mapboxgl-compact"):u.classList.remove("mapboxgl-compact")}}}class sg{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const u=++this._id;return this._queue.push({callback:r,id:u,cancelled:!1}),u}remove(r){const u=this._currentlyRunning,g=u?this._queue.concat(u):this._queue;for(const x of g)if(x.id===r)return void(x.cancelled=!0)}run(r=0){const u=this._currentlyRunning=this._queue;this._queue=[];for(const g of u)if(!g.cancelled&&(g.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Iu(f,r,u){if(f=new s.LngLat(f.lng,f.lat),r){const g=new s.LngLat(f.lng-360,f.lat),x=new s.LngLat(f.lng+360,f.lat),b=360*Math.ceil(Math.abs(f.lng-u.center.lng)/360),S=u.locationPoint(f).distSqr(r),P=r.x<0||r.y<0||r.x>u.width||r.y>u.height;u.locationPoint(g).distSqr(r)<S&&(P||Math.abs(g.lng-u.center.lng)<b)?f=g:u.locationPoint(x).distSqr(r)<S&&(P||Math.abs(x.lng-u.center.lng)<b)&&(f=x)}for(;Math.abs(f.lng-u.center.lng)>180;){const g=u.locationPoint(f);if(g.x>=0&&g.y>=0&&g.x<=u.width&&g.y<=u.height)break;f.lng>u.center.lng?f.lng-=360:f.lng+=360}return f}const Ru={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class zu extends s.Evented{constructor(r,u){if(super(),(r instanceof s.window.HTMLElement||u)&&(r=s.extend({element:r},u)),s.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&r.pitchAlignment!=="auto"?r.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),r&&r.element)this._element=r.element,this._offset=s.pointGeometry.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=L("div");const x=41,b=27,S=I("svg",{display:"block",height:x*this._scale+"px",width:b*this._scale+"px",viewBox:`0 0 ${b} ${x}`},this._element),P=I("radialGradient",{id:"shadowGradient"},I("defs",{},S));I("stop",{offset:"10%","stop-opacity":.4},P),I("stop",{offset:"100%","stop-opacity":.05},P),I("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},S),I("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},S),I("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},S),I("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},S),this._offset=s.pointGeometry.convert(r&&r.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",x=>{x.preventDefault()}),this._element.addEventListener("mousedown",x=>{x.preventDefault()});const g=this._element.classList;for(const x in Ru)g.remove(`mapboxgl-marker-anchor-${x}`);g.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(r){return r===this._map||(this.remove(),this._map=r,r.getCanvasContainer().appendChild(this._element),r.on("move",this._updateMoving),r.on("moveend",this._update),r.on("remove",this._clearFadeTimer),r._addMarker(this),this.setDraggable(this._draggable),this._update(),r.on("click",this._onMapClick)),this}remove(){const r=this._map;return r&&(r.off("click",this._onMapClick),r.off("move",this._updateMoving),r.off("moveend",this._update),r.off("mousedown",this._addDragHandler),r.off("touchstart",this._addDragHandler),r.off("mouseup",this._onUp),r.off("touchend",this._onUp),r.off("mousemove",this._onMove),r.off("touchmove",this._onMove),r.off("remove",this._clearFadeTimer),r._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=s.LngLat.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(r){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),r){if(!("offset"in r.options)){const x=Math.sqrt(Math.pow(13.5,2)/2);r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[x,-1*(24.6+x)],"bottom-right":[-x,-1*(24.6+x)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=r,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(r){const u=r.code,g=r.charCode||r.keyCode;u!=="Space"&&u!=="Enter"&&g!==32&&g!==13||this.togglePopup()}_onMapClick(r){const u=r.originalEvent.target,g=this._element;this._popup&&(u===g||g.contains(u))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const r=this._popup;return r?(r.isOpen()?(r.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(r.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const r=this._map;if(!r)return;const u=this._pos;if(!u||u.x<0||u.x>r.transform.width||u.y<0||u.y>r.transform.height)return void this._clearFadeTimer();const g=r.unproject(u);let x=!1;if(r.transform._terrainEnabled()&&r.getTerrain()){const S=r.getFreeCameraOptions();if(S.position){const P=S.position.toLngLat();x=P.distanceTo(g)<.9*P.distanceTo(this._lngLat)}}const b=(1-r._queryFogOpacity(g))*(x?.2:1);this._element.style.opacity=`${b}`,this._popup&&this._popup._setOpacity(`${b}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const r=this._pos;if(!r)return;const u=this._offset.mult(this._scale),g=this._calculatePitch(),x=this._calculateRotation();this._element.style.transform=`
  3891. translate(${r.x}px, ${r.y}px) ${Ru[this._anchor]}
  3892. rotateX(${g}deg) rotateZ(${x}deg)
  3893. translate(${u.x}px, ${u.y}px)
  3894. `}_calculatePitch(){return this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?0:this._map&&this._pitchAlignment==="map"?this._map.getPitch():0}_calculateRotation(){return this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?this._rotation:this._map&&this._rotationAlignment==="map"?this._rotation-this._map.getBearing():0}_update(r){s.window.cancelAnimationFrame(this._updateFrameId);const u=this._map;u&&(u.transform.renderWorldCopies&&(this._lngLat=Iu(this._lngLat,this._pos,u.transform)),this._pos=u.project(this._lngLat),r===!0?this._updateFrameId=s.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),u._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!u.getTerrain()&&!u.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(r){return this._offset=s.pointGeometry.convert(r),this._update(),this}_onMove(r){const u=this._map;if(u){if(!this._isDragging){const g=this._clickTolerance||u._clickTolerance;this._isDragging=r.point.dist(this._pointerdownPos)>=g}this._isDragging&&(this._pos=r.point.sub(this._positionDelta),this._lngLat=u.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new s.Event("dragstart"))),this.fire(new s.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const r=this._map;r&&(r.off("mousemove",this._onMove),r.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new s.Event("dragend")),this._state="inactive"}_addDragHandler(r){const u=this._map;u&&this._element.contains(r.originalEvent.target)&&(r.preventDefault(),this._positionDelta=r.point.sub(this._pos),this._pointerdownPos=r.point,this._state="pending",u.on("mousemove",this._onMove),u.on("touchmove",this._onMove),u.once("mouseup",this._onUp),u.once("touchend",this._onUp))}setDraggable(r){this._draggable=!!r;const u=this._map;return u&&(r?(u.on("mousedown",this._addDragHandler),u.on("touchstart",this._addDragHandler)):(u.off("mousedown",this._addDragHandler),u.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(r){return this._rotation=r||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r&&r!=="auto"?r:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class qy{constructor(r){this.jumpTo(r)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const u=s.easeCubicInOut((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-u)+this._end*u}isEasing(r){return r>=this._startTime&&r<=this._endTime}jumpTo(r){this._startTime=-1/0,this._endTime=-1/0,this._start=r,this._end=r}easeTo(r,u,g){this._start=this.getValue(u),this._end=r,this._startTime=u,this._endTime=u+g}}const Zy={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},tp={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function Nl(f){f.parentNode&&f.parentNode.removeChild(f)}const np={showCompass:!0,showZoom:!0,visualizePitch:!1};class ip{constructor(r,u,g=!1){this._clickTolerance=10,this.element=u,this.mouseRotate=new Ps({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,g&&(this.mousePitch=new Xd({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),s.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),u.addEventListener("mousedown",this.mousedown),u.addEventListener("touchstart",this.touchstart,{passive:!1}),u.addEventListener("touchmove",this.touchmove),u.addEventListener("touchend",this.touchend),u.addEventListener("touchcancel",this.reset)}down(r,u){this.mouseRotate.mousedown(r,u),this.mousePitch&&this.mousePitch.mousedown(r,u),q()}move(r,u){const g=this.map,x=this.mouseRotate.mousemoveWindow(r,u),b=x&&x.bearingDelta;if(b&&g.setBearing(g.getBearing()+b),this.mousePitch){const S=this.mousePitch.mousemoveWindow(r,u),P=S&&S.pitchDelta;P&&g.setPitch(g.getPitch()+P)}}off(){const r=this.element;r.removeEventListener("mousedown",this.mousedown),r.removeEventListener("touchstart",this.touchstart,{passive:!1}),r.removeEventListener("touchmove",this.touchmove),r.removeEventListener("touchend",this.touchend),r.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ee(),s.window.removeEventListener("mousemove",this.mousemove),s.window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(s.extend({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),K(this.element,r)),s.window.addEventListener("mousemove",this.mousemove),s.window.addEventListener("mouseup",this.mouseup)}mousemove(r){this.move(r,K(this.element,r))}mouseup(r){this.mouseRotate.mouseupWindow(r),this.mousePitch&&this.mousePitch.mouseupWindow(r),this.offTemp()}touchstart(r){r.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ie(this.element,r.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>r.preventDefault()},this._startPos))}touchmove(r){r.targetTouches.length!==1?this.reset():(this._lastPos=ie(this.element,r.targetTouches)[0],this.move({preventDefault:()=>r.preventDefault()},this._lastPos))}touchend(r){r.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const _r={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1};let Ir,Ul=0,Wo=!1;const rp={maxWidth:100,unit:"metric"};function ku(f,r,u){const g=u&&u.maxWidth||100,x=f._containerHeight/2,b=f._containerWidth/2-g/2,S=f.unproject([b,x]),P=f.unproject([b+g,x]),z=S.distanceTo(P);if(u&&u.unit==="imperial"){const F=3.2808*z;F>5280?Ds(r,g,F/5280,f._getUIString("ScaleControl.Miles"),f):Ds(r,g,F,f._getUIString("ScaleControl.Feet"),f)}else u&&u.unit==="nautical"?Ds(r,g,z/1852,f._getUIString("ScaleControl.NauticalMiles"),f):z>=1e3?Ds(r,g,z/1e3,f._getUIString("ScaleControl.Kilometers"),f):Ds(r,g,z,f._getUIString("ScaleControl.Meters"),f)}function Ds(f,r,u,g,x){const b=function(P){const z=Math.pow(10,`${Math.floor(P)}`.length-1);let F=P/z;return F=F>=10?10:F>=5?5:F>=3?3:F>=2?2:F>=1?1:function(N){const H=Math.pow(10,Math.ceil(-Math.log(N)/Math.LN10));return Math.round(N*H)/H}(F),z*F}(u),S=b/u;x._requestDomTask(()=>{f.style.width=r*S+"px",f.innerHTML=`${b}&nbsp;${g}`})}const qr={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},ci=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Vl(f=new s.pointGeometry(0,0),r="bottom"){if(typeof f=="number"){const u=Math.round(Math.sqrt(.5*Math.pow(f,2)));switch(r){case"top":return new s.pointGeometry(0,f);case"top-left":return new s.pointGeometry(u,u);case"top-right":return new s.pointGeometry(-u,u);case"bottom":return new s.pointGeometry(0,-f);case"bottom-left":return new s.pointGeometry(u,-u);case"bottom-right":return new s.pointGeometry(-u,-u);case"left":return new s.pointGeometry(f,0);case"right":return new s.pointGeometry(-f,0)}return new s.pointGeometry(0,0)}return f instanceof s.pointGeometry||Array.isArray(f)?s.pointGeometry.convert(f):s.pointGeometry.convert(f[r]||[0,0])}const Is={version:s.version,supported:M,setRTLTextPlugin:s.setRTLTextPlugin,getRTLTextPluginStatus:s.getRTLTextPluginStatus,Map:class extends ep{constructor(f){if((f=s.extend({},tp,f)).minZoom!=null&&f.maxZoom!=null&&f.minZoom>f.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(f.minPitch!=null&&f.maxPitch!=null&&f.minPitch>f.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(f.minPitch!=null&&f.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(f.maxPitch!=null&&f.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(f.antialias&&s.isSafariWithAntialiasingBug(s.window)&&(f.antialias=!1,s.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Eu(f.minZoom,f.maxZoom,f.minPitch,f.maxPitch,f.renderWorldCopies),f),this._interactive=f.interactive,this._minTileCacheSize=f.minTileCacheSize,this._maxTileCacheSize=f.maxTileCacheSize,this._failIfMajorPerformanceCaveat=f.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=f.preserveDrawingBuffer,this._antialias=f.antialias,this._trackResize=f.trackResize,this._bearingSnap=f.bearingSnap,this._refreshExpiredTiles=f.refreshExpiredTiles,this._fadeDuration=f.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=f.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=f.collectResourceTiming,this._optimizeForTerrain=f.optimizeForTerrain,this._renderTaskQueue=new sg,this._domRenderTaskQueue=new sg,this._controls=[],this._markers=[],this._mapId=s.uniqueId(),this._locale=s.extend({},Zy,f.locale),this._clickTolerance=f.clickTolerance,this._cooperativeGestures=f.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new qy(0),this._explicitProjection=null,this._requestManager=new s.RequestManager(f.transformRequest,f.accessToken,f.testMode),this._silenceAuthErrors=!!f.testMode,typeof f.container=="string"){if(this._container=s.window.document.getElementById(f.container),!this._container)throw new Error(`Container '${f.container}' not found.`)}else{if(!(f.container instanceof s.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=f.container}if(this._container.childNodes.length>0&&s.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),f.maxBounds&&this.setMaxBounds(f.maxBounds),s.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),s.window!==void 0&&(s.window.addEventListener("online",this._onWindowOnline,!1),s.window.addEventListener("resize",this._onWindowResize,!1),s.window.addEventListener("orientationchange",this._onWindowResize,!1),s.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new ag(this,f),this._localFontFamily=f.localFontFamily,this._localIdeographFontFamily=f.localIdeographFontFamily,f.style&&this.setStyle(f.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),f.projection&&this.setProjection(f.projection),this._hash=f.hash&&new Nm(typeof f.hash=="string"&&f.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch}),f.bounds&&(this.resize(),this.fitBounds(f.bounds,s.extend({},f.fitBoundsOptions,{duration:0})))),this.resize(),f.attributionControl&&this.addControl(new Du({customAttribution:f.customAttribution})),this._logoControl=new og,this.addControl(this._logoControl,f.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",r=>{this._update(r.dataType==="style"),this.fire(new s.Event(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new s.Event(`${r.dataType}dataloading`,r))})}_getMapId(){return this._mapId}addControl(f,r){if(r===void 0&&(r=f.getDefaultPosition?f.getDefaultPosition():"top-right"),!f||!f.onAdd)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const u=f.onAdd(this);this._controls.push(f);const g=this._controlPositions[r];return r.indexOf("bottom")!==-1?g.insertBefore(u,g.firstChild):g.appendChild(u),this}removeControl(f){if(!f||!f.onRemove)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(f);return r>-1&&this._controls.splice(r,1),f.onRemove(this),this}hasControl(f){return this._controls.indexOf(f)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(f){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const r=!this._moving;return r&&this.fire(new s.Event("movestart",f)).fire(new s.Event("move",f)),this.fire(new s.Event("resize",f)),r&&this.fire(new s.Event("moveend",f)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(f){return this.transform.setMaxBounds(s.LngLatBounds.convert(f)),this._update()}setMinZoom(f){if((f=f==null?-2:f)>=-2&&f<=this.transform.maxZoom)return this.transform.minZoom=f,this._update(),this.getZoom()<f?this.setZoom(f):this.fire(new s.Event("zoomstart")).fire(new s.Event("zoom")).fire(new s.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(f){if((f=f==null?22:f)>=this.transform.minZoom)return this.transform.maxZoom=f,this._update(),this.getZoom()>f?this.setZoom(f):this.fire(new s.Event("zoomstart")).fire(new s.Event("zoom")).fire(new s.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(f){if((f=f==null?0:f)<0)throw new Error("minPitch must be greater than or equal to 0");if(f>=0&&f<=this.transform.maxPitch)return this.transform.minPitch=f,this._update(),this.getPitch()<f?this.setPitch(f):this.fire(new s.Event("pitchstart")).fire(new s.Event("pitch")).fire(new s.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(f){if((f=f==null?85:f)>85)throw new Error("maxPitch must be less than or equal to 85");if(f>=this.transform.minPitch)return this.transform.maxPitch=f,this._update(),this.getPitch()>f?this.setPitch(f):this.fire(new s.Event("pitchstart")).fire(new s.Event("pitch")).fire(new s.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(f){return this.transform.renderWorldCopies=f,this._update()}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}setProjection(f){return this._lazyInitEmptyStyle(),f?typeof f=="string"&&(f={name:f}):f=null,this._updateProjection(f)}_updateProjection(f){f===null&&(this._explicitProjection=null);const r=f||this.getProjection(),u=this.transform.setProjection(r);if(f&&(this._explicitProjection=this.transform.getProjection()),u){this.painter.clearBackgroundTiles();for(const g in this.style._sourceCaches)this.style._sourceCaches[g].clearTiles();this.style.applyProjectionUpdate(),this._update(!0)}return this}project(f){return this.transform.locationPoint3D(s.LngLat.convert(f))}unproject(f){return this.transform.pointLocation3D(s.pointGeometry.convert(f))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(f,r,u){if(f==="mouseenter"||f==="mouseover"){let g=!1;const x=S=>{const P=r.filter(F=>this.getLayer(F)),z=P.length?this.queryRenderedFeatures(S.point,{layers:P}):[];z.length?g||(g=!0,u.call(this,new Dr(f,this,S.originalEvent,{features:z}))):g=!1},b=()=>{g=!1};return{layers:new Set(r),listener:u,delegates:{mousemove:x,mouseout:b}}}if(f==="mouseleave"||f==="mouseout"){let g=!1;const x=S=>{const P=r.filter(z=>this.getLayer(z));(P.length?this.queryRenderedFeatures(S.point,{layers:P}):[]).length?g=!0:g&&(g=!1,u.call(this,new Dr(f,this,S.originalEvent)))},b=S=>{g&&(g=!1,u.call(this,new Dr(f,this,S.originalEvent)))};return{layers:new Set(r),listener:u,delegates:{mousemove:x,mouseout:b}}}{const g=x=>{const b=r.filter(P=>this.getLayer(P)),S=b.length?this.queryRenderedFeatures(x.point,{layers:b}):[];S.length&&(x.features=S,u.call(this,x),delete x.features)};return{layers:new Set(r),listener:u,delegates:{[f]:g}}}}on(f,r,u){if(u===void 0)return super.on(f,r);Array.isArray(r)||(r=[r]);const g=this._createDelegatedListener(f,r,u);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[f]=this._delegatedListeners[f]||[],this._delegatedListeners[f].push(g);for(const x in g.delegates)this.on(x,g.delegates[x]);return this}once(f,r,u){if(u===void 0)return super.once(f,r);Array.isArray(r)||(r=[r]);const g=this._createDelegatedListener(f,r,u);for(const x in g.delegates)this.once(x,g.delegates[x]);return this}off(f,r,u){if(u===void 0)return super.off(f,r);r=new Set(Array.isArray(r)?r:[r]);const g=(b,S)=>{if(b.size!==S.size)return!1;for(const P of b)if(!S.has(P))return!1;return!0},x=this._delegatedListeners?this._delegatedListeners[f]:void 0;return x&&(b=>{for(let S=0;S<b.length;S++){const P=b[S];if(P.listener===u&&g(P.layers,r)){for(const z in P.delegates)this.off(z,P.delegates[z]);return b.splice(S,1),this}}})(x),this}queryRenderedFeatures(f,r){return this.style?(r!==void 0||f===void 0||f instanceof s.pointGeometry||Array.isArray(f)||(r=f,f=void 0),this.style.queryRenderedFeatures(f=f||[[0,0],[this.transform.width,this.transform.height]],r=r||{},this.transform)):[]}querySourceFeatures(f,r){return this.style.querySourceFeatures(f,r)}queryTerrainElevation(f,r){const u=this.transform.elevation;return u?(r=s.extend({},{exaggerated:!0},r),u.getAtPoint(s.MercatorCoordinate.fromLngLat(f),null,r.exaggerated)):null}setStyle(f,r){return(r=s.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r)).diff!==!1&&r.localIdeographFontFamily===this._localIdeographFontFamily&&r.localFontFamily===this._localFontFamily&&this.style&&f?(this._diffStyle(f,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(f,r))}_getUIString(f){const r=this._locale[f];if(r==null)throw new Error(`Missing UI string '${f}'`);return r}_updateStyle(f,r){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),f&&(this.style=new gr(this,r||{}),this.style.setEventedParent(this,{style:this.style}),typeof f=="string"?this.style.loadURL(f):this.style.loadJSON(f)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new gr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(f,r){if(typeof f=="string"){const u=this._requestManager.normalizeStyleURL(f),g=this._requestManager.transformRequest(u,s.ResourceType.Style);s.getJSON(g,(x,b)=>{x?this.fire(new s.ErrorEvent(x)):b&&this._updateDiff(b,r)})}else typeof f=="object"&&this._updateDiff(f,r)}_updateDiff(f,r){try{this.style.setState(f)&&this._update(!0)}catch(u){s.warnOnce(`Unable to perform style diff: ${u.message||u.error||u}. Rebuilding the style from scratch.`),this._updateStyle(f,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(s.warnOnce("There is no style added to the map."),!1)}addSource(f,r){return this._lazyInitEmptyStyle(),this.style.addSource(f,r),this._update(!0)}isSourceLoaded(f){return!!this.style&&this.style._isSourceCacheLoaded(f)}areTilesLoaded(){const f=this.style&&this.style._sourceCaches;for(const r in f){const u=f[r]._tiles;for(const g in u){const x=u[g];if(x.state!=="loaded"&&x.state!=="errored")return!1}}return!0}addSourceType(f,r,u){this._lazyInitEmptyStyle(),this.style.addSourceType(f,r,u)}removeSource(f){return this.style.removeSource(f),this._updateTerrain(),this._update(!0)}getSource(f){return this.style.getSource(f)}addImage(f,r,{pixelRatio:u=1,sdf:g=!1,stretchX:x,stretchY:b,content:S}={}){if(this._lazyInitEmptyStyle(),r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap){const{width:P,height:z,data:F}=s.exported.getImageData(r);this.style.addImage(f,{data:new s.RGBAImage({width:P,height:z},F),pixelRatio:u,stretchX:x,stretchY:b,content:S,sdf:g,version:0})}else if(r.width===void 0||r.height===void 0)this.fire(new s.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:P,height:z}=r,F=r;this.style.addImage(f,{data:new s.RGBAImage({width:P,height:z},new Uint8Array(F.data)),pixelRatio:u,stretchX:x,stretchY:b,content:S,sdf:g,version:0,userImage:F}),F.onAdd&&F.onAdd(this,f)}}updateImage(f,r){const u=this.style.getImage(f);if(!u)return void this.fire(new s.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const g=r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap?s.exported.getImageData(r):r,{width:x,height:b}=g;x!==void 0&&b!==void 0?x===u.data.width&&b===u.data.height?(u.data.replace(g.data,!(r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap)),this.style.updateImage(f,u)):this.fire(new s.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):this.fire(new s.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(f){return f?!!this.style.getImage(f):(this.fire(new s.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(f){this.style.removeImage(f)}loadImage(f,r){s.getImage(this._requestManager.transformRequest(f,s.ResourceType.Image),(u,g)=>{r(u,g instanceof s.window.HTMLImageElement?s.exported.getImageData(g):g)})}listImages(){return this.style.listImages()}addLayer(f,r){return this._lazyInitEmptyStyle(),this.style.addLayer(f,r),this._update(!0)}moveLayer(f,r){return this.style.moveLayer(f,r),this._update(!0)}removeLayer(f){return this.style.removeLayer(f),this._update(!0)}getLayer(f){return this.style.getLayer(f)}setLayerZoomRange(f,r,u){return this.style.setLayerZoomRange(f,r,u),this._update(!0)}setFilter(f,r,u={}){return this.style.setFilter(f,r,u),this._update(!0)}getFilter(f){return this.style.getFilter(f)}setPaintProperty(f,r,u,g={}){return this.style.setPaintProperty(f,r,u,g),this._update(!0)}getPaintProperty(f,r){return this.style.getPaintProperty(f,r)}setLayoutProperty(f,r,u,g={}){return this.style.setLayoutProperty(f,r,u,g),this._update(!0)}getLayoutProperty(f,r){return this.style.getLayoutProperty(f,r)}setLight(f,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(f,r),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(f){return this._lazyInitEmptyStyle(),!f&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(f),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(f){return this._lazyInitEmptyStyle(),this.style.setFog(f),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(f){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(s.LngLat.convert(f),this.transform):0}setFeatureState(f,r){return this.style.setFeatureState(f,r),this._update()}removeFeatureState(f,r){return this.style.removeFeatureState(f,r),this._update()}getFeatureState(f){return this.style.getFeatureState(f)}_updateContainerDimensions(){if(!this._container)return;const f=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let u,g,x,b=this._container;for(;b&&(!g||!x);){const S=s.window.getComputedStyle(b).transform;S&&S!=="none"&&(u=S.match(/matrix.*\((.+)\)/)[1].split(", "),u[0]&&u[0]!=="0"&&u[0]!=="1"&&(g=u[0]),u[3]&&u[3]!=="0"&&u[3]!=="1"&&(x=u[3])),b=b.parentElement}this._containerWidth=g?Math.abs(f/g):f,this._containerHeight=x?Math.abs(r/x):r}_detectMissingCSS(){s.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&s.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const f=this._container;f.classList.add("mapboxgl-map"),(this._missingCSSCanary=L("div","mapboxgl-canary",f)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=L("div","mapboxgl-canvas-container",f);this._interactive&&r.classList.add("mapboxgl-interactive"),this._canvas=L("canvas","mapboxgl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const u=this._controlContainer=L("div","mapboxgl-control-container",f),g=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(x=>{g[x]=L("div",`mapboxgl-ctrl-${x}`,u)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(f,r){const u=s.exported.devicePixelRatio||1;this._canvas.width=u*Math.ceil(f),this._canvas.height=u*Math.ceil(r),this._canvas.style.width=`${f}px`,this._canvas.style.height=`${r}px`}_addMarker(f){this._markers.push(f)}_removeMarker(f){const r=this._markers.indexOf(f);r!==-1&&this._markers.splice(r,1)}_setupPainter(){const f=s.extend({},M.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",f)||this._canvas.getContext("experimental-webgl",f);r?(s.storeAuthState(r,!0),this.painter=new Fm(r,this.transform),this.on("data",u=>{u.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),s.exported$1.testSupport(r)):this.fire(new s.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(f){f.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.Event("webglcontextlost",{originalEvent:f}))}_contextRestored(f){this._setupPainter(),this.resize(),this._update(),this.fire(new s.Event("webglcontextrestored",{originalEvent:f}))}_onMapScroll(f){if(f.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(f){return this.style?(this._styleDirty=this._styleDirty||f,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(f){return this._update(),this._renderTaskQueue.add(f)}_cancelRenderFrame(f){this._renderTaskQueue.remove(f)}_requestDomTask(f){!this.loaded()||this.loaded()&&!this.isMoving()?f():this._domRenderTaskQueue.add(f)}_render(f){let r;const u=this.painter.context.extTimerQuery,g=s.exported.now();if(this.listens("gpu-timing-frame")&&(r=u.createQueryEXT(),u.beginQueryEXT(u.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(f),this._domRenderTaskQueue.run(f),this._removed)return;let x=!1;const b=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const z=this.transform.zoom,F=this.transform.pitch,N=s.exported.now();this.style.zoomHistory.update(z,N);const H=new s.EvaluationParameters(z,{now:N,fadeDuration:b,pitch:F,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),J=H.crossFadingFactor();J===1&&J===this._crossFadingFactor||(x=!0,this._crossFadingFactor=J),this.style.update(H)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let S=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),S=this._updateAverageElevation(g),this.style._updateSources(this.transform),this._forceMarkerUpdate()):S=this._updateAverageElevation(g),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,b,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:b,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new s.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new s.Event("load"))),this.style&&(this.style.hasTransitions()||x)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const z=s.exported.now()-g;u.endQueryEXT(u.TIME_ELAPSED_EXT,r),setTimeout(()=>{const F=u.getQueryObjectEXT(r,u.QUERY_RESULT_EXT)/1e6;u.deleteQueryEXT(r),this.fire(new s.Event("gpu-timing-frame",{cpuTime:z,gpuTime:F}))},50)}if(this.listens("gpu-timing-layer")){const z=this.painter.collectGpuTimers();setTimeout(()=>{const F=this.painter.queryGpuTimers(z);this.fire(new s.Event("gpu-timing-layer",{layerTimes:F}))},50)}const P=this._sourcesDirty||this._styleDirty||this._placementDirty||S;if(P||this._repaint)this.triggerRepaint();else{const z=!this.isMoving()&&this.loaded();if(z&&(S=this._updateAverageElevation(g,!0)),S)this.triggerRepaint();else if(this._triggerFrame(!1),z&&(this.fire(new s.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const F=this._calculateSpeedIndex();this.fire(new s.Event("speedindexcompleted",{speedIndex:F})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||P||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const f of this._markers)f._update()}_updateAverageElevation(f,r=!1){const u=g=>(this.transform.averageElevation=g,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&u(0);if((r||f-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(f)){const g=this.transform.averageElevation;let x=this.transform.sampleAverageElevation(),b=!1;this.transform.elevation&&(b=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(x)?x=0:this._averageElevationLastSampledAt=f;const S=Math.abs(g-x);if(S>1){if(this._isInitialLoad||b)return this._averageElevation.jumpTo(x),u(x);this._averageElevation.easeTo(x,f,300)}else if(S>1e-4)return this._averageElevation.jumpTo(x),u(x)}return!!this._averageElevation.isEasing(f)&&u(this._averageElevation.getValue(f))}_authenticate(){s.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,f=>{if(f&&(f.message===s.AUTH_ERR_MSG||f.status===401)){const r=this.painter.context.gl;s.storeAuthState(r,!1),this._logoControl instanceof og&&this._logoControl._updateLogo(),r&&r.clear(r.DEPTH_BUFFER_BIT|r.COLOR_BUFFER_BIT|r.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new s.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),s.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const f=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const u=this.painter.context.gl,g=u.createFramebuffer();function x(b){u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,b,0);const S=new Uint8Array(u.drawingBufferWidth*u.drawingBufferHeight*4);return u.readPixels(0,0,u.drawingBufferWidth,u.drawingBufferHeight,u.RGBA,u.UNSIGNED_BYTE,S),S}return u.bindFramebuffer(u.FRAMEBUFFER,g),this._canvasPixelComparison(x(f),r.canvasCopies.map(x),r.timeStamps)}_canvasPixelComparison(f,r,u){let g=u[1]-u[0];const x=f.length/4;for(let b=0;b<r.length;b++){const S=r[b];let P=0;for(let z=0;z<S.length;z+=4)S[z]===f[z]&&S[z+1]===f[z+1]&&S[z+2]===f[z+2]&&S[z+3]===f[z+3]&&(P+=1);g+=(u[b+2]-u[b+1])*(1-P/x)}return g}remove(){this._hash&&this._hash.remove();for(const r of this._controls)r.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),s.window!==void 0&&(s.window.removeEventListener("resize",this._onWindowResize,!1),s.window.removeEventListener("orientationchange",this._onWindowResize,!1),s.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),s.window.removeEventListener("online",this._onWindowOnline,!1));const f=this.painter.context.gl.getExtension("WEBGL_lose_context");f&&f.loseContext(),Nl(this._canvasContainer),Nl(this._controlContainer),Nl(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),s.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new s.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(f){this._renderNextFrame=this._renderNextFrame||f,this.style&&!this._frame&&(this._frame=s.exported.frame(r=>{const u=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,u&&this._render(r)}))}_preloadTiles(f){const r=this.style?Object.values(this.style._sourceCaches):[];return s.asyncAll(r,(u,g)=>u._preloadTiles(f,g),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(f){this._trackResize&&this.resize({originalEvent:f})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(f){this._showTileBoundaries!==f&&(this._showTileBoundaries=f,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(f){this._showTerrainWireframe!==f&&(this._showTerrainWireframe=f,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(f){this._speedIndexTiming!==f&&(this._speedIndexTiming=f,this._update())}get showPadding(){return!!this._showPadding}set showPadding(f){this._showPadding!==f&&(this._showPadding=f,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(f){this._showCollisionBoxes!==f&&(this._showCollisionBoxes=f,f?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(f){this._showOverdrawInspector!==f&&(this._showOverdrawInspector=f,this._update())}get repaint(){return!!this._repaint}set repaint(f){this._repaint!==f&&(this._repaint=f,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(f){this._vertices=f,this._update()}_setCacheLimits(f,r){s.setCacheLimits(f,r)}get version(){return s.version}},NavigationControl:class{constructor(f){this.options=s.extend({},np,f),this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(s.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",r=>{this._map&&this._map.zoomIn({},{originalEvent:r})}),L("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",r=>{this._map&&this._map.zoomOut({},{originalEvent:r})}),L("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(s.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",r=>{const u=this._map;u&&(this.options.visualizePitch?u.resetNorthPitch({},{originalEvent:r}):u.resetNorth({},{originalEvent:r}))}),this._compassIcon=L("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const f=this._map;if(!f)return;const r=f.getZoom(),u=r===f.getMaxZoom(),g=r===f.getMinZoom();this._zoomInButton.disabled=u,this._zoomOutButton.disabled=g,this._zoomInButton.setAttribute("aria-disabled",u.toString()),this._zoomOutButton.setAttribute("aria-disabled",g.toString())}_rotateCompassArrow(){const f=this._map;if(!f)return;const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(f.transform.pitch*(Math.PI/180)),.5)}) rotateX(${f.transform.pitch}deg) rotateZ(${f.transform.angle*(180/Math.PI)}deg)`:`rotate(${f.transform.angle*(180/Math.PI)}deg)`;f._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=r)})}onAdd(f){return this._map=f,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),f.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&f.on("pitch",this._rotateCompassArrow),f.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ip(f,this._compass,this.options.visualizePitch)),this._container}onRemove(){const f=this._map;f&&(this._container.remove(),this.options.showZoom&&f.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&f.off("pitch",this._rotateCompassArrow),f.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(f,r){const u=L("button",f,this._container);return u.type="button",u.addEventListener("click",r),u}_setButtonTitle(f,r){if(!this._map)return;const u=this._map._getUIString(`NavigationControl.${r}`);f.setAttribute("aria-label",u),f.firstElementChild&&f.firstElementChild.setAttribute("title",u)}},GeolocateControl:class extends s.Evented{constructor(f){super(),this.options=s.extend({},_r,f),s.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Zd(this._updateMarkerRotation,20)}onAdd(f){var r;return this._map=f,this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-group"),r=this._setupUI,Ir!==void 0?r(Ir):s.window.navigator.permissions!==void 0?s.window.navigator.permissions.query({name:"geolocation"}).then(u=>{Ir=u.state!=="denied",r(Ir)}):(Ir=!!s.window.navigator.geolocation,r(Ir)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(s.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Ul=0,Wo=!1}_isOutOfMapMaxBounds(f){const r=this._map.getMaxBounds(),u=f.coords;return!!r&&(u.longitude<r.getWest()||u.longitude>r.getEast()||u.latitude<r.getSouth()||u.latitude>r.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(f){if(this._map){if(this._isOutOfMapMaxBounds(f))return this._setErrorState(),this.fire(new s.Event("outofmaxbounds",f)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=f,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(f),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(f),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("geolocate",f)),this._finish()}}_updateCamera(f){const r=new s.LngLat(f.coords.longitude,f.coords.latitude),u=f.coords.accuracy,g=this._map.getBearing(),x=s.extend({bearing:g},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(u),x,{geolocateSource:!0})}_updateMarker(f){if(f){const r=new s.LngLat(f.coords.longitude,f.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=f.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const f=this._map._containerHeight/2,r=this._map.unproject([0,f]),u=this._map.unproject([100,f]),g=r.distanceTo(u)/100,x=Math.ceil(2*this._accuracy/g);this._circleElement.style.width=`${x}px`,this._circleElement.style.height=`${x}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(f){if(this._map){if(this.options.trackUserLocation)if(f.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(f.code===3&&Wo)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("error",f)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(f){if(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=L("button","mapboxgl-ctrl-geolocate",this._container),L("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",f===!1){s.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}else{const r=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=L("div","mapboxgl-user-location"),this._dotElement.appendChild(L("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(L("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new zu({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=L("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new zu({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",r=>{r.geolocateSource||this._watchState!=="ACTIVE_LOCK"||r.originalEvent&&r.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new s.Event("trackuserlocationend")))})}_onDeviceOrientation(f){this._userLocationDotMarker&&(f.webkitCompassHeading?this._heading=f.webkitCompassHeading:f.absolute===!0&&(this._heading=-1*f.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return s.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new s.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ul--,Wo=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new s.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new s.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let f;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ul++,Ul>1?(f={maximumAge:6e5,timeout:0},Wo=!0):(f=this.options.positionOptions,Wo=!1),this._geolocationWatchID=s.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,f),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else s.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const f=()=>{s.window.addEventListener("ondeviceorientationabsolute"in s.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};s.window.DeviceMotionEvent!==void 0&&typeof s.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(r=>{r==="granted"&&f()}).catch(console.error):f()}_clearWatch(){s.window.navigator.geolocation.clearWatch(this._geolocationWatchID),s.window.removeEventListener("deviceorientation",this._onDeviceOrientation),s.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Du,ScaleControl:class{constructor(f){this.options=s.extend({},rp,f),s.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){ku(this._map,this._container,this.options)}onAdd(f){return this._map=f,this._container=L("div","mapboxgl-ctrl mapboxgl-ctrl-scale",f.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(f){this.options.unit=f,ku(this._map,this._container,this.options)}},FullscreenControl:class{constructor(f){this._fullscreen=!1,f&&f.container&&(f.container instanceof s.window.HTMLElement?this._container=f.container:s.warnOnce("Full screen control 'container' must be a DOM element.")),s.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in s.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in s.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(f){return this._map=f,this._container||(this._container=this._map.getContainer()),this._controlContainer=L("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",s.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,s.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!s.window.document.fullscreenEnabled&&!s.window.document.webkitFullscreenEnabled)}_setupUI(){const f=this._fullscreenButton=L("button","mapboxgl-ctrl-fullscreen",this._controlContainer);L("span","mapboxgl-ctrl-icon",f).setAttribute("aria-hidden","true"),f.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),s.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const f=this._getTitle();this._fullscreenButton.setAttribute("aria-label",f),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",f)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(s.window.document.fullscreenElement||s.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?s.window.document.exitFullscreen?s.window.document.exitFullscreen():s.window.document.webkitCancelFullScreen&&s.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends s.Evented{constructor(f){super(),this.options=s.extend(Object.create(qr),f),s.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(f&&f.className?f.className.trim().split(/\s+/):[])}addTo(f){return this._map&&this.remove(),this._map=f,this.options.closeOnClick&&f.on("preclick",this._onClose),this.options.closeOnMove&&f.on("move",this._onClose),f.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(f.on("mousemove",this._onMouseEvent),f.on("mouseup",this._onMouseEvent),f._canvasContainer.classList.add("mapboxgl-track-pointer")):f.on("move",this._update),this.fire(new s.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const f=this._map;return f&&(f.off("move",this._update),f.off("move",this._onClose),f.off("preclick",this._onClose),f.off("click",this._onClose),f.off("remove",this.remove),f.off("mousemove",this._onMouseEvent),f.off("mouseup",this._onMouseEvent),f.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new s.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(f){this._lngLat=s.LngLat.convert(f),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const f=this._map;return f&&(f.off("move",this._update),f.on("mousemove",this._onMouseEvent),f.on("drag",this._onMouseEvent),f._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(f){return this.setDOMContent(s.window.document.createTextNode(f))}setHTML(f){const r=s.window.document.createDocumentFragment(),u=s.window.document.createElement("body");let g;for(u.innerHTML=f;g=u.firstChild,g;)r.appendChild(g);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(f){return this.options.maxWidth=f,this._update(),this}setDOMContent(f){let r=this._content;if(r)for(;r.hasChildNodes();)r.firstChild&&r.removeChild(r.firstChild);else r=this._content=L("div","mapboxgl-popup-content",this._container||void 0);if(r.appendChild(f),this.options.closeButton){const u=this._closeButton=L("button","mapboxgl-popup-close-button",r);u.type="button",u.setAttribute("aria-label","Close popup"),u.setAttribute("aria-hidden","true"),u.innerHTML="&#215;",u.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(f){return this._classList.add(f),this._updateClassList(),this}removeClassName(f){return this._classList.delete(f),this._updateClassList(),this}setOffset(f){return this.options.offset=f,this._update(),this}toggleClassName(f){let r;return this._classList.delete(f)?r=!1:(this._classList.add(f),r=!0),this._updateClassList(),r}_onMouseEvent(f){this._update(f.point)}_getAnchor(f){if(this.options.anchor)return this.options.anchor;const r=this._map,u=this._container,g=this._pos;if(!r||!u||!g)return"bottom";const x=u.offsetWidth,b=u.offsetHeight,S=g.x<x/2,P=g.x>r.transform.width-x/2;if(g.y+f<b)return S?"top-left":P?"top-right":"top";if(g.y>r.transform.height-b){if(S)return"bottom-left";if(P)return"bottom-right"}return S?"left":P?"right":"bottom"}_updateClassList(){const f=this._container;if(!f)return;const r=[...this._classList];r.push("mapboxgl-popup"),this._anchor&&r.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&r.push("mapboxgl-popup-track-pointer"),f.className=r.join(" ")}_update(f){const r=this._map,u=this._content;if(!r||!this._lngLat&&!this._trackPointer||!u)return;let g=this._container;if(g||(g=this._container=L("div","mapboxgl-popup",r.getContainer()),this._tip=L("div","mapboxgl-popup-tip",g),g.appendChild(u)),this.options.maxWidth&&g.style.maxWidth!==this.options.maxWidth&&(g.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Iu(this._lngLat,this._pos,r.transform)),!this._trackPointer||f){const x=this._pos=this._trackPointer&&f?f:r.project(this._lngLat),b=Vl(this.options.offset),S=this._anchor=this._getAnchor(b.y),P=Vl(this.options.offset,S),z=x.add(P).round();r._requestDomTask(()=>{this._container&&S&&(this._container.style.transform=`${Ru[S]} translate(${z.x}px,${z.y}px)`)})}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const f=this._container.querySelector(ci);f&&f.focus()}_onClose(){this.remove()}_setOpacity(f){this._content&&(this._content.style.opacity=f),this._tip&&(this._tip.style.opacity=f)}},Marker:zu,Style:gr,LngLat:s.LngLat,LngLatBounds:s.LngLatBounds,Point:s.pointGeometry,MercatorCoordinate:s.MercatorCoordinate,FreeCameraOptions:Ll,Evented:s.Evented,config:s.config,prewarm:function(){ze().acquire(_n)},clearPrewarmedResources:function(){const f=Y;f&&(f.isPreloaded()&&f.numActive()===1?(f.release(_n),Y=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return s.config.ACCESS_TOKEN},set accessToken(f){s.config.ACCESS_TOKEN=f},get baseApiUrl(){return s.config.API_URL},set baseApiUrl(f){s.config.API_URL=f},get workerCount(){return W.workerCount},set workerCount(f){W.workerCount=f},get maxParallelImageRequests(){return s.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(f){s.config.MAX_PARALLEL_IMAGE_REQUESTS=f},clearStorage(f){s.clearTileCache(f)},workerUrl:"",workerClass:null,setNow:s.exported.setNow,restoreNow:s.exported.restoreNow};return Is});var _=h;return _})})(G1);var oL=G1.exports;const sL=z1(oL),tu={tdtsl(){return{layers:[["tdtsl","TianDiTu.Normal.Map"],["tdtslzj","TianDiTu.Normal.Annotion"]],key:"fb258b4c0bbf60ff7a0205b519ad9a96"}},tdtyx(){return{layers:[["tdtyx","TianDiTu.Satellite.Map"],["tdtyxzj","TianDiTu.Satellite.Annotion"]],key:"fb258b4c0bbf60ff7a0205b519ad9a96"}},tdtdx(){return{layers:[["tdtdx","TianDiTu.Terrain.Map"],["tdtdxzj","TianDiTu.Terrain.Annotion"]],key:"fb258b4c0bbf60ff7a0205b519ad9a96"}},gdsl(){return{layers:[["gdsl","GaoDe.Normal.Map"]]}},gdslwzj(){return{layers:[["gdslwzj","GaoDe.Normal_NoTag.Map"]]}},gdyx(){return{layers:[["gdyx","GaoDe.Satellite.Map"],["gdyxzj","GaoDe.Satellite.Annotion"]]}},bdsl(){return{layers:[["bdsl","Baidu.Normal.Map"]]}},bdyx(){return{layers:[["bdyx","Baidu.Satellite.Map"],["bdyxzj","Baidu.Satellite.Annotion"]]}},osm(){return{layers:[["osm","OSM.Normal.Map"]]}},geoq(){return{layers:[["geoq","Geoq.Normal.Map"]]}},geoqPurplishBlue(){return{layers:[["geoqPurplishBlue","Geoq.Normal.PurplishBlue"]]}},geoqGray(){return{layers:[["geoqGray","Geoq.Normal.Gray"]]}},geoqWarm(){return{layers:[["geoqWarm","Geoq.Normal.Warm"]]}},geoqCold(){return{layers:[["geoqCold","Geoq.Normal.Cold"]]}}};function lL(e){const n="./gis/radar.tiff";console.log(n);let i=(114.06825863001939-104.18084906665138)*.005,l=(32.396413467808586-22.54283198132819)*.005,h=114.07867152431874,p=22.563727343812303;e.addSource("radar",{type:"image",url:n,coordinates:[[h-i*.5,p+l*.5],[h+i*.5,p+l*.5],[h+i*.5,p-l*.5],[h-i*.5,p-l*.5]]}),e.addLayer({id:"radar-layer",type:"raster",source:"radar",paint:{"raster-fade-duration":0}})}function cL(e){var n="http://192.168.5.19:8080/geoserver/gwc/service/wmts?layer=mytest%3Amxcadtest2&style=&tilematrixset=EPSG:900913&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:900913:{z}&TileCol={x}&TileRow={y}";e.addSource("wmts-source",{type:"raster",tiles:[n],tileSize:256}),e.addLayer({id:"wmts-layer",type:"raster",source:"wmts-source",paint:{"raster-opacity":.95}})}let md,Ra;function uL(e){md.on("click",function(n){return wn(this,null,function*(){let{lng:i,lat:l}=n.lngLat;if(e){let _=te.mx_gcj02_To_gps84(i,l);i=_.lng,l=_.lat}console.log("经纬度坐标:",JSON.stringify([i,l]));let h=sL.MercatorCoordinate.fromLngLat([i,l],0);console.log("墨卡托坐标:",JSON.stringify(Ra.map_lnglat_to_meters(i,l)));let p=Ra.mercatorCoord2CAD(h.x,h.y);console.log("CAD坐标:",JSON.stringify(p))})})}let gd=!1,mm=!0;mm=!1,mm&&(gd=!1);function hL(){let e=new te.MxCADPluginMapDefaultData;e.cadOrigin=[116275.977014,19273.279085],e.mapOrigin=[114.06825863001939,22.54283198132819],e.meterInCADUnits=1,e.openFile="./demo/road.dwg.mxweb";let n=tt.MxFun.getQueryString("maptype");if(!mm)if(n=="google"){let i=te.mx_gps84_To_gcj02(e.mapOrigin[0],e.mapOrigin[1]);e.mapOrigin=[i.lng,i.lat],gd=!0,e.viewColor={red:0,green:0,blue:0}}else{let i=tu.gdslwzj();n=="gdslwzj"?i=tu.gdslwzj():n=="gdyx"?i=tu.gdyx():n=="tdtsl"?i=tu.tdtsl():n=="bdsl"?i=tu.bdsl():n=="geoq"&&(i=tu.geoq()),e.rasterTileLayerList=i.layers,i.key&&(e.rasterTileKey=i.key)}return e}function dL(e){Ra=e,md=e.getMapbox(),gd&&te.MxMapAddGoogleCnLayer(md,["Image","Lable"]),uL(gd),mm?cL(md):lL(md)}function pL(){return wn(this,null,function*(){let e=new te.MxCADUiPrPoint;e.setMessage(`
  3895. 指定下载范围第一点:`);let n=yield e.go();if(!n)return;e.setMessage(`
  3896. 指定下载范围第二点:`),e.setUserDraw((T,C)=>{C.setColor(16711680);let E=new te.McDbPolyline;E.addVertexAt(n),E.addVertexAt(new te.McGePoint3d(n.x,T.y)),E.addVertexAt(T),E.addVertexAt(new te.McGePoint3d(T.x,n.y)),E.constantWidth=tt.MxFun.screenCoordLong2Doc(2),E.isClosed=!0,C.drawMcDbEntity(E);let L=[];L.push(n.toVector3()),L.push(new THREE.Vector3(n.x,T.y)),L.push(T.toVector3()),L.push(new THREE.Vector3(T.x,n.y)),C.setColor(12868),C.drawSolid(L,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(tt.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let l=Ra.cadTolnglat(n.toVector3()),h=Ra.cadTolnglat(i.toVector3()),p=Ra.map_lnglat_to_meters(l[0],l[1]),_=Ra.map_lnglat_to_meters(h[0],h[1]);if(gd&&!(Ra.outOfChina(l[0],l[1])&&Ra.outOfChina(h[0],h[1]))){let T=te.mx_gcj02_To_gps84(l[0],l[1]),C=te.mx_gcj02_To_gps84(h[0],h[1]);p=Ra.map_lnglat_to_meters(T.lng,T.lat),_=Ra.map_lnglat_to_meters(C.lng,C.lat)}let s={url:"https://gac-geo.googlecnapps.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",polygon:[p[0],p[1],_[0],_[1]],zoom:18,auto_close:!1,no_repeated_download:!0,download_dir:"",thread_count:32};tt.MxFun.acutPrintf(`
  3897. 使用教程:https://help.mxdraw.com/?pid=111`),tt.MxFun.acutPrintf(`
  3898. 复制下面的范围,到下载器下载地图,下载范围:`);let M=`
  3899. `+JSON.stringify([p[0],p[1],_[0],_[1]]);tt.MxFun.acutPrintf(M),tt.MxFun.acutPrintf(`
  3900. `),Fp({method:"post",url:"http://localhost:1337/users/mxgis/download",data:s}).then(T=>{console.log(T.data),alert(JSON.stringify(T.data))}).catch(T=>{console.log("网络错误")})})}window._iconfont_svg_string_4337873='<svg><symbol id="icon-zidian" viewBox="0 0 1024 1024"><path d="M893.080181 585.210149h-86.234525v-37.615932h79.557697a57.552376 57.552376 0 0 0 1.786757-115.104753l-20.500683-0.658279 2.445035-20.312603a153.473004 153.473004 0 0 0 1.034439-17.679488A148.300813 148.300813 0 0 0 723.056167 245.72636a151.310088 151.310088 0 0 0-39.966928 5.64239l-20.782803 5.64239-3.009274-21.347042A225.695594 225.695594 0 0 0 209.222531 266.415123v18.807966l-16.739089 1.880797a130.715365 130.715365 0 0 0 14.952333 260.490331v37.615932a168.331297 168.331297 0 0 1-35.547056-332.806961 263.311526 263.311526 0 0 1 521.074702-41.753685 181.120714 181.120714 0 0 1 29.998706-2.539075 185.916746 185.916746 0 0 1 185.822706 185.728666v3.573513a95.168309 95.168309 0 0 1-15.704652 187.515423z" fill="#282D33" ></path><path d="M399.371069 341.646988H329.875634a74.573586 74.573586 0 0 0-74.291466 73.257028v478.944858-18.807966 14.576174a74.573586 74.573586 0 0 1 74.573586-74.479546h431.454744V341.646988H399.371069z" fill="#FFFFFF" ></path><path d="M255.584168 908.519088h-18.807966V414.715936A94.039831 94.039831 0 0 1 329.875634 322.839021h69.495435v37.615933H329.875634a56.423898 56.423898 0 0 0-55.4835 54.825221v399.481201a93.381552 93.381552 0 0 1 55.76562-18.807966h412.646778V360.454954H506.012238v-37.615933h274.408226v511.106481H329.875634a55.85966 55.85966 0 0 0-55.4835 52.568265v7.523187h-0.940398a18.807966 18.807966 0 0 1-17.867568 14.482134z" fill="#282D33" ></path><path d="M369.654483 392.804655H710.736949v371.363292H369.654483z" fill="#F8C44F" ></path><path d="M761.612498 815.137536H329.875634a74.573586 74.573586 0 1 0 0 149.053132h431.736864z" fill="#FFFFFF" ></path><path d="M780.420464 982.998634H329.875634a93.381552 93.381552 0 1 1 0-186.669064h450.54483zM329.875634 833.945502a55.76562 55.76562 0 1 0 0 111.437199h412.928898V833.945502z" fill="#282D33" ></path><path d="M475.073133 1024l-54.072903-34.230498-54.072902 34.230498v-127.89417h108.145805v127.89417z" fill="#34CA9D" ></path><path d="M324.327284 893.942914z" fill="#FFFFFF" ></path><path d="M324.327284 875.134948h437.285214v37.615932h-437.285214z" fill="#282D33" ></path><path d="M324.327284 810.529584z" fill="#FFFFFF" ></path><path d="M305.519318 349.076134h37.615933v461.45345h-37.615933zM520.494371 257.857498L453.067813 190.524979l-67.332519 67.332519-26.613272-26.613272L453.067813 137.392475l94.039831 93.851751-26.613273 26.613272z" fill="#282D33" ></path><path d="M436.422763 189.302462h37.615932v248.829392h-37.615932zM559.803021 694.390393l-94.039831-93.851751 26.613272-26.613272 67.426559 67.332519 67.426558-67.332519 26.519233 26.613272-93.945791 93.851751z" fill="#282D33" ></path><path d="M538.832138 393.556974h37.615933v248.829393h-37.615933z" fill="#282D33" ></path></symbol></svg>',function(e){var i=(i=document.getElementsByTagName("script"))[i.length-1],n=i.getAttribute("data-injectcss"),i=i.getAttribute("data-disable-injectsvg");if(!i){var l,h,p,_,s,M=function(E,L){L.parentNode.insertBefore(E,L)};if(n&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>")}catch(E){console&&console.log(E)}}l=function(){var E,L=document.createElement("div");L.innerHTML=e._iconfont_svg_string_4337873,(L=L.getElementsByTagName("svg")[0])&&(L.setAttribute("aria-hidden","true"),L.style.position="absolute",L.style.width=0,L.style.height=0,L.style.overflow="hidden",L=L,(E=document.body).firstChild?M(L,E.firstChild):E.appendChild(L))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(h=function(){document.removeEventListener("DOMContentLoaded",h,!1),l()},document.addEventListener("DOMContentLoaded",h,!1)):document.attachEvent&&(p=l,_=e.document,s=!1,C(),_.onreadystatechange=function(){_.readyState=="complete"&&(_.onreadystatechange=null,T())})}function T(){s||(s=!0,p())}function C(){try{_.documentElement.doScroll("left")}catch(E){return void setTimeout(C,50)}T()}}(window);var fL=function(){function e(Pe){ri.call(this,Pe),this.dracoLoader=null,this.ddsLoader=null}e.prototype=Object.assign(Object.create(ri.prototype),{constructor:e,load:function(Pe,ge,Ve,Ne){var Ie=this,it;this.resourcePath!==""?it=this.resourcePath:this.path!==""?it=this.path:it=ul.extractUrlBase(Pe),Ie.manager.itemStart(Pe);var ce=function(Me){Ne?Ne(Me):console.error(Me),Ie.manager.itemError(Pe),Ie.manager.itemEnd(Pe)},we=new xa(Ie.manager);we.setPath(this.path),we.setResponseType("arraybuffer"),Ie.crossOrigin==="use-credentials"&&we.setWithCredentials(!0),we.load(Pe,function(Me){try{Ie.parse(Me,it,function(pe){ge(pe),Ie.manager.itemEnd(Pe)},ce)}catch(pe){ce(pe)}},Ve,ce)},setDRACOLoader:function(Pe){return this.dracoLoader=Pe,this},setDDSLoader:function(Pe){return this.ddsLoader=Pe,this},parse:function(Pe,ge,Ve,Ne){var Ie,it={};if(typeof Pe=="string")Ie=Pe;else{var ce=ul.decodeText(new Uint8Array(Pe,0,4));if(ce===_){try{it[i.KHR_BINARY_GLTF]=new T(Pe)}catch(ot){Ne&&Ne(ot);return}Ie=it[i.KHR_BINARY_GLTF].content}else Ie=ul.decodeText(new Uint8Array(Pe))}var we=JSON.parse(Ie);if(we.asset===void 0||we.asset.version[0]<2){Ne&&Ne(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}if(we.extensionsUsed)for(var Me=0;Me<we.extensionsUsed.length;++Me){var pe=we.extensionsUsed[Me],Be=we.extensionsRequired||[];switch(pe){case i.KHR_LIGHTS_PUNCTUAL:it[pe]=new h(we);break;case i.KHR_MATERIALS_UNLIT:it[pe]=new p;break;case i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:it[pe]=new I;break;case i.KHR_DRACO_MESH_COMPRESSION:it[pe]=new C(we,this.dracoLoader);break;case i.MSFT_TEXTURE_DDS:it[pe]=new l(this.ddsLoader);break;case i.KHR_TEXTURE_TRANSFORM:it[pe]=new E;break;case i.KHR_MESH_QUANTIZATION:it[pe]=new B;break;default:Be.indexOf(pe)>=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+pe+'".')}}var $e=new gt(we,it,{path:ge||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager});$e.parse(Ve,Ne)}});function n(){var Pe={};return{get:function(ge){return Pe[ge]},add:function(ge,Ve){Pe[ge]=Ve},remove:function(ge){delete Pe[ge]},removeAll:function(){Pe={}}}}var i={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function l(Pe){if(!Pe)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=i.MSFT_TEXTURE_DDS,this.ddsLoader=Pe}function h(Pe){this.name=i.KHR_LIGHTS_PUNCTUAL;var ge=Pe.extensions&&Pe.extensions[i.KHR_LIGHTS_PUNCTUAL]||{};this.lightDefs=ge.lights||[]}h.prototype.loadLight=function(Pe){var ge=this.lightDefs[Pe],Ve,Ne=new en(16777215);ge.color!==void 0&&Ne.fromArray(ge.color);var Ie=ge.range!==void 0?ge.range:0;switch(ge.type){case"directional":Ve=new Kf(Ne),Ve.target.position.set(0,0,-1),Ve.add(Ve.target);break;case"point":Ve=new Jf(Ne),Ve.distance=Ie;break;case"spot":Ve=new $f(Ne),Ve.distance=Ie,ge.spot=ge.spot||{},ge.spot.innerConeAngle=ge.spot.innerConeAngle!==void 0?ge.spot.innerConeAngle:0,ge.spot.outerConeAngle=ge.spot.outerConeAngle!==void 0?ge.spot.outerConeAngle:Math.PI/4,Ve.angle=ge.spot.outerConeAngle,Ve.penumbra=1-ge.spot.innerConeAngle/ge.spot.outerConeAngle,Ve.target.position.set(0,0,-1),Ve.add(Ve.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+ge.type+'".')}return Ve.position.set(0,0,0),Ve.decay=2,ge.intensity!==void 0&&(Ve.intensity=ge.intensity),Ve.name=ge.name||"light_"+Pe,Promise.resolve(Ve)};function p(){this.name=i.KHR_MATERIALS_UNLIT}p.prototype.getMaterialType=function(){return lr},p.prototype.extendParams=function(Pe,ge,Ve){var Ne=[];Pe.color=new en(1,1,1),Pe.opacity=1;var Ie=ge.pbrMetallicRoughness;if(Ie){if(Array.isArray(Ie.baseColorFactor)){var it=Ie.baseColorFactor;Pe.color.fromArray(it),Pe.opacity=it[3]}Ie.baseColorTexture!==void 0&&Ne.push(Ve.assignTexture(Pe,"map",Ie.baseColorTexture))}return Promise.all(Ne)};var _="glTF",s=12,M={JSON:1313821514,BIN:5130562};function T(Pe){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;var ge=new DataView(Pe,0,s);if(this.header={magic:ul.decodeText(new Uint8Array(Pe.slice(0,4))),version:ge.getUint32(4,!0),length:ge.getUint32(8,!0)},this.header.magic!==_)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var Ve=new DataView(Pe,s),Ne=0;Ne<Ve.byteLength;){var Ie=Ve.getUint32(Ne,!0);Ne+=4;var it=Ve.getUint32(Ne,!0);if(Ne+=4,it===M.JSON){var ce=new Uint8Array(Pe,s+Ne,Ie);this.content=ul.decodeText(ce)}else if(it===M.BIN){var we=s+Ne;this.body=Pe.slice(we,we+Ie)}Ne+=Ie}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}function C(Pe,ge){if(!ge)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=i.KHR_DRACO_MESH_COMPRESSION,this.json=Pe,this.dracoLoader=ge,this.dracoLoader.preload()}C.prototype.decodePrimitive=function(Pe,ge){var Ve=this.json,Ne=this.dracoLoader,Ie=Pe.extensions[this.name].bufferView,it=Pe.extensions[this.name].attributes,ce={},we={},Me={};for(var pe in it){var Be=K[pe]||pe.toLowerCase();ce[Be]=it[pe]}for(pe in Pe.attributes){var Be=K[pe]||pe.toLowerCase();if(it[pe]!==void 0){var $e=Ve.accessors[Pe.attributes[pe]],ot=q[$e.componentType];Me[Be]=ot,we[Be]=$e.normalized===!0}}return ge.getDependency("bufferView",Ie).then(function(bt){return new Promise(function(Vt){Ne.decodeDracoFile(bt,function(oe){for(var ve in oe.attributes){var xt=oe.attributes[ve],mt=we[ve];mt!==void 0&&(xt.normalized=mt)}Vt(oe)},ce,Me)})})};function E(){this.name=i.KHR_TEXTURE_TRANSFORM}E.prototype.extendTexture=function(Pe,ge){return Pe=Pe.clone(),ge.offset!==void 0&&Pe.offset.fromArray(ge.offset),ge.rotation!==void 0&&(Pe.rotation=ge.rotation),ge.scale!==void 0&&Pe.repeat.fromArray(ge.scale),ge.texCoord!==void 0&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),Pe.needsUpdate=!0,Pe};function L(Pe){Ur.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var ge=["#ifdef USE_SPECULARMAP"," uniform sampler2D specularMap;","#endif"].join(`
  3901. `),Ve=["#ifdef USE_GLOSSINESSMAP"," uniform sampler2D glossinessMap;","#endif"].join(`
  3902. `),Ne=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP"," vec4 texelSpecular = texture2D( specularMap, vUv );"," texelSpecular = sRGBToLinear( texelSpecular );"," // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture"," specularFactor *= texelSpecular.rgb;","#endif"].join(`
  3903. `),Ie=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP"," vec4 texelGlossiness = texture2D( glossinessMap, vUv );"," // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture"," glossinessFactor *= texelGlossiness.a;","#endif"].join(`
  3904. `),it=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb;","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor.rgb;"].join(`
  3905. `),ce={specular:{value:new en().setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=ce,this.onBeforeCompile=function(we){for(var Me in ce)we.uniforms[Me]=ce[Me];we.fragmentShader=we.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;"),we.fragmentShader=we.fragmentShader.replace("uniform float metalness;","uniform float glossiness;"),we.fragmentShader=we.fragmentShader.replace("#include <roughnessmap_pars_fragment>",ge),we.fragmentShader=we.fragmentShader.replace("#include <metalnessmap_pars_fragment>",Ve),we.fragmentShader=we.fragmentShader.replace("#include <roughnessmap_fragment>",Ne),we.fragmentShader=we.fragmentShader.replace("#include <metalnessmap_fragment>",Ie),we.fragmentShader=we.fragmentShader.replace("#include <lights_physical_fragment>",it)},Object.defineProperties(this,{specular:{get:function(){return ce.specular.value},set:function(we){ce.specular.value=we}},specularMap:{get:function(){return ce.specularMap.value},set:function(we){ce.specularMap.value=we}},glossiness:{get:function(){return ce.glossiness.value},set:function(we){ce.glossiness.value=we}},glossinessMap:{get:function(){return ce.glossinessMap.value},set:function(we){ce.glossinessMap.value=we,we?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_ROUGHNESSMAP=""):(delete this.defines.USE_ROUGHNESSMAP,delete this.defines.USE_GLOSSINESSMAP)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(Pe)}L.prototype=Object.create(Ur.prototype),L.prototype.constructor=L,L.prototype.copy=function(Pe){return Ur.prototype.copy.call(this,Pe),this.specularMap=Pe.specularMap,this.specular.copy(Pe.specular),this.glossinessMap=Pe.glossinessMap,this.glossiness=Pe.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function I(){return{name:i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return L},extendParams:function(Pe,ge,Ve){var Ne=ge.extensions[this.name];Pe.color=new en(1,1,1),Pe.opacity=1;var Ie=[];if(Array.isArray(Ne.diffuseFactor)){var it=Ne.diffuseFactor;Pe.color.fromArray(it),Pe.opacity=it[3]}if(Ne.diffuseTexture!==void 0&&Ie.push(Ve.assignTexture(Pe,"map",Ne.diffuseTexture)),Pe.emissive=new en(0,0,0),Pe.glossiness=Ne.glossinessFactor!==void 0?Ne.glossinessFactor:1,Pe.specular=new en(1,1,1),Array.isArray(Ne.specularFactor)&&Pe.specular.fromArray(Ne.specularFactor),Ne.specularGlossinessTexture!==void 0){var ce=Ne.specularGlossinessTexture;Ie.push(Ve.assignTexture(Pe,"glossinessMap",ce)),Ie.push(Ve.assignTexture(Pe,"specularMap",ce))}return Promise.all(Ie)},createMaterial:function(Pe){var ge=new L(Pe);return ge.fog=!0,ge.color=Pe.color,ge.map=Pe.map===void 0?null:Pe.map,ge.lightMap=null,ge.lightMapIntensity=1,ge.aoMap=Pe.aoMap===void 0?null:Pe.aoMap,ge.aoMapIntensity=1,ge.emissive=Pe.emissive,ge.emissiveIntensity=1,ge.emissiveMap=Pe.emissiveMap===void 0?null:Pe.emissiveMap,ge.bumpMap=Pe.bumpMap===void 0?null:Pe.bumpMap,ge.bumpScale=1,ge.normalMap=Pe.normalMap===void 0?null:Pe.normalMap,ge.normalMapType=Xs,Pe.normalScale&&(ge.normalScale=Pe.normalScale),ge.displacementMap=null,ge.displacementScale=1,ge.displacementBias=0,ge.specularMap=Pe.specularMap===void 0?null:Pe.specularMap,ge.specular=Pe.specular,ge.glossinessMap=Pe.glossinessMap===void 0?null:Pe.glossinessMap,ge.glossiness=Pe.glossiness,ge.alphaMap=null,ge.envMap=Pe.envMap===void 0?null:Pe.envMap,ge.envMapIntensity=1,ge.refractionRatio=.98,ge}}}function B(){this.name=i.KHR_MESH_QUANTIZATION}function O(Pe,ge,Ve,Ne){Vr.call(this,Pe,ge,Ve,Ne)}O.prototype=Object.create(Vr.prototype),O.prototype.constructor=O,O.prototype.copySampleValue_=function(Pe){for(var ge=this.resultBuffer,Ve=this.sampleValues,Ne=this.valueSize,Ie=Pe*Ne*3+Ne,it=0;it!==Ne;it++)ge[it]=Ve[Ie+it];return ge},O.prototype.beforeStart_=O.prototype.copySampleValue_,O.prototype.afterEnd_=O.prototype.copySampleValue_,O.prototype.interpolate_=function(Pe,ge,Ve,Ne){for(var Ie=this.resultBuffer,it=this.sampleValues,ce=this.valueSize,we=ce*2,Me=ce*3,pe=Ne-ge,Be=(Ve-ge)/pe,$e=Be*Be,ot=$e*Be,bt=Pe*Me,Vt=bt-Me,oe=-2*ot+3*$e,ve=ot-$e,xt=1-oe,mt=ve-$e+Be,xn=0;xn!==ce;xn++){var un=it[Vt+xn+ce],tn=it[Vt+xn+we]*pe,dn=it[bt+xn+ce],bn=it[bt+xn]*pe;Ie[xn]=xt*un+mt*tn+oe*dn+ve*bn}return Ie};var U={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},q={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ee={9728:Ui,9729:qi,9984:Gp,9985:Yg,9986:Hp,9987:ec},he={33071:wr,33648:sh,10497:Zs},Ce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},K={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ie={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ue={CUBICSPLINE:void 0,LINEAR:nc,STEP:uh},ae={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},le={"image/png":Aa,"image/jpeg":Mo};function De(Pe,ge){return typeof Pe!="string"||Pe===""?"":(/^https?:\/\//i.test(ge)&&/^\//.test(Pe)&&(ge=ge.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(Pe)||/^data:.*,.*$/i.test(Pe)||/^blob:.*$/i.test(Pe)?Pe:ge+Pe)}function ye(Pe){return Pe.DefaultMaterial===void 0&&(Pe.DefaultMaterial=new Ur({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Jl})),Pe.DefaultMaterial}function se(Pe,ge,Ve){for(var Ne in Ve.extensions)Pe[Ne]===void 0&&(ge.userData.gltfExtensions=ge.userData.gltfExtensions||{},ge.userData.gltfExtensions[Ne]=Ve.extensions[Ne])}function Ue(Pe,ge){ge.extras!==void 0&&(typeof ge.extras=="object"?Object.assign(Pe.userData,ge.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+ge.extras))}function Oe(Pe,ge,Ve){for(var Ne=!1,Ie=!1,it=0,ce=ge.length;it<ce;it++){var we=ge[it];if(we.POSITION!==void 0&&(Ne=!0),we.NORMAL!==void 0&&(Ie=!0),Ne&&Ie)break}if(!Ne&&!Ie)return Promise.resolve(Pe);for(var Me=[],pe=[],it=0,ce=ge.length;it<ce;it++){var we=ge[it];if(Ne){var Be=we.POSITION!==void 0?Ve.getDependency("accessor",we.POSITION):Pe.attributes.position;Me.push(Be)}if(Ie){var Be=we.NORMAL!==void 0?Ve.getDependency("accessor",we.NORMAL):Pe.attributes.normal;pe.push(Be)}}return Promise.all([Promise.all(Me),Promise.all(pe)]).then(function($e){var ot=$e[0],bt=$e[1];return Ne&&(Pe.morphAttributes.position=ot),Ie&&(Pe.morphAttributes.normal=bt),Pe.morphTargetsRelative=!0,Pe})}function We(Pe,ge){if(Pe.updateMorphTargets(),ge.weights!==void 0)for(var Ve=0,Ne=ge.weights.length;Ve<Ne;Ve++)Pe.morphTargetInfluences[Ve]=ge.weights[Ve];if(ge.extras&&Array.isArray(ge.extras.targetNames)){var Ie=ge.extras.targetNames;if(Pe.morphTargetInfluences.length===Ie.length){Pe.morphTargetDictionary={};for(var Ve=0,Ne=Ie.length;Ve<Ne;Ve++)Pe.morphTargetDictionary[Ie[Ve]]=Ve}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function st(Pe){var ge=Pe.extensions&&Pe.extensions[i.KHR_DRACO_MESH_COMPRESSION],Ve;return ge?Ve="draco:"+ge.bufferView+":"+ge.indices+":"+St(ge.attributes):Ve=Pe.indices+":"+St(Pe.attributes)+":"+Pe.mode,Ve}function St(Pe){for(var ge="",Ve=Object.keys(Pe).sort(),Ne=0,Ie=Ve.length;Ne<Ie;Ne++)ge+=Ve[Ne]+":"+Pe[Ve[Ne]]+";";return ge}function gt(Pe,ge,Ve){this.json=Pe||{},this.extensions=ge||{},this.options=Ve||{},this.cache=new n,this.primitiveCache={},this.textureLoader=new $h(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new xa(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}gt.prototype.parse=function(Pe,ge){var Ve=this,Ne=this.json,Ie=this.extensions;this.cache.removeAll(),this.markDefs(),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then(function(it){var ce={scene:it[0][Ne.scene||0],scenes:it[0],animations:it[1],cameras:it[2],asset:Ne.asset,parser:Ve,userData:{}};se(Ie,ce,Ne),Ue(ce,Ne),Pe(ce)}).catch(ge)},gt.prototype.markDefs=function(){for(var Pe=this.json.nodes||[],ge=this.json.skins||[],Ve=this.json.meshes||[],Ne={},Ie={},it=0,ce=ge.length;it<ce;it++)for(var we=ge[it].joints,Me=0,pe=we.length;Me<pe;Me++)Pe[we[Me]].isBone=!0;for(var Be=0,$e=Pe.length;Be<$e;Be++){var ot=Pe[Be];ot.mesh!==void 0&&(Ne[ot.mesh]===void 0&&(Ne[ot.mesh]=Ie[ot.mesh]=0),Ne[ot.mesh]++,ot.skin!==void 0&&(Ve[ot.mesh].isSkinnedMesh=!0))}this.json.meshReferences=Ne,this.json.meshUses=Ie},gt.prototype.getDependency=function(Pe,ge){var Ve=Pe+":"+ge,Ne=this.cache.get(Ve);if(!Ne){switch(Pe){case"scene":Ne=this.loadScene(ge);break;case"node":Ne=this.loadNode(ge);break;case"mesh":Ne=this.loadMesh(ge);break;case"accessor":Ne=this.loadAccessor(ge);break;case"bufferView":Ne=this.loadBufferView(ge);break;case"buffer":Ne=this.loadBuffer(ge);break;case"material":Ne=this.loadMaterial(ge);break;case"texture":Ne=this.loadTexture(ge);break;case"skin":Ne=this.loadSkin(ge);break;case"animation":Ne=this.loadAnimation(ge);break;case"camera":Ne=this.loadCamera(ge);break;case"light":Ne=this.extensions[i.KHR_LIGHTS_PUNCTUAL].loadLight(ge);break;default:throw new Error("Unknown type: "+Pe)}this.cache.add(Ve,Ne)}return Ne},gt.prototype.getDependencies=function(Pe){var ge=this.cache.get(Pe);if(!ge){var Ve=this,Ne=this.json[Pe+(Pe==="mesh"?"es":"s")]||[];ge=Promise.all(Ne.map(function(Ie,it){return Ve.getDependency(Pe,it)})),this.cache.add(Pe,ge)}return ge},gt.prototype.loadBuffer=function(Pe){var ge=this.json.buffers[Pe],Ve=this.fileLoader;if(ge.type&&ge.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+ge.type+" buffer type is not supported.");if(ge.uri===void 0&&Pe===0)return Promise.resolve(this.extensions[i.KHR_BINARY_GLTF].body);var Ne=this.options;return new Promise(function(Ie,it){Ve.load(De(ge.uri,Ne.path),Ie,void 0,function(){it(new Error('THREE.GLTFLoader: Failed to load buffer "'+ge.uri+'".'))})})},gt.prototype.loadBufferView=function(Pe){var ge=this.json.bufferViews[Pe];return this.getDependency("buffer",ge.buffer).then(function(Ve){var Ne=ge.byteLength||0,Ie=ge.byteOffset||0;return Ve.slice(Ie,Ie+Ne)})},gt.prototype.loadAccessor=function(Pe){var ge=this,Ve=this.json,Ne=this.json.accessors[Pe];if(Ne.bufferView===void 0&&Ne.sparse===void 0)return Promise.resolve(null);var Ie=[];return Ne.bufferView!==void 0?Ie.push(this.getDependency("bufferView",Ne.bufferView)):Ie.push(null),Ne.sparse!==void 0&&(Ie.push(this.getDependency("bufferView",Ne.sparse.indices.bufferView)),Ie.push(this.getDependency("bufferView",Ne.sparse.values.bufferView))),Promise.all(Ie).then(function(it){var ce=it[0],we=Ce[Ne.type],Me=q[Ne.componentType],pe=Me.BYTES_PER_ELEMENT,Be=pe*we,$e=Ne.byteOffset||0,ot=Ne.bufferView!==void 0?Ve.bufferViews[Ne.bufferView].byteStride:void 0,bt=Ne.normalized===!0,Vt,oe;if(ot&&ot!==Be){var ve=Math.floor($e/ot),xt="InterleavedBuffer:"+Ne.bufferView+":"+Ne.componentType+":"+ve+":"+Ne.count,mt=ge.cache.get(xt);mt||(Vt=new Me(ce,ve*ot,Ne.count*ot/pe),mt=new zo(Vt,ot/pe),ge.cache.add(xt,mt)),oe=new Ah(mt,we,$e%ot/pe,bt)}else ce===null?Vt=new Me(Ne.count*we):Vt=new Me(ce,$e,Ne.count*we),oe=new zn(Vt,we,bt);if(Ne.sparse!==void 0){var xn=Ce.SCALAR,un=q[Ne.sparse.indices.componentType],tn=Ne.sparse.indices.byteOffset||0,dn=Ne.sparse.values.byteOffset||0,bn=new un(it[1],tn,Ne.sparse.count*xn),ln=new Me(it[2],dn,Ne.sparse.count*we);ce!==null&&(oe=new zn(oe.array.slice(),oe.itemSize,oe.normalized));for(var Gt=0,on=bn.length;Gt<on;Gt++){var Zt=bn[Gt];if(oe.setX(Zt,ln[Gt*we]),we>=2&&oe.setY(Zt,ln[Gt*we+1]),we>=3&&oe.setZ(Zt,ln[Gt*we+2]),we>=4&&oe.setW(Zt,ln[Gt*we+3]),we>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return oe})},gt.prototype.loadTexture=function(Pe){var ge=this,Ve=this.json,Ne=this.options,Ie=this.textureLoader,it=window.URL||window.webkitURL,ce=Ve.textures[Pe],we=ce.extensions||{},Me;we[i.MSFT_TEXTURE_DDS]?Me=Ve.images[we[i.MSFT_TEXTURE_DDS].source]:Me=Ve.images[ce.source];var pe=Me.uri,Be=!1;return Me.bufferView!==void 0&&(pe=ge.getDependency("bufferView",Me.bufferView).then(function($e){Be=!0;var ot=new Blob([$e],{type:Me.mimeType});return pe=it.createObjectURL(ot),pe})),Promise.resolve(pe).then(function($e){var ot=Ne.manager.getHandler($e);return ot||(ot=we[i.MSFT_TEXTURE_DDS]?ge.extensions[i.MSFT_TEXTURE_DDS].ddsLoader:Ie),new Promise(function(bt,Vt){ot.load(De($e,Ne.path),bt,void 0,Vt)})}).then(function($e){Be===!0&&it.revokeObjectURL(pe),$e.flipY=!1,ce.name!==void 0&&($e.name=ce.name),Me.mimeType in le&&($e.format=le[Me.mimeType]);var ot=Ve.samplers||{},bt=ot[ce.sampler]||{};return $e.magFilter=ee[bt.magFilter]||qi,$e.minFilter=ee[bt.minFilter]||ec,$e.wrapS=he[bt.wrapS]||Zs,$e.wrapT=he[bt.wrapT]||Zs,$e})},gt.prototype.assignTexture=function(Pe,ge,Ve){var Ne=this;return this.getDependency("texture",Ve.index).then(function(Ie){if(!Ie.isCompressedTexture)switch(ge){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":Ie.format=Mo;break}if(Ve.texCoord!==void 0&&Ve.texCoord!=0&&!(ge==="aoMap"&&Ve.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+Ve.texCoord+" for texture "+ge+" not yet supported."),Ne.extensions[i.KHR_TEXTURE_TRANSFORM]){var it=Ve.extensions!==void 0?Ve.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;it&&(Ie=Ne.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(Ie,it))}Pe[ge]=Ie})},gt.prototype.assignFinalMaterial=function(Pe){var ge=Pe.geometry,Ve=Pe.material;this.extensions;var Ne=ge.attributes.tangent!==void 0,Ie=ge.attributes.color!==void 0,it=ge.attributes.normal===void 0,ce=Pe.isSkinnedMesh===!0,we=Object.keys(ge.morphAttributes).length>0,Me=we&&ge.morphAttributes.normal!==void 0;if(Pe.isPoints){var pe="PointsMaterial:"+Ve.uuid,Be=this.cache.get(pe);Be||(Be=new os,Rn.prototype.copy.call(Be,Ve),Be.color.copy(Ve.color),Be.map=Ve.map,Be.sizeAttenuation=!1,this.cache.add(pe,Be)),Ve=Be}else if(Pe.isLine){var pe="LineBasicMaterial:"+Ve.uuid,$e=this.cache.get(pe);$e||($e=new Ri,Rn.prototype.copy.call($e,Ve),$e.color.copy(Ve.color),this.cache.add(pe,$e)),Ve=$e}if(Ne||Ie||it||ce||we){var pe="ClonedMaterial:"+Ve.uuid+":";Ve.isGLTFSpecularGlossinessMaterial&&(pe+="specular-glossiness:"),ce&&(pe+="skinning:"),Ne&&(pe+="vertex-tangents:"),Ie&&(pe+="vertex-colors:"),it&&(pe+="flat-shading:"),we&&(pe+="morph-targets:"),Me&&(pe+="morph-normals:");var ot=this.cache.get(pe);ot||(ot=Ve.clone(),ce&&(ot.skinning=!0),Ne&&(ot.vertexTangents=!0),Ie&&(ot.vertexColors=Kl),it&&(ot.flatShading=!0),we&&(ot.morphTargets=!0),Me&&(ot.morphNormals=!0),this.cache.add(pe,ot)),Ve=ot}Ve.aoMap&&ge.attributes.uv2===void 0&&ge.attributes.uv!==void 0&&ge.setAttribute("uv2",new zn(ge.attributes.uv.array,2)),Ve.normalScale&&!Ne&&(Ve.normalScale.y=-Ve.normalScale.y),Pe.material=Ve},gt.prototype.loadMaterial=function(Pe){var ge=this,Ve=this.json,Ne=this.extensions,Ie=Ve.materials[Pe],it,ce={},we=Ie.extensions||{},Me=[];if(we[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var pe=Ne[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];it=pe.getMaterialType(),Me.push(pe.extendParams(ce,Ie,ge))}else if(we[i.KHR_MATERIALS_UNLIT]){var Be=Ne[i.KHR_MATERIALS_UNLIT];it=Be.getMaterialType(),Me.push(Be.extendParams(ce,Ie,ge))}else{it=Ur;var $e=Ie.pbrMetallicRoughness||{};if(ce.color=new en(1,1,1),ce.opacity=1,Array.isArray($e.baseColorFactor)){var ot=$e.baseColorFactor;ce.color.fromArray(ot),ce.opacity=ot[3]}$e.baseColorTexture!==void 0&&Me.push(ge.assignTexture(ce,"map",$e.baseColorTexture)),ce.metalness=$e.metallicFactor!==void 0?$e.metallicFactor:1,ce.roughness=$e.roughnessFactor!==void 0?$e.roughnessFactor:1,$e.metallicRoughnessTexture!==void 0&&(Me.push(ge.assignTexture(ce,"metalnessMap",$e.metallicRoughnessTexture)),Me.push(ge.assignTexture(ce,"roughnessMap",$e.metallicRoughnessTexture)))}Ie.doubleSided===!0&&(ce.side=rh);var bt=Ie.alphaMode||ae.OPAQUE;return bt===ae.BLEND?ce.transparent=!0:(ce.transparent=!1,bt===ae.MASK&&(ce.alphaTest=Ie.alphaCutoff!==void 0?Ie.alphaCutoff:.5)),Ie.normalTexture!==void 0&&it!==lr&&(Me.push(ge.assignTexture(ce,"normalMap",Ie.normalTexture)),ce.normalScale=new Lt(1,1),Ie.normalTexture.scale!==void 0&&ce.normalScale.set(Ie.normalTexture.scale,Ie.normalTexture.scale)),Ie.occlusionTexture!==void 0&&it!==lr&&(Me.push(ge.assignTexture(ce,"aoMap",Ie.occlusionTexture)),Ie.occlusionTexture.strength!==void 0&&(ce.aoMapIntensity=Ie.occlusionTexture.strength)),Ie.emissiveFactor!==void 0&&it!==lr&&(ce.emissive=new en().fromArray(Ie.emissiveFactor)),Ie.emissiveTexture!==void 0&&it!==lr&&Me.push(ge.assignTexture(ce,"emissiveMap",Ie.emissiveTexture)),Promise.all(Me).then(function(){var Vt;return it===L?Vt=Ne[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(ce):Vt=new it(ce),Ie.name!==void 0&&(Vt.name=Ie.name),Vt.map&&(Vt.map.encoding=hh),Vt.emissiveMap&&(Vt.emissiveMap.encoding=hh),Ue(Vt,Ie),Ie.extensions&&se(Ne,Vt,Ie),Vt})};function At(Pe,ge,Ve){var Ne=ge.attributes,Ie=new Pa;if(Ne.POSITION!==void 0){var it=Ve.json.accessors[Ne.POSITION],ce=it.min,we=it.max;if(ce!==void 0&&we!==void 0)Ie.set(new Ee(ce[0],ce[1],ce[2]),new Ee(we[0],we[1],we[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var Me=ge.targets;if(Me!==void 0)for(var pe=new Ee,Be=0,$e=Me.length;Be<$e;Be++){var ot=Me[Be];if(ot.POSITION!==void 0){var it=Ve.json.accessors[ot.POSITION],ce=it.min,we=it.max;ce!==void 0&&we!==void 0?(pe.setX(Math.max(Math.abs(ce[0]),Math.abs(we[0]))),pe.setY(Math.max(Math.abs(ce[1]),Math.abs(we[1]))),pe.setZ(Math.max(Math.abs(ce[2]),Math.abs(we[2]))),Ie.expandByVector(pe)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}Pe.boundingBox=Ie;var bt=new Co;Ie.getCenter(bt.center),bt.radius=Ie.min.distanceTo(Ie.max)/2,Pe.boundingSphere=bt}function Dt(Pe,ge,Ve){var Ne=ge.attributes,Ie=[];function it(pe,Be){return Ve.getDependency("accessor",pe).then(function($e){Pe.setAttribute(Be,$e)})}for(var ce in Ne){var we=K[ce]||ce.toLowerCase();we in Pe.attributes||Ie.push(it(Ne[ce],we))}if(ge.indices!==void 0&&!Pe.index){var Me=Ve.getDependency("accessor",ge.indices).then(function(pe){Pe.setIndex(pe)});Ie.push(Me)}return Ue(Pe,ge),At(Pe,ge,Ve),Promise.all(Ie).then(function(){return ge.targets!==void 0?Oe(Pe,ge.targets,Ve):Pe})}function Ot(Pe,ge){var Ve=Pe.getIndex();if(Ve===null){var Ne=[],Ie=Pe.getAttribute("position");if(Ie!==void 0){for(var it=0;it<Ie.count;it++)Ne.push(it);Pe.setIndex(Ne),Ve=Pe.getIndex()}else return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),Pe}var ce=Ve.count-2,we=[];if(ge===T0)for(var it=1;it<=ce;it++)we.push(Ve.getX(0)),we.push(Ve.getX(it)),we.push(Ve.getX(it+1));else for(var it=0;it<ce;it++)it%2===0?(we.push(Ve.getX(it)),we.push(Ve.getX(it+1)),we.push(Ve.getX(it+2))):(we.push(Ve.getX(it+2)),we.push(Ve.getX(it+1)),we.push(Ve.getX(it)));we.length/3!==ce&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var Me=Pe.clone();return Me.setIndex(we),Me}return gt.prototype.loadGeometries=function(Pe){var ge=this,Ve=this.extensions,Ne=this.primitiveCache;function Ie(ot){return Ve[i.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(ot,ge).then(function(bt){return Dt(bt,ot,ge)})}for(var it=[],ce=0,we=Pe.length;ce<we;ce++){var Me=Pe[ce],pe=st(Me),Be=Ne[pe];if(Be)it.push(Be.promise);else{var $e;Me.extensions&&Me.extensions[i.KHR_DRACO_MESH_COMPRESSION]?$e=Ie(Me):$e=Dt(new yn,Me,ge),Ne[pe]={primitive:Me,promise:$e},it.push($e)}}return Promise.all(it)},gt.prototype.loadMesh=function(Pe){for(var ge=this,Ve=this.json,Ne=Ve.meshes[Pe],Ie=Ne.primitives,it=[],ce=0,we=Ie.length;ce<we;ce++){var Me=Ie[ce].material===void 0?ye(this.cache):this.getDependency("material",Ie[ce].material);it.push(Me)}return it.push(ge.loadGeometries(Ie)),Promise.all(it).then(function(pe){for(var Be=pe.slice(0,pe.length-1),$e=pe[pe.length-1],ot=[],bt=0,Vt=$e.length;bt<Vt;bt++){var oe=$e[bt],ve=Ie[bt],xt,mt=Be[bt];if(ve.mode===U.TRIANGLES||ve.mode===U.TRIANGLE_STRIP||ve.mode===U.TRIANGLE_FAN||ve.mode===void 0)xt=Ne.isSkinnedMesh===!0?new Dh(oe,mt):new Ai(oe,mt),xt.isSkinnedMesh===!0&&!xt.geometry.attributes.skinWeight.normalized&&xt.normalizeSkinWeights(),ve.mode===U.TRIANGLE_STRIP?xt.geometry=Ot(xt.geometry,l2):ve.mode===U.TRIANGLE_FAN&&(xt.geometry=Ot(xt.geometry,T0));else if(ve.mode===U.LINES)xt=new Vi(oe,mt);else if(ve.mode===U.LINE_STRIP)xt=new sa(oe,mt);else if(ve.mode===U.LINE_LOOP)xt=new Tf(oe,mt);else if(ve.mode===U.POINTS)xt=new Af(oe,mt);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+ve.mode);Object.keys(xt.geometry.morphAttributes).length>0&&We(xt,Ne),xt.name=Ne.name||"mesh_"+Pe,$e.length>1&&(xt.name+="_"+bt),Ue(xt,Ne),ge.assignFinalMaterial(xt),ot.push(xt)}if(ot.length===1)return ot[0];for(var xn=new rl,bt=0,Vt=ot.length;bt<Vt;bt++)xn.add(ot[bt]);return xn})},gt.prototype.loadCamera=function(Pe){var ge,Ve=this.json.cameras[Pe],Ne=Ve[Ve.type];if(!Ne){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return Ve.type==="perspective"?ge=new Xi(Wn.radToDeg(Ne.yfov),Ne.aspectRatio||1,Ne.znear||1,Ne.zfar||2e6):Ve.type==="orthographic"&&(ge=new $c(Ne.xmag/-2,Ne.xmag/2,Ne.ymag/2,Ne.ymag/-2,Ne.znear,Ne.zfar)),Ve.name!==void 0&&(ge.name=Ve.name),Ue(ge,Ve),Promise.resolve(ge)},gt.prototype.loadSkin=function(Pe){var ge=this.json.skins[Pe],Ve={joints:ge.joints};return ge.inverseBindMatrices===void 0?Promise.resolve(Ve):this.getDependency("accessor",ge.inverseBindMatrices).then(function(Ne){return Ve.inverseBindMatrices=Ne,Ve})},gt.prototype.loadAnimation=function(Pe){for(var ge=this.json,Ve=ge.animations[Pe],Ne=[],Ie=[],it=[],ce=[],we=[],Me=0,pe=Ve.channels.length;Me<pe;Me++){var Be=Ve.channels[Me],$e=Ve.samplers[Be.sampler],ot=Be.target,bt=ot.node!==void 0?ot.node:ot.id,Vt=Ve.parameters!==void 0?Ve.parameters[$e.input]:$e.input,oe=Ve.parameters!==void 0?Ve.parameters[$e.output]:$e.output;Ne.push(this.getDependency("node",bt)),Ie.push(this.getDependency("accessor",Vt)),it.push(this.getDependency("accessor",oe)),ce.push($e),we.push(ot)}return Promise.all([Promise.all(Ne),Promise.all(Ie),Promise.all(it),Promise.all(ce),Promise.all(we)]).then(function(ve){for(var xt=ve[0],mt=ve[1],xn=ve[2],un=ve[3],tn=ve[4],dn=[],bn=0,ln=xt.length;bn<ln;bn++){var Gt=xt[bn],on=mt[bn],Zt=xn[bn],qe=un[bn],Nt=tn[bn];if(Gt!==void 0){Gt.updateMatrix(),Gt.matrixAutoUpdate=!0;var Qt;switch(ie[Nt.path]){case ie.weights:Qt=Zc;break;case ie.rotation:Qt=Xh;break;case ie.position:case ie.scale:default:Qt=Xc;break}var Pn=Gt.name?Gt.name:Gt.uuid,pn=qe.interpolation!==void 0?ue[qe.interpolation]:nc,On=[];ie[Nt.path]===ie.weights?Gt.traverse(function(yi){yi.isMesh===!0&&yi.morphTargetInfluences&&On.push(yi.name?yi.name:yi.uuid)}):On.push(Pn);var Gn=Zt.array;if(Zt.normalized){var Zn;if(Gn.constructor===Int8Array)Zn=1/127;else if(Gn.constructor===Uint8Array)Zn=1/255;else if(Gn.constructor==Int16Array)Zn=1/32767;else if(Gn.constructor===Uint16Array)Zn=1/65535;else throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");for(var Wi=new Float32Array(Gn.length),Nn=0,Ci=Gn.length;Nn<Ci;Nn++)Wi[Nn]=Gn[Nn]*Zn;Gn=Wi}for(var Nn=0,Ci=On.length;Nn<Ci;Nn++){var ei=new Qt(On[Nn]+"."+ie[Nt.path],on.array,Gn,pn);qe.interpolation==="CUBICSPLINE"&&(ei.createInterpolant=function(Wr){return new O(this.times,this.values,this.getValueSize()/3,Wr)},ei.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),dn.push(ei)}}}var Ki=Ve.name!==void 0?Ve.name:"animation_"+Pe;return new va(Ki,void 0,dn)})},gt.prototype.loadNode=function(Pe){var ge=this.json,Ve=this.extensions,Ne=this,Ie=ge.meshReferences,it=ge.meshUses,ce=ge.nodes[Pe];return function(){var we=[];return ce.mesh!==void 0&&we.push(Ne.getDependency("mesh",ce.mesh).then(function(Me){var pe;if(Ie[ce.mesh]>1){var Be=it[ce.mesh]++;pe=Me.clone(),pe.name+="_instance_"+Be}else pe=Me;return ce.weights!==void 0&&pe.traverse(function($e){if($e.isMesh)for(var ot=0,bt=ce.weights.length;ot<bt;ot++)$e.morphTargetInfluences[ot]=ce.weights[ot]}),pe})),ce.camera!==void 0&&we.push(Ne.getDependency("camera",ce.camera)),ce.extensions&&ce.extensions[i.KHR_LIGHTS_PUNCTUAL]&&ce.extensions[i.KHR_LIGHTS_PUNCTUAL].light!==void 0&&we.push(Ne.getDependency("light",ce.extensions[i.KHR_LIGHTS_PUNCTUAL].light)),Promise.all(we)}().then(function(we){var Me;if(ce.isBone===!0?Me=new R_:we.length>1?Me=new rl:we.length===1?Me=we[0]:Me=new rn,Me!==we[0])for(var pe=0,Be=we.length;pe<Be;pe++)Me.add(we[pe]);if(ce.name!==void 0&&(Me.userData.name=ce.name,Me.name=mr.sanitizeNodeName(ce.name)),Ue(Me,ce),ce.extensions&&se(Ve,Me,ce),ce.matrix!==void 0){var $e=new jn;$e.fromArray(ce.matrix),Me.applyMatrix4($e)}else ce.translation!==void 0&&Me.position.fromArray(ce.translation),ce.rotation!==void 0&&Me.quaternion.fromArray(ce.rotation),ce.scale!==void 0&&Me.scale.fromArray(ce.scale);return Me})},gt.prototype.loadScene=function(){function Pe(ge,Ve,Ne,Ie){var it=Ne.nodes[ge];return Ie.getDependency("node",ge).then(function(ce){if(it.skin===void 0)return ce;var we;return Ie.getDependency("skin",it.skin).then(function(Me){we=Me;for(var pe=[],Be=0,$e=we.joints.length;Be<$e;Be++)pe.push(Ie.getDependency("node",we.joints[Be]));return Promise.all(pe)}).then(function(Me){return ce.traverse(function(pe){if(pe.isMesh){for(var Be=[],$e=[],ot=0,bt=Me.length;ot<bt;ot++){var Vt=Me[ot];if(Vt){Be.push(Vt);var oe=new jn;we.inverseBindMatrices!==void 0&&oe.fromArray(we.inverseBindMatrices.array,ot*16),$e.push(oe)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',we.joints[ot])}pe.bind(new vf(Be,$e),pe.matrixWorld)}}),ce})}).then(function(ce){Ve.add(ce);var we=[];if(it.children)for(var Me=it.children,pe=0,Be=Me.length;pe<Be;pe++){var $e=Me[pe];we.push(Pe($e,ce,Ne,Ie))}return Promise.all(we)})}return function(Ve){var Ne=this.json,Ie=this.extensions,it=this.json.scenes[Ve],ce=this,we=new So;it.name!==void 0&&(we.name=it.name),Ue(we,it),it.extensions&&se(Ie,we,it);for(var Me=it.nodes||[],pe=[],Be=0,$e=Me.length;Be<$e;Be++)pe.push(Pe(Me[Be],we,Ne,ce));return Promise.all(pe).then(function(){return we})}}(),e}();function mL(e){new fL().load("./gis/34M_17.gltf",i=>{i.scene.position.set(116577.28779765591,19632.646909285337,0),i.scene.rotateX(Math.PI/2),i.scene.scale.set(2,2,2),e.addObject(i.scene)})}class gL extends te.MxCADPluginBase{constructor(){super(),this.map_default_data=hL()}}let _d;const{showModal:_L,hideModal:yd}=e0();function yL(){return wn(this,null,function*(){_L({title:"My Test Draw",text:"测试Modal",oncancel:()=>{yd()},onsubmit:()=>{yd()},ongetallentity:()=>{yd(),tt.MxFun.sendStringToExecute("TestGetAllEntity")},ondrawline:()=>{yd(),tt.MxFun.sendStringToExecute("Mx_Circle")},docommand:e=>{yd(),tt.MxFun.sendStringToExecute(e)}})})}const H1=document.createElement("div");document.body.appendChild(H1),ct.createApp(TM).mount(H1),SM(),tt.MxFun.on("mxcadApplicationStart",e=>{_d=e,_d.init(new gL)}),tt.MxFun.on("mxcadApplicationInitMap",()=>{dL(_d.mxmap)}),tt.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{e.mxcad.on("selectChange",i=>{if(i.length==0)return;let l=i[0],h=l.getMxDbEntity();if(h!==null){console.log(h.getTypeName()),h instanceof tt.MxDbRectBoxLeadComment&&console.log(h.text);return}let p=l.getMcDbEntity();p!==null&&(console.log(p.objectName),p instanceof te.McDbText?console.log(p.textString):p instanceof te.McDbBlockReference&&p.getAllAttribute().forEach(M=>{let T=M.getMcDbEntity();console.log(T.textString),console.log(T.tag)}))}),te.MxCpp.PropertiesWindow.onEvent_getProperties(i=>{let l=i.getMcDbEntity();if(!l)return[];let h=l.getxDataDouble("DN"),p=l.getxDataDouble("LEN"),_=[];return h.ret&&_.push({sVarName:"DN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),p.ret&&_.push({sVarName:"LEN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:p.val,isOnlyRead:!1}),_}),te.MxCpp.PropertiesWindow.onEvent_setProperties((i,l)=>{let h=i.getMcDbEntity();h&&(l.sVarName=="DN"?h.setxDataDouble("DN",l.val):l.sVarName=="LEN"&&h.setxDataDouble("LEN",l.val))})});function vd(){return _d}function Er(e){return"x="+e.x+",y="+e.y+",z="+e.z}function vL(){window.open("https://demo.mxdraw3d.com:3562/MxCADCode.7z")}function xL(){window.open("https://demo.mxdraw3d.com:3562/MxDrawCloudServer1.0TryVersion.7z")}function nu(e){var n=window.location.href;return n.indexOf("?")!=-1&&(n=n.replace(/(\?|#)[^'"]*/,"")),`${n}?map=true&maptype=${e}`}function bL(){window.open(nu("gdslwzj"))}function wL(){window.open(nu("google"))}function ML(){window.open(nu("gdyx"))}function TL(){window.open(nu("tdtsl"))}function EL(){window.open(nu("bdsl"))}function SL(){window.open(nu("geoq"))}function AL(){te.MxCpp.getCurrentMxCAD().setViewBackgroundColor(255,255,255),tt.MxFun.callEvent("updateBackgroundColor",new te.McCmColor(255,255,255))}function W1(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择要需要开启自定义属性的对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity();te.MxCpp.PropertiesWindow.setEntitySupportCustom(n),i.setxDataDouble("DN",100),i.setxDataDouble("LEN",2e3)})}function CL(){te.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/a9cbed3d3a351b79f24484e87bd78338.DWG.mxweb")}function PL(){return wn(this,null,function*(){})}function LL(){return wn(this,null,function*(){let e=new te.MxCADUiPrEntity;e.setMessage("选择要隐藏的对象");let n=yield e.go();if(!n.isValid())return;let i=n.getMcDbEntity(),l=te.MxCpp.getCurrentMxCAD(),_=l.getDatabase().getLayerTable().get(i.layer).getMcDbLayerTableRecord();_!==null&&(_.isOff=!0,l.updateLayerDisplayStatus(),l.updateDisplay())})}function DL(){return window.location.origin+window.location.pathname}function IL(){return wn(this,null,function*(){const e=new te.MxCADUiPrPoint;e.setMessage(`
  3906. 指定插入点:`);let n=yield e.go();if(!n)return;let i=te.MxCpp.getCurrentMxCAD(),l=DL()+"mxcad.jpg";i.loadImage(l,h=>{if(!h){console.log("loadImage failed");return}let p=i.mxdraw.viewCoordLong2Cad(100),_=h.height/h.width*p;i.drawImage(n.x,n.y,p,_,0,l),i.updateDisplay()})})}function j1(){return wn(this,null,function*(){let e=te.MxCpp.getCurrentMxCAD(),n=new te.MxCADUiPrPoint,i=yield n.go();if(i==null)return;n.setBasePt(i);let l=yield n.go();if(l==null)return;let h=e.drawLine(i.x,i.y,l.x,l.y);e.addCurrentSelect(h)})}let q1=0;function Z1(){return wn(this,null,function*(){q1+=Math.PI*.5,te.MxCpp.getCurrentMxCAD().zoomAngle(q1)})}function X1(){te.MxCpp.getCurrentMxCAD().zoomCenter(900,900)}tt.MxFun.on("mxcadApplicationStartCreatingMxCADObject",e=>{let n=e.mxdraw;n.setViewMovementMethod(!0),n.on("openFileComplete",()=>{window.parent.postMessage({cmd:"MKY_Open_File_Complete"})}),n.addControlsEvent("mousedown",i=>{let l=i.offsetX,h=i.offsetY,p=n.viewCoord2Cad(l,h,0);return console.log("mousedown:",p),0})}),tt.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{e.mxcad.on("selectChange",i=>{if(i.length==0)return;let l=i[0],h=l.getMxDbEntity();if(h!==null){console.log(h.getTypeName()),h instanceof tt.MxDbRectBoxLeadComment&&console.log(h.text);return}let p=l.getMcDbEntity();p!==null&&(console.log(p.objectName),p instanceof te.McDbText?console.log(p.textString):p instanceof te.McDbBlockReference&&p.getAllAttribute().forEach(M=>{let T=M.getMcDbEntity();console.log(T.textString),console.log(T.tag)}))}),te.MxCpp.PropertiesWindow.onEvent_getProperties(i=>{let l=i.getMcDbEntity();if(!l)return[];let h=l.getxDataDouble("DN"),p=l.getxDataDouble("LEN"),_=[];return h.ret&&_.push({sVarName:"DN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),p.ret&&_.push({sVarName:"LEN",iVarType:te.MxPropertiesWindowCustomValueType.kDouble,val:p.val,isOnlyRead:!1}),_}),te.MxCpp.PropertiesWindow.onEvent_setProperties((i,l)=>{let h=i.getMcDbEntity();h&&(l.sVarName=="DN"?h.setxDataDouble("DN",l.val):l.sVarName=="LEN"&&h.setxDataDouble("LEN",l.val))}),RL()});function RL(){tt.MxFun.addCommand("My_PluginTest",yL),tt.MxFun.addCommand("Mx_Open_DemoCode",vL),tt.MxFun.addCommand("Mx_Open_DevInstall",xL),tt.MxFun.addCommand("Mx_Open_Map_gdslwzj",bL),tt.MxFun.addCommand("Mx_Open_Map_gdyx",ML),tt.MxFun.addCommand("Mx_Open_Map_tdtsl",TL),tt.MxFun.addCommand("Mx_Open_Map_bdsl",EL),tt.MxFun.addCommand("Mx_Open_Map_geoq",SL),tt.MxFun.addCommand("Mx_Open_Map_googlecn",wL),tt.MxFun.addCommand("Mx_ViewBackgroundColor",AL),tt.MxFun.addCommand("Mx_TestExProp",W1),tt.MxFun.addCommand("Mx_Test_OpenFile",CL),tt.MxFun.addCommand("Mx_Test_GetFile",PL),tt.MxFun.addCommand("Mx_TestExProp",W1),tt.MxFun.addCommand("Mx_SelectEntitHideLayer",LL),tt.MxFun.addCommand("MxTest_TestAddCurrentSelect",j1),tt.MxFun.addCommand("MxTest_TestSetViewAngle",Z1),tt.MxFun.addCommand("MxText_ZoomCenter",X1),tt.MxFun.addCommand("MxTest_Map_Download",pL),tt.MxFun.addCommand("Mx_Test_DrawImage",IL),kM(),$M(),MP(),EP(),n3(),u3(),d3(),g3(),y3(),Z3(),K3(),f3(),aL(),_d.mxmap&&mL(tt.MxFun.getCurrentDraw())}return wo.McGePoint3dToString=Er,wo.MxTest_TestAddCurrentSelect=j1,wo.MxTest_TestSetViewAngle=Z1,wo.MxText_ZoomCenter=X1,wo.getMxCADUi=vd,Object.defineProperty(wo,Symbol.toStringTag,{value:"Module"}),wo}({},Mx,mxcad,Vue,axios);
  3907. //# sourceMappingURL=test.js.map