var test=function(ar,X,M,q,Wp){"use strict";var HF=Object.defineProperty;var TM=Object.getOwnPropertySymbols;var $F=Object.prototype.hasOwnProperty,qF=Object.prototype.propertyIsEnumerable;var fx=Math.pow,EM=(ar,X,M)=>X in ar?HF(ar,X,{enumerable:!0,configurable:!0,writable:!0,value:M}):ar[X]=M,CM=(ar,X)=>{for(var M in X||(X={}))$F.call(X,M)&&EM(ar,M,X[M]);if(TM)for(var M of TM(X))qF.call(X,M)&&EM(ar,M,X[M]);return ar};var Qe=(ar,X,M)=>new Promise((q,Wp)=>{var jp=wa=>{try{Qa(M.next(wa))}catch(sh){Wp(sh)}},tc=wa=>{try{Qa(M.throw(wa))}catch(sh){Wp(sh)}},Qa=wa=>wa.done?q(wa.value):Promise.resolve(wa.value).then(jp,tc);Qa((M=M.apply(ar,X)).next())});var jp=document.createElement("style");jp.textContent=`.heading[data-v-2e0ffbfe]{font-size:1.5em;margin-bottom:12px}.card[data-v-2e0ffbfe]{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-2e0ffbfe]{font-size:1.1em;margin-bottom:44px}.content-wrapper[data-v-2e0ffbfe]:last-child{margin-bottom:0}.button[data-v-2e0ffbfe]{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-2e0ffbfe]:focus{border:2px solid transparent;box-shadow:0 0 0 2px #121943;outline:solid 4px transparent}.link[data-v-2e0ffbfe]{color:#121943}.link[data-v-2e0ffbfe]:focus{box-shadow:0 0 0 2px #121943}.input-wrapper[data-v-2e0ffbfe]{display:flex;flex-direction:column}.input-wrapper .label[data-v-2e0ffbfe]{align-items:baseline;display:flex;font-weight:700;justify-content:space-between;margin-bottom:8px}.input-wrapper .optional[data-v-2e0ffbfe]{color:#5a72b5;font-size:.9em}.input-wrapper .input[data-v-2e0ffbfe]{border:1px solid #5a72b5;border-radius:4px;height:40px;padding:8px}code[data-v-2e0ffbfe]{background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;padding:2px 4px}.modal-header[data-v-2e0ffbfe]{align-items:baseline;display:flex;justify-content:space-between}.close[data-v-2e0ffbfe]{background:none;border:none;cursor:pointer;display:flex;height:16px;text-decoration:none;width:16px}.close svg[data-v-2e0ffbfe]{width:16px}.modal-wrapper[data-v-2e0ffbfe]{align-items:center;background:rgba(0,0,0,.7);display:flex;justify-content:center;inset:0;position:fixed}#modal[data-v-2e0ffbfe]{transition:opacity .25s ease-in-out}#modal .modal-body[data-v-2e0ffbfe]{max-width:830px;opacity:1;transform:translateY(-100px);transition:opacity .25s ease-in-out;width:100%;z-index:1}.outside-trigger[data-v-2e0ffbfe]{cursor:default;inset:0;position:fixed}.button__link[data-v-2e0ffbfe]{text-decoration:none}.button[data-v-2e0ffbfe]{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-2e0ffbfe]{background-color:#fff;color:#000;border:2px solid #4CAF50}.button1[data-v-2e0ffbfe]:hover{background-color:#4caf50;color:#fff}.button2[data-v-2e0ffbfe]{background-color:#fff;color:#000;border:2px solid #008CBA}.button2[data-v-2e0ffbfe]:hover{background-color:#008cba;color:#fff}.btn_box[data-v-2e0ffbfe]{width:100%;display:flex;justify-items:center;justify-content:start;align-items:start}.heading[data-v-6c1067c7]{font-size:1.5em;margin-bottom:12px}.btn[data-v-6c1067c7]{height:40px;width:100px;text-align:center;line-height:40px;font-size:16px;font-weight:700}.btn2[data-v-6c1067c7]{background-color:#008cba;color:#fff;border-top-right-radius:4px;border-top-left-radius:4px}.card[data-v-6c1067c7]{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%;height:600px}.content-wrapper[data-v-6c1067c7]{font-size:1.1em;margin-bottom:44px}.content-wrapper[data-v-6c1067c7]:last-child{margin-bottom:0}.button[data-v-6c1067c7]{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-6c1067c7]:focus{border:2px solid transparent;box-shadow:0 0 0 2px #121943;outline:solid 4px transparent}.link[data-v-6c1067c7]{color:#121943}.link[data-v-6c1067c7]:focus{box-shadow:0 0 0 2px #121943}.input-wrapper[data-v-6c1067c7]{display:flex;flex-direction:column}.input-wrapper .label[data-v-6c1067c7]{align-items:baseline;display:flex;font-weight:700;justify-content:space-between;margin-bottom:8px}.input-wrapper .optional[data-v-6c1067c7]{color:#5a72b5;font-size:.9em}.input-wrapper .input[data-v-6c1067c7]{border:1px solid #5a72b5;border-radius:4px;height:40px;padding:8px}code[data-v-6c1067c7]{background:#e5efe9;border:1px solid #5a72b5;border-radius:4px;padding:2px 4px}.modal-header[data-v-6c1067c7]{align-items:baseline;display:flex;justify-content:space-between}.close[data-v-6c1067c7]{background:none;border:none;cursor:pointer;display:flex;height:16px;text-decoration:none;width:16px}.close svg[data-v-6c1067c7]{width:16px}.modal-wrapper[data-v-6c1067c7]{align-items:center;background:rgba(0,0,0,.7);display:flex;justify-content:center;inset:0;position:fixed}#modal[data-v-6c1067c7]{transition:opacity .25s ease-in-out}#modal .modal-body[data-v-6c1067c7]{max-width:830px;opacity:1;transform:translateY(-100px);transition:opacity .25s ease-in-out;width:100%;z-index:1}.outside-trigger[data-v-6c1067c7]{cursor:default;inset:0;position:fixed}.button__link[data-v-6c1067c7]{text-decoration:none}.button[data-v-6c1067c7]{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-6c1067c7]{background-color:#fff;color:#000;border:2px solid #4CAF50}.button1[data-v-6c1067c7]:hover{background-color:#4caf50;color:#fff}.button2[data-v-6c1067c7]{background-color:#fff;color:#000;border:2px solid #008CBA}.button2[data-v-6c1067c7]:hover{background-color:#008cba;color:#fff}.btn_box[data-v-6c1067c7]{width:100%;display:flex;justify-items:center;justify-content:start;align-items:start}.textBox[data-v-6c1067c7]{position:absolute;top:30%;left:42%;background-image:linear-gradient(48deg,#fff 0%,#e5efe9 100%);color:#000;padding:10px 15px}.textBox .header[data-v-6c1067c7]{display:flex;justify-content:space-between;align-items:center}.textBox textarea[data-v-6c1067c7]{color:#000;background-color:#ccc;border:1px solid #5a72b5;border-radius:8px;margin-top:10px;font-size:var(--mx-font-size);padding:5px}.textBox .btnBox[data-v-6c1067c7]{display:flex;justify-content:flex-end}.textBox .btnBox button[data-v-6c1067c7]{background-color:#fff;color:#000;border:2px solid #008CBA;border-radius:5px;padding:5px;margin-top:10px}.textBox .btnBox button[data-v-6c1067c7]:hover{background-color:#008cba;color:#fff} `,document.head.appendChild(jp);const tc=q.ref(!1),Qa=q.ref(!1),wa=e=>{tc.value=!0,Qa.value=!1,ch.value=Object.assign(ch.value,e||{})},sh=e=>{Qa.value=!0,tc.value=!1,ch.value=Object.assign(ch.value,e||{})},lh=()=>{tc.value=!1,Qa.value=!1},DM={title:"Modal",text:"",oncancel:lh,onsubmit:lh,ongetallentity:lh,ondrawline:lh,docommand:e=>{}},ch=q.ref(DM),PM=q.ref(!1),mx=q.ref(""),Hp=q.ref("");document.addEventListener("mouseup",function(){Hp.value=document.getSelection().toString(),Hp.value===""&&(Hp.value=mx.value)});function SM(){return Qe(this,null,function*(){try{yield navigator.clipboard.writeText(Hp.value)}catch(e){console.error("Failed to copy: ",e)}})}const $p=()=>({isModalVisible:tc,isToolsVisible:Qa,isDialogVisible:PM,showModal:wa,showTools:sh,hideModal:lh,modalOptions:ch,excelText:mx,copyTextToClipboard:SM}),LM={key:0,class:"modal-wrapper",id:"modal"},IM={class:"modal-body card"},RM={class:"modal-header"},kM={class:"heading"},zM={style:{"overflow-y":"auto",height:"500px"}},FM={class:"btn_box"},BM={class:"btn_box"},OM={class:"btn_box"},NM={class:"btn_box"},UM={class:"btn_box"},VM={class:"btn_box"},GM={class:"btn_box"},WM={class:"btn_box"},jM={class:"btn_box"},HM={class:"btn_box"},$M={class:"btn_box"},qM={class:"btn_box"},XM={class:"btn_box"},ZM={class:"btn_box"},YM={class:"btn_box"},KM={class:"btn_box"},JM={class:"btn_box"},QM=q.defineComponent({__name:"Modal",setup(e){const{isModalVisible:t,hideModal:i,modalOptions:l}=$p();return(c,h)=>(q.openBlock(),q.createBlock(q.Teleport,{to:"body"},[q.unref(t)?(q.openBlock(),q.createElementBlock("div",LM,[q.createElementVNode("div",IM,[q.createElementVNode("div",RM,[q.createElementVNode("h2",kM,q.toDisplayString(q.unref(l).title),1),q.createElementVNode("a",{href:"#!",onClick:h[0]||(h[0]=(...f)=>q.unref(i)&&q.unref(i)(...f)),role:"button",class:"close","aria-label":"close this modal"},h[68]||(h[68]=[q.createElementVNode("svg",{viewBox:"0 0 24 24"},[q.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)]))]),q.createElementVNode("div",zM,[q.createElementVNode("div",FM,[q.createElementVNode("button",{class:"button button2",onClick:h[1]||(h[1]=f=>q.unref(l).docommand("Mx_Open_DemoCode"))},"下载开Demo代码"),q.createElementVNode("button",{class:"button button2",onClick:h[2]||(h[2]=f=>q.unref(l).docommand("Mx_Open_DevInstall"))},"下载开发包"),q.createElementVNode("button",{class:"button button2",onClick:h[3]||(h[3]=(...f)=>q.unref(l).ondrawline&&q.unref(l).ondrawline(...f))},"调用画圆线命令"),q.createElementVNode("button",{class:"button button2",onClick:h[4]||(h[4]=f=>q.unref(l).docommand("MxTest_DrawLine"))},"交互画直线")]),q.createElementVNode("div",BM,[q.createElementVNode("button",{class:"button button2",onClick:h[5]||(h[5]=f=>q.unref(l).docommand("MxTest_AddLayer"))},"添加图层"),q.createElementVNode("button",{class:"button button2",onClick:h[6]||(h[6]=f=>q.unref(l).docommand("MxTest_GetAllLayer"))},"得到所有图层"),q.createElementVNode("button",{class:"button button2",onClick:h[7]||(h[7]=f=>q.unref(l).docommand("MxTest_GetAllTextStyle"))},"得到所有文字样式"),q.createElementVNode("button",{class:"button button2",onClick:h[8]||(h[8]=f=>q.unref(l).docommand("MxTest_GetAllBlock"))},"得到所有图块")]),q.createElementVNode("div",OM,[q.createElementVNode("button",{class:"button button2",onClick:h[9]||(h[9]=f=>q.unref(l).docommand("MxTest_GetAllLinetype"))},"得到所有线型"),q.createElementVNode("button",{class:"button button2",onClick:h[10]||(h[10]=f=>q.unref(l).docommand("MxTest_WritexData"))},"写扩展数据"),q.createElementVNode("button",{class:"button button2",onClick:h[11]||(h[11]=f=>q.unref(l).docommand("MxTest_ReadxData"))},"读扩展数据"),q.createElementVNode("button",{class:"button button2",onClick:h[12]||(h[12]=f=>q.unref(l).docommand("MxTest_InsertBlock"))},"测试插入一个图块")]),q.createElementVNode("div",NM,[q.createElementVNode("button",{class:"button button2",onClick:h[13]||(h[13]=f=>q.unref(l).docommand("Mx_Test_DrawLine"))},"绘直线"),q.createElementVNode("button",{class:"button button2",onClick:h[14]||(h[14]=f=>q.unref(l).docommand("Mx_Test_DrawArc"))},"绘圆弧"),q.createElementVNode("button",{class:"button button2",onClick:h[15]||(h[15]=f=>q.unref(l).docommand("Mx_Test_DrawCircle"))},"绘圆"),q.createElementVNode("button",{class:"button button2",onClick:h[16]||(h[16]=f=>q.unref(l).docommand("Mx_Test_DrawPolyline"))},"绘PL线")]),q.createElementVNode("div",UM,[q.createElementVNode("button",{class:"button button2",onClick:h[17]||(h[17]=f=>q.unref(l).docommand("Mx_Test_DrawHatch"))},"绘填充"),q.createElementVNode("button",{class:"button button2",onClick:h[18]||(h[18]=f=>q.unref(l).docommand("Mx_Test_DrawText"))},"绘文字"),q.createElementVNode("button",{class:"button button2",onClick:h[19]||(h[19]=f=>q.unref(l).docommand("Mx_Test_Ellipse"))},"绘椭圆"),q.createElementVNode("button",{class:"button button2",onClick:h[20]||(h[20]=f=>q.unref(l).docommand("Mx_Test_EllipseArc"))},"绘椭圆弧")]),q.createElementVNode("div",VM,[q.createElementVNode("button",{class:"button button2",onClick:h[21]||(h[21]=f=>q.unref(l).docommand("Mx_Test_MText"))},"绘制多行文字"),q.createElementVNode("button",{class:"button button2",onClick:h[22]||(h[22]=f=>q.unref(l).docommand("Mx_Test_DrawTable"))},"绘制表格"),q.createElementVNode("button",{class:"button button2",onClick:h[23]||(h[23]=f=>q.unref(l).docommand("Mx_Test_QRCode"))},"绘制二维码"),q.createElementVNode("button",{class:"button button2",onClick:h[24]||(h[24]=f=>q.unref(l).docommand("MxTest_InsertStamp"))},"插入图章")]),q.createElementVNode("div",GM,[q.createElementVNode("button",{class:"button button2",onClick:h[25]||(h[25]=(...f)=>q.unref(l).ongetallentity&&q.unref(l).ongetallentity(...f))},"得到所有对象"),q.createElementVNode("button",{class:"button button2",onClick:h[26]||(h[26]=f=>q.unref(l).docommand("MxTest_SelectEntity"))},"交互选择对象"),q.createElementVNode("button",{class:"button button2",onClick:h[27]||(h[27]=f=>q.unref(l).docommand("Mx_Export_MxWeb"))},"保存mxweb到服务器"),q.createElementVNode("button",{class:"button button2",onClick:h[28]||(h[28]=f=>q.unref(l).docommand("MxTest_GetSysVars"))},"得到系统变量")]),q.createElementVNode("div",WM,[q.createElementVNode("button",{class:"button button2",onClick:h[29]||(h[29]=f=>q.unref(l).docommand("MxTest_NewFile"))},"新建图纸"),q.createElementVNode("button",{class:"button button2",onClick:h[30]||(h[30]=f=>q.unref(l).docommand("Mx_ViewBackgroundColor"))},"白色背景色"),q.createElementVNode("button",{class:"button button2",onClick:h[31]||(h[31]=f=>q.unref(l).docommand("MxTest_FindText"))},"文字查找定位"),q.createElementVNode("button",{class:"button button2",onClick:h[32]||(h[32]=f=>q.unref(l).docommand("MxTest_SelectEntitysToBlock"))},"选择实体做块")]),q.createElementVNode("div",jM,[q.createElementVNode("button",{class:"button button2",onClick:h[33]||(h[33]=f=>q.unref(l).docommand("Mx_Test_Text"))},"绘制单行文字"),q.createElementVNode("button",{class:"button button2",onClick:h[34]||(h[34]=f=>q.unref(l).docommand("MxTest_DrawHatchFormPoint"))},"选点填充"),q.createElementVNode("button",{class:"button button2",onClick:h[35]||(h[35]=f=>q.unref(l).docommand("Mx_TestExProp"))},"设置扩展属性"),q.createElementVNode("button",{class:"button button2",onClick:h[36]||(h[36]=f=>q.unref(l).docommand("Mx_Test_DimAligned"))},"绘制对齐标注")]),q.createElementVNode("div",HM,[q.createElementVNode("button",{class:"button button2",onClick:h[37]||(h[37]=f=>q.unref(l).docommand("Mx_Test_DrawDimRotated"))},"绘性线标注"),q.createElementVNode("button",{class:"button button2",onClick:h[38]||(h[38]=f=>q.unref(l).docommand("Mx_Test_DrawDimAngular"))},"角度标注"),q.createElementVNode("button",{class:"button button2",onClick:h[39]||(h[39]=f=>q.unref(l).docommand("MxTest_LineTypeTest"))},"修改对象线型"),q.createElementVNode("button",{class:"button button2",onClick:h[40]||(h[40]=f=>q.unref(l).docommand("Mx_SelectEntitHideLayer"))},"选择隐藏对象层")]),q.createElementVNode("div",$M,[q.createElementVNode("button",{class:"button button2",onClick:h[41]||(h[41]=f=>q.unref(l).docommand("MxTest_TestAddCurrentSelect"))},"添加到当前选择"),q.createElementVNode("button",{class:"button button2",onClick:h[42]||(h[42]=f=>q.unref(l).docommand("MxTest_TestSetViewAngle"))},"视区旋转"),q.createElementVNode("button",{class:"button button2",onClick:h[43]||(h[43]=f=>q.unref(l).docommand("MxTest_WriteXRecord"))},"写扩展记录"),q.createElementVNode("button",{class:"button button2",onClick:h[44]||(h[44]=f=>q.unref(l).docommand("MxTest_GetNamedObjectsDictionary"))},"得到命名字典")]),q.createElementVNode("div",qM,[q.createElementVNode("button",{class:"button button2",onClick:h[45]||(h[45]=f=>q.unref(l).docommand("MxTest_AddTextStyleTable"))},"添加文字样式"),q.createElementVNode("button",{class:"button button2",onClick:h[46]||(h[46]=f=>q.unref(l).docommand("MxTest_DrawCustomEntity"))},"绘自定义实体"),q.createElementVNode("button",{class:"button button2",onClick:h[47]||(h[47]=f=>q.unref(l).docommand("Mx_Test_ChangeColor"))},"修改对象颜色"),q.createElementVNode("button",{class:"button button2",onClick:h[48]||(h[48]=f=>q.unref(l).docommand("Mx_Test_ChangeVisible"))},"修改对象不可见")]),q.createElementVNode("div",XM,[q.createElementVNode("button",{class:"button button2",onClick:h[49]||(h[49]=f=>q.unref(l).docommand("Mx_Test_ChangeEntityLayer"))},"修改对象层"),q.createElementVNode("button",{class:"button button2",onClick:h[50]||(h[50]=f=>q.unref(l).docommand("Mx_ChaneEntityDrawOrder"))},"修改对象显示顺序"),q.createElementVNode("button",{class:"button button2",onClick:h[51]||(h[51]=f=>q.unref(l).docommand("Mx_Export_Pdf"))},"指定范围输出pdf"),q.createElementVNode("button",{class:"button button2",onClick:h[52]||(h[52]=f=>q.unref(l).docommand("Mx_Test_DrawImage"))},"绘制image")]),q.createElementVNode("div",ZM,[q.createElementVNode("button",{class:"button button2",onClick:h[53]||(h[53]=f=>q.unref(l).docommand("MxTest_GetObjectExDictionaryData"))},"读取对象扩展字典"),q.createElementVNode("button",{class:"button button2",onClick:h[54]||(h[54]=f=>q.unref(l).docommand("Mx_Test_Draw3DPolyline"))},"绘制3DPolyline"),q.createElementVNode("button",{class:"button button2",onClick:h[55]||(h[55]=f=>q.unref(l).docommand("MxTest_LineText"))},"绘线文本自定义实体"),q.createElementVNode("button",{class:"button button2",onClick:h[56]||(h[56]=f=>q.unref(l).docommand("Mx_Test_IntersectWith"))},"计算交点")]),q.createElementVNode("div",YM,[q.createElementVNode("button",{class:"button button2",onClick:h[57]||(h[57]=f=>q.unref(l).docommand("Mx_Test_TrueText"))},"修改文字样式"),q.createElementVNode("button",{class:"button button2",onClick:h[58]||(h[58]=f=>q.unref(l).docommand("Mx_Test_OffsetIn_DrawLine"))},"偏移输入画线"),q.createElementVNode("button",{class:"button button2",onClick:h[59]||(h[59]=f=>q.unref(l).docommand("Mx_Test_CreateGroup"))},"创建组"),q.createElementVNode("button",{class:"button button2",onClick:h[60]||(h[60]=f=>q.unref(l).docommand("Mx_ScreenToJpg"))},"屏幕截图jpg")]),q.createElementVNode("div",KM,[q.createElementVNode("button",{class:"button button2",onClick:h[61]||(h[61]=f=>q.unref(l).docommand("Mx_Test_GetText"))},"获取图纸相同文字"),q.createElementVNode("button",{class:"button button2",onClick:h[62]||(h[62]=f=>q.unref(l).docommand("Mx_Cut_Dwg"))},"指定范围输出dwg"),q.createElementVNode("button",{class:"button button2",onClick:h[63]||(h[63]=f=>q.unref(l).docommand("Mx_Test_DrawMarkCircle"))},"测试绘制标记圆"),q.createElementVNode("button",{class:"button button2",onClick:h[64]||(h[64]=f=>q.unref(l).docommand("Mx_Test_Wipeout"))},"测试Wipeout")]),q.createElementVNode("div",JM,[q.createElementVNode("button",{class:"button button2",onClick:h[65]||(h[65]=f=>q.unref(l).docommand("MxTest_SelectEntitysToSpatialFilterBlock"))},"创建剪切块"),q.createElementVNode("button",{class:"button button2",onClick:h[66]||(h[66]=f=>q.unref(l).docommand("Mx_Test_DrawDimRotatedTol"))},"公差标注"),q.createElementVNode("button",{class:"button button2",onClick:h[67]||(h[67]=f=>q.unref(l).docommand("MxTest_ModifyAllEntityColor"))},"改所有对象颜色")])])])])):q.createCommentVNode("",!0)]))}}),XF="",ty=(e,t)=>{const i=e.__vccOpts||e;for(const[l,c]of t)i[l]=c;return i},e2=ty(QM,[["__scopeId","data-v-2e0ffbfe"],["__file","Modal.vue"]]),t2={key:0,class:"modal-wrapper",id:"modal"},n2={class:"modal-body card"},i2={class:"modal-header"},r2={class:"heading"},o2={style:{"border-bottom":"2px solid #008CBA","margin-bottom":"8px"}},a2=["onClick"],s2={style:{"overflow-y":"auto",height:"500px"}},l2={class:"btn_box"},c2={class:"btn_box"},u2={class:"btn_box"},h2={class:"btn_box"},d2={class:"btn_box"},p2={style:{"overflow-y":"auto",height:"500px"}},f2={class:"btn_box"},m2={class:"btn_box"},g2={class:"btn_box"},y2={class:"btn_box"},_2={class:"btn_box"},v2={class:"btn_box"},x2={style:{"overflow-y":"auto",height:"500px"}},b2={class:"btn_box"},w2={class:"btn_box"},M2={class:"btn_box"},T2={class:"btn_box"},E2={class:"btn_box"},C2={class:"btn_box"},A2={style:{"overflow-y":"auto",height:"500px"}},D2={class:"btn_box"},P2={class:"btn_box"},S2={class:"btn_box"},L2={class:"btn_box"},I2={style:{"overflow-y":"auto",height:"500px"}},R2={class:"btn_box"},k2={class:"btn_box"},z2={class:"btn_box"},F2={style:{"overflow-y":"auto",height:"500px"}},B2={class:"btn_box"},O2={class:"btn_box"},N2={class:"header"},U2={class:"btnBox"},V2=q.defineComponent({__name:"Tools",setup(e){const{isToolsVisible:t,hideModal:i,modalOptions:l,isDialogVisible:c,excelText:h,copyTextToClipboard:f}=$p(),r=q.reactive([{name:"修改工具",id:"fit"},{name:"文字工具",id:"text"},{name:"绘图工具",id:"draw"},{name:"块工具",id:"block"},{name:"测量工具",id:"count"},{name:"标注工具",id:"dimension"}]),v=q.ref("fit"),{store:x}=MxPluginContext,{setCommandFocus:w}=x.useFocus(),b=q.ref(null),A=L=>{const P=b.value,R=L.clientX-P.offsetLeft,F=L.clientY-P.offsetTop,V=j=>{P.style.left=j.clientX-R+"px",P.style.top=j.clientY-F+"px"};document.addEventListener("mousemove",V),document.addEventListener("mouseup",()=>{document.removeEventListener("mousemove",V)})};return(L,P)=>(q.openBlock(),q.createBlock(q.Teleport,{to:"body"},[q.unref(t)?(q.openBlock(),q.createElementBlock("div",t2,[q.createElementVNode("div",n2,[q.createElementVNode("div",i2,[q.createElementVNode("h2",r2,q.toDisplayString(q.unref(l).title),1),q.createElementVNode("a",{href:"#!",onClick:P[0]||(P[0]=(...R)=>q.unref(i)&&q.unref(i)(...R)),role:"button",class:"close","aria-label":"close this modal"},P[101]||(P[101]=[q.createElementVNode("svg",{viewBox:"0 0 24 24"},[q.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)]))]),q.createElementVNode("div",o2,[(q.openBlock(!0),q.createElementBlock(q.Fragment,null,q.renderList(r,R=>(q.openBlock(),q.createElementBlock("button",{key:R.id,onClick:()=>{v.value=R.id},class:q.normalizeClass(v.value===R.id?"btn btn2":"btn")},q.toDisplayString(R.name),11,a2))),128))]),q.withDirectives(q.createElementVNode("div",s2,[q.createElementVNode("div",l2,[q.createElementVNode("button",{class:"button button2",onClick:P[1]||(P[1]=R=>q.unref(l).docommand("Mx_Multicopy"))},"多重复制"),q.createElementVNode("button",{class:"button button2",onClick:P[2]||(P[2]=R=>q.unref(l).docommand("Mx_ArcToCircle"))},"弧转圆"),q.createElementVNode("button",{class:"button button2",onClick:P[3]||(P[3]=R=>q.unref(l).docommand("Mx_CopyRotation"))},"复制旋转"),q.createElementVNode("button",{class:"button button2",onClick:P[4]||(P[4]=R=>q.unref(l).docommand("Mx_CricleTotoll"))},"圆转多边")]),q.createElementVNode("div",c2,[q.createElementVNode("button",{class:"button button2",onClick:P[5]||(P[5]=R=>q.unref(l).docommand("Mx_ChangeColor"))},"修改颜色"),q.createElementVNode("button",{class:"button button2",onClick:P[6]||(P[6]=R=>q.unref(l).docommand("Mx_ArcToAngle"))},"圆弧切角"),q.createElementVNode("button",{class:"button button2",onClick:P[7]||(P[7]=R=>q.unref(l).docommand("Mx_TemHiding"))},"临时隐藏"),q.createElementVNode("button",{class:"button button2",onClick:P[8]||(P[8]=R=>q.unref(l).docommand("Mx_BoxDel"))},"方框删除")]),q.createElementVNode("div",u2,[q.createElementVNode("button",{class:"button button2",onClick:P[9]||(P[9]=R=>q.unref(l).docommand("Mx_AngleCopy"))},"角度复制"),q.createElementVNode("button",{class:"button button2",onClick:P[10]||(P[10]=R=>q.unref(l).docommand("Mx_VertexRep"))},"顶点复制"),q.createElementVNode("button",{class:"button button2",onClick:P[11]||(P[11]=R=>q.unref(l).docommand("Mx_IntersectBreak"))},"交点打断"),q.createElementVNode("button",{class:"button button2",onClick:P[12]||(P[12]=R=>q.unref(l).docommand("Mx_DoubleOff"))},"双向偏移")]),q.createElementVNode("div",h2,[q.createElementVNode("button",{class:"button button2",onClick:P[13]||(P[13]=R=>q.unref(l).docommand("Mx_EitCircle"))},"改圆大小"),q.createElementVNode("button",{class:"button button2",onClick:P[14]||(P[14]=R=>q.unref(l).docommand("Mx_LayerTypeScale"))},"线型比例"),q.createElementVNode("button",{class:"button button2",onClick:P[15]||(P[15]=R=>q.unref(l).docommand("Mx_Telescoping"))},"伸缩"),q.createElementVNode("button",{class:"button button2",onClick:P[16]||(P[16]=R=>q.unref(l).docommand("Mx_ArcOrder"))},"按弧阵列")]),q.createElementVNode("div",d2,[q.createElementVNode("button",{class:"button button2",onClick:P[17]||(P[17]=R=>q.unref(l).docommand("Mx_PlRoundCorners"))},"pl圆角"),q.createElementVNode("button",{class:"button button2",onClick:P[18]||(P[18]=R=>q.unref(l).docommand("Mx_PlReverse"))},"pl线反向"),q.createElementVNode("button",{class:"button button2",onClick:P[19]||(P[19]=R=>q.unref(l).docommand("Mx_TestGetAllLineByLayer"))},"得到所有直线对象"),q.createElementVNode("button",{class:"button button2",onClick:P[20]||(P[20]=R=>q.unref(l).docommand("Mx_Bisection"))},"等分")]),q.createElementVNode("div",null,[q.createElementVNode("button",{class:"button button2",onClick:P[21]||(P[21]=R=>q.unref(l).docommand("Mx_RectangularScaling"))},"矩形缩放"),q.createElementVNode("button",{class:"button button2",onClick:P[22]||(P[22]=R=>q.unref(l).docommand("Mx_Interrupt"))},"打断")])],512),[[q.vShow,v.value==="fit"]]),q.withDirectives(q.createElementVNode("div",p2,[q.createElementVNode("div",f2,[q.createElementVNode("button",{class:"button button2",onClick:P[23]||(P[23]=R=>q.unref(l).docommand("Mx_DrawStart"))},"星形"),q.createElementVNode("button",{class:"button button2",onClick:P[24]||(P[24]=R=>q.unref(l).docommand("Mx_ConcavoVex"))},"凹凸线"),q.createElementVNode("button",{class:"button button2",onClick:P[25]||(P[25]=R=>q.unref(l).docommand("Mx_ZigzagLine"))},"锯齿线"),q.createElementVNode("button",{class:"button button2",onClick:P[26]||(P[26]=R=>q.unref(l).docommand("Mx_CenterRect"))},"中心矩形")]),q.createElementVNode("div",m2,[q.createElementVNode("button",{class:"button button2",onClick:P[27]||(P[27]=R=>q.unref(l).docommand("Mx_BreakLine"))},"折断线"),q.createElementVNode("button",{class:"button button2",onClick:P[28]||(P[28]=R=>q.unref(l).docommand("Mx_CCLine"))},"圆中心线"),q.createElementVNode("button",{class:"button button2",onClick:P[29]||(P[29]=R=>q.unref(l).docommand("Mx_Piping"))},"管道"),q.createElementVNode("button",{class:"button button2",onClick:P[30]||(P[30]=R=>q.unref(l).docommand("Mx_CutPipeline"))},"剖管符")]),q.createElementVNode("div",g2,[q.createElementVNode("button",{class:"button button2",onClick:P[31]||(P[31]=R=>q.unref(l).docommand("Mx_PerpLine"))},"中垂线"),q.createElementVNode("button",{class:"button button2",onClick:P[32]||(P[32]=R=>q.unref(l).docommand("Mx_StairLine"))},"楼梯"),q.createElementVNode("button",{class:"button button2",onClick:P[33]||(P[33]=R=>q.unref(l).docommand("Mx_SolidCircle"))},"实心圆"),q.createElementVNode("button",{class:"button button2",onClick:P[34]||(P[34]=R=>q.unref(l).docommand("Mx_CottonInsulation"))},"保温棉")]),q.createElementVNode("div",y2,[q.createElementVNode("button",{class:"button button2",onClick:P[35]||(P[35]=R=>q.unref(l).docommand("Mx_CenterLine"))},"中心线"),q.createElementVNode("button",{class:"button button2",onClick:P[36]||(P[36]=R=>q.unref(l).docommand("Mx_DoHole"))},"开洞"),q.createElementVNode("button",{class:"button button2",onClick:P[37]||(P[37]=R=>q.unref(l).docommand("Mx_Compass"))},"指北针"),q.createElementVNode("button",{class:"button button2",onClick:P[38]||(P[38]=R=>q.unref(l).docommand("Mx_MassegeBox"))},"消息框")]),q.createElementVNode("div",_2,[q.createElementVNode("button",{class:"button button2",onClick:P[39]||(P[39]=R=>q.unref(l).docommand("Mx_DatumSymbol"))},"基准符"),q.createElementVNode("button",{class:"button button2",onClick:P[40]||(P[40]=R=>q.unref(l).docommand("Mx_WelLine"))},"焊缝线"),q.createElementVNode("button",{class:"button button2",onClick:P[41]||(P[41]=R=>q.unref(l).docommand("Mx_ConcentricCircles"))},"同心圆"),q.createElementVNode("button",{class:"button button2",onClick:P[42]||(P[42]=R=>q.unref(l).docommand("Mx_Gear"))},"齿轮")]),q.createElementVNode("div",v2,[q.createElementVNode("button",{class:"button button2",onClick:P[43]||(P[43]=R=>q.unref(l).docommand("Mx_BlkCenterLine"))},"块中心线")])],512),[[q.vShow,v.value==="draw"]]),q.withDirectives(q.createElementVNode("div",x2,[q.createElementVNode("div",b2,[q.createElementVNode("button",{class:"button button2",onClick:P[44]||(P[44]=R=>q.unref(l).docommand("Mx_AlignByLine"))},"按线对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[45]||(P[45]=R=>q.unref(l).docommand("Mx_TextHeight"))},"改字高"),q.createElementVNode("button",{class:"button button2",onClick:P[46]||(P[46]=R=>q.unref(l).docommand("Mx_TextWidth"))},"改字宽"),q.createElementVNode("button",{class:"button button2",onClick:P[47]||(P[47]=R=>q.unref(l).docommand("Mx_BrushCon"))},"刷内容")]),q.createElementVNode("div",w2,[q.createElementVNode("button",{class:"button button2",onClick:P[48]||(P[48]=R=>q.unref(l).docommand("Mx_ReplaceCon"))},"换内容"),q.createElementVNode("button",{class:"button button2",onClick:P[49]||(P[49]=R=>q.unref(l).docommand("Mx_AlignLeft"))},"左右对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[50]||(P[50]=R=>q.unref(l).docommand("Mx_AlignUp"))},"上下对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[51]||(P[51]=R=>q.unref(l).docommand("Mx_TextReversal"))},"文字反转")]),q.createElementVNode("div",M2,[q.createElementVNode("button",{class:"button button2",onClick:P[52]||(P[52]=R=>q.unref(l).docommand("Mx_TextTraming"))},"文字加框"),q.createElementVNode("button",{class:"button button2",onClick:P[53]||(P[53]=R=>q.unref(l).docommand("Mx_Underline"))},"下划线"),q.createElementVNode("button",{class:"button button2",onClick:P[54]||(P[54]=R=>q.unref(l).docommand("Mx_TitleLine"))},"图名线"),q.createElementVNode("button",{class:"button button2",onClick:P[55]||(P[55]=R=>q.unref(l).docommand("Mx_Case"))},"大小写")]),q.createElementVNode("div",T2,[q.createElementVNode("button",{class:"button button2",onClick:P[56]||(P[56]=R=>q.unref(l).docommand("Mx_NumSum"))},"数字求和"),q.createElementVNode("button",{class:"button button2",onClick:P[57]||(P[57]=R=>q.unref(l).docommand("Mx_SSWords"))},"选特定字"),q.createElementVNode("button",{class:"button button2",onClick:P[58]||(P[58]=R=>q.unref(l).docommand("Mx_Prefix"))},"前后缀"),q.createElementVNode("button",{class:"button button2",onClick:P[59]||(P[59]=R=>q.unref(l).docommand("Mx_ConnectText"))},"连接文字")]),q.createElementVNode("div",E2,[q.createElementVNode("button",{class:"button button2",onClick:P[60]||(P[60]=R=>q.unref(l).docommand("Mx_TextTrim"))},"去空格"),q.createElementVNode("button",{class:"button button2",onClick:P[61]||(P[61]=R=>q.unref(l).docommand("Mx_VerticalText"))},"文字竖向"),q.createElementVNode("button",{class:"button button2",onClick:P[62]||(P[62]=R=>q.unref(l).docommand("Mx_AlignByArc"))},"按弧对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[63]||(P[63]=R=>q.unref(l).docommand("Mx_EditTextStyle"))},"修改全局文字样式")]),q.createElementVNode("div",C2,[q.createElementVNode("button",{class:"button button2",onClick:P[64]||(P[64]=R=>q.unref(l).docommand("Mx_ExtractText"))},"提取文字")])],512),[[q.vShow,v.value==="text"]]),q.withDirectives(q.createElementVNode("div",A2,[q.createElementVNode("div",D2,[q.createElementVNode("button",{class:"button button2",onClick:P[65]||(P[65]=R=>q.unref(l).docommand("Mx_ChangeBN"))},"改块名"),q.createElementVNode("button",{class:"button button2",onClick:P[66]||(P[66]=R=>q.unref(l).docommand("Mx_BushBlk"))},"刷块"),q.createElementVNode("button",{class:"button button2",onClick:P[67]||(P[67]=R=>q.unref(l).docommand("Mx_ConBlk"))},"块连线"),q.createElementVNode("button",{class:"button button2",onClick:P[68]||(P[68]=R=>q.unref(l).docommand("Mx_BlkCenterLine"))},"块中心线")]),q.createElementVNode("div",P2,[q.createElementVNode("button",{class:"button button2",onClick:P[69]||(P[69]=R=>q.unref(l).docommand("Mx_BlkPt"))},"改块基点"),q.createElementVNode("button",{class:"button button2",onClick:P[70]||(P[70]=R=>q.unref(l).docommand("Mx_BlkColor"))},"改块颜色"),q.createElementVNode("button",{class:"button button2",onClick:P[71]||(P[71]=R=>q.unref(l).docommand("Mx_BlkRotate"))},"多块旋转"),q.createElementVNode("button",{class:"button button2",onClick:P[72]||(P[72]=R=>q.unref(l).docommand("Mx_BlkScale"))},"多块缩放")]),q.createElementVNode("div",S2,[q.createElementVNode("button",{class:"button button2",onClick:P[73]||(P[73]=R=>q.unref(l).docommand("Mx_BlkAngle"))},"刷块角度"),q.createElementVNode("button",{class:"button button2",onClick:P[74]||(P[74]=R=>q.unref(l).docommand("Mx_BlkSelect"))},"按块选择"),q.createElementVNode("button",{class:"button button2",onClick:P[75]||(P[75]=R=>q.unref(l).docommand("Mx_BlkAllSelect"))},"按块全选"),q.createElementVNode("button",{class:"button button2",onClick:P[76]||(P[76]=R=>q.unref(l).docommand("Mx_SSBlk"))},"统计单块")]),q.createElementVNode("div",L2,[q.createElementVNode("button",{class:"button button2",onClick:P[77]||(P[77]=R=>q.unref(l).docommand("Mx_SMBlk"))},"统计多块"),q.createElementVNode("button",{class:"button button2",onClick:P[78]||(P[78]=R=>q.unref(l).docommand("Mx_BlkLayer"))},"修改块图层")])],512),[[q.vShow,v.value==="block"]]),q.withDirectives(q.createElementVNode("div",I2,[q.createElementVNode("div",R2,[q.createElementVNode("button",{class:"button button2",onClick:P[79]||(P[79]=R=>q.unref(l).docommand("Mx_StaLength"))},"长度"),q.createElementVNode("button",{class:"button button2",onClick:P[80]||(P[80]=R=>q.unref(l).docommand("Mx_StaArea"))},"统计面积"),q.createElementVNode("button",{class:"button button2",onClick:P[81]||(P[81]=R=>q.unref(l).docommand("Mx_Elevation"))},"智能标高"),q.createElementVNode("button",{class:"button button2",onClick:P[82]||(P[82]=R=>q.unref(l).docommand("Mx_Area"))},"面积")]),q.createElementVNode("div",k2,[q.createElementVNode("button",{class:"button button2",onClick:P[83]||(P[83]=R=>q.unref(l).docommand("Mx_ReactArea"))},"矩形面积"),q.createElementVNode("button",{class:"button button2",onClick:P[84]||(P[84]=R=>q.unref(l).docommand("Mx_DistFromPointToLine"))},"点到直线的距离"),q.createElementVNode("button",{class:"button button2",onClick:P[85]||(P[85]=R=>q.unref(l).docommand("Mx_ArcLength"))},"弧长"),q.createElementVNode("button",{class:"button button2",onClick:P[86]||(P[86]=R=>q.unref(l).docommand("Mx_MeasuringCircle"))},"测量圆")]),q.createElementVNode("div",z2,[q.createElementVNode("button",{class:"button button2",onClick:P[87]||(P[87]=R=>q.unref(l).docommand("Mx_ContinueMeasurement"))},"连续测量"),q.createElementVNode("button",{class:"button button2",onClick:P[88]||(P[88]=R=>q.unref(l).docommand("Mx_CountList"))},"查看分段长度"),q.createElementVNode("button",{class:"button button2",onClick:P[89]||(P[89]=R=>q.unref(l).docommand("Mx_AreaArc"))},"面积含弧线")])],512),[[q.vShow,v.value==="count"]]),q.withDirectives(q.createElementVNode("div",F2,[q.createElementVNode("div",B2,[q.createElementVNode("button",{class:"button button2",onClick:P[90]||(P[90]=R=>q.unref(l).docommand("Mx_Approval"))},"审图标注"),q.createElementVNode("button",{class:"button button2",onClick:P[91]||(P[91]=R=>q.unref(l).docommand("Mx_AnnotatedRectangle"))},"矩形标注"),q.createElementVNode("button",{class:"button button2",onClick:P[92]||(P[92]=R=>q.unref(l).docommand("Mx_Roughness"))},"粗糙度标注"),q.createElementVNode("button",{class:"button button2",onClick:P[93]||(P[93]=R=>q.unref(l).docommand("Mx_CoordAnnotation"))},"坐标标注")]),q.createElementVNode("div",O2,[q.createElementVNode("button",{class:"button button2",onClick:P[94]||(P[94]=R=>q.unref(l).docommand("Mx_StandardSlope"))},"标斜率"),q.createElementVNode("button",{class:"button button2",onClick:P[95]||(P[95]=R=>q.unref(l).docommand("Mx_Alignment"))},"对齐"),q.createElementVNode("button",{class:"button button2",onClick:P[96]||(P[96]=R=>q.unref(l).docommand("Mx_Enlarge"))},"局部放大")])],512),[[q.vShow,v.value==="dimension"]])])])):q.createCommentVNode("",!0),q.unref(c)?(q.openBlock(),q.createElementBlock("div",{key:1,class:"textBox",ref_key:"model",ref:b,onMousedown:A},[q.createElementVNode("div",N2,[P[103]||(P[103]=q.createElementVNode("span",null,"选择的文字",-1)),q.createElementVNode("a",{href:"#!",onClick:P[97]||(P[97]=R=>c.value=!1),role:"button",class:"close","aria-label":"close this modal"},P[102]||(P[102]=[q.createElementVNode("svg",{viewBox:"0 0 24 24"},[q.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)]))]),q.createElementVNode("textarea",{rows:"20",cols:"50",onFocus:P[98]||(P[98]=()=>q.unref(w)(!1)),onBlur:P[99]||(P[99]=()=>q.unref(w)(!0))}," "+q.toDisplayString(q.unref(h)),33),q.createElementVNode("div",U2,[q.createElementVNode("button",{onClick:P[100]||(P[100]=(...R)=>q.unref(f)&&q.unref(f)(...R))},"复制到剪贴板")])],544)):q.createCommentVNode("",!0)]))}}),ZF="",G2=ty(V2,[["__scopeId","data-v-6c1067c7"],["__file","Tools.vue"]]),W2=ty(q.defineComponent({__name:"Test",setup(e){return(t,i)=>(q.openBlock(),q.createElementBlock("div",null,[q.createVNode(e2),q.createVNode(G2)]))}}),[["__file","Test.vue"]]),j2={init(){X.MxFun.setPostMessageToParentFrameFunction(function(e){top.postMessage(e,"*")}),window.addEventListener("message",function(e){e.data.type==="sendStringToExecute"?X.MxFun.sendStringToExecute(e.data.cmd,e.data):(console.log("mx:unprocessed message:"),console.log(e.data))},!1)}};function H2(){j2.init()}function $2(){return Qe(this,null,function*(){const e=new X.MrxDbgUiPrPoint;e.setMessage(` 指定第一点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new X.MxDbLeadComment;l.point1=i.clone(),l.textHeight=X.MxFun.screenCoordLong2Doc(50),l.text="测试Test1",l.textWidth=X.MxFun.screenCoordLong2Doc(300),l.fixedSize=!0,l.fixedSize&&(l.textHeight=50,l.textWidth=250),l.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const c=new X.McEdGetPointWorldDrawObject;c.setDraw((h,f)=>{l.point2=h,f.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(c),e.setMessage(` 指定第二点:`),e.go(h=>{if(h!=0){console.log(h);return}const f=e.value();l.point2=f,X.MxFun.addToCurrentSpace(l)})})})}function q2(){X.MxFun.getCurrentDraw().createCanvasImageData(e=>{const t=window.open();t!=null&&(t.document.write(''),setTimeout(()=>{t.print()},300))},{width:349,height:536})}function X2(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const t=new X.MrxDbgUiPrPoint,i=X.MxFun.getCurrentDraw(),l=new X.McEdGetPointWorldDrawObject,c=new X.MxDbRectBoxLeadComment;c.color=e.getHex(),c.color==0&&(c.color=65793),c.radius=X.MxFun.screenCoordLong2Doc(8),c.setLineWidth(3),c.setLineWidthByPixels(!0),t.setMessage(` 云线框起始点:`),t.go(h=>{h==X.MrxDbgUiPrBaseReturn.kOk&&(c.point1=t.value(),l.setDraw(f=>{c.point2=f,l.drawCustomEntity(c)}),t.setUserDraw(l),t.setMessage(` 云线框结束点:`),t.go(f=>{f==X.MrxDbgUiPrBaseReturn.kOk&&(c.point2=t.value(),l.setDraw(r=>{c.point3=r,l.drawCustomEntity(c)}),c.text="审图批注XXXXXXXXXX",c.textWidth=X.MxFun.screenCoordLong2Doc(200),c.textHeight=X.MxFun.screenCoordLong2Doc(50),c.fixedSize=!0,c.fixedSize&&(c.textHeight=20,c.textWidth=230),t.setMessage(` 审图标注点:`),t.go(r=>{r==X.MrxDbgUiPrBaseReturn.kOk&&(c.point3=t.value(),i.addMxEntity(c))}))}))})})}function ny(e,t){let i=X.MxFun.screenCoordLong2World(t?e:e-e/3);return i=X.MxFun.worldCoordLong2Doc(i),i}function Z2(){const e=new X.McEdGetPointWorldDrawObject,t=new X.MxDbArrow,i=X.MxFun.getCurrentDraw(),l=new X.MrxDbgUiPrPoint;l.setUserDraw(e),t.setLineWidth(10),t.innerOffset=ny(10),t.outerOffset=ny(22),t.topOffset=ny(36),t.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),l.go(()=>{t.startPoint=l.value(),e.setDraw(c=>{t.endPoint=c,e.drawCustomEntity(t)}),l.go(c=>Qe(this,null,function*(){t.endPoint=l.value(),i.addMxEntity(t)}))})}function Y2(){const e=new X.MrxDbgUiPrPoint,t=X.MxFun.getCurrentDraw(),i=new X.McEdGetPointWorldDrawObject,l=X.MxFun.screenCoordLong2Doc(16);e.setMessage(` 点击开启绘制云线:`),e.go(()=>{let c=e.value();const h=new X.MxDbCloudLine;h.setRadius(l),h.addPoint(c),h.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),i.setDraw(f=>{c.distanceTo(f)>l&&(c=f.clone(),h.addPoint(f,!0)),i.drawCustomEntity(h)}),e.setUserDraw(i),e.setMessage(` 再次点击结束绘制云线:`),e.go(()=>{t.addMxEntity(h)})})}let qp="";function K2(){qp=X.MxFun.getCurrentDraw().saveMxEntityToJson(),console.log(qp)}function J2(){return Qe(this,null,function*(){if(qp.length==0)return;let e=X.MxFun.getCurrentDraw();yield e.loadMxEntityFromJson(qp,["models/svg/mark.svg"]),e.updateDisplay()})}function Q2(){const e=new X.MrxDbgUiPrPoint;e.setMessage(` 指定第一点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new X.MxDbArea;l.addPoint(i),l.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const c=new X.McEdGetPointWorldDrawObject;c.setDraw((h,f)=>{let r=l.clone();r.addPoint(h),c.drawCustomEntity(r)}),e.setUserDraw(c),e.setMessage(` 指定下一点:`),e.goWhile(h=>{if(h==0){const f=e.value();l.addPoint(f)}},h=>{l.isFill=!0,l.fillOpacity=.7,l.fillColor=6697540,X.MxFun.getCurrentDraw().addMxEntity(l)})})}function eT(){X.MxFun.addCommand("BR_Comment",$2),X.MxFun.addCommand("BR_CheckDraw",X2),X.MxFun.addCommand("BR_Arrow",Z2),X.MxFun.addCommand("BR_CloudLine",Y2),X.MxFun.addCommand("BR_Print",q2),X.MxFun.addCommand("BR_SaveAllMxEntity",K2),X.MxFun.addCommand("BR_LoadAllMxEntity",J2),X.MxFun.addCommand("BR_Area",Q2)}function tT(){let e=M.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 M.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 M.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 nT(){let e=M.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 M.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 iT(){let e=M.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 M.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 rT(){let e=M.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 M.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 M.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 M.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 M.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 M.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 M.McCmColor(255,255,25),e.drawLinetype="MyLineType3",e.drawPathToPolyline(),e.zoomAll(),e.regen(),e.updateDisplay()}function oT(){let e=M.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 M.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 M.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 M.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 aT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawColorIndex=0,e.addLayer("TextLayer"),e.drawLayer="TextLayer",e.drawText(0,1900,"绘图控件文字测试",100,0,0,1),e.drawColor=new M.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 M.McCmColor(255,0,0),e.drawText(0,3e3,"绘图控件文字测试",100,0,0,1),e.AddTureTypeTextStyle("MyTrueTypeTextStyle"),e.drawTextStyle="MyTrueTypeTextStyle",e.drawColor=new M.McCmColor(200,255,50),e.drawText(0,3500,"绘图控件TrueType文字测试",100,0,0,1),e.zoomAll(),e.regen(),e.updateDisplay()}function sT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),M.MxCpp.App.loadFonts([],[],["syadobe","simsun"],()=>{e.AddTureTypeTextStyle("ht_style","syadobe"),e.AddTureTypeTextStyle("st_style","simsun"),e.drawTextStyle="ht_style",e.drawColor=new M.McCmColor(200,255,50);let i=e.drawText(0,3500,"绘图控件TrueType文字测试",100,0,0,1).getMcDbEntity();i&&(i.textStyle="st_style"),e.zoomAll(),e.regen(),e.updateDisplay()})}function lT(){let e=M.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 M.McCmColor(200,0,0),e.drawEllipse(200,1400,80,30,.5),e.zoomAll(),e.regen(),e.updateDisplay()}function cT(){let e=M.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 M.McCmColor(200,200,0),e.drawEllipseArc(200,1600,-80,30,.5,60,300),e.drawLinetype="",e.zoomAll(),e.regen(),e.updateDisplay()}function uT(){let e=M.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 hT(e){if(!e||!e.param)return;let t=M.MxCpp.getCurrentMxCAD();t.newFile(),t.drawColorIndex=0,t.drawLinetype="",t.drawLineWidth=0,t.addLayer("LineLayer"),t.drawLayer="LineLayer",t.drawLine(e.param.x1,e.param.y1,e.param.x2,e.param.y2),t.zoomAll(),t.updateDisplay(),X.MxFun.postMessageToParentFrame({cmd:"Mx_ParamDrawLine",message:"ok"})}function dT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile(),e.drawText(350831.77,1940511845e-2,"1.034",10,0,M.McDb.TextHorzMode.kTextLeft,M.McDb.TextVertMode.kTextVertMid),e.zoomAll(),e.regen(100)}function pT(){let e=M.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 fT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=e.addTextStyle("我的标注字体","complex.shx","gbcbig.shx",1);e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",`340,${t.id}`),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 mT(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=e.addTextStyle("我的标注字体","complex.shx","gbcbig.shx",1);e.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3",'3,"DN%%c<>"',`340,${t.id}`),e.drawDimStyle="MyDimStyle",e.drawColorIndex=0,e.drawLinetype="",e.drawLineWidth=0;let i=e.drawDimRotated(0,7e3,600,7e3,250,7050,0).getMcDbDimension();i&&(i.setDimVarInt(71,1),i.setDimVarInt(272,1),i.setDimVarDouble(146,.5),i.setDimVarDouble(48,5.5),i.setDimVarDouble(47,2.5),i.recomputeDimBlock()),e.zoomAll(),e.updateDisplay()}function gT(){let e=M.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 yT(){X.MxFun.addCommand("Mx_Test_DrawLine",tT),X.MxFun.addCommand("Mx_Test_DrawArc",nT),X.MxFun.addCommand("Mx_Test_DrawCircle",iT),X.MxFun.addCommand("Mx_Test_DrawPolyline",rT),X.MxFun.addCommand("Mx_Test_DrawHatch",oT),X.MxFun.addCommand("Mx_Test_DrawText",aT),X.MxFun.addCommand("Mx_Test_Ellipse",lT),X.MxFun.addCommand("Mx_Test_EllipseArc",cT),X.MxFun.addCommand("Mx_Test_MText",uT),X.MxFun.addCommand("Mx_Test_Text",dT),X.MxFun.addCommand("Mx_ParamDrawLine",hT),X.MxFun.addCommand("Mx_Test_DimAligned",pT),X.MxFun.addCommand("Mx_Test_DrawDimRotated",fT),X.MxFun.addCommand("Mx_Test_DrawDimRotatedTol",mT),X.MxFun.addCommand("Mx_Test_DrawDimAngular",gT),X.MxFun.addCommand("Mx_Test_TrueText",sT)}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 t=Object(e),i=1;i>8&255]+sr[e>>16&255]+sr[e>>24&255]+"-"+sr[t&255]+sr[t>>8&255]+"-"+sr[t>>16&15|64]+sr[t>>24&255]+"-"+sr[i&63|128]+sr[i>>8&255]+"-"+sr[i>>16&255]+sr[i>>24&255]+sr[l&255]+sr[l>>8&255]+sr[l>>16&255]+sr[l>>24&255];return c.toUpperCase()},clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,l,c){return l+(e-t)*(c-l)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*jn.DEG2RAD},radToDeg:function(e){return e*jn.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,t,i,l,c){var h=Math.cos,f=Math.sin,r=h(i/2),v=f(i/2),x=h((t+l)/2),w=f((t+l)/2),b=h((t-l)/2),A=f((t-l)/2),L=h((l-t)/2),P=f((l-t)/2);c==="XYX"?e.set(r*w,v*b,v*A,r*x):c==="YZY"?e.set(v*A,r*w,v*b,r*x):c==="ZXZ"?e.set(v*b,v*A,r*w,r*x):c==="XZX"?e.set(r*w,v*P,v*L,r*x):c==="YXY"?e.set(v*L,r*w,v*P,r*x):c==="ZYZ"?e.set(v*P,v*L,r*w,r*x):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}};function Lt(e,t){this.x=e||0,this.y=t||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,t){return this.x=e,this.y=t,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;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,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.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 t=this.x,i=this.y,l=e.elements;return this.x=l[0]*t+l[3]*i+l[6],this.y=l[1]*t+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,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,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 t=this.x-e.x,i=this.y-e.y;return t*t+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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return i!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t),l=Math.sin(t),c=this.x-e.x,h=this.y-e.y;return this.x=c*i-h*l+e.x,this.y=c*l+h*i+e.y,this}});function pr(){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(pr.prototype,{isMatrix3:!0,set:function(e,t,i,l,c,h,f,r,v){var x=this.elements;return x[0]=e,x[1]=l,x[2]=f,x[3]=t,x[4]=c,x[5]=r,x[6]=i,x[7]=h,x[8]=v,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 t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,l=t.elements,c=this.elements,h=i[0],f=i[3],r=i[6],v=i[1],x=i[4],w=i[7],b=i[2],A=i[5],L=i[8],P=l[0],R=l[3],F=l[6],V=l[1],j=l[4],J=l[7],ne=l[2],H=l[5],Q=l[8];return c[0]=h*P+f*V+r*ne,c[3]=h*R+f*j+r*H,c[6]=h*F+f*J+r*Q,c[1]=v*P+x*V+w*ne,c[4]=v*R+x*j+w*H,c[7]=v*F+x*J+w*Q,c[2]=b*P+A*V+L*ne,c[5]=b*R+A*j+L*H,c[8]=b*F+A*J+L*Q,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[1],l=e[2],c=e[3],h=e[4],f=e[5],r=e[6],v=e[7],x=e[8];return t*h*x-t*f*v-i*c*x+i*f*r+l*c*v-l*h*r},getInverse:function(e,t){e&&e.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=e.elements,l=this.elements,c=i[0],h=i[1],f=i[2],r=i[3],v=i[4],x=i[5],w=i[6],b=i[7],A=i[8],L=A*v-x*b,P=x*w-A*r,R=b*r-v*w,F=c*L+h*P+f*R;if(F===0){var V="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(t===!0)throw new Error(V);return console.warn(V),this.identity()}var j=1/F;return l[0]=L*j,l[1]=(f*b-A*h)*j,l[2]=(x*h-f*v)*j,l[3]=P*j,l[4]=(A*c-f*w)*j,l[5]=(f*r-x*c)*j,l[6]=R*j,l[7]=(h*w-b*c)*j,l[8]=(v*c-h*r)*j,this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,i,l,c,h,f){var r=Math.cos(c),v=Math.sin(c);this.set(i*r,i*v,-i*(r*h+v*f)+h+e,-l*v,l*r,-l*(-v*h+r*f)+f+t,0,0,1)},scale:function(e,t){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this},rotate:function(e){var t=Math.cos(e),i=Math.sin(e),l=this.elements,c=l[0],h=l[3],f=l[6],r=l[1],v=l[4],x=l[7];return l[0]=t*c+i*r,l[3]=t*h+i*v,l[6]=t*f+i*x,l[1]=-i*c+t*r,l[4]=-i*h+t*v,l[7]=-i*f+t*x,this},translate:function(e,t){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this},equals:function(e){for(var t=this.elements,i=e.elements,l=0;l<9;l++)if(t[l]!==i[l])return!1;return!0},fromArray:function(e,t){t===void 0&&(t=0);for(var i=0;i<9;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}});var uc,Ks={getDataURL:function(e){var t;if(typeof HTMLCanvasElement=="undefined")return e.src;if(e instanceof HTMLCanvasElement)t=e;else{uc===void 0&&(uc=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),uc.width=e.width,uc.height=e.height;var i=uc.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=uc}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},zE=0;function mi(e,t,i,l,c,h,f,r,v,x){Object.defineProperty(this,"id",{value:zE++}),this.uuid=jn.generateUUID(),this.name="",this.image=e!==void 0?e:mi.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=t!==void 0?t:mi.DEFAULT_MAPPING,this.wrapS=i!==void 0?i:Mr,this.wrapT=l!==void 0?l:Mr,this.magFilter=c!==void 0?c:$i,this.minFilter=h!==void 0?h:oc,this.anisotropy=v!==void 0?v:1,this.format=f!==void 0?f:Ao,this.internalFormat=null,this.type=r!==void 0?r:Jp,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 pr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=x!==void 0?x:io,this.version=0,this.onUpdate=null}mi.DEFAULT_IMAGE=void 0,mi.DEFAULT_MAPPING=oy,mi.prototype=Object.assign(Object.create(Ta.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 t=e===void 0||typeof e=="string";if(!t&&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=jn.generateUUID()),!t&&e.images[l.uuid]===void 0){var c;if(Array.isArray(l)){c=[];for(var h=0,f=l.length;h1)switch(this.wrapS){case Zs:e.x=e.x-Math.floor(e.x);break;case Mr:e.x=e.x<0?0:1;break;case fh: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 Mr:e.y=e.y<0?0:1;break;case fh: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,t,i,l){this.x=e||0,this.y=t||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,t,i,l){return this.x=e,this.y=t,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;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,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,l=this.z,c=this.w,h=e.elements;return this.x=h[0]*t+h[4]*i+h[8]*l+h[12]*c,this.y=h[1]*t+h[5]*i+h[9]*l+h[13]*c,this.z=h[2]*t+h[6]*i+h[10]*l+h[14]*c,this.w=h[3]*t+h[7]*i+h[11]*l+h[15]*c,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,l,c,h=.01,f=.1,r=e.elements,v=r[0],x=r[4],w=r[8],b=r[1],A=r[5],L=r[9],P=r[2],R=r[6],F=r[10];if(Math.abs(x-b)j&&V>J?VJ?j=0?1:-1,j=1-F*F;if(j>Number.EPSILON){var J=Math.sqrt(j),ne=Math.atan2(J,F*V);R=Math.sin(R*ne)/J,f=Math.sin(f*ne)/J}var H=f*V;if(r=r*R+b*H,v=v*R+A*H,x=x*R+L*H,w=w*R+P*H,R===1-f){var Q=1/Math.sqrt(r*r+v*v+x*x+w*w);r*=Q,v*=Q,x*=Q,w*=Q}}e[t]=r,e[t+1]=v,e[t+2]=x,e[t+3]=w}}),Object.defineProperties(Nr.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(Nr.prototype,{isQuaternion:!0,set:function(e,t,i,l){return this._x=e,this._y=t,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,t){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,c=e._z,h=e.order,f=Math.cos,r=Math.sin,v=f(i/2),x=f(l/2),w=f(c/2),b=r(i/2),A=r(l/2),L=r(c/2);return h==="XYZ"?(this._x=b*x*w+v*A*L,this._y=v*A*w-b*x*L,this._z=v*x*L+b*A*w,this._w=v*x*w-b*A*L):h==="YXZ"?(this._x=b*x*w+v*A*L,this._y=v*A*w-b*x*L,this._z=v*x*L-b*A*w,this._w=v*x*w+b*A*L):h==="ZXY"?(this._x=b*x*w-v*A*L,this._y=v*A*w+b*x*L,this._z=v*x*L+b*A*w,this._w=v*x*w-b*A*L):h==="ZYX"?(this._x=b*x*w-v*A*L,this._y=v*A*w+b*x*L,this._z=v*x*L-b*A*w,this._w=v*x*w+b*A*L):h==="YZX"?(this._x=b*x*w+v*A*L,this._y=v*A*w+b*x*L,this._z=v*x*L-b*A*w,this._w=v*x*w-b*A*L):h==="XZY"&&(this._x=b*x*w-v*A*L,this._y=v*A*w-b*x*L,this._z=v*x*L+b*A*w,this._w=v*x*w+b*A*L),t!==!1&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/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 t=e.elements,i=t[0],l=t[4],c=t[8],h=t[1],f=t[5],r=t[9],v=t[2],x=t[6],w=t[10],b=i+f+w,A;return b>0?(A=.5/Math.sqrt(b+1),this._w=.25/A,this._x=(x-r)*A,this._y=(c-v)*A,this._z=(h-l)*A):i>f&&i>w?(A=2*Math.sqrt(1+i-f-w),this._w=(x-r)/A,this._x=.25*A,this._y=(l+h)/A,this._z=(c+v)/A):f>w?(A=2*Math.sqrt(1+f-i-w),this._w=(c-v)/A,this._x=(l+h)/A,this._y=.25*A,this._z=(r+x)/A):(A=2*Math.sqrt(1+w-i-f),this._w=(h-l)/A,this._x=(c+v)/A,this._y=(r+x)/A,this._z=.25*A),this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var i=1e-6,l=e.dot(t)+1;return lMath.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*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=l),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(jn.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var i=this.angleTo(e);if(i===0)return this;var l=Math.min(1,t/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,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,l=e._y,c=e._z,h=e._w,f=t._x,r=t._y,v=t._z,x=t._w;return this._x=i*x+h*f+l*v-c*r,this._y=l*x+h*r+c*f-i*v,this._z=c*x+h*v+i*r-l*f,this._w=h*x-i*f-l*r-c*v,this._onChangeCallback(),this},slerp:function(e,t){if(t===0)return this;if(t===1)return this.copy(e);var i=this._x,l=this._y,c=this._z,h=this._w,f=h*e._w+i*e._x+l*e._y+c*e._z;if(f<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,f=-f):this.copy(e),f>=1)return this._w=h,this._x=i,this._y=l,this._z=c,this;var r=1-f*f;if(r<=Number.EPSILON){var v=1-t;return this._w=v*h+t*this._w,this._x=v*i+t*this._x,this._y=v*l+t*this._y,this._z=v*c+t*this._z,this.normalize(),this._onChangeCallback(),this}var x=Math.sqrt(r),w=Math.atan2(x,f),b=Math.sin((1-t)*w)/x,A=Math.sin(t*w)/x;return this._w=h*b+this._w*A,this._x=i*b+this._x*A,this._y=l*b+this._y*A,this._z=c*b+this._z*A,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,t){return t===void 0&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var my=new Pe,Hx=new Nr;function Pe(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}Object.assign(Pe.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;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,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(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,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.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(Hx.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(Hx.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,i=this.y,l=this.z,c=e.elements;return this.x=c[0]*t+c[3]*i+c[6]*l,this.y=c[1]*t+c[4]*i+c[7]*l,this.z=c[2]*t+c[5]*i+c[8]*l,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,i=this.y,l=this.z,c=e.elements,h=1/(c[3]*t+c[7]*i+c[11]*l+c[15]);return this.x=(c[0]*t+c[4]*i+c[8]*l+c[12])*h,this.y=(c[1]*t+c[5]*i+c[9]*l+c[13])*h,this.z=(c[2]*t+c[6]*i+c[10]*l+c[14])*h,this},applyQuaternion:function(e){var t=this.x,i=this.y,l=this.z,c=e.x,h=e.y,f=e.z,r=e.w,v=r*t+h*l-f*i,x=r*i+f*t-c*l,w=r*l+c*i-h*t,b=-c*t-h*i-f*l;return this.x=v*r+b*-c+x*-f-w*-h,this.y=x*r+b*-h+w*-c-v*-f,this.z=w*r+b*-f+v*-h-x*-c,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 t=this.x,i=this.y,l=this.z,c=e.elements;return this.x=c[0]*t+c[4]*i+c[8]*l,this.y=c[1]*t+c[5]*i+c[9]*l,this.z=c[2]*t+c[6]*i+c[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,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},cross:function(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,l=e.y,c=e.z,h=t.x,f=t.y,r=t.z;return this.x=l*r-c*f,this.y=c*h-i*r,this.z=i*f-l*h,this},projectOnVector:function(e){var t=e.lengthSq();if(t===0)return this.set(0,0,0);var i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)},projectOnPlane:function(e){return my.copy(this).projectOnVector(e),this.sub(my)},reflect:function(e){return this.sub(my.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;var i=this.dot(e)/t;return Math.acos(jn.clamp(i,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,l=this.z-e.z;return t*t+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,t,i){var l=Math.sin(t)*e;return this.x=l*Math.sin(i),this.y=Math.cos(t)*e,this.z=l*Math.cos(i),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=l,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,t*4)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,t*3)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return i!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}});var hc=new Pe,Do=new Hn,FE=new Pe(0,0,0),BE=new Pe(1,1,1),ts=new Pe,rf=new Pe,ro=new Pe;function Hn(){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(Hn.prototype,{isMatrix4:!0,set:function(e,t,i,l,c,h,f,r,v,x,w,b,A,L,P,R){var F=this.elements;return F[0]=e,F[4]=t,F[8]=i,F[12]=l,F[1]=c,F[5]=h,F[9]=f,F[13]=r,F[2]=v,F[6]=x,F[10]=w,F[14]=b,F[3]=A,F[7]=L,F[11]=P,F[15]=R,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 Hn().fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,i=e.elements,l=1/hc.setFromMatrixColumn(e,0).length(),c=1/hc.setFromMatrixColumn(e,1).length(),h=1/hc.setFromMatrixColumn(e,2).length();return t[0]=i[0]*l,t[1]=i[1]*l,t[2]=i[2]*l,t[3]=0,t[4]=i[4]*c,t[5]=i[5]*c,t[6]=i[6]*c,t[7]=0,t[8]=i[8]*h,t[9]=i[9]*h,t[10]=i[10]*h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[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 t=this.elements,i=e.x,l=e.y,c=e.z,h=Math.cos(i),f=Math.sin(i),r=Math.cos(l),v=Math.sin(l),x=Math.cos(c),w=Math.sin(c);if(e.order==="XYZ"){var b=h*x,A=h*w,L=f*x,P=f*w;t[0]=r*x,t[4]=-r*w,t[8]=v,t[1]=A+L*v,t[5]=b-P*v,t[9]=-f*r,t[2]=P-b*v,t[6]=L+A*v,t[10]=h*r}else if(e.order==="YXZ"){var R=r*x,F=r*w,V=v*x,j=v*w;t[0]=R+j*f,t[4]=V*f-F,t[8]=h*v,t[1]=h*w,t[5]=h*x,t[9]=-f,t[2]=F*f-V,t[6]=j+R*f,t[10]=h*r}else if(e.order==="ZXY"){var R=r*x,F=r*w,V=v*x,j=v*w;t[0]=R-j*f,t[4]=-h*w,t[8]=V+F*f,t[1]=F+V*f,t[5]=h*x,t[9]=j-R*f,t[2]=-h*v,t[6]=f,t[10]=h*r}else if(e.order==="ZYX"){var b=h*x,A=h*w,L=f*x,P=f*w;t[0]=r*x,t[4]=L*v-A,t[8]=b*v+P,t[1]=r*w,t[5]=P*v+b,t[9]=A*v-L,t[2]=-v,t[6]=f*r,t[10]=h*r}else if(e.order==="YZX"){var J=h*r,ne=h*v,H=f*r,Q=f*v;t[0]=r*x,t[4]=Q-J*w,t[8]=H*w+ne,t[1]=w,t[5]=h*x,t[9]=-f*x,t[2]=-v*x,t[6]=ne*w+H,t[10]=J-Q*w}else if(e.order==="XZY"){var J=h*r,ne=h*v,H=f*r,Q=f*v;t[0]=r*x,t[4]=-w,t[8]=v*x,t[1]=J*w+Q,t[5]=h*x,t[9]=ne*w-H,t[2]=H*w-ne,t[6]=f*x,t[10]=Q*w+J}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(FE,e,BE)},lookAt:function(e,t,i){var l=this.elements;return ro.subVectors(e,t),ro.lengthSq()===0&&(ro.z=1),ro.normalize(),ts.crossVectors(i,ro),ts.lengthSq()===0&&(Math.abs(i.z)===1?ro.x+=1e-4:ro.z+=1e-4,ro.normalize(),ts.crossVectors(i,ro)),ts.normalize(),rf.crossVectors(ro,ts),l[0]=ts.x,l[4]=rf.x,l[8]=ro.x,l[1]=ts.y,l[5]=rf.y,l[9]=ro.y,l[2]=ts.z,l[6]=rf.z,l[10]=ro.z,this},multiply:function(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,l=t.elements,c=this.elements,h=i[0],f=i[4],r=i[8],v=i[12],x=i[1],w=i[5],b=i[9],A=i[13],L=i[2],P=i[6],R=i[10],F=i[14],V=i[3],j=i[7],J=i[11],ne=i[15],H=l[0],Q=l[4],ae=l[8],ie=l[12],le=l[1],fe=l[5],me=l[9],he=l[13],Oe=l[2],Ve=l[6],He=l[10],at=l[14],At=l[3],yt=l[7],Dt=l[11],It=l[15];return c[0]=h*H+f*le+r*Oe+v*At,c[4]=h*Q+f*fe+r*Ve+v*yt,c[8]=h*ae+f*me+r*He+v*Dt,c[12]=h*ie+f*he+r*at+v*It,c[1]=x*H+w*le+b*Oe+A*At,c[5]=x*Q+w*fe+b*Ve+A*yt,c[9]=x*ae+w*me+b*He+A*Dt,c[13]=x*ie+w*he+b*at+A*It,c[2]=L*H+P*le+R*Oe+F*At,c[6]=L*Q+P*fe+R*Ve+F*yt,c[10]=L*ae+P*me+R*He+F*Dt,c[14]=L*ie+P*he+R*at+F*It,c[3]=V*H+j*le+J*Oe+ne*At,c[7]=V*Q+j*fe+J*Ve+ne*yt,c[11]=V*ae+j*me+J*He+ne*Dt,c[15]=V*ie+j*he+J*at+ne*It,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[4],l=e[8],c=e[12],h=e[1],f=e[5],r=e[9],v=e[13],x=e[2],w=e[6],b=e[10],A=e[14],L=e[3],P=e[7],R=e[11],F=e[15];return L*(+c*r*w-l*v*w-c*f*b+i*v*b+l*f*A-i*r*A)+P*(+t*r*A-t*v*b+c*h*b-l*h*A+l*v*x-c*r*x)+R*(+t*v*w-t*f*A-c*h*w+i*h*A+c*f*x-i*v*x)+F*(-l*f*x-t*r*w+t*f*b+l*h*w-i*h*b+i*r*x)},transpose:function(){var e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(e,t,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]=t,l[14]=i),this},getInverse:function(e,t){var i=this.elements,l=e.elements,c=l[0],h=l[1],f=l[2],r=l[3],v=l[4],x=l[5],w=l[6],b=l[7],A=l[8],L=l[9],P=l[10],R=l[11],F=l[12],V=l[13],j=l[14],J=l[15],ne=L*j*b-V*P*b+V*w*R-x*j*R-L*w*J+x*P*J,H=F*P*b-A*j*b-F*w*R+v*j*R+A*w*J-v*P*J,Q=A*V*b-F*L*b+F*x*R-v*V*R-A*x*J+v*L*J,ae=F*L*w-A*V*w-F*x*P+v*V*P+A*x*j-v*L*j,ie=c*ne+h*H+f*Q+r*ae;if(ie===0){var le="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(t===!0)throw new Error(le);return console.warn(le),this.identity()}var fe=1/ie;return i[0]=ne*fe,i[1]=(V*P*r-L*j*r-V*f*R+h*j*R+L*f*J-h*P*J)*fe,i[2]=(x*j*r-V*w*r+V*f*b-h*j*b-x*f*J+h*w*J)*fe,i[3]=(L*w*r-x*P*r-L*f*b+h*P*b+x*f*R-h*w*R)*fe,i[4]=H*fe,i[5]=(A*j*r-F*P*r+F*f*R-c*j*R-A*f*J+c*P*J)*fe,i[6]=(F*w*r-v*j*r-F*f*b+c*j*b+v*f*J-c*w*J)*fe,i[7]=(v*P*r-A*w*r+A*f*b-c*P*b-v*f*R+c*w*R)*fe,i[8]=Q*fe,i[9]=(F*L*r-A*V*r-F*h*R+c*V*R+A*h*J-c*L*J)*fe,i[10]=(v*V*r-F*x*r+F*h*b-c*V*b-v*h*J+c*x*J)*fe,i[11]=(A*x*r-v*L*r-A*h*b+c*L*b+v*h*R-c*x*R)*fe,i[12]=ae*fe,i[13]=(A*V*f-F*L*f+F*h*P-c*V*P-A*h*j+c*L*j)*fe,i[14]=(F*x*f-v*V*f-F*h*w+c*V*w+v*h*j-c*x*j)*fe,i[15]=(v*L*f-A*x*f+A*h*w-c*L*w-v*h*P+c*x*P)*fe,this},scale:function(e){var t=this.elements,i=e.x,l=e.y,c=e.z;return t[0]*=i,t[4]*=l,t[8]*=c,t[1]*=i,t[5]*=l,t[9]*=c,t[2]*=i,t[6]*=l,t[10]*=c,t[3]*=i,t[7]*=l,t[11]*=c,this},getMaxScaleOnAxis:function(){var e=this.elements,t=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(t,i,l))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var i=Math.cos(t),l=Math.sin(t),c=1-i,h=e.x,f=e.y,r=e.z,v=c*h,x=c*f;return this.set(v*h+i,v*f-l*r,v*r+l*f,0,v*f+l*r,x*f+i,x*r-l*h,0,v*r-l*f,x*r+l*h,c*r*r+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,t,i){return this.set(1,t,i,0,e,1,i,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,i){var l=this.elements,c=t._x,h=t._y,f=t._z,r=t._w,v=c+c,x=h+h,w=f+f,b=c*v,A=c*x,L=c*w,P=h*x,R=h*w,F=f*w,V=r*v,j=r*x,J=r*w,ne=i.x,H=i.y,Q=i.z;return l[0]=(1-(P+F))*ne,l[1]=(A+J)*ne,l[2]=(L-j)*ne,l[3]=0,l[4]=(A-J)*H,l[5]=(1-(b+F))*H,l[6]=(R+V)*H,l[7]=0,l[8]=(L+j)*Q,l[9]=(R-V)*Q,l[10]=(1-(b+P))*Q,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this},decompose:function(e,t,i){var l=this.elements,c=hc.set(l[0],l[1],l[2]).length(),h=hc.set(l[4],l[5],l[6]).length(),f=hc.set(l[8],l[9],l[10]).length(),r=this.determinant();r<0&&(c=-c),e.x=l[12],e.y=l[13],e.z=l[14],Do.copy(this);var v=1/c,x=1/h,w=1/f;return Do.elements[0]*=v,Do.elements[1]*=v,Do.elements[2]*=v,Do.elements[4]*=x,Do.elements[5]*=x,Do.elements[6]*=x,Do.elements[8]*=w,Do.elements[9]*=w,Do.elements[10]*=w,t.setFromRotationMatrix(Do),i.x=c,i.y=h,i.z=f,this},makePerspective:function(e,t,i,l,c,h){h===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var f=this.elements,r=2*c/(t-e),v=2*c/(i-l),x=(t+e)/(t-e),w=(i+l)/(i-l),b=-(h+c)/(h-c),A=-2*h*c/(h-c);return f[0]=r,f[4]=0,f[8]=x,f[12]=0,f[1]=0,f[5]=v,f[9]=w,f[13]=0,f[2]=0,f[6]=0,f[10]=b,f[14]=A,f[3]=0,f[7]=0,f[11]=-1,f[15]=0,this},makeOrthographic:function(e,t,i,l,c,h){var f=this.elements,r=1/(t-e),v=1/(i-l),x=1/(h-c),w=(t+e)*r,b=(i+l)*v,A=(h+c)*x;return f[0]=2*r,f[4]=0,f[8]=0,f[12]=-w,f[1]=0,f[5]=2*v,f[9]=0,f[13]=-b,f[2]=0,f[6]=0,f[10]=-2*x,f[14]=-A,f[3]=0,f[7]=0,f[11]=0,f[15]=1,this},equals:function(e){for(var t=this.elements,i=e.elements,l=0;l<16;l++)if(t[l]!==i[l])return!1;return!0},fromArray:function(e,t){t===void 0&&(t=0);for(var i=0;i<16;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}});var $x=new Hn,qx=new Nr;function dc(e,t,i,l){this._x=e||0,this._y=t||0,this._z=i||0,this._order=l||dc.DefaultOrder}dc.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],dc.DefaultOrder="XYZ",Object.defineProperties(dc.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(dc.prototype,{isEuler:!0,set:function(e,t,i,l){return this._x=e,this._y=t,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,t,i){var l=jn.clamp,c=e.elements,h=c[0],f=c[4],r=c[8],v=c[1],x=c[5],w=c[9],b=c[2],A=c[6],L=c[10];return t=t||this._order,t==="XYZ"?(this._y=Math.asin(l(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(-w,L),this._z=Math.atan2(-f,h)):(this._x=Math.atan2(A,x),this._z=0)):t==="YXZ"?(this._x=Math.asin(-l(w,-1,1)),Math.abs(w)<.9999999?(this._y=Math.atan2(r,L),this._z=Math.atan2(v,x)):(this._y=Math.atan2(-b,h),this._z=0)):t==="ZXY"?(this._x=Math.asin(l(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(-b,L),this._z=Math.atan2(-f,x)):(this._y=0,this._z=Math.atan2(v,h))):t==="ZYX"?(this._y=Math.asin(-l(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(A,L),this._z=Math.atan2(v,h)):(this._x=0,this._z=Math.atan2(-f,x))):t==="YZX"?(this._z=Math.asin(l(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(-w,x),this._y=Math.atan2(-b,h)):(this._x=0,this._y=Math.atan2(r,L))):t==="XZY"?(this._z=Math.asin(-l(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(A,x),this._y=Math.atan2(r,h)):(this._x=Math.atan2(-w,L),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,i!==!1&&this._onChangeCallback(),this},setFromQuaternion:function(e,t,i){return $x.makeRotationFromQuaternion(e),this.setFromRotationMatrix($x,t,i)},setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(e){return qx.setFromEuler(this),this.setFromQuaternion(qx,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,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new Pe(this._x,this._y,this._z)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});function Xx(){this.mask=1}Object.assign(Xx.prototype,{set:function(e){this.mask=1<1){for(var t=0;t1){for(var t=0;t0){l.children=[];for(var r=0;r0&&(i.geometries=b),A.length>0&&(i.materials=A),L.length>0&&(i.textures=L),P.length>0&&(i.images=P),f.length>0&&(i.shapes=f)}return i.object=l,i;function R(F){var V=[];for(var j in F){var J=F[j];delete J.metadata,V.push(J)}return V}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(e,t){if(t===void 0&&(t=!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)),t===!0)for(var i=0;ic&&(c=x),w>h&&(h=w),b>f&&(f=b)}return this.min.set(t,i,l),this.max.set(c,h,f),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,l=1/0,c=-1/0,h=-1/0,f=-1/0,r=0,v=e.count;rc&&(c=x),w>h&&(h=w),b>f&&(f=b)}return this.min.set(t,i,l),this.max.set(c,h,f),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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,t){return t===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new Pe),t.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,wh),wh.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Mh),sf.subVectors(this.max,Mh),fc.subVectors(e.a,Mh),mc.subVectors(e.b,Mh),gc.subVectors(e.c,Mh),ns.subVectors(mc,fc),is.subVectors(gc,mc),Js.subVectors(fc,gc);var t=[0,-ns.z,ns.y,0,-is.z,is.y,0,-Js.z,Js.y,ns.z,0,-ns.x,is.z,0,-is.x,Js.z,0,-Js.x,-ns.y,ns.x,0,-is.y,is.x,0,-Js.y,Js.x,0];return!gy(t,fc,mc,gc,sf)||(t=[1,0,0,0,1,0,0,0,1],!gy(t,fc,mc,gc,sf))?!1:(lf.crossVectors(ns,is),t=[lf.x,lf.y,lf.z],gy(t,fc,mc,gc,sf))},clampPoint:function(e,t){return t===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new Pe),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var t=wh.copy(e).clamp(this.min,this.max);return t.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(wh).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:(Aa[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Aa[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Aa[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Aa[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Aa[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Aa[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Aa[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Aa[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Aa),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 gy(e,t,i,l,c){var h,f;for(h=0,f=e.length-3;h<=f;h+=3){Qs.fromArray(e,h);var r=c.x*Math.abs(Qs.x)+c.y*Math.abs(Qs.y)+c.z*Math.abs(Qs.z),v=t.dot(Qs),x=i.dot(Qs),w=l.dot(Qs);if(Math.max(-Math.max(v,x,w),Math.min(v,x,w))>r)return!1}return!0}var WE=new Po;function Da(e,t){this.center=e!==void 0?e:new Pe,this.radius=t!==void 0?t:0}Object.assign(Da.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var i=this.center;t!==void 0?i.copy(t):WE.setFromPoints(e).getCenter(i);for(var l=0,c=0,h=e.length;cthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return e===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Po),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 Pa=new Pe,yy=new Pe,cf=new Pe,rs=new Pe,_y=new Pe,uf=new Pe,vy=new Pe;function yc(e,t){this.origin=e!==void 0?e:new Pe,this.direction=t!==void 0?t:new Pe(0,0,-1)}Object.assign(yc.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),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,t){return t===void 0&&(console.warn("THREE.Ray: .at() target is now required"),t=new Pe),t.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,Pa)),this},closestPointToPoint:function(e,t){t===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new Pe),t.subVectors(e,this.origin);var i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=Pa.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Pa.copy(this.direction).multiplyScalar(t).add(this.origin),Pa.distanceToSquared(e))},distanceSqToSegment:function(e,t,i,l){yy.copy(e).add(t).multiplyScalar(.5),cf.copy(t).sub(e).normalize(),rs.copy(this.origin).sub(yy);var c=e.distanceTo(t)*.5,h=-this.direction.dot(cf),f=rs.dot(this.direction),r=-rs.dot(cf),v=rs.lengthSq(),x=Math.abs(1-h*h),w,b,A,L;if(x>0)if(w=h*r-f,b=h*f-r,L=c*x,w>=0)if(b>=-L)if(b<=L){var P=1/x;w*=P,b*=P,A=w*(w+h*b+2*f)+b*(h*w+b+2*r)+v}else b=c,w=Math.max(0,-(h*b+f)),A=-w*w+b*(b+2*r)+v;else b=-c,w=Math.max(0,-(h*b+f)),A=-w*w+b*(b+2*r)+v;else b<=-L?(w=Math.max(0,-(-h*c+f)),b=w>0?-c:Math.min(Math.max(-c,-r),c),A=-w*w+b*(b+2*r)+v):b<=L?(w=0,b=Math.min(Math.max(-c,-r),c),A=b*(b+2*r)+v):(w=Math.max(0,-(h*c+f)),b=w>0?c:Math.min(Math.max(-c,-r),c),A=-w*w+b*(b+2*r)+v);else b=h>0?-c:c,w=Math.max(0,-(h*b+f)),A=-w*w+b*(b+2*r)+v;return i&&i.copy(this.direction).multiplyScalar(w).add(this.origin),l&&l.copy(cf).multiplyScalar(b).add(yy),A},intersectSphere:function(e,t){Pa.subVectors(e.center,this.origin);var i=Pa.dot(this.direction),l=Pa.dot(Pa)-i*i,c=e.radius*e.radius;if(l>c)return null;var h=Math.sqrt(c-l),f=i-h,r=i+h;return f<0&&r<0?null:f<0?this.at(r,t):this.at(f,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return i===null?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(t===0)return!0;var i=e.normal.dot(this.direction);return i*t<0},intersectBox:function(e,t){var i,l,c,h,f,r,v=1/this.direction.x,x=1/this.direction.y,w=1/this.direction.z,b=this.origin;return v>=0?(i=(e.min.x-b.x)*v,l=(e.max.x-b.x)*v):(i=(e.max.x-b.x)*v,l=(e.min.x-b.x)*v),x>=0?(c=(e.min.y-b.y)*x,h=(e.max.y-b.y)*x):(c=(e.max.y-b.y)*x,h=(e.min.y-b.y)*x),i>h||c>l||((c>i||i!==i)&&(i=c),(h=0?(f=(e.min.z-b.z)*w,r=(e.max.z-b.z)*w):(f=(e.max.z-b.z)*w,r=(e.min.z-b.z)*w),i>r||f>l)||((f>i||i!==i)&&(i=f),(r=0?i:l,t)},intersectsBox:function(e){return this.intersectBox(e,Pa)!==null},intersectTriangle:function(e,t,i,l,c){_y.subVectors(t,e),uf.subVectors(i,e),vy.crossVectors(_y,uf);var h=this.direction.dot(vy),f;if(h>0){if(l)return null;f=1}else if(h<0)f=-1,h=-h;else return null;rs.subVectors(this.origin,e);var r=f*this.direction.dot(uf.crossVectors(rs,uf));if(r<0)return null;var v=f*this.direction.dot(_y.cross(rs));if(v<0||r+v>h)return null;var x=-f*rs.dot(vy);return x<0?null:this.at(x/h,c)},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 xy=new Pe,jE=new Pe,HE=new pr;function $o(e,t){this.normal=e!==void 0?e:new Pe(1,0,0),this.constant=t!==void 0?t:0}Object.assign($o.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,l){return this.normal.set(e,t,i),this.constant=l,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,i){var l=xy.subVectors(i,t).cross(jE.subVectors(e,t)).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,t){return t===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new Pe),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){t===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new Pe);var i=e.delta(xy),l=this.normal.dot(i);if(l===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):void 0;var c=-(e.start.dot(this.normal)+this.constant)/l;if(!(c<0||c>1))return t.copy(i).multiplyScalar(c).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>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 Pe),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var i=t||HE.getNormalMatrix(e),l=this.coplanarPoint(xy).applyMatrix4(e),c=this.normal.applyMatrix3(i).normalize();return this.constant=-l.dot(c),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 So=new Pe,Sa=new Pe,by=new Pe,La=new Pe,_c=new Pe,vc=new Pe,Qx=new Pe,wy=new Pe,My=new Pe,Ty=new Pe;function lr(e,t,i){this.a=e!==void 0?e:new Pe,this.b=t!==void 0?t:new Pe,this.c=i!==void 0?i:new Pe}Object.assign(lr,{getNormal:function(e,t,i,l){l===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),l=new Pe),l.subVectors(i,t),So.subVectors(e,t),l.cross(So);var c=l.lengthSq();return c>0?l.multiplyScalar(1/Math.sqrt(c)):l.set(0,0,0)},getBarycoord:function(e,t,i,l,c){So.subVectors(l,t),Sa.subVectors(i,t),by.subVectors(e,t);var h=So.dot(So),f=So.dot(Sa),r=So.dot(by),v=Sa.dot(Sa),x=Sa.dot(by),w=h*v-f*f;if(c===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),c=new Pe),w===0)return c.set(-2,-1,-1);var b=1/w,A=(v*r-f*x)*b,L=(h*x-f*r)*b;return c.set(1-A-L,L,A)},containsPoint:function(e,t,i,l){return lr.getBarycoord(e,t,i,l,La),La.x>=0&&La.y>=0&&La.x+La.y<=1},getUV:function(e,t,i,l,c,h,f,r){return this.getBarycoord(e,t,i,l,La),r.set(0,0),r.addScaledVector(c,La.x),r.addScaledVector(h,La.y),r.addScaledVector(f,La.z),r},isFrontFacing:function(e,t,i,l){return So.subVectors(i,t),Sa.subVectors(e,t),So.cross(Sa).dot(l)<0}}),Object.assign(lr.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,l){return this.a.copy(e[t]),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 So.subVectors(this.c,this.b),Sa.subVectors(this.a,this.b),So.cross(Sa).length()*.5},getMidpoint:function(e){return e===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Pe),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(.3333333333333333)},getNormal:function(e){return lr.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 $o),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return lr.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,i,l,c){return lr.getUV(e,this.a,this.b,this.c,t,i,l,c)},containsPoint:function(e){return lr.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return lr.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){t===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new Pe);var i=this.a,l=this.b,c=this.c,h,f;_c.subVectors(l,i),vc.subVectors(c,i),wy.subVectors(e,i);var r=_c.dot(wy),v=vc.dot(wy);if(r<=0&&v<=0)return t.copy(i);My.subVectors(e,l);var x=_c.dot(My),w=vc.dot(My);if(x>=0&&w<=x)return t.copy(l);var b=r*w-x*v;if(b<=0&&r>=0&&x<=0)return h=r/(r-x),t.copy(i).addScaledVector(_c,h);Ty.subVectors(e,c);var A=_c.dot(Ty),L=vc.dot(Ty);if(L>=0&&A<=L)return t.copy(c);var P=A*v-r*L;if(P<=0&&v>=0&&L<=0)return f=v/(v-L),t.copy(i).addScaledVector(vc,f);var R=x*L-A*w;if(R<=0&&w-x>=0&&A-L>=0)return Qx.subVectors(c,l),f=(w-x)/(w-x+(A-L)),t.copy(l).addScaledVector(Qx,f);var F=1/(R+P+b);return h=P*F,f=b*F,t.copy(i).addScaledVector(_c,h).addScaledVector(vc,f)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var e0={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},Lo={h:0,s:0,l:0},hf={h:0,s:0,l:0};function tn(e,t,i){return t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}function Ey(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<.16666666666666666?e+(t-e)*6*i:i<.5?t:i<.6666666666666666?e+(t-e)*6*(.6666666666666666-i):e}function Cy(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function Ay(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}Object.assign(tn.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,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(e,t,i){if(e=jn.euclideanModulo(e,1),t=jn.clamp(t,0,1),i=jn.clamp(i,0,1),t===0)this.r=this.g=this.b=i;else{var l=i<=.5?i*(1+t):i+t-i*t,c=2*i-l;this.r=Ey(c,l,e+.3333333333333333),this.g=Ey(c,l,e),this.b=Ey(c,l,e-.3333333333333333)}return this},setStyle:function(e){function t(b){b!==void 0&&parseFloat(b)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var l,c=i[1],h=i[2];switch(c){case"rgb":case"rgba":if(l=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(h))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,t(l[5]),this;if(l=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(h))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,t(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(h)){var f=parseFloat(l[1])/360,r=parseInt(l[2],10)/100,v=parseInt(l[3],10)/100;return t(l[5]),this.setHSL(f,r,v)}break}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var x=i[1],w=x.length;if(w===3)return this.r=parseInt(x.charAt(0)+x.charAt(0),16)/255,this.g=parseInt(x.charAt(1)+x.charAt(1),16)/255,this.b=parseInt(x.charAt(2)+x.charAt(2),16)/255,this;if(w===6)return this.r=parseInt(x.charAt(0)+x.charAt(1),16)/255,this.g=parseInt(x.charAt(2)+x.charAt(3),16)/255,this.b=parseInt(x.charAt(4)+x.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var t=e0[e];return t!==void 0?this.setHex(t):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,t){return t===void 0&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){t===void 0&&(t=2);var i=t>0?1/t: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=Cy(e.r),this.g=Cy(e.g),this.b=Cy(e.b),this},copyLinearToSRGB:function(e){return this.r=Ay(e.r),this.g=Ay(e.g),this.b=Ay(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 t=this.r,i=this.g,l=this.b,c=Math.max(t,i,l),h=Math.min(t,i,l),f,r,v=(h+c)/2;if(h===c)f=0,r=0;else{var x=c-h;switch(r=v<=.5?x/(c+h):x/(2-c-h),c){case t:f=(i-l)/x+(i0&&(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(f){var r=[];for(var v in f){var x=f[v];delete x.metadata,r.push(x)}return r}if(t){var c=l(e.textures),h=l(e.images);c.length>0&&(i.textures=c),h.length>0&&(i.images=h)}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 t=e.clippingPlanes,i=null;if(t!==null){var l=t.length;i=new Array(l);for(var c=0;c!==l;++c)i[c]=t[c].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 cr(e){Rn.call(this),this.type="MeshBasicMaterial",this.color=new tn(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=Xp,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)}cr.prototype=Object.create(Rn.prototype),cr.prototype.constructor=cr,cr.prototype.isMeshBasicMaterial=!0,cr.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 Pe;function kn(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i===!0,this.usage=nf,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(kn.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(kn.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,t,i){e*=this.itemSize,i*=t.itemSize;for(var l=0,c=this.itemSize;l0,h=l[1]&&l[1].length>0,f=e.morphTargets,r=f.length,v;if(r>0){v=[];for(var x=0;x0){A=[];for(var x=0;x0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var x=0;xt&&(t=e[i]);return t}var qE=1,qo=new Hn,ky=new on,xc=new Pe,oo=new Po,Ch=new Po,qi=new Pe;function vn(){Object.defineProperty(this,"id",{value:qE+=2}),this.uuid=jn.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={}}vn.prototype=Object.assign(Object.create(Ta.prototype),{constructor:vn,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(n0(e)>65535?Eh:Th)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:i!==void 0?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){var t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);var i=this.attributes.normal;if(i!==void 0){var l=new pr().getNormalMatrix(e);i.applyNormalMatrix(l),i.needsUpdate=!0}var c=this.attributes.tangent;return c!==void 0&&(c.transformDirection(e),c.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return qo.makeRotationX(e),this.applyMatrix4(qo),this},rotateY:function(e){return qo.makeRotationY(e),this.applyMatrix4(qo),this},rotateZ:function(e){return qo.makeRotationZ(e),this.applyMatrix4(qo),this},translate:function(e,t,i){return qo.makeTranslation(e,t,i),this.applyMatrix4(qo),this},scale:function(e,t,i){return qo.makeScale(e,t,i),this.applyMatrix4(qo),this},lookAt:function(e){return ky.lookAt(e),ky.updateMatrix(),this.applyMatrix4(ky.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(xc).negate(),this.translate(xc.x,xc.y,xc.z),this},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var i=new ln(t.vertices.length*3,3),l=new ln(t.colors.length*3,3);if(this.setAttribute("position",i.copyVector3sArray(t.vertices)),this.setAttribute("color",l.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var c=new ln(t.lineDistances.length,1);this.setAttribute("lineDistance",c.copyArray(t.lineDistances))}t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,l=e.length;i0){var i=new Float32Array(e.normals.length*3);this.setAttribute("normal",new kn(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var l=new Float32Array(e.colors.length*3);this.setAttribute("color",new kn(l,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var c=new Float32Array(e.uvs.length*2);this.setAttribute("uv",new kn(c,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var h=new Float32Array(e.uvs2.length*2);this.setAttribute("uv2",new kn(h,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var f in e.morphTargets){for(var r=[],v=e.morphTargets[f],x=0,w=v.length;x0){var L=new ln(e.skinIndices.length*4,4);this.setAttribute("skinIndex",L.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var P=new ln(e.skinWeights.length*4,4);this.setAttribute("skinWeight",P.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 Po);var e=this.attributes.position,t=this.morphAttributes.position;if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(var i=0,l=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){var t=this.parameters;for(var i in t)t[i]!==void 0&&(e[i]=t[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 c=this.attributes;for(var i in c){var h=c[i],f=h.toJSON();h.name!==""&&(f.name=h.name),e.data.attributes[i]=f}var r={},v=!1;for(var i in this.morphAttributes){for(var x=this.morphAttributes[i],w=[],b=0,A=x.length;b0&&(r[i]=w,v=!0)}v&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);var L=this.groups;L.length>0&&(e.data.groups=JSON.parse(JSON.stringify(L)));var P=this.boundingSphere;return P!==null&&(e.data.boundingSphere={center:P.center.toArray(),radius:P.radius}),e},clone:function(){return new vn().copy(this)},copy:function(e){var t,i,l;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var c=e.index;c!==null&&this.setIndex(c.clone());var h=e.attributes;for(t in h){var f=h[t];this.setAttribute(t,f.clone())}var r=e.morphAttributes;for(t in r){var v=[],x=r[t];for(i=0,l=x.length;i0){var f=c[h[0]];if(f!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,i=f.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){var i=this.geometry,l=this.material,c=this.matrixWorld;if(l!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),zy.copy(i.boundingSphere),zy.applyMatrix4(c),e.ray.intersectsSphere(zy)!==!1&&(i0.getInverse(c),el.copy(e.ray).applyMatrix4(i0),!(i.boundingBox!==null&&el.intersectsBox(i.boundingBox)===!1)))){var h;if(i.isBufferGeometry){var f,r,v,x=i.index,w=i.attributes.position,b=i.morphAttributes.position,A=i.morphTargetsRelative,L=i.attributes.uv,P=i.attributes.uv2,R=i.groups,F=i.drawRange,V,j,J,ne,H,Q,ae,ie;if(x!==null)if(Array.isArray(l))for(V=0,J=R.length;V0&&(He=at);for(var At=0,yt=Ve.length;Ati.far?null:{distance:x,point:gf.clone(),object:e}}function yf(e,t,i,l,c,h,f,r,v,x,w,b){tl.fromBufferAttribute(c,x),nl.fromBufferAttribute(c,w),il.fromBufferAttribute(c,b);var A=e.morphTargetInfluences;if(t.morphTargets&&h&&A){pf.set(0,0,0),ff.set(0,0,0),mf.set(0,0,0);for(var L=0,P=h.length;L0)for(var x=0;x0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,i;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,l,c;for(i=0,l=this.faces.length;i=0;r--){var R=L[r];for(this.faces.splice(R,1),b=0,A=this.faceVertexUvs.length;b0,j=L.vertexNormals.length>0,J=L.color.r!==1||L.color.g!==1||L.color.b!==1,ne=L.vertexColors.length>0,H=0;if(H=le(H,0,0),H=le(H,1,P),H=le(H,2,R),H=le(H,3,F),H=le(H,4,V),H=le(H,5,j),H=le(H,6,J),H=le(H,7,ne),f.push(H),f.push(L.a,L.b,L.c),f.push(L.materialIndex),F){var Q=this.faceVertexUvs[0][c];f.push(he(Q[0]),he(Q[1]),he(Q[2]))}if(V&&f.push(fe(L.normal)),j){var ae=L.vertexNormals;f.push(fe(ae[0]),fe(ae[1]),fe(ae[2]))}if(J&&f.push(me(L.color)),ne){var ie=L.vertexColors;f.push(me(ie[0]),me(ie[1]),me(ie[2]))}}function le(Oe,Ve,He){return He?Oe|1<0&&(e.data.colors=x),b.length>0&&(e.data.uvs=[b]),e.data.faces=f,e},clone:function(){return new Bn().copy(this)},copy:function(e){var t,i,l,c,h,f;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 r=e.vertices;for(t=0,i=r.length;t0?1:-1,w.push(Nt.x,Nt.y,Nt.z),b.push(Dt/ae),b.push(1-It/ie),At+=1}}for(It=0;It0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var h={};for(var f in this.extensions)this.extensions[f]===!0&&(h[f]=!0);return Object.keys(h).length>0&&(t.extensions=h),t};function Ia(){on.call(this),this.type="Camera",this.matrixWorldInverse=new Hn,this.projectionMatrix=new Hn,this.projectionMatrixInverse=new Hn}Ia.prototype=Object.assign(Object.create(on.prototype),{constructor:Ia,isCamera:!0,copy:function(e,t){return on.prototype.copy.call(this,e,t),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 Pe),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){on.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(e,t){on.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return new this.constructor().copy(this)}});function Xi(e,t,i,l){Ia.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=t!==void 0?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Xi.prototype=Object.assign(Object.create(Ia.prototype),{constructor:Xi,isPerspectiveCamera:!0,copy:function(e,t){return Ia.prototype.copy.call(this,e,t),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 t=.5*this.getFilmHeight()/e;this.fov=jn.RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(jn.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return jn.RAD2DEG*2*Math.atan(Math.tan(jn.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,t,i,l,c,h){this.aspect=e/t,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=t,this.view.offsetX=i,this.view.offsetY=l,this.view.width=c,this.view.height=h,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(jn.DEG2RAD*.5*this.fov)/this.zoom,i=2*t,l=this.aspect*i,c=-.5*l,h=this.view;if(this.view!==null&&this.view.enabled){var f=h.fullWidth,r=h.fullHeight;c+=h.offsetX*l/f,t-=h.offsetY*i/r,l*=h.width/f,i*=h.height/r}var v=this.filmOffset;v!==0&&(c+=e*v/this.getFilmWidth()),this.projectionMatrix.makePerspective(c,c+l,t,t-i,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=on.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});var Ec=90,Cc=1;function Dh(e,t,i,l){on.call(this),this.type="CubeCamera";var c=new Xi(Ec,Cc,e,t);c.up.set(0,-1,0),c.lookAt(new Pe(1,0,0)),this.add(c);var h=new Xi(Ec,Cc,e,t);h.up.set(0,-1,0),h.lookAt(new Pe(-1,0,0)),this.add(h);var f=new Xi(Ec,Cc,e,t);f.up.set(0,0,1),f.lookAt(new Pe(0,1,0)),this.add(f);var r=new Xi(Ec,Cc,e,t);r.up.set(0,0,-1),r.lookAt(new Pe(0,-1,0)),this.add(r);var v=new Xi(Ec,Cc,e,t);v.up.set(0,-1,0),v.lookAt(new Pe(0,0,1)),this.add(v);var x=new Xi(Ec,Cc,e,t);x.up.set(0,-1,0),x.lookAt(new Pe(0,0,-1)),this.add(x),l=l||{format:Ma,magFilter:$i,minFilter:$i},this.renderTarget=new Ac(i,l),this.renderTarget.texture.name="CubeCamera",this.update=function(w,b){this.parent===null&&this.updateMatrixWorld();var A=w.getRenderTarget(),L=this.renderTarget,P=L.texture.generateMipmaps;L.texture.generateMipmaps=!1,w.setRenderTarget(L,0),w.render(b,c),w.setRenderTarget(L,1),w.render(b,h),w.setRenderTarget(L,2),w.render(b,f),w.setRenderTarget(L,3),w.render(b,r),w.setRenderTarget(L,4),w.render(b,v),L.texture.generateMipmaps=P,w.setRenderTarget(L,5),w.render(b,x),w.setRenderTarget(A)},this.clear=function(w,b,A,L){for(var P=w.getRenderTarget(),R=this.renderTarget,F=0;F<6;F++)w.setRenderTarget(R,F),w.clear(b,A,L);w.setRenderTarget(P)}}Dh.prototype=Object.create(on.prototype),Dh.prototype.constructor=Dh;function Ac(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),Tr.call(this,e,e,t)}Ac.prototype=Object.create(Tr.prototype),Ac.prototype.constructor=Ac,Ac.prototype.isWebGLCubeRenderTarget=!0,Ac.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=t.format,this.texture.encoding=t.encoding;var i=new Ca,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 "," #include ","}"].join(` `),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(` `)},c=new Ur({type:"CubemapFromEquirect",uniforms:Tc(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,side:tr,blending:es});c.uniforms.tEquirect.value=t;var h=new Ai(new vf(5,5,5),c);i.add(h);var f=new Dh(1,10,1);return f.renderTarget=this,f.renderTarget.texture.name="CubeCameraTexture",f.update(e,i),h.geometry.dispose(),h.material.dispose(),this};function Dc(e,t,i,l,c,h,f,r,v,x,w,b){mi.call(this,null,h,f,r,v,x,l,c,w,b),this.image={data:e||null,width:t||1,height:i||1},this.magFilter=v!==void 0?v:Ui,this.minFilter=x!==void 0?x:Ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Dc.prototype=Object.create(mi.prototype),Dc.prototype.constructor=Dc,Dc.prototype.isDataTexture=!0;var Pc=new Da,xf=new Pe;function Ph(e,t,i,l,c,h){this.planes=[e!==void 0?e:new $o,t!==void 0?t:new $o,i!==void 0?i:new $o,l!==void 0?l:new $o,c!==void 0?c:new $o,h!==void 0?h:new $o]}Object.assign(Ph.prototype,{set:function(e,t,i,l,c,h){var f=this.planes;return f[0].copy(e),f[1].copy(t),f[2].copy(i),f[3].copy(l),f[4].copy(c),f[5].copy(h),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromProjectionMatrix:function(e){var t=this.planes,i=e.elements,l=i[0],c=i[1],h=i[2],f=i[3],r=i[4],v=i[5],x=i[6],w=i[7],b=i[8],A=i[9],L=i[10],P=i[11],R=i[12],F=i[13],V=i[14],j=i[15];return t[0].setComponents(f-l,w-r,P-b,j-R).normalize(),t[1].setComponents(f+l,w+r,P+b,j+R).normalize(),t[2].setComponents(f+c,w+v,P+A,j+F).normalize(),t[3].setComponents(f-c,w-v,P-A,j-F).normalize(),t[4].setComponents(f-h,w-x,P-L,j-V).normalize(),t[5].setComponents(f+h,w+x,P+L,j+V).normalize(),this},intersectsObject:function(e){var t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Pc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Pc)},intersectsSprite:function(e){return Pc.center.set(0,0,0),Pc.radius=.7071067811865476,Pc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pc)},intersectsSphere:function(e){for(var t=this.planes,i=e.center,l=-e.radius,c=0;c<6;c++){var h=t[c].distanceToPoint(i);if(h0?e.max.x:e.min.x,xf.y=l.normal.y>0?e.max.y:e.min.y,xf.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(xf)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}});var an={common:{diffuse:{value:new tn(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new pr},uv2Transform:{value:new pr},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 tn(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 tn(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new pr}},sprite:{diffuse:{value:new tn(15658734)},opacity:{value:1},center:{value:new Lt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new pr}}};function o0(){var e=null,t=!1,i=null;function l(c,h){t!==!1&&(i(c,h),e.requestAnimationFrame(l))}return{start:function(){t!==!0&&i!==null&&(e.requestAnimationFrame(l),t=!0)},stop:function(){t=!1},setAnimationLoop:function(c){i=c},setContext:function(c){e=c}}}function QE(e,t){var i=t.isWebGL2,l=new WeakMap;function c(x,w){var b=x.array,A=x.usage,L=e.createBuffer();e.bindBuffer(w,L),e.bufferData(w,b,A),x.onUploadCallback();var P=5126;return b instanceof Float32Array?P=5126:b instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):b instanceof Uint16Array?P=5123:b instanceof Int16Array?P=5122:b instanceof Uint32Array?P=5125:b instanceof Int32Array?P=5124:b instanceof Int8Array?P=5120:b instanceof Uint8Array&&(P=5121),{buffer:L,type:P,bytesPerElement:b.BYTES_PER_ELEMENT,version:x.version}}function h(x,w,b){var A=w.array,L=w.updateRange;e.bindBuffer(b,x),L.count===-1?e.bufferSubData(b,0,A):(i?e.bufferSubData(b,L.offset*A.BYTES_PER_ELEMENT,A,L.offset,L.count):e.bufferSubData(b,L.offset*A.BYTES_PER_ELEMENT,A.subarray(L.offset,L.offset+L.count)),L.count=-1)}function f(x){return x.isInterleavedBufferAttribute&&(x=x.data),l.get(x)}function r(x){x.isInterleavedBufferAttribute&&(x=x.data);var w=l.get(x);w&&(e.deleteBuffer(w.buffer),l.delete(x))}function v(x,w){x.isInterleavedBufferAttribute&&(x=x.data);var b=l.get(x);b===void 0?l.set(x,c(x,w)):b.version 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) { float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH ); return ( 1.0 - specularColor ) * fresnel + specularColor; } vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) { float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV ); vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0; return Fr * fresnel + F0; } float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); return 1.0 / ( gl * gv ); } float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) { float alpha = pow2( roughness ); vec3 halfDir = normalize( incidentLight.direction + viewDir ); float dotNL = saturate( dot( normal, incidentLight.direction ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotLH = saturate( dot( incidentLight.direction, halfDir ) ); vec3 F = F_Schlick( specularColor, dotLH ); float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( G * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 brdf = integrateSpecularBRDF( dotNV, roughness ); return specularColor * brdf.x + brdf.y; } void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness ); vec2 brdf = integrateSpecularBRDF( dotNV, roughness ); vec3 FssEss = F * brdf.x + brdf.y; float Ess = brdf.x + brdf.y; float Ems = 1.0 - Ess; vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir ); float dotNH = saturate( dot( geometry.normal, halfDir ) ); float dotLH = saturate( dot( incidentLight.direction, halfDir ) ); vec3 F = F_Schlick( specularColor, dotLH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) { return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 ); } float BlinnExponentToGGXRoughness( const in float blinnExponent ) { return sqrt( 2.0 / ( blinnExponent + 2.0 ) ); } #if defined( USE_SHEEN ) float D_Charlie(float roughness, float NoH) { float invAlpha = 1.0 / roughness; float cos2h = NoH * NoH; float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI); } float V_Neubelt(float NoV, float NoL) { return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV))); } vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) { vec3 N = geometry.normal; vec3 V = geometry.viewDir; vec3 H = normalize( V + L ); float dotNH = saturate( dot( N, H ) ); return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) ); } #endif`,lC=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) { vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ); fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 ); vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,cC=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard; } #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped; } if ( clipped ) discard; #endif #endif`,uC=`#if NUM_CLIPPING_PLANES > 0 #if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP ) varying vec3 vViewPosition; #endif uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,hC=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP ) varying vec3 vViewPosition; #endif`,dC=`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP ) vViewPosition = - mvPosition.xyz; #endif`,pC=`#ifdef USE_COLOR diffuseColor.rgb *= vColor; #endif`,fC=`#ifdef USE_COLOR varying vec3 vColor; #endif`,mC=`#ifdef USE_COLOR varying vec3 vColor; #endif`,gC=`#ifdef USE_COLOR vColor.xyz = color.xyz; #endif`,yC=`#define PI 3.14159265359 #define PI2 6.28318530718 #define PI_HALF 1.5707963267949 #define RECIPROCAL_PI 0.31830988618 #define RECIPROCAL_PI2 0.15915494 #define LOG2 1.442695 #define EPSILON 1e-6 #ifndef saturate #define saturate(a) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement(a) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract(sin(sn) * c); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); } float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef CLEARCOAT vec3 clearcoatNormal; #endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) { float distance = dot( planeNormal, point - pointOnPlane ); return - distance * planeNormal + point; } float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) { return sign( dot( point - pointOnPlane, planeNormal ) ); } vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) { return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine; } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float linearToRelativeLuminance( const in vec3 color ) { vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); return dot( weights, color.rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; }`,_C=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_maxMipLevel 8.0 #define cubeUV_minMipLevel 4.0 #define cubeUV_maxTileSize 256.0 #define cubeUV_minTileSize 16.0 float getFace(vec3 direction) { vec3 absDirection = abs(direction); float face = -1.0; if (absDirection.x > absDirection.z) { if (absDirection.x > absDirection.y) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if (absDirection.z > absDirection.y) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV(vec3 direction, float face) { vec2 uv; if (face == 0.0) { uv = vec2(-direction.z, direction.y) / abs(direction.x); } else if (face == 1.0) { uv = vec2(direction.x, -direction.z) / abs(direction.y); } else if (face == 2.0) { uv = direction.xy / abs(direction.z); } else if (face == 3.0) { uv = vec2(direction.z, direction.y) / abs(direction.x); } else if (face == 4.0) { uv = direction.xz / abs(direction.y); } else { uv = vec2(-direction.x, direction.y) / abs(direction.z); } return 0.5 * (uv + 1.0); } vec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) { float face = getFace(direction); float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0); mipInt = max(mipInt, cubeUV_minMipLevel); float faceSize = exp2(mipInt); float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize); vec2 uv = getUV(direction, face) * (faceSize - 1.0); vec2 f = fract(uv); uv += 0.5 - f; if (face > 2.0) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; if(mipInt < cubeUV_maxMipLevel){ uv.y += 2.0 * cubeUV_maxTileSize; } uv.y += filterInt * 2.0 * cubeUV_minTileSize; uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize); uv *= texelSize; vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb; uv.x += texelSize; vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb; uv.y += texelSize; vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb; uv.x -= texelSize; vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb; vec3 tm = mix(tl, tr, f.x); vec3 bm = mix(bl, br, f.x); return mix(tm, bm, f.y); } #define r0 1.0 #define v0 0.339 #define m0 -2.0 #define r1 0.8 #define v1 0.276 #define m1 -1.0 #define r4 0.4 #define v4 0.046 #define m4 2.0 #define r5 0.305 #define v5 0.016 #define m5 3.0 #define r6 0.21 #define v6 0.0038 #define m6 4.0 float roughnessToMip(float roughness) { float mip = 0.0; if (roughness >= r1) { mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0; } else if (roughness >= r4) { mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1; } else if (roughness >= r5) { mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4; } else if (roughness >= r6) { mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5; } else { mip = -2.0 * log2(1.16 * roughness); } return mip; } vec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) { float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel); float mipF = fract(mip); float mipInt = floor(mip); vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt); if (mipF == 0.0) { return vec4(color0, 1.0); } else { vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0); return vec4(mix(color0, color1, mipF), 1.0); } } #endif`,vC=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING transformedNormal = mat3( instanceMatrix ) * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,xC=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,bC=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,wC=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; totalEmissiveRadiance *= emissiveColor.rgb; #endif`,MC=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,TC="gl_FragColor = linearToOutputTexel( gl_FragColor );",EC=` vec4 LinearToLinear( in vec4 value ) { return value; } vec4 GammaToLinear( in vec4 value, in float gammaFactor ) { return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a ); } vec4 LinearToGamma( in vec4 value, in float gammaFactor ) { return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a ); } vec4 sRGBToLinear( in vec4 value ) { 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 ); } vec4 LinearTosRGB( in vec4 value ) { 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 ); } vec4 RGBEToLinear( in vec4 value ) { return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 ); } vec4 LinearToRGBE( in vec4 value ) { float maxComponent = max( max( value.r, value.g ), value.b ); float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 ); return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 ); } vec4 RGBMToLinear( in vec4 value, in float maxRange ) { return vec4( value.rgb * value.a * maxRange, 1.0 ); } vec4 LinearToRGBM( in vec4 value, in float maxRange ) { float maxRGB = max( value.r, max( value.g, value.b ) ); float M = clamp( maxRGB / maxRange, 0.0, 1.0 ); M = ceil( M * 255.0 ) / 255.0; return vec4( value.rgb / ( M * maxRange ), M ); } vec4 RGBDToLinear( in vec4 value, in float maxRange ) { return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 ); } vec4 LinearToRGBD( in vec4 value, in float maxRange ) { float maxRGB = max( value.r, max( value.g, value.b ) ); float D = max( maxRange / maxRGB, 1.0 ); D = clamp( floor( D ) / 255.0, 0.0, 1.0 ); return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D ); } const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 ); vec4 LinearToLogLuv( in vec4 value ) { vec3 Xp_Y_XYZp = cLogLuvM * value.rgb; Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) ); vec4 vResult; vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z; float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0; vResult.w = fract( Le ); vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0; return vResult; } const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 ); vec4 LogLuvToLinear( in vec4 value ) { float Le = value.z * 255.0 + value.w; vec3 Xp_Y_XYZp; Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 ); Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y; Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z; vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb; return vec4( max( vRGB, 0.0 ), 1.0 ); }`,CC=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); #elif defined( ENVMAP_TYPE_EQUIREC ) vec2 sampleUV; reflectVec = normalize( reflectVec ); sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5; vec4 envColor = texture2D( envMap, sampleUV ); #elif defined( ENVMAP_TYPE_SPHERE ) reflectVec = normalize( reflectVec ); vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ); vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 ); #else vec4 envColor = vec4( 0.0 ); #endif #ifndef ENVMAP_TYPE_CUBE_UV envColor = envMapTexelToLinear( envColor ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,AC=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform int maxMipLevel; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,DC=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,PC=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,SC=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,LC=`#ifdef USE_FOG fogDepth = -mvPosition.z; #endif`,IC=`#ifdef USE_FOG varying float fogDepth; #endif`,RC=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, fogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,kC=`#ifdef USE_FOG uniform vec3 fogColor; varying float fogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,zC=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return texture2D( gradientMap, coord ).rgb; #else return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); #endif }`,FC=`#ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #endif`,BC=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,OC=`vec3 diffuse = vec3( 1.0 ); GeometricContext geometry; geometry.position = mvPosition.xyz; geometry.normal = normalize( transformedNormal ); geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); GeometricContext backGeometry; backGeometry.position = geometry.position; backGeometry.normal = -geometry.normal; backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); #endif IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #endif #if NUM_SPOT_LIGHTS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #endif #if NUM_DIR_LIGHTS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #endif #if NUM_HEMI_LIGHTS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); #ifdef DOUBLE_SIDED vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry ); #endif } #endif`,NC=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) { vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif return irradiance; } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; int shadow; float shadowBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) { directLight.color = directionalLight.color; directLight.direction = directionalLight.direction; directLight.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; int shadow; float shadowBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) { vec3 lVector = pointLight.position - geometry.position; directLight.direction = normalize( lVector ); float lightDistance = length( lVector ); directLight.color = pointLight.color; directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay ); directLight.visible = ( directLight.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; int shadow; float shadowBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) { vec3 lVector = spotLight.position - geometry.position; directLight.direction = normalize( lVector ); float lightDistance = length( lVector ); float angleCos = dot( directLight.direction, spotLight.direction ); if ( angleCos > spotLight.coneCos ) { float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos ); directLight.color = spotLight.color; directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay ); directLight.visible = true; } else { directLight.color = vec3( 0.0 ); directLight.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) { float dotNL = dot( geometry.normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif return irradiance; } #endif`,UC=`#if defined( USE_ENVMAP ) #ifdef ENVMAP_MODE_REFRACTION uniform float refractionRatio; #endif vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) { vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix ); #ifdef ENVMAP_TYPE_CUBE vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) ); #else vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); #else vec4 envMapColor = vec4( 0.0 ); #endif return PI * envMapColor.rgb * envMapIntensity; } float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) { float maxMIPLevelScalar = float( maxMIPLevel ); float sigma = PI * roughness * roughness / ( 1.0 + roughness ); float desiredMIPLevel = maxMIPLevelScalar + log2( sigma ); return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar ); } vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) { #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( -viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); #else vec3 reflectVec = refract( -viewDir, normal, refractionRatio ); #endif reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel ); #ifdef ENVMAP_TYPE_CUBE vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel ); #else vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); #elif defined( ENVMAP_TYPE_EQUIREC ) vec2 sampleUV; sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5; #ifdef TEXTURE_LOD_EXT vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel ); #else vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_SPHERE ) vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel ); #else vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #endif return envMapColor.rgb * envMapIntensity; } #endif`,VC=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,GC=`varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct ToonMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon #define Material_LightProbeLOD( material ) (0)`,WC=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,jC=`varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong #define Material_LightProbeLOD( material ) (0)`,HC=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness; material.specularRoughness = min( material.specularRoughness, 1.0 ); #ifdef REFLECTIVITY material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor ); #endif #ifdef CLEARCOAT material.clearcoat = saturate( clearcoat ); material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_SHEEN material.sheenColor = sheen; #endif`,$C=`struct PhysicalMaterial { vec3 diffuseColor; float specularRoughness; vec3 specularColor; #ifdef CLEARCOAT float clearcoat; float clearcoatRoughness; #endif #ifdef USE_SHEEN vec3 sheenColor; #endif }; #define MAXIMUM_SPECULAR_COEFFICIENT 0.16 #define DEFAULT_SPECULAR_COEFFICIENT 0.04 float clearcoatDHRApprox( const in float roughness, const in float dotNL ) { return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) ); } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.specularRoughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif #ifdef CLEARCOAT float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = ccDotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS ccIrradiance *= PI; #endif float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL ); reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness ); #else float clearcoatDHR = 0.0; #endif #ifdef USE_SHEEN reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen( material.specularRoughness, directLight.direction, geometry, material.sheenColor ); #else reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness); #endif reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } 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) { #ifdef CLEARCOAT float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness ); float ccDotNL = ccDotNV; float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL ); #else float clearcoatDHR = 0.0; #endif float clearcoatInv = 1.0 - clearcoatDHR; vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering ); vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,qC=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #pragma unroll_loop for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointDirectLightIrradiance( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) 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; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; #pragma unroll_loop for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotDirectLightIrradiance( spotLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) directLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #pragma unroll_loop for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); } #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,XC=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #ifndef PHYSICALLY_CORRECT_LIGHTS lightMapIrradiance *= PI; #endif irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel ); #ifdef CLEARCOAT clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel ); #endif #endif`,ZC=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,YC=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,KC=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,JC=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,QC=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,eA=`#ifdef USE_MAP vec4 texelColor = texture2D( map, vUv ); texelColor = mapTexelToLinear( texelColor ); diffuseColor *= texelColor; #endif`,tA=`#ifdef USE_MAP uniform sampler2D map; #endif`,nA=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP vec4 mapTexel = texture2D( map, uv ); diffuseColor *= mapTexelToLinear( mapTexel ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,iA=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,rA=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,oA=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,aA=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif`,sA=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif`,lA=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif`,cA=`#ifdef FLAT_SHADED vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,uA=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( -vViewPosition, normal, mapN ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() ); #endif`,hA=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) { vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); float scale = sign( st1.t * st0.s - st0.t * st1.s ); vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale ); vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale ); vec3 N = normalize( surf_norm ); mat3 tsn = mat3( S, T, N ); mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 ); return normalize( tsn * mapN ); } #endif`,dA=`#ifdef CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,pA=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN ); #endif #endif`,fA=`#ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,mA=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 )); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return (( near + viewZ ) * far ) / (( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,gA=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,yA=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,_A=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,vA=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,xA=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,bA=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,wA=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); 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 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); bool inFrustum = all( inFrustumVec ); bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); bool frustumTest = all( frustumTestVec ); if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,MA=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,TA=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition; } #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition; } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition; } #endif #endif`,EA=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLight directionalLight; #pragma unroll_loop for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLights[ i ]; shadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLight spotLight; #pragma unroll_loop for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLights[ i ]; shadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLight pointLight; #pragma unroll_loop for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLights[ i ]; shadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #endif #endif return shadow; }`,CA=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,AA=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; #ifdef BONE_TEXTURE uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #else uniform mat4 boneMatrices[ MAX_BONES ]; mat4 getBoneMatrix( const in float i ) { mat4 bone = boneMatrices[ int(i) ]; return bone; } #endif #endif`,DA=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,PA=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,SA=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,LA=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,IA=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,RA=`#ifndef saturate #define saturate(a) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; uniform float toneMappingWhitePoint; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } #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 ) ) vec3 Uncharted2ToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 ACESFilmicToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) ); }`,kA=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,zA=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,FA=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,BA=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,OA=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,NA=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,UA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,VA=`uniform sampler2D t2D; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,GA=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,WA=`#include uniform float opacity; varying vec3 vWorldDirection; #include void main() { vec3 vReflect = vWorldDirection; #include gl_FragColor = envColor; gl_FragColor.a *= opacity; #include #include }`,jA=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,HA=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( gl_FragCoord.z ); #endif }`,$A=`#include #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include }`,qA=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,XA=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,ZA=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include 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; vec4 texColor = texture2D( tEquirect, sampleUV ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,YA=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,KA=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,JA=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include void main() { #include vLineDistance = scale * lineDistance; vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * mvPosition; #include #include #include }`,QA=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,eD=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_ENVMAP #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,tD=`uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor ); #ifdef DOUBLE_SIDED reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; #else reflectedLight.indirectDiffuse += vIndirectFront; #endif #include reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ); #ifdef DOUBLE_SIDED reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; #else reflectedLight.directDiffuse = vLightFront; #endif reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask(); #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,nD=`#define LAMBERT varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,iD=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); matcapColor = matcapTexelToLinear( matcapColor ); #else vec4 matcapColor = vec4( 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,rD=`#define MATCAP varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,oD=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,aD=`#define TOON varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,sD=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,lD=`#define PHONG varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,cD=`#define STANDARD #ifdef PHYSICAL #define REFLECTIVITY #define CLEARCOAT #define TRANSPARENCY #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef TRANSPARENCY uniform float transparency; #endif #ifdef REFLECTIVITY uniform float reflectivity; #endif #ifdef CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_SHEEN uniform vec3 sheen; #endif varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #ifdef TRANSPARENCY diffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ); #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,uD=`#define STANDARD varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,hD=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); }`,dD=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,pD=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,fD=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,mD=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,gD=`#include #include void main() { #include #include #include #include #include }`,yD=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include }`,_D=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,Zn={alphamap_fragment:eC,alphamap_pars_fragment:tC,alphatest_fragment:nC,aomap_fragment:iC,aomap_pars_fragment:rC,begin_vertex:oC,beginnormal_vertex:aC,bsdfs:sC,bumpmap_pars_fragment:lC,clipping_planes_fragment:cC,clipping_planes_pars_fragment:uC,clipping_planes_pars_vertex:hC,clipping_planes_vertex:dC,color_fragment:pC,color_pars_fragment:fC,color_pars_vertex:mC,color_vertex:gC,common:yC,cube_uv_reflection_fragment:_C,defaultnormal_vertex:vC,displacementmap_pars_vertex:xC,displacementmap_vertex:bC,emissivemap_fragment:wC,emissivemap_pars_fragment:MC,encodings_fragment:TC,encodings_pars_fragment:EC,envmap_fragment:CC,envmap_common_pars_fragment:AC,envmap_pars_fragment:DC,envmap_pars_vertex:PC,envmap_physical_pars_fragment:UC,envmap_vertex:SC,fog_vertex:LC,fog_pars_vertex:IC,fog_fragment:RC,fog_pars_fragment:kC,gradientmap_pars_fragment:zC,lightmap_fragment:FC,lightmap_pars_fragment:BC,lights_lambert_vertex:OC,lights_pars_begin:NC,lights_toon_fragment:VC,lights_toon_pars_fragment:GC,lights_phong_fragment:WC,lights_phong_pars_fragment:jC,lights_physical_fragment:HC,lights_physical_pars_fragment:$C,lights_fragment_begin:qC,lights_fragment_maps:XC,lights_fragment_end:ZC,logdepthbuf_fragment:YC,logdepthbuf_pars_fragment:KC,logdepthbuf_pars_vertex:JC,logdepthbuf_vertex:QC,map_fragment:eA,map_pars_fragment:tA,map_particle_fragment:nA,map_particle_pars_fragment:iA,metalnessmap_fragment:rA,metalnessmap_pars_fragment:oA,morphnormal_vertex:aA,morphtarget_pars_vertex:sA,morphtarget_vertex:lA,normal_fragment_begin:cA,normal_fragment_maps:uA,normalmap_pars_fragment:hA,clearcoat_normal_fragment_begin:dA,clearcoat_normal_fragment_maps:pA,clearcoat_normalmap_pars_fragment:fA,packing:mA,premultiplied_alpha_fragment:gA,project_vertex:yA,dithering_fragment:_A,dithering_pars_fragment:vA,roughnessmap_fragment:xA,roughnessmap_pars_fragment:bA,shadowmap_pars_fragment:wA,shadowmap_pars_vertex:MA,shadowmap_vertex:TA,shadowmask_pars_fragment:EA,skinbase_vertex:CA,skinning_pars_vertex:AA,skinning_vertex:DA,skinnormal_vertex:PA,specularmap_fragment:SA,specularmap_pars_fragment:LA,tonemapping_fragment:IA,tonemapping_pars_fragment:RA,uv_pars_fragment:kA,uv_pars_vertex:zA,uv_vertex:FA,uv2_pars_fragment:BA,uv2_pars_vertex:OA,uv2_vertex:NA,worldpos_vertex:UA,background_frag:VA,background_vert:GA,cube_frag:WA,cube_vert:jA,depth_frag:HA,depth_vert:$A,distanceRGBA_frag:qA,distanceRGBA_vert:XA,equirect_frag:ZA,equirect_vert:YA,linedashed_frag:KA,linedashed_vert:JA,meshbasic_frag:QA,meshbasic_vert:eD,meshlambert_frag:tD,meshlambert_vert:nD,meshmatcap_frag:iD,meshmatcap_vert:rD,meshtoon_frag:oD,meshtoon_vert:aD,meshphong_frag:sD,meshphong_vert:lD,meshphysical_frag:cD,meshphysical_vert:uD,normal_frag:hD,normal_vert:dD,points_frag:pD,points_vert:fD,shadow_frag:mD,shadow_vert:gD,sprite_frag:yD,sprite_vert:_D},Ra={basic:{uniforms:fr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.fog]),vertexShader:Zn.meshbasic_vert,fragmentShader:Zn.meshbasic_frag},lambert:{uniforms:fr([an.common,an.specularmap,an.envmap,an.aomap,an.lightmap,an.emissivemap,an.fog,an.lights,{emissive:{value:new tn(0)}}]),vertexShader:Zn.meshlambert_vert,fragmentShader:Zn.meshlambert_frag},phong:{uniforms:fr([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 tn(0)},specular:{value:new tn(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshphong_vert,fragmentShader:Zn.meshphong_frag},standard:{uniforms:fr([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 tn(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag},toon:{uniforms:fr([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 tn(0)},specular:{value:new tn(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshtoon_vert,fragmentShader:Zn.meshtoon_frag},matcap:{uniforms:fr([an.common,an.bumpmap,an.normalmap,an.displacementmap,an.fog,{matcap:{value:null}}]),vertexShader:Zn.meshmatcap_vert,fragmentShader:Zn.meshmatcap_frag},points:{uniforms:fr([an.points,an.fog]),vertexShader:Zn.points_vert,fragmentShader:Zn.points_frag},dashed:{uniforms:fr([an.common,an.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zn.linedashed_vert,fragmentShader:Zn.linedashed_frag},depth:{uniforms:fr([an.common,an.displacementmap]),vertexShader:Zn.depth_vert,fragmentShader:Zn.depth_frag},normal:{uniforms:fr([an.common,an.bumpmap,an.normalmap,an.displacementmap,{opacity:{value:1}}]),vertexShader:Zn.normal_vert,fragmentShader:Zn.normal_frag},sprite:{uniforms:fr([an.sprite,an.fog]),vertexShader:Zn.sprite_vert,fragmentShader:Zn.sprite_frag},background:{uniforms:{uvTransform:{value:new pr},t2D:{value:null}},vertexShader:Zn.background_vert,fragmentShader:Zn.background_frag},cube:{uniforms:fr([an.envmap,{opacity:{value:1}}]),vertexShader:Zn.cube_vert,fragmentShader:Zn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zn.equirect_vert,fragmentShader:Zn.equirect_frag},distanceRGBA:{uniforms:fr([an.common,an.displacementmap,{referencePosition:{value:new Pe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zn.distanceRGBA_vert,fragmentShader:Zn.distanceRGBA_frag},shadow:{uniforms:fr([an.lights,an.fog,{color:{value:new tn(0)},opacity:{value:1}}]),vertexShader:Zn.shadow_vert,fragmentShader:Zn.shadow_frag}};Ra.physical={uniforms:fr([Ra.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new tn(0)},clearcoatNormalScale:{value:new Lt(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag};function vD(e,t,i,l){var c=new tn(0),h=0,f,r,v=null,x=0,w=null;function b(L,P,R,F){var V=P.background,j=e.xr,J=j.getSession&&j.getSession();if(J&&J.environmentBlendMode==="additive"&&(V=null),V===null?A(c,h):V&&V.isColor&&(A(V,1),F=!0),(e.autoClear||F)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),V&&(V.isCubeTexture||V.isWebGLCubeRenderTarget||V.mapping===ph)){r===void 0&&(r=new Ai(new vf(1,1,1),new Ur({type:"BackgroundCubeMaterial",uniforms:Tc(Ra.cube.uniforms),vertexShader:Ra.cube.vertexShader,fragmentShader:Ra.cube.fragmentShader,side:tr,depthTest:!1,depthWrite:!1,fog:!1})),r.geometry.deleteAttribute("normal"),r.geometry.deleteAttribute("uv"),r.onBeforeRender=function(H,Q,ae){this.matrixWorld.copyPosition(ae.matrixWorld)},Object.defineProperty(r.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(r));var ne=V.isWebGLCubeRenderTarget?V.texture:V;r.material.uniforms.envMap.value=ne,r.material.uniforms.flipEnvMap.value=ne.isCubeTexture?-1:1,(v!==V||x!==ne.version||w!==e.toneMapping)&&(r.material.needsUpdate=!0,v=V,x=ne.version,w=e.toneMapping),L.unshift(r,r.geometry,r.material,0,0,null)}else V&&V.isTexture&&(f===void 0&&(f=new Ai(new Sc(2,2),new Ur({type:"BackgroundMaterial",uniforms:Tc(Ra.background.uniforms),vertexShader:Ra.background.vertexShader,fragmentShader:Ra.background.fragmentShader,side:nc,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(f)),f.material.uniforms.t2D.value=V,V.matrixAutoUpdate===!0&&V.updateMatrix(),f.material.uniforms.uvTransform.value.copy(V.matrix),(v!==V||x!==V.version||w!==e.toneMapping)&&(f.material.needsUpdate=!0,v=V,x=V.version,w=e.toneMapping),L.unshift(f,f.geometry,f.material,0,0,null))}function A(L,P){t.buffers.color.setClear(L.r,L.g,L.b,P,l)}return{getClearColor:function(){return c},setClearColor:function(L,P){c.set(L),h=P!==void 0?P:1,A(c,h)},getClearAlpha:function(){return h},setClearAlpha:function(L){h=L,A(c,h)},render:b}}function xD(e,t,i,l){var c=l.isWebGL2,h;function f(x){h=x}function r(x,w){e.drawArrays(h,x,w),i.update(w,h)}function v(x,w,b,A){if(A!==0){var L,P;if(c)L=e,P="drawArraysInstanced";else if(L=t.get("ANGLE_instanced_arrays"),P="drawArraysInstancedANGLE",L===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}L[P](h,w,b,A),i.update(b,h,A)}}this.setMode=f,this.render=r,this.renderInstances=v}function bD(e,t,i){var l;function c(){if(l!==void 0)return l;var Q=t.get("EXT_texture_filter_anisotropic");return Q!==null?l=e.getParameter(Q.MAX_TEXTURE_MAX_ANISOTROPY_EXT):l=0,l}function h(Q){if(Q==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";Q="mediump"}return Q==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var f=typeof WebGL2RenderingContext!="undefined"&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&e instanceof WebGL2ComputeRenderingContext,r=i.precision!==void 0?i.precision:"highp",v=h(r);v!==r&&(console.warn("THREE.WebGLRenderer:",r,"not supported, using",v,"instead."),r=v);var x=i.logarithmicDepthBuffer===!0,w=e.getParameter(34930),b=e.getParameter(35660),A=e.getParameter(3379),L=e.getParameter(34076),P=e.getParameter(34921),R=e.getParameter(36347),F=e.getParameter(36348),V=e.getParameter(36349),j=b>0,J=f||!!t.get("OES_texture_float"),ne=j&&J,H=f?e.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:c,getMaxPrecision:h,precision:r,logarithmicDepthBuffer:x,maxTextures:w,maxVertexTextures:b,maxTextureSize:A,maxCubemapSize:L,maxAttributes:P,maxVertexUniforms:R,maxVaryings:F,maxFragmentUniforms:V,vertexTextures:j,floatFragmentTextures:J,floatVertexTextures:ne,maxSamples:H}}function wD(){var e=this,t=null,i=0,l=!1,c=!1,h=new $o,f=new pr,r={value:null,needsUpdate:!1};this.uniform=r,this.numPlanes=0,this.numIntersection=0,this.init=function(w,b,A){var L=w.length!==0||b||i!==0||l;return l=b,t=x(w,A,0),i=w.length,L},this.beginShadows=function(){c=!0,x(null)},this.endShadows=function(){c=!1,v()},this.setState=function(w,b,A,L,P,R){if(!l||w===null||w.length===0||c&&!A)c?x(null):v();else{var F=c?0:i,V=F*4,j=P.clippingState||null;r.value=j,j=x(w,L,V,R);for(var J=0;J!==V;++J)j[J]=t[J];P.clippingState=j,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=F}};function v(){r.value!==t&&(r.value=t,r.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function x(w,b,A,L){var P=w!==null?w.length:0,R=null;if(P!==0){if(R=r.value,L!==!0||R===null){var F=A+P*4,V=b.matrixWorldInverse;f.getNormalMatrix(V),(R===null||R.length65535?Eh:Th)(b,1);H.version=P,t.update(H,34963);var Q=c.get(w);Q&&t.remove(Q),c.set(w,H)}function x(w){var b=c.get(w);if(b){var A=w.index;A!==null&&b.version0)return e;var c=t*i,h=l0[c];if(h===void 0&&(h=new Float32Array(c),l0[c]=h),t!==0){l.toArray(h,0);for(var f=1,r=0;f!==t;++f)r+=i,e[f].toArray(h,r)}return h}function _o(e,t){if(e.length!==t.length)return!1;for(var i=0,l=e.length;i/gm;function Vy(e){return e.replace(_P,vP)}function vP(e,t){var i=Zn[t];if(i===void 0)throw new Error("Can not resolve #include <"+t+">");return Vy(i)}var xP=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function w0(e){return e.replace(xP,bP)}function bP(e,t,i,l){for(var c="",h=parseInt(t);h0?e.gammaFactor:1,A=i.isWebGL2?"":mP(i),L=gP(c),P=l.createProgram(),R,F,V=i.numMultiviewViews;if(i.isRawShaderMaterial?(R=[L].filter(Rh).join(` `),R.length>0&&(R+=` `),F=[A,L].filter(Rh).join(` `),F.length>0&&(F+=` `)):(R=[M0(i),"#define SHADER_NAME "+i.shaderName,L,i.instancing?"#define USE_INSTANCING":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+b,"#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 "+x:"",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 "+r:"",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",` `].filter(Rh).join(` `),F=[A,M0(i),"#define SHADER_NAME "+i.shaderName,L,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+b,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 "+v:"",i.envMap?"#define "+x:"",i.envMap?"#define "+w:"",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 "+r:"",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!==Zp?"#define TONE_MAPPING":"",i.toneMapping!==Zp?Zn.tonemapping_pars_fragment:"",i.toneMapping!==Zp?fP("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.outputEncoding||i.mapEncoding||i.matcapEncoding||i.envMapEncoding||i.emissiveMapEncoding||i.lightMapEncoding?Zn.encodings_pars_fragment:"",i.mapEncoding?Ih("mapTexelToLinear",i.mapEncoding):"",i.matcapEncoding?Ih("matcapTexelToLinear",i.matcapEncoding):"",i.envMapEncoding?Ih("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Ih("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMapEncoding?Ih("lightMapTexelToLinear",i.lightMapEncoding):"",i.outputEncoding?pP("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",` `].filter(Rh).join(` `)),h=Vy(h),h=x0(h,i),h=b0(h,i),f=Vy(f),f=x0(f,i),f=b0(f,i),h=w0(h),f=w0(f),i.isWebGL2&&!i.isRawShaderMaterial){var j=!1,J=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&h.match(J)!==null&&f.match(J)!==null&&(j=!0,h=h.replace(J,""),f=f.replace(J,"")),R=[`#version 300 es `,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+R,F=[`#version 300 es `,"#define varying in",j?"":"out highp vec4 pc_fragColor;",j?"":"#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(` `)+` `+F,V>0&&(R=R.replace(`#version 300 es `,[`#version 300 es `,"#extension GL_OVR_multiview2 : require","layout(num_views = "+V+") in;","#define VIEW_ID gl_ViewID_OVR"].join(` `)),R=R.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join(` `),["uniform mat4 modelViewMatrices["+V+"];","uniform mat4 projectionMatrices["+V+"];","uniform mat4 viewMatrices["+V+"];","uniform mat3 normalMatrices["+V+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join(` `)),F=F.replace(`#version 300 es `,[`#version 300 es `,"#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join(` `)),F=F.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+V+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join(` `)))}var ne=R+h,H=F+f,Q=y0(l,35633,ne),ae=y0(l,35632,H);if(l.attachShader(P,Q),l.attachShader(P,ae),i.index0AttributeName!==void 0?l.bindAttribLocation(P,0,i.index0AttributeName):i.morphTargets===!0&&l.bindAttribLocation(P,0,"position"),l.linkProgram(P),e.debug.checkShaderErrors){var ie=l.getProgramInfoLog(P).trim(),le=l.getShaderInfoLog(Q).trim(),fe=l.getShaderInfoLog(ae).trim(),me=!0,he=!0;if(l.getProgramParameter(P,35714)===!1){me=!1;var Oe=v0(l,Q,"vertex"),Ve=v0(l,ae,"fragment");console.error("THREE.WebGLProgram: shader error: ",l.getError(),"35715",l.getProgramParameter(P,35715),"gl.getProgramInfoLog",ie,Oe,Ve)}else ie!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",ie):(le===""||fe==="")&&(he=!1);he&&(this.diagnostics={runnable:me,programLog:ie,vertexShader:{log:le,prefix:R},fragmentShader:{log:fe,prefix:F}})}l.deleteShader(Q),l.deleteShader(ae);var He;this.getUniforms=function(){return He===void 0&&(He=new as(l,P)),He};var at;return this.getAttributes=function(){return at===void 0&&(at=yP(l,P)),at},this.destroy=function(){l.deleteProgram(P),this.program=void 0},this.name=i.shaderName,this.id=hP++,this.cacheKey=t,this.usedTimes=1,this.program=P,this.vertexShader=Q,this.fragmentShader=ae,this.numMultiviewViews=V,this}function AP(e,t,i){var l=[],c=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.floatVertexTextures,r=i.precision,v=i.maxVertexUniforms,x=i.vertexTextures,w={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"},b=["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 A(R,F){var V;if(F){var j=Ra[F];V={name:R.type,uniforms:YE.clone(j.uniforms),vertexShader:j.vertexShader,fragmentShader:j.fragmentShader}}else V={name:R.type,uniforms:R.uniforms,vertexShader:R.vertexShader,fragmentShader:R.fragmentShader};return V}function L(R){var F=R.skeleton,V=F.bones;if(f)return 1024;var j=v,J=Math.floor((j-20)/4),ne=Math.min(J,V.length);return ne0,maxBones:fe,useVertexTexture:f,morphTargets:R.morphTargets,morphNormals:R.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:F.directional.length,numPointLights:F.point.length,numSpotLights:F.spot.length,numRectAreaLights:F.rectArea.length,numHemiLights:F.hemi.length,numDirLightShadows:F.directionalShadowMap.length,numPointLightShadows:F.pointShadowMap.length,numSpotLightShadows:F.spotShadowMap.length,numClippingPlanes:J,numClipIntersection:ne,dithering:R.dithering,shadowMapEnabled:e.shadowMap.enabled&&V.length>0,shadowMapType:e.shadowMap.type,toneMapping:R.toneMapped?e.toneMapping:Zp,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:R.premultipliedAlpha,alphaTest:R.alphaTest,doubleSided:R.side===hh,flipSided:R.side===tr,depthPacking:R.depthPacking!==void 0?R.depthPacking:!1,index0AttributeName:R.index0AttributeName,extensionDerivatives:R.extensions&&R.extensions.derivatives,extensionFragDepth:R.extensions&&R.extensions.frawbuffers,extensionDrawbuffers:R.extensions&&R.extensions.drawbuffers,extensionShaderTextureLOD:R.extensions&&R.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||t.get("EXT_frag_depth")!==null,rendererExtensionDrawBuffers:c||t.get("WEBGL_draw_buffers")!==null,rendererExtensionShaderTextureLod:c||t.get("EXT_shader_texture_lod")!==null,onBeforeCompile:R.onBeforeCompile};return Ve},this.getProgramCacheKey=function(R){var F=[];if(R.shaderID?F.push(R.shaderID):(F.push(R.fragmentShader),F.push(R.vertexShader)),R.defines!==void 0)for(var V in R.defines)F.push(V),F.push(R.defines[V]);if(R.isRawShaderMaterial===void 0){for(var j=0;j1&&i.sort(w||PP),l.length>1&&l.sort(b||SP)}return{opaque:i,transparent:l,init:h,push:r,unshift:v,sort:x}}function LP(){var e=new WeakMap;function t(c){var h=c.target;h.removeEventListener("dispose",t),e.delete(h)}function i(c,h){var f=e.get(c),r;return f===void 0?(r=new T0,e.set(c,new WeakMap),e.get(c).set(h,r),c.addEventListener("dispose",t)):(r=f.get(h),r===void 0&&(r=new T0,f.set(h,r))),r}function l(){e=new WeakMap}return{get:i,dispose:l}}function IP(){var e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new Pe,color:new tn,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"SpotLight":i={position:new Pe,direction:new Pe,color:new tn,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"PointLight":i={position:new Pe,color:new tn,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Lt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new Pe,skyColor:new tn,groundColor:new tn};break;case"RectAreaLight":i={color:new tn,position:new Pe,halfWidth:new Pe,halfHeight:new Pe};break}return e[t.id]=i,i}}}var RP=0;function kP(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function zP(){for(var e=new IP,t={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++)t.probe.push(new Pe);var l=new Pe,c=new Hn,h=new Hn;function f(r,v,x){for(var w=0,b=0,A=0,L=0;L<9;L++)t.probe[L].set(0,0,0);var P=0,R=0,F=0,V=0,j=0,J=0,ne=0,H=0,Q=x.matrixWorldInverse;r.sort(kP);for(var L=0,ae=r.length;L void main() { float mean = 0.0; float squared_mean = 0.0; float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) ); for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) { #ifdef HORIZONAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean * HALF_SAMPLE_RATE; squared_mean = squared_mean * HALF_SAMPLE_RATE; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`,OP=`void main() { gl_Position = vec4( position, 1.0 ); }`;function C0(e,t,i){var l=new Ph,c=new Lt,h=new Lt,f=new gi,r=[],v=[],x={},w={0:tr,1:nc,2:hh},b=new Ur({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lt},radius:{value:4}},vertexShader:OP,fragmentShader:BP}),A=b.clone();A.defines.HORIZONAL_PASS=1;var L=new vn;L.setAttribute("position",new kn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var P=new Ai(L,b),R=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yx,this.render=function(H,Q,ae){if(R.enabled!==!1&&!(R.autoUpdate===!1&&R.needsUpdate===!1)&&H.length!==0){var ie=e.getRenderTarget(),le=e.getActiveCubeFace(),fe=e.getActiveMipmapLevel(),me=e.state;me.setBlending(es),me.buffers.color.setClear(1,1,1,1),me.buffers.depth.setTest(!0),me.setScissorTest(!1);for(var he=0,Oe=H.length;hei||c.y>i)&&(console.warn("THREE.WebGLShadowMap:",Ve,"has shadow exceeding max texture size, reducing"),c.x>i&&(h.x=Math.floor(i/at.x),c.x=h.x*at.x,He.mapSize.x=h.x),c.y>i&&(h.y=Math.floor(i/at.y),c.y=h.y*at.y,He.mapSize.y=h.y)),He.map===null&&!He.isPointLightShadow&&this.type===uh){var At={minFilter:$i,magFilter:$i,format:Ao};He.map=new Tr(c.x,c.y,At),He.map.texture.name=Ve.name+".shadowMap",He.mapPass=new Tr(c.x,c.y,At),He.camera.updateProjectionMatrix()}if(He.map===null){var At={minFilter:Ui,magFilter:Ui,format:Ao};He.map=new Tr(c.x,c.y,At),He.map.texture.name=Ve.name+".shadowMap",He.camera.updateProjectionMatrix()}e.setRenderTarget(He.map),e.clear();for(var yt=He.getViewportCount(),Dt=0;Dt0:me.isGeometry===!0&&(He=me.morphTargets&&me.morphTargets.length>0));var at=!1;H.isSkinnedMesh===!0&&(Q.skinning===!0?at=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",H));var At=H.isInstancedMesh===!0;he=Oe(He,at,At)}else he=Ve;if(e.localClippingEnabled&&Q.clipShadows===!0&&Q.clippingPlanes.length!==0){var yt=he.uuid,Dt=Q.uuid,It=x[yt];It===void 0&&(It={},x[yt]=It);var Nt=It[Dt];Nt===void 0&&(Nt=he.clone(),It[Dt]=Nt),he=Nt}return he.visible=Q.visible,he.wireframe=Q.wireframe,fe===uh?he.side=Q.shadowSide!==null?Q.shadowSide:Q.side:he.side=Q.shadowSide!==null?Q.shadowSide:w[Q.side],he.clipShadows=Q.clipShadows,he.clippingPlanes=Q.clippingPlanes,he.clipIntersection=Q.clipIntersection,he.wireframeLinewidth=Q.wireframeLinewidth,he.linewidth=Q.linewidth,ae.isPointLight===!0&&he.isMeshDistanceMaterial===!0&&(he.referencePosition.setFromMatrixPosition(ae.matrixWorld),he.nearDistance=ie,he.farDistance=le),he}function ne(H,Q,ae,ie,le){if(H.visible!==!1){var fe=H.layers.test(Q.layers);if(fe&&(H.isMesh||H.isLine||H.isPoints)&&(H.castShadow||H.receiveShadow&&le===uh)&&(!H.frustumCulled||l.intersectsObject(H))){H.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,H.matrixWorld);var me=t.update(H),he=H.material;if(Array.isArray(he))for(var Oe=me.groups,Ve=0,He=Oe.length;Ve=1):At.indexOf("OpenGL ES")!==-1&&(at=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(At)[1]),He=at>=2);var yt=null,Dt={},It=new gi,Nt=new gi;function Ie(Xe,Ut,en){var Pn=new Uint8Array(4),fn=e.createTexture();e.bindTexture(Xe,fn),e.texParameteri(Xe,10241,9728),e.texParameteri(Xe,10240,9728);for(var On=0;Ongt||pe.height>gt)&&(bn=gt/Math.max(pe.width,pe.height)),bn<1||Me===!0)if(typeof HTMLImageElement!="undefined"&&pe instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&pe instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&pe instanceof ImageBitmap){var hn=Me?jn.floorPowerOfTwo:Math.floor,nn=hn(bn*pe.width),pn=hn(bn*pe.height);L===void 0&&(L=R(nn,pn));var wn=bt?R(nn,pn):L;wn.width=nn,wn.height=pn;var cn=wn.getContext("2d");return cn.drawImage(pe,0,0,nn,pn),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+pe.width+"x"+pe.height+") to ("+nn+"x"+pn+")."),wn}else return"data"in pe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+pe.width+"x"+pe.height+")."),pe;return pe}function V(pe){return jn.isPowerOfTwo(pe.width)&&jn.isPowerOfTwo(pe.height)}function j(pe){return r?!1:pe.wrapS!==Mr||pe.wrapT!==Mr||pe.minFilter!==Ui&&pe.minFilter!==$i}function J(pe,Me){return pe.generateMipmaps&&Me&&pe.minFilter!==Ui&&pe.minFilter!==$i}function ne(pe,Me,bt,gt){e.generateMipmap(pe);var bn=l.get(Me);bn.__maxMipLevel=Math.log(Math.max(bt,gt))*Math.LOG2E}function H(pe,Me,bt){if(r===!1)return Me;if(pe!==null){if(e[pe]!==void 0)return e[pe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+pe+"'")}var gt=Me;return Me===6403&&(bt===5126&&(gt=33326),bt===5131&&(gt=33325),bt===5121&&(gt=33321)),Me===6407&&(bt===5126&&(gt=34837),bt===5131&&(gt=34843),bt===5121&&(gt=32849)),Me===6408&&(bt===5126&&(gt=34836),bt===5131&&(gt=34842),bt===5121&&(gt=32856)),gt===33325||gt===33326||gt===34842||gt===34836?t.get("EXT_color_buffer_float"):(gt===34843||gt===34837)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),gt}function Q(pe){return pe===Ui||pe===Yp||pe===Kp?9728:9729}function ae(pe){var Me=pe.target;Me.removeEventListener("dispose",ae),le(Me),Me.isVideoTexture&&A.delete(Me),f.memory.textures--}function ie(pe){var Me=pe.target;Me.removeEventListener("dispose",ie),fe(Me),f.memory.textures--}function le(pe){var Me=l.get(pe);Me.__webglInit!==void 0&&(e.deleteTexture(Me.__webglTexture),l.remove(pe))}function fe(pe){var Me=l.get(pe),bt=l.get(pe.texture);if(pe){if(bt.__webglTexture!==void 0&&e.deleteTexture(bt.__webglTexture),pe.depthTexture&&pe.depthTexture.dispose(),pe.isWebGLCubeRenderTarget)for(var gt=0;gt<6;gt++)e.deleteFramebuffer(Me.__webglFramebuffer[gt]),Me.__webglDepthbuffer&&e.deleteRenderbuffer(Me.__webglDepthbuffer[gt]);else e.deleteFramebuffer(Me.__webglFramebuffer),Me.__webglDepthbuffer&&e.deleteRenderbuffer(Me.__webglDepthbuffer);if(pe.isWebGLMultiviewRenderTarget){e.deleteTexture(Me.__webglColorTexture),e.deleteTexture(Me.__webglDepthStencilTexture),f.memory.textures-=2;for(var gt=0,bn=Me.__webglViewFramebuffers.length;gt=v&&console.warn("THREE.WebGLTextures: Trying to use "+pe+" texture units while this GPU supports only "+v),me+=1,pe}function Ve(pe,Me){var bt=l.get(pe);if(pe.isVideoTexture&&Ne(pe),pe.version>0&&bt.__version!==pe.version){var gt=pe.image;if(gt===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(gt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{be(bt,pe,Me);return}}i.activeTexture(33984+Me),i.bindTexture(3553,bt.__webglTexture)}function He(pe,Me){var bt=l.get(pe);if(pe.version>0&&bt.__version!==pe.version){be(bt,pe,Me);return}i.activeTexture(33984+Me),i.bindTexture(35866,bt.__webglTexture)}function at(pe,Me){var bt=l.get(pe);if(pe.version>0&&bt.__version!==pe.version){be(bt,pe,Me);return}i.activeTexture(33984+Me),i.bindTexture(32879,bt.__webglTexture)}function At(pe,Me){if(pe.image.length===6){var bt=l.get(pe);if(pe.version>0&&bt.__version!==pe.version){Ie(bt,pe),i.activeTexture(33984+Me),i.bindTexture(34067,bt.__webglTexture),e.pixelStorei(37440,pe.flipY);for(var gt=pe&&(pe.isCompressedTexture||pe.image[0].isCompressedTexture),bn=pe.image[0]&&pe.image[0].isDataTexture,hn=[],nn=0;nn<6;nn++)!gt&&!bn?hn[nn]=F(pe.image[nn],!1,!0,x):hn[nn]=bn?pe.image[nn].image:pe.image[nn];var pn=hn[0],wn=V(pn)||r,cn=h.convert(pe.format),Wt=h.convert(pe.type),sn=H(pe.internalFormat,cn,Wt);Nt(34067,pe,wn);var Xt;if(gt){for(var nn=0;nn<6;nn++){Xt=hn[nn].mipmaps;for(var Xe=0;Xe1||l.get(Me).__currentAnisotropy)&&(e.texParameterf(pe,gt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Me.anisotropy,c.getMaxAnisotropy())),l.get(Me).__currentAnisotropy=Me.anisotropy)}}function Ie(pe,Me){pe.__webglInit===void 0&&(pe.__webglInit=!0,Me.addEventListener("dispose",ae),pe.__webglTexture=e.createTexture(),f.memory.textures++)}function be(pe,Me,bt){var gt=3553;Me.isDataTexture2DArray&&(gt=35866),Me.isDataTexture3D&&(gt=32879),Ie(pe,Me),i.activeTexture(33984+bt),i.bindTexture(gt,pe.__webglTexture),e.pixelStorei(37440,Me.flipY),e.pixelStorei(37441,Me.premultiplyAlpha),e.pixelStorei(3317,Me.unpackAlignment);var bn=j(Me)&&V(Me.image)===!1,hn=F(Me.image,bn,!1,w),nn=V(hn)||r,pn=h.convert(Me.format),wn=h.convert(Me.type),cn=H(Me.internalFormat,pn,wn);Nt(gt,Me,nn);var Wt,sn=Me.mipmaps;if(Me.isDepthTexture){if(cn=6402,Me.type===mh){if(r===!1)throw new Error("Float Depth Texture only supported in WebGL2.0");cn=36012}else r&&(cn=33189);Me.format===ac&&cn===6402&&Me.type!==Qp&&Me.type!==Sx&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),Me.type=Qp,wn=h.convert(Me.type)),Me.format===gh&&(cn=34041,Me.type!==ef&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),Me.type=ef,wn=h.convert(Me.type))),i.texImage2D(3553,0,cn,hn.width,hn.height,0,pn,wn,null)}else if(Me.isDataTexture)if(sn.length>0&&nn){for(var Xt=0,Xe=sn.length;Xt0&&nn){for(var Xt=0,Xe=sn.length;XtA)return!1;for(var le=1,fe=ie.length;le=0){var Ln=Tt[rn];if(Ln!==void 0){var Mt=Ln.normalized,un=Ln.itemSize,Kt=ct.get(Ln);if(Kt===void 0)continue;var mn=Kt.buffer,Tn=Kt.type,Cn=Kt.bytesPerElement;if(Ln.isInterleavedBufferAttribute){var di=Ln.data,Dr=di.stride,oi=Ln.offset;di&&di.isInstancedInterleavedBuffer?(Ae.enableAttributeAndDivisor(Sn,di.meshPerAttribute),re.maxInstancedCount===void 0&&(re.maxInstancedCount=di.meshPerAttribute*di.count)):Ae.enableAttribute(Sn),ke.bindBuffer(34962,mn),ke.vertexAttribPointer(Sn,un,Tn,Mt,Dr*Cn,oi*Cn)}else Ln.isInstancedBufferAttribute?(Ae.enableAttributeAndDivisor(Sn,Ln.meshPerAttribute),re.maxInstancedCount===void 0&&(re.maxInstancedCount=Ln.meshPerAttribute*Ln.count)):Ae.enableAttribute(Sn),ke.bindBuffer(34962,mn),ke.vertexAttribPointer(Sn,un,Tn,Mt,0,0)}else if(rn==="instanceMatrix"){var Kt=ct.get(Y.instanceMatrix);if(Kt===void 0)continue;var mn=Kt.buffer,Tn=Kt.type;Ae.enableAttributeAndDivisor(Sn+0,1),Ae.enableAttributeAndDivisor(Sn+1,1),Ae.enableAttributeAndDivisor(Sn+2,1),Ae.enableAttributeAndDivisor(Sn+3,1),ke.bindBuffer(34962,mn),ke.vertexAttribPointer(Sn+0,4,Tn,!1,64,0),ke.vertexAttribPointer(Sn+1,4,Tn,!1,64,16),ke.vertexAttribPointer(Sn+2,4,Tn,!1,64,32),ke.vertexAttribPointer(Sn+3,4,Tn,!1,64,48)}else if(Ot!==void 0){var li=Ot[rn];if(li!==void 0)switch(li.length){case 2:ke.vertexAttrib2fv(Sn,li);break;case 3:ke.vertexAttrib3fv(Sn,li);break;case 4:ke.vertexAttrib4fv(Sn,li);break;default:ke.vertexAttrib1fv(Sn,li)}}}}Ae.disableUnusedAttributes()}}this.compile=function(Y,re){A=bt.get(Y,re),A.init(),Y.traverse(function(Te){Te.isLight&&(A.pushLight(Te),Te.castShadow&&A.pushShadow(Te))}),A.setupLights(re);var Fe={};Y.traverse(function(Te){if(Te.material)if(Array.isArray(Te.material))for(var Tt=0;Tt=0&&Y.numSupportedMorphTargets++}if(Y.morphNormals){Y.numSupportedMorphNormals=0;for(var Kt=0;Kt=0&&Y.numSupportedMorphNormals++}var mn=Te.uniforms;(!Y.isShaderMaterial&&!Y.isRawShaderMaterial||Y.clipping===!0)&&(Te.numClippingPlanes=It.numPlanes,Te.numIntersection=It.numIntersection,mn.clippingPlanes=It.uniform),Te.fog=re.fog,Te.needsLights=_n(Y),Te.lightsStateVersion=Ot,Te.needsLights&&(mn.ambientLightColor.value=Tt.state.ambient,mn.lightProbe.value=Tt.state.probe,mn.directionalLights.value=Tt.state.directional,mn.spotLights.value=Tt.state.spot,mn.rectAreaLights.value=Tt.state.rectArea,mn.pointLights.value=Tt.state.point,mn.hemisphereLights.value=Tt.state.hemi,mn.directionalShadowMap.value=Tt.state.directionalShadowMap,mn.directionalShadowMatrix.value=Tt.state.directionalShadowMatrix,mn.spotShadowMap.value=Tt.state.spotShadowMap,mn.spotShadowMatrix.value=Tt.state.spotShadowMatrix,mn.pointShadowMap.value=Tt.state.pointShadowMap,mn.pointShadowMatrix.value=Tt.state.pointShadowMatrix);var Tn=Te.program.getUniforms(),Cn=as.seqWithValue(Tn.seq,mn);Te.uniformsList=Cn}function jr(Y,re,Fe,Te){Je.resetTextureUnits();var Tt=re.fog,_t=Fe.isMeshStandardMaterial?re.environment:null,Ot=Ne.get(Fe),rn=A.state.lights;if(Nt&&(Ie||Y!==Q)){var Sn=Y===Q&&Fe.id===ne;It.setState(Fe.clippingPlanes,Fe.clipIntersection,Fe.clipShadows,Y,Ot,Sn)}Fe.version===Ot.__version?(Ot.program===void 0||Fe.fog&&Ot.fog!==Tt||Ot.environment!==_t||Ot.needsLights&&Ot.lightsStateVersion!==rn.state.version||Ot.numClippingPlanes!==void 0&&(Ot.numClippingPlanes!==It.numPlanes||Ot.numIntersection!==It.numIntersection)||Ot.outputEncoding!==L.outputEncoding)&&_i(Fe,re,Te):(_i(Fe,re,Te),Ot.__version=Fe.version);var Ln=!1,Mt=!1,un=!1,Kt=Ot.program,mn=Kt.getUniforms(),Tn=Ot.uniforms;if(Ae.useProgram(Kt.program)&&(Ln=!0,Mt=!0,un=!0),Fe.id!==ne&&(ne=Fe.id,Mt=!0),Ln||Q!==Y){if(Kt.numMultiviewViews>0?Wt.updateCameraProjectionMatricesUniform(Y,mn):mn.setValue(ke,"projectionMatrix",Y.projectionMatrix),Ce.logarithmicDepthBuffer&&mn.setValue(ke,"logDepthBufFC",2/(Math.log(Y.far+1)/Math.LN2)),Q!==Y&&(Q=Y,Mt=!0,un=!0),Fe.isShaderMaterial||Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshStandardMaterial||Fe.envMap){var Cn=mn.map.cameraPosition;Cn!==void 0&&Cn.setValue(ke,We.setFromMatrixPosition(Y.matrixWorld))}(Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshLambertMaterial||Fe.isMeshBasicMaterial||Fe.isMeshStandardMaterial||Fe.isShaderMaterial)&&mn.setValue(ke,"isOrthographic",Y.isOrthographicCamera===!0),(Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshLambertMaterial||Fe.isMeshBasicMaterial||Fe.isMeshStandardMaterial||Fe.isShaderMaterial||Fe.skinning)&&(Kt.numMultiviewViews>0?Wt.updateCameraViewMatricesUniform(Y,mn):mn.setValue(ke,"viewMatrix",Y.matrixWorldInverse))}if(Fe.skinning){mn.setOptional(ke,Te,"bindMatrix"),mn.setOptional(ke,Te,"bindMatrixInverse");var di=Te.skeleton;if(di){var Dr=di.bones;if(Ce.floatVertexTextures){if(di.boneTexture===void 0){var oi=Math.sqrt(Dr.length*4);oi=jn.ceilPowerOfTwo(oi),oi=Math.max(oi,4);var li=new Float32Array(oi*oi*4);li.set(di.boneMatrices);var ai=new Dc(li,oi,oi,Ao,mh);di.boneMatrices=li,di.boneTexture=ai,di.boneTextureSize=oi}mn.setValue(ke,"boneTexture",di.boneTexture,Je),mn.setValue(ke,"boneTextureSize",di.boneTextureSize)}else mn.setOptional(ke,di,"boneMatrices")}}return(Mt||Ot.receiveShadow!==Te.receiveShadow)&&(Ot.receiveShadow=Te.receiveShadow,mn.setValue(ke,"receiveShadow",Te.receiveShadow)),Mt&&(mn.setValue(ke,"toneMappingExposure",L.toneMappingExposure),mn.setValue(ke,"toneMappingWhitePoint",L.toneMappingWhitePoint),Ot.needsLights&&Ct(Tn,un),Tt&&Fe.fog&&ee(Tn,Tt),Fe.isMeshBasicMaterial?zi(Tn,Fe):Fe.isMeshLambertMaterial?(zi(Tn,Fe),ye(Tn,Fe)):Fe.isMeshToonMaterial?(zi(Tn,Fe),je(Tn,Fe)):Fe.isMeshPhongMaterial?(zi(Tn,Fe),Re(Tn,Fe)):Fe.isMeshStandardMaterial?(zi(Tn,Fe,_t),Fe.isMeshPhysicalMaterial?tt(Tn,Fe,_t):et(Tn,Fe,_t)):Fe.isMeshMatcapMaterial?(zi(Tn,Fe),qe(Tn,Fe)):Fe.isMeshDepthMaterial?(zi(Tn,Fe),rt(Tn,Fe)):Fe.isMeshDistanceMaterial?(zi(Tn,Fe),vt(Tn,Fe)):Fe.isMeshNormalMaterial?(zi(Tn,Fe),Vt(Tn,Fe)):Fe.isLineBasicMaterial?(Hr(Tn,Fe),Fe.isLineDashedMaterial&&Ar(Tn,Fe)):Fe.isPointsMaterial?we(Tn,Fe):Fe.isSpriteMaterial?$(Tn,Fe):Fe.isShadowMaterial&&(Tn.color.value.copy(Fe.color),Tn.opacity.value=Fe.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(ke,Ot.uniformsList,Tn,Je),Fe.isShaderMaterial&&(Fe.uniformsNeedUpdate=!1)),Fe.isShaderMaterial&&Fe.uniformsNeedUpdate===!0&&(as.upload(ke,Ot.uniformsList,Tn,Je),Fe.uniformsNeedUpdate=!1),Fe.isSpriteMaterial&&mn.setValue(ke,"center",Te.center),Kt.numMultiviewViews>0?Wt.updateObjectMatricesUniforms(Te,Y,mn):(mn.setValue(ke,"modelViewMatrix",Te.modelViewMatrix),mn.setValue(ke,"normalMatrix",Te.normalMatrix)),mn.setValue(ke,"modelMatrix",Te.matrixWorld),Kt}function zi(Y,re,Fe){Y.opacity.value=re.opacity,re.color&&Y.diffuse.value.copy(re.color),re.emissive&&Y.emissive.value.copy(re.emissive).multiplyScalar(re.emissiveIntensity),re.map&&(Y.map.value=re.map),re.alphaMap&&(Y.alphaMap.value=re.alphaMap),re.specularMap&&(Y.specularMap.value=re.specularMap);var Te=re.envMap||Fe;Te&&(Y.envMap.value=Te,Y.flipEnvMap.value=Te.isCubeTexture?-1:1,Y.reflectivity.value=re.reflectivity,Y.refractionRatio.value=re.refractionRatio,Y.maxMipLevel.value=Ne.get(Te).__maxMipLevel),re.lightMap&&(Y.lightMap.value=re.lightMap,Y.lightMapIntensity.value=re.lightMapIntensity),re.aoMap&&(Y.aoMap.value=re.aoMap,Y.aoMapIntensity.value=re.aoMapIntensity);var Tt;re.map?Tt=re.map:re.specularMap?Tt=re.specularMap:re.displacementMap?Tt=re.displacementMap:re.normalMap?Tt=re.normalMap:re.bumpMap?Tt=re.bumpMap:re.roughnessMap?Tt=re.roughnessMap:re.metalnessMap?Tt=re.metalnessMap:re.alphaMap?Tt=re.alphaMap:re.emissiveMap&&(Tt=re.emissiveMap),Tt!==void 0&&(Tt.isWebGLRenderTarget&&(Tt=Tt.texture),Tt.matrixAutoUpdate===!0&&Tt.updateMatrix(),Y.uvTransform.value.copy(Tt.matrix));var _t;re.aoMap?_t=re.aoMap:re.lightMap&&(_t=re.lightMap),_t!==void 0&&(_t.isWebGLRenderTarget&&(_t=_t.texture),_t.matrixAutoUpdate===!0&&_t.updateMatrix(),Y.uv2Transform.value.copy(_t.matrix))}function Hr(Y,re){Y.diffuse.value.copy(re.color),Y.opacity.value=re.opacity}function Ar(Y,re){Y.dashSize.value=re.dashSize,Y.totalSize.value=re.dashSize+re.gapSize,Y.scale.value=re.scale}function we(Y,re){Y.diffuse.value.copy(re.color),Y.opacity.value=re.opacity,Y.size.value=re.size*Oe,Y.scale.value=he*.5,re.map&&(Y.map.value=re.map),re.alphaMap&&(Y.alphaMap.value=re.alphaMap);var Fe;re.map?Fe=re.map:re.alphaMap&&(Fe=re.alphaMap),Fe!==void 0&&(Fe.matrixAutoUpdate===!0&&Fe.updateMatrix(),Y.uvTransform.value.copy(Fe.matrix))}function $(Y,re){Y.diffuse.value.copy(re.color),Y.opacity.value=re.opacity,Y.rotation.value=re.rotation,re.map&&(Y.map.value=re.map),re.alphaMap&&(Y.alphaMap.value=re.alphaMap);var Fe;re.map?Fe=re.map:re.alphaMap&&(Fe=re.alphaMap),Fe!==void 0&&(Fe.matrixAutoUpdate===!0&&Fe.updateMatrix(),Y.uvTransform.value.copy(Fe.matrix))}function ee(Y,re){Y.fogColor.value.copy(re.color),re.isFog?(Y.fogNear.value=re.near,Y.fogFar.value=re.far):re.isFogExp2&&(Y.fogDensity.value=re.density)}function ye(Y,re){re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap)}function Re(Y,re){Y.specular.value.copy(re.specular),Y.shininess.value=Math.max(re.shininess,1e-4),re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function je(Y,re){Y.specular.value.copy(re.specular),Y.shininess.value=Math.max(re.shininess,1e-4),re.gradientMap&&(Y.gradientMap.value=re.gradientMap),re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function et(Y,re,Fe){Y.roughness.value=re.roughness,Y.metalness.value=re.metalness,re.roughnessMap&&(Y.roughnessMap.value=re.roughnessMap),re.metalnessMap&&(Y.metalnessMap.value=re.metalnessMap),re.emissiveMap&&(Y.emissiveMap.value=re.emissiveMap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias),(re.envMap||Fe)&&(Y.envMapIntensity.value=re.envMapIntensity)}function tt(Y,re,Fe){et(Y,re,Fe),Y.reflectivity.value=re.reflectivity,Y.clearcoat.value=re.clearcoat,Y.clearcoatRoughness.value=re.clearcoatRoughness,re.sheen&&Y.sheen.value.copy(re.sheen),re.clearcoatNormalMap&&(Y.clearcoatNormalScale.value.copy(re.clearcoatNormalScale),Y.clearcoatNormalMap.value=re.clearcoatNormalMap,re.side===tr&&Y.clearcoatNormalScale.value.negate()),Y.transparency.value=re.transparency}function qe(Y,re){re.matcap&&(Y.matcap.value=re.matcap),re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function rt(Y,re){re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function vt(Y,re){re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias),Y.referencePosition.value.copy(re.referencePosition),Y.nearDistance.value=re.nearDistance,Y.farDistance.value=re.farDistance}function Vt(Y,re){re.bumpMap&&(Y.bumpMap.value=re.bumpMap,Y.bumpScale.value=re.bumpScale,re.side===tr&&(Y.bumpScale.value*=-1)),re.normalMap&&(Y.normalMap.value=re.normalMap,Y.normalScale.value.copy(re.normalScale),re.side===tr&&Y.normalScale.value.negate()),re.displacementMap&&(Y.displacementMap.value=re.displacementMap,Y.displacementScale.value=re.displacementScale,Y.displacementBias.value=re.displacementBias)}function Ct(Y,re){Y.ambientLightColor.needsUpdate=re,Y.lightProbe.needsUpdate=re,Y.directionalLights.needsUpdate=re,Y.pointLights.needsUpdate=re,Y.spotLights.needsUpdate=re,Y.rectAreaLights.needsUpdate=re,Y.hemisphereLights.needsUpdate=re}function _n(Y){return Y.isMeshLambertMaterial||Y.isMeshToonMaterial||Y.isMeshPhongMaterial||Y.isMeshStandardMaterial||Y.isShadowMaterial||Y.isShaderMaterial&&Y.lights===!0}this.setFramebuffer=function(Y){R!==Y&&j===null&&ke.bindFramebuffer(36160,Y),R=Y},this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return j},this.setRenderTarget=function(Y,re,Fe){j=Y,F=re,V=Fe,Y&&Ne.get(Y).__webglFramebuffer===void 0&&Je.setupRenderTarget(Y);var Te=R,Tt=!1;if(Y){var _t=Ne.get(Y).__webglFramebuffer;Y.isWebGLCubeRenderTarget?(Te=_t[re||0],Tt=!0):Y.isWebGLMultisampleRenderTarget?Te=Ne.get(Y).__webglMultisampledFramebuffer:Te=_t,ie.copy(Y.viewport),le.copy(Y.scissor),fe=Y.scissorTest}else ie.copy(at).multiplyScalar(Oe).floor(),le.copy(At).multiplyScalar(Oe).floor(),fe=yt;if(J!==Te&&(ke.bindFramebuffer(36160,Te),J=Te),Ae.viewport(ie),Ae.scissor(le),Ae.setScissorTest(fe),Tt){var Ot=Ne.get(Y.texture);ke.framebufferTexture2D(36160,36064,34069+(re||0),Ot.__webglTexture,Fe||0)}},this.readRenderTargetPixels=function(Y,re,Fe,Te,Tt,_t,Ot){if(!(Y&&Y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}var rn=Ne.get(Y).__webglFramebuffer;if(Y.isWebGLCubeRenderTarget&&Ot!==void 0&&(rn=rn[Ot]),rn){var Sn=!1;rn!==J&&(ke.bindFramebuffer(36160,rn),Sn=!0);try{var Ln=Y.texture,Mt=Ln.format,un=Ln.type;if(Mt!==Ao&&pn.convert(Mt)!==ke.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(un!==Jp&&pn.convert(un)!==ke.getParameter(35738)&&!(un===mh&&(Ce.isWebGL2||ge.get("OES_texture_float")||ge.get("WEBGL_color_buffer_float")))&&!(un===hy&&(Ce.isWebGL2?ge.get("EXT_color_buffer_float"):ge.get("EXT_color_buffer_half_float")))){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ke.checkFramebufferStatus(36160)===36053?re>=0&&re<=Y.width-Te&&Fe>=0&&Fe<=Y.height-Tt&&ke.readPixels(re,Fe,Te,Tt,pn.convert(Mt),pn.convert(un),_t):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Sn&&ke.bindFramebuffer(36160,J)}}},this.copyFramebufferToTexture=function(Y,re,Fe){Fe===void 0&&(Fe=0);var Te=Math.pow(2,-Fe),Tt=Math.floor(re.image.width*Te),_t=Math.floor(re.image.height*Te),Ot=pn.convert(re.format);Je.setTexture2D(re,0),ke.copyTexImage2D(3553,Fe,Ot,Y.x,Y.y,Tt,_t,0),Ae.unbindTexture()},this.copyTextureToTexture=function(Y,re,Fe,Te){var Tt=re.image.width,_t=re.image.height,Ot=pn.convert(Fe.format),rn=pn.convert(Fe.type);Je.setTexture2D(Fe,0),re.isDataTexture?ke.texSubImage2D(3553,Te||0,Y.x,Y.y,Tt,_t,Ot,rn,re.image.data):ke.texSubImage2D(3553,Te||0,Y.x,Y.y,Ot,rn,re.image),Ae.unbindTexture()},this.initTexture=function(Y){Je.setTexture2D(Y,0),Ae.unbindTexture()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function jy(e,t){this.name="",this.color=new tn(e),this.density=t!==void 0?t:25e-5}Object.assign(jy.prototype,{isFogExp2:!0,clone:function(){return new jy(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});function Hy(e,t,i){this.name="",this.color=new tn(e),this.near=t!==void 0?t:1,this.far=i!==void 0?i:1e3}Object.assign(Hy.prototype,{isFog:!0,clone:function(){return new Hy(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});function ka(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=nf,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(ka.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(ka.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,t,i){e*=this.stride,i*=t.stride;for(var l=0,c=this.stride;le.far||t.push({distance:r,point:zh.clone(),uv:lr.getUV(zh,wf,Bh,Mf,S0,$y,L0,new Lt),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return on.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this}});function Tf(e,t,i,l,c,h){zc.subVectors(e,i).addScalar(.5).multiply(l),c!==void 0?(Fh.x=h*zc.x-c*zc.y,Fh.y=c*zc.x+h*zc.y):Fh.copy(zc),e.copy(t),e.x+=Fh.x,e.y+=Fh.y,e.applyMatrix4(P0)}var Ef=new Pe,I0=new Pe;function Cf(){on.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Cf.prototype=Object.assign(Object.create(on.prototype),{constructor:Cf,isLOD:!0,copy:function(e){on.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,l=t.length;i0){for(var i=1,l=t.length;i0){Ef.setFromMatrixPosition(this.matrixWorld);var l=e.ray.origin.distanceTo(Ef);this.getObjectForDistance(l).raycast(e,t)}},update:function(e){var t=this.levels;if(t.length>1){Ef.setFromMatrixPosition(e.matrixWorld),I0.setFromMatrixPosition(this.matrixWorld);var i=Ef.distanceTo(I0);t[0].object.visible=!0;for(var l=1,c=t.length;l=t[l].distance;l++)t[l-1].object.visible=!1,t[l].object.visible=!0;for(;l0&&(Fc[0].instanceId=c,Fc[0].object=this,t.push(Fc[0]),Fc.length=0)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,e*16)},updateMorphTargets:function(){}});function Ri(e){Rn.call(this),this.type="LineBasicMaterial",this.color=new tn(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 F0=new Pe,B0=new Pe,O0=new Hn,Df=new yc,Pf=new Da;function so(e,t,i){i===1&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),on.call(this),this.type="Line",this.geometry=e!==void 0?e:new vn,this.material=t!==void 0?t:new Ri}so.prototype=Object.assign(Object.create(on.prototype),{constructor:so,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var t=e.attributes.position,i=[0],l=1,c=t.count;lf)){w.applyMatrix4(this.matrixWorld);var H=e.ray.origin.distanceTo(w);He.far||t.push({distance:H,point:x.clone().applyMatrix4(this.matrixWorld),index:F,face:null,faceIndex:null,object:this})}}else for(var F=0,V=P.length/3-1;Ff)){w.applyMatrix4(this.matrixWorld);var H=e.ray.origin.distanceTo(w);He.far||t.push({distance:H,point:x.clone().applyMatrix4(this.matrixWorld),index:F,face:null,faceIndex:null,object:this})}}}else if(l.isGeometry)for(var Q=l.vertices,ae=Q.length,F=0;Ff)){w.applyMatrix4(this.matrixWorld);var H=e.ray.origin.distanceTo(w);He.far||t.push({distance:H,point:x.clone().applyMatrix4(this.matrixWorld),index:F,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Sf=new Pe,Lf=new Pe;function Vi(e,t){so.call(this,e,t),this.type="LineSegments"}Vi.prototype=Object.assign(Object.create(so.prototype),{constructor:Vi,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(e.index===null){for(var t=e.attributes.position,i=[],l=0,c=t.count;l0){var f=c[h[0]];if(f!==void 0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,i=f.length;t0&&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 Ky(e,t,i,l,c,h,f){var r=Yy.distanceSqToPoint(e);if(rc.far)return;h.push({distance:x,distanceToRay:Math.sqrt(r),point:v,index:t,face:null,object:f})}}function U0(e,t,i,l,c,h,f,r,v){mi.call(this,e,t,i,l,c,h,f,r,v),this.format=f!==void 0?f:Ma,this.minFilter=h!==void 0?h:$i,this.magFilter=c!==void 0?c:$i,this.generateMipmaps=!1}U0.prototype=Object.assign(Object.create(mi.prototype),{constructor:U0,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Uh(e,t,i,l,c,h,f,r,v,x,w,b){mi.call(this,null,h,f,r,v,x,l,c,w,b),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}Uh.prototype=Object.create(mi.prototype),Uh.prototype.constructor=Uh,Uh.prototype.isCompressedTexture=!0;function Ff(e,t,i,l,c,h,f,r,v){mi.call(this,e,t,i,l,c,h,f,r,v),this.needsUpdate=!0}Ff.prototype=Object.create(mi.prototype),Ff.prototype.constructor=Ff,Ff.prototype.isCanvasTexture=!0;function Bf(e,t,i,l,c,h,f,r,v,x){if(x=x!==void 0?x:ac,x!==ac&&x!==gh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&x===ac&&(i=Qp),i===void 0&&x===gh&&(i=ef),mi.call(this,null,l,c,h,f,r,x,i,v),this.image={width:e,height:t},this.magFilter=f!==void 0?f:Ui,this.minFilter=r!==void 0?r:Ui,this.flipY=!1,this.generateMipmaps=!1}Bf.prototype=Object.create(mi.prototype),Bf.prototype.constructor=Bf,Bf.prototype.isDepthTexture=!0;function Of(e){vn.call(this),this.type="WireframeGeometry";var t=[],i,l,c,h,f,r=[0,0],v={},x,w,b,A,L=["a","b","c"],P;if(e&&e.isGeometry){var R=e.faces;for(i=0,c=R.length;i=0?(e(V-r,F,w),b.subVectors(x,w)):(e(V+r,F,w),b.subVectors(w,x)),F-r>=0?(e(V,F-r,w),A.subVectors(x,w)):(e(V,F+r,w),A.subVectors(w,x)),v.crossVectors(b,A).normalize(),h.push(v.x,v.y,v.z),f.push(V,F)}}for(L=0;L.9&&Q<.1&&(j<.2&&(h[V+0]+=1),J<.2&&(h[V+2]+=1),ne<.2&&(h[V+4]+=1))}}function b(V){c.push(V.x,V.y,V.z)}function A(V,j){var J=V*3;j.x=e[J+0],j.y=e[J+1],j.z=e[J+2]}function L(){for(var V=new Pe,j=new Pe,J=new Pe,ne=new Pe,H=new Lt,Q=new Lt,ae=new Lt,ie=0,le=0;ie80*i){r=x=e[0],v=w=e[1];for(var P=i;Px&&(x=b),A>w&&(w=A);L=Math.max(x-r,w-v),L=L!==0?1/L:0}return Xh(h,f,i,r,v,L),f}};function V0(e,t,i,l,c){var h,f;if(c===oS(e,t,i,l)>0)for(h=t;h=t;h-=l)f=j0(h,e[h],e[h+1],f);return f&&cl(f,f.next)&&(Yh(f),f=f.next),f}function qh(e,t){if(!e)return e;t||(t=e);var i=e,l;do if(l=!1,!i.steiner&&(cl(i,i.next)||ur(i.prev,i,i.next)===0)){if(Yh(i),i=t=i.prev,i===i.next)break;l=!0}else i=i.next;while(l||i!==t);return t}function Xh(e,t,i,l,c,h,f){if(e){!f&&h&&QP(e,l,c,h);for(var r=e,v,x;e.prev!==e.next;){if(v=e.prev,x=e.next,h?$P(e,l,c,h):HP(e)){t.push(v.i/i),t.push(e.i/i),t.push(x.i/i),Yh(e),e=x.next,r=x.next;continue}if(e=x,e===r){f?f===1?(e=qP(e,t,i),Xh(e,t,i,l,c,h,2)):f===2&&XP(e,t,i,l,c,h):Xh(qh(e),t,i,l,c,h,1);break}}}}function HP(e){var t=e.prev,i=e,l=e.next;if(ur(t,i,l)>=0)return!1;for(var c=e.next.next;c!==e.prev;){if(Nc(t.x,t.y,i.x,i.y,l.x,l.y,c.x,c.y)&&ur(c.prev,c,c.next)>=0)return!1;c=c.next}return!0}function $P(e,t,i,l){var c=e.prev,h=e,f=e.next;if(ur(c,h,f)>=0)return!1;for(var r=c.xh.x?c.x>f.x?c.x:f.x:h.x>f.x?h.x:f.x,w=c.y>h.y?c.y>f.y?c.y:f.y:h.y>f.y?h.y:f.y,b=Jy(r,v,t,i,l),A=Jy(x,w,t,i,l),L=e.prevZ,P=e.nextZ;L&&L.z>=b&&P&&P.z<=A;){if(L!==e.prev&&L!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,L.x,L.y)&&ur(L.prev,L,L.next)>=0||(L=L.prevZ,P!==e.prev&&P!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,P.x,P.y)&&ur(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;L&&L.z>=b;){if(L!==e.prev&&L!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,L.x,L.y)&&ur(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;P&&P.z<=A;){if(P!==e.prev&&P!==e.next&&Nc(c.x,c.y,h.x,h.y,f.x,f.y,P.x,P.y)&&ur(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function qP(e,t,i){var l=e;do{var c=l.prev,h=l.next.next;!cl(c,h)&&G0(c,l,l.next,h)&&Zh(c,h)&&Zh(h,c)&&(t.push(c.i/i),t.push(l.i/i),t.push(h.i/i),Yh(l),Yh(l.next),l=e=h),l=l.next}while(l!==e);return l}function XP(e,t,i,l,c,h){var f=e;do{for(var r=f.next.next;r!==f.prev;){if(f.i!==r.i&&nS(f,r)){var v=W0(f,r);f=qh(f,f.next),v=qh(v,v.next),Xh(f,t,i,l,c,h),Xh(v,t,i,l,c,h);return}r=r.next}f=f.next}while(f!==e)}function ZP(e,t,i,l){var c=[],h,f,r,v,x;for(h=0,f=t.length;h=i.next.y&&i.next.y!==i.y){var r=i.x+(c-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(r<=l&&r>h){if(h=r,r===l){if(c===i.y)return i;if(c===i.next.y)return i.next}f=i.x=i.x&&i.x>=x&&l!==i.x&&Nc(cf.x)&&Zh(i,e)&&(f=i,b=A)),i=i.next;return f}function QP(e,t,i,l){var c=e;do c.z===null&&(c.z=Jy(c.x,c.y,t,i,l)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next;while(c!==e);c.prevZ.nextZ=null,c.prevZ=null,eS(c)}function eS(e){var t,i,l,c,h,f,r,v,x=1;do{for(i=e,e=null,h=null,f=0;i;){for(f++,l=i,r=0,t=0;t0||v>0&&l;)r!==0&&(v===0||!l||i.z<=l.z)?(c=i,i=i.nextZ,r--):(c=l,l=l.nextZ,v--),h?h.nextZ=c:e=c,c.prevZ=h,h=c;i=l}h.nextZ=null,x*=2}while(f>1);return e}function Jy(e,t,i,l,c){return e=32767*(e-i)*c,t=32767*(t-l)*c,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function tS(e){var t=e,i=e;do(t.x=0&&(e-f)*(l-r)-(i-f)*(t-r)>=0&&(i-f)*(h-r)-(c-f)*(l-r)>=0}function nS(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!iS(e,t)&&Zh(e,t)&&Zh(t,e)&&rS(e,t)}function ur(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function cl(e,t){return e.x===t.x&&e.y===t.y}function G0(e,t,i,l){return cl(e,i)&&cl(t,l)||cl(e,l)&&cl(i,t)?!0:ur(e,t,i)>0!=ur(e,t,l)>0&&ur(i,l,e)>0!=ur(i,l,t)>0}function iS(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&G0(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Zh(e,t){return ur(e.prev,e,e.next)<0?ur(e,t,e.next)>=0&&ur(e,e.prev,t)>=0:ur(e,t,e.prev)<0||ur(e,e.next,t)<0}function rS(e,t){var i=e,l=!1,c=(e.x+t.x)/2,h=(e.y+t.y)/2;do i.y>h!=i.next.y>h&&i.next.y!==i.y&&c<(i.next.x-i.x)*(h-i.y)/(i.next.y-i.y)+i.x&&(l=!l),i=i.next;while(i!==e);return l}function W0(e,t){var i=new Qy(e.i,e.x,e.y),l=new Qy(t.i,t.x,t.y),c=e.next,h=t.prev;return e.next=t,t.prev=e,i.next=c,c.prev=i,l.next=i,i.prev=l,h.next=l,l.prev=h,l}function j0(e,t,i,l){var c=new Qy(e,t,i);return l?(c.next=l.next,c.prev=l,l.next.prev=c,l.next=c):(c.prev=c,c.next=c),c}function Yh(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 Qy(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function oS(e,t,i,l){for(var c=0,h=t,f=i-l;h2&&e[t-1].equals(e[0])&&e.pop()}function $0(e,t){for(var i=0;iNumber.EPSILON){var Nn=Math.sqrt(qn),Di=Math.sqrt(On*On+Gn*Gn),ei=sn.x-fn/Nn,Ji=sn.y+Pn/Nn,_i=Xt.x-Gn/Di,jr=Xt.y+On/Di,zi=((_i-ei)*Gn-(jr-Ji)*On)/(Pn*Gn-fn*On);Xe=ei+Pn*zi-Wt.x,Ut=Ji+fn*zi-Wt.y;var Hr=Xe*Xe+Ut*Ut;if(Hr<=2)return new Lt(Xe,Ut);en=Math.sqrt(Hr/2)}else{var Ar=!1;Pn>Number.EPSILON?On>Number.EPSILON&&(Ar=!0):Pn<-Number.EPSILON?On<-Number.EPSILON&&(Ar=!0):Math.sign(fn)===Math.sign(Gn)&&(Ar=!0),Ar?(Xe=-fn,Ut=Pn,en=Math.sqrt(qn)):(Xe=Pn,Ut=fn,en=Math.sqrt(qn/2))}return new Lt(Xe/en,Ut/en)}for(var Ae=[],_e=0,Ne=Dt.length,Je=Ne-1,ct=_e+1;_e=0;Nt--){for(be=Nt/j,We=R*Math.cos(be*Math.PI/2),Ie=F*Math.sin(be*Math.PI/2)+V,_e=0,Ne=Dt.length;_e=0;){Xt=_e,Xe=_e-1,Xe<0&&(Xe=Wt.length-1);var Ut=0,en=A+j*2;for(Ut=0;Ut0)&&P.push(Q,ae,le),(x!==i-1||r0&&j(!0),t>0&&j(!1)),this.setIndex(x),this.setAttribute("position",new ln(w,3)),this.setAttribute("normal",new ln(b,3)),this.setAttribute("uv",new ln(A,2));function V(){var J,ne,H=new Pe,Q=new Pe,ae=0,ie=(t-e)/i;for(ne=0;ne<=c;ne++){var le=[],fe=ne/c,me=fe*(t-e)+e;for(J=0;J<=l;J++){var he=J/l,Oe=he*r+f,Ve=Math.sin(Oe),He=Math.cos(Oe);Q.x=me*Ve,Q.y=-fe*i+R,Q.z=me*He,w.push(Q.x,Q.y,Q.z),H.set(Ve,ie,He).normalize(),b.push(H.x,H.y,H.z),A.push(he,1-fe),le.push(L++)}P.push(le)}for(J=0;J=l)){w.push(v.times[A]);for(var P=0;Ph.tracks[r].times[0]&&(R=h.tracks[r].times[0]);for(var r=0;r=c)){var r=t[1];e=c)break t}h=i,i=0;break n}break e}for(;i>>1;et;)--h;if(++h,c!==0||h!==l){c>=h&&(h=Math.max(h,1),c=h-1);var f=this.getValueSize();this.times=Gi.arraySlice(i,c,h),this.values=Gi.arraySlice(this.values,c*f,h*f)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var i=this.times,l=this.values,c=i.length;c===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var h=null,f=0;f!==c;f++){var r=i[f];if(typeof r=="number"&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,r),e=!1;break}if(h!==null&&h>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,r,h),e=!1;break}h=r}if(l!==void 0&&Gi.isTypedArray(l))for(var f=0,v=l.length;f!==v;++f){var x=l[f];if(isNaN(x)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,x),e=!1;break}}return e},optimize:function(){for(var e=Gi.arraySlice(this.times),t=Gi.arraySlice(this.values),i=this.getValueSize(),l=this.getInterpolation()===dy,c=1,h=e.length-1,f=1;f0){e[c]=e[h];for(var R=h*i,F=c*i,L=0;L!==i;++L)t[F+L]=t[R+L];++c}return c!==e.length?(this.times=Gi.arraySlice(e,0,c),this.values=Gi.arraySlice(t,0,c*i)):(this.times=e,this.values=t),this},clone:function(){var e=Gi.arraySlice(this.times,0),t=Gi.arraySlice(this.values,0),i=this.constructor,l=new i(this.name,e,t);return l.createInterpolant=this.createInterpolant,l}});function n_(e,t,i){mr.call(this,e,t,i)}n_.prototype=Object.assign(Object.create(mr.prototype),{constructor:n_,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:yh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function i_(e,t,i,l){mr.call(this,e,t,i,l)}i_.prototype=Object.assign(Object.create(mr.prototype),{constructor:i_,ValueTypeName:"color"});function Jc(e,t,i,l){mr.call(this,e,t,i,l)}Jc.prototype=Object.assign(Object.create(mr.prototype),{constructor:Jc,ValueTypeName:"number"});function r_(e,t,i,l){Gr.call(this,e,t,i,l)}r_.prototype=Object.assign(Object.create(Gr.prototype),{constructor:r_,interpolate_:function(e,t,i,l){for(var c=this.resultBuffer,h=this.sampleValues,f=this.valueSize,r=e*f,v=(i-t)/(l-t),x=r+f;r!==x;r+=4)Nr.slerpFlat(c,0,h,r-f,h,r,v);return c}});function td(e,t,i,l){mr.call(this,e,t,i,l)}td.prototype=Object.assign(Object.create(mr.prototype),{constructor:td,ValueTypeName:"quaternion",DefaultInterpolation:sc,InterpolantFactoryMethodLinear:function(e){return new r_(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0});function o_(e,t,i,l){mr.call(this,e,t,i,l)}o_.prototype=Object.assign(Object.create(mr.prototype),{constructor:o_,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:yh,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Qc(e,t,i,l){mr.call(this,e,t,i,l)}Qc.prototype=Object.assign(Object.create(mr.prototype),{constructor:Qc,ValueTypeName:"vector"});function vo(e,t,i){this.name=e,this.tracks=i,this.duration=t!==void 0?t:-1,this.uuid=jn.generateUUID(),this.duration<0&&this.resetDuration()}function lS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Jc;case"vector":case"vector2":case"vector3":case"vector4":return Qc;case"color":return i_;case"quaternion":return td;case"bool":case"boolean":return n_;case"string":return o_}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function cS(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=lS(e.type);if(e.times===void 0){var i=[],l=[];Gi.flattenJSON(e.keys,i,l,"value"),e.times=i,e.values=l}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Object.assign(vo,{parse:function(e){for(var t=[],i=e.tracks,l=1/(e.fps||1),c=0,h=i.length;c!==h;++c)t.push(cS(i[c]).scale(l));return new vo(e.name,e.duration,t)},toJSON:function(e){for(var t=[],i=e.tracks,l={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},c=0,h=i.length;c!==h;++c)t.push(mr.toJSON(i[c]));return l},CreateFromMorphTargetSequence:function(e,t,i,l){for(var c=t.length,h=[],f=0;f1){var x=v[1],w=l[x];w||(l[x]=w=[]),w.push(r)}}var b=[];for(var x in l)b.push(vo.CreateFromMorphTargetSequence(x,l[x],t,i));return b},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(J,ne,H,Q,ae){if(H.length!==0){var ie=[],le=[];Gi.flattenJSON(H,ie,le,Q),ie.length!==0&&ae.push(new J(ne,ie,le))}},l=[],c=e.name||"default",h=e.length||-1,f=e.fps||30,r=e.hierarchy||[],v=0;v0||e.search(/^data\:image\/jpeg/)===0;c.format=r?Ma:Ao,c.needsUpdate=!0,t!==void 0&&t(c)},i,l),c}});function Dn(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(Dn.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var i=this.getUtoTmapping(e);return this.getPoint(i,t)},getPoints:function(e){e===void 0&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e){e===void 0&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},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 t=[],i,l=this.getPoint(0),c,h=0;for(t.push(0),c=1;c<=e;c++)i=this.getPoint(c/e),h+=i.distanceTo(l),t.push(h),l=i;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i=this.getLengths(),l=0,c=i.length,h;t?h=t:h=e*i[c-1];for(var f=0,r=c-1,v;f<=r;)if(l=Math.floor(f+(r-f)/2),v=i[l]-h,v<0)f=l+1;else if(v>0)r=l-1;else{r=l;break}if(l=r,i[l]===h)return l/(c-1);var x=i[l],w=i[l+1],b=w-x,A=(h-x)/b,L=(l+A)/(c-1);return L},getTangent:function(e){var t=1e-4,i=e-t,l=e+t;i<0&&(i=0),l>1&&(l=1);var c=this.getPoint(i),h=this.getPoint(l),f=h.clone().sub(c);return f.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var i=new Pe,l=[],c=[],h=[],f=new Pe,r=new Hn,v,x,w;for(v=0;v<=e;v++)x=v/e,l[v]=this.getTangentAt(x),l[v].normalize();c[0]=new Pe,h[0]=new Pe;var b=Number.MAX_VALUE,A=Math.abs(l[0].x),L=Math.abs(l[0].y),P=Math.abs(l[0].z);for(A<=b&&(b=A,i.set(1,0,0)),L<=b&&(b=L,i.set(0,1,0)),P<=b&&i.set(0,0,1),f.crossVectors(l[0],i).normalize(),c[0].crossVectors(l[0],f),h[0].crossVectors(l[0],c[0]),v=1;v<=e;v++)c[v]=c[v-1].clone(),h[v]=h[v-1].clone(),f.crossVectors(l[v-1],l[v]),f.length()>Number.EPSILON&&(f.normalize(),w=Math.acos(jn.clamp(l[v-1].dot(l[v]),-1,1)),c[v].applyMatrix4(r.makeRotationAxis(f,w))),h[v].crossVectors(l[v],c[v]);if(t===!0)for(w=Math.acos(jn.clamp(c[0].dot(c[e]),-1,1)),w/=e,l[0].dot(f.crossVectors(c[0],c[e]))>0&&(w=-w),v=1;v<=e;v++)c[v].applyMatrix4(r.makeRotationAxis(l[v],w*v)),h[v].crossVectors(l[v],c[v]);return{tangents:l,normals:c,binormals:h}},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 bo(e,t,i,l,c,h,f,r){Dn.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=l||1,this.aStartAngle=c||0,this.aEndAngle=h||2*Math.PI,this.aClockwise=f||!1,this.aRotation=r||0}bo.prototype=Object.create(Dn.prototype),bo.prototype.constructor=bo,bo.prototype.isEllipseCurve=!0,bo.prototype.getPoint=function(e,t){for(var i=t||new Lt,l=Math.PI*2,c=this.aEndAngle-this.aStartAngle,h=Math.abs(c)l;)c-=l;c0?0:(Math.floor(Math.abs(f)/c)+1)*c:r===0&&f===c-1&&(f=c-2,r=1);var v,x,w,b;if(this.closed||f>0?v=l[(f-1)%c]:(im.subVectors(l[0],l[1]).add(l[0]),v=im),x=l[f%c],w=l[(f+1)%c],this.closed||f+2l.length-2?l.length-1:h+1],w=l[h>l.length-3?l.length-1:h+2];return i.set(Q0(f,r.x,v.x,x.x,w.x),Q0(f,r.y,v.y,x.y,w.y)),i},Jo.prototype.copy=function(e){Dn.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t=t){var c=i[l]-t,h=this.curves[l],f=h.getLength(),r=f===0?0:1-c/f;return h.getPointAt(r)}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=[],t=0,i=0,l=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(e){Dn.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;t0){var x=v.getPoint(0);x.equals(this.currentPoint)||this.lineTo(x.x,x.y)}this.curves.push(v);var w=v.getPoint(1);return this.currentPoint.copy(w),this},copy:function(e){return hs.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=hs.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return hs.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}});function hl(e){Qo.call(this,e),this.uuid=jn.generateUUID(),this.type="Shape",this.holes=[]}hl.prototype=Object.assign(Object.create(Qo.prototype),{constructor:hl,getPointsHoles:function(e){for(var t=[],i=0,l=this.holes.length;i0){var h=new Z0(t),f=new nd(h);f.setCrossOrigin(this.crossOrigin);for(var r=0,v=e.length;r0?l=new Oh(f,r):l=new Ai(f,r);break;case"InstancedMesh":var f=c(e.geometry),r=h(e.material),v=e.count,x=e.instanceMatrix;l=new Zy(f,r,v),l.instanceMatrix=new kn(new Float32Array(x.array),16);break;case"LOD":l=new Cf;break;case"Line":l=new so(c(e.geometry),h(e.material),e.mode);break;case"LineLoop":l=new If(c(e.geometry),h(e.material));break;case"LineSegments":l=new Vi(c(e.geometry),h(e.material));break;case"PointCloud":case"Points":l=new zf(c(e.geometry),h(e.material));break;case"Sprite":l=new qy(h(e.material));break;case"Group":l=new al;break;default:l=new on}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 w=e.children,b=0;bNumber.EPSILON){if(We<0&&(Nt=at[It],be=-be,Ie=at[Dt],We=-We),He.yIe.y)continue;if(He.y===Nt.y){if(He.x===Nt.x)return!0}else{var Ge=We*(He.x-Nt.x)-be*(He.y-Nt.y);if(Ge===0)return!0;if(Ge<0)continue;yt=!yt}}else{if(He.y!==Nt.y)continue;if(Ie.x<=He.x&&He.x<=Nt.x||Nt.x<=He.x&&He.x<=Ie.x)return!0}}return yt}var c=ls.isClockWise,h=this.subPaths;if(h.length===0)return[];if(t===!0)return i(h);var f,r,v,x=[];if(h.length===1)return r=h[0],v=new hl,v.curves=r.curves,x.push(v),x;var w=!c(h[0].getPoints());w=e?!w:w;var b=[],A=[],L=[],P=0,R;A[P]=void 0,L[P]=[];for(var F=0,V=h.length;F1){for(var j=!1,J=[],ne=0,H=A.length;ne0&&(j||(L=b))}for(var me,F=0,he=A.length;F0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var h=0;h!==c;++h)e[t+h]=e[i+h]},_slerp:function(e,t,i,l){Nr.slerpFlat(e,t,e,t,e,i,l)},_lerp:function(e,t,i,l,c){for(var h=1-l,f=0;f!==c;++f){var r=t+f;e[r]=e[r]*h+e[i+f]*l}}});var C_="\\[\\]\\.:\\/",TS=new RegExp("["+C_+"]","g"),A_="[^"+C_+"]",ES="[^"+C_.replace("\\.","")+"]",CS=/((?:WC+[\/:])*)/.source.replace("WC",A_),AS=/(WCOD+)?/.source.replace("WCOD",ES),DS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",A_),PS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",A_),SS=new RegExp("^"+CS+AS+DS+PS+"$"),LS=["material","materials","bones"];function _1(e,t,i){var l=i||gr.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,l)}Object.assign(_1.prototype,{getValue:function(e,t){this.bind();var i=this._targetGroup.nCachedObjects_,l=this._bindings[i];l!==void 0&&l.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,l=this._targetGroup.nCachedObjects_,c=i.length;l!==c;++l)i[l].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}});function gr(e,t,i){this.path=t,this.parsedPath=i||gr.parseTrackName(t),this.node=gr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(gr,{Composite:_1,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new gr.Composite(e,t,i):new gr(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(TS,"")},parseTrackName:function(e){var t=SS.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},l=i.nodeName&&i.nodeName.lastIndexOf(".");if(l!==void 0&&l!==-1){var c=i.nodeName.substring(l+1);LS.indexOf(c)!==-1&&(i.nodeName=i.nodeName.substring(0,l),i.objectName=c)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,t){if(!t||t===""||t==="root"||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){var l=function(h){for(var f=0;f=t){var w=t++,b=e[w];i[b.uuid]=x,e[x]=b,i[v]=w,e[w]=r;for(var A=0,L=c;A!==L;++A){var P=l[A],R=P[w],F=P[x];P[x]=R,P[w]=F}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,l=this._indicesByUUID,c=this._bindings,h=c.length,f=0,r=arguments.length;f!==r;++f){var v=arguments[f],x=v.uuid,w=l[x];if(w!==void 0)if(delete l[x],w0)for(var v=this._interpolants,x=this._propertyBindings,w=0,b=v.length;w!==b;++w)v[w].evaluate(f),x[w].accumulate(l,r)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(i!==null){var l=i.evaluate(e)[0];t*=l,e>i.parameterPositions[1]&&(this.stopFading(),l===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(i!==null){var l=i.evaluate(e)[0];t*=l,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,i=this._clip.duration,l=this.loop,c=this._loopCount,h=l===AE;if(e===0)return c===-1?t:h&&(c&1)===1?i-t:t;if(l===EE){c===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=i)t=i;else if(t<0)t=0;else{this.time=t;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(c===-1&&(e>=0?(c=0,this._setEndings(!0,this.repetitions===0,h)):this._setEndings(this.repetitions===0,!0,h)),t>=i||t<0){var f=Math.floor(t/i);t-=i*f,c+=Math.abs(f);var r=this.repetitions-c;if(r<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(r===1){var v=e<0;this._setEndings(v,!v,h)}else this._setEndings(!1,!1,h);this._loopCount=c,this.time=t,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f})}}else this.time=t;if(h&&(c&1)===1)return i-t}return t},_setEndings:function(e,t,i){var l=this._interpolantSettings;i?(l.endingStart=cc,l.endingEnd=cc):(e?l.endingStart=this.zeroSlopeAtStart?cc:lc:l.endingStart=tf,t?l.endingEnd=this.zeroSlopeAtEnd?cc:lc:l.endingEnd=tf)},_scheduleFading:function(e,t,i){var l=this._mixer,c=l.time,h=this._weightInterpolant;h===null&&(h=l._lendControlInterpolant(),this._weightInterpolant=h);var f=h.parameterPositions,r=h.sampleValues;return f[0]=c,r[0]=t,f[1]=c+e,r[1]=i,this}});function x1(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}x1.prototype=Object.assign(Object.create(Ta.prototype),{constructor:x1,_bindAction:function(e,t){var i=e._localRoot||this._root,l=e._clip.tracks,c=l.length,h=e._propertyBindings,f=e._interpolants,r=i.uuid,v=this._bindingsByRootAndName,x=v[r];x===void 0&&(x={},v[r]=x);for(var w=0;w!==c;++w){var b=l[w],A=b.name,L=x[A];if(L!==void 0)h[w]=L;else{if(L=h[w],L!==void 0){L._cacheIndex===null&&(++L.referenceCount,this._addInactiveBinding(L,r,A));continue}var P=t&&t._propertyBindings[w].binding.parsedPath;L=new y1(gr.create(i,A,P),b.ValueTypeName,b.getValueSize()),++L.referenceCount,this._addInactiveBinding(L,r,A),h[w]=L}f[w].resultBuffer=L.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,l=this._actionsByClip[i];this._bindAction(e,l&&l.knownActions[0]),this._addInactiveAction(e,i,t)}for(var c=e._propertyBindings,h=0,f=c.length;h!==f;++h){var r=c[h];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,l=t.length;i!==l;++i){var c=t[i];--c.useCount===0&&(c.restoreOriginalState(),this._takeBackBinding(c))}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 t=e._cacheIndex;return t!==null&&tthis.max.x||e.ythis.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,t){return t===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new Lt),t.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.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return t===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new Lt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){var t=M1.copy(e).clamp(this.min,this.max);return t.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 E1=new Pe,lm=new Pe;function C1(e,t){this.start=e!==void 0?e:new Pe,this.end=t!==void 0?t:new Pe}Object.assign(C1.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),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 Pe),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 Pe),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,t){return t===void 0&&(console.warn("THREE.Line3: .at() target is now required"),t=new Pe),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){E1.subVectors(e,this.start),lm.subVectors(this.end,this.start);var i=lm.dot(lm),l=lm.dot(E1),c=l/i;return t&&(c=jn.clamp(c,0,1)),c},closestPointToPoint:function(e,t,i){var l=this.closestPointToPointParameter(e,t);return i===void 0&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new Pe),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 cm(e){on.call(this),this.material=e,this.render=function(){}}cm.prototype=Object.create(on.prototype),cm.prototype.constructor=cm,cm.prototype.isImmediateRenderObject=!0;var A1=new Pe;function ld(e,t){on.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var i=new vn,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],c=0,h=1,f=32;c.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{R1.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(R1,t)}},ps.prototype.setLength=function(e,t,i){t===void 0&&(t=.2*e),i===void 0&&(i=.2*t),this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},ps.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},ps.prototype.copy=function(e){return on.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},ps.prototype.clone=function(){return new this.constructor().copy(this)};function k_(e){e=e||1;var t=[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 vn;l.setAttribute("position",new ln(t,3)),l.setAttribute("color",new ln(i,3));var c=new Ri({vertexColors:ic});Vi.call(this,l,c)}k_.prototype=Object.create(Vi.prototype),k_.prototype.constructor=k_;var nu=4,fs=8,ta=Math.pow(2,fs),k1=[.125,.215,.35,.446,.526,.582],z1=fs-nu+1+k1.length,iu=20,na={[io]:0,[_h]:1,[py]:2,[Vx]:3,[Gx]:4,[Wx]:5,[Ux]:6},z_=new tu,_m=US(iu),ms=null,gs=null,{_lodPlanes:pd,_sizeLods:F1,_sigmas:vm}=BS(),xm=null,yi=null,F_=null,_l=(1+Math.sqrt(5))/2,ru=1/_l,B1=[new Pe(1,1,1),new Pe(-1,1,1),new Pe(1,1,-1),new Pe(-1,1,-1),new Pe(0,_l,ru),new Pe(0,_l,-ru),new Pe(ru,0,_l),new Pe(-ru,0,_l),new Pe(_l,ru,0),new Pe(-_l,ru,0)];function O1(e){yi=e,B_(_m)}O1.prototype={constructor:O1,fromScene:function(e,t=0,i=.1,l=100){F_=yi.getRenderTarget();var c=N1();return OS(e,i,l,c),t>0&&W1(c,0,0,t),G1(c),U1(c),c},fromEquirectangular:function(e){return e.magFilter=Ui,e.minFilter=Ui,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){F_=yi.getRenderTarget();var t=N1(e);return NS(e,t),G1(t),U1(t),t},compileCubemapShader:function(){gs==null&&(gs=$1(),B_(gs))},compileEquirectangularShader:function(){ms==null&&(ms=H1(),B_(ms))},dispose:function(){_m.dispose(),gs!=null&&gs.dispose(),ms!=null&&ms.dispose();for(var e=0;efs-nu?f=k1[c-fs+nu-1]:c==0&&(f=0),i.push(f);for(var r=1/(h-1),v=-r/2,x=1+r/2,w=[v,v,x,v,x,x,v,v,x,x,v,x],b=6,A=6,L=3,P=2,R=1,F=new Float32Array(L*A*b),V=new Float32Array(P*A*b),j=new Float32Array(R*A*b),J=0;J2?0:-1,Q=[ne,H,0,ne+2/3,H,0,ne+2/3,H+1,0,ne,H,0,ne+2/3,H+1,0,ne,H+1,0];F.set(Q,L*A*J),V.set(w,P*A*J);var ae=[J,J,J,J,J,J];j.set(ae,R*A*J)}var ie=new vn;ie.setAttribute("position",new kn(F,L)),ie.setAttribute("uv",new kn(V,P)),ie.setAttribute("faceIndex",new kn(j,R)),e.push(ie),l>nu&&l--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}function N1(e){var t={magFilter:Ui,minFilter:Ui,generateMipmaps:!1,type:e?e.type:Jp,format:e?e.format:iE,encoding:e?e.encoding:py,depthBuffer:!1,stencilBuffer:!1},i=V1(t);return i.depthBuffer=!e,xm=V1(t),i}function U1(e){xm.dispose(),yi.setRenderTarget(F_),e.scissorTest=!1,e.setSize(e.width,e.height)}function OS(e,t,i,l){var c=90,h=1,f=new Xi(c,h,t,i),r=[1,1,1,1,-1,1],v=[1,1,-1,-1,-1,1],x=yi.outputEncoding,w=yi.toneMapping,b=yi.toneMappingExposure,A=yi.getClearColor(),L=yi.getClearAlpha();yi.toneMapping=ry,yi.toneMappingExposure=1,yi.outputEncoding=io,e.scale.z*=-1;var P=e.background;if(P&&P.isColor){P.convertSRGBToLinear();var R=Math.max(P.r,P.g,P.b),F=Math.min(Math.max(Math.ceil(Math.log2(R)),-128),127);P=P.multiplyScalar(Math.pow(2,-F));var V=(F+128)/255;yi.setClearColor(P,V),e.background=null}for(var j=0;j<6;j++){var J=j%3;J==0?(f.up.set(0,r[j],0),f.lookAt(v[j],0,0)):J==1?(f.up.set(0,0,r[j]),f.lookAt(0,v[j],0)):(f.up.set(0,r[j],0),f.lookAt(0,0,v[j])),O_(l,J*ta,j>2?ta:0,ta,ta),yi.setRenderTarget(l),yi.render(e,f)}yi.toneMapping=w,yi.toneMappingExposure=b,yi.outputEncoding=x,yi.setClearColor(A,L),e.scale.z*=-1}function NS(e,t){var i=new Ca;e.isCubeTexture?gs==null&&(gs=$1()):ms==null&&(ms=H1());var l=e.isCubeTexture?gs:ms;i.add(new Ai(pd[0],l));var c=l.uniforms;c.envMap.value=e,e.isCubeTexture||c.texelSize.value.set(1/e.image.width,1/e.image.height),c.inputEncoding.value=na[e.encoding],c.outputEncoding.value=na[e.encoding],O_(t,0,0,3*ta,2*ta),yi.setRenderTarget(t),yi.render(i,z_)}function B_(e){var t=new Ca;t.add(new Ai(pd[0],e)),yi.compile(t,z_)}function V1(e){var t=new Tr(3*ta,3*ta,e);return t.texture.mapping=ph,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function O_(e,t,i,l,c){e.viewport.set(t,i,l,c),e.scissor.set(t,i,l,c)}function G1(e){var t=yi.autoClear;yi.autoClear=!1;for(var i=1;iiu&&console.warn(`sigmaRadians, ${c}, is too large and will clip, as it requested ${L} samples when the maximum is set to ${iu}`);for(var P=[],R=0,F=0;Ffs-nu?l-fs+nu:0);O_(t,J,ne,3*j,2*j),yi.setRenderTarget(t),yi.render(v,z_)}function US(e){var t=new Float32Array(e),i=new Pe(0,1,0),l=new us({defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:na[io]},outputEncoding:{value:na[io]}},vertexShader:N_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[n]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; ${U_()} #define ENVMAP_TYPE_CUBE_UV #include void main() { gl_FragColor = vec4(0.0); for (int i = 0; i < n; i++) { if (i >= samples) break; for (int dir = -1; dir < 2; dir += 2) { if (i == 0 && dir == 1) continue; vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection); if (all(equal(axis, vec3(0.0)))) axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection); axis = normalize(axis); float theta = dTheta * float(dir * i); float cosTheta = cos(theta); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross(axis, vOutputDirection) * sin(theta) + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta); gl_FragColor.rgb += weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt); } } gl_FragColor = linearToOutputTexel(gl_FragColor); } `,blending:es,depthTest:!1,depthWrite:!1});return l.type="SphericalGaussianBlur",l}function H1(){var e=new Lt(1,1),t=new us({uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:na[io]},outputEncoding:{value:na[io]}},vertexShader:N_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform vec2 texelSize; ${U_()} #define RECIPROCAL_PI 0.31830988618 #define RECIPROCAL_PI2 0.15915494 void main() { gl_FragColor = vec4(0.0); vec3 outputDirection = normalize(vOutputDirection); vec2 uv; uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5; uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5; vec2 f = fract(uv / texelSize - 0.5); uv -= f * texelSize; vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb; uv.x += texelSize.x; vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb; uv.y += texelSize.y; vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb; uv.x -= texelSize.x; vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb; vec3 tm = mix(tl, tr, f.x); vec3 bm = mix(bl, br, f.x); gl_FragColor.rgb = mix(tm, bm, f.y); gl_FragColor = linearToOutputTexel(gl_FragColor); } `,blending:es,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function $1(){var e=new us({uniforms:{envMap:{value:null},inputEncoding:{value:na[io]},outputEncoding:{value:na[io]}},vertexShader:N_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform samplerCube envMap; ${U_()} void main() { gl_FragColor = vec4(0.0); gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb; gl_FragColor = linearToOutputTexel(gl_FragColor); } `,blending:es,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function N_(){return` precision mediump float; precision mediump int; attribute vec3 position; attribute vec2 uv; attribute float faceIndex; varying vec3 vOutputDirection; vec3 getDirection(vec2 uv, float face) { uv = 2.0 * uv - 1.0; vec3 direction = vec3(uv, 1.0); if (face == 0.0) { direction = direction.zyx; direction.z *= -1.0; } else if (face == 1.0) { direction = direction.xzy; direction.z *= -1.0; } else if (face == 3.0) { direction = direction.zyx; direction.x *= -1.0; } else if (face == 4.0) { direction = direction.xzy; direction.y *= -1.0; } else if (face == 5.0) { direction.xz *= -1.0; } return direction; } void main() { vOutputDirection = getDirection(uv, faceIndex); gl_Position = vec4( position, 1.0 ); } `}function U_(){return` uniform int inputEncoding; uniform int outputEncoding; #include vec4 inputTexelToLinear(vec4 value){ if(inputEncoding == 0){ return value; }else if(inputEncoding == 1){ return sRGBToLinear(value); }else if(inputEncoding == 2){ return RGBEToLinear(value); }else if(inputEncoding == 3){ return RGBMToLinear(value, 7.0); }else if(inputEncoding == 4){ return RGBMToLinear(value, 16.0); }else if(inputEncoding == 5){ return RGBDToLinear(value, 256.0); }else{ return GammaToLinear(value, 2.2); } } vec4 linearToOutputTexel(vec4 value){ if(outputEncoding == 0){ return value; }else if(outputEncoding == 1){ return LinearTosRGB(value); }else if(outputEncoding == 2){ return LinearToRGBE(value); }else if(outputEncoding == 3){ return LinearToRGBM(value, 7.0); }else if(outputEncoding == 4){ return LinearToRGBM(value, 16.0); }else if(outputEncoding == 5){ return LinearToRGBD(value, 256.0); }else{ return LinearToGamma(value, 2.2); } } vec4 envMapTexelToLinear(vec4 color) { return inputTexelToLinear(color); } `}Dn.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Dn.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(hs.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new Bn,i=0,l=e.length;i{if(t!=0)return;const i=e.value();let l=new bm;l.setPoint1(i),l.setColor(65314);const c=new X.McEdGetPointWorldDrawObject;c.setDraw(h=>{l.setPoint2(h),c.drawCustomEntity(l)}),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw(c),e.setMessage(` 指定第二点:`),e.setInputToucheType(X.MxType.InputToucheType.kGetEnd),e.go(h=>{if(h!=0){console.log(h);return}const f=e.value();l.setPoint2(f),X.MxFun.getCurrentDraw().addMxEntity(l),alert("测试长度是:"+l.getDimText())})})})}function GS(){const e=new X.MrxDbgUiPrPoint,t=X.MxFun.getCurrentDraw(),i=new X.MxDb2LineAngularDimension;i.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();const l=new X.McEdGetPointWorldDrawObject;l.setColor(M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor()),e.setMessage(` 指定第一点:`),e.go(c=>{c===0&&(e.setMessage(` 指定第二个角度点:`),i.point1=e.value(),l.setDraw((h,f)=>{i.point2=h,f.drawLine(i.point1,h)}),e.setUserDraw(l),e.go(h=>{e.setMessage(` 指定最后一个点:`),h===0&&(i.point2=e.value(),l.setDraw((f,r)=>{i.point3=f,l.drawCustomEntity(i)}),e.go(f=>{f===0&&t.addMxEntity(i)}))}))})}function WS(){const e=new X.MrxDbgUiPrPoint;e.setMessage(` 指定坐标点:`),e.go(t=>{if(t!=0)return;const i=e.value();let l=new X.MxDbCoord;l.point1=i,l.point2=i.clone(),l.color=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor(),e.setBasePt(i),e.setUseBasePt(!0),e.setUserDraw((c,h)=>{l.point2=c,h.drawCustomEntity(l)}),e.setMessage(` 指定标注点:`),e.go(c=>{if(c!=0){console.log(c);return}l.point2=e.value(),X.MxFun.addToCurrentSpace(l)})})}function jS(){new bm().rxInit(),X.MxFun.addCommand("Mx_Linear",VS),X.MxFun.addCommand("BR_AngleMeasure",GS),X.MxFun.addCommand("BR_CoordMeasure",WS)}function HS(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("select entity:");let i=(yield e.go()).getMcDbEntity();if(i!==null){if(console.log("ent.objectName",i.objectName),i instanceof M.McDbBlockReference){let c=i.explode();if(c.GetCount()==0)return;let h=c.GetCount();for(let f=0;f=7&&Nt(ge),Oe==null&&(Oe=Ge(le,fe,Ve)),be(Oe,Ce)},At=function(ge,Ce){for(var Ae=-1;Ae<=7;Ae+=1)if(!(ge+Ae<=-1||he<=ge+Ae))for(var _e=-1;_e<=7;_e+=1)Ce+_e<=-1||he<=Ce+_e||(0<=Ae&&Ae<=6&&(_e==0||_e==6)||0<=_e&&_e<=6&&(Ae==0||Ae==6)||2<=Ae&&Ae<=4&&2<=_e&&_e<=4?me[ge+Ae][Ce+_e]=!0:me[ge+Ae][Ce+_e]=!1)},yt=function(){for(var ge=0,Ce=0,Ae=0;Ae<8;Ae+=1){at(!0,Ae);var _e=r.getLostPoint(He);(Ae==0||ge>_e)&&(ge=_e,Ce=Ae)}return Ce},Dt=function(){for(var ge=8;ge>Ae&1)==1;me[Math.floor(Ae/3)][Ae%3+he-8-3]=_e}for(var Ae=0;Ae<18;Ae+=1){var _e=!ge&&(Ce>>Ae&1)==1;me[Ae%3+he-8-3][Math.floor(Ae/3)]=_e}},Ie=function(ge,Ce){for(var Ae=fe<<3|Ce,_e=r.getBCHTypeInfo(Ae),Ne=0;Ne<15;Ne+=1){var Je=!ge&&(_e>>Ne&1)==1;Ne<6?me[Ne][8]=Je:Ne<8?me[Ne+1][8]=Je:me[he-15+Ne][8]=Je}for(var Ne=0;Ne<15;Ne+=1){var Je=!ge&&(_e>>Ne&1)==1;Ne<8?me[8][he-Ne-1]=Je:Ne<9?me[8][15-Ne-1+1]=Je:me[8][15-Ne-1]=Je}me[he-8][8]=!ge},be=function(ge,Ce){for(var Ae=-1,_e=he-1,Ne=7,Je=0,ct=r.getMaskFunction(Ce),wt=he-1;wt>0;wt-=2)for(wt==6&&(wt-=1);;){for(var Gt=0;Gt<2;Gt+=1)if(me[_e][wt-Gt]==null){var pe=!1;Je>>Ne&1)==1);var Me=ct(_e,wt-Gt);Me&&(pe=!pe),me[_e][wt-Gt]=pe,Ne-=1,Ne==-1&&(Je+=1,Ne=7)}if(_e+=Ae,_e<0||he<=_e){_e-=Ae,Ae=-Ae;break}}},We=function(ge,Ce){for(var Ae=0,_e=0,Ne=0,Je=new Array(Ce.length),ct=new Array(Ce.length),wt=0;wt=0?bn.getAt(hn):0}}for(var nn=0,Me=0;Mewt*8)throw"code length overflow. ("+Ne.getLengthInBits()+">"+wt*8+")";for(Ne.getLengthInBits()+4<=wt*8&&Ne.put(0,4);Ne.getLengthInBits()%8!=0;)Ne.putBit(!1);for(;!(Ne.getLengthInBits()>=wt*8||(Ne.put(ae,8),Ne.getLengthInBits()>=wt*8));)Ne.put(ie,8);return We(Ne,_e)};He.addData=function(ge,Ce){Ce=Ce||"Byte";var Ae=null;switch(Ce){case"Numeric":Ae=A(ge);break;case"Alphanumeric":Ae=L(ge);break;case"Byte":Ae=P(ge);break;case"Kanji":Ae=R(ge);break;default:throw"mode:"+Ce}Ve.push(Ae),Oe=null},He.isDark=function(ge,Ce){if(ge<0||he<=ge||Ce<0||he<=Ce)throw ge+","+Ce;return me[ge][Ce]},He.getModuleCount=function(){return he},He.make=function(){if(le<1){for(var ge=1;ge<40;ge++){for(var Ce=w.getRSBlocks(ge,fe),Ae=b(),_e=0;_e";for(var Ne=0;Ne';Ae+=""}return Ae+="",Ae+="",Ae},He.createSvgTag=function(ge,Ce,Ae,_e){var Ne={};typeof arguments[0]=="object"&&(Ne=arguments[0],ge=Ne.cellSize,Ce=Ne.margin,Ae=Ne.alt,_e=Ne.title),ge=ge||2,Ce=typeof Ce=="undefined"?ge*4:Ce,Ae=typeof Ae=="string"?{text:Ae}:Ae||{},Ae.text=Ae.text||null,Ae.id=Ae.text?Ae.id||"qrcode-description":null,_e=typeof _e=="string"?{text:_e}:_e||{},_e.text=_e.text||null,_e.id=_e.text?_e.id||"qrcode-title":null;var Je=He.getModuleCount()*ge+Ce*2,ct,wt,Gt,pe,Me="",bt;for(bt="l"+ge+",0 0,"+ge+" -"+ge+",0 0,-"+ge+"z ",Me+=''+ke(_e.text)+"":"",Me+=Ae.text?''+ke(Ae.text)+"":"",Me+='',Me+='":Ce+=">";break;case"&":Ce+="&";break;case'"':Ce+=""";break;default:Ce+=_e;break}}return Ce},ot=function(ge){var Ce=1;ge=typeof ge=="undefined"?Ce*2:ge;var Ae=He.getModuleCount()*Ce+ge*2,_e=ge,Ne=Ae-ge,Je,ct,wt,Gt,pe,Me={"██":"█","█ ":"▀"," █":"▄"," ":" "},bt={"██":"▀","█ ":"▀"," █":" "," ":" "},gt="";for(Je=0;Je=Ne?bt[pe]:Me[pe];gt+=` `}return Ae%2&&ge>0?gt.substring(0,gt.length-Ae-1)+Array(Ae+1).join("▀"):gt.substring(0,gt.length-1)};return He.createASCII=function(ge,Ce){if(ge=ge||1,ge<2)return ot(Ce);ge-=1,Ce=typeof Ce=="undefined"?ge*2:Ce;var Ae=He.getModuleCount()*ge+Ce*2,_e=Ce,Ne=Ae-Ce,Je,ct,wt,Gt,pe=Array(ge+1).join("██"),Me=Array(ge+1).join(" "),bt="",gt="";for(Je=0;Je>>8),fe.push(Oe&255)):fe.push(ie)}}return fe}};var c={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},h={L:1,M:0,Q:3,H:2},f={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=function(){var H=[[],[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]],Q=1335,ae=7973,ie=21522,le={},fe=function(me){for(var he=0;me!=0;)he+=1,me>>>=1;return he};return le.getBCHTypeInfo=function(me){for(var he=me<<10;fe(he)-fe(Q)>=0;)he^=Q<=0;)he^=ae<5&&(Oe+=3+at-5)}for(var Ve=0;Ve=256;)le-=255;return H[le]},ie}();function x(H,Q){if(typeof H.length=="undefined")throw H.length+"/"+Q;var ae=function(){for(var le=0;le>>7-ie%8&1)==1},ae.put=function(ie,le){for(var fe=0;fe>>le-fe-1&1)==1)},ae.getLengthInBits=function(){return Q},ae.putBit=function(ie){var le=Math.floor(Q/8);H.length<=le&&H.push(0),ie&&(H[le]|=128>>>Q%8),Q+=1},ae},A=function(H){var Q=c.MODE_NUMBER,ae=H,ie={};ie.getMode=function(){return Q},ie.getLength=function(me){return ae.length},ie.write=function(me){for(var he=ae,Oe=0;Oe+2>>8&255)*192+(Oe&255),fe.put(Oe,13),he+=2}if(he>>8)},Q.writeBytes=function(ae,ie,le){ie=ie||0,le=le||ae.length;for(var fe=0;fe0&&(ae+=","),ae+=H[ie];return ae+="]",ae},Q},V=function(){var H=0,Q=0,ae=0,ie="",le={},fe=function(he){ie+=String.fromCharCode(me(he&63))},me=function(he){if(!(he<0)){if(he<26)return 65+he;if(he<52)return 97+(he-26);if(he<62)return 48+(he-52);if(he==62)return 43;if(he==63)return 47}throw"n:"+he};return le.writeByte=function(he){for(H=H<<8|he&255,Q+=8,ae+=1;Q>=6;)fe(H>>>Q-6),Q-=6},le.flush=function(){if(Q>0&&(fe(H<<6-Q),H=0,Q=0),ae%3!=0)for(var he=3-ae%3,Oe=0;Oe=Q.length){if(le==0)return-1;throw"unexpected end of file./"+le}var he=Q.charAt(ae);if(ae+=1,he=="=")return le=0,-1;if(he.match(/^\s$/))continue;ie=ie<<6|me(he.charCodeAt(0)),le+=6}var Oe=ie>>>le-8&255;return le-=8,Oe};var me=function(he){if(65<=he&&he<=90)return he-65;if(97<=he&&he<=122)return he-97+26;if(48<=he&&he<=57)return he-48+52;if(he==43)return 62;if(he==47)return 63;throw"c:"+he};return fe},J=function(H,Q){var ae=H,ie=Q,le=new Array(H*Q),fe={};fe.setPixel=function(Ve,He,at){le[He*ae+Ve]=at},fe.write=function(Ve){Ve.writeString("GIF87a"),Ve.writeShort(ae),Ve.writeShort(ie),Ve.writeByte(128),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(0),Ve.writeByte(255),Ve.writeByte(255),Ve.writeByte(255),Ve.writeString(","),Ve.writeShort(0),Ve.writeShort(0),Ve.writeShort(ae),Ve.writeShort(ie),Ve.writeByte(0);var He=2,at=he(He);Ve.writeByte(He);for(var At=0;at.length-At>255;)Ve.writeByte(255),Ve.writeBytes(at,At,255),At+=255;Ve.writeByte(at.length-At),Ve.writeBytes(at,At,at.length-At),Ve.writeByte(0),Ve.writeString(";")};var me=function(Ve){var He=Ve,at=0,At=0,yt={};return yt.write=function(Dt,It){if(Dt>>>It)throw"length over";for(;at+It>=8;)He.writeByte(255&(Dt<>>=8-at,At=0,at=0;At=Dt<0&&He.writeByte(At)},yt},he=function(Ve){for(var He=1<>6,128|v&63):v<55296||v>=57344?f.push(224|v>>12,128|v>>6&63,128|v&63):(r++,v=65536+((v&1023)<<10|h.charCodeAt(r)&1023),f.push(240|v>>18,128|v>>12&63,128|v>>6&63,128|v&63))}return f}return c(l)}})(),function(l){e.exports=l()}(function(){return i})})(Y1);var ZS=Y1.exports;const YS=Z1(ZS);function KS(e){let t={};if(t.ObjectName=e.objectName,t.id=e.getObjectID().id,t.handle=e.getHandle(),t.layer=e.layer,t.color=e.trueColor.getColorString(),t.colorVal=e.trueColor.getColorValue(e.layerId),t.linetype=e.linetype,t.textStyle=e.textStyle,t.type=e.objectName,t.dxf0=e.dxf0,e instanceof M.McDbText){let i=e;t.position=Cr(i.position),t.textString=i.textString}else if(e instanceof M.McDbMText){let i=e;t.contents=i.contents,t.location=Cr(i.location)}else if(e instanceof M.McDbLine){let i=e;t.startPoint=Cr(i.startPoint),t.endPoint=Cr(i.endPoint)}else if(e instanceof M.McDbCircle){let i=e;t.center=Cr(i.center),t.radius=i.radius}else if(e instanceof M.McDbArc){let i=e;t.center=Cr(i.center),t.startAngle=i.startAngle,t.endAngle=i.endAngle}else if(e instanceof M.McDbPolyline){let i=e,l=i.numVerts();t.num=l;for(let c=0;c{t["txt:"+h]=c})}else if(e instanceof M.McDbRotatedDimension){let i=e;t.xLine1Point=Cr(i.xLine1Point),t.xLine2Point=Cr(i.xLine2Point),i.GetAllText().forEach((c,h)=>{t["txt:"+h]=c})}else if(e instanceof M.McDbDimension)e.GetAllText().forEach((c,h)=>{t["txt:"+h]=c});else if(e instanceof M.McDbHatch){let i=e;t.patternType=i.patternType(),t.patternName=i.patternName(),t.patternAngle=i.patternAngle,t.patternScale=i.patternScale,t.patternSpace=i.patternSpace,t.patternDouble=i.patternDouble,t.hatchStyle=i.hatchStyle(),t.isSolid=i.isSolid(),t.numLoops=i.numLoops;for(let l=0;l{c["pt:"+f]={},c["pt:"+f].x=h.x,c["pt:"+f].y=h.y,c["pt:"+f].z=h.z}),t["loop:"+l]=c}t.numPatternDefinitions=i.numPatternDefinitions;for(let l=0;l{t.clipBoundary["pt"+r]=f.toVector3()}),t.clipBoundaryType=i.clipBoundaryType();let h=i.imageDefId().getMcDbRasterImageDef();h&&(t.filePath=h.sourceFileName)}return t}function JS(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;e.allSelect(),e.forEach(t=>{let i=t.getMcDbEntity();i&&(i=KS(i),console.log(JSON.stringify(i)))})})}function QS(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet,t=new M.MxCADResbuf;t.AddString("0",8),e.allSelect(t),e.forEach(i=>{let l=i.getMcDbEntity();if(l&&l instanceof M.McDbHatch){let c={},h=l;c.patternType=h.patternType(),c.patternName=h.patternName(),c.patternAngle=h.patternAngle,c.patternScale=h.patternScale,c.patternSpace=h.patternSpace,c.patternDouble=h.patternDouble,c.hatchStyle=h.hatchStyle(),c.isSolid=h.isSolid(),c.numLoops=h.numLoops;for(let f=0;f{r["pt:"+x]={},r["pt:"+x].x=v.x,r["pt:"+x].y=v.y,r["pt:"+x].z=v.z}),c["loop:"+f]=r}c.numPatternDefinitions=h.numPatternDefinitions;for(let f=0;f{console.log(JSON.stringify({val:c,type:h,dxf:f}))})})}function n3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();i!==null&&i.setxDataString("DataName","xxxxx")})}function i3(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定第一点:`);let t=yield e.go();if(t)for(e.setMessage(` 指定下一个点:`);;){e.setBasePt(t);let i=yield e.go();if(!i)return;let l=new M.McDbLine(t,i);M.MxCpp.getCurrentMxCAD().drawEntity(l),t=i}})}function K1(){let e=window.location.hostname;return e.substring(0,4)!="http"&&(e=document.location.protocol+"//"+e),e}function r3(){return Qe(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=K1()+e.substring(16));let t=e+"tree.mxweb",i=M.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(t,"tree");if(!l.isValid())return;let c=new M.McDbBlockReference;c.blockTableRecordId=l;let h=c.getBoundingBox();if(h.ret){let b=h.maxPt.distanceTo(h.minPt);b>1e-5&&c.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/b)}let f=new M.MxCADUiPrPoint;f.setMessage("指定插入基点"),f.setUserDraw((b,A)=>{c.position=b,A.drawMcDbEntity(c)});let r=yield f.go();if(!r)return;c.position=r;let v=i.drawEntity(c);if(!v.isValid){console.log("insert error");return}c=v.getMcDbEntity(),c.disableDisplay(!0),l.getMcDbBlockTableRecord().getAllEntityId().forEach((b,A)=>{if(!b.isKindOf("McDbAttributeDefinition"))return;let L=b.getMcDbEntity(),P=L.tag,R=L.textString,F=new M.McDbAttribute;F.position=L.position,F.alignmentPoint=L.alignmentPoint,F.height=L.height,F.trueColor=L.trueColor,F.widthFactor=L.widthFactor,R.length>0?F.textString=R:F.textString="test"+A,F.tag=P,F.isInvisible=L.isInvisible,F.transformBy(c.blockTransform),F=c.appendAttribute(F).getMcDbEntity(),F.textStyle=L.textStyle,F.layer=L.layer}),c.disableDisplay(!1)})}function o3(){let i=M.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable().getAllRecordId(),l=[];return i.forEach(c=>{let h=c.getMcDbLayerTableRecord();if(h===null)return;console.log(h),console.log("layerRec.color:"+h.color.getColorString()),console.log("layerRec.name:"+h.name);let f={};f.name=h.name,f.color=h.color.getColorString(),l.push(f)}),X.MxFun.postMessageToParentFrame(l),l}function a3(){let t=M.MxCpp.App.getCurrentMxCAD().getDatabase().getLayerTable();if(!t.has("xxx11")){let i=new M.McDbLayerTableRecord;i.name="xxx11",t.add(i)}t.has("xxx11")&&console.log("add layer ok")}function s3(){M.MxCpp.App.getCurrentMxCAD().getDatabase().getLinetypeTable().getAllRecordId().forEach(l=>{let c=l.getMcDbLinetypeTableRecord();c!==null&&console.log(c)})}function l3(){M.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable().getAllRecordId().forEach(l=>{let c=l.getMcDbTextStyleTableRecord();if(c===null)return;let h={};h.name=c.name,h.font=c.font(),h.fileName=c.fileName,h.bigFontFileName=c.bigFontFileName,h.textSize=c.textSize,h.xScale=c.xScale,console.log(h)})}function c3(){return Qe(this,null,function*(){let t=M.MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable(),i="MyTextStyle";t.has(i,!1)&&t.get(i,!1).erase(!1);let l=new M.McDbTextStyleTableRecord;l.fileName="txt.shx",l.bigFontFileName="hztxt.shx",l.textSize=10,l.name=i,l.xScale=.7,t.add(l).isValid()&&console.log("add ok")})}function u3(){M.MxCpp.App.getCurrentMxCAD().getDatabase().getBlockTable().getAllRecordId().forEach(l=>{let c=l.getMcDbBlockTableRecord();c!==null&&(console.log(c),console.log("blkRec.name:"+c.name),console.log("blkRec.origin:"+c.origin))})}function h3(){return Qe(this,null,function*(){let e=new X1;e.data.addColumn("序号",30),e.data.addColumn("名称",45),e.data.addColumn("材料",60),e.data.addColumn("长度",50);for(let c=0;c<10;c++){let h=""+c;e.data.addRow([h,"AAAA","BBBB","1000"])}let t=new M.MxCADUiPrPoint;t.setMessage(` 指定表格插入点:`);let i=yield t.go();if(!i)return;let l=X.MxFun.screenCoordLong2Doc(100)/200;e.draw(i,l)})}function d3(){return Qe(this,null,function*(){const e=new X.MrxDbgUiPrPoint;e.setMessage(` 指定插入点:`);let t=yield e.go();if(!t)return;let i=X.MxFun.getCurrentDraw();const l=YS(5,"L");l.addData("https://www.mxdraw3d.com"),l.make();const c=l.createDataURL(),h=new id().load(c),f=new cr({map:h});let r=X.MxFun.screenCoordLong2Doc(80),v=X.MxFun.screenCoordLong2Doc(80),x=new X.MxDbImage;x.setRenderOrder(X.MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1),x.setPoint1(t);let w=new Pe(t.x+r,t.y+v,t.z);x.setPoint2(w),x.setMaterial(f),i.addMxEntity(x),setInterval(()=>{i.updateDisplay()},100)})}function p3(){return Qe(this,null,function*(){let e="http://localhost:3000/mxcad/";e.substring(0,16)=="http://localhost"&&(e=K1()+e.substring(16));let t=e+"stamp.mxweb",i=M.MxCpp.App.getCurrentMxCAD(),l=yield i.insertBlock(t,"stamp");if(!l.isValid())return;let c=new M.McDbBlockReference;c.blockTableRecordId=l;let h=c.getBoundingBox();if(h.ret){let v=h.maxPt.distanceTo(h.minPt);v>1e-5&&c.setScale(i.getMxDrawObject().screenCoordLong2Doc(100)/v)}let f=new M.MxCADUiPrPoint;f.setMessage("指定插入基点"),f.setUserDraw((v,x)=>{c.position=v,x.drawMcDbEntity(c)});let r=yield f.go();r&&(c.position=r,i.drawEntity(c))})}function f3(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=e.database.getLinetypeTable().get("TestMyLine");t.isErase()||t.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 h=(yield new M.MxCADUiPrEntity().go()).getMcDbEntity();h&&(h.linetypeId=i)})}function V_(e){e.getAllObjectName().forEach(i=>{console.log(i);let c=e.getAt(i).getMcDbObject();if(c instanceof M.McDbDictionary){let h=c;console.log(h),V_(h)}else c instanceof M.McDbXrecord&&c.getData().PrintData()})}function m3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择标注对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();if(i&&i.isHaveExtensionDictionary()){let l=i.getExtensionDictionary();V_(l)}})}function g3(){return Qe(this,null,function*(){let t=M.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary();t.getAllObjectName().forEach(l=>{console.log(l);let h=t.getAt(l).getMcDbObject();if(h instanceof M.McDbDictionary){let f=h;console.log(f),V_(f)}})})}function y3(){return Qe(this,null,function*(){let t=M.MxCpp.getCurrentMxCAD().getDatabase().getNamedObjectsDictionary(),i="MyDict",l=t.getAt(i);if(l.isNull()){let h=new M.McDbDictionary;l=t.addObject(i,h)}let c=l.getMcDbDictionary();if(c){let h=new M.McDbXrecord,f=new M.MxCADResbuf;f.AddString("TestData"),h.setData(f),c.addObject("MyRecord",h),console.log("write xrecord ok")}})}function _3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择标注对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();i&&(i.trueColor=new M.McCmColor(255,0,255))})}let G_;function v3(){return Qe(this,null,function*(){if(G_){let e=G_.getMcDbEntity();if(!e)return;e.visible=!0}else{let e=new M.MxCADUiPrEntity;e.setMessage("选择标注对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();if(!i)return;i.visible=!1,G_=t}})}function x3(){return Qe(this,null,function*(){let e="WALL";M.MxCpp.getCurrentMxCAD().database.layerTable.has(e)||console.log("no have layer:"+e);let i=new M.MxCADUiPrEntity;i.setMessage("选择对象");let l=yield i.go();if(!l.isValid())return;let c=l.getMcDbEntity();c&&(c.layer=e)})}function b3(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect(` 选择对象`)))return;let i=M.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder().maxDrawOrder+1;e.forEach(l=>{let c=l.getMcDbEntity();c&&(c.drawOrder=i)})})}function w3(e){let t=M.MxCpp.getCurrentMxCAD();t.mxdraw.makeCurrent(),t.loadDwgBackground(e,i=>{let l=t.getBackgroundEntity();l.setShow(e,!1);let c=l.getBackgroundDatabase(e);if(c==null)return;let h=new M.MxCompare;if(h.do(c)){let f=h.getResult();f.length>0&&l.setShow(e,!0),console.log(JSON.stringify(f))}},53962434921)}function M3(){w3("test3.mxweb")}let fd;function T3(){if(fd)fd.DoRestore(),fd=void 0;else{fd=new M.MxModifyColor;let e=new M.McCmColor;e.setColorIndex(M.ColorIndexType.kWhite),fd.Do(M.MxCpp.getCurrentDatabase(),e)}}function E3(){X.MxFun.addCommand("TestGetAllEntity",JS),X.MxFun.addCommand("MxTest_GetSysVars",e3),X.MxFun.addCommand("MxTest_ReadxData",t3),X.MxFun.addCommand("MxTest_WritexData",n3),X.MxFun.addCommand("MxTest_DrawLine",i3),X.MxFun.addCommand("MxTest_InsertBlock",r3),X.MxFun.addCommand("MxTest_GetAllLayer",o3),X.MxFun.addCommand("MxTest_AddLayer",a3),X.MxFun.addCommand("MxTest_GetAllTextStyle",l3),X.MxFun.addCommand("MxTest_GetAllBlock",u3),X.MxFun.addCommand("MxTest_GetAllLinetype",s3),X.MxFun.addCommand("Mx_Test_DrawTable",h3),X.MxFun.addCommand("Mx_Test_QRCode",d3),X.MxFun.addCommand("MxTest_InsertStamp",p3),X.MxFun.addCommand("MxTest_LineTypeTest",f3),X.MxFun.addCommand("TestGentEntityOnLayer",QS),X.MxFun.addCommand("MxTest_GetNamedObjectsDictionary",g3),X.MxFun.addCommand("MxTest_GetObjectExDictionaryData",m3),X.MxFun.addCommand("MxTest_WriteXRecord",y3),X.MxFun.addCommand("MxTest_AddTextStyleTable",c3),X.MxFun.addCommand("Mx_Test_ChangeColor",_3),X.MxFun.addCommand("Mx_Test_ChangeVisible",v3),X.MxFun.addCommand("Mx_Test_ChangeEntityLayer",x3),X.MxFun.addCommand("Mx_ChaneEntityDrawOrder",b3),X.MxFun.addCommand("Mx_MxCompare",M3),X.MxFun.addCommand("MxTest_ModifyAllEntityColor",T3)}function C3(){return Qe(this,null,function*(){let{baseUrl:e="",saveDwgUrl:t="",mxfilepath:i=""}=xl().getUploadFileConfig();M.MxCpp.getCurrentMxCAD().saveFileToUrl(t,(l,c)=>{try{let h=JSON.parse(c);if(h.ret=="ok"){let f=e+i+h.file;fetch(f).then(r=>Qe(this,null,function*(){const v=yield r.blob();M.MxTools.saveAsFileDialog({blob:v,filename:h.file,types:[{description:"dwg图纸",accept:{"application/octet-stream":[".dwg"]}}]})}))}else console.log(c)}catch(h){console.log("Mx: sserverResult error")}})})}function A3(){return Qe(this,null,function*(){let{baseUrl:e="",mxfilepath:t="",saveUrl:i=""}=xl().getUploadFileConfig();M.MxCpp.getCurrentMxCAD().saveFileToUrl(i,(l,c)=>{try{let h=JSON.parse(c);if(h.ret=="ok"){let f=e+t+h.file;M.MxTools.downloadFileFromUrl(f,h.file)}else console.log(c)}catch(h){console.log("Mx: sserverResult error")}})})}function D3(){return Qe(this,null,function*(){M.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/8c79da20e232495888dbb0da17459399.mxweb")})}function P3(){return Qe(this,null,function*(){M.MxCpp.getCurrentMxCAD().newFile()})}function S3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrPoint;e.setMessage(` 指定输出范围第一点:`);let t=yield e.go();if(!t)return;e.setMessage(` 指定输出范围第二点:`),e.setUserDraw((r,v)=>{v.setColor(16711680);let x=new M.McDbPolyline;x.addVertexAt(t),x.addVertexAt(new M.McGePoint3d(t.x,r.y)),x.addVertexAt(r),x.addVertexAt(new M.McGePoint3d(r.x,t.y)),x.constantWidth=X.MxFun.screenCoordLong2Doc(2),x.isClosed=!0,v.drawMcDbEntity(x);let w=[];w.push(t.toVector3()),w.push(new THREE.Vector3(t.x,r.y)),w.push(r.toVector3()),w.push(new THREE.Vector3(r.x,t.y)),v.setColor(12868),v.drawSolid(w,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let{baseUrl:l="",mxfilepath:c="",printPdfUrl:h=""}=xl().getUploadFileConfig();console.log(xl().getUploadFileConfig());let f={width:"2100",height:"2970",bd_pt1_x:""+t.x,bd_pt1_y:""+t.y,bd_pt2_x:""+i.x,bd_pt2_y:""+i.y};M.MxCpp.getCurrentMxCAD().saveFileToUrl(h,(r,v)=>{try{let x=JSON.parse(v);if(x.ret=="ok"){let w=l+c+x.file;M.MxTools.downloadFileFromUrl(w,x.file)}else console.log(v)}catch(x){console.log("Mx: sserverResult error")}},void 0,JSON.stringify(f))})}function L3(){return Qe(this,null,function*(){let e=new M.MxCADUiPrPoint;e.setMessage(` 指定输出范围第一点:`);let t=yield e.go();if(!t)return;e.setMessage(` 指定输出范围第二点:`),e.setUserDraw((r,v)=>{v.setColor(16711680);let x=new M.McDbPolyline;x.addVertexAt(t),x.addVertexAt(new M.McGePoint3d(t.x,r.y)),x.addVertexAt(r),x.addVertexAt(new M.McGePoint3d(r.x,t.y)),x.constantWidth=X.MxFun.screenCoordLong2Doc(2),x.isClosed=!0,v.drawMcDbEntity(x);let w=[];w.push(t.toVector3()),w.push(new THREE.Vector3(t.x,r.y)),w.push(r.toVector3()),w.push(new THREE.Vector3(r.x,t.y)),v.setColor(12868),v.drawSolid(w,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let{baseUrl:l="",mxfilepath:c="",cutDwgUrl:h=""}=xl().getUploadFileConfig();console.log(xl().getUploadFileConfig());let f={bd_pt1_x:""+t.x,bd_pt1_y:""+t.y,bd_pt2_x:""+i.x,bd_pt2_y:""+i.y};M.MxCpp.getCurrentMxCAD().saveFileToUrl(h,(r,v)=>{try{let x=JSON.parse(v);if(x.ret=="ok"){let w=l+c+x.file;M.MxTools.downloadFileFromUrl(w,x.file)}else console.log(v)}catch(x){console.log("Mx: sserverResult error")}},void 0,JSON.stringify(f))})}function I3(t){return Qe(this,arguments,function*({param:e}){M.MxCpp.getCurrentMxCAD().openWebFile(e)})}function R3(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD();e.saveFile(e.getCurrentFileName(),t=>{window.parent.postMessage({cmd:"MKY_Download_Mxweb",file:t})},!1,!1)})}function k3(){X.MxFun.addCommand("Mx_Export_DWG_test",C3),X.MxFun.addCommand("Mx_Export_MxWeb",A3),X.MxFun.addCommand("Mx_Open_MxWeb",D3),X.MxFun.addCommand("MxTest_NewFile",P3),X.MxFun.addCommand("Mx_Export_Pdf",S3),X.MxFun.addCommand("Mx_Cut_Dwg",L3),X.MxFun.addCommand("MKY_Open_Mxweb",I3),X.MxFun.addCommand("MKY_Download_Mxweb",R3)}function z3(){return Qe(this,null,function*(){let e="0601",t="001A",i=new M.MxCADSelectionSet,l=new M.MxCADResbuf;l.AddMcDbEntityTypes("TEXT,MTEXT,INSERT,ACAD_PROXY_ENTITY"),i.allSelect(l);let c,h,f=i.count();for(let r=0;r{let P=L.getMcDbEntity();(P.textString==e||P.textString==t)&&A++}),A==2){c=w.position,h=w.getBoundingBox();break}}else if(x instanceof M.McDbProxyEntity){let w=x,b=w.getAllTextContent(),A=0;if(b.forEach(L=>{L==e&&A++}),A>=1){h=w.getBoundingBox(),h&&h.ret&&(c=new M.McGePoint3d(h.minPt.x+(h.maxPt.x-h.minPt.x)*.5,h.minPt.y+(h.maxPt.y-h.minPt.y)*.5));break}}}if(h&&h.ret){console.log(h);let r=h.minPt.distanceTo(h.maxPt)*2;X.MxFun.getCurrentDraw().zoomW(new THREE.Vector3(h.minPt.x-r,h.minPt.y-r,0),new THREE.Vector3(h.maxPt.x+r,h.maxPt.y+r,0))}else c?X.MxFun.getCurrentDraw().zoomCenter(c.x,c.y):console.log("没有找到文字:"+e)})}function F3(){return Qe(this,null,function*(){const e=new M.MxCADUiPrEntity;e.setMessage("请选择目标文字");const t=yield e.go();if(!t.id)return;const i=t.getMcDbEntity(),l=new M.MxCADSelectionSet,c=[];l.allSelect(new M.MxCADResbuf([M.DxfCode.kEntityType,"TEXT"])),l.forEach(r=>Qe(this,null,function*(){let v=r.getMcDbEntity();if(v.textString==i.textString){const x=v.position;console.log("文字位置:X:"+x.x+"Y:"+x.y+"Z:"+x.z);const w=v.height;let{minPt:b,maxPt:A,ret:L}=v.getBoundingBox();if(!L)return;const P=M.McGeVector3d.kXAxis.normalize().mult(w*4),R=M.McGeVector3d.kYAxis.normalize().mult(w*4);b.addvec(P.negate()).addvec(R.negate()),A.subvec(P).subvec(R);let F=Math.abs(b.x-A.x),V=Math.abs(b.y-A.y);if(F<1||V<1)return;let j=200,J=j*V/F;c.push({width:j,height:J,range_pt1:b.toVector3(),range_pt2:A.toVector3()})}}));let h="";for(let r=0;r'}let f=window.open();f!=null&&f.document.write(`
${h}
`)})}function B3(e){return new Promise((t,i)=>{X.MxFun.getCurrentDraw().createCanvasImageData(l=>{t(l)},e)})}function O3(){X.MxFun.addCommand("MxTest_FindText",z3),X.MxFun.addCommand("Mx_Test_GetText",F3)}class wm extends M.McDbCustomEntity{constructor(t){super(t),this.pt1=new M.McGePoint3d,this.pt2=new M.McGePoint3d}create(t){return new wm(t)}getTypeName(){return"McDbTestLineCustomEntity"}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=c):t==1&&(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t}worldDraw(t){let i=new M.McDbPolyline;i.addVertexAt(this.pt1),i.addVertexAt(this.pt2),t.drawEntity(i)}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function N3(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrPoint;t.setMessage(` 指定一点:`);let i=yield t.go();if(!i)return;t.setBasePt(i),t.setUseBasePt(!0),t.setMessage(` 指定二点:`);let l=yield t.go();if(!l)return;let c=new wm;c.setPoint1(i),c.setPoint2(l),e.drawEntity(c)})}function U3(){new wm().rxInit(),X.MxFun.addCommand("MxTest_DrawCustomEntity",N3)}function V3(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成块的对象:"))||e.count()==0)return;let t=M.MxCpp.getCurrentMxCAD(),l=t.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),c=l.getMcDbBlockTableRecord();if(c==null)return;let h,f,r,v;if(e.forEach(A=>{let L=A.getMcDbEntity();if(!L)return;let P=L.clone();c.appendAcDbEntity(P);let R=L.getBoundingBox();R.ret&&(h?(h>R.minPt.x&&(h=R.minPt.x),f>R.minPt.y&&(f=R.minPt.y),r{let L=A.getMcDbEntity();L&&L.erase()})})}function G3(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成块的对象:"))||e.count()==0)return;let t=M.MxCpp.getCurrentMxCAD(),i=t.getDatabase().getBlockTable(),l=new M.McDbBlockTableRecord,c=i.add(l),h=c.getMcDbBlockTableRecord();if(h==null)return;let f,r,v,x;if(e.forEach(J=>{let ne=J.getMcDbEntity();if(!ne)return;let H=ne.clone();h.appendAcDbEntity(H);let Q=ne.getBoundingBox();Q.ret&&(f?(f>Q.minPt.x&&(f=Q.minPt.x),r>Q.minPt.y&&(r=Q.minPt.y),v{if(H===1010){const Q=new M.McGePoint3d(J.x,J.y,J.z);F.append(Q)}}),A.createSpatialFilter(),A.scaleFactors=new M.McGePoint3d(3,3,3),A.getSpatialFilterId().getMcDbObject().setBoundary(F),P.center=A.position,P.radius=P.radius*3,t.drawEntity(P)})}function W3(){X.MxFun.addCommand("MxTest_SelectEntitysToBlock",V3),X.MxFun.addCommand("MxTest_SelectEntitysToSpatialFilterBlock",G3)}function j3(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定填充区域内部一点:`),e.disableAllTrace(!0),e.setDisableOsnap(!0);let t=yield e.go();if(!t)return;let i=M.MxCADUtility.builderHatchFromPoint(t);if(!i){X.MxFun.acutPrintf(`没有找到闭合区域 `);return}M.MxCpp.getCurrentMxCAD().drawEntity(i)})}function H3(){X.MxFun.addCommand("MxTest_DrawHatchFormPoint",j3)}const W_={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 $3(e){if(/^\d+,\s*\d+,\s*\d+$/.test(e))return e.split(",").map(Number);if(/^0x[0-9a-fA-F]{6}$/.test(e)){const t=parseInt(e,16);return[t>>16&255,t>>8&255,t&255]}else if(/^#[0-9a-fA-F]{6}$/.test(e)){const t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}else if(W_[e.toLowerCase()]){const t=e.toLowerCase();if(W_[t])return W_[t]}else{const t=new M.McCmColor;return t.setColorIndex(256),[t.red,t.green,t.blue]}}const q3=e=>{const t=M.MxCpp.getCurrentDatabase().layerTable;if(t.has(e))return;const i=new M.McDbLayerTableRecord;i.color=new M.McCmColor(0,0,0),i.isFrozen=!1,i.isLocked=!1,i.isOff=!1,i.lineWeight=M.McDb.LineWeight.kLnWtByLayer,i.name=e,t.add(i)},ys=[{name:"color",description:"颜色",type:"str",required:!0},{name:"layer",description:"图层",type:"str",required:!0},{name:"lineweight",description:"线重",type:"float",required:!0}],_s=(e,t)=>{t.layer&&q3(t.layer);const i=l=>{t.color?l.trueColor=new M.McCmColor(...$3(t.color)):l.trueColor=new M.McCmColor(M.MxCpp.getCurrentDatabase().getCurrentlyDrawColor()),t.layer?l.layer=t.layer:l.layer=M.MxCpp.getCurrentDatabase().getCurrentlyLayerName(),t.lineweight&&(l.lineweight=t.lineweight)};Array.isArray(e)?e.forEach(i):e&&i(e)},X3=e=>{const t=e.split(",").map(c=>Number(c)),i=[];let l=0;for(;l{if(typeof e=="object"&&"x"in e&&"y"in e)return new M.McGePoint3d(e.x,e.y);if(Array.isArray(e))return new M.McGePoint3d(e[0],e[1]);if(typeof e=="string"){const[t,i]=e.split(",").map(l=>Number(l));if(typeof t=="number"&&typeof i=="number")return new M.McGePoint3d(t,i)}};class Z3{call(t){if(console.log(t),t&&t.pt1&&t.pt2){let i=M.MxCpp.getCurrentMxCAD();t.pt1&&(t.pt1=hr(t.pt1)),t.pt2&&(t.pt2=hr(t.pt2));const l=i.drawLine(t.pt1.x,t.pt1.y,t.pt2.x,t.pt2.y);_s(l.getMcDbEntity(),t),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},...ys]}}}function Y3(){wo.regist(Z3)}class K3{call(t){if(console.log(t),t&&t.cen&&t.radius){t.cen&&(t.center=hr(t.cen));let i=M.MxCpp.getCurrentMxCAD();const l=i.drawCircle(t.center.x,t.center.y,t.radius);_s(l.getMcDbEntity(),t),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},...ys]}}}const J3=()=>{wo.regist(K3)};function Wr(e,t,i,l,c){const h=e.x,f=e.y,r=t.x,v=t.y,x=i.x,w=i.y,b=l.x,A=l.y,L=(h-r)*(w-A)-(f-v)*(x-b);if(L===0)return null;const P=((h-x)*(w-A)-(f-w)*(x-b))/L,R=-((h-r)*(f-w)-(f-v)*(h-x))/L,F=h+P*(r-h),V=f+P*(v-f),j=new M.McGePoint3d(F,V,0);return c||P>0&&P<1&&R>0&&R<1?j:null}function ou(e,t){const i=t.x,l=t.y;let c=!1;for(let h=0,f=e.length-1;hl!=w>l&&i<(x-r)*(l-v)/(w-v)+r&&(c=!c)}return c}function md(e,t,i,l){const c=e-i,h=t-l;let f=0;return c==0?f=Math.PI/2:f=Math.atan(Math.abs(h/c)),c<0&&h>=0?f=Math.PI-f:c<0&&h<0?f=Math.PI+f:c>=0&&h<0&&(f=Math.PI*2-f),f}function gd(e,t,i,l){const c=new M.McDbArc;return c.center=e,c.radius=t,c.startAngle=i,c.endAngle=l,c}class Q3{call(t){return Qe(this,null,function*(){console.log(t);let{center:i,radius:l,startAngle:c,endAngle:h,is3PDraw:f,point1:r,point2:v,point3:x}=t,w=M.MxCpp.getCurrentMxCAD();w.newFile(),w.zoomAll();const b=new M.MxCADUiPrPoint,A=new M.MxCADUiPrDist;if(f){if(r&&(r=hr(r)),v&&(v=hr(v)),x&&(x=hr(x)),b.setKeyWords(""),!r&&(b.setMessage("指定圆弧起点"),b.setUserDraw((P,R)=>{if(!v||!x)return;const F=new M.McDbArc;F.computeArc(P.x,P.y,v.x,v.y,x.x,x.y),R.drawMcDbEntity(F)}),r=yield b.go(),!r)||!v&&(b.setMessage("指定圆弧第二个点"),b.setUserDraw((P,R)=>{if(!r||!x)return;const F=new M.McDbArc;F.computeArc(r.x,r.y,P.x,P.y,x.x,x.y),R.drawMcDbEntity(F)}),v=yield b.go(),!v)||!x&&(b.setMessage("指定圆弧的端点"),b.setUserDraw((P,R)=>{if(!r||!v)return;const F=new M.McDbArc;F.computeArc(r.x,r.y,v.x,v.y,P.x,P.y),R.drawMcDbEntity(F)}),x=yield b.go(),!x))return;const L=new M.McDbArc;console.log(r.x,r.y,v.x,v.y,x.x,x.y),L.computeArc(r.x,r.y,v.x,v.y,x.x,x.y),_s(L,t),w.drawEntity(L),w.updateDisplay()}else{if(i&&(i=hr(i)),c&&(c=c*(Math.PI/180)),h&&(h=h*(Math.PI/180)),!i){b.setMessage("指定圆弧圆心"),b.setKeyWords(""),b.setUserDraw((R,F)=>{l&&F.drawMcDbEntity(gd(R,l,c||0,h||Math.PI*2))});const P=yield b.go();if(!P)return;i=P}if(!l&&(A.setBasePt(i),A.setMessage(M._ML_String("MxAiDrawCircleArc_Radius","指定圆弧半径")),A.setKeyWords(""),A.setUserDraw((P,R)=>{if(!i)return;const F=P.distanceTo(i);R.drawMcDbEntity(gd(i,F,c||0,h||Math.PI*2))}),l=yield A.go(),!l))return;if(!c){if(!i)return;A.setBasePt(i),A.setMessage(M._ML_String("MxAiDrawCircleArc_StartAngle","指定圆弧开始角")),A.setKeyWords(""),A.setUserDraw((R,F)=>{i&&l&&(c=md(i.x,i.y,R.x,R.y)-Math.PI,F.drawMcDbEntity(gd(i,l,c||0,h||Math.PI*2)))});const P=yield A.go();if(!P)return;A.getDetailedResult()===X.DetailedResult.kCoordIn&&(c=P*(Math.PI/180))}if(!h){if(!i)return;A.setBasePt(i),A.setMessage(M._ML_String("MxAiDrawCircleArc_EndAngle","指定圆弧结束角")),A.setKeyWords(""),A.setUserDraw((R,F)=>{i&&l&&(h=md(i.x,i.y,R.x,R.y)-Math.PI,F.drawMcDbEntity(gd(i,l,c||0,h||Math.PI*2)))});const P=yield A.go();if(!P)return;A.getDetailedResult()===X.DetailedResult.kCoordIn&&(h=P*(Math.PI/180))}const L=gd(i,l,c,h);_s(L,t),w.drawEntity(L),w.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},...ys]}}}const eL=()=>{wo.regist(Q3)};function J1(e=new M.McGePoint3d,t=new M.McGePoint3d,i=3){const l=t.x,c=t.y,h=e.x,f=e.y,r=Math.max(3,i),x=Math.sqrt(fx(l-h,2)+fx(c-f,2))/Math.cos(Math.PI/r),w=Math.atan2(c-f,l-h)-Math.PI/r,b=[];for(let A=0;A"),x.setKeyWords(""),x.clearLastInputPoint(),l=(yield x.go())||5}if(i){if(r)r=hr(r);else{const A=new M.MxCADUiPrPoint;if(A.setMessage(` 指定正多变形的中心点`),A.setKeyWords(""),A.clearLastInputPoint(),r=yield A.go(),!r)return}let x=M.McGeVector3d.kXAxis,w;if(!f){const A=new M.MxCADUiPrDist;A.setMessage(M._ML_String("MxAiDrawPolygon_radius","指定圆的半径")),A.setKeyWords(""),A.setBasePt(r),A.setUserDraw((P,R)=>{if(v){const F=P.distanceTo(r);x=P.sub(r);const V=r.clone().addvec(P.sub(r).normalize().mult(F)),j=J1(r,V,l),J=new M.McDbPolyline;j.forEach(ne=>{J.addVertexAt(ne)}),J.isClosed=!0,R.drawMcDbEntity(J)}else{w=P;const F=new M.McDbPolyline;Q1(r,P,l).forEach(V=>{F.addVertexAt(V)}),F.isClosed=!0,R.drawMcDbEntity(F)}});const L=yield A.go();if(!L)return;f=L}const b=new M.McDbPolyline;if(b.isClosed=!0,v){const A=r.clone().addvec(x.normalize().mult(f));J1(r,A,l).forEach(P=>{b.addVertexAt(P)})}else{if(!w){const A=M.McGeVector3d.kXAxis.clone().rotateBy(Math.PI/l).mult(f);w=r.clone().addvec(A)}Q1(r,w,l).forEach(A=>{b.addVertexAt(A)})}M.MxCpp.getCurrentMxCAD().drawEntity(b)}else{const x=b=>{const A=new M.McDbPolyline;return tL(c,b,l||5).forEach(P=>{A.addVertexAt(P)}),A.isClosed=!0,A};if(c)c=hr(c);else{const b=new M.MxCADUiPrPoint;if(b.clearLastInputPoint(),b.setMessage(` 指定边的第一个端点`),b.setKeyWords(""),c=yield b.go(),!c)return;b.setUserDraw((A,L)=>{L.drawMcDbEntity(x(A))})}if(h)h=hr(h);else{const b=new M.MxCADUiPrPoint;b.setBasePt(c),b.setMessage(` 指定边的第二个端点`),h=yield b.go()}if(!h)return;const w=x(h);M.MxCpp.getCurrentMxCAD().drawEntity(w)}})}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 iL=()=>{wo.regist(nL)},eb=(e,t,i)=>{const l=Math.cos(i),c=Math.sin(i),h=t.x-e.x,f=t.y-e.y,r=h*l-f*c+e.x,v=h*c+f*l+e.y,x=t.z;return new M.McGePoint3d(r,v,x)},j_=(e,t,i=0)=>{const l=new M.McGePoint3d((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2),c=new M.McGePoint3d(e.x,t.y,e.z),h=new M.McGePoint3d(t.x,e.y,t.z),f=eb(l,c,i),r=eb(l,h,i);return[e,f,t,r]},tb=(e,t)=>[t.x>=e.x&&t.y>=e.y,t.x=e.y,t.x=e.x&&t.yP.angleTo1(i)&&(R=A),M.MxCADUtility.calcBulge(e,R,t).val}class oL{call(t){return Qe(this,null,function*(){console.log(t),M.MxCpp.getCurrentMxCAD().newFile();let{pt1:i,pt2:l,chamfer1Length:c,chamfer2Length:h,filletRadius:f,lineWidth:r,area:v,rectLength:x,rectWidth:w,rotationAngle:b}=t;const A=(R,F)=>{const[V,j,J,ne]=j_(R,F,b),H=new M.McDbPolyline;return H.addVertexAt(V,0,r,r),H.addVertexAt(j,0,r,r),H.addVertexAt(J,0,r,r),H.addVertexAt(ne,0,r,r),H.isClosed=!0,r&&(H.constantWidth=r),H},L=(R,F)=>{let V;if(f){const j=nb(j_(R,F,b),f,f),[J,ne,H,Q]=tb(R,F);if(j.length===8){V||(V=new M.McDbPolyline);const ae=(he,Oe,Ve)=>{let He=new M.McGeVector3d(Ve);const at=rL(he,Oe,He);V.addVertexAt(he,at,r,r),V.addVertexAt(Oe,0,r,r)},ie=new M.McGeVector3d(-1,0),le=new M.McGeVector3d(0,1),fe=new M.McGeVector3d(1,0),me=new M.McGeVector3d(0,-1);Q&&(le.y=-1,fe.x=1,me.y=1),ne&&(ie.x=1,le.y=1,fe.x=-1,me.y=-1),H&&(ie.x=1,le.y=-1,fe.x=-1,me.y=1),ae(j[0],j[1],ie),ae(j[2],j[3],le),ae(j[4],j[5],fe),ae(j[6],j[7],me),V.isClosed=!0}}else(c||h)&&(V||(V=new M.McDbPolyline),nb(j_(R,F,b),c||h,h||c).forEach(J=>{V.addVertexAt(J)}),V.isClosed=!0);return V||(V=A(R,F)),r&&(V.constantWidth=r),V};if(i)i=hr(i);else{const R=new M.MxCADUiPrPoint;if(R.setMessage("指定第一个角点"),R.setKeyWords(""),i=yield R.go(),!i)return}if(v&&(x&&(w=v/x),w&&(x=v/w)),x&&w&&(l=new M.McGePoint3d(i.x+w,i.y+x,0)),l)l=hr(l);else{const R=new M.MxCADUiPrPoint;if(R.setMessage("指定第二个角点"),R.setKeyWords(""),R.setUserDraw((F,V)=>{V.drawMcDbEntity(L(i,F))}),l=yield R.go(),!l)return}const P=L(i,l);_s(P,t),M.MxCpp.getCurrentMxCAD().drawEntity(P)})}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},...ys]}}}function aL(){wo.regist(oL)}const ia=(e,t,i,l,c)=>{const h=new M.McDbEllipse,f=new M.McGePoint3d((e.x+t.x)/2,(t.y+t.y)/2),r=e.sub(t),v=r,x=e.distanceTo(t)/2,b=i/2/x;return h.center=f,h.majorAxis=r,h.minorAxis=v,h.radiusRatio=b,h.startAngle=l,h.endAngle=c,h};class sL{call(t){return Qe(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:c}=t;const h=M.MxCpp.getCurrentMxCAD();h.newFile();const f=new M.MxCADUiPrPoint,r=new M.MxCADUiPrDist;if(i&&(i=hr(i)),l&&(l=hr(l)),!i&&(f.setMessage("指定椭圆的轴端点1"),f.setKeyWords(""),f.setUserDraw((x,w)=>{l&&c&&w.drawMcDbEntity(ia(x,l,c,0,Math.PI*2))}),i=yield f.go(),!i)||!l&&(f.setMessage("指定椭圆的轴端点2"),f.setKeyWords(""),f.setUserDraw((x,w)=>{i&&c&&w.drawMcDbEntity(ia(i,x,c,0,Math.PI*2))}),l=yield f.go(),!l))return;if(!c){r.setMessage("指定半轴长度"),r.setKeyWords("");const x=new M.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(r.setBasePt(x),r.setUserDraw((w,b)=>{i&&b.drawMcDbEntity(ia(i,l,x.distanceTo(w),0,Math.PI*2))}),c=yield r.go(),!c)return}const v=ia(i,l,c,0,Math.PI*2);_s(v,t),h.drawEntity(v)})}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},...ys]}}}class lL{call(t){return Qe(this,null,function*(){let{endPoint1:i,endPoint2:l,halfAxisLength:c,startAngle:h,endAngle:f}=t;const r=M.MxCpp.getCurrentMxCAD();r.newFile();const v=new M.MxCADUiPrPoint,x=new M.MxCADUiPrDist;if(i&&(i=hr(i)),l&&(l=hr(l)),h&&(h=h*(Math.PI/180)),f&&(f=f*(Math.PI/180)),!i&&(v.setMessage("指定椭圆的轴端点1"),v.setKeyWords(""),v.setUserDraw((L,P)=>{l&&c&&P.drawMcDbEntity(ia(L,l,c,0,Math.PI*2))}),i=yield v.go(),!i)||!l&&(v.setMessage("指定椭圆的轴端点2"),v.setKeyWords(""),v.setUserDraw((L,P)=>{i&&c&&P.drawMcDbEntity(ia(i,L,c,0,Math.PI*2))}),l=yield v.go(),!l))return;const w=new M.McGePoint3d((i.x+l.x)/2,(l.y+l.y)/2);if(!c&&(x.setMessage("指定半轴长度"),x.setKeyWords(""),x.setBasePt(w),x.setUserDraw((L,P)=>{i&&P.drawMcDbEntity(ia(i,l,w.distanceTo(L),0,Math.PI*2))}),c=yield x.go(),!c))return;const b=md(w.x,w.y,i.x,i.y);if(!h){x.setMessage(M._ML_String("EllipticalArc_startAngle","指定起点角度")),x.setKeyWords(""),x.setUserDraw((P,R)=>{h=md(w.x,w.y,P.x,P.y)-b-Math.PI,R.drawMcDbEntity(ia(i,l,c,h,Math.PI*2))});const L=yield x.go();if(!L)return;x.getDetailedResult()==X.DetailedResult.kCoordIn&&(h=L*(180/Math.PI))}if(!f){x.setLastInputPoint(w),x.setMessage(M._ML_String("EllipticalArc_endAngle","指定端点角度")),x.setKeyWords(""),x.setUserDraw((P,R)=>{f=md(w.x,w.y,P.x,P.y)-b-Math.PI,R.drawMcDbEntity(ia(i,l,c,h,f))});const L=yield x.go();if(!L)return;x.getDetailedResult()===X.DetailedResult.kCoordIn&&(f=L*(180/Math.PI))}const A=ia(i,l,c,h,f);_s(A,t),r.drawEntity(A)})}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},...ys]}}}const cL=()=>{wo.regist(sL),wo.regist(lL)},ib=class Ho{constructor(t,i,l=50){this.width=50,this.isDraw=!1,this.update(t,i,l)}update(t,i,l=this.width){let c=t.clone().sub(i).normalize();c=new M.McGeVector3d(-c.y,c.x,0).mult(l/2);const h=c.clone().negate();this.outsidePoints=[t.clone().addvec(c),i.clone().addvec(c)],this.insidePoints=[t.clone().addvec(h),i.clone().addvec(h)],this.width=l,this.startPoint=t.clone(),this.endPoint=i.clone(),this.outsideLine?(this.outsideLine.startPoint=this.outsidePoints[0],this.outsideLine.endPoint=this.outsidePoints[1]):this.outsideLine=new M.McDbLine(this.outsidePoints[0],this.outsidePoints[1]),this.insideLine?(this.insideLine.startPoint=this.insidePoints[0],this.insideLine.endPoint=this.insidePoints[1]):this.insideLine=new M.McDbLine(this.insidePoints[0],this.insidePoints[1]),this.startClosedLine?(this.startClosedLine.startPoint=this.outsidePoints[0],this.startClosedLine.endPoint=this.insidePoints[0]):this.startClosedLine=new M.McDbLine(this.outsidePoints[0],this.insidePoints[0]),this.endClosedLine?(this.endClosedLine.startPoint=this.outsidePoints[1],this.endClosedLine.endPoint=this.insidePoints[1]):this.endClosedLine=new M.McDbLine(this.outsidePoints[1],this.insidePoints[1])}clone(){const t=new Ho(this.startPoint,this.endPoint,this.width);return t.insideLine=this.insideLine.clone(),t.outsideLine=this.outsideLine.clone(),t}hiddenStartClosedLine(){this.startClosedLine.visible=!1}hiddenEndClosedLine(){this.endClosedLine.visible=!1}getClosedStartLineToDiffWallInsideLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffWallOutsideLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffWallInsideLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffWallOutsideLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getInsideToDiffInsideIntersectionPoint(t,i=!1){return Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffOutsideIntersectionPoint(t,i=!1){return Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getInsideToDiffOutsideIntersectionPoint(t,i=!1){return Wr(t.outsideLine.startPoint,t.outsideLine.endPoint,this.insideLine.startPoint,this.insideLine.endPoint,i)}getOutsideToDiffInsideIntersectionPoint(t,i=!1){return Wr(t.insideLine.startPoint,t.insideLine.endPoint,this.outsideLine.startPoint,this.outsideLine.endPoint,i)}getClosedStartLineToDiffLineClosedStartLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.startClosedLine.startPoint,t.startClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedStartLineToDiffLineClosedEndLineIntersectionPoint(t,i=!1){return this.startClosedLine.visible?Wr(t.endClosedLine.startPoint,t.endClosedLine.endPoint,this.startClosedLine.startPoint,this.startClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedStartLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.startClosedLine.startPoint,t.startClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}getClosedEndLineToDiffLineClosedEndLineIntersectionPoint(t,i=!1){return this.endClosedLine.visible?Wr(t.endClosedLine.startPoint,t.endClosedLine.endPoint,this.endClosedLine.startPoint,this.endClosedLine.endPoint,i):null}isCorner(t){const i=t.startPoint.sub(t.endPoint).normalize(),l=i.clone().mult(t.width),c=i.clone().mult(-t.width),h=t.insideLine.startPoint.clone().addvec(l),f=t.insideLine.startPoint.clone().addvec(c),r=t.outsideLine.startPoint.clone().addvec(c),v=t.outsideLine.startPoint.clone().addvec(l),x=t.insideLine.endPoint.clone().addvec(l),w=t.insideLine.endPoint.clone().addvec(c),b=t.outsideLine.endPoint.clone().addvec(c),A=t.outsideLine.endPoint.clone().addvec(l),L=ou([h,f,r,v],this.startPoint),P=ou([h,f,r,v],this.endPoint),R=ou([x,w,b,A],this.startPoint),F=ou([x,w,b,A],this.endPoint);return[{start:L,end:P},{start:R,end:F}]}handlingCorners(t){const[i,l]=this.isCorner(t);if(l.start){this.outsideLine.startPoint=t.outsideLine.endPoint=this.getOutsideToDiffOutsideIntersectionPoint(t,!0),this.insideLine.startPoint=t.insideLine.endPoint=this.getInsideToDiffInsideIntersectionPoint(t,!0),this.hiddenStartClosedLine(),t.hiddenEndClosedLine();return}else if(l.end){this.outsideLine.endPoint=t.insideLine.endPoint=this.getOutsideToDiffInsideIntersectionPoint(t,!0),this.insideLine.endPoint=t.outsideLine.endPoint=this.getInsideToDiffOutsideIntersectionPoint(t,!0),this.hiddenEndClosedLine(),t.hiddenEndClosedLine();return}else if(i.start){this.insideLine.startPoint=t.outsideLine.startPoint=this.getInsideToDiffOutsideIntersectionPoint(t,!0),this.outsideLine.startPoint=t.insideLine.startPoint=this.getOutsideToDiffInsideIntersectionPoint(t,!0),this.hiddenStartClosedLine(),t.hiddenStartClosedLine();return}else if(i.end){this.outsideLine.endPoint=t.outsideLine.startPoint=this.getOutsideToDiffOutsideIntersectionPoint(t,!0),this.insideLine.endPoint=t.insideLine.startPoint=this.getInsideToDiffInsideIntersectionPoint(t,!0),this.hiddenEndClosedLine(),t.hiddenStartClosedLine();return}}processingIntersection(){const t=[];Ho.lines.forEach(i=>{const l=this.getInsideToDiffInsideIntersectionPoint(i),c=this.getInsideToDiffOutsideIntersectionPoint(i),h=this.getOutsideToDiffOutsideIntersectionPoint(i),f=this.getOutsideToDiffInsideIntersectionPoint(i);(l||c||h||f)&&t.push({diffLine:i,intersectionPoints:[l,c,h,f]})}),t.forEach(({diffLine:i,intersectionPoints:l})=>{const[c,h]=this.isCorner(i);c.end||c.start||h.start||h.start;const[f,r,v,x]=l,w=[i.insideLine.startPoint,i.insideLine.endPoint,i.outsideLine.endPoint,i.outsideLine.startPoint];if(ou(w,this.startPoint),ou(w,this.endPoint),f&&r&&v&&x){const b=Wr(this.startPoint,this.endPoint,i.startPoint,i.endPoint),A=new Ho(this.startPoint,b,this.width),L=new Ho(b,this.endPoint,this.width),P=new Ho(i.startPoint,b,i.width),R=new Ho(b,i.endPoint,i.width);A.insideLine.startPoint=this.insideLine.startPoint,A.outsideLine.startPoint=this.outsideLine.startPoint,L.insideLine.endPoint=this.insideLine.endPoint,L.outsideLine.endPoint=this.outsideLine.endPoint,i.remove(),this.remove(),A.draw(),L.draw(),P.draw(),R.draw()}else if(v&&r||f&&x){const b=Wr(this.startPoint,this.endPoint,i.startPoint,i.endPoint,!0),A=new Ho(i.startPoint,b,i.width);A.hiddenEndClosedLine();const L=new Ho(b,i.endPoint,i.width);L.hiddenStartClosedLine(),i.remove(),A.draw(),L.draw()}else{if(t.length===1)return this.handlingCorners(i);h.start?(console.log("endCorner.start"),v&&(i.outsideLine.endPoint=this.outsideLine.startPoint=v),f&&(i.insideLine.endPoint=this.insideLine.startPoint=f),this.hiddenStartClosedLine(),i.hiddenEndClosedLine()):h.end?(console.log("endCorner.end"),x&&(i.insideLine.endPoint=this.outsideLine.endPoint=x),r&&(i.outsideLine.endPoint=this.insideLine.endPoint=r),this.hiddenEndClosedLine(),i.hiddenEndClosedLine()):c.start?(console.log("startCorner.start"),r&&(i.outsideLine.startPoint=this.insideLine.startPoint=r),x&&(i.insideLine.startPoint=this.outsideLine.startPoint=x),i.hiddenStartClosedLine(),this.hiddenStartClosedLine()):c.end&&(console.log("startCorner.end"),v&&(i.outsideLine.startPoint=this.outsideLine.endPoint=v),f&&(i.insideLine.startPoint=this.insideLine.endPoint=f),i.hiddenStartClosedLine(),this.hiddenEndClosedLine())}})}draw(t=!0){if(this.isDraw)return;const i=M.MxCpp.getCurrentMxCAD();if(this.outsideLine&&this.outsideLine.erase(),this.insideLine&&this.insideLine.erase(),!i)return;this.outsideLine.trueColor=new M.McCmColor(255,0,0),this.outsideId=i.drawEntity(this.outsideLine),this.insideLine.trueColor=new M.McCmColor(0,255,255),this.insideId=i.drawEntity(this.insideLine);const l=this.outsideId.getMcDbEntity();l&&(this.outsideLine=l);const c=this.insideId.getMcDbEntity();c&&(this.insideLine=c),this.startClosedId=i.drawEntity(this.startClosedLine),this.endClosedId=i.drawEntity(this.endClosedLine);const h=this.startClosedId.getMcDbEntity();h&&(this.startClosedLine=h);const f=this.endClosedId.getMcDbEntity();f&&(this.endClosedLine=f),i.updateDisplay(),Ho.lines.add(this),this.isDraw=!0,t&&this.processingIntersection()}remove(){this.endClosedId&&this.endClosedId.erase(),this.startClosedId&&this.startClosedId.erase(),this.insideId&&this.insideId.erase(),this.outsideId&&this.outsideId.erase(),Ho.lines.delete(this)}};ib.lines=new Set;let uL=ib;class hL{call(t){if(t&&t.points){let i=M.MxCpp.getCurrentMxCAD();const l=X3(t.points);if(l.length<2)return;l.forEach((c,h)=>{const f=l[h+1];if(!f)return;new uL(c,f,t.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},...ys]}}}class dL{call(t){return Qe(this,null,function*(){let i=M.MxCpp.App.getCurrentMxCAD();if(t.name){const c=i.getDatabase().getBlockTable().get(t.name);if(!c||!c.isValid())return;let h=new M.McDbBlockReference;h.blockTableRecordId=c;let f=h.getBoundingBox(),r=0;if(f.ret){let v=f.maxPt.distanceTo(f.minPt);v>1e-5&&(r=i.getMxDrawObject().screenCoordLong2Doc(100)/v,h.setScale(r))}h.position=new M.McGePoint3d(t.pos[0],t.pos[1]),i.drawEntity(h),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 pL(){wo.regist(hL),wo.regist(dL)}class fL{call(t){return Qe(this,null,function*(){let i=M.MxCpp.getCurrentMxCAD();console.log(t),i.newFile();let l;const c=typeof t.isMText=="undefined"?!1:t.isMText,h=()=>{const r=new M.McDbMText;return r.textHeight=t.textSize||100,r.location=t.textPos||new M.McGePoint3d,r.contents=t.textString||"",r},f=()=>{const r=new M.McDbText;return r.height=t.textSize||100,r.textString=t.textString||"",r.position=t.textPos||new M.McGePoint3d,r};if(!t.textString){const r=new M.MxCADUiPrString;r.setMessage("请输入文字");const v=yield r.go();if(!v)return;t.textString=v}if(t.textPos)t.textPos=hr(t.textPos);else{const r=new M.MxCADUiPrPoint;r.clearLastInputPoint(),r.setMessage("请指定文字位置");const v=yield r.go();if(r.setUserDraw((x,w)=>{if(t.textPos=x,c){const b=h();w.drawMcDbEntity(b)}else{const b=f();w.drawMcDbEntity(b)}}),!v)return;t.textPos=v}if(!t.textSize){const r=new M.MxCADUiPrPoint;r.clearLastInputPoint(),r.setMessage("通过线段长度确定文字高度");const v=yield r.go();if(v){r.setUserDraw((w,b)=>{if(t.textSize=v.distanceTo(w),c){const A=h();b.drawMcDbEntity(A)}else{const A=f();b.drawMcDbEntity(A)}});const x=yield r.go();x&&(t.textSize=x.distanceTo(v))}}if(c){const r=h();l=i.drawEntity(r)}else{const r=f();l=i.drawEntity(r)}_s(l.getMcDbEntity(),t),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},...ys]}}}function mL(){wo.regist(fL)}class gL{call(t){if(console.log(t),t.isWithdraw){typeof t.withdrawNum!="number"&&(t.withdrawNum=1);for(let i=0;i{i.operation_code=t,M.MxCpp.Ai.registTool(i)}),M.MxCpp.Ai.reloadTools({operation_code:t})}}let wo=new _L;function vL(){return Qe(this,null,function*(){let e=new M.MxCADUiPrString;e.setMessage(` human:`);let t=yield e.go();t&&M.MxCpp.Ai.chat_tool(t)})}function xL(){return Qe(this,null,function*(){let e=new M.MxCADUiPrString;e.setMessage(` 输入 server_operate_code:`);let t=yield e.go();t&&wo.regist_server(t)})}function bL(){X.MxFun.addCommand("Mx_Ai",vL),X.MxFun.addCommand("Mx_AiRegistServer",xL),Y3(),J3(),eL(),iL(),cL(),pL(),mL(),yL(),aL()}function wL(e,t){let i=40,l=new M.MxCADResbuf;l.AddString("电杆层",0),l.AddString("INSERT",5020);let c=new M.MxCADSelectionSet;c.crossingSelect(e.x-i,e.y-i,e.x+i,e.y+i,l);let h=[];if(c.forEach(f=>{let r=f.getMcDbEntity();if(r){let v=r;t[v.getObjectID().id]&&h.push({dist:v.position.distanceTo(e),blk:t[v.getObjectID().id]})}}),h.length!=0)return h.sort((f,r)=>f.dist-r.dist),h[0].dist{let x=v.getMcDbEntity();if(x){let w=x,b=w.endPoint,A=w.startPoint.distanceTo(c.position);if(A>w.endPoint.distanceTo(c.position)&&(A=w.endPoint.distanceTo(c.position),b=w.startPoint),A{let h=c.getMcDbEntity();if(h){let f=h,r=f.getAllAttribute(),v={};r.forEach(x=>{let w=x.getMcDbEntity();w.tag=="杆号"&&(v.tag=w.textString)}),v.tag&&(v.handle=f.getHandle(),i[c.id]={ref:f,tag:v.tag},console.log(v))}});let l={};Object.keys(i).forEach(c=>{ML(c,i,l)}),Object.keys(l).forEach(c=>{console.log(l[c])})})}function EL(){X.MxFun.addCommand("MxTest_UserGetData",TL)}class vs extends M.McDbCustomEntity{constructor(t){super(t),this.pt1=new M.McGePoint3d,this.pt2=new M.McGePoint3d,this._text="",this._textsize=10}create(t){return new vs(t)}getTypeName(){return"McDbLineText"}set text(t){this._text=t}get text(){return this._text}set textsize(t){this._textsize=t}get textsize(){return this._textsize}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,this._text=t.readString("text").val,this._textsize=t.readDouble("textsize").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),t.writeString("text",this._text),t.writeDouble("textsize",this._textsize),!0}fineLink(t){let i={},l=this.getObjectID(),c=this._textsize*.5,h=new M.MxCADResbuf;h.AddString("McDbCustomEntity",5020);let f=new M.MxCADSelectionSet;return f.crossingSelect(t.x-c,t.y-c,t.x+c,t.y+c,h),f.forEach(r=>{if(r==l)return;let v=r.getMcDbEntity();if(v&&v instanceof vs){let x=v,w=x.getPoint1(),b=0,A=x.getPoint1().distanceTo(t);A>x.getPoint2().distanceTo(t)&&(A=x.getPoint2().distanceTo(t),w=x.getPoint2(),b=1),A{let w=new M.McObjectId(v).getMcDbEntity();r[v].link_pos==0?w.setPoint1(f):w.setPoint2(f)})}}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t}worldDraw(t){let i=this._textsize*.4,l=this.pt2.sub(this.pt1);l.normalize().mult(i);let c=new M.McDbLine(this.pt1.clone().addvec(l),this.pt2.clone().subvec(l));t.drawEntity(c);let h=this.pt2.sub(this.pt1).mult(.5),f=this.pt1.clone().addvec(h);h.dotProduct(M.McGeVector3d.kXAxis)<0&&h.negate();let r=h.angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),v=this._text;v.length==0&&(v=this.pt1.distanceTo(this.pt2).toFixed(2)),h.perpVector(),h.dotProduct(M.McGeVector3d.kYAxis)<0&&h.negate(),h.normalize().mult(this._textsize*.2);let x=new M.McDbText;x.textString=v,x.position=f.clone().addvec(h),x.alignmentPoint=f.clone().addvec(h),x.rotation=r,x.verticalMode=M.McDb.TextVertMode.kTextBottom,x.horizontalMode=M.McDb.TextHorzMode.kTextCenter,x.height=this._textsize,t.drawEntity(x);let w=new M.McDbCircle;w.center=this.pt1,w.radius=i,t.drawEntity(w);let b=new M.McDbCircle;b.center=this.pt2,b.radius=i,t.drawEntity(b)}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function CL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=new M.McGePoint3d(100,100,0),i=new M.McGePoint3d(200,150,0),l=new M.McGePoint3d(400,50,0),c=new M.McGePoint3d(600,60,0),h=new M.McGePoint3d(200,300,0),f=5,r=new vs;r.setPoint1(t),r.setPoint2(i),r.textsize=f,r.text="xxxx",e.drawEntity(r);let v=new vs;v.setPoint1(i),v.setPoint2(l),v.textsize=f,e.drawEntity(v);let x=new vs;x.setPoint1(l),x.setPoint2(c),x.textsize=f,e.drawEntity(x);let w=new vs;w.setPoint1(i),w.setPoint2(h),w.textsize=f,e.drawEntity(w),e.zoomW(new M.McGePoint3d(-300,-300,0),new M.McGePoint3d(650,500,0)),e.updateDisplay()})}function AL(){X.MxFun.addCommand("MxTest_LineText",CL),new vs().rxInit()}function DL(){EL(),AL()}class yd extends M.McDbCustomEntity{create(t){throw new Error("Method not implemented.")}getTypeName(){throw new Error("Method not implemented.")}dwgInFields(t){throw new Error("Method not implemented.")}dwgOutFields(t){throw new Error("Method not implemented.")}worldDraw(t){throw new Error("Method not implemented.")}}class _d extends yd{constructor(t){super(t),this.pt=new M.McGePoint3d}create(t){return new _d(t)}getTypeName(){return"McDbGisPoint"}dwgInFields(t){return this.pt=t.readPoint("pt").val,!0}dwgOutFields(t){return t.writePoint("pt",this.pt),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0&&(this.pt.x+=i,this.pt.y+=l,this.pt.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt),t}worldDraw(t){t.drawEntity(new M.McDbPoint(this.pt))}setPoint(t){this.assertWrite(),this.pt=t.clone()}getPoint(){return this.pt}}class vd extends yd{constructor(t){super(t),this.pts=[]}create(t){return new vd(t)}getTypeName(){return"McDbGisMultiPoint"}dwgInFields(t){return this.pts=t.readPoints("pts").val,!0}dwgOutFields(t){return t.writePoints("pts",this.pts),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t>=0&&t{t.append(i)}),t}worldDraw(t){this.pts.forEach(i=>{t.drawEntity(new M.McDbPoint(i))})}setPoint(t,i){this.assertWrite(),t>=0&&t=0&&t=0&&t{t.append(i)}),t}worldDraw(t){let i=new M.McDbPolyline;this.pts.forEach(l=>{i.addVertexAt(l)}),t.drawEntity(i)}setPoint(t,i){this.assertWrite(),t>=0&&t=0&&t{t.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(t,i,l,c){this.assertWrite();let h=0;for(let f=0;f{i.forEach(l=>{t.append(l)})}),t}worldDraw(t){for(let i=0;i{c.addVertexAt(h)}),t.drawEntity(c)}}addPoints(t){this.ptss.push(t)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(t){return t>=0&&t{t.writePoints("ptss_"+l,i)}),!0}moveGripPointsAt(t,i,l,c){this.assertWrite();let h=0;for(let f=0;f{i.forEach(l=>{t.append(l)})}),t}worldDraw(t){let i=new M.McDbHatch;for(let l=0;l2&&i.appendLoop(new M.McGePoint3dArray(c))}i.numLoops>0&&t.drawEntity(i)}addPoints(t){this.ptss.push(t)}removeAllPoint(){this.ptss=[]}getPointsCount(){return this.ptss.length}getPoints(t){return t>=0&&t0&&e.drawEntity(i),l.forEach(c=>{c.erase()})})}function LL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标");let i=new xd,l=[],c;for(;;){c&&(t.setBasePt(c),t.setUseBasePt(!0)),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let h=yield t.go();if(h){if(i.addPoint(h),c){let f=new M.McDbLine;f.startPoint=c,f.endPoint=h,l.push(e.drawEntity(f))}c=h}else break}i.getPointCount()>1&&e.drawEntity(i),l.forEach(h=>{h.erase()})})}function IL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标"),t.setKeyWords("[下一段线(N)]");let i=new bd,l=[],c=[],h;for(;;){h?t.setBasePt(h):t.setUseBasePt(!1),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let f=yield t.go();if(t.isKeyWordPicked("N"))l.length>1&&i.addPoints(l),l=[],h=void 0;else if(f){if(l.push(f),h){let r=new M.McDbLine;r.startPoint=h,r.endPoint=f,c.push(e.drawEntity(r))}h=f}else break}l.length>1&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),c.forEach(f=>{f.erase()})})}function RL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint;t.setMessage("点取一个点坐标");let i=new wd,l=[],c=[],h;for(;;){h?t.setBasePt(h):t.setUseBasePt(!1),l.length>2&&t.setKeyWords("[闭合(C)/退出(E)]"),t.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let f=yield t.go();if(t.isKeyWordPicked("C")){let r=new M.McDbLine;r.startPoint=l[0],r.endPoint=l[l.length-1],c.push(e.drawEntity(r)),l.length>2&&i.addPoints(l),l=[],h=void 0}else{if(t.isKeyWordPicked("E"))break;if(f){if(l.push(f),h){let r=new M.McDbLine;r.startPoint=h,r.endPoint=f,c.push(e.drawEntity(r))}h=f}else break}}l.length>2&&i.addPoints(l),i.getPointsCount()>0&&e.drawEntity(i),c.forEach(f=>{f.erase()})})}function kL(){let e=new M.MxCADSelectionSet,t=new M.MxCADResbuf;t.AddMcDbEntityTypes("McDbCustomEntity"),e.allSelect(t);let i={type:"FeatureCollection",features:[]};e.forEach(l=>{let c=l.getMcDbEntity();if(c){if(c instanceof _d){let f=c.getPoint(),r={type:"Feature",properties:{},geometry:{type:"Point",coordinates:[f.x,f.y,f.z]}};i.features.push(r)}else if(c instanceof vd){let h=c,f=[],r=h.getPointCount();for(let x=0;x{const L=new M.McDbCircle(b.x,b.y,b.z,i);if(A%2===0){const P=[];L.IntersectWith(l,M.McDb.Intersect.kOnBothOperands).forEach(R=>{P.push(R)}),L.splitCurves(P).forEach(R=>{const F=R.getPointAtDist(R.getLength().val/2).val;(F.xMath.max(this.pt1.x,this.pt2.x))&&t.drawEntity(R),(F.yMath.max(this.pt1.y,this.pt2.y))&&t.drawEntity(R)})}});const r=[];for(let b=0;b{e.setPoint1(c),e.setPoint2(x),e.setPoint3(x),w.drawMcDbEntity(e)});const f=yield h.go();if(!f)return;e.setPoint2(f);const r=new M.MxCADUiPrPoint;r.setMessage("指定审图标注点"),r.setUserDraw((x,w)=>{e.setPoint3(x),w.drawMcDbEntity(e)});const v=yield r.go();v&&(e.setPoint3(v),M.MxCpp.getCurrentMxCAD().drawEntity(e))})}class Tm extends M.McDbCustomEntity{constructor(t){super(t),this.pt1=new M.McGePoint3d,this.pt2=new M.McGePoint3d}create(t){return new Tm(t)}getTypeName(){return"McDbTestRectangle"}dwgInFields(t){return this.pt1=t.readPoint("pt1").val,this.pt2=t.readPoint("pt2").val,!0}dwgOutFields(t){return t.writePoint("pt1",this.pt1),t.writePoint("pt2",this.pt2),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0?(this.pt1.x+=i,this.pt1.y+=l,this.pt1.z+=c):t==1&&(this.pt2.x+=i,this.pt2.y+=l,this.pt2.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.pt1),t.append(this.pt2),t}worldDraw(t){const i=new M.McDbPolyline;i.isClosed=!0,i.addVertexAt(this.pt1),i.addVertexAt(new M.McGePoint3d(this.pt2.x,this.pt1.y)),i.addVertexAt(this.pt2),i.addVertexAt(new M.McGePoint3d(this.pt1.x,this.pt2.y)),t.drawEntity(i);let l=M.MxCpp.getCurrentMxCAD();const c=new M.McGePoint3d(this.pt2.x,this.pt1.y);l.addDimStyle("MyDimStyle","41,0.18,141,0.09,40,200","77,1,271,3","",""),l.drawDimStyle="MyDimStyle";const h=l.drawDimAligned(this.pt1.x,this.pt1.y+20,c.x,c.y+20,(this.pt1.x+c.x)/2,this.pt1.y+20);t.drawEntity(h.getMcDbEntity()),h.erase();const f=l.drawDimAligned(this.pt2.x+20,this.pt2.y,c.x+20,c.y,c.x+20,(this.pt2.y+c.y)/2);t.drawEntity(f.getMcDbEntity()),f.erase()}setPoint1(t){this.assertWrite(),this.pt1=t.clone()}setPoint2(t){this.assertWrite(),this.pt2=t.clone()}getPoint1(){return this.pt1}getPoint2(){return this.pt2}}function BL(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrPoint;t.setMessage(` 指定第一个角点:`);let i=yield t.go();if(!i)return;const l=new Tm;l.setPoint1(i),t.setMessage(` 指定第二个角点:`),t.setUserDraw((h,f)=>{l.setPoint2(h),f.drawMcDbEntity(l)});let c=yield t.go();c&&(l.setPoint2(c),e.drawEntity(l))})}class Md extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this._radius=1}create(t){return new Md(t)}getTypeName(){return"MxDbTestDivide"}set radius(t){this._radius=t}get radius(){return this._radius}dwgInFields(t){return this.center=t.readPoint("center").val,this._radius=t.readDouble("radius").val,!0}dwgOutFields(t){return t.writePoint("center",this.center),t.writeDouble("radius",this._radius),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.center.x+=i,this.center.y+=l,this.center.z+=c}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.center),t}worldDraw(t){const i=new M.McDbCircle(this.center.x,this.center.y,this.center.z,this._radius);t.drawEntity(i);const{minPt:l,maxPt:c,ret:h}=i.getBoundingBox();if(!h)return;const f=new M.McDbLine(l,c),r=new M.McDbLine(new M.McGePoint3d(l.x,c.y,0),new M.McGePoint3d(c.x,l.y,0));t.drawEntity(f),t.drawEntity(r)}setCenter(t){this.assertWrite(),this.center=t.clone()}getCenter(){return this.center}}function OL(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择要对齐水平标注或竖直标注:"),e.setKeyWords("[水平(H)/竖直(V)]");const t=yield e.go();if(!t)return;const i=new M.MxCADSelectionSet;if(!(yield i.userSelect("选择对齐标注:"))||i.count()==0)return;const l=[];if(i.forEach(x=>{const w=x.getMcDbEntity();if(w.objectName==="McDbRotatedDimension"){const b=w.clone(),A=Math.abs(b.xLine1Point.x-b.xLine2Point.x).toFixed(0),L=Math.abs(b.xLine1Point.y-b.xLine2Point.y).toFixed(0),P=Math.abs(b.dimLinePoint.x-b.xLine1Point.x)+Math.abs(b.dimLinePoint.x-b.xLine2Point.x),R=Math.abs(b.dimLinePoint.y-b.xLine1Point.y)+Math.abs(b.dimLinePoint.y-b.xLine2Point.y);t==="H"&&P.toFixed(0)==A&&l.push(w),t==="V"&&R.toFixed(0)==L&&l.push(w)}}),l.length===0)return;const c=M.MxCpp.getCurrentMxCAD(),h=new M.MxCADUiPrPoint;h.setMessage("设置尺寸线位置");const f=yield h.go();if(!f)return;l.forEach(x=>{x.dimLinePoint=f}),c.updateDisplay();const r=new M.MxCADUiPrPoint;r.setMessage("设置尺寸线界限");const v=yield r.go();v&&(l.forEach(x=>{t==="H"?(x.xLine1Point=new M.McGePoint3d(x.xLine1Point.x,v.y),x.xLine2Point=new M.McGePoint3d(x.xLine2Point.x,v.y)):t==="V"&&(x.xLine1Point=new M.McGePoint3d(v.x,x.xLine1Point.y),x.xLine2Point=new M.McGePoint3d(v.x,x.xLine2Point.y))}),c.updateDisplay())})}function NL(){new Mm().rxInit(),new Tm().rxInit(),new Md().rxInit(),X.MxFun.addCommand("Mx_Approval",FL),X.MxFun.addCommand("Mx_AnnotatedRectangle",BL),X.MxFun.addCommand("Mx_Alignment",OL)}function UL(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择对象:"))||e.count()==0)return;const t=[],i=M.MxCpp.getCurrentMxCAD(),l=new M.MxCADUiPrPoint;l.setMessage("指定基点");const c=yield l.go();if(c)for(;;){const h=new M.MxCADUiPrPoint;h.setMessage(`指定第二个点 `),t.length>0?h.setKeyWords("[阵列(A)/退出(E)/放弃(U)]"):h.setKeyWords("[阵列(A)/退出(E)]"),h.setUserDraw((r,v)=>{v.drawLine(r.toVector3(),c.toVector3()),e.forEach(x=>{let w=x.getMcDbEntity();if(!w)return;let b=w.clone();b.move(c,r),v.drawMcDbEntity(b)})});const f=yield h.go();if(h.getStatus()===X.MrxDbgUiPrBaseReturn.kKeyWord){if(h.isKeyWordPicked("E"))return;if(h.isKeyWordPicked("U"))if(t.length>0)t[t.length-1].forEach(r=>{r.erase()}),t.pop();else return;else if(h.isKeyWordPicked("A")){const r=new M.MxCADUiPrInt;r.clearLastInputPoint(),r.setMessage(`输入要进行阵列的项目数 `);const v=(yield r.go())||1;let x=[];if(h.setUserDraw((b,A)=>{A.drawLine(b.toVector3(),c.toVector3()),x.length=0;let L=b.clone();x.push(L);for(let P=0;P{let R=P.getMcDbEntity();R&&x.forEach(F=>{let V=new M.McGeMatrix3d,j=R.clone();V.clone(),V.setToTranslation(F.sub(c)),j.transformBy(V),A.drawMcDbEntity(j)})})}),!(yield h.go()))return;t.push([]),e.forEach(b=>{let A=b.getMcDbEntity();A&&x.forEach(L=>{let P=new M.McGeMatrix3d,R=A.clone();P.clone(),P.setToTranslation(L.sub(c)),R.transformBy(P),t[t.length-1].push(i.drawEntity(R))})})}}else if(h.getStatus()===X.MrxDbgUiPrBaseReturn.kOk){if(!f)return;t.push([]),e.forEach(r=>{let v=r.getMcDbEntity();if(!v)return;let x=v.clone();x.move(c,f),t[t.length-1].push(i.drawEntity(x))})}else return}})}function VL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("ARC");let t=yield M.MxCADUtility.userSelect("选择圆弧对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity(),c=l,h=c.center,f=c.radius,r=new M.McDbCircle;r.center=h,r.radius=f,l.erase(),M.MxCpp.getCurrentMxCAD().drawEntity(r)}))})}function GL(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD();let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择复制旋转对象:"))||t.count()==0)return;const i=new M.MxCADUiPrPoint;i.setMessage("指定基点");const l=yield i.go(),c=new M.MxCADUiPrPoint;c.setMessage(`请指定目标点 `),c.setUserDraw((w,b)=>{b.drawLine(w.toVector3(),l.toVector3()),t.forEach(A=>{let L=A.getMcDbEntity();if(!L)return;let P=L.clone();P.move(l,w),b.drawMcDbEntity(P)})});const h=yield c.go();if(!h)return;let f=[];t.forEach(w=>{let b=w.getMcDbEntity();if(!b)return;let A=b.clone();A.move(l,h),f.push(e.drawEntity(A))});let r=new M.MxCADUiPrAngle;if(r.setMessage("请指定旋转角度"),r.setBasePt(h),r.setUserDraw((w,b)=>{b.drawLine(w.toVector3(),h.toVector3()),f.forEach(A=>{let L=A.getMcDbEntity();if(!L)return;let P=L.clone(),R=w.sub(h).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);P.rotate(h,R),b.drawMcDbEntity(P)})}),!(yield r.go()))return;const x=r.value();f.forEach(w=>{let b=w.getMcDbEntity();if(!b)return;let A=b.clone();A.rotate(h,x),e.drawEntity(A),b.erase()})})}function WL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("CIRCLE");let t=yield M.MxCADUtility.userSelect("选择要转成多边形的对象",e);if(t.length==0)return;let i=new M.MxCADUiPrInt;i.setMessage("设置多边形边数");let l=(yield i.go())||5;if(i.clearLastInputPoint(),!l)return;const c=new M.MxCADUiPrPoint;c.setMessage(` 输入选项`),c.setKeyWords("[内接于圆(I)/外切于圆(C)]"),c.clearLastInputPoint(),yield c.go();let h="inside";c.isKeyWordPicked("i")&&(h="inside"),c.isKeyWordPicked("c")&&(h="outside");let f=M.MxCpp.getCurrentMxCAD();t.forEach(r=>Qe(this,null,function*(){let v=yield r.getMcDbEntity(),x=v,w=[];if(h==="inside"){for(let A=0;A{b.addVertexAt(A)}),b.isClosed=!0,f.drawEntity(b)}else if(h==="outside"){let b=90-360/(l*2),A=Math.sin(b*Math.PI/180),L=x.radius/A,P=new M.McDbCircle;P.center=x.center,P.radius=L;let R=[];for(let V=0;V{F.addVertexAt(V)}),F.isClosed=!0,f.drawEntity(F)}v.erase()}))})}function jL(){return Qe(this,null,function*(){let e=yield M.MxCADUtility.userSelect("选择要修改颜色的对象");if(e.length==0)return;const t=new M.MxCADUiPrInt;t.setMessage("输入颜色索引(0~256)");let i=(yield t.go())||20,l=new M.McCmColor;l.setColorIndex(i),e.forEach(c=>Qe(this,null,function*(){let h=c.getMcDbEntity();h.trueColor=l}))})}function HL(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("ARC");let t=yield M.MxCADUtility.userSelect("选择圆弧对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity();if(!l)return;let c=l.clone(),h=c.getLength(),f=c.getStartPoint().val,r=M.MxCpp.getCurrentMxCAD(),v=new M.McDbCircle;v.center=c.center,v.radius=c.radius;let x=v.getDistAtPoint(f),w=v.getPointAtDist(h.val+x.val).val,b=c.getFirstDeriv(f);if(!b.ret)return;let A=f.clone();A.addvec(b.val);let L=c.getFirstDeriv(w);if(!L.ret)return;let P=w.clone();P.addvec(L.val);let R=new M.McDbLine;R.startPoint=f,R.endPoint=A;let F=new M.McDbLine;F.startPoint=w,F.endPoint=P;let V=R.IntersectWith(F,M.McDb.Intersect.kExtendBoth);if(V.length()===0)return;let j=V.at(0);R.endPoint=j,F.endPoint=j,r.drawEntity(R),r.drawEntity(F)}))})}function $L(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrKeyWord;t.setMessage(` 输入选项`),t.setKeyWords("[隐藏(A)/隐藏未选(B)/全部显示(C)]");const i=yield t.go();if(i)if(i==="A"||i==="B"){let l=yield M.MxCADUtility.userSelect("选择目标的对象");if(l.length==0)return;let c=[];if(l.forEach(h=>c.push(h.id)),i==="A")l.forEach(h=>Qe(this,null,function*(){let f=yield h.getMcDbEntity(),r=f.clone();r.visible=!1,e.drawEntity(r),f.erase()}));else if(i==="B"){let h=new M.MxCADSelectionSet;h.allSelect(),h.forEach(f=>Qe(this,null,function*(){if(!c.includes(f.id)){let r=yield f.getMcDbEntity(),v=r.clone();v.visible=!1,e.drawEntity(v),r.erase()}}))}}else if(i==="C"){let l=new M.MxCADSelectionSet;l.allSelect(),l.forEach(c=>Qe(this,null,function*(){let h=yield c.getMcDbEntity(),f=h.clone();f.visible===!1&&(f.visible=!0,e.drawEntity(f),h.erase())}))}else return})}function qL(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;let t=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();e.setMessage(` 指定删除方框第一点:`);let i=yield e.go();if(!i)return;let l=M.MxCpp.getCurrentMxCAD(),c=new X.MxDbRect;c.pt1=i.toVector3(),e.setUserDraw((w,b)=>{c.pt2=w.toVector3(),c.setColor(t),b.drawCustomEntity(c)}),e.setMessage(` 指定删除方框第二点:`),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let h=yield e.go();if(!h)return;c.pt2=h.toVector3();let f=new M.McDbPolyline;f.addVertexAt(i),f.addVertexAt(new M.McGePoint3d(i.x,h.y)),f.addVertexAt(h),f.addVertexAt(new M.McGePoint3d(h.x,i.y)),f.isClosed=!0;let r=l.drawEntity(f);const v=new M.MxCADSelectionSet;for(v.crossingSelect(i.x,i.y,h.x,h.y),v.getIds().forEach(w=>{if(w&&w.id!==r.id){let b=w.getMcDbEntity(),A=b.IntersectWith(f,M.McDb.Intersect.kOnBothOperands);if(A.length()===0)w.erase();else{let L=[];A.forEach(P=>L.push(P)),b.splitCurves(L).forEach(P=>{l.drawEntity(P)}),w.erase()}}});;){const w=new M.MxCADUiPrPoint;w.setMessage(` 选择需要精确删除的实体`);const b=yield w.go();if(!b)break;let A=M.MxCADUtility.findEntAtPoint(b.x,b.y,b.z,-1);l.addCurrentSelect(A)}M.MxCADUtility.getCurrentSelect().forEach(w=>{w.erase()}),l.mxdraw.clearMxCurrentSelect()})}function XL(){return Qe(this,null,function*(){const e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrEntity;t.setMessage(` 请选择角度复制对象`);const i=yield t.go();if(i===null)return;const l=yield i.getMcDbEntity(),c=new M.MxCADUiPrInt;c.setMessage(` 请输入角度复制数量`);const h=(yield c.go())||1,f=new M.MxCADUiPrPoint;f.setMessage(` 请输入角度复制的基点`);const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrAngle;if(v.setMessage(` 请输入复制角度`),v.setBasePt(r),v.setUserDraw((b,A)=>{const L=b.sub(r).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);for(let P=1;P{let r=f.getMcDbEntity();if(!r)return;let v=r.numVerts();for(let x=0;x{const L=b.getMcDbEntity().clone();L.move(c,w),h.drawEntity(L)})}})})}function YL(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("请选择参考曲线");let t=yield e.go(),i=yield t.getMcDbEntity();if(i===null)return;const l=M.MxCpp.App.getCurrentMxCAD();let c=i.clone(),h=new M.MxCADResbuf;h.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");let f=yield M.MxCADUtility.userSelect("选择打断对象",h);if(f.length==0)return;let r=l.mxdraw.viewCoordLong2Cad(.5);f.forEach(v=>Qe(this,null,function*(){if(v.id!==t.id){let x=yield v.getMcDbEntity(),w=x.IntersectWith(c,M.McDb.Intersect.kOnBothOperands);if(w.length()!=0){let b=[];w.forEach(P=>{b.push(P)});let A=[];b.forEach(P=>{let R=x.getClosestPointTo(P,!1);if(!R.ret)return;let F=x.getFirstDeriv(R.val);if(!F.ret)return;F.val.normalize().mult(X.MxFun.viewCoordLong2Cad(10));let V=R.val.clone();V.addvec(F.val);let j=R.val.clone();j.subvec(F.val);const J=x.getPointAtDist(0).val,ne=x.getPointAtDist(x.getLength().val).val;if(J.distanceTo(R.val){R%2==0&&l.drawEntity(P)}),x.erase()}}}))})}function KL(){return Qe(this,null,function*(){let e=M.MxCpp.App.getCurrentMxCAD(),t=new M.MxCADResbuf;t.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");let i=new M.MxCADUiPrEntity;i.setFilter(t),i.setMessage("指定偏移对象");let l=yield i.go();if(!l)return;const c=new M.MxCADUiPrDist;if(c.setMessage("请输入偏移距离"),!(yield c.go()))return;const f=c.value();let r=yield l.getMcDbEntity();const v=r.getStartPoint().val,w=r.getFirstDeriv(v).val.rotateBy(M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis)),b=v.clone().addvec(w),A=v.clone().subvec(w);let L=r.offsetCurves(f,b);if(L.length()===0)return;L.forEach(R=>{e.drawEntity(R)});let P=r.offsetCurves(f,A);P.length()!==0&&P.forEach(R=>{e.drawEntity(R)})})}function JL(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("ARC,LINE,LWPOLYLINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("指定伸缩对象(选择直线、多段线、圆弧)");const i=yield t.go();if(!i)return;const l=M.MxCpp.App.getCurrentMxCAD(),c=i.getMcDbEntity();if(c instanceof M.McDbArc){const h=c.clone(),f=h.center,r=new M.MxCADUiPrPoint;r.setMessage("伸缩至"),c.visible=!1,r.setUserDraw((x,w)=>{h.endAngle=x.sub(f).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),w.drawMcDbEntity(h)});const v=yield r.go();if(c.visible=!0,!v)return;c.endAngle=v.sub(f).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),l.updateDisplay()}else if(c instanceof M.McDbLine){const h=c.clone(),f=new M.MxCADUiPrPoint;f.setMessage("伸缩至"),c.visible=!1;let r;f.setUserDraw((x,w)=>{r=h.getClosestPointTo(x,!0).val,h.endPoint=r,w.drawMcDbEntity(h)});const v=yield f.go();if(c.visible=!0,!v)return;c.endPoint=r,l.updateDisplay()}else if(c instanceof M.McDbPolyline){const h=c.clone(),f=new M.MxCADUiPrPoint;f.setMessage("伸缩至"),c.visible=!1;let r;const v=c.numVerts(),x=c.getBulgeAt(v-1),w=c.getWidthsAt(v-1);f.setUserDraw((A,L)=>{r=h.getClosestPointTo(A,!0).val,h.setPointAt(v-1,r),h.setBulgeAt(v-1,x),h.setWidthsAt(v-1,w.val1,w.val2),L.drawMcDbEntity(h)});const b=yield f.go();if(c.visible=!0,!b)return;c.setPointAt(v-1,r),c.setBulgeAt(v-1,x),c.setWidthsAt(v-1,w.val1,w.val2),l.updateDisplay()}})}function QL(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("CIRCLE");let t=yield M.MxCADUtility.userSelect("选择对象",e);if(t.length==0)return;const i=new M.MxCADUiPrDist;i.setMessage("请输入圆半径");const l=t[0].getMcDbEntity();if(i.setBasePt(l.center),i.setUserDraw((f,r)=>{const v=f.distanceTo(l.center);t.forEach(x=>{const b=x.getMcDbEntity().clone();b.radius=v,r.drawMcDbEntity(b)})}),!(yield i.go()))return;const h=i.value();t.forEach(f=>{const r=f.getMcDbEntity();r.radius=h})})}function eI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE,ARC,LINE,CIRCLE,ELLIPSE");let t=yield M.MxCADUtility.userSelect("选择要修改线型比例的对象",e);if(t.length==0)return;const i=new M.MxCADUiPrString;if(i.setMessage("请输入线型比例"),!(yield i.go()))return;const c=Number(i.value());c&&t.forEach(h=>Qe(this,null,function*(){let f=h.getMcDbEntity();f.linetypeScale=c}))})}function tI(){return Qe(this,null,function*(){const e=M.MxCpp.App.getCurrentMxCAD(),t=new M.MxCADUiPrDist;if(t.setMessage("请输入阵列间距"),!(yield t.go()))return;const l=t.value(),c=new M.MxCADResbuf;c.AddMcDbEntityTypes("ARC");const h=new M.MxCADUiPrEntity;h.setFilter(c),h.setMessage("请选择圆弧");const f=yield h.go();if(!f.id)return;const r=f.getMcDbEntity(),v=yield M.MxCADUtility.userSelect("选择排列对象");if(v.length==0)return;const x=new M.MxCADUiPrPoint;x.setMessage("指定排列基点");const w=yield x.go();w&&v.forEach(b=>Qe(this,null,function*(){let A=b.getMcDbEntity(),L=r.getLength().val/l;if(!(L<1))for(let P=0;P");let l=5;(yield i.go())&&(l=i.value());const h=M.MxCpp.getCurrentMxCAD();t.forEach(f=>{const r=f.getMcDbEntity(),v=new M.McDbPolyline;v.trueColor=r.trueColor,v.isClosed=r.isClosed,v.colorIndex=r.colorIndex,v.layerId=r.layerId;const x=r.numVerts(),w=[];for(let b=0;b{if(A+2>=w.length)return;const L=w[A+1],P=w[A+2],R=new M.McDbLine(L,b),F=new M.McDbLine(L,P),V=b.sub(L).angleTo2(P.sub(L),M.McGeVector3d.kNegateZAxis);let j=l*Math.sin(Math.PI/2-V/2)/Math.sin(V/2);j<0&&(j=-j);const J=R.getPointAtDist(j).val,ne=F.getPointAtDist(j).val;R.rotate(J,Math.PI/2),F.rotate(ne,Math.PI/2);const H=R.IntersectWith(F,M.McDb.Intersect.kExtendBoth);if(!H.length())return;const Q=H.at(0),ie=new M.McDbLine(Q,L).getPointAtDist(l).val;let le=M.MxCADUtility.calcBulge(J,ie,ne).val;if(A===0&&r.isClosed===!1){let me=r.getWidthsAt(A);v.addVertexAt(b,0,me.val1,me.val2)}let fe;r.isClosed===!0&&A+2===w.length-1?fe=r.getWidthsAt(A):fe=r.getWidthsAt(A+1),v.addVertexAt(J,le,fe.val1,fe.val2),v.addVertexAt(ne,0,fe.val1,fe.val2),A+2===w.length-1&&r.isClosed===!1&&v.addVertexAt(P,0,fe.val1,fe.val2)}),r.erase(),h.drawEntity(v)})})}function iI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE");const t=new M.MxCADUiPrEntity;t.setMessage("请选择线对象"),t.setFilter(e);const i=yield t.go();if(console.log(i),!i.id)return;const l=i.getMcDbEntity(),c=l.numVerts(),h=new M.McDbPolyline;for(let r=c-1;r>=0;r--){const v=l.getPointAt(r).val;if(r>0){const x=l.getWidthsAt(r-1),w=l.getBulgeAt(r-1);h.addVertexAt(v,-w,x.val2,x.val1)}else{const x=l.getWidthsAt(r),w=l.getBulgeAt(r);h.addVertexAt(v,-w,x.val2,x.val2)}}const f=M.MxCpp.getCurrentMxCAD();h.isClosed=l.isClosed,f.drawEntity(h),l.erase()})}function rI(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;e.allSelect(new M.MxCADResbuf([M.DxfCode.kEntityType,"LINE"])),console.log("得到对象数目:"+e.count()),e.forEach(t=>{t.getMcDbEntity().highlight(!0)}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function oI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择等分模式"),e.setKeyWords("[定距等分(ME)/定数等分(DIV)/偏移等分(O)/复制等分(CO)]");let t=yield e.go();if(!t)return;const i=new M.MxCADResbuf;i.AddMcDbEntityTypes("LINE");const l=new M.MxCADUiPrEntity;l.setFilter(i),t==="O"?l.setMessage("请选择偏移等分对象"):t==="CO"?l.setMessage("请选择复制等分对象"):l.setMessage("请选择需要等分的线段");const c=yield l.go();if(!c.id)return;const h=c.getMcDbEntity(),f=h.getLength().val,r=M.MxCpp.getCurrentMxCAD();if(t==="ME"){const v=new M.MxCADUiPrDist;if(v.setMessage("请设置等分距离"),!(yield v.go()))return;const w=v.value(),b=f/w;for(let A=1;A{h.offsetCurves(w*b,P).forEach(F=>{R.drawMcDbEntity(F)})});const L=yield A.go();if(!L)return;h.offsetCurves(w*b,L).forEach(P=>{r.drawEntity(P),b++})}}else if(t==="CO"){const v=new M.MxCADUiPrPoint;v.setMessage("请指定复制基点");const x=yield v.go();if(!x)return;const w=new M.MxCADUiPrInt;if(w.setMessage("请指定复制等分数量"),!(yield w.go()))return;const A=w.value(),L=new M.MxCADUiPrPoint;L.setMessage("请指定复制等分端点"),L.setUserDraw((V,j)=>{const J=new M.McDbLine(x,V);j.drawMcDbEntity(J);const ne=J.getLength().val/A;for(let H=1;H{const J=j.getMcDbEntity();if(!J)return;const ne=J.clone();c.appendAcDbEntity(ne)});let h=new M.McDbBlockReference;h.blockTableRecordId=l;const{ret:f,maxPt:r,minPt:v}=h.getBoundingBox();if(!f)return;const x=new M.McDbLine(v,r),w=x.getLength().val;c.origin=x.getPointAtDist(w/2).val;const b=new M.MxCADUiPrPoint;b.setMessage("请指定矩形的角点1");const A=yield b.go();if(!A)return;const L=new M.MxCADUiPrPoint;L.setMessage("请指定矩形角点2"),L.setUserDraw((j,J)=>{let ne=new M.McDbPolyline;ne.addVertexAt(A),ne.addVertexAt(new M.McGePoint3d(A.x,j.y)),ne.addVertexAt(j),ne.addVertexAt(new M.McGePoint3d(j.x,A.y)),ne.isClosed=!0,J.drawMcDbEntity(ne)});const P=yield L.go();if(!P)return;const R=Math.abs(A.x-P.x)/Math.abs(v.x-r.x),F=Math.abs(A.y-P.y)/Math.abs(v.y-r.y);h.scaleFactors=new M.McGePoint3d(R,F,0);const V=new M.McDbLine(A,P);h.position=V.getPointAtDist(V.getLength().val/2).val,t.drawEntity(h)})}class Em extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this.radius=20,this.scale=50,this.position=new M.McGePoint3d}create(t){return new Em(t)}getTypeName(){return"McDbTestEnlarge"}set enlargeCenter(t){this.center=t}get enlargeCenter(){return this.center}set enlargeRadius(t){this.radius=t}get enlargeRadius(){return this.radius}set enlargeScale(t){this.scale=t}get enlargeScale(){return this.scale}dwgInFields(t){return this.center=t.readPoint("center").val,this.position=t.readPoint("position").val,this.radius=t.readDouble("radius").val,this.scale=t.readDouble("scale").val,!0}dwgOutFields(t){return t.writePoint("center",this.center),t.writePoint("position",this.position),t.writeDouble("radius",this.radius),t.writeDouble("scale",this.scale),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t==0?(this.center.x+=i,this.center.y+=l,this.center.z+=c):t==1&&(this.position.x+=i,this.position.y+=l,this.position.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.center),t.append(this.position),t}worldDraw(t){const i=new M.McDbCircle;i.center=this.center,i.radius=this.radius,t.drawEntity(i);const{minPt:l,maxPt:c,ret:h}=i.getBoundingBox();if(!h)return;let f=new M.MxCADSelectionSet;f.crossingSelect(l.x,l.y,c.x,c.y);const r=M.MxCpp.getCurrentMxCAD();let v=r.getDatabase().getBlockTable(),x=new M.McDbBlockTableRecord,w=v.add(x),b=w.getMcDbBlockTableRecord();if(b==null)return;f.forEach(Q=>{let ae=Q.getMcDbEntity();if(!ae)return;let ie=ae.clone();b.appendAcDbEntity(ie)}),b.origin=new M.McGePoint3d(this.center.x,this.center.y,0);let A=new M.McDbBlockReference;A.blockTableRecordId=w,A.position=this.position;const L=r.drawEntity(A);A=L.getMcDbEntity();let P=i.getSamplePoints(this.radius*1e-5),R=new M.McGePoint3dArray;P.forEach((Q,ae,ie)=>{if(ie===1010){const le=new M.McGePoint3d(Q.x,Q.y,Q.z);R.append(le)}}),A.createSpatialFilter(),A.setScale(this.scale),A.getSpatialFilterId().getMcDbObject().setBoundary(R),t.drawEntity(A),L.erase();const j=this.position.sub(this.center).normalize(),J=this.center.clone().addvec(j.mult(this.radius)),ne=this.position.clone().subvec(j.mult(this.scale)),H=new M.McDbLine(J,ne);t.drawEntity(H)}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}function sI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择放大中心点");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setMessage("请选择放大范围"),i.setBasePt(t),i.setUserDraw((L,P)=>{const R=t.distanceTo(L),F=new M.McDbCircle(t.x,t.y,t.z,R);P.drawMcDbEntity(F)}),!(yield i.go()))return;const c=i.value(),h=M.MxCpp.getCurrentMxCAD(),f=new M.McDbCircle(t.x,t.y,t.z,c),r=new M.MxCADUiPrDist;if(r.setMessage("请设置放大倍数"),r.setBasePt(t),r.setUserDraw((L,P)=>{const R=t.distanceTo(L),F=new M.McDbCircle(t.x,t.y,t.z,R);P.drawMcDbEntity(F),P.drawMcDbEntity(f)}),!(yield r.go()))return;const x=r.value(),w=new M.MxCADUiPrPoint;w.setMessage("请选择放大插入点"),w.setUserDraw((L,P)=>{const R=new M.McDbCircle(L.x,L.y,L.z,x);P.drawMcDbEntity(R),P.drawMcDbEntity(f)});const b=yield w.go();if(!b)return;const A=new Em;A.enlargeCenter=t,A.enlargeRadius=c,A.enlargeScale=x/c,A.setPosition(b),h.drawEntity(A)})}function lI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrEntity;e.setMessage("请选择一条需要打断的曲线");const t=new M.MxCADResbuf([M.DxfCode.kEntityType,"LWPOLYLINE,LINE,ARC,CIRCLE,ELLIPSE"]);e.setFilter(t);const i=yield e.go();if(!i.id)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new M.MxCADUiPrPoint;c.setMessage("请在曲线上选取打断点");const h=[],f=X.MxFun.screenCoordLong2Doc(5);for(;;){c.setUserDraw((x,w)=>{h.length>0&&h.forEach(b=>{const A=new M.McDbCircle;A.center=b,A.radius=f,w.drawMcDbEntity(A)}),w.drawCircle(new THREE.Vector3(x.x,x.y),f)});const v=yield c.go();if(!v)break;h.push(v)}const r=M.MxCpp.getCurrentMxCAD();h.length!==0&&(l.splitCurves(h).forEach(v=>{r.drawEntity(v)}),l.highlight(!1),i.erase(),r.updateDisplay())})}function cI(){new Em().rxInit(),X.MxFun.addCommand("Mx_Multicopy",UL),X.MxFun.addCommand("Mx_ArcToCircle",VL),X.MxFun.addCommand("Mx_CopyRotation",GL),X.MxFun.addCommand("Mx_CricleTotoll",WL),X.MxFun.addCommand("Mx_ChangeColor",jL),X.MxFun.addCommand("Mx_ArcToAngle",HL),X.MxFun.addCommand("Mx_TemHiding",$L),X.MxFun.addCommand("Mx_BoxDel",qL),X.MxFun.addCommand("Mx_AngleCopy",XL),X.MxFun.addCommand("Mx_VertexRep",ZL),X.MxFun.addCommand("Mx_IntersectBreak",YL),X.MxFun.addCommand("Mx_DoubleOff",KL),X.MxFun.addCommand("Mx_Telescoping",JL),X.MxFun.addCommand("Mx_EitCircle",QL),X.MxFun.addCommand("Mx_LayerTypeScale",eI),X.MxFun.addCommand("Mx_ArcOrder",tI),X.MxFun.addCommand("Mx_PlRoundCorners",nI),X.MxFun.addCommand("Mx_PlReverse",iI),X.MxFun.addCommand("Mx_TestGetAllLineByLayer",rI),X.MxFun.addCommand("Mx_Bisection",oI),X.MxFun.addCommand("Mx_RectangularScaling",aI),X.MxFun.addCommand("Mx_Enlarge",sI),X.MxFun.addCommand("Mx_Interrupt",lI)}function uI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标对齐线对象(选择直线)"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.MxCADUiPrEntity;let h=new M.MxCADResbuf;h.AddMcDbEntityTypes("TEXT"),c.setMessage("请选择目标文字对象"),c.setFilter(h);const f=yield c.go();if(!f.id)return;const r=f.getMcDbEntity();let x=l.getFirstDeriv(l.getStartPoint().val).val.angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),w=r.rotation;r.rotate(r.position,x-w),M.MxCpp.App.getCurrentMxCAD().updateDisplay()})}function hI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");const t=yield M.MxCADUtility.userSelect("选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrString;i.setMessage("请设置字高");const l=yield i.go();!l||!Number(l)||(t.forEach(c=>{const h=c.getMcDbEntity();h.height=Number(l)}),M.MxCpp.getCurrentMxCAD().updateDisplay())})}function dI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");const t=yield M.MxCADUtility.userSelect("选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrString;i.setMessage("请设置字宽");const l=yield i.go();!l||!Number(l)||(t.forEach(c=>{const h=c.getMcDbEntity();h.widthFactor=Number(l)}),M.MxCpp.getCurrentMxCAD().updateDisplay())})}function pI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源文字"),t.setFilter(e);const i=yield t.go();if(!(i!=null&&i.id))return;const l=i.getMcDbEntity();let c=yield M.MxCADUtility.userSelect("请选择目标文字",e);if(c.length==0)return;const h=M.MxCpp.App.getCurrentMxCAD();c.forEach(f=>{let v=f.getMcDbEntity().clone();v.textString=l.textString,h.drawEntity(v),f.erase()})})}function fI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择第一个文字");const i=yield t.go();if(!(i!=null&&i.id))return;const l=i.getMcDbEntity(),c=M.MxCpp.App.getCurrentMxCAD(),h=new M.MxCADUiPrEntity;h.setFilter(e),h.setMessage("请选择第二个文字");const f=yield h.go();if(!(f!=null&&f.id))return;const r=f.getMcDbEntity();let v=l.textString,x=r.textString,w=l.clone(),b=r.clone();w.textString=x,b.textString=v,c.drawEntity(w),c.drawEntity(b),i.erase(),f.erase()})}function mI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择需要对齐的文字",e);if(t.length==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage("请选择对齐方式"),i.setKeyWords("[左(L)/中(M)/右(R)]");const l=yield i.go();if(!l)return;const c=new M.MxCADUiPrPoint;c.setMessage("请选择对齐基点");const h=yield c.go();if(!h)return;const f=M.MxCpp.getCurrentMxCAD();l==="L"?t.forEach(r=>{const v=r.getMcDbEntity(),x=v.clone(),w=v.alignmentPoint,b=v.position;x.horizontalMode=M.McDb.TextHorzMode.kTextLeft,x.alignmentPoint=new M.McGePoint3d(h.x,w.y),x.position=new M.McGePoint3d(h.x,b.y),f.drawEntity(x),r.erase()}):l==="R"?t.forEach(r=>{const v=r.getMcDbEntity(),x=v.clone(),w=v.alignmentPoint,b=v.position;x.horizontalMode=M.McDb.TextHorzMode.kTextRight,x.alignmentPoint=new M.McGePoint3d(h.x,w.y),x.position=new M.McGePoint3d(h.x,b.y),f.drawEntity(x),r.erase()}):l==="M"&&t.forEach(r=>{const v=r.getMcDbEntity(),x=v.clone(),w=v.alignmentPoint,b=v.position;x.horizontalMode=M.McDb.TextHorzMode.kTextCenter,x.alignmentPoint=new M.McGePoint3d(h.x,w.y),x.position=new M.McGePoint3d(h.x,b.y),f.drawEntity(x),r.erase()})})}function gI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择需要对齐的文字",e);if(t.length==0)return;const i=new M.MxCADUiPrPoint;i.setMessage("请选择对齐基点");const l=yield i.go();l&&(t.forEach(c=>{const h=c.getMcDbEntity(),f=h.position;h.alignmentPoint=h.position=new M.McGePoint3d(f.x,l.y)}),M.MxCpp.getCurrentMxCAD().updateDisplay())})}function yI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择需要反转的文字",e);if(t.length==0)return;const i=M.MxCpp.App.getCurrentMxCAD();t.forEach(l=>{const c=l.getMcDbEntity(),h=c.clone();let f=c.getBoundingBox();if(!f.ret)return;const r=f.maxPt,v=f.minPt,x=new M.McDbLine(v,r),w=x.getPointAtDist(x.getLength().val/2).val,b=M.McGeVector3d.kXAxis.angleTo1(new M.McGeVector3d(-1,0,0))+c.rotation;h.rotate(w,b),l.erase(),i.drawEntity(h)})})}function _I(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");let t=yield M.MxCADUtility.userSelect("请选择需要去空格的文字",e);t.length!=0&&t.forEach(i=>{const l=i.getMcDbEntity();let c;l instanceof M.McDbText?(c=l.clone(),c.textString=l.textString.replace(/\s+/g,"")):l instanceof M.McDbMText&&(c=l.clone(),c.contents=l.contents.replace(/\s+/g,"")),i.erase(),M.MxCpp.App.getCurrentMxCAD().drawEntity(c)})})}function vI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT, MTEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);t.length!=0&&t.forEach(i=>{let c=i.getMcDbEntity().getBoundingBox();if(!c.ret)return;const h=c.maxPt,f=c.minPt,r=new M.McGePoint3d(f.x,h.y),v=new M.McGePoint3d(h.x,f.y),x=f.clone().sub(h).normalize().mult(2),w=r.clone().sub(v).normalize().mult(2),b=new M.McDbPolyline;b.addVertexAt(f.addvec(x)),b.addVertexAt(r.addvec(w)),b.addVertexAt(h.subvec(x)),b.addVertexAt(v.subvec(w)),b.isClosed=!0,M.MxCpp.getCurrentMxCAD().drawEntity(b)})})}function xI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrInt;i.setMessage(`请输入下划线宽度 `);const l=(yield i.go())||0,c=new M.MxCADUiPrDist;c.setMessage(`请设置下划线距离 `);const h=yield c.go();let f=0;h&&(f=c.value());const r=new M.MxCADUiPrDist;r.setMessage(`请设置下划线延长距离 `);const v=yield r.go();let x=0;v&&(x=r.value()),t.forEach(w=>{let A=w.getMcDbEntity().getBoundingBox();if(!A.ret)return;const L=A.maxPt,P=A.minPt,R=new M.McDbLine(P.x,P.y,0,L.x,P.y,0),F=new M.McDbLine(L.x,P.y,0,P.x,P.y,0),V=F.getLength().val,j=R.getPointAtDist(V+x).val,J=F.getPointAtDist(V+x).val,ne=new M.McDbPolyline;ne.addVertexAt(j,0,l,l),ne.addVertexAt(J,0,l,l);const H=ne.getClosestPointTo(L,!0).val,Q=H.clone().sub(L);Q.normalize().mult(f);const ae=H.clone().addvec(Q),ie=new M.McGeMatrix3d;ie.setToTranslation(ae.sub(H)),ne.transformBy(ie),M.MxCpp.getCurrentMxCAD().drawEntity(ne)})})}function bI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);t.length!=0&&t.forEach(i=>{let c=i.getMcDbEntity().getBoundingBox();if(!c.ret)return;const h=c.maxPt,f=c.minPt,r=new M.McDbPolyline;r.addVertexAt(f,0,2,2),r.addVertexAt(new M.McGePoint3d(h.x,f.y),0,2,2);const v=new M.McDbPolyline;v.addVertexAt(f),v.addVertexAt(new M.McGePoint3d(h.x,f.y));const x=r.getClosestPointTo(h,!0).val,w=x.clone().sub(h),b=x.clone().sub(h);w.normalize().mult(2),b.normalize().mult(4);const A=x.clone().addvec(w),L=x.clone().addvec(b),P=new M.McGeMatrix3d,R=new M.McGeMatrix3d;P.setToTranslation(A.sub(x)),r.transformBy(P),R.setToTranslation(L.sub(x)),v.transformBy(R),M.MxCpp.getCurrentMxCAD().drawEntity(r),M.MxCpp.getCurrentMxCAD().drawEntity(v)})})}function wI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择文字对象",e);if(t.length==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage(`请选择操作选项 `),i.setKeyWords("[大写(C)/小写(S)/句首大写(I)]");const l=yield i.go();if(!l)return;const c=M.MxCpp.getCurrentMxCAD();l==="C"?t.forEach(h=>{const f=h.getMcDbEntity(),r=f.textString,v=f.clone();v.textString=r.toUpperCase(),console.log(v.textString),f.erase(),c.drawEntity(v)}):l==="S"?t.forEach(h=>{const f=h.getMcDbEntity(),r=f.textString,v=f.clone();v.textString=r.toLowerCase(),console.log(v.textString),f.erase(),c.drawEntity(v)}):l==="I"&&t.forEach(h=>{const f=h.getMcDbEntity(),r=f.textString,v=f.clone();v.textString=r.charAt(0).toUpperCase()+r.slice(1),f.erase(),c.drawEntity(v)})})}function MI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=yield M.MxCADUtility.userSelect("请选择数字对象",e);if(t.length==0)return;let i=[];if(t.forEach(v=>{const x=v.getMcDbEntity(),w=Number(x.textString);isNaN(w)||i.push(w)}),i.length!==t.length)return;let l=i.reduce((v,x)=>v+x,0);const c=new M.MxCADUiPrPoint,h=new M.McDbText;h.textString=l.toString(),h.height=10,c.setMessage(`请选择文字插入点 `),c.setUserDraw((v,x)=>{h.position=v,h.alignmentPoint=v,x.drawMcDbEntity(h)});const f=yield c.go();if(!f)return;const r=M.MxCpp.getCurrentMxCAD();h.position=f,h.alignmentPoint=f,r.drawEntity(h)})}function TI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要查找的范围:",e))||t.count()==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage(`请选择查找模式 `),i.setKeyWords("[等于(A)/包含(B)/前缀为(C)/后缀为(D)]");const l=yield i.go();if(!l)return;const c=new M.MxCADUiPrString;c.setMessage(`请输入关键字 `);const h=yield c.go();if(!h)return;const f=M.MxCpp.getCurrentMxCAD();let r=[];t.forEach(v=>{const w=v.getMcDbEntity().textString;l==="A"?w===h&&r.push(v):l==="B"?w.includes(h)&&r.push(v):l==="C"?w.startsWith(h)&&r.push(v):l==="D"&&w.endsWith(h)&&r.push(v)}),r.length>0&&r.forEach(v=>{f.addCurrentSelect(v)})})}function EI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要操作的范围:",e))||t.count()==0)return;const i=new M.MxCADUiPrKeyWord;i.setMessage("选择操作方式"),i.setKeyWords("[添加(A)/删除(D)]");let l=yield i.go();if(!l)return;const c=new M.MxCADUiPrKeyWord;c.setMessage("选择操作位置"),c.setKeyWords("[前缀(P)/后缀(S)]");let h=yield c.go();if(!h)return;const f=new M.MxCADUiPrString;f.setMessage("请输入内容");const r=yield f.go();r&&t.forEach(v=>{const x=v.getMcDbEntity(),w=x.textString;l==="A"?h==="P"?x.textString=r+w:h==="S"&&(x.textString=w+r):l==="D"&&(h==="P"?w.startsWith(r)&&(x.textString=w.slice(r.length)):h==="S"&&w.endsWith(r)&&(x.textString=w.slice(0,-r.length)))})})}function CI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=M.MxCpp.getCurrentMxCAD();for(;;){const h=new M.MxCADUiPrPoint;h.setMessage(`请选择文本 `);const f=yield h.go();if(!f)break;let r=M.MxCADUtility.findEntAtPoint(f.x,f.y,f.z,-1,e);t.addCurrentSelect(r)}const i=M.MxCADUtility.getCurrentSelect();if(!i.length)return;let l="";i.forEach((h,f)=>{const r=h.getMcDbEntity();l+=r.textString,f!==0&&h.erase()});const c=i.at(0).getMcDbEntity();c.textString=l,t.mxdraw.clearMxCurrentSelect()})}function AI(){return Qe(this,null,function*(){new M.MxCADResbuf().AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setMessage(`请选择文本 `);const i=yield t.go();if(!i)return;const l=i.getMcDbEntity(),c=l.textString.split("").join("\\P"),h=new M.McDbMText;h.contents=c,h.textHeight=l.height,h.location=l.position,h.trueColor=l.trueColor,h.colorIndex=l.colorIndex,h.layerId=l.layerId;const f=M.MxCpp.getCurrentMxCAD();i.erase(),f.drawEntity(h)})}function DI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("TEXT");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage(`请选择文本 `);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new M.MxCADResbuf;c.AddMcDbEntityTypes("ARC");const h=new M.MxCADUiPrEntity;h.setFilter(c),h.setMessage(`请选择圆弧 `);const f=yield h.go();if(!f.id)return;const r=f.getMcDbEntity();r.highlight(!0);const v=l.textString.split("");v.reverse();const x=r.getLength().val/(v.length-1),w=M.MxCpp.getCurrentMxCAD();for(let b=0;b{const w=v.getMcDbTextStyleTableRecord();l+=`${w.name}(${x})/`,c.push(v)});const h=new M.MxCADUiPrKeyWord;h.setMessage("请选择文字样式:"),h.setKeyWords(`[${l}]`);const f=yield h.go(),r=new M.MxCADSelectionSet;r.allSelect(new M.MxCADResbuf([M.DxfCode.kEntityType,"TEXT, MTEXT"])),r.forEach(v=>{let x=v.getMcDbEntity();x.textStyleId=c[Number(f)]}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function SI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf([M.DxfCode.kEntityType,"MTEXT,TEXT"]),t=new M.MxCADSelectionSet;if(!(yield t.userSelect("请设置文字提取范围",e))||t.count()==0)return;let i="";t.forEach(h=>{const f=h.getMcDbEntity(),r=f.objectName;if(r==="McDbText"){const v=f.clone();i+=`${v.textString} `}else if(r==="McDbMText"){const v=f.clone();i+=v.contents.replace("\\P",` `)}});const{isDialogVisible:l,excelText:c}=$p();l.value=!0,c.value=i})}function LI(){X.MxFun.addCommand("Mx_AlignByLine",uI),X.MxFun.addCommand("Mx_TextHeight",hI),X.MxFun.addCommand("Mx_TextWidth",dI),X.MxFun.addCommand("Mx_BrushCon",pI),X.MxFun.addCommand("Mx_ReplaceCon",fI),X.MxFun.addCommand("Mx_AlignLeft",mI),X.MxFun.addCommand("Mx_AlignUp",gI),X.MxFun.addCommand("Mx_TextReversal",yI),X.MxFun.addCommand("Mx_TextTrim",_I),X.MxFun.addCommand("Mx_TextTraming",vI),X.MxFun.addCommand("Mx_Underline",xI),X.MxFun.addCommand("Mx_TitleLine",bI),X.MxFun.addCommand("Mx_Case",wI),X.MxFun.addCommand("Mx_NumSum",MI),X.MxFun.addCommand("Mx_SSWords",TI),X.MxFun.addCommand("Mx_Prefix",EI),X.MxFun.addCommand("Mx_ConnectText",CI),X.MxFun.addCommand("Mx_VerticalText",AI),X.MxFun.addCommand("Mx_AlignByArc",DI),X.MxFun.addCommand("Mx_EditTextStyle",PI),X.MxFun.addCommand("Mx_ExtractText",SI)}function II(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块对象"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=new M.MxCADUiPrString;l.setMessage("请输入新块名");const c=yield l.go();if(!c)return;const h=i.getMcDbEntity().blockTableRecordId.getMcDbBlockTableRecord();console.log("原块名",h.name),h.name=c,console.log("新块名",h.name)})}function RI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("选择需要修改基点的块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.MxCADUiPrPoint,h=M.MxCpp.getCurrentMxCAD();c.setMessage("设置基点");const f=yield c.go();if(!f)return;let r=l.blockTableRecordId.getMcDbBlockTableRecord(),v=r.origin.clone(),x=l.blockTransform;v.transformBy(x);const w=f.sub(v);x.invert(),f.transformBy(x),r.origin=f,l.position=l.position.addvec(w),h.updateDisplay()})}function rb(e){e.getAllEntityId().forEach(t=>{let i=t.getMcDbEntity();i.colorIndex=M.ColorIndexType.kByblock,i instanceof M.McDbBlockReference&&rb(i.blockTableRecordId.getMcDbBlockTableRecord())})}function kI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("选择需要修改颜色的块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();let c=l.blockTableRecordId.getMcDbBlockTableRecord();rb(c);const h=new M.MxCADUiPrInt;h.setMessage("输入颜色索引(0~256)");let f=(yield h.go())||0,r=new M.McCmColor;r.setColorIndex(f),l.trueColor=r,M.MxCpp.getCurrentMxCAD().updateDisplay()})}function zI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();let c=new M.MxCADSelectionSet;(yield c.userSelect("选择要刷的目标块:",e))&&c.count()!=0&&c.forEach(h=>{const f=h.getMcDbEntity(),r=l.clone();r.position=f.position,h.erase(),M.MxCpp.getCurrentMxCAD().drawEntity(r)})})}function FI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择连接方式"),e.setKeyWords("[手动逐个连线(H)/自动批量连线(A)]");const t=yield e.go();if(!t)return;const i=M.MxCpp.getCurrentMxCAD();let l=new M.MxCADResbuf;if(l.AddMcDbEntityTypes("INSERT"),t==="A"){let c=new M.MxCADSelectionSet;if(!(yield c.userSelect("选择要刷的目标块:",l))||c.count()==0)return;const h=new M.McDbPolyline;c.forEach(f=>{const r=f.getMcDbEntity();h.addVertexAt(r.position)}),i.drawEntity(h)}else if(t==="H"){const c=new M.McDbPolyline;for(;;){const h=new M.MxCADUiPrEntity;h.setMessage("请选择连线的块"),h.setFilter(l),h.setUserDraw((v,x)=>{const w=c.clone();w.addVertexAt(v),x.drawMcDbEntity(w)});const f=yield h.go();if(!f.id)break;const r=f.getMcDbEntity();c.addVertexAt(r.position)}i.drawEntity(c)}})}function BI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择连线的块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;let c=i.getMcDbEntity().getBoundingBox();const h=new M.McDbPolyline;h.addVertexAt(c.minPt),h.addVertexAt(c.maxPt);const f=h.getPointAtDist(h.getLength().val/2).val,r=new M.MxCADUiPrDist;r.setMessage("设置中心线长度"),r.setBasePt(f),r.setUserDraw((L,P)=>{const R=L.distanceTo(f);let F=new M.McDbLine(f.x+R,f.y,f.z,f.x-R,f.y,f.z),V=F.clone();V.rotate(f,Math.PI/2),P.drawMcDbEntity(V),P.drawMcDbEntity(F)});const v=yield r.go();let x=10;v&&(x=r.value());const w=M.MxCpp.App.getCurrentMxCAD();let b=new M.McDbLine(f.x+x,f.y,f.z,f.x-x,f.y,f.z);b.trueColor=new M.McCmColor(255,0,0);let A=b.clone();A.rotate(f,Math.PI/2),w.drawEntity(A),w.drawEntity(b)})}function OI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要旋转的目标块:",e))||t.count()==0)return;const i=t.item(0).getMcDbEntity(),l=new M.MxCADUiPrDist;l.setMessage("设置旋转角度"),l.setBasePt(i.position);let c=0;l.setUserDraw((r,v)=>{c=r.sub(i.position).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis),t.forEach(x=>{const b=x.getMcDbEntity().clone();b.rotate(b.position,c),v.drawMcDbEntity(b)})});const h=yield l.go();if(!h)return;l.getDetailedResult()===X.DetailedResult.kCoordIn&&(c=h*Math.PI/180),t.forEach(r=>{const v=r.getMcDbEntity();v.rotate(v.position,c)}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function NI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");let t=new M.MxCADSelectionSet;if(!(yield t.userSelect("选择要旋转的目标块:",e))||t.count()==0)return;const i=new M.MxCADUiPrDist;i.setMessage("请设置缩放比例");let l=t.item(0).getMcDbEntity();if(i.setBasePt(l.position),i.setUserDraw((r,v)=>{const x=r.distanceTo(l.position);t.forEach(w=>{const A=w.getMcDbEntity().clone();let L=new M.McGeMatrix3d;L.setToScaling(x,A.position),A.transformBy(L),v.drawMcDbEntity(A)})}),!(yield i.go()))return;const h=i.value()||1;t.forEach(r=>{const v=r.getMcDbEntity();let x=new M.McGeMatrix3d;x.setToScaling(h,v.position),v.transformBy(x)}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function UI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().rotation;let h=new M.MxCADSelectionSet;if(!(yield h.userSelect("选择要刷的目标块:",e))||h.count()==0)return;h.forEach(r=>{const v=r.getMcDbEntity();v.rotation=c}),M.MxCpp.getCurrentMxCAD().updateDisplay()})}function VI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择源块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().blockName;let h=new M.MxCADSelectionSet;(yield h.userSelect("请设置选择范围:",e))&&h.count()!=0&&h.forEach(f=>{f.getMcDbEntity().blockName==c&&M.MxCpp.getCurrentMxCAD().addCurrentSelect(f)})})}function GI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().blockName;let h=new M.MxCADSelectionSet;h.allSelect(e),h.count()!=0&&h.forEach(f=>{f.getMcDbEntity().blockName==c&&M.MxCpp.getCurrentMxCAD().addCurrentSelect(f)})})}function WI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().blockName,h=new M.MxCADSelectionSet;if(!(yield h.userSelect("请设置统计范围",e))||h.count()==0)return;let f=0;h.forEach(r=>{r.getMcDbEntity().blockName==c&&(f+=1)}),console.log(`找到块${c}:共${f}个`)})}function jI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADSelectionSet;if(!(yield t.userSelect("请设置统计范围",e))||t.count()==0)return;let i=[];t.forEach(v=>{const w=v.getMcDbEntity().blockName;i.push(w)});let l=[];Array.from(new Set(i)).forEach(v=>{const x=i.filter(w=>w===v).length;l.push({blkName:v,num:x})});let c=new X1;c.data.addColumn("名称",100),c.data.addColumn("数量",30),l.forEach(v=>{c.data.addRow([v.blkName,v.num])});let h=new M.MxCADUiPrPoint;h.setMessage(` 指定表格插入点:`);let f=yield h.go();if(!f)return;let r=X.MxFun.screenCoordLong2Doc(100)/200;c.draw(f,r)})}function HI(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setMessage("请选择目标块"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=M.MxCpp.getCurrentMxCAD(),h=c.addLayer("测试图层");l.layerId=h,console.log(l.layer),c.updateDisplay()})}function $I(){X.MxFun.addCommand("Mx_ChangeBN",II),X.MxFun.addCommand("Mx_BushBlk",zI),X.MxFun.addCommand("Mx_ConBlk",FI),X.MxFun.addCommand("Mx_BlkCenterLine",BI),X.MxFun.addCommand("Mx_BlkPt",RI),X.MxFun.addCommand("Mx_BlkColor",kI),X.MxFun.addCommand("Mx_BlkRotate",OI),X.MxFun.addCommand("Mx_BlkScale",NI),X.MxFun.addCommand("Mx_BlkAngle",UI),X.MxFun.addCommand("Mx_BlkSelect",VI),X.MxFun.addCommand("Mx_BlkAllSelect",GI),X.MxFun.addCommand("Mx_SSBlk",WI),X.MxFun.addCommand("Mx_SMBlk",jI),X.MxFun.addCommand("Mx_BlkLayer",HI)}function qI(){return Qe(this,null,function*(){const e=M.MxCpp.App.getCurrentMxCAD(),t=new M.McDbText;t.height=10;let i=new M.McGePoint3d,l=new M.MxCADResbuf;l.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");let c=yield M.MxCADUtility.userSelect("选择目标曲线",l);if(c.length==0)return;let h=0;c.forEach(r=>Qe(this,null,function*(){let v=r.getMcDbEntity();h+=v.getLength().val})),t.textString=h.toFixed(2).toString();const f=new M.MxCADUiPrPoint;f.setMessage("指定长度标注点"),f.setUserDraw((r,v)=>{t.position=r,t.alignmentPoint=r,v.drawMcDbEntity(t)}),i=yield f.go(),i&&(t.alignmentPoint=i,t.position=i,e.drawEntity(t))})}function XI(){return Qe(this,null,function*(){const e=M.MxCpp.App.getCurrentMxCAD(),t=new M.McDbText;t.height=10;let i=new M.McGePoint3d,l=new M.MxCADResbuf;l.AddMcDbEntityTypes("CIRCLE,LWPOLYLINE,ELLIPSE");let c=yield M.MxCADUtility.userSelect("选择目标对象",l);if(c.length==0)return;let h=0;c.forEach(r=>Qe(this,null,function*(){let v=r.getMcDbEntity();h+=v.getArea().val})),t.textString=h.toFixed(2).toString();const f=new M.MxCADUiPrPoint;f.setMessage("指定长度标注点"),f.setUserDraw((r,v)=>{t.position=r,t.alignmentPoint=r,v.drawMcDbEntity(t)}),i=yield f.go(),i&&(t.alignmentPoint=i,t.position=i,e.drawEntity(t))})}function ZI(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择目标斜率对象");const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.MxCADUiPrDist;if(c.setMessage("请设置标注文字高度"),!(yield c.go()))return;const f=c.value(),r=new M.MxCADUiPrPoint;r.setMessage("指定斜率标注点");let v=new M.McDbBlockReference;const x=M.MxCpp.getCurrentMxCAD();r.setUserDraw((b,A)=>{const L=l.getClosestPointTo(b,!0).val,P=new M.McGePoint3d(L.x,L.y+f*4),R=new M.McDbLine(L,P),F=R.clone();F.rotate(P,Math.PI*1/2);const V=l.IntersectWith(F,M.McDb.Intersect.kExtendBoth).at(0),j=l.getClosestPointTo(L,!1).val,J=new M.McDbPolyline;J.isClosed=!0,J.addVertexAt(j),J.addVertexAt(L),J.addVertexAt(P),J.addVertexAt(V);const ne=new M.McDbText;ne.height=f,ne.position=R.getPointAtDist(R.getLength().val/2).val,ne.alignmentPoint=ne.position,ne.rotation=-Math.PI/2,ne.horizontalMode=M.McDb.TextHorzMode.kTextMid,ne.textString="1000";const H=new M.McDbText,Q=new M.McDbLine(V,P);H.height=f,H.position=Q.getPointAtDist(V.distanceTo(P)/2).val,H.alignmentPoint=H.position,H.horizontalMode=M.McDb.TextHorzMode.kTextMid,H.textString=(1e3*V.distanceTo(P)/R.getLength().val).toFixed(0).toString();let ie=x.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),le=ie.getMcDbBlockTableRecord();le!=null&&(le.appendAcDbEntity(J),le.appendAcDbEntity(ne),le.appendAcDbEntity(H),le.name="斜率test",le.origin=L,v.blockTableRecordId=ie,v.position=L,A.drawMcDbEntity(v))}),(yield r.go())&&x.drawEntity(v)})}class Cm extends M.McDbCustomEntity{constructor(t){super(t),this.point=new M.McGePoint3d,this.position=new M.McGePoint3d,this.height=30}create(t){return new Cm(t)}getTypeName(){return"McDbTestCoordinateLabeling"}set coordinatePoint(t){this.point=t.clone()}get coordinatePoint(){return this.point}set coordinateHeight(t){this.height=t}get coordinateHeight(){return this.height}dwgInFields(t){return this.point=t.readPoint("point").val,this.position=t.readPoint("position").val,this.height=t.readDouble("height").val,!0}dwgOutFields(t){return t.writePoint("point",this.point),t.writePoint("position",this.position),t.writeDouble("height",this.height),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t===0?(this.point.x+=i,this.point.y+=l,this.point.z+=c):(this.position.x+=i,this.position.y+=l,this.position.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.point),t.append(this.position),t}worldDraw(t){const i=new M.McDbMText;i.textHeight=X.MxFun.screenCoordLong2Doc(this.height),i.attachment=M.McDb.AttachmentPoint.kMiddleLeft,i.contents=`X=${this.point.x.toFixed(3)}\\PY=${this.point.y.toFixed(3)}`,i.location=this.position,t.drawEntity(i);const c=M.MxCpp.getCurrentMxCAD().drawEntity(i),{maxPt:h,minPt:f}=c.getMcDbEntity().getBoundingBox();c.erase();const r=Math.abs(h.x-f.x),v=new M.McGePoint3d(this.position.x+r*1.2,this.position.y),x=new M.McDbPolyline;x.addVertexAt(this.point),x.addVertexAt(this.position),x.addVertexAt(v),t.drawEntity(x)}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}function YI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择目标坐标点");const t=yield e.go();if(!t)return;const i=new Cm;i.coordinatePoint=t;const l=new M.MxCADUiPrPoint;l.setMessage("请指定标注位置"),l.setUserDraw((h,f)=>{i.setPosition(h),f.drawMcDbEntity(i)});const c=yield l.go();c&&(i.setPosition(c),M.MxCpp.getCurrentMxCAD().drawEntity(i))})}function KI(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("指定起点");const t=yield e.go();if(!t)return;const i=10,l=M.MxCpp.getCurrentMxCAD(),c=new M.McDbText;c.height=i,c.textString=t.y.toFixed(2),c.position=t;const h=l.drawEntity(c);let f,r,v;setTimeout(()=>Qe(this,null,function*(){const x=h.getMcDbEntity().getBoundingBox(),w=x.maxPt.distanceTo(new M.McGePoint3d(x.minPt.x,x.maxPt.y));h.erase();const b=new M.MxCADUiPrPoint;if(b.setMessage("指定终点"),b.setUserDraw((R,F)=>{f=new M.McDbLine(t,new M.McGePoint3d(t.x+i,t.y,0)),f.startPoint=t,f.endPoint=f.getClosestPointTo(R,!0).val,F.drawMcDbEntity(f);const V=new M.McGePoint3d(R.x,t.y+i,0),j=f.getPointAtDist(f.getLength().val-i).val,J=f.getPointAtDist(f.getLength().val-i*2).val;r=new M.McDbPolyline,r.addVertexAt(V),r.addVertexAt(j),r.addVertexAt(new M.McGePoint3d(J.x,J.y+i,0)),R.x>t.x?r.addVertexAt(new M.McGePoint3d(V.x+w,V.y,0)):r.addVertexAt(new M.McGePoint3d(V.x-w,V.y,0)),F.drawMcDbEntity(r),v=c.clone(),v.position=v.alignmentPoint=V,R.x>t.x?c.horizontalMode=M.McDb.TextHorzMode.kTextLeft:c.horizontalMode=M.McDb.TextHorzMode.kTextRight,F.drawMcDbEntity(v)}),!(yield b.go()))return;const L=new M.MxCADUiPrPoint;L.setMessage("指定标注方向"),L.setUserDraw((R,F)=>{const V=r.clone(),j=v.clone();if(R.yQe(this,null,function*(){const h=c.getMcDbEntity().getBoundingBox(),f=h.maxPt.distanceTo(new M.McGePoint3d(h.minPt.x,h.maxPt.y));c.erase();const r=new M.MxCADUiPrPoint;r.setMessage("请指定标注位置");let v,x;r.setUserDraw((b,A)=>{const L=new M.McGePoint3d(b.x,b.y+f,0),P=new M.McGePoint3d(L.x-f/2,L.y,0),R=new M.McGePoint3d(L.x+f/2,L.y,0),F=new M.McDbLine(b,R),V=F.getPointAtDist(F.getLength().val+f).val;v=new M.McDbPolyline,v.addVertexAt(R),v.addVertexAt(P),v.addVertexAt(b),v.addVertexAt(V),A.drawMcDbEntity(v),x=i.clone(),x.position=x.alignmentPoint=L,A.drawMcDbEntity(x)}),(yield r.go())&&(l.drawEntity(v),l.drawEntity(x))}),0)})}class au extends M.McDbCustomEntity{constructor(t){super(t),this.ptArr=[],this.height=30,this.dbulges=[],this.isReactFlag=!1}create(t){return new au(t)}getTypeName(){return"McDbTestAreaComment"}set textHeight(t){this.height=t}get textHeight(){return this.height}set isReact(t){this.isReactFlag=t}get isReact(){return this.isReactFlag}dwgInFields(t){this.ptArr=t.readPoints("ptArr").val,this.pt=t.readPoint("pt").val;const i=t.readString("dbulges").val;return this.dbulges=i.split(",").map(Number),this.isReactFlag=!!t.readLong("isReactFlag").val,!0}dwgOutFields(t){t.writePoints("ptArr",this.ptArr),t.writePoint("pt",this.pt);const i=this.dbulges.toString();return t.writeString("dbulges",i),t.writeLong("isReactFlag",this.isReactFlag?1:0),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.ptArr.forEach((h,f)=>{f===t&&(h.x+=i,h.y+=l,h.z+=c)}),t===this.ptArr.length&&(this.pt.x+=i,this.pt.y+=l,this.pt.z+=c)}getGripPoints(){let t=new M.McGePoint3dArray;return this.ptArr.forEach(i=>{t.append(i)}),t.append(this.pt),t}worldDraw(t){const i=new M.McDbPolyline;i.isClosed=!0,this.isReactFlag?(i.addVertexAt(this.ptArr[0],0,.1,.1),i.addVertexAt(new M.McGePoint3d(this.ptArr[1].x,this.ptArr[0].y),0,.1,.1),i.addVertexAt(this.ptArr[1],0,.1,.1),i.addVertexAt(new M.McGePoint3d(this.ptArr[0].x,this.ptArr[1].y),0,.1,.1)):this.ptArr.forEach((f,r)=>{i.addVertexAt(f,this.dbulges[r],.1,.1)});const l=i.getArea().val,c=i.getLength().val,h=new M.McDbMText;h.contents=`面积:${l.toFixed(2)}\\P周长:${c.toFixed(2)} `,h.attachment=M.McDb.AttachmentPoint.kMiddleCenter,h.location=this.pt,h.textHeight=X.MxFun.screenCoordLong2Doc(this.height),h.trueColor=this.trueColor,t.trueColor=this.trueColor,t.drawEntity(h),t.drawEntity(i)}setPoint(t){this.assertWrite(),this.pt=t.clone()}addVertex(t,i){this.assertWrite(),this.ptArr.push(t.clone()),this.dbulges.push(i||0)}getPoint(){return this.pt}}function QI(){return Qe(this,null,function*(){const e=[],t=new M.MxCADUiPrPoint;t.setMessage("请选择面积的第一个点");const i=yield t.go();if(!i)return;for(e.push(i);;){const r=new M.MxCADUiPrPoint;r.setMessage("请选择下一个点"),r.setKeyWords("[回退(B)/结束(O)]"),r.setUserDraw((w,b)=>{const A=new M.McDbPolyline;e.forEach(L=>{A.addVertexAt(L,0,.1,.1)}),A.addVertexAt(w),b.drawMcDbEntity(A)});const v=yield r.go(),x=r.keyWordPicked();if(x==="B")e.length>1&&e.pop();else{if(x==="O")break;if(!v)break;e.push(v)}}if(e.length<3)return;const l=M.MxCpp.getCurrentMxCAD(),c=new au;e.forEach(r=>{c.addVertex(r,0)});const h=new M.MxCADUiPrPoint;h.setMessage("请选择面积标注的位置"),h.setUserDraw((r,v)=>{v.setColor(16711680),c.setPoint(r),v.drawMcDbEntity(c)});const f=yield h.go();f&&(c.setPoint(f),c.trueColor=new M.McCmColor(255,0,0),l.drawEntity(c))})}function eR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择矩形的角点1");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;i.setMessage("请选择矩形的角点2"),i.setUserDraw((r,v)=>{const x=new M.McDbPolyline;x.isClosed=!0,x.addVertexAt(t),x.addVertexAt(new M.McGePoint3d(r.x,t.y)),x.addVertexAt(r),x.addVertexAt(new M.McGePoint3d(t.x,r.y)),v.drawMcDbEntity(x)});const l=yield i.go();if(!l)return;const c=new au;c.isReact=!0,c.addVertex(t),c.addVertex(l);const h=new M.MxCADUiPrPoint;h.setMessage("请设置面积标注的位置"),h.setUserDraw((r,v)=>{v.setColor(16711680),c.setPoint(r),v.drawMcDbEntity(c)});const f=yield h.go();f&&(c.setPoint(f),c.trueColor=new M.McCmColor(255,0,0),M.MxCpp.getCurrentMxCAD().drawEntity(c))})}function tR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请选择一个测量点");const t=yield e.go();if(!t)return;const i=new M.MxCADResbuf([M.DxfCode.kEntityType,"LINE"]),l=new M.MxCADUiPrEntity;l.setMessage("请选择一条直线"),l.setFilter(i);const c=yield l.go();if(!c.id)return;const f=c.getMcDbEntity().getClosestPointTo(t,!0).val;let r;const v=M.MxCpp.getCurrentMxCAD(),x=new M.MxCADUiPrPoint;x.setMessage("请设置尺寸线的位置"),x.setUserDraw((b,A)=>{r&&r.erase(),r=v.drawDimAligned(t.x,t.y,f.x,f.y,b.x,b.y)});const w=yield x.go();if(!w){r&&r.erase();return}r&&r.erase(),v.drawDimAligned(t.x,t.y,f.x,f.y,w.x,w.y)})}class Am extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this.position=new M.McGePoint3d,this.height=30}create(t){return new Am(t)}getTypeName(){return"McDbTestArcComment"}set arcCenter(t){this.center=t.clone()}get arcCenter(){return this.center}set arcRadius(t){this.radius=t}get arcRadius(){return this.radius}set textHeight(t){this.height=t}get textHeight(){return this.height}set arcStartAngle(t){this.startAngle=t}get arcStartAngle(){return this.startAngle}set arcEndAngle(t){this.endAngle=t}get arcEndAngle(){return this.endAngle}dwgInFields(t){return this.position=t.readPoint("position").val,this.center=t.readPoint("center").val,this.startAngle=t.readDouble("startAngle").val,this.endAngle=t.readDouble("endAngle").val,this.radius=t.readDouble("radius").val,this.height=t.readDouble("textHeight").val,!0}dwgOutFields(t){return t.writePoint("position",this.position),t.writePoint("center",this.center),t.writeDouble("startAngle",this.startAngle),t.writeDouble("endAngle",this.endAngle),t.writeDouble("radius",this.radius),t.writeDouble("textHeight",this.height),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.position.x+=i,this.position.y+=l,this.position.z+=c}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.position),t}drawLine(t,i){const l=i.sub(t).normalize().mult(X.MxFun.screenCoordLong2Doc(this.height*.4)),c=i.clone().addvec(l),h=i.clone().subvec(l),f=new M.McDbLine(c,h);return f.rotate(i,Math.PI/4),{line:f,pt:c}}worldDraw(t){const i=new M.McDbArc;i.center=this.center,i.startAngle=this.startAngle,i.endAngle=this.endAngle,i.radius=this.radius;const l=i.getLength().val,c=i.getPointAtDist(0).val,h=i.getPointAtDist(l).val,f=new M.McDbText;f.textString=`${l.toFixed(2)}`,f.height=X.MxFun.screenCoordLong2Doc(this.height),f.horizontalMode=M.McDb.TextHorzMode.kTextCenter,f.position=f.alignmentPoint=this.position;const v=i.getClosestPointTo(this.position,!0).val.distanceTo(this.position);i.offsetCurves(v,this.position).forEach(R=>{const F=R.clone(),V=F.getLength().val;this.pt1=F.getPointAtDist(0).val,this.pt2=F.getPointAtDist(V).val;const j=F.getPointAtDist(V/2).val;this.dbulge=M.MxCADUtility.calcBulge(this.pt1,j,this.pt2).val});const x=new M.McDbPolyline;x.addVertexAt(this.pt1,this.dbulge),x.addVertexAt(this.pt2);const w=this.pt1.sub(this.pt2).angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);f.rotation=w===Math.PI?0:w;const{line:b,pt:A}=this.drawLine(c,this.pt1),{line:L,pt:P}=this.drawLine(h,this.pt2);x.trueColor=f.trueColor=b.trueColor=L.trueColor=this.trueColor,t.drawEntity(x),t.drawEntity(f),t.drawEntity(b),t.drawEntity(L),t.drawEntity(new M.McDbLine(c,A)),t.drawEntity(new M.McDbLine(h,P))}setPosition(t){this.assertWrite(),this.position=t.clone()}getPoint(){return this.position}}function nR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf([M.DxfCode.kEntityType,"ARC"]),t=new M.MxCADUiPrEntity;t.setMessage("请选择一条弧线"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new Am;c.arcCenter=l.center,c.arcStartAngle=l.startAngle,c.arcEndAngle=l.endAngle,c.arcRadius=l.radius;const h=new M.MxCADUiPrPoint;h.setMessage("请指定尺寸线位置"),h.setUserDraw((v,x)=>{x.setColor(16711680),c.setPosition(v),x.drawMcDbEntity(c)});const f=yield h.go();if(!f)return;c.setPosition(f),c.trueColor=new M.McCmColor(255,0,0),M.MxCpp.getCurrentMxCAD().drawEntity(c)})}class Dm extends M.McDbCustomEntity{constructor(t){super(t),this.center=new M.McGePoint3d,this.position=new M.McGePoint3d}create(t){return new Dm(t)}getTypeName(){return"McDbTestMeasuringCircle"}set circleRadius(t){this.radius=t}get circleRadius(){return this.radius}dwgInFields(t){return this.center=t.readPoint("center").val,this.position=t.readPoint("position").val,this.radius=t.readDouble("radius").val,!0}dwgOutFields(t){return t.writePoint("center",this.center),t.writePoint("position",this.position),t.writeDouble("radius",this.radius),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),this.position.x+=i,this.position.y+=l,this.position.z+=c}getGripPoints(){let t=new M.McGePoint3dArray;return t.append(this.position),t}worldDraw(t){const i=new M.McDbCircle;i.center=this.center,i.radius=this.radius;const l=i.getLength().val,c=i.radius,h=Math.PI*c*c,f=new M.McDbMText;f.contents=`半径:${c.toFixed(2)} \\P 周长:${l.toFixed(2)} \\P 面积:${h.toFixed(2)}`,f.textHeight=c/6,f.attachment=M.McDb.AttachmentPoint.kMiddleCenter,f.location=this.position,f.trueColor=i.trueColor=this.trueColor,t.drawEntity(f),t.drawEntity(i)}setCenter(t){this.assertWrite(),this.center=t.clone()}getCenter(){return this.center}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}function iR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf([M.DxfCode.kEntityType,"CIRCLE"]),t=new M.MxCADUiPrEntity;t.setMessage("请选择一个圆对象"),t.setFilter(e);const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new Dm;c.setCenter(l.center),c.circleRadius=l.radius;const h=new M.MxCADUiPrPoint;h.setMessage("请指定文字位置"),h.setUserDraw((v,x)=>{x.setColor(16711680),c.setPosition(v),x.drawMcDbEntity(c)});const f=yield h.go();if(!f)return;c.setPosition(f),c.trueColor=new M.McCmColor(255,0,0),M.MxCpp.getCurrentMxCAD().drawEntity(c),l.highlight(!1)})}class Pm extends M.McDbCustomEntity{constructor(t){super(t),this.points=[],this.dbulges=[],this.position=new M.McGePoint3d,this.height=30,this.dimColor=new M.McCmColor(255,0,0),this.width=.1,this.showSegLength=!1}create(t){return new Pm(t)}getTypeName(){return"McDbTestConMeasurement"}set textHeight(t){this.height=t}get textHeight(){return this.height}set color(t){this.dimColor=t.clone()}get color(){return this.dimColor}set conWidth(t){this.width=X.MxFun.screenCoordLong2Doc(t)}get conWidth(){return this.width}set isShowSegLength(t){this.showSegLength=t}get isShowSegLength(){return this.showSegLength}dwgInFields(t){this.points=t.readPoints("points").val,this.position=t.readPoint("position").val;const i=t.readString("dbulges").val;this.dbulges=i.split(",").map(Number);const l=t.readString("dimColor").val;return this.dimColor=new M.McCmColor(...l.split(",").map(Number)),this.width=t.readDouble("conWidth").val,this.showSegLength=t.readLong("showSegLength").val===1,!0}dwgOutFields(t){const i=this.dbulges.toString(),l=`${this.dimColor.red},${this.dimColor.green},${this.dimColor.blue}`,c=this.showSegLength?1:0;return t.writePoints("points",this.points),t.writePoint("position",this.position),t.writeString("dbulges",i),t.writeString("dimColor",l),t.writeDouble("conWidth",this.width),t.writeLong("showSegLength",c),!0}moveGripPointsAt(t,i,l,c){this.assertWrite(),t{t.append(i)}),t.append(this.position),t}worldDraw(t){const i=new M.McDbPolyline,l=[];this.points.forEach((J,ne)=>{let H=this.width;if(ne===this.points.length-1&&(H=0),i.addVertexAt(J,this.dbulges[ne],H,H),ne>0){const Q=this.points[ne-1],ae=new M.McDbPolyline;ae.addVertexAt(Q,this.dbulges[ne-1]),ae.addVertexAt(J,this.dbulges[ne]);const ie=ae.getLength().val,le=ae.getPointAtDist(ie/2).val,fe=new M.McDbText;fe.textString=`${ie.toFixed(2)}`,fe.height=X.MxFun.screenCoordLong2Doc(this.height*.6),fe.horizontalMode=M.McDb.TextHorzMode.kTextCenter;let me;Q.x<=J.x?me=J.sub(Q):me=Q.sub(J);const he=me.clone().perpVector().normalize(),Oe=X.MxFun.screenCoordLong2Doc(this.height*.15),Ve=new M.McDbLine(Q,J);Ve.getPointAtDist(Ve.getLength().val/2).val.y>=le.y?le.addvec(he.mult(Oe)):le.subvec(he.mult(Oe)),fe.position=fe.alignmentPoint=le;const at=me.angleTo2(M.McGeVector3d.kXAxis,M.McGeVector3d.kNegateZAxis);fe.rotation=at===Math.PI?0:at,l.push(fe)}});const c=M.MxCpp.getCurrentMxCAD(),h=c.drawEntity(i),f=h.getMcDbEntity().getLength().val,r=this.points[this.points.length-1],x=i.getFirstDeriv(r).val.clone();x.rotateBy(Math.PI/4).normalize().mult(this.width*5);const w=r.clone().addvec(x),b=r.clone().subvec(x),A=new M.McDbPolyline;A.addVertexAt(w,0,this.width,this.width),A.addVertexAt(b),h.erase();const L=new M.McDbText;L.textString=`${f.toFixed(2)}`,L.height=X.MxFun.screenCoordLong2Doc(this.height);const P=X.MxFun.screenCoordLong2Doc(4);L.position=L.alignmentPoint=new M.McGePoint3d(this.position.x+P,this.position.y+P),L.horizontalMode=M.McDb.TextHorzMode.kTextLeft;const R=c.drawEntity(L),{minPt:F,maxPt:V}=R.getMcDbEntity().getBoundingBox();R.erase();const j=new M.McGePoint3d(this.position.x+Math.abs(F.x-V.x)+P*6,this.position.y);i.addVertexAt(this.position),i.addVertexAt(j),this.showSegLength&&l.forEach(J=>{t.drawEntity(J)}),t.trueColor=this.dimColor,t.drawEntity(i),t.drawEntity(L),t.drawEntity(A)}addVertex(t,i){this.assertWrite(),this.dbulges.push(i),this.points.push(t)}getPoints(){return this.points}setPosition(t){this.assertWrite(),this.position=t.clone()}getPosition(){return this.position}}let ob=[];function ab(e){const t=M.MxCpp.getCurrentMxCAD();e===1?(ob.push({name:"ORTHOMODE",value:t.getSysVarLong("ORTHOMODE")},{name:"GRIDMODE",value:t.getSysVarLong("GRIDMODE")},{name:"OSMODE",value:t.getSysVarLong("OSMODE")}),t.setSysVarLong("ORTHOMODE",0),t.setSysVarLong("GRIDMODE",0),t.setSysVarLong("OSMODE",16383)):e===0&&ob.forEach(i=>{t.setSysVarLong(i.name,i.value)})}function sb(){return Qe(this,null,function*(){ab(1);let e=[],t=!1;const i=new M.MxCADResbuf([M.DxfCode.kEntityType,"ARC"]);let c=M.MxCpp.getCurrentMxCAD().mxdraw.viewCoordLong2Cad(.5),h=null;for(;;){const f=new M.MxCADUiPrPoint;f.setMessage("请选择直线的端点或弧线"),f.setKeyWords("[回退(B)/结束(O)]"),e.length>0&&f.setBasePt(e[e.length-1].pt),f.setUserDraw((x,w)=>{const b=new M.McDbPolyline;e.forEach(A=>{b.addVertexAt(A.pt,A.dbulge,.1,.1)}),w.drawMcDbEntity(b)});const r=yield f.go(),v=f.keyWordPicked();if(v==="B")e.length>1&&e.pop(),h=null;else{if(v==="O")break;{if(!r)break;const x=M.MxCADUtility.findEntAtPoint(r.x,r.y,r.z,-1,i);if(!x.id)h=null,t?e.filter(b=>b.pt.distanceTo(r)0){const P=e[e.length-1].pt;if(A.distanceTo(P)w.getLength().val){const ne=J.clone();J.startAngle=ne.endAngle,J.endAngle=ne.startAngle,j=J.getPointAtDist(J.getLength().val/2).val}R.dbulge=M.MxCADUtility.calcBulge(R.pt,j,r).val,e.push({pt:r,dbulge:0}),h=null}else{const R=A.distanceTo(P){i.addVertex(h.pt,h.dbulge)});const l=new M.MxCADUiPrPoint;l.setMessage("请指定文字的位置"),l.setUserDraw((h,f)=>{i.setPosition(h),f.drawMcDbEntity(i)});const c=yield l.go();c&&(i.setPosition(c),e.drawEntity(i))})}function oR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrEntity;e.setMessage("请选择一个连续测量的标注");const t=yield e.go();if(!t.id)return;const i=t.getMcDbEntity();if(i instanceof M.McDbCustomEntity&&i.getTypeName()==="McDbTestConMeasurement"){const l=i.clone();l.isShowSegLength=!l.isShowSegLength,M.MxCpp.getCurrentMxCAD().drawEntity(l),t.erase()}})}function aR(){return Qe(this,null,function*(){const e=yield sb(),t=M.MxCpp.getCurrentMxCAD(),i=new au;e.forEach(h=>{i.addVertex(h.pt,h.dbulge)});const l=new M.MxCADUiPrPoint;l.setMessage("请选择面积标注的位置"),l.setUserDraw((h,f)=>{i.setPoint(h),f.drawMcDbEntity(i)});const c=yield l.go();c&&(i.setPoint(c),i.trueColor=new M.McCmColor(255,0,0),t.drawEntity(i))})}function sR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setMessage("请选择一条直线"),t.setFilter(e);const i=yield t.go();if(!i)return;const l=i.getMcDbEntity();l.highlight(!0);const c=new M.MxCADUiPrEntity;c.setMessage("请选择第二条直线"),c.setFilter(e);const h=yield c.go();if(!h)return;const f=h.getMcDbEntity();f.highlight(!0);const r=new M.MxCADUiPrPoint;r.setMessage("请设置角度标注的位置");const v=M.MxCpp.getCurrentMxCAD().addDimStyle("MyDimStyle2","41,0.18,141,0.09,40,20","77,1,271,3","",""),x=new M.McDb2LineAngularDimension;x.xLine1Start=l.startPoint,x.xLine1End=l.endPoint,x.xLine2Start=f.startPoint,x.xLine2End=f.endPoint,x.dimensionStyle=v,l.highlight(!1),f.highlight(!1),r.setUserDraw((b,A)=>{x.arcPoint=b,A.drawMcDbEntity(x)});const w=yield r.go();w&&(x.arcPoint=w,M.MxCpp.getCurrentMxCAD().drawEntity(x))})}function lR(){new au().rxInit(),new Pm().rxInit(),new Dm().rxInit(),new Am().rxInit(),new Cm().rxInit(),X.MxFun.addCommand("Mx_StaLength",qI),X.MxFun.addCommand("Mx_StaArea",XI),X.MxFun.addCommand("Mx_StandardSlope",ZI),X.MxFun.addCommand("Mx_CoordAnnotation",YI),X.MxFun.addCommand("Mx_Elevation",KI),X.MxFun.addCommand("Mx_Roughness",JI),X.MxFun.addCommand("Mx_Area",QI),X.MxFun.addCommand("Mx_ReactArea",eR),X.MxFun.addCommand("Mx_DistFromPointToLine",tR),X.MxFun.addCommand("Mx_ArcLength",nR),X.MxFun.addCommand("Mx_MeasuringCircle",iR),X.MxFun.addCommand("Mx_ContinueMeasurement",rR),X.MxFun.addCommand("Mx_CountList",oR),X.MxFun.addCommand("Mx_AreaArc",aR),X.MxFun.addCommand("Mx_MeasuringAngle",sR)}function cR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrInt;e.setMessage(` 请输入星形顶点数:`);const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;i.setMessage(` 指定星形中心点:`);const l=yield i.go();if(!l)return;const c=new M.MxCADUiPrDist;c.setBasePt(l),c.setMessage("请设置星形的内半径:");const h=yield c.go();let f;h?f=c.value():f=5;const r=new M.McDbCircle(l.x,l.y,l.z,f);let v=[];const x=new M.MxCADUiPrDist;if(x.setBasePt(l),x.setMessage(` 指定星形的外半径:`),x.setUserDraw((L,P)=>{let R=new M.McDbCircle(l.x,l.y,l.z,L.distanceTo(l)),F=r.getLength(),V=R.getLength();if(!F||!V)return;let j=[];for(let ne=0;ne{J.addVertexAt(ne)}),J.isClosed=!0,P.drawMcDbEntity(J),v=[...j]}),!(yield x.go()))return;let b=M.MxCpp.getCurrentMxCAD(),A=new M.McDbPolyline;v.forEach(L=>{A.addVertexAt(L)}),A.isClosed=!0,b.drawEntity(A)})}function uR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(` 请输入凹凸线宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(` 请输入凹凸线高度<10>`),(yield c.go())&&(l=c.value());let f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起始点");let r=yield f.go();if(!r)return;let v=new M.MxCADUiPrPoint;v.setMessage("请点击确定终点"),v.setUserDraw((fe,me)=>{let he=new M.McDbLine(r.x,r.y,r.z,fe.x,fe.y,fe.z);me.drawMcDbEntity(he)});let x=yield v.go();if(!x)return;let w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=w.clone(),A=w.getLength(),L=w.getPointAtDist(A.val/2).val,P=M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis);b.rotate(L,P);let R=b.getPointAtDist(A.val/2+l/2).val,F=b.getPointAtDist(A.val/2-l/2).val,V=w.offsetCurves(l/2,R),j=w.offsetCurves(l/2,F),J=M.MxCpp.App.getCurrentMxCAD();if(V.length()===0||j.length()===0)return;let ne,H;V.forEach(fe=>{ne=fe.clone()}),j.forEach(fe=>{H=fe.clone()});let Q=[],ae=A.val/e;for(let fe=0;fe{ie.addVertexAt(fe)});let le=w.getPointAtDist(e*parseInt(ae.toString())).val;ie.setPointAt(0,w.startPoint),ie.setPointAt(Q.length-1,le),J.drawEntity(ie)})}function hR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(` 请输入锯齿线宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(` 请输入锯齿线高度<10>`),(yield c.go())&&(l=c.value());let f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起始点");let r=yield f.go();if(!r)return;let v=new M.MxCADUiPrPoint;v.setMessage("请点击确定终点"),v.setUserDraw((fe,me)=>{let he=new M.McDbLine(r.x,r.y,r.z,fe.x,fe.y,fe.z);me.drawMcDbEntity(he)});let x=yield v.go();if(!x)return;let w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=w.clone(),A=w.getLength(),L=w.getPointAtDist(A.val/2).val,P=M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis);b.rotate(L,P);let R=b.getPointAtDist(A.val/2+l/2).val,F=b.getPointAtDist(A.val/2-l/2).val,V=w.offsetCurves(l/2,R),j=w.offsetCurves(l/2,F),J=M.MxCpp.App.getCurrentMxCAD();if(V.length()===0||j.length()===0)return;let ne,H;V.forEach(fe=>{ne=fe.clone()}),j.forEach(fe=>{H=fe.clone()});let Q=[],ae=A.val/(e/2);for(let fe=0;fe{ie.addVertexAt(fe)});let le=w.getPointAtDist(e/2*parseInt(ae.toString())).val;ie.setPointAt(0,w.startPoint),ie.setPointAt(Q.length-1,le),J.drawEntity(ie)})}function dR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(` 请输入矩形宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(` 请输入矩形高度<10>`),(yield c.go())&&(l=c.value());const f=A=>{const L=[];return L.push(new M.McGePoint3d(A.x+e/2,A.y+l/2,A.z)),L.push(new M.McGePoint3d(A.x-e/2,A.y+l/2,A.z)),L.push(new M.McGePoint3d(A.x-e/2,A.y-l/2,A.z)),L.push(new M.McGePoint3d(A.x+e/2,A.y-l/2,A.z)),L},r=new M.MxCADUiPrPoint;r.setMessage("请点击确定矩形中心"),r.setUserDraw((A,L)=>{const P=f(A);let R=new M.McDbPolyline;P.forEach(F=>{R.addVertexAt(F)}),R.isClosed=!0,L.drawMcDbEntity(R)});const v=yield r.go();if(!v)return;const x=f(v);let w=new M.McDbPolyline;x.forEach(A=>{w.addVertexAt(A)});const b=M.MxCpp.App.getCurrentMxCAD();w.isClosed=!0,b.drawEntity(w)})}function pR(){return Qe(this,null,function*(){let e=10;const t=new M.MxCADUiPrDist;t.setMessage(` 请设置断口宽度<10>`),(yield t.go())&&(e=t.value());let l=5;const c=new M.MxCADUiPrDist;c.setMessage(` 请设置两头延长长度<5>`),(yield c.go())&&(l=c.value()),console.log(l);const f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起点");const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrPoint;v.setMessage("请点击下一个点"),v.setUserDraw((le,fe)=>{const me=new M.McDbLine(r.x,r.y,r.z,le.x,le.y,le.z);fe.drawMcDbEntity(me)});const x=yield v.go();if(!x)return;const w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=w.getPointAtDist(w.getLength().val/2).val;let A=w.getFirstDeriv(b),L=A.val.clone();if(!A.ret)return;A.val.normalize().mult(e/2),L.normalize().mult(l),r.subvec(L),x.addvec(L);let P=b.clone();P.addvec(A.val);let R=b.clone();R.subvec(A.val);let F=new M.McDbLine(b.x,b.y,b.z,P.x,P.y,P.z),V=M.McGeVector3d.kXAxis.angleTo1(M.McGeVector3d.kYAxis),j=F.clone();j.rotate(F.getPointAtDist(F.getLength().val/2).val,V);let J=j.getPointAtDist(2*j.getLength().val).val,H=new M.McDbLine(b.x,b.y,b.z,R.x,R.y,R.z).clone();H.rotate(H.getPointAtDist(H.getLength().val/2).val,V);let Q=H.getPointAtDist(2*H.getLength().val).val;const ae=new M.McDbPolyline;ae.addVertexAt(r),ae.addVertexAt(R),ae.addVertexAt(Q),ae.addVertexAt(J),ae.addVertexAt(P),ae.addVertexAt(x),M.MxCpp.App.getCurrentMxCAD().drawEntity(ae)})}function fR(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("CIRCLE");let t=yield M.MxCADUtility.userSelect("选择目标对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity(),c=l.center,h=l.radius,f=M.MxCpp.App.getCurrentMxCAD(),r=new M.McDbLine(c.x+h*1.3,c.y,c.z,c.x-h*1.3,c.y,c.z);r.trueColor=new M.McCmColor(255,0,0);let v=new M.McDbLine(c.x,c.y+h*1.3,c.z,c.x,c.y-h*1.3,c.z);v.trueColor=new M.McCmColor(255,0,0),f.drawEntity(r),f.drawEntity(v)}))})}function mR(){return Qe(this,null,function*(){let e=10;const t=new M.MxCADUiPrDist;t.setMessage(` 请输入管径<10>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(` 请输入长出管口长度<5>`),(yield c.go())&&(l=c.value());let f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起点");const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrPoint;v.setMessage("请点击确定终点"),v.setUserDraw((H,Q)=>{const ae=new M.McDbLine(r.x,r.y,r.z,H.x,H.y,H.z);Q.drawMcDbEntity(ae)});const x=yield v.go();if(!x)return;const w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z),b=M.MxCpp.App.getCurrentMxCAD();let A=w.getLength().val,L=w.getPointAtDist(A+l),P=w.getPointAtDist(0-l),R=w.getPointAtDist(A/2).val,F=M.McGeVector3d.kXAxis.angleTo1(M.McGeVector3d.kYAxis),V=w.clone();V.rotate(R,F);let j=V.getPointAtDist(A/2+e/2).val,J=V.getPointAtDist(A/2-e/2).val;w.offsetCurves(e/2,j).forEach(H=>{H.trueColor=new M.McCmColor(0,255,0),b.drawEntity(H)}),w.offsetCurves(e/2,J).forEach(H=>{H.trueColor=new M.McCmColor(0,255,0),b.drawEntity(H)});let ne=b.addLinetypeEx("TestMyLine","25,-5");ne.isValid()&&(w.linetypeId=ne,w.endPoint=P.val,w.startPoint=L.val,w.trueColor=new M.McCmColor(255,0,0),b.drawEntity(w))})}function gR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("指定剖管线起点");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;i.setMessage("指定剖管线终点"),i.setUserDraw((H,Q)=>{let ae=new M.McDbLine(t.x,t.y,t.z,H.x,H.y,H.z);Q.drawMcDbEntity(ae)});const l=yield i.go();if(!l)return;const c=new M.McDbLine(t.x,t.y,t.z,l.x,l.y,l.z),h=c.getLength().val,f=h/8,r=c.getPointAtDist(h/2).val,v=c.clone();v.rotate(r,Math.PI/2);const x=v.getPointAtDist(h/2+f).val,w=v.getPointAtDist(h/2-f).val,b=M.MxCpp.App.getCurrentMxCAD();let A;c.clone().offsetCurves(f,x).forEach(H=>{A=H});let L;c.clone().offsetCurves(f,w).forEach(H=>{L=H});const P=[],R=[];for(let H=0;H<4;H++)H%2!==0&&(P.push(A.getPointAtDist(H*f*2).val),R.push(L.getPointAtDist(H*f*2).val));let F,V=new M.McDbArc;V.computeArc(t.x,t.y,P[0].x,P[0].y,r.x,r.y),b.drawEntity(V);let j=new M.McDbArc;j.computeArc(t.x,t.y,R[0].x,R[0].y,r.x,r.y),b.drawEntity(j);let J=new M.McDbArc;J.computeArc(r.x,r.y,R[1].x,R[1].y,l.x,l.y),F=b.drawEntity(J);let ne=new M.MxCADUiPrKeyWord;for(;;){ne.setMessage("选择剖管线圆弧方向"),ne.setKeyWords("[左边(L)/右边(R)]");const H=yield ne.go();if(!H)return;if(H=="L"){let Q=new M.McDbArc;F.erase(),Q.computeArc(r.x,r.y,R[1].x,R[1].y,l.x,l.y),F=b.drawEntity(Q)}else if(H=="R"){F.erase();let Q=new M.McDbArc;Q.computeArc(r.x,r.y,P[1].x,P[1].y,l.x,l.y),F=b.drawEntity(Q)}}})}function yR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择模式"),e.setKeyWords("[直线焊缝(L)/弧线焊缝(A)]");const t=yield e.go();if(!t)return;let i=5;const l=new M.MxCADUiPrDist;l.setMessage(` 请输入焊缝半径<5>`),(yield l.go())&&(i=l.value());let h=new M.McDbCurve;if(t==="L"){let A=new M.MxCADUiPrPoint;A.setMessage("请点击确定起始点");let L=yield A.go();if(!L)return;let P=new M.MxCADUiPrPoint;P.setMessage("请点击确定终点"),P.setUserDraw((F,V)=>{let j=new M.McDbLine(L.x,L.y,L.z,F.x,F.y,F.z);V.drawMcDbEntity(j)});let R=yield P.go();if(!R)return;h=new M.McDbLine(L.x,L.y,L.z,R.x,R.y,R.z)}else if(t==="A"){let A=new M.MxCADUiPrPoint;A.setMessage("指定起点");let L=yield A.go();if(!L)return;let P=new M.MxCADUiPrPoint;P.setMessage("指定圆弧的第二个点"),P.setUserDraw((J,ne)=>{ne.drawLine(L.toVector3(),J.toVector3())});let R=yield P.go();if(!R)return;let F=new M.MxCADUiPrPoint;F.setMessage("指定圆弧的端点"),F.setUserDraw((J,ne)=>{let H=new M.McDbArc;H.computeArc(L.x,L.y,R.x,R.y,J.x,J.y),ne.drawMcDbEntity(H)});let V=yield F.go();if(!V)return;let j=new M.McDbArc;j.computeArc(L.x,L.y,R.x,R.y,V.x,V.y),h=j}const f=M.MxCpp.App.getCurrentMxCAD();let v=h.getLength().val/i,x=[],w,b;t==="A"&&(w=h.center,b=h.radius);for(let A=0;A{F.push(J)});let V=[],j=[];P.splitCurves(F).forEach((J,ne)=>{if(t==="L")ne%2!==0&&x.push(J);else if(t==="A"){let H=J.clone();H.getPointAtDist(H.getLength().val/2).val.distanceTo(w)>b?V.push(H):j.push(H)}}),V.length===1&&t==="A"?x.push(V[0]):t==="A"&&V.length>1&&(j[0].rotate(P.center,Math.PI),x.push(j[0]))}x.forEach((A,L)=>{if(L===0)f.drawEntity(A);else{let P=A.IntersectWith(x[L-1],M.McDb.Intersect.kExtendThis);if(P.length()===0)return;let R=[];P.forEach(j=>{R.push(j)});let F=[];A.splitCurves(R).forEach((j,J)=>{F.push({obj_cur:j,lenth:j.getLength().val})});let V=F.map(j=>j.lenth);f.drawEntity(F[V.indexOf(Math.max(...V))].obj_cur)}})})}function _R(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE,LWPOLYLINE");let t=yield M.MxCADUtility.userSelect("选择对象",e);t.length!=0&&t.forEach(i=>Qe(this,null,function*(){let l=yield i.getMcDbEntity();if(!l)return;let c=l.clone(),h=c.getLength(),f=c.getPointAtDist(h.val/2).val;if(!c.getFirstDeriv(f).ret)return;let v=M.McGeVector3d.kYAxis.angleTo1(M.McGeVector3d.kXAxis);c.rotate(f,v);let x=M.MxCpp.App.getCurrentMxCAD();c.trueColor=new M.McCmColor(255,0,0),x.drawEntity(c)}))})}function vR(){return Qe(this,null,function*(){let e=25;const t=new M.MxCADUiPrDist;t.setMessage("请输入宽度<25>"),(yield t.go())&&(e=t.value());let l=15;const c=new M.MxCADUiPrDist;c.setMessage("请输入高度<15>"),(yield c.go())&&(l=c.value());const f=new M.MxCADUiPrInt;f.setMessage("请输入楼梯级数<10>");const r=(yield f.go())||10,v=Math.sqrt(e*e+l*l),x=new M.MxCADUiPrPoint;x.setMessage("请点击确定起点");const w=yield x.go();if(!w)return;const b=new M.MxCADUiPrPoint;b.setMessage("请点击确定终点"),b.setUserDraw((V,j)=>{const J=new M.McDbLine(w.x,w.y,w.z,V.x,V.y,V.z);j.drawMcDbEntity(J)});const A=yield b.go();if(!A)return;const L=new M.McDbLine(w.x,w.y,w.z,A.x,A.y,A.z),P=[];for(let V=0;V{if(R.addVertexAt(V),j!=P.length-1){let J=new M.McGePoint3d(V.x,P[j+1].y,V.z);R.addVertexAt(J)}}),M.MxCpp.App.getCurrentMxCAD().drawEntity(R)})}function xR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(`请确定圆心位置 `);const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setBasePt(t),i.setMessage("请输入圆半径"),i.setUserDraw((f,r)=>{const v=f.distanceTo(t),x=new M.McDbCircle;x.center=t,x.radius=v,r.drawMcDbEntity(x)}),!(yield i.go()))return;const c=i.value(),h=M.MxCpp.getCurrentMxCAD();h.pathCircle(t.x,t.y,c),h.drawPathToHatch()})}function bR(){return Qe(this,null,function*(){let e=5;const t=new M.MxCADUiPrDist;t.setMessage(` 请输入保温棉宽度<5>`),(yield t.go())&&(e=t.value());let l=10;const c=new M.MxCADUiPrDist;c.setMessage(` 请输入保温棉高度<10>`),(yield c.go())&&(l=c.value());const f=new M.MxCADUiPrPoint;f.setMessage("请点击确定起点");const r=yield f.go();if(!r)return;const v=new M.MxCADUiPrPoint;v.setMessage("请点击下一个点"),v.setUserDraw((ae,ie)=>{const le=new M.McDbLine(r.x,r.y,r.z,ae.x,ae.y,ae.z);ie.drawMcDbEntity(le)});const x=yield v.go();if(!x)return;const w=new M.McDbLine(r.x,r.y,r.z,x.x,x.y,x.z);r.y{R=ae}),w.offsetCurves(l/2,P).forEach(ae=>{F=ae});let V=w.getLength().val/e*2,j=[],J=[],ne=[];for(let ae=0;ae{H.addVertexAt(ae)});const Q=M.MxCpp.App.getCurrentMxCAD();Q.drawEntity(H),J.forEach(ae=>{const ie=new M.McDbArc;ie.center=ae,ie.radius=e/2,ie.startAngle=-new M.McGeVector3d(w.endPoint.x-w.startPoint.x,w.endPoint.y-w.startPoint.y).angleTo1(M.McGeVector3d.kXAxis),ie.endAngle=new M.McGeVector3d(w.startPoint.x-w.endPoint.x,w.startPoint.y-w.endPoint.y).angleTo1(M.McGeVector3d.kXAxis),Q.drawEntity(ie)}),ne.forEach(ae=>{const ie=new M.McDbArc;ie.center=ae,ie.radius=e/2,ie.startAngle=new M.McGeVector3d(w.startPoint.x-w.endPoint.x,w.startPoint.y-w.endPoint.y).angleTo1(M.McGeVector3d.kXAxis),ie.endAngle=-new M.McGeVector3d(w.endPoint.x-w.startPoint.x,w.endPoint.y-w.startPoint.y).angleTo1(M.McGeVector3d.kXAxis),Q.drawEntity(ie)})})}function wR(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择第一条线");const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity(),c=new M.McDbLine(l.startPoint,l.endPoint),h=new M.MxCADUiPrEntity;h.setFilter(e),h.setMessage("请选择第二条线");const f=yield h.go();if(!f.id)return;const r=f.getMcDbEntity(),v=new M.McDbLine(r.startPoint,r.endPoint),x=M.MxCpp.getCurrentMxCAD();let w=l.IntersectWith(v,M.McDb.Intersect.kExtendBoth);if(console.log(w.length()),w.length()===0){const b=l.getLength().val>r.getLength().val?r.clone():l.clone(),A=l.getLength().val>r.getLength().val?c:v,L=b.clone(),P=b.getPointAtDist(b.getLength().val/2).val;if(b.rotate(P,Math.PI/2),w=b.IntersectWith(A,M.McDb.Intersect.kExtendBoth),!w.length())return;const R=w.at(0).distanceTo(P)/2;L.offsetCurves(R,w.at(0)).forEach(F=>{F.trueColor=new M.McCmColor(255,0,0),x.drawEntity(F)})}else{const b=new M.McDbCircle;let A,L=c.endPoint.distanceTo(w.at(0)),P=c.startPoint.distanceTo(w.at(0));L!==0&&P!==0&&(L>P?c.startPoint=w.at(0):c.endPoint=w.at(0));let R=v.endPoint.distanceTo(w.at(0)),F=v.startPoint.distanceTo(w.at(0));R!==0&&F!==0&&(F>R?v.startPoint=w.at(0):v.endPoint=w.at(0)),c.getLength().val>v.getLength().val?(A=v.getLength().val,new M.McDbLine(r.startPoint,v.endPoint)):(A=l.getLength().val,new M.McDbLine(c.startPoint,c.endPoint)),b.center=w.at(0),b.radius=A;let V=b.IntersectWith(c,M.McDb.Intersect.kOnBothOperands),j=b.IntersectWith(v,M.McDb.Intersect.kOnBothOperands);if(!V.length()||!j.length())return;let J=V.at(0).sub(w.at(0)).angleTo2(M.McGeVector3d.kXAxis),ne=j.at(0).sub(w.at(0)).angleTo2(M.McGeVector3d.kXAxis),H=new M.McDbArc;H.center=w.at(0),H.radius=A,H.startAngle=J,H.endAngle=ne;const Q=H.getPointAtDist(H.getLength().val/2).val,ae=new M.McDbLine(w.at(0),Q),ie=new M.MxCADUiPrPoint;ie.setMessage("请选择终点"),ie.setUserDraw((fe,me)=>{let he=ae.getClosestPointTo(fe,!0).val,Oe=ae.clone();Oe.endPoint=he,me.drawMcDbEntity(Oe)});const le=yield ie.go();if(!le)return;ae.endPoint=ae.getClosestPointTo(le,!0).val,ae.trueColor=new M.McCmColor(255,0,0),x.drawEntity(ae)}})}function MR(){return Qe(this,null,function*(){let e=new M.MxCADResbuf;e.AddMcDbEntityTypes("LWPOLYLINE");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择目标矩形");const i=yield t.go();if(!i.id)return;const l=i.getMcDbEntity();let c=[];const h=l.numVerts();for(let w=0;w{let A=[];c.forEach(P=>{A.push(P.distanceTo(w))}),r=A.findIndex(P=>P===Math.min(...A));let L=l.clone();L.setPointAt(r,w),b.drawMcDbEntity(L)});const v=yield f.go();if(!v)return;let x=l.clone();x.setPointAt(r,v),M.MxCpp.getCurrentMxCAD().drawEntity(x)})}function TR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("设置指北针中心点");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setMessage("设置指北针半径"),i.setBasePt(t),i.setUserDraw((F,V)=>{const j=F.distanceTo(t);V.drawCircle(t.toVector3(),j)}),!(yield i.go()))return;const c=i.value(),h=M.MxCpp.App.getCurrentMxCAD(),f=new M.McDbCircle;f.trueColor=new M.McCmColor(0,255,0),f.center=t,f.radius=c,h.drawEntity(f);const r=new M.McGePoint3d(t.x,t.y+c),v=new M.McGePoint3d(t.x,t.y-c),x=new M.McDbLine;x.startPoint=r,x.endPoint=v;const w=x.clone();w.rotate(r,Math.PI/30);const b=x.clone();b.rotate(r,-Math.PI/30);let A,L;w.IntersectWith(f,M.McDb.Intersect.kOnBothOperands).forEach(F=>{F.x!==r.x&&F.y!==r.y&&(A=F)}),b.IntersectWith(f,M.McDb.Intersect.kOnBothOperands).forEach(F=>{F.x!==r.x&&F.y!==r.y&&(L=F)});let P=M.MxCADUtility.calcBulge(A,v,L);h.pathMoveToEx(A.x,A.y,0,0,P.val),h.pathLineTo(L.x,L.y),h.pathLineTo(r.x,r.y),h.pathLineTo(A.x,A.y),h.drawColor=new M.McCmColor(25,255,0),h.drawPathToHatch(1);const R=new M.McDbText;R.height=c/3,R.position=new M.McGePoint3d(t.x,t.y+c*1.2),R.alignmentPoint=R.position,R.textString="N",R.horizontalMode=M.McDb.TextHorzMode.kTextMid,R.trueColor=new M.McCmColor(25,255,0),h.drawEntity(R)})}function ER(){return Qe(this,null,function*(){const e=new M.MxCADUiPrKeyWord;e.setMessage("选择提示框指向"),e.setKeyWords("[向上(U)/向下(D)]");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrPoint;let l=M.MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();i.setMessage(` 指定消息框第一点:`);let c=yield i.go();if(!c)return;let h=M.MxCpp.getCurrentMxCAD(),f=new X.MxDbRect;f.pt1=c.toVector3(),i.setUserDraw((V,j)=>{f.pt2=V.toVector3(),f.setColor(l),j.drawCustomEntity(f)}),i.setMessage(` 指定消息框第二点:`),i.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let r=yield i.go();if(!r)return;f.pt2=r.toVector3();let v=new M.McDbPolyline;v.isClosed=!0;let x;c.y>r.y&&t==="U"||c.yr.y&&t==="D"||c.y{const J=x.getClosestPointTo(V,!1).val;let ne=v.getFirstDeriv(J);if(!ne.ret)return;ne.val.normalize().mult(w/4),P=J.clone(),P.addvec(ne.val),R=J.clone(),R.subvec(ne.val);let H=v.clone();H.addVertexAt(R),H.addVertexAt(V),H.addVertexAt(P),j.drawMcDbEntity(H)});let F=yield L.go();F&&(v.addVertexAt(R),v.addVertexAt(F),v.addVertexAt(P),h.drawEntity(v))})}function CR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrString;e.setMessage("请设置基准符文字");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;if(i.setMessage("请设置文字高度"),!(yield i.go()))return;const c=i.value(),h=new M.MxCADUiPrPoint;h.setMessage("请设置基准符位置");const f=M.MxCpp.getCurrentMxCAD();let r=new M.McDbBlockReference;h.setUserDraw((x,w)=>{const b=new M.McDbPolyline;b.addVertexAt(new M.McGePoint3d(x.x+c,x.y,0),0,2,2),b.addVertexAt(new M.McGePoint3d(x.x-c,x.y,0));const A=new M.McDbLine(x,new M.McGePoint3d(x.x,x.y+c*(8/7),0)),L=new M.McDbCircle;L.center=new M.McGePoint3d(x.x,x.y+c*2.142857142857143,0),L.radius=c;const P=new M.McDbText;P.textString=t,P.height=c,P.position=P.alignmentPoint=new M.McGePoint3d(x.x,x.y+c*1.7857142857142858,0),P.horizontalMode=M.McDb.TextHorzMode.kTextMid;let F=f.getDatabase().getBlockTable().add(new M.McDbBlockTableRecord),V=F.getMcDbBlockTableRecord();V!=null&&(V.appendAcDbEntity(b),V.appendAcDbEntity(A),V.appendAcDbEntity(L),V.appendAcDbEntity(P),V.name="基准符",V.origin=x,r.blockTableRecordId=F,r.position=x,w.drawMcDbEntity(r))}),(yield h.go())&&f.drawEntity(r)})}function AR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请设置圆心");let t=yield e.go();if(!t)return;const i=M.MxCpp.getCurrentMxCAD();for(let l=1;l<4;l++){const c=new M.McDbCircle;c.center=t,c.radius=10*l,i.drawEntity(c)}})}function DR(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage("请设置齿轮圆心");const t=yield e.go();if(!t)return;const i=new M.MxCADUiPrDist;i.setBasePt(t),i.setMessage("请设置齿轮半径"),i.setUserDraw((j,J)=>{const ne=new M.McDbCircle;ne.center=t,ne.radius=j.distanceTo(t),J.drawMcDbEntity(ne)});const l=yield i.go();let c=10;l&&(c=i.value());const h=M.MxCpp.getCurrentMxCAD(),f=new M.McDbCircle;f.center=t,f.radius=c;const r=30,v=f.getLength().val/(r*2),x=new M.McGePoint3d(t.x,t.y+c,t.z),w=f.getDistAtPoint(x).val,b=f.getPointAtDist(w+v/2).val,A=f.getPointAtDist(w-v/2).val,L=[],P=new M.McDbPolyline;P.addVertexAt(b),P.addVertexAt(new M.McGePoint3d(b.x,b.y+5,b.z)),P.addVertexAt(new M.McGePoint3d(A.x,A.y+5,A.z)),P.addVertexAt(A),L.push(P);for(let j=0;j{J%2!==0&&(j.IntersectWith(f,M.McDb.Intersect.kOnBothOperands).forEach(H=>{R.push(H)}),h.drawEntity(j))});const F=new M.McDbArc,V=new M.McGePoint3d(t.x,t.y-c,t.z);F.computeArc(b.x,b.y,V.x,V.y,A.x,A.y),F.splitCurves(R).forEach((j,J)=>{J%2!==0&&h.drawEntity(j)})})}function PR(){return Qe(this,null,function*(){const e=new M.MxCADResbuf;e.AddMcDbEntityTypes("INSERT");const t=new M.MxCADUiPrEntity;t.setFilter(e),t.setMessage("请选择目标块");const i=yield t.go();if(!i.id)return;const c=i.getMcDbEntity().getBoundingBox(),h=new M.McDbLine(c.minPt,c.maxPt),f=h.getPointAtDist(h.getLength().val/2).val,r=new M.MxCADUiPrDist;let v=10;r.setMessage(` 请设置中心线长度10>`),r.setBasePt(f),r.setUserDraw((V,j)=>{const J=V.distanceTo(f),ne=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(J)),H=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(J).negate()),Q=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(J)),ae=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(J).negate()),ie=new M.McDbLine(ne,H),le=new M.McDbLine(Q,ae);j.drawMcDbEntity(ie),j.drawMcDbEntity(le)}),(yield r.go())&&(v=r.value());const w=M.MxCpp.getCurrentMxCAD(),b=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(v)),A=f.clone().addvec(M.McGeVector3d.kXAxis.normalize().mult(v).negate()),L=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(v)),P=f.clone().addvec(M.McGeVector3d.kYAxis.normalize().mult(v).negate()),R=new M.McDbLine(b,A),F=new M.McDbLine(L,P);w.drawEntity(R),w.drawEntity(F)})}function SR(){X.MxFun.addCommand("Mx_DrawStart",cR),X.MxFun.addCommand("Mx_ConcavoVex",uR),X.MxFun.addCommand("Mx_ZigzagLine",hR),X.MxFun.addCommand("Mx_CenterRect",dR),X.MxFun.addCommand("Mx_BreakLine",pR),X.MxFun.addCommand("Mx_CCLine",fR),X.MxFun.addCommand("Mx_Piping",mR),X.MxFun.addCommand("Mx_CutPipeline",gR),X.MxFun.addCommand("Mx_WelLine",yR),X.MxFun.addCommand("Mx_PerpLine",_R),X.MxFun.addCommand("Mx_StairLine",vR),X.MxFun.addCommand("Mx_SolidCircle",xR),X.MxFun.addCommand("Mx_CottonInsulation",bR),X.MxFun.addCommand("Mx_CenterLine",wR),X.MxFun.addCommand("Mx_DoHole",MR),X.MxFun.addCommand("Mx_Compass",TR),X.MxFun.addCommand("Mx_MassegeBox",ER),X.MxFun.addCommand("Mx_DatumSymbol",CR),X.MxFun.addCommand("Mx_ConcentricCircles",AR),X.MxFun.addCommand("Mx_Gear",DR),X.MxFun.addCommand("Mx_BlkCenterLine",PR)}var lb={exports:{}};(function(e,t){(function(i,l){e.exports=l()})(XS,function(){var i,l,c;function h(r,v){if(!i)i=v;else if(!l)l=v;else{var x="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;",w={};i(w),c=v(w),typeof window!="undefined"&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([x],{type:"text/javascript"})))}}h(["exports"],function(r){var v="2.8.2",x=w;function w(a,n,s,u){this.cx=3*a,this.bx=3*(s-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*n,this.by=3*(u-n)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=u,this.p2x=s,this.p2y=u}w.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},w.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},w.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},w.prototype.solveCurveX=function(a,n){var s,u,p,g,_;for(n===void 0&&(n=1e-6),p=a,_=0;_<8;_++){if(g=this.sampleCurveX(p)-a,Math.abs(g)(u=1))return u;for(;sg?s=p:u=p,p=.5*(u-s)+s}return p},w.prototype.solve=function(a,n){return this.sampleCurveY(this.solveCurveX(a,n))};var b=A;function A(a,n){this.x=a,this.y=n}A.prototype={clone:function(){return new A(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,n){return this.clone()._rotateAround(a,n)},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 n=a.x-this.x,s=a.y-this.y;return n*n+s*s},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,n){return Math.atan2(this.x*n-this.y*a,this.x*a+this.y*n)},_matMult:function(a){var n=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=n,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 n=Math.cos(a),s=Math.sin(a),u=s*this.x+n*this.y;return this.x=n*this.x-s*this.y,this.y=u,this},_rotateAround:function(a,n){var s=Math.cos(a),u=Math.sin(a),p=n.y+u*(this.x-n.x)+s*(this.y-n.y);return this.x=n.x+s*(this.x-n.x)-u*(this.y-n.y),this.y=p,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},A.convert=function(a){return a instanceof A?a:Array.isArray(a)?new A(a[0],a[1]):a};var L=typeof self!="undefined"?self:{};const P=Math.PI/180,R=180/Math.PI;function F(a){return a*P}function V(a){return a*R}const j=[[0,0],[1,0],[1,1],[0,1]];function J(a){if(a<=0)return 0;if(a>=1)return 1;const n=a*a,s=n*a;return 4*(a<.5?s:3*(a-n)+s-.75)}function ne(a,n,s,u){const p=new x(a,n,s,u);return function(g){return p.solve(g)}}const H=ne(.25,.1,.25,1);function Q(a,n,s){return Math.min(s,Math.max(n,a))}function ae(a,n,s){return(s=Q((s-a)/(n-a),0,1))*s*(3-2*s)}function ie(a,n,s){const u=s-n,p=((a-n)%u+u)%u+n;return p===n?s:p}function le(a,n,s){if(!a.length)return s(null,[]);let u=a.length;const p=new Array(a.length);let g=null;a.forEach((_,T)=>{n(_,(D,I)=>{D&&(g=D),p[T]=I,--u==0&&s(g,p)})})}function fe(a){const n=[];for(const s in a)n.push(a[s]);return n}function me(a,...n){for(const s of n)for(const u in s)a[u]=s[u];return a}let he=1;function Oe(){return he++}function Ve(){return function a(n){return n?(n^Math.random()*(16>>n/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,a)}()}function He(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function at(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 At(a,n){a.forEach(s=>{n[s]&&(n[s]=n[s].bind(n))})}function yt(a,n){return a.indexOf(n,a.length-n.length)!==-1}function Dt(a,n,s){const u={};for(const p in a)u[p]=n.call(s||this,a[p],p,a);return u}function It(a,n,s){const u={};for(const p in a)n.call(s||this,a[p],p,a)&&(u[p]=a[p]);return u}function Nt(a){return Array.isArray(a)?a.map(Nt):typeof a=="object"&&a?Dt(a,Nt):a}const Ie={};function be(a){Ie[a]||(typeof console!="undefined"&&console.warn(a),Ie[a]=!0)}function We(a,n,s){return(s.y-a.y)*(n.x-a.x)>(n.y-a.y)*(s.x-a.x)}function Ge(a){let n=0;for(let s,u,p=0,g=a.length,_=g-1;p@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(s,u,p,g)=>{const _=p||g;return n[u]=!_||_.toLowerCase(),""}),n["max-age"]){const s=parseInt(n["max-age"],10);isNaN(s)?delete n["max-age"]:n["max-age"]=s}return n}let ge,Ce,Ae,_e,Ne=null;function Je(a){if(Ne==null){const n=a.navigator?a.navigator.userAgent:null;Ne=!!a.safari||!(!n||!(/\b(iPad|iPhone|iPod)\b/.test(n)||n.match("Safari")&&!n.match("Chrome")))}return Ne}function ct(a){try{const n=L[a];return n.setItem("_mapbox_test_",1),n.removeItem("_mapbox_test_"),!0}catch(n){return!1}}const wt={now:()=>Ae!==void 0?Ae:L.performance.now(),setNow(a){Ae=a},restoreNow(){Ae=void 0},frame(a){const n=L.requestAnimationFrame(a);return{cancel:()=>L.cancelAnimationFrame(n)}},getImageData(a,n=0){const{width:s,height:u}=a;_e||(_e=L.document.createElement("canvas"));const p=_e.getContext("2d");if(!p)throw new Error("failed to create canvas 2d context");return(s>_e.width||u>_e.height)&&(_e.width=s,_e.height=u),p.clearRect(-n,-n,s+2*n,u+2*n),p.drawImage(a,0,0,s,u),p.getImageData(-n,-n,s+2*n,u+2*n)},resolveURL:a=>(ge||(ge=L.document.createElement("a")),ge.href=a,ge.href),get devicePixelRatio(){return L.devicePixelRatio},get prefersReducedMotion(){return!!L.matchMedia&&(Ce==null&&(Ce=L.matchMedia("(prefers-reduced-motion: reduce)")),Ce.matches)}};let Gt;const pe={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(Gt==null){const a=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Gt=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):a}catch(n){Gt=a}}return Gt},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},Me={supported:!1,testSupport:function(a){!bn&>&&(hn?nn(a):bt=a)}};let bt,gt,bn=!1,hn=!1;function nn(a){const n=a.createTexture();a.bindTexture(a.TEXTURE_2D,n);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,gt),a.isContextLost())return;Me.supported=!0}catch(s){}a.deleteTexture(n),bn=!0}L.document&&(gt=L.document.createElement("img"),gt.onload=function(){bt&&nn(bt),bt=null,hn=!0},gt.onerror=function(){bn=!0,bt=null},gt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const pn="01",wn="NO_ACCESS_TOKEN";function cn(a){return a.indexOf("mapbox:")===0}function Wt(a){return pe.API_URL_REGEX.test(a)}const sn=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Xt(a){const n=a.match(sn);if(!n)throw new Error("Unable to parse URL object");return{protocol:n[1],authority:n[2],path:n[3]||"/",params:n[4]?n[4].split("&"):[]}}function Xe(a){const n=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${n}`}function Ut(a){if(!a)return null;const n=a.split(".");if(!n||n.length!==3)return null;try{return JSON.parse(decodeURIComponent(L.atob(n[1]).split("").map(s=>"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(s){return null}}class en{constructor(n){this.type=n,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(n){const s=Ut(pe.ACCESS_TOKEN);let u="";return u=s&&s.u?L.btoa(encodeURIComponent(s.u).replace(/%([0-9A-F]{2})/g,(p,g)=>String.fromCharCode(+("0x"+g)))):pe.ACCESS_TOKEN||"",n?`mapbox.eventData.${n}:${u}`:`mapbox.eventData:${u}`}fetchEventData(){const n=ct("localStorage"),s=this.getStorageKey(),u=this.getStorageKey("uuid");if(n)try{const p=L.localStorage.getItem(s);p&&(this.eventData=JSON.parse(p));const g=L.localStorage.getItem(u);g&&(this.anonId=g)}catch(p){be("Unable to read from LocalStorage")}}saveEventData(){const n=ct("localStorage"),s=this.getStorageKey(),u=this.getStorageKey("uuid");if(n)try{L.localStorage.setItem(u,this.anonId),Object.keys(this.eventData).length>=1&&L.localStorage.setItem(s,JSON.stringify(this.eventData))}catch(p){be("Unable to write to LocalStorage")}}processRequests(n){}postEvent(n,s,u,p){if(!pe.EVENTS_URL)return;const g=Xt(pe.EVENTS_URL);g.params.push(`access_token=${p||pe.ACCESS_TOKEN||""}`);const _={event:this.type,created:new Date(n).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:v,skuId:pn,userId:this.anonId},T=s?me(_,s):_,D={url:Xe(g),headers:{"Content-Type":"text/plain"},body:JSON.stringify([T])};this.pendingRequest=je(D,I=>{this.pendingRequest=null,u(I),this.saveEventData(),this.processRequests(p)})}queueRequest(n,s){this.queue.push(n),this.processRequests(s)}}const Pn=new class extends en{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,n){pe.EVENTS_URL&&pe.ACCESS_TOKEN&&Array.isArray(a)&&a.some(s=>cn(s)||Wt(s))&&this.queueRequest(Date.now(),n)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=Ut(pe.ACCESS_TOKEN),s=n?n.u:pe.ACCESS_TOKEN;let u=s!==this.eventData.tokenU;at(this.anonId)||(this.anonId=Ve(),u=!0);const p=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),_=new Date(p),T=(p-this.eventData.lastSuccess)/864e5;u=u||T>=1||T<-1||g.getDate()!==_.getDate()}else u=!0;u?this.postEvent(p,{"enabled.telemetry":!1},g=>{g||(this.eventData.lastSuccess=p,this.eventData.tokenU=s)},a):this.processRequests()}},fn=Pn.postTurnstileEvent.bind(Pn),On=new class extends en{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,n,s,u){this.skuToken=n,this.errorCb=u,pe.EVENTS_URL&&(s||pe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},s):this.errorCb(new Error(wn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:s}=this.queue.shift();n&&this.success[n]||(this.anonId||this.fetchEventData(),at(this.anonId)||(this.anonId=Ve()),this.postEvent(s,{skuToken:this.skuToken},u=>{u?this.errorCb(u):n&&(this.success[n]=!0)},a))}},Gn=On.postMapLoadEvent.bind(On),qn=new class extends en{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,n,s,u){if(!pe.API_URL||!pe.SESSION_PATH)return;const p=Xt(pe.API_URL+pe.SESSION_PATH);p.params.push(`sku=${n||""}`),p.params.push(`access_token=${u||pe.ACCESS_TOKEN||""}`);const g={url:Xe(p),headers:{"Content-Type":"text/plain"}};this.pendingRequest=et(g,_=>{this.pendingRequest=null,s(_),this.saveEventData(),this.processRequests(u)})}getSessionAPI(a,n,s,u){this.skuToken=n,this.errorCb=u,pe.SESSION_PATH&&pe.API_URL&&(s||pe.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},s):this.errorCb(new Error(wn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:s}=this.queue.shift();n&&this.success[n]||this.getSession(s,this.skuToken,u=>{u?this.errorCb(u):n&&(this.success[n]=!0)},a)}},ji=qn.getSessionAPI.bind(qn),Nn=new Set,Di="mapbox-tiles";let ei,Ji,_i=500,jr=50;function zi(){L.caches&&!ei&&(ei=L.caches.open(Di))}function Hr(a){const n=a.indexOf("?");return n<0?a:a.slice(0,n)}let Ar=1/0;const we={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(we);class $ extends Error{constructor(n,s,u){s===401&&Wt(u)&&(n+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(n),this.status=s,this.url=u}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ee=ke()?()=>self.worker&&self.worker.referrer:()=>(L.location.protocol==="blob:"?L.parent:L).location.href,ye=function(a,n){if(!(/^file:/.test(s=a.url)||/^file:/.test(ee())&&!/^\w+:/.test(s))){if(L.fetch&&L.Request&&L.AbortController&&L.Request.prototype.hasOwnProperty("signal"))return function(u,p){const g=new L.AbortController,_=new L.Request(u.url,{method:u.method||"GET",body:u.body,credentials:u.credentials,headers:u.headers,referrer:ee(),signal:g.signal});let T=!1,D=!1;const I=(z=_.url).indexOf("sku=")>0&&Wt(z);var z;u.type==="json"&&_.headers.set("Accept","application/json");const B=(W,K,oe)=>{if(D)return;if(W&&W.message!=="SecurityError"&&be(W),K&&oe)return N(K);const ue=Date.now();L.fetch(_).then(xe=>{if(xe.ok){const Be=I?xe.clone():null;return N(xe,Be,ue)}return p(new $(xe.statusText,xe.status,u.url))}).catch(xe=>{xe.code!==20&&p(new Error(xe.message))})},N=(W,K,oe)=>{(u.type==="arrayBuffer"?W.arrayBuffer():u.type==="json"?W.json():W.text()).then(ue=>{D||(K&&oe&&function(xe,Be,$e){if(zi(),!ei)return;const Ze={status:Be.status,statusText:Be.statusText,headers:new L.Headers};Be.headers.forEach((ut,dt)=>Ze.headers.set(dt,ut));const Ye=ot(Be.headers.get("Cache-Control")||"");if(Ye["no-store"])return;Ye["max-age"]&&Ze.headers.set("Expires",new Date($e+1e3*Ye["max-age"]).toUTCString());const Ke=Ze.headers.get("Expires");Ke&&(new Date(Ke).getTime()-$e<42e4||function(ut,dt){if(Ji===void 0)try{new Response(new ReadableStream),Ji=!0}catch(xt){Ji=!1}Ji?dt(ut.body):ut.blob().then(dt)}(Be,ut=>{const dt=new L.Response(ut,Ze);zi(),ei&&ei.then(xt=>xt.put(Hr(xe.url),dt)).catch(xt=>be(xt.message))}))}(_,K,oe),T=!0,p(null,ue,W.headers.get("Cache-Control"),W.headers.get("Expires")))}).catch(ue=>{D||p(new Error(ue.message))})};return I?function(W,K){if(zi(),!ei)return K(null);const oe=Hr(W.url);ei.then(ue=>{ue.match(oe).then(xe=>{const Be=function($e){if(!$e)return!1;const Ze=new Date($e.headers.get("Expires")||0),Ye=ot($e.headers.get("Cache-Control")||"");return Ze>Date.now()&&!Ye["no-cache"]}(xe);ue.delete(oe),Be&&ue.put(oe,xe.clone()),K(null,xe,Be)}).catch(K)}).catch(K)}(_,B):B(null,null),{cancel:()=>{D=!0,T||g.abort()}}}(a,n);if(ke()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,n,void 0,!0)}var s;return function(u,p){const g=new L.XMLHttpRequest;g.open(u.method||"GET",u.url,!0),u.type==="arrayBuffer"&&(g.responseType="arraybuffer");for(const _ in u.headers)g.setRequestHeader(_,u.headers[_]);return u.type==="json"&&(g.responseType="text",g.setRequestHeader("Accept","application/json")),g.withCredentials=u.credentials==="include",g.onerror=()=>{p(new Error(g.statusText))},g.onload=()=>{if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let _=g.response;if(u.type==="json")try{_=JSON.parse(g.response)}catch(T){return p(T)}p(null,_,g.getResponseHeader("Cache-Control"),g.getResponseHeader("Expires"))}else p(new $(g.statusText,g.status,u.url))},g.send(u.body),{cancel:()=>g.abort()}}(a,n)},Re=function(a,n){return ye(me(a,{type:"arrayBuffer"}),n)},je=function(a,n){return ye(me(a,{method:"POST"}),n)},et=function(a,n){return ye(me(a,{method:"GET"}),n)};function tt(a){const n=L.document.createElement("a");return n.href=a,n.protocol===L.document.location.protocol&&n.host===L.document.location.host}const qe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let rt,vt;rt=[],vt=0;const Vt=function(a,n){if(Me.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),vt>=pe.MAX_PARALLEL_IMAGE_REQUESTS){const g={requestParameters:a,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return rt.push(g),g}vt++;let s=!1;const u=()=>{if(!s)for(s=!0,vt--;rt.length&&vt{u(),g?n(g):_&&(L.createImageBitmap?function(I,z){const B=new L.Blob([new Uint8Array(I)],{type:"image/png"});L.createImageBitmap(B).then(N=>{z(null,N)}).catch(N=>{z(new Error(`Could not load image because of ${N.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(_,(I,z)=>n(I,z,T,D)):function(I,z){const B=new L.Image,N=L.URL;B.onload=()=>{z(null,B),N.revokeObjectURL(B.src),B.onload=null,L.requestAnimationFrame(()=>{B.src=qe})},B.onerror=()=>z(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 W=new L.Blob([new Uint8Array(I)],{type:"image/png"});B.src=I.byteLength?N.createObjectURL(W):qe}(_,(I,z)=>n(I,z,T,D)))});return{cancel:()=>{p.cancel(),u()}}};function Ct(a,n,s){s[a]&&s[a].indexOf(n)!==-1||(s[a]=s[a]||[],s[a].push(n))}function _n(a,n,s){if(s&&s[a]){const u=s[a].indexOf(n);u!==-1&&s[a].splice(u,1)}}class Y{constructor(n,s={}){me(this,s),this.type=n}}class re extends Y{constructor(n,s={}){super("error",me({error:n},s))}}class Fe{on(n,s){return this._listeners=this._listeners||{},Ct(n,s,this._listeners),this}off(n,s){return _n(n,s,this._listeners),_n(n,s,this._oneTimeListeners),this}once(n,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},Ct(n,s,this._oneTimeListeners),this):new Promise(u=>this.once(n,u))}fire(n,s){typeof n=="string"&&(n=new Y(n,s||{}));const u=n.type;if(this.listens(u)){n.target=this;const p=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(const T of p)T.call(this,n);const g=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(const T of g)_n(u,T,this._oneTimeListeners),T.call(this,n);const _=this._eventedParent;_&&(me(n,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),_.fire(n))}else n instanceof re&&console.error(n.error);return this}listens(n){return!!(this._listeners&&this._listeners[n]&&this._listeners[n].length>0||this._oneTimeListeners&&this._oneTimeListeners[n]&&this._oneTimeListeners[n].length>0||this._eventedParent&&this._eventedParent.listens(n))}setEventedParent(n,s){return this._eventedParent=n,this._eventedParentData=s,this}}var Te=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 Tt(a,...n){for(const s of n)for(const u in s)a[u]=s[u];return a}function _t(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function Ot(a){if(Array.isArray(a))return a.map(Ot);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const n={};for(const s in a)n[s]=Ot(a[s]);return n}return _t(a)}class rn extends Error{constructor(n,s){super(s),this.message=s,this.key=n}}class Sn{constructor(n,s=[]){this.parent=n,this.bindings={};for(const[u,p]of s)this.bindings[u]=p}concat(n){return new Sn(this,n)}get(n){if(this.bindings[n])return this.bindings[n];if(this.parent)return this.parent.get(n);throw new Error(`${n} not found in scope.`)}has(n){return!!this.bindings[n]||!!this.parent&&this.parent.has(n)}}const Ln={kind:"null"},Mt={kind:"number"},un={kind:"string"},Kt={kind:"boolean"},mn={kind:"color"},Tn={kind:"object"},Cn={kind:"value"},di={kind:"collator"},Dr={kind:"formatted"},oi={kind:"resolvedImage"};function li(a,n){return{kind:"array",itemType:a,N:n}}function ai(a){if(a.kind==="array"){const n=ai(a.itemType);return typeof a.N=="number"?`array<${n}, ${a.N}>`:a.itemType.kind==="value"?"array":`array<${n}>`}return a.kind}const xs=[Ln,Mt,un,Kt,mn,Dr,Tn,li(Cn),oi];function ko(a,n){if(n.kind==="error")return null;if(a.kind==="array"){if(n.kind==="array"&&(n.N===0&&n.itemType.kind==="value"||!ko(a.itemType,n.itemType))&&(typeof a.N!="number"||a.N===n.N))return null}else{if(a.kind===n.kind)return null;if(a.kind==="value"){for(const s of xs)if(!ko(s,n))return null}}return`Expected ${ai(a)} but found ${ai(n)} instead.`}function uu(a,n){return n.some(s=>s.kind===a.kind)}function bs(a,n){return n.some(s=>s==="null"?a===null:s==="array"?Array.isArray(a):s==="object"?a&&!Array.isArray(a)&&typeof a=="object":s===typeof a)}function hu(a){var n={exports:{}};return a(n,n.exports),n.exports}var Cd=hu(function(a,n){var s={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 u(T){return(T=Math.round(T))<0?0:T>255?255:T}function p(T){return u(T[T.length-1]==="%"?parseFloat(T)/100*255:parseInt(T))}function g(T){return(D=T[T.length-1]==="%"?parseFloat(T)/100:parseFloat(T))<0?0:D>1?1:D;var D}function _(T,D,I){return I<0?I+=1:I>1&&(I-=1),6*I<1?T+(D-T)*I*6:2*I<1?D:3*I<2?T+(D-T)*(2/3-I)*6:T}try{n.parseCSSColor=function(T){var D,I=T.replace(/ /g,"").toLowerCase();if(I in s)return s[I].slice();if(I[0]==="#")return I.length===4?(D=parseInt(I.substr(1),16))>=0&&D<=4095?[(3840&D)>>4|(3840&D)>>8,240&D|(240&D)>>4,15&D|(15&D)<<4,1]:null:I.length===7&&(D=parseInt(I.substr(1),16))>=0&&D<=16777215?[(16711680&D)>>16,(65280&D)>>8,255&D,1]:null;var z=I.indexOf("("),B=I.indexOf(")");if(z!==-1&&B+1===I.length){var N=I.substr(0,z),W=I.substr(z+1,B-(z+1)).split(","),K=1;switch(N){case"rgba":if(W.length!==4)return null;K=g(W.pop());case"rgb":return W.length!==3?null:[p(W[0]),p(W[1]),p(W[2]),K];case"hsla":if(W.length!==4)return null;K=g(W.pop());case"hsl":if(W.length!==3)return null;var oe=(parseFloat(W[0])%360+360)%360/360,ue=g(W[1]),xe=g(W[2]),Be=xe<=.5?xe*(ue+1):xe+ue-xe*ue,$e=2*xe-Be;return[u(255*_($e,Be,oe+1/3)),u(255*_($e,Be,oe)),u(255*_($e,Be,oe-1/3)),K];default:return null}}return null}}catch(T){}});class Xn{constructor(n,s,u,p=1){this.r=n,this.g=s,this.b=u,this.a=p}static parse(n){if(!n)return;if(n instanceof Xn)return n;if(typeof n!="string")return;const s=Cd.parseCSSColor(n);return s?new Xn(s[0]/255*s[3],s[1]/255*s[3],s[2]/255*s[3],s[3]):void 0}toString(){const[n,s,u,p]=this.toArray();return`rgba(${Math.round(n)},${Math.round(s)},${Math.round(u)},${p})`}toArray(){const{r:n,g:s,b:u,a:p}=this;return p===0?[0,0,0,0]:[255*n/p,255*s/p,255*u/p,p]}}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 ws{constructor(n,s,u){this.sensitivity=n?s?"variant":"case":s?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(n,s){return this.collator.compare(n,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ad{constructor(n,s,u,p,g){this.text=n.normalize?n.normalize():n,this.image=s,this.scale=u,this.fontStack=p,this.textColor=g}}class Fi{constructor(n){this.sections=n}static fromString(n){return new Fi([new Ad(n,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(n=>n.text.length!==0||n.image&&n.image.name.length!==0)}static factory(n){return n instanceof Fi?n:Fi.fromString(n)}toString(){return this.sections.length===0?"":this.sections.map(n=>n.text).join("")}serialize(){const n=["format"];for(const s of this.sections){if(s.image){n.push(["image",s.image.name]);continue}n.push(s.text);const u={};s.fontStack&&(u["text-font"]=["literal",s.fontStack.split(",")]),s.scale&&(u["font-scale"]=s.scale),s.textColor&&(u["text-color"]=["rgba"].concat(s.textColor.toArray())),n.push(u)}return n}}class Pr{constructor(n){this.name=n.name,this.available=n.available}toString(){return this.name}static fromString(n){return n?new Pr({name:n,available:!1}):null}serialize(){return["image",this.name]}}function ho(a,n,s,u){return typeof a=="number"&&a>=0&&a<=255&&typeof n=="number"&&n>=0&&n<=255&&typeof s=="number"&&s>=0&&s<=255?u===void 0||typeof u=="number"&&u>=0&&u<=1?null:`Invalid rgba value [${[a,n,s,u].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof u=="number"?[a,n,s,u]:[a,n,s]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function du(a){if(a===null||typeof a=="string"||typeof a=="boolean"||typeof a=="number"||a instanceof Xn||a instanceof ws||a instanceof Fi||a instanceof Pr)return!0;if(Array.isArray(a)){for(const n of a)if(!du(n))return!1;return!0}if(typeof a=="object"){for(const n in a)if(!du(a[n]))return!1;return!0}return!1}function Pi(a){if(a===null)return Ln;if(typeof a=="string")return un;if(typeof a=="boolean")return Kt;if(typeof a=="number")return Mt;if(a instanceof Xn)return mn;if(a instanceof ws)return di;if(a instanceof Fi)return Dr;if(a instanceof Pr)return oi;if(Array.isArray(a)){const n=a.length;let s;for(const u of a){const p=Pi(u);if(s){if(s===p)continue;s=Cn;break}s=p}return li(s||Cn,n)}return Tn}function zo(a){const n=typeof a;return a===null?"":n==="string"||n==="number"||n==="boolean"?String(a):a instanceof Xn||a instanceof Fi||a instanceof Pr?a.toString():JSON.stringify(a)}class Fo{constructor(n,s){this.type=n,this.value=s}static parse(n,s){if(n.length!==2)return s.error(`'literal' expression requires exactly one argument, but found ${n.length-1} instead.`);if(!du(n[1]))return s.error("invalid value");const u=n[1];let p=Pi(u);const g=s.expectedType;return p.kind!=="array"||p.N!==0||!g||g.kind!=="array"||typeof g.N=="number"&&g.N!==0||(p=g),new Fo(p,u)}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 Fi?this.value.serialize():this.value}}class Qi{constructor(n){this.name="ExpressionEvaluationError",this.message=n}toJSON(){return this.message}}const Dd={string:un,number:Mt,boolean:Kt,object:Tn};class po{constructor(n,s){this.type=n,this.args=s}static parse(n,s){if(n.length<2)return s.error("Expected at least one argument.");let u,p=1;const g=n[0];if(g==="array"){let T,D;if(n.length>2){const I=n[1];if(typeof I!="string"||!(I in Dd)||I==="object")return s.error('The item type argument of "array" must be one of string, number, boolean',1);T=Dd[I],p++}else T=Cn;if(n.length>3){if(n[2]!==null&&(typeof n[2]!="number"||n[2]<0||n[2]!==Math.floor(n[2])))return s.error('The length argument to "array" must be a positive integer literal',2);D=n[2],p++}u=li(T,D)}else u=Dd[g];const _=[];for(;pn.outputDefined())}serialize(){const n=this.type,s=[n.kind];if(n.kind==="array"){const u=n.itemType;if(u.kind==="string"||u.kind==="number"||u.kind==="boolean"){s.push(u.kind);const p=n.N;(typeof p=="number"||this.args.length>1)&&s.push(p)}}return s.concat(this.args.map(u=>u.serialize()))}}class Ms{constructor(n){this.type=Dr,this.sections=n}static parse(n,s){if(n.length<2)return s.error("Expected at least one argument.");const u=n[1];if(!Array.isArray(u)&&typeof u=="object")return s.error("First argument must be an image or text section.");const p=[];let g=!1;for(let _=1;_<=n.length-1;++_){const T=n[_];if(g&&typeof T=="object"&&!Array.isArray(T)){g=!1;let D=null;if(T["font-scale"]&&(D=s.parse(T["font-scale"],1,Mt),!D))return null;let I=null;if(T["text-font"]&&(I=s.parse(T["text-font"],1,li(un)),!I))return null;let z=null;if(T["text-color"]&&(z=s.parse(T["text-color"],1,mn),!z))return null;const B=p[p.length-1];B.scale=D,B.font=I,B.textColor=z}else{const D=s.parse(n[_],1,Cn);if(!D)return null;const I=D.type.kind;if(I!=="string"&&I!=="value"&&I!=="null"&&I!=="resolvedImage")return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");g=!0,p.push({content:D,scale:null,font:null,textColor:null})}}return new Ms(p)}evaluate(n){return new Fi(this.sections.map(s=>{const u=s.content.evaluate(n);return Pi(u)===oi?new Ad("",u,null,null,null):new Ad(zo(u),null,s.scale?s.scale.evaluate(n):null,s.font?s.font.evaluate(n).join(","):null,s.textColor?s.textColor.evaluate(n):null)}))}eachChild(n){for(const s of this.sections)n(s.content),s.scale&&n(s.scale),s.font&&n(s.font),s.textColor&&n(s.textColor)}outputDefined(){return!1}serialize(){const n=["format"];for(const s of this.sections){n.push(s.content.serialize());const u={};s.scale&&(u["font-scale"]=s.scale.serialize()),s.font&&(u["text-font"]=s.font.serialize()),s.textColor&&(u["text-color"]=s.textColor.serialize()),n.push(u)}return n}}class Ts{constructor(n){this.type=oi,this.input=n}static parse(n,s){if(n.length!==2)return s.error("Expected two arguments.");const u=s.parse(n[1],1,un);return u?new Ts(u):s.error("No image name provided.")}evaluate(n){const s=this.input.evaluate(n),u=Pr.fromString(s);return u&&n.availableImages&&(u.available=n.availableImages.indexOf(s)>-1),u}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const $_={"to-boolean":Kt,"to-color":mn,"to-number":Mt,"to-string":un};class fo{constructor(n,s){this.type=n,this.args=s}static parse(n,s){if(n.length<2)return s.error("Expected at least one argument.");const u=n[0];if((u==="to-boolean"||u==="to-string")&&n.length!==2)return s.error("Expected one argument.");const p=$_[u],g=[];for(let _=1;_4?`Invalid rbga value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:ho(s[0],s[1],s[2],s[3]),!u))return new Xn(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new Qi(u||`Could not parse color from value '${typeof s=="string"?s:String(JSON.stringify(s))}'`)}if(this.type.kind==="number"){let s=null;for(const u of this.args){if(s=u.evaluate(n),s===null)return 0;const p=Number(s);if(!isNaN(p))return p}throw new Qi(`Could not convert ${JSON.stringify(s)} to number.`)}return this.type.kind==="formatted"?Fi.fromString(zo(this.args[0].evaluate(n))):this.type.kind==="resolvedImage"?Pr.fromString(zo(this.args[0].evaluate(n))):zo(this.args[0].evaluate(n))}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){if(this.type.kind==="formatted")return new Ms([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Ts(this.args[0]).serialize();const n=[`to-${this.type.kind}`];return this.eachChild(s=>{n.push(s.serialize())}),n}}const q_=["Unknown","Point","LineString","Polygon"];class Lm{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"?q_[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 n=this.featureDistanceData.center,s=this.featureDistanceData.scale,{x:u,y:p}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(u*s-n[0])+this.featureDistanceData.bearing[1]*(p*s-n[1])}return 0}parseColor(n){let s=this._parseColorCache[n];return s||(s=this._parseColorCache[n]=Xn.parse(n)),s}}class Sr{constructor(n,s,u,p){this.name=n,this.type=s,this._evaluate=u,this.args=p}evaluate(n){return this._evaluate(n,this.args)}eachChild(n){this.args.forEach(n)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(n=>n.serialize()))}static parse(n,s){const u=n[0],p=Sr.definitions[u];if(!p)return s.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);const g=Array.isArray(p)?p[0]:p.type,_=Array.isArray(p)?[[p[1],p[2]]]:p.overloads,T=_.filter(([I])=>!Array.isArray(I)||I.length===n.length-1);let D=null;for(const[I,z]of T){D=new oa(s.registry,s.path,null,s.scope);const B=[];let N=!1;for(let W=1;W{return N=B,Array.isArray(N)?`(${N.map(ai).join(", ")})`:`(${ai(N.type)}...)`;var N}).join(" | "),z=[];for(let B=1;B=n[2]||a[1]<=n[1]||a[3]>=n[3])}function Im(a,n){const s=(180+a[0])/360,u=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,p=Math.pow(2,n.z);return[Math.round(s*p*ra),Math.round(u*p*ra)]}function mu(a,n,s){const u=a[0]-n[0],p=a[1]-n[1],g=a[0]-s[0],_=a[1]-s[1];return u*_-g*p==0&&u*g<=0&&p*_<=0}function Sd(a,n){let s=!1;for(let _=0,T=n.length;_(u=a)[1]!=(g=D[I+1])[1]>u[1]&&u[0]<(g[0]-p[0])*(u[1]-p[1])/(g[1]-p[1])+p[0]&&(s=!s)}}var u,p,g;return s}function X_(a,n){for(let s=0;s0&&T<0||_<0&&T>0}function Z_(a,n,s){for(const I of s)for(let z=0;zs[2]){const p=.5*u;let g=a[0]-s[0]>p?-u:s[0]-a[0]>p?u:0;g===0&&(g=a[0]-s[2]>p?-u:s[2]-a[0]>p?u:0),a[0]+=g}Pd(n,a)}function Fm(a,n,s,u){const p=Math.pow(2,u.z)*ra,g=[u.x*ra,u.y*ra],_=[];if(!a)return _;for(const T of a)for(const D of T){const I=[D.x+g[0],D.y+g[1]];zm(I,n,s,p),_.push(I)}return _}function Bm(a,n,s,u){const p=Math.pow(2,u.z)*ra,g=[u.x*ra,u.y*ra],_=[];if(!a)return _;for(const D of a){const I=[];for(const z of D){const B=[z.x+g[0],z.y+g[1]];Pd(n,B),I.push(B)}_.push(I)}if(n[2]-n[0]<=p/2){(T=n)[0]=T[1]=1/0,T[2]=T[3]=-1/0;for(const D of _)for(const I of D)zm(I,n,s,p)}var T;return _}class Na{constructor(n,s){this.type=Kt,this.geojson=n,this.geometries=s}static parse(n,s){if(n.length!==2)return s.error(`'within' expression requires exactly one argument, but found ${n.length-1} instead.`);if(du(n[1])){const u=n[1];if(u.type==="FeatureCollection")for(let p=0;p{n&&!yr(s)&&(n=!1)}),n}function wl(a){if(a instanceof Sr&&a.name==="feature-state")return!1;let n=!0;return a.eachChild(s=>{n&&!wl(s)&&(n=!1)}),n}function Ml(a,n){if(a instanceof Sr&&n.indexOf(a.name)>=0)return!1;let s=!0;return a.eachChild(u=>{s&&!Ml(u,n)&&(s=!1)}),s}class Ua{constructor(n,s){this.type=s.type,this.name=n,this.boundExpression=s}static parse(n,s){if(n.length!==2||typeof n[1]!="string")return s.error("'var' expression requires exactly one string literal argument.");const u=n[1];return s.scope.has(u)?new Ua(u,s.scope.get(u)):s.error(`Unknown variable "${u}". Make sure "${u}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(n){return this.boundExpression.evaluate(n)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class oa{constructor(n,s=[],u,p=new Sn,g=[]){this.registry=n,this.path=s,this.key=s.map(_=>`[${_}]`).join(""),this.scope=p,this.errors=g,this.expectedType=u}parse(n,s,u,p,g={}){return s?this.concat(s,u,p)._parse(n,g):this._parse(n,g)}_parse(n,s){function u(p,g,_){return _==="assert"?new po(g,[p]):_==="coerce"?new fo(g,[p]):p}if(n!==null&&typeof n!="string"&&typeof n!="boolean"&&typeof n!="number"||(n=["literal",n]),Array.isArray(n)){if(n.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const p=n[0];if(typeof p!="string")return this.error(`Expression name must be a string, but found ${typeof p} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const g=this.registry[p];if(g){let _=g.parse(n,this);if(!_)return null;if(this.expectedType){const T=this.expectedType,D=_.type;if(T.kind!=="string"&&T.kind!=="number"&&T.kind!=="boolean"&&T.kind!=="object"&&T.kind!=="array"||D.kind!=="value")if(T.kind!=="color"&&T.kind!=="formatted"&&T.kind!=="resolvedImage"||D.kind!=="value"&&D.kind!=="string"){if(this.checkSubtype(T,D))return null}else _=u(_,T,s.typeAnnotation||"coerce");else _=u(_,T,s.typeAnnotation||"assert")}if(!(_ instanceof Fo)&&_.type.kind!=="resolvedImage"&&yu(_)){const T=new Lm;try{_=new Fo(_.type,_.evaluate(T))}catch(D){return this.error(D.message),null}}return _}return this.error(`Unknown expression "${p}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(n===void 0?"'undefined' value invalid. Use null instead.":typeof n=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof n} instead.`)}concat(n,s,u){const p=typeof n=="number"?this.path.concat(n):this.path,g=u?this.scope.concat(u):this.scope;return new oa(this.registry,p,s||null,g,this.errors)}error(n,...s){const u=`${this.key}${s.map(p=>`[${p}]`).join("")}`;this.errors.push(new rn(u,n))}checkSubtype(n,s){const u=ko(n,s);return u&&this.error(u),u}}function yu(a){if(a instanceof Ua)return yu(a.boundExpression);if(a instanceof Sr&&a.name==="error"||a instanceof pu||a instanceof Na)return!1;const n=a instanceof fo||a instanceof po;let s=!0;return a.eachChild(u=>{s=n?s&&yu(u):s&&u instanceof Fo}),!!s&&yr(a)&&Ml(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Tl(a,n){const s=a.length-1;let u,p,g=0,_=s,T=0;for(;g<=_;)if(T=Math.floor((g+_)/2),u=a[T],p=a[T+1],u<=n){if(T===s||nn))throw new Qi("Input is not a number.");_=T-1}return 0}class El{constructor(n,s,u){this.type=n,this.input=s,this.labels=[],this.outputs=[];for(const[p,g]of u)this.labels.push(p),this.outputs.push(g)}static parse(n,s){if(n.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return s.error("Expected an even number of arguments.");const u=s.parse(n[1],1,Mt);if(!u)return null;const p=[];let g=null;s.expectedType&&s.expectedType.kind!=="value"&&(g=s.expectedType);for(let _=1;_=T)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',I);const B=s.parse(D,z,g);if(!B)return null;g=g||B.type,p.push([T,B])}return new El(g,u,p)}evaluate(n){const s=this.labels,u=this.outputs;if(s.length===1)return u[0].evaluate(n);const p=this.input.evaluate(n);if(p<=s[0])return u[0].evaluate(n);const g=s.length;return p>=s[g-1]?u[g-1].evaluate(n):u[Tl(s,p)].evaluate(n)}eachChild(n){n(this.input);for(const s of this.outputs)n(s)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){const n=["step",this.input.serialize()];for(let s=0;s0&&n.push(this.labels[s]),n.push(this.outputs[s].serialize());return n}}function yn(a,n,s){return a*(1-s)+n*s}var _u=Object.freeze({__proto__:null,number:yn,color:function(a,n,s){return new Xn(yn(a.r,n.r,s),yn(a.g,n.g,s),yn(a.b,n.b,s),yn(a.a,n.a,s))},array:function(a,n,s){return a.map((u,p)=>yn(u,n[p],s))}});const Om=.95047,Nm=1.08883,Ld=4/29,Id=6/29,Rd=3*Id*Id,Um=Math.PI/180,Vm=180/Math.PI;function vu(a){return a>.008856451679035631?Math.pow(a,.3333333333333333):a/Rd+Ld}function aa(a){return a>Id?a*a*a:Rd*(a-Ld)}function Es(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,.4166666666666667)-.055)}function kd(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function xu(a){const n=kd(a.r),s=kd(a.g),u=kd(a.b),p=vu((.4124564*n+.3575761*s+.1804375*u)/Om),g=vu((.2126729*n+.7151522*s+.072175*u)/1);return{l:116*g-16,a:500*(p-g),b:200*(g-vu((.0193339*n+.119192*s+.9503041*u)/Nm)),alpha:a.a}}function zd(a){let n=(a.l+16)/116,s=isNaN(a.a)?n:n+a.a/500,u=isNaN(a.b)?n:n-a.b/200;return n=1*aa(n),s=Om*aa(s),u=Nm*aa(u),new Xn(Es(3.2404542*s-1.5371385*n-.4985314*u),Es(-.969266*s+1.8760108*n+.041556*u),Es(.0556434*s-.2040259*n+1.0572252*u),a.alpha)}function K_(a,n,s){const u=n-a;return a+s*(u>180||u<-180?u-360*Math.round(u/360):u)}const Cl={forward:xu,reverse:zd,interpolate:function(a,n,s){return{l:yn(a.l,n.l,s),a:yn(a.a,n.a,s),b:yn(a.b,n.b,s),alpha:yn(a.alpha,n.alpha,s)}}},Al={forward:function(a){const{l:n,a:s,b:u}=xu(a),p=Math.atan2(u,s)*Vm;return{h:p<0?p+360:p,c:Math.sqrt(s*s+u*u),l:n,alpha:a.a}},reverse:function(a){const n=a.h*Um,s=a.c;return zd({l:a.l,a:Math.cos(n)*s,b:Math.sin(n)*s,alpha:a.alpha})},interpolate:function(a,n,s){return{h:K_(a.h,n.h,s),c:yn(a.c,n.c,s),l:yn(a.l,n.l,s),alpha:yn(a.alpha,n.alpha,s)}}};var Fd=Object.freeze({__proto__:null,lab:Cl,hcl:Al});class Lr{constructor(n,s,u,p,g){this.type=n,this.operator=s,this.interpolation=u,this.input=p,this.labels=[],this.outputs=[];for(const[_,T]of g)this.labels.push(_),this.outputs.push(T)}static interpolationFactor(n,s,u,p){let g=0;if(n.name==="exponential")g=bu(s,n.base,u,p);else if(n.name==="linear")g=bu(s,1,u,p);else if(n.name==="cubic-bezier"){const _=n.controlPoints;g=new x(_[0],_[1],_[2],_[3]).solve(bu(s,1,u,p))}return g}static parse(n,s){let[u,p,g,..._]=n;if(!Array.isArray(p)||p.length===0)return s.error("Expected an interpolation type expression.",1);if(p[0]==="linear")p={name:"linear"};else if(p[0]==="exponential"){const I=p[1];if(typeof I!="number")return s.error("Exponential interpolation requires a numeric base.",1,1);p={name:"exponential",base:I}}else{if(p[0]!=="cubic-bezier")return s.error(`Unknown interpolation type ${String(p[0])}`,1,0);{const I=p.slice(1);if(I.length!==4||I.some(z=>typeof z!="number"||z<0||z>1))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);p={name:"cubic-bezier",controlPoints:I}}}if(n.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(g=s.parse(g,2,Mt),!g)return null;const T=[];let D=null;u==="interpolate-hcl"||u==="interpolate-lab"?D=mn:s.expectedType&&s.expectedType.kind!=="value"&&(D=s.expectedType);for(let I=0;I<_.length;I+=2){const z=_[I],B=_[I+1],N=I+3,W=I+4;if(typeof z!="number")return s.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',N);if(T.length&&T[T.length-1][0]>=z)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',N);const K=s.parse(B,W,D);if(!K)return null;D=D||K.type,T.push([z,K])}return D.kind==="number"||D.kind==="color"||D.kind==="array"&&D.itemType.kind==="number"&&typeof D.N=="number"?new Lr(D,u,p,g,T):s.error(`Type ${ai(D)} is not interpolatable.`)}evaluate(n){const s=this.labels,u=this.outputs;if(s.length===1)return u[0].evaluate(n);const p=this.input.evaluate(n);if(p<=s[0])return u[0].evaluate(n);const g=s.length;if(p>=s[g-1])return u[g-1].evaluate(n);const _=Tl(s,p),T=Lr.interpolationFactor(this.interpolation,p,s[_],s[_+1]),D=u[_].evaluate(n),I=u[_+1].evaluate(n);return this.operator==="interpolate"?_u[this.type.kind.toLowerCase()](D,I,T):this.operator==="interpolate-hcl"?Al.reverse(Al.interpolate(Al.forward(D),Al.forward(I),T)):Cl.reverse(Cl.interpolate(Cl.forward(D),Cl.forward(I),T))}eachChild(n){n(this.input);for(const s of this.outputs)n(s)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){let n;n=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 s=[this.operator,n,this.input.serialize()];for(let u=0;uko(p,T.type));return new Dl(_?Cn:u,g)}evaluate(n){let s,u=null,p=0;for(const g of this.args){if(p++,u=g.evaluate(n),u&&u instanceof Pr&&!u.available&&(s||(s=u),u=null,p===this.args.length))return s;if(u!==null)break}return u}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){const n=["coalesce"];return this.eachChild(s=>{n.push(s.serialize())}),n}}class Pl{constructor(n,s){this.type=s.type,this.bindings=[].concat(n),this.result=s}evaluate(n){return this.result.evaluate(n)}eachChild(n){for(const s of this.bindings)n(s[1]);n(this.result)}static parse(n,s){if(n.length<4)return s.error(`Expected at least 3 arguments, but found ${n.length-1} instead.`);const u=[];for(let g=1;g=u.length)throw new Qi(`Array index out of bounds: ${s} > ${u.length-1}.`);if(s!==Math.floor(s))throw new Qi(`Array index must be an integer, but found ${s} instead.`);return u[s]}eachChild(n){n(this.index),n(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class wu{constructor(n,s){this.type=Kt,this.needle=n,this.haystack=s}static parse(n,s){if(n.length!==3)return s.error(`Expected 2 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Cn),p=s.parse(n[2],2,Cn);return u&&p?uu(u.type,[Kt,un,Mt,Ln,Cn])?new wu(u,p):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${ai(u.type)} instead`):null}evaluate(n){const s=this.needle.evaluate(n),u=this.haystack.evaluate(n);if(u==null)return!1;if(!bs(s,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${ai(Pi(s))} instead.`);if(!bs(u,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${ai(Pi(u))} instead.`);return u.indexOf(s)>=0}eachChild(n){n(this.needle),n(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Mu{constructor(n,s,u){this.type=Mt,this.needle=n,this.haystack=s,this.fromIndex=u}static parse(n,s){if(n.length<=2||n.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Cn),p=s.parse(n[2],2,Cn);if(!u||!p)return null;if(!uu(u.type,[Kt,un,Mt,Ln,Cn]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${ai(u.type)} instead`);if(n.length===4){const g=s.parse(n[3],3,Mt);return g?new Mu(u,p,g):null}return new Mu(u,p)}evaluate(n){const s=this.needle.evaluate(n),u=this.haystack.evaluate(n);if(!bs(s,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${ai(Pi(s))} instead.`);if(!bs(u,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${ai(Pi(u))} instead.`);if(this.fromIndex){const p=this.fromIndex.evaluate(n);return u.indexOf(s,p)}return u.indexOf(s)}eachChild(n){n(this.needle),n(this.haystack),this.fromIndex&&n(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const n=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),n]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Tu{constructor(n,s,u,p,g,_){this.inputType=n,this.type=s,this.input=u,this.cases=p,this.outputs=g,this.otherwise=_}static parse(n,s){if(n.length<5)return s.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if(n.length%2!=1)return s.error("Expected an even number of arguments.");let u,p;s.expectedType&&s.expectedType.kind!=="value"&&(p=s.expectedType);const g={},_=[];for(let I=2;INumber.MAX_SAFE_INTEGER)return N.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof K=="number"&&Math.floor(K)!==K)return N.error("Numeric branch labels must be integer values.");if(u){if(N.checkSubtype(u,Pi(K)))return null}else u=Pi(K);if(g[String(K)]!==void 0)return N.error("Branch labels must be unique.");g[String(K)]=_.length}const W=s.parse(B,I,p);if(!W)return null;p=p||W.type,_.push(W)}const T=s.parse(n[1],1,Cn);if(!T)return null;const D=s.parse(n[n.length-1],n.length-1,p);return D?T.type.kind!=="value"&&s.concat(1).checkSubtype(u,T.type)?null:new Tu(u,p,T,g,_,D):null}evaluate(n){const s=this.input.evaluate(n);return(Pi(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(n)}eachChild(n){n(this.input),this.outputs.forEach(n),n(this.otherwise)}outputDefined(){return this.outputs.every(n=>n.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["match",this.input.serialize()],s=Object.keys(this.cases).sort(),u=[],p={};for(const _ of s){const T=p[this.cases[_]];T===void 0?(p[this.cases[_]]=u.length,u.push([this.cases[_],[_]])):u[T][1].push(_)}const g=_=>this.inputType.kind==="number"?Number(_):_;for(const[_,T]of u)n.push(T.length===1?g(T[0]):T.map(g)),n.push(this.outputs[_].serialize());return n.push(this.otherwise.serialize()),n}}class Eu{constructor(n,s,u){this.type=n,this.branches=s,this.otherwise=u}static parse(n,s){if(n.length<4)return s.error(`Expected at least 3 arguments, but found only ${n.length-1}.`);if(n.length%2!=0)return s.error("Expected an odd number of arguments.");let u;s.expectedType&&s.expectedType.kind!=="value"&&(u=s.expectedType);const p=[];for(let _=1;_s.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["case"];return this.eachChild(s=>{n.push(s.serialize())}),n}}class Cu{constructor(n,s,u,p){this.type=n,this.input=s,this.beginIndex=u,this.endIndex=p}static parse(n,s){if(n.length<=2||n.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const u=s.parse(n[1],1,Cn),p=s.parse(n[2],2,Mt);if(!u||!p)return null;if(!uu(u.type,[li(Cn),un,Cn]))return s.error(`Expected first argument to be of type array or string, but found ${ai(u.type)} instead`);if(n.length===4){const g=s.parse(n[3],3,Mt);return g?new Cu(u.type,u,p,g):null}return new Cu(u.type,u,p)}evaluate(n){const s=this.input.evaluate(n),u=this.beginIndex.evaluate(n);if(!bs(s,["string","array"]))throw new Qi(`Expected first argument to be of type array or string, but found ${ai(Pi(s))} instead.`);if(this.endIndex){const p=this.endIndex.evaluate(n);return s.slice(u,p)}return s.slice(u)}eachChild(n){n(this.input),n(this.beginIndex),this.endIndex&&n(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const n=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),n]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Gm(a,n){return a==="=="||a==="!="?n.kind==="boolean"||n.kind==="string"||n.kind==="number"||n.kind==="null"||n.kind==="value":n.kind==="string"||n.kind==="number"||n.kind==="value"}function Wm(a,n,s,u){return u.compare(n,s)===0}function Cs(a,n,s){const u=a!=="=="&&a!=="!=";return class AM{constructor(g,_,T){this.type=Kt,this.lhs=g,this.rhs=_,this.collator=T,this.hasUntypedArgument=g.type.kind==="value"||_.type.kind==="value"}static parse(g,_){if(g.length!==3&&g.length!==4)return _.error("Expected two or three arguments.");const T=g[0];let D=_.parse(g[1],1,Cn);if(!D)return null;if(!Gm(T,D.type))return _.concat(1).error(`"${T}" comparisons are not supported for type '${ai(D.type)}'.`);let I=_.parse(g[2],2,Cn);if(!I)return null;if(!Gm(T,I.type))return _.concat(2).error(`"${T}" comparisons are not supported for type '${ai(I.type)}'.`);if(D.type.kind!==I.type.kind&&D.type.kind!=="value"&&I.type.kind!=="value")return _.error(`Cannot compare types '${ai(D.type)}' and '${ai(I.type)}'.`);u&&(D.type.kind==="value"&&I.type.kind!=="value"?D=new po(I.type,[D]):D.type.kind!=="value"&&I.type.kind==="value"&&(I=new po(D.type,[I])));let z=null;if(g.length===4){if(D.type.kind!=="string"&&I.type.kind!=="string"&&D.type.kind!=="value"&&I.type.kind!=="value")return _.error("Cannot use collator to compare non-string types.");if(z=_.parse(g[3],3,di),!z)return null}return new AM(D,I,z)}evaluate(g){const _=this.lhs.evaluate(g),T=this.rhs.evaluate(g);if(u&&this.hasUntypedArgument){const D=Pi(_),I=Pi(T);if(D.kind!==I.kind||D.kind!=="string"&&D.kind!=="number")throw new Qi(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${D.kind}, ${I.kind}) instead.`)}if(this.collator&&!u&&this.hasUntypedArgument){const D=Pi(_),I=Pi(T);if(D.kind!=="string"||I.kind!=="string")return n(g,_,T)}return this.collator?s(g,_,T,this.collator.evaluate(g)):n(g,_,T)}eachChild(g){g(this.lhs),g(this.rhs),this.collator&&g(this.collator)}outputDefined(){return!0}serialize(){const g=[a];return this.eachChild(_=>{g.push(_.serialize())}),g}}}const J_=Cs("==",function(a,n,s){return n===s},Wm),Q_=Cs("!=",function(a,n,s){return n!==s},function(a,n,s,u){return!Wm(0,n,s,u)}),jm=Cs("<",function(a,n,s){return n",function(a,n,s){return n>s},function(a,n,s,u){return u.compare(n,s)>0}),tv=Cs("<=",function(a,n,s){return n<=s},function(a,n,s,u){return u.compare(n,s)<=0}),nv=Cs(">=",function(a,n,s){return n>=s},function(a,n,s,u){return u.compare(n,s)>=0});class Od{constructor(n,s,u,p,g){this.type=un,this.number=n,this.locale=s,this.currency=u,this.minFractionDigits=p,this.maxFractionDigits=g}static parse(n,s){if(n.length!==3)return s.error("Expected two arguments.");const u=s.parse(n[1],1,Mt);if(!u)return null;const p=n[2];if(typeof p!="object"||Array.isArray(p))return s.error("NumberFormat options argument must be an object.");let g=null;if(p.locale&&(g=s.parse(p.locale,1,un),!g))return null;let _=null;if(p.currency&&(_=s.parse(p.currency,1,un),!_))return null;let T=null;if(p["min-fraction-digits"]&&(T=s.parse(p["min-fraction-digits"],1,Mt),!T))return null;let D=null;return p["max-fraction-digits"]&&(D=s.parse(p["max-fraction-digits"],1,Mt),!D)?null:new Od(u,g,_,T,D)}evaluate(n){return new Intl.NumberFormat(this.locale?this.locale.evaluate(n):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(n):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(n):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(n):void 0}).format(this.number.evaluate(n))}eachChild(n){n(this.number),this.locale&&n(this.locale),this.currency&&n(this.currency),this.minFractionDigits&&n(this.minFractionDigits),this.maxFractionDigits&&n(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const n={};return this.locale&&(n.locale=this.locale.serialize()),this.currency&&(n.currency=this.currency.serialize()),this.minFractionDigits&&(n["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(n["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),n]}}class Au{constructor(n){this.type=Mt,this.input=n}static parse(n,s){if(n.length!==2)return s.error(`Expected 1 argument, but found ${n.length-1} instead.`);const u=s.parse(n[1],1);return u?u.type.kind!=="array"&&u.type.kind!=="string"&&u.type.kind!=="value"?s.error(`Expected argument of type string or array, but found ${ai(u.type)} instead.`):new Au(u):null}evaluate(n){const s=this.input.evaluate(n);if(typeof s=="string"||Array.isArray(s))return s.length;throw new Qi(`Expected value to be of type string or array, but found ${ai(Pi(s))} instead.`)}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){const n=["length"];return this.eachChild(s=>{n.push(s.serialize())}),n}}const Va={"==":J_,"!=":Q_,">":ev,"<":jm,">=":nv,"<=":tv,array:po,at:Bd,boolean:po,case:Eu,coalesce:Dl,collator:pu,format:Ms,image:Ts,in:wu,"index-of":Mu,interpolate:Lr,"interpolate-hcl":Lr,"interpolate-lab":Lr,length:Au,let:Pl,literal:Fo,match:Tu,number:po,"number-format":Od,object:po,slice:Cu,step:El,string:po,"to-boolean":fo,"to-color":fo,"to-number":fo,"to-string":fo,var:Ua,within:Na};function Nd(a,[n,s,u,p]){n=n.evaluate(a),s=s.evaluate(a),u=u.evaluate(a);const g=p?p.evaluate(a):1,_=ho(n,s,u,g);if(_)throw new Qi(_);return new Xn(n/255*g,s/255*g,u/255*g,g)}function Hm(a,n){return a in n}function Ud(a,n){const s=n[a];return s===void 0?null:s}function sa(a){return{type:a}}function Vd(a){return{result:"success",value:a}}function Ga(a){return{result:"error",value:a}}function As(a){return a["property-type"]==="data-driven"||a["property-type"]==="cross-faded-data-driven"}function $m(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")>-1}function Gd(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 Wa(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function qm(a){return a}function Wd(a,n){const s=n.type==="color",u=a.stops&&typeof a.stops[0][0]=="object",p=u||!(u||a.property!==void 0),g=a.type||(Gd(n)?"exponential":"interval");if(s&&((a=Tt({},a)).stops&&(a.stops=a.stops.map(I=>[I[0],Xn.parse(I[1])])),a.default=Xn.parse(a.default?a.default:n.default)),a.colorSpace&&a.colorSpace!=="rgb"&&!Fd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let _,T,D;if(g==="exponential")_=jd;else if(g==="interval")_=rv;else if(g==="categorical"){_=iv,T=Object.create(null);for(const I of a.stops)T[I[0]]=I[1];D=typeof a.stops[0][0]}else{if(g!=="identity")throw new Error(`Unknown function type "${g}"`);_=Xm}if(u){const I={},z=[];for(let W=0;WW[0]),evaluate:({zoom:W},K)=>jd({stops:B,base:a.base},n,W).evaluate(W,K)}}if(p){const I=g==="exponential"?{name:"exponential",base:a.base!==void 0?a.base:1}:null;return{kind:"camera",interpolationType:I,interpolationFactor:Lr.interpolationFactor.bind(void 0,I),zoomStops:a.stops.map(z=>z[0]),evaluate:({zoom:z})=>_(a,n,z,T,D)}}return{kind:"source",evaluate(I,z){const B=z&&z.properties?z.properties[a.property]:void 0;return B===void 0?Sl(a.default,n.default):_(a,n,B,T,D)}}}function Sl(a,n,s){return a!==void 0?a:n!==void 0?n:s!==void 0?s:void 0}function iv(a,n,s,u,p){return Sl(typeof s===p?u[s]:void 0,a.default,n.default)}function rv(a,n,s){if(Qn(s)!=="number")return Sl(a.default,n.default);const u=a.stops.length;if(u===1||s<=a.stops[0][0])return a.stops[0][1];if(s>=a.stops[u-1][0])return a.stops[u-1][1];const p=Tl(a.stops.map(g=>g[0]),s);return a.stops[p][1]}function jd(a,n,s){const u=a.base!==void 0?a.base:1;if(Qn(s)!=="number")return Sl(a.default,n.default);const p=a.stops.length;if(p===1||s<=a.stops[0][0])return a.stops[0][1];if(s>=a.stops[p-1][0])return a.stops[p-1][1];const g=Tl(a.stops.map(z=>z[0]),s),_=function(z,B,N,W){const K=W-N,oe=z-N;return K===0?0:B===1?oe/K:(Math.pow(B,oe)-1)/(Math.pow(B,K)-1)}(s,u,a.stops[g][0],a.stops[g+1][0]),T=a.stops[g][1],D=a.stops[g+1][1];let I=_u[n.type]||qm;if(a.colorSpace&&a.colorSpace!=="rgb"){const z=Fd[a.colorSpace];I=(B,N)=>z.reverse(z.interpolate(z.forward(B),z.forward(N),_))}return typeof T.evaluate=="function"?{evaluate(...z){const B=T.evaluate.apply(void 0,z),N=D.evaluate.apply(void 0,z);if(B!==void 0&&N!==void 0)return I(B,N,_)}}:I(T,D,_)}function Xm(a,n,s){return n.type==="color"?s=Xn.parse(s):n.type==="formatted"?s=Fi.fromString(s.toString()):n.type==="resolvedImage"?s=Pr.fromString(s.toString()):Qn(s)===n.type||n.type==="enum"&&n.values[s]||(s=void 0),Sl(s,a.default,n.default)}Sr.register(Va,{error:[{kind:"error"},[un],(a,[n])=>{throw new Qi(n.evaluate(a))}],typeof:[un,[Cn],(a,[n])=>ai(Pi(n.evaluate(a)))],"to-rgba":[li(Mt,4),[mn],(a,[n])=>n.evaluate(a).toArray()],rgb:[mn,[Mt,Mt,Mt],Nd],rgba:[mn,[Mt,Mt,Mt,Mt],Nd],has:{type:Kt,overloads:[[[un],(a,[n])=>Hm(n.evaluate(a),a.properties())],[[un,Tn],(a,[n,s])=>Hm(n.evaluate(a),s.evaluate(a))]]},get:{type:Cn,overloads:[[[un],(a,[n])=>Ud(n.evaluate(a),a.properties())],[[un,Tn],(a,[n,s])=>Ud(n.evaluate(a),s.evaluate(a))]]},"feature-state":[Cn,[un],(a,[n])=>Ud(n.evaluate(a),a.featureState||{})],properties:[Tn,[],a=>a.properties()],"geometry-type":[un,[],a=>a.geometryType()],id:[Cn,[],a=>a.id()],zoom:[Mt,[],a=>a.globals.zoom],pitch:[Mt,[],a=>a.globals.pitch||0],"distance-from-center":[Mt,[],a=>a.distanceFromCenter()],"heatmap-density":[Mt,[],a=>a.globals.heatmapDensity||0],"line-progress":[Mt,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[Mt,[],a=>a.globals.skyRadialProgress||0],accumulated:[Cn,[],a=>a.globals.accumulated===void 0?null:a.globals.accumulated],"+":[Mt,sa(Mt),(a,n)=>{let s=0;for(const u of n)s+=u.evaluate(a);return s}],"*":[Mt,sa(Mt),(a,n)=>{let s=1;for(const u of n)s*=u.evaluate(a);return s}],"-":{type:Mt,overloads:[[[Mt,Mt],(a,[n,s])=>n.evaluate(a)-s.evaluate(a)],[[Mt],(a,[n])=>-n.evaluate(a)]]},"/":[Mt,[Mt,Mt],(a,[n,s])=>n.evaluate(a)/s.evaluate(a)],"%":[Mt,[Mt,Mt],(a,[n,s])=>n.evaluate(a)%s.evaluate(a)],ln2:[Mt,[],()=>Math.LN2],pi:[Mt,[],()=>Math.PI],e:[Mt,[],()=>Math.E],"^":[Mt,[Mt,Mt],(a,[n,s])=>Math.pow(n.evaluate(a),s.evaluate(a))],sqrt:[Mt,[Mt],(a,[n])=>Math.sqrt(n.evaluate(a))],log10:[Mt,[Mt],(a,[n])=>Math.log(n.evaluate(a))/Math.LN10],ln:[Mt,[Mt],(a,[n])=>Math.log(n.evaluate(a))],log2:[Mt,[Mt],(a,[n])=>Math.log(n.evaluate(a))/Math.LN2],sin:[Mt,[Mt],(a,[n])=>Math.sin(n.evaluate(a))],cos:[Mt,[Mt],(a,[n])=>Math.cos(n.evaluate(a))],tan:[Mt,[Mt],(a,[n])=>Math.tan(n.evaluate(a))],asin:[Mt,[Mt],(a,[n])=>Math.asin(n.evaluate(a))],acos:[Mt,[Mt],(a,[n])=>Math.acos(n.evaluate(a))],atan:[Mt,[Mt],(a,[n])=>Math.atan(n.evaluate(a))],min:[Mt,sa(Mt),(a,n)=>Math.min(...n.map(s=>s.evaluate(a)))],max:[Mt,sa(Mt),(a,n)=>Math.max(...n.map(s=>s.evaluate(a)))],abs:[Mt,[Mt],(a,[n])=>Math.abs(n.evaluate(a))],round:[Mt,[Mt],(a,[n])=>{const s=n.evaluate(a);return s<0?-Math.round(-s):Math.round(s)}],floor:[Mt,[Mt],(a,[n])=>Math.floor(n.evaluate(a))],ceil:[Mt,[Mt],(a,[n])=>Math.ceil(n.evaluate(a))],"filter-==":[Kt,[un,Cn],(a,[n,s])=>a.properties()[n.value]===s.value],"filter-id-==":[Kt,[Cn],(a,[n])=>a.id()===n.value],"filter-type-==":[Kt,[un],(a,[n])=>a.geometryType()===n.value],"filter-<":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u{const s=a.id(),u=n.value;return typeof s==typeof u&&s":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u>p}],"filter-id->":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s>u}],"filter-<=":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u<=p}],"filter-id-<=":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s<=u}],"filter->=":[Kt,[un,Cn],(a,[n,s])=>{const u=a.properties()[n.value],p=s.value;return typeof u==typeof p&&u>=p}],"filter-id->=":[Kt,[Cn],(a,[n])=>{const s=a.id(),u=n.value;return typeof s==typeof u&&s>=u}],"filter-has":[Kt,[Cn],(a,[n])=>n.value in a.properties()],"filter-has-id":[Kt,[],a=>a.id()!==null&&a.id()!==void 0],"filter-type-in":[Kt,[li(un)],(a,[n])=>n.value.indexOf(a.geometryType())>=0],"filter-id-in":[Kt,[li(Cn)],(a,[n])=>n.value.indexOf(a.id())>=0],"filter-in-small":[Kt,[un,li(Cn)],(a,[n,s])=>s.value.indexOf(a.properties()[n.value])>=0],"filter-in-large":[Kt,[un,li(Cn)],(a,[n,s])=>function(u,p,g,_){for(;g<=_;){const T=g+_>>1;if(p[T]===u)return!0;p[T]>u?_=T-1:g=T+1}return!1}(a.properties()[n.value],s.value,0,s.value.length-1)],all:{type:Kt,overloads:[[[Kt,Kt],(a,[n,s])=>n.evaluate(a)&&s.evaluate(a)],[sa(Kt),(a,n)=>{for(const s of n)if(!s.evaluate(a))return!1;return!0}]]},any:{type:Kt,overloads:[[[Kt,Kt],(a,[n,s])=>n.evaluate(a)||s.evaluate(a)],[sa(Kt),(a,n)=>{for(const s of n)if(s.evaluate(a))return!0;return!1}]]},"!":[Kt,[Kt],(a,[n])=>!n.evaluate(a)],"is-supported-script":[Kt,[un],(a,[n])=>{const s=a.globals&&a.globals.isSupportedScript;return!s||s(n.evaluate(a))}],upcase:[un,[un],(a,[n])=>n.evaluate(a).toUpperCase()],downcase:[un,[un],(a,[n])=>n.evaluate(a).toLowerCase()],concat:[un,sa(Cn),(a,n)=>n.map(s=>zo(s.evaluate(a))).join("")],"resolved-locale":[un,[di],(a,[n])=>n.evaluate(a).resolvedLocale()]});class Du{constructor(n,s){this.expression=n,this._warningHistory={},this._evaluator=new Lm,this._defaultValue=s?function(u){return u.type==="color"&&Wa(u.default)?new Xn(0,0,0,0):u.type==="color"?Xn.parse(u.default)||null:u.default===void 0?null:u.default}(s):null,this._enumValues=s&&s.type==="enum"?s.values:null}evaluateWithoutErrorHandling(n,s,u,p,g,_,T,D){return this._evaluator.globals=n,this._evaluator.feature=s,this._evaluator.featureState=u,this._evaluator.canonical=p||null,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=_,this._evaluator.featureTileCoord=T||null,this._evaluator.featureDistanceData=D||null,this.expression.evaluate(this._evaluator)}evaluate(n,s,u,p,g,_,T,D){this._evaluator.globals=n,this._evaluator.feature=s||null,this._evaluator.featureState=u||null,this._evaluator.canonical=p||null,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=_||null,this._evaluator.featureTileCoord=T||null,this._evaluator.featureDistanceData=D||null;try{const I=this.expression.evaluate(this._evaluator);if(I==null||typeof I=="number"&&I!=I)return this._defaultValue;if(this._enumValues&&!(I in this._enumValues))throw new Qi(`Expected value to be one of ${Object.keys(this._enumValues).map(z=>JSON.stringify(z)).join(", ")}, but found ${JSON.stringify(I)} instead.`);return I}catch(I){return this._warningHistory[I.message]||(this._warningHistory[I.message]=!0,typeof console!="undefined"&&console.warn(I.message)),this._defaultValue}}}function Ds(a){return Array.isArray(a)&&a.length>0&&typeof a[0]=="string"&&a[0]in Va}function Ll(a,n){const s=new oa(Va,[],n?function(p){const g={color:mn,string:un,number:Mt,enum:un,boolean:Kt,formatted:Dr,resolvedImage:oi};return p.type==="array"?li(g[p.value]||Cn,p.length):g[p.type]}(n):void 0),u=s.parse(a,void 0,void 0,void 0,n&&n.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?Vd(new Du(u,n)):Ga(s.errors)}class Hd{constructor(n,s){this.kind=n,this._styleExpression=s,this.isStateDependent=n!=="constant"&&!wl(s.expression)}evaluateWithoutErrorHandling(n,s,u,p,g,_){return this._styleExpression.evaluateWithoutErrorHandling(n,s,u,p,g,_)}evaluate(n,s,u,p,g,_){return this._styleExpression.evaluate(n,s,u,p,g,_)}}class $d{constructor(n,s,u,p){this.kind=n,this.zoomStops=u,this._styleExpression=s,this.isStateDependent=n!=="camera"&&!wl(s.expression),this.interpolationType=p}evaluateWithoutErrorHandling(n,s,u,p,g,_){return this._styleExpression.evaluateWithoutErrorHandling(n,s,u,p,g,_)}evaluate(n,s,u,p,g,_){return this._styleExpression.evaluate(n,s,u,p,g,_)}interpolationFactor(n,s,u){return this.interpolationType?Lr.interpolationFactor(this.interpolationType,n,s,u):0}}function Zm(a,n){if((a=Ll(a,n)).result==="error")return a;const s=a.value.expression,u=yr(s);if(!u&&!As(n))return Ga([new rn("","data expressions not supported")]);const p=Ml(s,["zoom","pitch","distance-from-center"]);if(!p&&!$m(n))return Ga([new rn("","zoom expressions not supported")]);const g=Su(s);return g||p?g instanceof rn?Ga([g]):g instanceof Lr&&!Gd(n)?Ga([new rn("",'"interpolate" expressions cannot be used with this property')]):Vd(g?new $d(u?"camera":"composite",a.value,g.labels,g instanceof Lr?g.interpolation:void 0):new Hd(u?"constant":"source",a.value)):Ga([new rn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Pu{constructor(n,s){this._parameters=n,this._specification=s,Tt(this,Wd(this._parameters,this._specification))}static deserialize(n){return new Pu(n._parameters,n._specification)}static serialize(n){return{_parameters:n._parameters,_specification:n._specification}}}function Su(a){let n=null;if(a instanceof Pl)n=Su(a.result);else if(a instanceof Dl){for(const s of a.args)if(n=Su(s),n)break}else(a instanceof El||a instanceof Lr)&&a.input instanceof Sr&&a.input.name==="zoom"&&(n=a);return n instanceof rn||a.eachChild(s=>{const u=Su(s);u instanceof rn?n=u:!n&&u?n=new rn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&u&&n!==u&&(n=new rn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}class jt{constructor(n,s,u,p){this.message=(n?`${n}: `:"")+u,p&&(this.identifier=p),s!=null&&s.__line__&&(this.line=s.__line__)}}function $r(a){const n=a.key,s=a.value,u=a.valueSpec||{},p=a.objectElementValidators||{},g=a.style,_=a.styleSpec;let T=[];const D=Qn(s);if(D!=="object")return[new jt(n,s,`object expected, ${D} found`)];for(const I in s){const z=I.split(".")[0],B=u[z]||u["*"];let N;p[z]?N=p[z]:u[z]?N=Hi:p["*"]?N=p["*"]:u["*"]&&(N=Hi),N?T=T.concat(N({key:(n&&`${n}.`)+I,value:s[I],valueSpec:B,style:g,styleSpec:_,object:s,objectKey:I},s)):T.push(new jt(n,s[I],`unknown property "${I}"`))}for(const I in u)p[I]||u[I].required&&u[I].default===void 0&&s[I]===void 0&&T.push(new jt(n,s,`missing required property "${I}"`));return T}function Il(a){const n=a.value,s=a.valueSpec,u=a.style,p=a.styleSpec,g=a.key,_=a.arrayElementValidator||Hi;if(Qn(n)!=="array")return[new jt(g,n,`array expected, ${Qn(n)} found`)];if(s.length&&n.length!==s.length)return[new jt(g,n,`array length ${s.length} expected, length ${n.length} found`)];if(s["min-length"]&&n.lengthg)return[new jt(n,s,`${s} is greater than the maximum value ${g}`)]}return[]}function Km(a){const n=a.valueSpec,s=_t(a.value.type);let u,p,g,_={};const T=s!=="categorical"&&a.value.property===void 0,D=!T,I=Qn(a.value.stops)==="array"&&Qn(a.value.stops[0])==="array"&&Qn(a.value.stops[0][0])==="object",z=$r({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(W){if(s==="identity")return[new jt(W.key,W.value,'identity function may not have a "stops" property')];let K=[];const oe=W.value;return K=K.concat(Il({key:W.key,value:oe,valueSpec:W.valueSpec,style:W.style,styleSpec:W.styleSpec,arrayElementValidator:B})),Qn(oe)==="array"&&oe.length===0&&K.push(new jt(W.key,oe,"array must have at least one stop")),K},default:function(W){return Hi({key:W.key,value:W.value,valueSpec:n,style:W.style,styleSpec:W.styleSpec})}}});return s==="identity"&&T&&z.push(new jt(a.key,a.value,'missing required property "property"')),s==="identity"||a.value.stops||z.push(new jt(a.key,a.value,'missing required property "stops"')),s==="exponential"&&a.valueSpec.expression&&!Gd(a.valueSpec)&&z.push(new jt(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(D&&!As(a.valueSpec)?z.push(new jt(a.key,a.value,"property functions not supported")):T&&!$m(a.valueSpec)&&z.push(new jt(a.key,a.value,"zoom functions not supported"))),s!=="categorical"&&!I||a.value.property!==void 0||z.push(new jt(a.key,a.value,'"property" property is required')),z;function B(W){let K=[];const oe=W.value,ue=W.key;if(Qn(oe)!=="array")return[new jt(ue,oe,`array expected, ${Qn(oe)} found`)];if(oe.length!==2)return[new jt(ue,oe,`array length 2 expected, length ${oe.length} found`)];if(I){if(Qn(oe[0])!=="object")return[new jt(ue,oe,`object expected, ${Qn(oe[0])} found`)];if(oe[0].zoom===void 0)return[new jt(ue,oe,"object stop key must have zoom")];if(oe[0].value===void 0)return[new jt(ue,oe,"object stop key must have value")];const xe=_t(oe[0].zoom);if(typeof xe!="number")return[new jt(ue,oe[0].zoom,"stop zoom values must be numbers")];if(g&&g>xe)return[new jt(ue,oe[0].zoom,"stop zoom values must appear in ascending order")];xe!==g&&(g=xe,p=void 0,_={}),K=K.concat($r({key:`${ue}[0]`,value:oe[0],valueSpec:{zoom:{}},style:W.style,styleSpec:W.styleSpec,objectElementValidators:{zoom:Ym,value:N}}))}else K=K.concat(N({key:`${ue}[0]`,value:oe[0],valueSpec:{},style:W.style,styleSpec:W.styleSpec},oe));return Ds(Ot(oe[1]))?K.concat([new jt(`${ue}[1]`,oe[1],"expressions are not allowed in function stops.")]):K.concat(Hi({key:`${ue}[1]`,value:oe[1],valueSpec:n,style:W.style,styleSpec:W.styleSpec}))}function N(W,K){const oe=Qn(W.value),ue=_t(W.value),xe=W.value!==null?W.value:K;if(u){if(oe!==u)return[new jt(W.key,xe,`${oe} stop domain type must match previous stop domain type ${u}`)]}else u=oe;if(oe!=="number"&&oe!=="string"&&oe!=="boolean"&&typeof ue!="number"&&typeof ue!="string"&&typeof ue!="boolean")return[new jt(W.key,xe,"stop domain value must be a number, string, or boolean")];if(oe!=="number"&&s!=="categorical"){let Be=`number expected, ${oe} found`;return As(n)&&s===void 0&&(Be+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jt(W.key,xe,Be)]}return s!=="categorical"||oe!=="number"||typeof ue=="number"&&isFinite(ue)&&Math.floor(ue)===ue?s!=="categorical"&&oe==="number"&&typeof ue=="number"&&typeof p=="number"&&p!==void 0&&uenew jt(`${a.key}${u.key}`,a.value,u.message));const s=n.value.expression||n.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!s.outputDefined())return[new jt(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"&&!wl(s))return[new jt(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return Bo(s,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!Ml(s,["zoom","feature-state"]))return[new jt(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!yr(s))return[new jt(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Bo(a,n){const s=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const p of n.valueSpec.expression.parameters)s.delete(p);if(s.size===0)return[];const u=[];return a instanceof Sr&&s.has(a.name)?[new jt(n.key,n.value,`["${a.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(a.eachChild(p=>{u.push(...Bo(p,n))}),u)}function Rl(a){const n=a.key,s=a.value,u=a.valueSpec,p=[];return Array.isArray(u.values)?u.values.indexOf(_t(s))===-1&&p.push(new jt(n,s,`expected one of [${u.values.join(", ")}], ${JSON.stringify(s)} found`)):Object.keys(u.values).indexOf(_t(s))===-1&&p.push(new jt(n,s,`expected one of [${Object.keys(u.values).join(", ")}], ${JSON.stringify(s)} found`)),p}function la(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 n of a.slice(1))if(!la(n)&&typeof n!="boolean")return!1;return!0;default:return!0}}function ca(a,n="fill"){if(a==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};la(a)||(a=kl(a));const s=a;let u=!0;try{u=function(I){if(!ua(I))return I;let z=Ot(I);return Jm(z),z=qd(z),z}(s)}catch(I){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. 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 and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(s,null,2)} `)}const p=Te[`filter_${n}`],g=Ll(u,p);let _=null;if(g.result==="error")throw new Error(g.value.map(I=>`${I.key}: ${I.message}`).join(", "));_=(I,z,B)=>g.value.evaluate(I,z,{},B);let T=null,D=null;if(u!==s){const I=Ll(s,p);if(I.result==="error")throw new Error(I.value.map(z=>`${z.key}: ${z.message}`).join(", "));T=(z,B,N,W,K)=>I.value.evaluate(z,B,{},N,void 0,void 0,W,K),D=!yr(I.value.expression)}return _=_,{filter:_,dynamicFilter:T||void 0,needGeometry:Lu(u),needFeature:!!D}}function qd(a){if(!Array.isArray(a))return a;const n=function(s){if(Qm.has(s[0])){for(let u=1;uqd(s))}function Jm(a){let n=!1;const s=[];if(a[0]==="case"){for(let u=1;u",">=","<","<=","to-boolean"]);function Xd(a,n){return an?1:0}function Lu(a){if(!Array.isArray(a))return!1;if(a[0]==="within")return!0;for(let n=1;n"||n==="<="||n===">="?zl(a[1],a[2],n):n==="any"?(s=a.slice(1),["any"].concat(s.map(kl))):n==="all"?["all"].concat(a.slice(1).map(kl)):n==="none"?["all"].concat(a.slice(1).map(kl).map(Fl)):n==="in"?Zd(a[1],a.slice(2)):n==="!in"?Fl(Zd(a[1],a.slice(2))):n==="has"?Yd(a[1]):n==="!has"?Fl(Yd(a[1])):n!=="within"||a;var s}function zl(a,n,s){switch(a){case"$type":return[`filter-type-${s}`,n];case"$id":return[`filter-id-${s}`,n];default:return[`filter-${s}`,a,n]}}function Zd(a,n){if(n.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",n]];case"$id":return["filter-id-in",["literal",n]];default:return n.length>200&&!n.some(s=>typeof s!=typeof n[0])?["filter-in-large",a,["literal",n.sort(Xd)]]:["filter-in-small",a,["literal",n]]}}function Yd(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function Fl(a){return["!",a]}function ha(a){return la(Ot(a.value))?Ps(Tt({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${a.layerType||"fill"}`]})):Kd(a)}function Kd(a){const n=a.value,s=a.key;if(Qn(n)!=="array")return[new jt(s,n,`array expected, ${Qn(n)} found`)];const u=a.styleSpec;let p,g=[];if(n.length<1)return[new jt(s,n,"filter array must have at least 1 element")];switch(g=g.concat(Rl({key:`${s}[0]`,value:n[0],valueSpec:u.filter_operator,style:a.style,styleSpec:a.styleSpec})),_t(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&_t(n[1])==="$type"&&g.push(new jt(s,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":n.length!==3&&g.push(new jt(s,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(p=Qn(n[1]),p!=="string"&&g.push(new jt(`${s}[1]`,n[1],`string expected, ${p} found`)));for(let _=2;_{I in s&&n.push(new jt(u,s[I],`"${I}" is prohibited for ref layers`))}),p.layers.forEach(I=>{_t(I.id)===T&&(D=I)}),D?D.ref?n.push(new jt(u,s.ref,"ref cannot reference another ref layer")):_=_t(D.type):typeof T=="string"&&n.push(new jt(u,s.ref,`ref layer "${T}" not found`))}else if(_!=="background"&&_!=="sky")if(s.source){const D=p.sources&&p.sources[s.source],I=D&&_t(D.type);D?I==="vector"&&_==="raster"?n.push(new jt(u,s.source,`layer "${s.id}" requires a raster source`)):I==="raster"&&_!=="raster"?n.push(new jt(u,s.source,`layer "${s.id}" requires a vector source`)):I!=="vector"||s["source-layer"]?I==="raster-dem"&&_!=="hillshade"?n.push(new jt(u,s.source,"raster-dem source can only be used with layer type 'hillshade'.")):_!=="line"||!s.paint||!s.paint["line-gradient"]||I==="geojson"&&D.lineMetrics||n.push(new jt(u,s,`layer "${s.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new jt(u,s,`layer "${s.id}" must specify a "source-layer"`)):n.push(new jt(u,s.source,`source "${s.source}" not found`))}else n.push(new jt(u,s,'missing required property "source"'));return n=n.concat($r({key:u,value:s,valueSpec:g.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Hi({key:`${u}.type`,value:s.type,valueSpec:g.layer.type,style:a.style,styleSpec:a.styleSpec,object:s,objectKey:"type"}),filter:D=>ha(Tt({layerType:_},D)),layout:D=>$r({layer:s,key:D.key,value:D.value,valueSpec:{},style:D.style,styleSpec:D.styleSpec,objectElementValidators:{"*":I=>Qd(Tt({layerType:_},I))}}),paint:D=>$r({layer:s,key:D.key,value:D.value,valueSpec:{},style:D.style,styleSpec:D.styleSpec,objectElementValidators:{"*":I=>Iu(Tt({layerType:_},I))}})}})),n}function Oo(a){const n=a.value,s=a.key,u=Qn(n);return u!=="string"?[new jt(s,n,`string expected, ${u} found`)]:[]}const tg={promoteId:function({key:a,value:n}){if(Qn(n)==="string")return Oo({key:a,value:n});{const s=[];for(const u in n)s.push(...Oo({key:`${a}.${u}`,value:n[u]}));return s}}};function ng(a){const n=a.value,s=a.key,u=a.styleSpec,p=a.style;if(!n.type)return[new jt(s,n,'"type" is required')];const g=_t(n.type);let _;switch(g){case"vector":case"raster":case"raster-dem":return _=$r({key:s,value:n,valueSpec:u[`source_${g.replace("-","_")}`],style:a.style,styleSpec:u,objectElementValidators:tg}),_;case"geojson":if(_=$r({key:s,value:n,valueSpec:u.source_geojson,style:p,styleSpec:u,objectElementValidators:tg}),n.cluster)for(const T in n.clusterProperties){const[D,I]=n.clusterProperties[T],z=typeof D=="string"?[D,["accumulated"],["get",T]]:D;_.push(...Ps({key:`${s}.${T}.map`,value:I,expressionContext:"cluster-map"})),_.push(...Ps({key:`${s}.${T}.reduce`,value:z,expressionContext:"cluster-reduce"}))}return _;case"video":return $r({key:s,value:n,valueSpec:u.source_video,style:p,styleSpec:u});case"image":return $r({key:s,value:n,valueSpec:u.source_image,style:p,styleSpec:u});case"canvas":return[new jt(s,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Rl({key:`${s}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:p,styleSpec:u})}}function ig(a){const n=a.value,s=a.styleSpec,u=s.light,p=a.style;let g=[];const _=Qn(n);if(n===void 0)return g;if(_!=="object")return g=g.concat([new jt("light",n,`object expected, ${_} found`)]),g;for(const T in n){const D=T.match(/^(.*)-transition$/);g=g.concat(D&&u[D[1]]&&u[D[1]].transition?Hi({key:T,value:n[T],valueSpec:s.transition,style:p,styleSpec:s}):u[T]?Hi({key:T,value:n[T],valueSpec:u[T],style:p,styleSpec:s}):[new jt(T,n[T],`unknown property "${T}"`)])}return g}function rg(a){const n=a.value,s=a.key,u=a.style,p=a.styleSpec,g=p.terrain;let _=[];const T=Qn(n);if(n===void 0)return _;if(T!=="object")return _=_.concat([new jt("terrain",n,`object expected, ${T} found`)]),_;for(const D in n){const I=D.match(/^(.*)-transition$/);_=_.concat(I&&g[I[1]]&&g[I[1]].transition?Hi({key:D,value:n[D],valueSpec:p.transition,style:u,styleSpec:p}):g[D]?Hi({key:D,value:n[D],valueSpec:g[D],style:u,styleSpec:p}):[new jt(D,n[D],`unknown property "${D}"`)])}if(n.source){const D=u.sources&&u.sources[n.source],I=D&&_t(D.type);D?I!=="raster-dem"&&_.push(new jt(s,n.source,`terrain cannot be used with a source of type ${String(I)}, it only be used with a "raster-dem" source type`)):_.push(new jt(s,n.source,`source "${n.source}" not found`))}else _.push(new jt(s,n,'terrain is missing required property "source"'));return _}function og(a){const n=a.value,s=a.style,u=a.styleSpec,p=u.fog;let g=[];const _=Qn(n);if(n===void 0)return g;if(_!=="object")return g=g.concat([new jt("fog",n,`object expected, ${_} found`)]),g;for(const T in n){const D=T.match(/^(.*)-transition$/);g=g.concat(D&&p[D[1]]&&p[D[1]].transition?Hi({key:T,value:n[T],valueSpec:u.transition,style:s,styleSpec:u}):p[T]?Hi({key:T,value:n[T],valueSpec:p[T],style:s,styleSpec:u}):[new jt(T,n[T],`unknown property "${T}"`)])}return g}const Bl={"*":()=>[],array:Il,boolean:function(a){const n=a.value,s=a.key,u=Qn(n);return u!=="boolean"?[new jt(s,n,`boolean expected, ${u} found`)]:[]},number:Ym,color:function(a){const n=a.key,s=a.value,u=Qn(s);return u!=="string"?[new jt(n,s,`color expected, ${u} found`)]:Cd.parseCSSColor(s)===null?[new jt(n,s,`color expected, "${s}" found`)]:[]},enum:Rl,filter:ha,function:Km,layer:eg,object:$r,source:ng,light:ig,terrain:rg,fog:og,string:Oo,formatted:function(a){return Oo(a).length===0?[]:Ps(a)},resolvedImage:function(a){return Oo(a).length===0?[]:Ps(a)},projection:function(a){const n=a.value,s=a.styleSpec,u=s.projection,p=a.style;let g=[];const _=Qn(n);if(_==="object")for(const T in n)g=g.concat(Hi({key:T,value:n[T],valueSpec:u[T],style:p,styleSpec:s}));else _!=="string"&&(g=g.concat([new jt("projection",n,`object or string expected, ${_} found`)]));return g}};function Hi(a){const n=a.value,s=a.valueSpec,u=a.styleSpec;return s.expression&&Wa(_t(n))?Km(a):s.expression&&Ds(Ot(n))?Ps(a):s.type&&Bl[s.type]?Bl[s.type](a):$r(Tt({},a,{valueSpec:s.type?u[s.type]:s}))}function Ir(a){const n=a.value,s=a.key,u=Oo(a);return u.length||(n.indexOf("{fontstack}")===-1&&u.push(new jt(s,n,'"glyphs" url must include a "{fontstack}" token')),n.indexOf("{range}")===-1&&u.push(new jt(s,n,'"glyphs" url must include a "{range}" token'))),u}function Ol(a,n=Te){return No(Hi({key:"",value:a,valueSpec:n.$root,styleSpec:n,style:a,objectElementValidators:{glyphs:Ir,"*":()=>[]}}))}const ov=a=>No(Iu(a)),av=a=>No(Qd(a));function No(a){return a.slice().sort((n,s)=>n.line&&s.line?n.line-s.line:0)}function ag(a,n){let s=!1;if(n&&n.length)for(const u of n)a.fire(new re(new Error(u.message))),s=!0;return s}var da=Mo;function Mo(a,n,s){var u=this.cells=[];if(a instanceof ArrayBuffer){this.arrayBuffer=a;var p=new Int32Array(this.arrayBuffer);a=p[0],this.d=(n=p[1])+2*(s=p[2]);for(var g=0;g=z[W+0]&&u>=z[W+1])?(_[N]=!0,g.push(I[N])):_[N]=!1}}},Mo.prototype._forEachCell=function(a,n,s,u,p,g,_,T){for(var D=this._convertToCellCoord(a),I=this._convertToCellCoord(n),z=this._convertToCellCoord(s),B=this._convertToCellCoord(u),N=D;N<=z;N++)for(var W=I;W<=B;W++){var K=this.d*W+N;if((!T||T(this._convertFromCellCoord(N),this._convertFromCellCoord(W),this._convertFromCellCoord(N+1),this._convertFromCellCoord(W+1)))&&p.call(this,a,n,s,u,K,g,_,T))return}},Mo.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},Mo.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},Mo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var a=this.cells,n=3+this.cells.length+1+1,s=0,u=0;u=0||(p[g]=Nl(a[g],n)));a instanceof Error&&(p.message=a.message)}if(p.$name)throw new Error("$name property is reserved for worker serialization logic.");return u!=="Object"&&(p.$name=u),p}throw new Error("can't serialize object of type "+typeof a)}function Ls(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||sg(a)||Ru(a)||ArrayBuffer.isView(a)||a instanceof L.ImageData)return a;if(Array.isArray(a))return a.map(Ls);if(typeof a=="object"){const n=a.$name||"Object",{klass:s}=Ss[n];if(!s)throw new Error(`can't deserialize unregistered class ${n}`);if(s.deserialize)return s.deserialize(a);const u=Object.create(s.prototype);for(const p of Object.keys(a))p!=="$name"&&(u[p]=Ls(a[p]));return u}throw new Error("can't deserialize object of type "+typeof a)}class ep{constructor(){this.first=!0}update(n,s){const u=Math.floor(n);return this.first?(this.first=!1,this.lastIntegerZoom=u,this.lastIntegerZoomTime=0,this.lastZoom=n,this.lastFloorZoom=u,!0):(this.lastFloorZoom>u?(this.lastIntegerZoom=u+1,this.lastIntegerZoomTime=s):this.lastFloorZooma>=1536&&a<=1791,ku=a=>a>=1872&&a<=1919,Ul=a=>a>=2208&&a<=2303,tp=a=>a>=11904&&a<=12031,cg=a=>a>=12032&&a<=12255,np=a=>a>=12272&&a<=12287,zu=a=>a>=12288&&a<=12351,Vl=a=>a>=12352&&a<=12447,Fu=a=>a>=12448&&a<=12543,ug=a=>a>=12544&&a<=12591,hg=a=>a>=12704&&a<=12735,dg=a=>a>=12736&&a<=12783,ip=a=>a>=12784&&a<=12799,pg=a=>a>=12800&&a<=13055,fg=a=>a>=13056&&a<=13311,mg=a=>a>=13312&&a<=19903,rp=a=>a>=19968&&a<=40959,gg=a=>a>=40960&&a<=42127,yg=a=>a>=42128&&a<=42191,_g=a=>a>=44032&&a<=55215,Gl=a=>a>=63744&&a<=64255,op=a=>a>=64336&&a<=65023,vg=a=>a>=65040&&a<=65055,Is=a=>a>=65072&&a<=65103,xg=a=>a>=65104&&a<=65135,Bu=a=>a>=65136&&a<=65279,ap=a=>a>=65280&&a<=65519;function Ou(a){for(const n of a)if(Nu(n.charCodeAt(0)))return!0;return!1}function bg(a){for(const n of a)if(!wg(n.charCodeAt(0)))return!1;return!0}function wg(a){return!(lg(a)||ku(a)||Ul(a)||op(a)||Bu(a))}function Nu(a){return!(a!==746&&a!==747&&(a<4352||!(hg(a)||ug(a)||Is(a)&&!(a>=65097&&a<=65103)||Gl(a)||fg(a)||tp(a)||dg(a)||!(!zu(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||a===12336)||mg(a)||rp(a)||pg(a)||(n=>n>=12592&&n<=12687)(a)||(n=>n>=43360&&n<=43391)(a)||(n=>n>=55216&&n<=55295)(a)||(n=>n>=4352&&n<=4607)(a)||_g(a)||Vl(a)||np(a)||(n=>n>=12688&&n<=12703)(a)||cg(a)||ip(a)||Fu(a)&&a!==12540||!(!ap(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)||!(!xg(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(n=>n>=5120&&n<=5759)(a)||(n=>n>=6320&&n<=6399)(a)||vg(a)||(n=>n>=19904&&n<=19967)(a)||gg(a)||yg(a))))}function Uu(a){return!(Nu(a)||function(n){return!!((s=>s>=128&&s<=255)(n)&&(n===167||n===169||n===174||n===177||n===188||n===189||n===190||n===215||n===247)||(s=>s>=8192&&s<=8303)(n)&&(n===8214||n===8224||n===8225||n===8240||n===8241||n===8251||n===8252||n===8258||n===8263||n===8264||n===8265||n===8273)||(s=>s>=8448&&s<=8527)(n)||(s=>s>=8528&&s<=8591)(n)||(s=>s>=8960&&s<=9215)(n)&&(n>=8960&&n<=8967||n>=8972&&n<=8991||n>=8996&&n<=9e3||n===9003||n>=9085&&n<=9114||n>=9150&&n<=9165||n===9167||n>=9169&&n<=9179||n>=9186&&n<=9215)||(s=>s>=9216&&s<=9279)(n)&&n!==9251||(s=>s>=9280&&s<=9311)(n)||(s=>s>=9312&&s<=9471)(n)||(s=>s>=9632&&s<=9727)(n)||(s=>s>=9728&&s<=9983)(n)&&!(n>=9754&&n<=9759)||(s=>s>=11008&&s<=11263)(n)&&(n>=11026&&n<=11055||n>=11088&&n<=11097||n>=11192&&n<=11243)||zu(n)||Fu(n)||(s=>s>=57344&&s<=63743)(n)||Is(n)||xg(n)||ap(n)||n===8734||n===8756||n===8757||n>=9984&&n<=10087||n>=10102&&n<=10131||n===65532||n===65533)}(a))}function Vu(a){return a>=1424&&a<=2303||op(a)||Bu(a)}function sv(a,n){return!(!n&&Vu(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(s=>s>=6016&&s<=6143)(a))}function lv(a){for(const n of a)if(Vu(n.charCodeAt(0)))return!0;return!1}const sp="deferred",Wl="loading",lp="loaded";let cp=null,_r="unavailable",Rr=null;const jl=function(a){a&&typeof a=="string"&&a.indexOf("NetworkError")>-1&&(_r="error"),cp&&cp(a)};function ja(){up.fire(new Y("pluginStateChange",{pluginStatus:_r,pluginURL:Rr}))}const up=new Fe,Gu=function(){return _r},Rs=function(){if(_r!==sp||!Rr)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_r=Wl,ja(),Rr&&Re({url:Rr},a=>{a?jl(a):(_r=lp,ja())})},qr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_r===lp||qr.applyArabicShaping!=null,isLoading:()=>_r===Wl,setState(a){_r=a.pluginStatus,Rr=a.pluginURL},isParsed:()=>qr.applyArabicShaping!=null&&qr.processBidirectionalText!=null&&qr.processStyledBidirectionalText!=null,getPluginURL:()=>Rr};class ci{constructor(n,s){this.zoom=n,s?(this.now=s.now,this.fadeDuration=s.fadeDuration,this.zoomHistory=s.zoomHistory,this.transition=s.transition,this.pitch=s.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ep,this.transition={},this.pitch=0)}isSupportedScript(n){return function(s,u){for(const p of s)if(!sv(p.charCodeAt(0),u))return!1;return!0}(n,qr.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const n=this.zoom,s=n-Math.floor(n),u=this.crossFadingFactor();return n>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:s+(1-s)*u}:{fromScale:.5,toScale:1,t:1-(1-u)*s}}}class Hl{constructor(n,s){this.property=n,this.value=s,this.expression=function(u,p){if(Wa(u))return new Pu(u,p);if(Ds(u)){const g=Zm(u,p);if(g.result==="error")throw new Error(g.value.map(_=>`${_.key}: ${_.message}`).join(", "));return g.value}{let g=u;return typeof u=="string"&&p.type==="color"&&(g=Xn.parse(u)),{kind:"constant",evaluate:()=>g}}}(s===void 0?n.specification.default:s,n.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(n,s,u){return this.property.possiblyEvaluate(this,n,s,u)}}class ks{constructor(n){this.property=n,this.value=new Hl(n,void 0)}transitioned(n,s){return new o(this.property,this.value,s,me({},n.transition,this.transition),n.now)}untransitioned(){return new o(this.property,this.value,null,{},0)}}class m{constructor(n){this._properties=n,this._values=Object.create(n.defaultTransitionablePropertyValues)}getValue(n){return Nt(this._values[n].value.value)}setValue(n,s){this._values.hasOwnProperty(n)||(this._values[n]=new ks(this._values[n].property)),this._values[n].value=new Hl(this._values[n].property,s===null?void 0:Nt(s))}getTransition(n){return Nt(this._values[n].transition)}setTransition(n,s){this._values.hasOwnProperty(n)||(this._values[n]=new ks(this._values[n].property)),this._values[n].transition=Nt(s)||void 0}serialize(){const n={};for(const s of Object.keys(this._values)){const u=this.getValue(s);u!==void 0&&(n[s]=u);const p=this.getTransition(s);p!==void 0&&(n[`${s}-transition`]=p)}return n}transitioned(n,s){const u=new d(this._properties);for(const p of Object.keys(this._values))u._values[p]=this._values[p].transitioned(n,s._values[p]);return u}untransitioned(){const n=new d(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].untransitioned();return n}}class o{constructor(n,s,u,p,g){const _=p.delay||0,T=p.duration||0;g=g||0,this.property=n,this.value=s,this.begin=g+_,this.end=this.begin+T,n.specification.transition&&(p.delay||p.duration)&&(this.prior=u)}possiblyEvaluate(n,s,u){const p=n.now||0,g=this.value.possiblyEvaluate(n,s,u),_=this.prior;if(_){if(p>this.end)return this.prior=null,g;if(this.value.isDataDriven())return this.prior=null,g;if(pp.zoomHistory.lastIntegerZoom?{from:n,to:s,other:u}:{from:u,to:s,other:n}}interpolate(n){return n}}class U{constructor(n){this.specification=n}possiblyEvaluate(n,s,u,p){if(n.value!==void 0){if(n.expression.kind==="constant"){const g=n.expression.evaluate(s,null,{},u,p);return this._calculate(g,g,g,s)}return this._calculate(n.expression.evaluate(new ci(Math.floor(s.zoom-1),s)),n.expression.evaluate(new ci(Math.floor(s.zoom),s)),n.expression.evaluate(new ci(Math.floor(s.zoom+1),s)),s)}}_calculate(n,s,u,p){return p.zoom>p.zoomHistory.lastIntegerZoom?{from:n,to:s}:{from:u,to:s}}interpolate(n){return n}}class G{constructor(n){this.specification=n}possiblyEvaluate(n,s,u,p){return!!n.expression.evaluate(s,null,{},u,p)}interpolate(){return!1}}class Z{constructor(n){this.properties=n,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const s in n){const u=n[s];u.specification.overridable&&this.overridableProperties.push(s);const p=this.defaultPropertyValues[s]=new Hl(u,void 0),g=this.defaultTransitionablePropertyValues[s]=new ks(u);this.defaultTransitioningPropertyValues[s]=g.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=p.possiblyEvaluate({})}}}function se(a,n){return 256*(a=Q(Math.floor(a),0,255))+Q(Math.floor(n),0,255)}$t(k,"DataDrivenProperty"),$t(S,"DataConstantProperty"),$t(O,"CrossFadedDataDrivenProperty"),$t(U,"CrossFadedProperty"),$t(G,"ColorRampProperty");const de={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ce{constructor(n,s){this._structArray=n,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class te{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(n,s){return n._trim(),s&&(n.isTransferred=!0,s.push(n.arrayBuffer)),{length:n.length,arrayBuffer:n.arrayBuffer}}static deserialize(n){const s=Object.create(this.prototype);return s.arrayBuffer=n.arrayBuffer,s.length=n.length,s.capacity=n.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_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(n){this.reserve(n),this.length=n}reserve(n){if(n>this.capacity){this.capacity=Math.max(n,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_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 Le(a,n=1){let s=0,u=0;return{members:a.map(p=>{const g=de[p.type].BYTES_PER_ELEMENT,_=s=ve(s,Math.max(n,g)),T=p.components||1;return u=Math.max(u,g),s+=g*T,{name:p.name,type:p.type,components:T,offset:_}}),size:ve(s,Math.max(u,n)),alignment:n}}function ve(a,n){return Math.ceil(a/n)*n}class De extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s){const u=this.length;return this.resize(u+1),this.emplace(u,n,s)}emplace(n,s,u){const p=2*n;return this.int16[p+0]=s,this.int16[p+1]=u,n}}De.prototype.bytesPerElement=4,$t(De,"StructArrayLayout2i4");class Se extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u){const p=this.length;return this.resize(p+1),this.emplace(p,n,s,u)}emplace(n,s,u,p){const g=3*n;return this.int16[g+0]=s,this.int16[g+1]=u,this.int16[g+2]=p,n}}Se.prototype.bytesPerElement=6,$t(Se,"StructArrayLayout3i6");class ze extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=4*n;return this.int16[_+0]=s,this.int16[_+1]=u,this.int16[_+2]=p,this.int16[_+3]=g,n}}ze.prototype.bytesPerElement=8,$t(ze,"StructArrayLayout4i8");class Ee extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=6*n,z=12*n,B=3*n;return this.int16[I+0]=s,this.int16[I+1]=u,this.uint8[z+4]=p,this.uint8[z+5]=g,this.uint8[z+6]=_,this.uint8[z+7]=T,this.float32[B+2]=D,n}}Ee.prototype.bytesPerElement=12,$t(Ee,"StructArrayLayout2i4ub1f12");class Ue extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=4*n;return this.float32[_+0]=s,this.float32[_+1]=u,this.float32[_+2]=p,this.float32[_+3]=g,n}}Ue.prototype.bytesPerElement=16,$t(Ue,"StructArrayLayout4f16");class nt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z){const B=this.length;return this.resize(B+1),this.emplace(B,n,s,u,p,g,_,T,D,I,z)}emplace(n,s,u,p,g,_,T,D,I,z,B){const N=10*n;return this.uint16[N+0]=s,this.uint16[N+1]=u,this.uint16[N+2]=p,this.uint16[N+3]=g,this.uint16[N+4]=_,this.uint16[N+5]=T,this.uint16[N+6]=D,this.uint16[N+7]=I,this.uint16[N+8]=z,this.uint16[N+9]=B,n}}nt.prototype.bytesPerElement=20,$t(nt,"StructArrayLayout10ui20");class lt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D){const I=this.length;return this.resize(I+1),this.emplace(I,n,s,u,p,g,_,T,D)}emplace(n,s,u,p,g,_,T,D,I){const z=8*n;return this.uint16[z+0]=s,this.uint16[z+1]=u,this.uint16[z+2]=p,this.uint16[z+3]=g,this.uint16[z+4]=_,this.uint16[z+5]=T,this.uint16[z+6]=D,this.uint16[z+7]=I,n}}lt.prototype.bytesPerElement=16,$t(lt,"StructArrayLayout8ui16");class pt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_){const T=this.length;return this.resize(T+1),this.emplace(T,n,s,u,p,g,_)}emplace(n,s,u,p,g,_,T){const D=6*n;return this.int16[D+0]=s,this.int16[D+1]=u,this.int16[D+2]=p,this.int16[D+3]=g,this.int16[D+4]=_,this.int16[D+5]=T,n}}pt.prototype.bytesPerElement=12,$t(pt,"StructArrayLayout6i12");class ht extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue){const xe=this.length;return this.resize(xe+1),this.emplace(xe,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe){const Be=16*n;return this.int16[Be+0]=s,this.int16[Be+1]=u,this.int16[Be+2]=p,this.int16[Be+3]=g,this.uint16[Be+4]=_,this.uint16[Be+5]=T,this.uint16[Be+6]=D,this.uint16[Be+7]=I,this.int16[Be+8]=z,this.int16[Be+9]=B,this.int16[Be+10]=N,this.int16[Be+11]=W,this.int16[Be+12]=K,this.int16[Be+13]=oe,this.int16[Be+14]=ue,this.int16[Be+15]=xe,n}}ht.prototype.bytesPerElement=32,$t(ht,"StructArrayLayout4i4ui4i4i32");class kt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u){const p=this.length;return this.resize(p+1),this.emplace(p,n,s,u)}emplace(n,s,u,p){const g=3*n;return this.float32[g+0]=s,this.float32[g+1]=u,this.float32[g+2]=p,n}}kt.prototype.bytesPerElement=12,$t(kt,"StructArrayLayout3f12");class it extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n){const s=this.length;return this.resize(s+1),this.emplace(s,n)}emplace(n,s){return this.uint32[1*n+0]=s,n}}it.prototype.bytesPerElement=4,$t(it,"StructArrayLayout1ul4");class zt extends te{_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(n,s,u,p,g,_,T,D,I,z,B,N,W){const K=this.length;return this.resize(K+1),this.emplace(K,n,s,u,p,g,_,T,D,I,z,B,N,W)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K){const oe=20*n,ue=10*n;return this.int16[oe+0]=s,this.int16[oe+1]=u,this.int16[oe+2]=p,this.int16[oe+3]=g,this.int16[oe+4]=_,this.float32[ue+3]=T,this.float32[ue+4]=D,this.float32[ue+5]=I,this.float32[ue+6]=z,this.int16[oe+14]=B,this.uint32[ue+8]=N,this.uint16[oe+18]=W,this.uint16[oe+19]=K,n}}zt.prototype.bytesPerElement=40,$t(zt,"StructArrayLayout5i4f1i1ul2ui40");class St extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=8*n;return this.int16[I+0]=s,this.int16[I+1]=u,this.int16[I+2]=p,this.int16[I+4]=g,this.int16[I+5]=_,this.int16[I+6]=T,this.int16[I+7]=D,n}}St.prototype.bytesPerElement=16,$t(St,"StructArrayLayout3i2i2i16");class Jt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g){const _=this.length;return this.resize(_+1),this.emplace(_,n,s,u,p,g)}emplace(n,s,u,p,g,_){const T=4*n,D=8*n;return this.float32[T+0]=s,this.float32[T+1]=u,this.float32[T+2]=p,this.int16[D+6]=g,this.int16[D+7]=_,n}}Jt.prototype.bytesPerElement=16,$t(Jt,"StructArrayLayout2f1f2i16");class ft extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=12*n,T=3*n;return this.uint8[_+0]=s,this.uint8[_+1]=u,this.float32[T+1]=p,this.float32[T+2]=g,n}}ft.prototype.bytesPerElement=12,$t(ft,"StructArrayLayout2ub2f12");class qt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u){const p=this.length;return this.resize(p+1),this.emplace(p,n,s,u)}emplace(n,s,u,p){const g=3*n;return this.uint16[g+0]=s,this.uint16[g+1]=u,this.uint16[g+2]=p,n}}qt.prototype.bytesPerElement=6,$t(qt,"StructArrayLayout3ui6");class gn extends te{_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(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye){const Ke=this.length;return this.resize(Ke+1),this.emplace(Ke,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke){const ut=30*n,dt=15*n,xt=60*n;return this.int16[ut+0]=s,this.int16[ut+1]=u,this.int16[ut+2]=p,this.float32[dt+2]=g,this.float32[dt+3]=_,this.uint16[ut+8]=T,this.uint16[ut+9]=D,this.uint32[dt+5]=I,this.uint32[dt+6]=z,this.uint32[dt+7]=B,this.uint16[ut+16]=N,this.uint16[ut+17]=W,this.uint16[ut+18]=K,this.float32[dt+10]=oe,this.float32[dt+11]=ue,this.uint8[xt+48]=xe,this.uint8[xt+49]=Be,this.uint8[xt+50]=$e,this.uint32[dt+13]=Ze,this.int16[ut+28]=Ye,this.uint8[xt+58]=Ke,n}}gn.prototype.bytesPerElement=60,$t(gn,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Zt extends te{_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(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke,ut,dt,xt,Et,st,mt,Pt,Bt){const Rt=this.length;return this.resize(Rt+1),this.emplace(Rt,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke,ut,dt,xt,Et,st,mt,Pt,Bt)}emplace(n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue,xe,Be,$e,Ze,Ye,Ke,ut,dt,xt,Et,st,mt,Pt,Bt,Rt){const Ft=38*n,En=19*n;return this.int16[Ft+0]=s,this.int16[Ft+1]=u,this.int16[Ft+2]=p,this.float32[En+2]=g,this.float32[En+3]=_,this.int16[Ft+8]=T,this.int16[Ft+9]=D,this.int16[Ft+10]=I,this.int16[Ft+11]=z,this.int16[Ft+12]=B,this.int16[Ft+13]=N,this.uint16[Ft+14]=W,this.uint16[Ft+15]=K,this.uint16[Ft+16]=oe,this.uint16[Ft+17]=ue,this.uint16[Ft+18]=xe,this.uint16[Ft+19]=Be,this.uint16[Ft+20]=$e,this.uint16[Ft+21]=Ze,this.uint16[Ft+22]=Ye,this.uint16[Ft+23]=Ke,this.uint16[Ft+24]=ut,this.uint16[Ft+25]=dt,this.uint16[Ft+26]=xt,this.uint16[Ft+27]=Et,this.uint16[Ft+28]=st,this.uint32[En+15]=mt,this.float32[En+16]=Pt,this.float32[En+17]=Bt,this.float32[En+18]=Rt,n}}Zt.prototype.bytesPerElement=76,$t(Zt,"StructArrayLayout3i2f6i15ui1ul3f76");class Yt extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n){const s=this.length;return this.resize(s+1),this.emplace(s,n)}emplace(n,s){return this.float32[1*n+0]=s,n}}Yt.prototype.bytesPerElement=4,$t(Yt,"StructArrayLayout1f4");class xn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=7*n;return this.float32[I+0]=s,this.float32[I+1]=u,this.float32[I+2]=p,this.float32[I+3]=g,this.float32[I+4]=_,this.float32[I+5]=T,this.float32[I+6]=D,n}}xn.prototype.bytesPerElement=28,$t(xn,"StructArrayLayout7f28");class zn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g){const _=this.length;return this.resize(_+1),this.emplace(_,n,s,u,p,g)}emplace(n,s,u,p,g,_){const T=5*n;return this.float32[T+0]=s,this.float32[T+1]=u,this.float32[T+2]=p,this.float32[T+3]=g,this.float32[T+4]=_,n}}zn.prototype.bytesPerElement=20,$t(zn,"StructArrayLayout5f20");class dn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s,u,p){const g=this.length;return this.resize(g+1),this.emplace(g,n,s,u,p)}emplace(n,s,u,p,g){const _=6*n;return this.uint32[3*n+0]=s,this.uint16[_+2]=u,this.uint16[_+3]=p,this.uint16[_+4]=g,n}}dn.prototype.bytesPerElement=12,$t(dn,"StructArrayLayout1ul3ui12");class Mn extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,s){const u=this.length;return this.resize(u+1),this.emplace(u,n,s)}emplace(n,s,u){const p=2*n;return this.uint16[p+0]=s,this.uint16[p+1]=u,n}}Mn.prototype.bytesPerElement=4,$t(Mn,"StructArrayLayout2ui4");class $n extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n){const s=this.length;return this.resize(s+1),this.emplace(s,n)}emplace(n,s){return this.uint16[1*n+0]=s,n}}$n.prototype.bytesPerElement=2,$t($n,"StructArrayLayout1ui2");class vi extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s){const u=this.length;return this.resize(u+1),this.emplace(u,n,s)}emplace(n,s,u){const p=2*n;return this.float32[p+0]=s,this.float32[p+1]=u,n}}vi.prototype.bytesPerElement=8,$t(vi,"StructArrayLayout2f8");class nr extends te{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,s,u,p,g,_,T){const D=this.length;return this.resize(D+1),this.emplace(D,n,s,u,p,g,_,T)}emplace(n,s,u,p,g,_,T,D){const I=8*n,z=4*n;return this.int16[I+0]=s,this.int16[I+1]=u,this.int16[I+2]=p,this.int16[I+3]=g,this.int16[I+4]=_,this.int16[I+5]=T,this.float32[z+3]=D,n}}nr.prototype.bytesPerElement=16,$t(nr,"StructArrayLayout6i1f16");class ir extends ce{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 kr extends pt{get(n){return new ir(this,n)}}$t(kr,"FillExtrusionExtArray");class mo extends ce{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]}}mo.prototype.size=40;class Uo extends zt{get(n){return new mo(this,n)}}$t(Uo,"CollisionBoxArray");class pa extends ce{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(n){this._structArray.uint8[this._pos1+49]=n}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(n){this._structArray.uint8[this._pos1+50]=n}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(n){this._structArray.uint32[this._pos4+13]=n}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(n){this._structArray.uint8[this._pos1+58]=n}}pa.prototype.size=60;class Vo extends gn{get(n){return new pa(this,n)}}$t(Vo,"PlacedSymbolArray");class bi extends ce{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(n){this._structArray.uint32[this._pos4+15]=n}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 Zt{get(n){return new bi(this,n)}}$t(Ti,"SymbolInstanceArray");class Yn extends Yt{getoffsetX(n){return this.float32[1*n+0]}}$t(Yn,"GlyphOffsetArray");class Si extends Se{getx(n){return this.int16[3*n+0]}gety(n){return this.int16[3*n+1]}gettileUnitDistanceFromAnchor(n){return this.int16[3*n+2]}}$t(Si,"SymbolLineVertexArray");class zr extends ce{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 dn{get(n){return new zr(this,n)}}$t(xi,"FeatureIndexArray");class Xr extends ce{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Xr.prototype.size=4;class $l extends Mn{get(n){return new Xr(this,n)}}$t($l,"FillExtrusionCentroidArray");class Fr extends ce{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]}}Fr.prototype.size=16;class Ha extends nr{get(n){return new Fr(this,n)}}$t(Ha,"CircleGlobeExtArray");const Mg=Le([{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"}]),hp=Le([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var zs=hu(function(a){a.exports=function(n,s){var u,p,g,_,T,D,I,z;for(p=n.length-(u=3&n.length),g=s,T=3432918353,D=461845907,z=0;z>>16)*T&65535)<<16)&4294967295)<<15|I>>>17))*D+(((I>>>16)*D&65535)<<16)&4294967295)<<13|g>>>19))+((5*(g>>>16)&65535)<<16)&4294967295))+((58964+(_>>>16)&65535)<<16);switch(I=0,u){case 3:I^=(255&n.charCodeAt(z+2))<<16;case 2:I^=(255&n.charCodeAt(z+1))<<8;case 1:g^=I=(65535&(I=(I=(65535&(I^=255&n.charCodeAt(z)))*T+(((I>>>16)*T&65535)<<16)&4294967295)<<15|I>>>17))*D+(((I>>>16)*D&65535)<<16)&4294967295}return g^=n.length,g=2246822507*(65535&(g^=g>>>16))+((2246822507*(g>>>16)&65535)<<16)&4294967295,g=3266489909*(65535&(g^=g>>>13))+((3266489909*(g>>>16)&65535)<<16)&4294967295,(g^=g>>>16)>>>0}}),cv=hu(function(a){a.exports=function(n,s){for(var u,p=n.length,g=s^p,_=0;p>=4;)u=1540483477*(65535&(u=255&n.charCodeAt(_)|(255&n.charCodeAt(++_))<<8|(255&n.charCodeAt(++_))<<16|(255&n.charCodeAt(++_))<<24))+((1540483477*(u>>>16)&65535)<<16),g=1540483477*(65535&g)+((1540483477*(g>>>16)&65535)<<16)^(u=1540483477*(65535&(u^=u>>>24))+((1540483477*(u>>>16)&65535)<<16)),p-=4,++_;switch(p){case 3:g^=(255&n.charCodeAt(_+2))<<16;case 2:g^=(255&n.charCodeAt(_+1))<<8;case 1:g=1540483477*(65535&(g^=255&n.charCodeAt(_)))+((1540483477*(g>>>16)&65535)<<16)}return g=1540483477*(65535&(g^=g>>>13))+((1540483477*(g>>>16)&65535)<<16),(g^=g>>>15)>>>0}}),fa=zs,dp=cv;fa.murmur3=zs,fa.murmur2=dp;class Tg{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(n,s,u,p){this.ids.push(vb(n)),this.positions.push(s,u,p)}getPositions(n){const s=vb(n);let u=0,p=this.ids.length-1;for(;u>1;this.ids[_]>=s?p=_:u=_+1}const g=[];for(;this.ids[u]===s;)g.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return g}static serialize(n,s){const u=new Float64Array(n.ids),p=new Uint32Array(n.positions);return uv(u,p,0,u.length-1),s&&s.push(u.buffer,p.buffer),{ids:u,positions:p}}static deserialize(n){const s=new Tg;return s.ids=n.ids,s.positions=n.positions,s.indexed=!0,s}}function vb(a){const n=+a;return!isNaN(n)&&Number.MIN_SAFE_INTEGER<=n&&n<=Number.MAX_SAFE_INTEGER?n:fa(String(a))}function uv(a,n,s,u){for(;s>1];let g=s-1,_=u+1;for(;;){do g++;while(a[g]p);if(g>=_)break;Eg(a,g,_),Eg(n,3*g,3*_),Eg(n,3*g+1,3*_+1),Eg(n,3*g+2,3*_+2)}_-s`u_${p}`),this.type=u}setUniform(n,s,u){n.set(u.constantOr(this.value))}getBinding(n,s,u){return this.type==="color"?new bb(n,s):new Cg(n,s)}}class Wu{constructor(n,s){this.uniformNames=s.map(u=>`u_${u}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(n,s){this.pixelRatioFrom=s.pixelRatio||1,this.pixelRatioTo=n.pixelRatio||1,this.patternFrom=s.tl.concat(s.br),this.patternTo=n.tl.concat(n.br)}setUniform(n,s,u,p){const g=p==="u_pattern_to"||p==="u_dash_to"?this.patternTo:p==="u_pattern_from"||p==="u_dash_from"?this.patternFrom:p==="u_pixel_ratio_to"?this.pixelRatioTo:p==="u_pixel_ratio_from"?this.pixelRatioFrom:null;g&&n.set(g)}getBinding(n,s,u){return u==="u_pattern_from"||u==="u_pattern_to"||u==="u_dash_from"||u==="u_dash_to"?new xb(n,s):new Cg(n,s)}}class qa{constructor(n,s,u,p){this.expression=n,this.type=u,this.maxValue=0,this.paintVertexAttributes=s.map(g=>({name:`a_${g}`,type:"Float32",components:u==="color"?2:1,offset:0})),this.paintVertexArray=new p}populatePaintArray(n,s,u,p,g,_){const T=this.paintVertexArray.length,D=this.expression.evaluate(new ci(0),s,{},g,p,_);this.paintVertexArray.resize(n),this._setPaintValue(T,n,D)}updatePaintArray(n,s,u,p,g){const _=this.expression.evaluate({zoom:0},u,p,void 0,g);this._setPaintValue(n,s,_)}_setPaintValue(n,s,u){if(this.type==="color"){const p=hv(u);for(let g=n;g`u_${T}_t`),this.type=u,this.useIntegerZoom=p,this.zoom=g,this.maxValue=0,this.paintVertexAttributes=s.map(T=>({name:`a_${T}`,type:"Float32",components:u==="color"?4:2,offset:0})),this.paintVertexArray=new _}populatePaintArray(n,s,u,p,g,_){const T=this.expression.evaluate(new ci(this.zoom),s,{},g,p,_),D=this.expression.evaluate(new ci(this.zoom+1),s,{},g,p,_),I=this.paintVertexArray.length;this.paintVertexArray.resize(n),this._setPaintValue(I,n,T,D)}updatePaintArray(n,s,u,p,g){const _=this.expression.evaluate({zoom:this.zoom},u,p,void 0,g),T=this.expression.evaluate({zoom:this.zoom+1},u,p,void 0,g);this._setPaintValue(n,s,_,T)}_setPaintValue(n,s,u,p){if(this.type==="color"){const g=hv(u),_=hv(p);for(let T=n;T!0){this.binders={},this._buffers=[];const p=[];for(const g in n.paint._values){if(!u(g))continue;const _=n.paint.get(g);if(!(_ instanceof E&&As(_.property.specification)))continue;const T=Ak(g,n.type),D=_.value,I=_.property.specification.type,z=_.property.useIntegerZoom,B=_.property.specification["property-type"],N=B==="cross-faded"||B==="cross-faded-data-driven",W=String(g)==="line-dasharray"&&n.layout.get("line-cap").value.kind!=="constant";if(D.kind!=="constant"||W)if(D.kind==="source"||W||N){const K=wb(g,I,"source");this.binders[g]=N?new Fs(D,T,I,z,s,K,n.id):new qa(D,T,I,K),p.push(`/a_${g}`)}else{const K=wb(g,I,"composite");this.binders[g]=new Go(D,T,I,z,s,K),p.push(`/z_${g}`)}else this.binders[g]=N?new Wu(D.value,T):new pp(D.value,T,I),p.push(`/u_${g}`)}this.cacheKey=p.sort().join("")}getMaxValue(n){const s=this.binders[n];return s instanceof qa||s instanceof Go?s.maxValue:0}populatePaintArrays(n,s,u,p,g,_){for(const T in this.binders){const D=this.binders[T];(D instanceof qa||D instanceof Go||D instanceof Fs)&&D.populatePaintArray(n,s,u,p,g,_)}}setConstantPatternPositions(n,s){for(const u in this.binders){const p=this.binders[u];p instanceof Wu&&p.setConstantPatternPositions(n,s)}}updatePaintArrays(n,s,u,p,g,_){let T=!1;for(const D in n){const I=s.getPositions(D);for(const z of I){const B=u.feature(z.index);for(const N in this.binders){const W=this.binders[N];if((W instanceof qa||W instanceof Go||W instanceof Fs)&&W.expression.isStateDependent===!0){const K=p.paint.get(N);W.expression=K.value,W.updatePaintArray(z.start,z.end,B,n[D],g,_),T=!0}}}}return T}defines(){const n=[];for(const s in this.binders){const u=this.binders[s];(u instanceof pp||u instanceof Wu)&&n.push(...u.uniformNames.map(p=>`#define HAS_UNIFORM_${p}`))}return n}getBinderAttributes(){const n=[];for(const s in this.binders){const u=this.binders[s];if(u instanceof qa||u instanceof Go||u instanceof Fs)for(let p=0;p!0){this.programConfigurations={};for(const p of n)this.programConfigurations[p.id]=new Bs(p,s,u);this.needsUpload=!1,this._featureMap=new Tg,this._bufferOffset=0}populatePaintArrays(n,s,u,p,g,_,T){for(const D in this.programConfigurations)this.programConfigurations[D].populatePaintArrays(n,s,p,g,_,T);s.id!==void 0&&this._featureMap.add(s.id,u,this._bufferOffset,n),this._bufferOffset=n,this.needsUpload=!0}updatePaintArrays(n,s,u,p,g){for(const _ of u)this.needsUpload=this.programConfigurations[_.id].updatePaintArrays(n,this._featureMap,s,_,p,g)||this.needsUpload}get(n){return this.programConfigurations[n]}upload(n){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(n);this.needsUpload=!1}}destroy(){for(const n in this.programConfigurations)this.programConfigurations[n].destroy()}}const Ck={"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 Ak(a,n){return Ck[a]||[a.replace(`${n}-`,"").replace(/-/g,"_")]}const Dk={"line-pattern":{source:nt,composite:nt},"fill-pattern":{source:nt,composite:nt},"fill-extrusion-pattern":{source:nt,composite:nt},"line-dasharray":{source:lt,composite:lt}},Pk={color:{source:vi,composite:Ue},number:{source:Yt,composite:vi}};function wb(a,n,s){const u=Dk[a];return u&&u[s]||Pk[n][s]}$t(pp,"ConstantBinder"),$t(Wu,"CrossFadedConstantBinder"),$t(qa,"SourceExpressionBinder"),$t(Fs,"CrossFadedCompositeBinder"),$t(Go,"CompositeExpressionBinder"),$t(Bs,"ProgramConfiguration",{omit:["_buffers"]}),$t(ql,"ProgramConfigurationSet");const Ag="-transition";class Wo extends Fe{constructor(n,s){if(super(),this.id=n.id,this.type=n.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,n.type!=="custom"&&(this.metadata=(n=n).metadata,this.minzoom=n.minzoom,this.maxzoom=n.maxzoom,n.type!=="background"&&n.type!=="sky"&&(this.source=n.source,this.sourceLayer=n["source-layer"],this.filter=n.filter),s.layout&&(this._unevaluatedLayout=new y(s.layout)),s.paint)){this._transitionablePaint=new m(s.paint);for(const u in n.paint)this.setPaintProperty(u,n.paint[u],{validate:!1});for(const u in n.layout)this.setLayoutProperty(u,n.layout[u],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new C(s.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(n){return n==="visibility"?this.visibility:this._unevaluatedLayout.getValue(n)}setLayoutProperty(n,s,u={}){s!=null&&this._validate(av,`layers.${this.id}.layout.${n}`,n,s,u)||(n!=="visibility"?this._unevaluatedLayout.setValue(n,s):this.visibility=s)}getPaintProperty(n){return yt(n,Ag)?this._transitionablePaint.getTransition(n.slice(0,-Ag.length)):this._transitionablePaint.getValue(n)}setPaintProperty(n,s,u={}){if(s!=null&&this._validate(ov,`layers.${this.id}.paint.${n}`,n,s,u))return!1;if(yt(n,Ag))return this._transitionablePaint.setTransition(n.slice(0,-Ag.length),s||void 0),!1;{const p=this._transitionablePaint._values[n],g=p.property.specification["property-type"]==="cross-faded-data-driven",_=p.value.isDataDriven(),T=p.value;this._transitionablePaint.setValue(n,s),this._handleSpecialPaintPropertyUpdate(n);const D=this._transitionablePaint._values[n].value;return D.isDataDriven()||_||g||this._handleOverridablePaintPropertyUpdate(n,T,D)}}_handleSpecialPaintPropertyUpdate(n){}getProgramIds(){return null}getProgramConfiguration(n){return null}_handleOverridablePaintPropertyUpdate(n,s,u){return!1}isHidden(n){return!!(this.minzoom&&n=this.maxzoom)||this.visibility==="none"}updateTransitions(n){this._transitioningPaint=this._transitionablePaint.transitioned(n,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(n,s){n.getCrossfadeParameters&&(this._crossfadeParameters=n.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(n,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(n,void 0,s)}serialize(){const n={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&&(n.layout=n.layout||{},n.layout.visibility=this.visibility),It(n,(s,u)=>!(s===void 0||u==="layout"&&!Object.keys(s).length||u==="paint"&&!Object.keys(s).length))}_validate(n,s,u,p,g={}){return(!g||g.validate!==!1)&&ag(this,n.call(Ol,{key:s,layerType:this.type,objectKey:u,value:p,styleSpec:Te,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const n in this.paint._values){const s=this.paint.get(n);if(s instanceof E&&As(s.property.specification)&&(s.value.kind==="source"||s.value.kind==="composite")&&s.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=ca(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const Sk=Le([{name:"a_pos",components:2,type:"Int16"}],4),Lk=Le([{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(n=[]){this.segments=n}prepareSegment(n,s,u,p){let g=this.segments[this.segments.length-1];return n>Ei.MAX_VERTEX_ARRAY_LENGTH&&be(`Max vertices per segment is ${Ei.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${n}`),(!g||g.vertexLength+n>Ei.MAX_VERTEX_ARRAY_LENGTH||g.sortKey!==p)&&(g={vertexOffset:s.length,primitiveOffset:u.length,vertexLength:0,primitiveLength:0},p!==void 0&&(g.sortKey=p),this.segments.push(g)),g}get(){return this.segments}destroy(){for(const n of this.segments)for(const s in n.vaos)n.vaos[s].destroy()}static simpleSegment(n,s,u,p){return new Ei([{vertexOffset:n,primitiveOffset:s,vertexLength:u,primitiveLength:p,vaos:{},sortKey:0}])}}Ei.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,$t(Ei,"SegmentVector");var In=8192;class Os{constructor(n,s){n&&(s?this.setSouthWest(n).setNorthEast(s):n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1]))}setNorthEast(n){return this._ne=n instanceof ti?new ti(n.lng,n.lat):ti.convert(n),this}setSouthWest(n){return this._sw=n instanceof ti?new ti(n.lng,n.lat):ti.convert(n),this}extend(n){const s=this._sw,u=this._ne;let p,g;if(n instanceof ti)p=n,g=n;else{if(!(n instanceof Os))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(Os.convert(n)):this.extend(ti.convert(n)):this;if(p=n._sw,g=n._ne,!p||!g)return this}return s||u?(s.lng=Math.min(p.lng,s.lng),s.lat=Math.min(p.lat,s.lat),u.lng=Math.max(g.lng,u.lng),u.lat=Math.max(g.lat,u.lat)):(this._sw=new ti(p.lng,p.lat),this._ne=new ti(g.lng,g.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(n){const{lng:s,lat:u}=ti.convert(n);let p=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(p=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=u&&u<=this._ne.lat&&p}static convert(n){return!n||n instanceof Os?n:new Os(n)}}const dv=63710088e-1;class ti{constructor(n,s){if(isNaN(n)||isNaN(s))throw new Error(`Invalid LngLat object: (${n}, ${s})`);if(this.lng=+n,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ti(ie(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(n){const s=Math.PI/180,u=this.lat*s,p=n.lat*s,g=Math.sin(u)*Math.sin(p)+Math.cos(u)*Math.cos(p)*Math.cos((n.lng-this.lng)*s);return dv*Math.acos(Math.min(g,1))}toBounds(n=0){const s=360*n/40075017,u=s/Math.cos(Math.PI/180*this.lat);return new Os(new ti(this.lng-u,this.lat-s),new ti(this.lng+u,this.lat+s))}static convert(n){if(n instanceof ti)return n;if(Array.isArray(n)&&(n.length===2||n.length===3))return new ti(Number(n[0]),Number(n[1]));if(!Array.isArray(n)&&typeof n=="object"&&n!==null)return new ti(Number("lng"in n?n.lng:n.lon),Number(n.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Mb=2*Math.PI*dv;function pv(a){return Mb*Math.cos(a*Math.PI/180)}function fp(a){return(180+a)/360}function ju(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function Hu(a,n){return a/pv(n)}function To(a){return 360*a-180}function rr(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function Tb(a,n){return a*pv(rr(n))}const ma=85.051129;class Dg{constructor(n,s,u=0){this.x=+n,this.y=+s,this.z=+u}static fromLngLat(n,s=0){const u=ti.convert(n);return new Dg(fp(u.lng),ju(u.lat),Hu(s,u.lat))}toLngLat(){return new ti(To(this.x),rr(this.y))}toAltitude(){return Tb(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Mb*(n=rr(this.y),1/Math.cos(n*Math.PI/180));var n}}function fv(a,n,s,u,p,g,_,T,D){const I=(n+u)/2,z=(s+p)/2,B=new b(I,z);T(B),function(N,W,K,oe,ue,xe){const Be=K-ue,$e=oe-xe;return Math.abs((oe-W)*Be-(K-N)*$e)/Math.hypot(Be,$e)}(B.x,B.y,g.x,g.y,_.x,_.y)>=D?(fv(a,n,s,I,z,g,B,T,D),fv(a,I,z,u,p,B,_,T,D)):a.push(_)}function Ik(a,n,s){let u=a[0],p=u.x,g=u.y;n(u);const _=[u];for(let T=1;Ta.x+1||ua.y+1)&&be("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function Xa(a,n,s){const u=a.loadGeometry(),p=a.extent,g=In/p;if(n&&s&&s.projection.isReprojectedInTileSpace){const _=1<{const W=To((n.x+N.x/p)/_),K=rr((n.y+N.y/p)/_),oe=z.project(W,K);N.x=(oe.x*T-D)*p,N.y=(oe.y*T-I)*p};for(let N=0;N=p||K.y<0||K.y>=p||(B(K),W.push(K));u[N]=W}}for(const _ of u)for(const T of _)Rk(T,g);return u}function Xl(a,n){return{type:a.type,id:a.id,properties:a.properties,geometry:n?Xa(a):[]}}function Pg(a,n,s,u,p){a.emplaceBack(2*n+(u+1)/2,2*s+(p+1)/2)}function Sg(a,n,s,u){a.emplaceBack(n.x,n.y,n.z,s[0]*16384,s[1]*16384,s[2]*16384,u)}class gv{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.hasPattern=!1,this.projection=n.projection,this.layoutVertexArray=new De,this.indexArray=new qt,this.segments=new Ei,this.programConfigurations=new ql(n.layers,n.zoom),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id)}populate(n,s,u,p){const g=this.layers[0],_=[];let T=null;g.type==="circle"&&(T=g.layout.get("circle-sort-key"));for(const{feature:I,id:z,index:B,sourceLayerIndex:N}of n){const W=this.layers[0]._featureFilter.needGeometry,K=Xl(I,W);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),K,u))continue;const oe=T?T.evaluate(K,{},u):void 0,ue={id:z,properties:I.properties,type:I.type,sourceLayerIndex:N,index:B,geometry:W?K.geometry:Xa(I,u,p),patterns:{},sortKey:oe};_.push(ue)}T&&_.sort((I,z)=>I.sortKey-z.sortKey);let D=null;p.projection.name==="globe"&&(this.globeExtVertexArray=new Ha,D=p.projection);for(const I of _){const{geometry:z,index:B,sourceLayerIndex:N}=I,W=n[B].feature;this.addFeature(I,z,B,s.availableImages,u,D),s.featureIndex.insert(W,z,B,N,this.index)}}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Sk.members),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=n.createVertexBuffer(this.globeExtVertexArray,Lk.members))),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(n,s,u,p,g,_){for(const T of s)for(const D of T){const I=D.x,z=D.y;if(I<0||I>=In||z<0||z>=In)continue;if(_){const W=_.projectTilePoint(I,z,g),K=_.upVector(g,I,z),oe=rr((z/In+g.y)/(1<1){if(yv(a,n))return!0;for(let u=0;u1?s:s.sub(n)._mult(p)._add(n))}function Pb(a,n){let s,u,p,g=!1;for(let _=0;_n.y!=p.y>n.y&&n.x<(p.x-u.x)*(n.y-u.y)/(p.y-u.y)+u.x&&(g=!g)}return g}function $u(a,n){let s=!1;for(let u=0,p=a.length-1;un.y!=_.y>n.y&&n.x<(_.x-g.x)*(n.y-g.y)/(_.y-g.y)+g.x&&(s=!s)}return s}function Sb(a,n,s,u,p){for(const _ of a)if(n<=_.x&&s<=_.y&&u>=_.x&&p>=_.y)return!0;const g=[new b(n,s),new b(n,p),new b(u,p),new b(u,s)];if(a.length>2){for(const _ of g)if($u(a,_))return!0}for(let _=0;_p.x&&n.x>p.x||a.yp.y&&n.y>p.y)return!1;const g=We(a,n,s[0]);return g!==We(a,n,s[1])||g!==We(a,n,s[2])||g!==We(a,n,s[3])}function qu(a,n,s){const u=n.paint.get(a).value;return u.kind==="constant"?u.value:s.programConfigurations.get(n.id).getMaxValue(a)}function Lg(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function Lb(a,n,s,u,p){if(!n[0]&&!n[1])return a;const g=b.convert(n)._mult(p);s==="viewport"&&g._rotate(-u);const _=[];for(let T=0;T0&&(g=1/Math.sqrt(g)),a[0]=n[0]*g,a[1]=n[1]*g,a[2]=n[2]*g,a}function _p(a,n){return a[0]*n[0]+a[1]*n[1]+a[2]*n[2]}function Nb(a,n,s){var u=n[0],p=n[1],g=n[2],_=s[0],T=s[1],D=s[2];return a[0]=p*D-g*T,a[1]=g*_-u*D,a[2]=u*T-p*_,a}function Yl(a,n,s){var u=n[0],p=n[1],g=n[2],_=s[3]*u+s[7]*p+s[11]*g+s[15];return a[0]=(s[0]*u+s[4]*p+s[8]*g+s[12])/(_=_||1),a[1]=(s[1]*u+s[5]*p+s[9]*g+s[13])/_,a[2]=(s[2]*u+s[6]*p+s[10]*g+s[14])/_,a}function Ub(a,n,s){var u=s[0],p=s[1],g=s[2],_=n[0],T=n[1],D=n[2],I=p*D-g*T,z=g*_-u*D,B=u*T-p*_,N=p*B-g*z,W=g*I-u*B,K=u*z-p*I,oe=2*s[3];return z*=oe,B*=oe,W*=2,K*=2,a[0]=_+(I*=oe)+(N*=2),a[1]=T+z+W,a[2]=D+B+K,a}var vp,Xu=Bb,Vk=Ob,Gk=zb;function Zu(a,n,s){var u=n[0],p=n[1],g=n[2],_=n[3];return a[0]=s[0]*u+s[4]*p+s[8]*g+s[12]*_,a[1]=s[1]*u+s[5]*p+s[9]*g+s[13]*_,a[2]=s[2]*u+s[6]*p+s[10]*g+s[14]*_,a[3]=s[3]*u+s[7]*p+s[11]*g+s[15]*_,a}function Vb(){var a=new Zr(4);return Zr!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function Gb(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function Wb(a,n,s){s*=.5;var u=n[0],p=n[1],g=n[2],_=n[3],T=Math.sin(s),D=Math.cos(s);return a[0]=u*D+_*T,a[1]=p*D+g*T,a[2]=g*D-p*T,a[3]=_*D-u*T,a}Mv(),vp=new Zr(4),Zr!=Float32Array&&(vp[0]=0,vp[1]=0,vp[2]=0,vp[3]=0),Mv(),mp(1,0,0),mp(0,1,0),Vb(),Vb(),Rb();class Av{constructor(n,s){this.points=n,this.planes=s}static fromInvProjectionMatrix(n,s,u,p){const g=Math.pow(2,u),_=[[-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(D=>{const I=Zu([],D,n),z=1/I[3]/s*g;return function(B,N,W){return B[0]=N[0]*W[0],B[1]=N[1]*W[1],B[2]=N[2]*W[2],B[3]=N[3]*W[3],B}(I,I,[z,z,p?1/I[3]:z,z])}),T=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(D=>{const I=yp([],Nb([],Xu([],_[D[0]],_[D[1]]),Xu([],_[D[2]],_[D[1]]))),z=-_p(I,_[D[1]]);return I.concat(z)});return new Av(_,T)}}class go{constructor(n,s){this.min=n,this.max=s,this.center=gp([],Fb([],this.min,this.max),.5)}quadrant(n){const s=[n%2==0,n<2],u=kb(this.min),p=kb(this.max);for(let g=0;g=0;if(_===0)return 0;_!==s.length&&(u=!1)}if(u)return 2;for(let p=0;p<3;p++){let g=Number.MAX_VALUE,_=-Number.MAX_VALUE;for(let T=0;Tthis.max[p]-this.min[p])return 0}return 1}}function jb(a,n,s,u,p,g,_,T,D){if(g&&a.queryGeometry.isAboveHorizon)return!1;g&&(D*=a.pixelToTileUnitsFactor);for(const I of n)for(const z of I){const B=z.add(T),N=p&&s.elevation?s.elevation.exaggeration()*p.getElevationAt(B.x,B.y,!0):0,W=g?B:Wk(B,N,u),K=g?a.tilespaceRays.map(ue=>Hk(ue,N)):a.queryGeometry.screenGeometry,oe=Zu([],[z.x,z.y,N,1],u);if(!_&&g?D*=oe[3]/s.cameraToCenterDistance:_&&!g&&(D*=s.cameraToCenterDistance/oe[3]),kk(K,W,D))return!0}return!1}function Wk(a,n,s){const u=Zu([],[a.x,a.y,n,1],s);return new b(u[0]/u[3],u[1]/u[3])}const Hb=mp(0,0,0),jk=mp(0,0,1);function Hk(a,n){const s=Mv();return Hb[2]=n,a.intersectsPlane(Hb,jk,s),new b(s[0],s[1])}class $b extends gv{}function qb(a,{width:n,height:s},u,p){if(p){if(p instanceof Uint8ClampedArray)p=new Uint8Array(p.buffer);else if(p.length!==n*s*u)throw new RangeError("mismatched image size")}else p=new Uint8Array(n*s*u);return a.width=n,a.height=s,a.data=p,a}function Xb(a,n,s){const{width:u,height:p}=n;u===a.width&&p===a.height||(Dv(a,n,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,u),height:Math.min(a.height,p)},s),a.width=u,a.height=p,a.data=n.data)}function Dv(a,n,s,u,p,g){if(p.width===0||p.height===0)return n;if(p.width>a.width||p.height>a.height||s.x>a.width-p.width||s.y>a.height-p.height)throw new RangeError("out of range source coordinates for image copy");if(p.width>n.width||p.height>n.height||u.x>n.width-p.width||u.y>n.height-p.height)throw new RangeError("out of range destination coordinates for image copy");const _=a.data,T=n.data;for(let D=0;D{n[a.evaluationKey]=D;const I=a.expression.evaluate(n);p.data[_+T+0]=Math.floor(255*I.r/I.a),p.data[_+T+1]=Math.floor(255*I.g/I.a),p.data[_+T+2]=Math.floor(255*I.b/I.a),p.data[_+T+3]=Math.floor(255*I.a)};if(a.clips)for(let _=0,T=0;_80*s){u=g=a[0],p=_=a[1];for(var K=s;Kg&&(g=T),D>_&&(_=D);I=(I=Math.max(g-u,_-p))!==0?1/I:0}return xp(N,W,s,u,p,I),W}function Zb(a,n,s,u,p){var g,_;if(p===Iv(a,n,s,u)>0)for(g=n;g=n;g-=u)_=Jb(g,a[g],a[g+1],_);return _&&kg(_,_.next)&&(wp(_),_=_.next),_}function Us(a,n){if(!a)return a;n||(n=a);var s,u=a;do if(s=!1,u.steiner||!kg(u,u.next)&&Li(u.prev,u,u.next)!==0)u=u.next;else{if(wp(u),(u=n=u.prev)===u.next)break;s=!0}while(s||u!==n);return n}function xp(a,n,s,u,p,g,_){if(a){!_&&g&&function(z,B,N,W){var K=z;do K.z===null&&(K.z=Sv(K.x,K.y,B,N,W)),K.prevZ=K.prev,K.nextZ=K.next,K=K.next;while(K!==z);K.prevZ.nextZ=null,K.prevZ=null,function(oe){var ue,xe,Be,$e,Ze,Ye,Ke,ut,dt=1;do{for(xe=oe,oe=null,Ze=null,Ye=0;xe;){for(Ye++,Be=xe,Ke=0,ue=0;ue0||ut>0&&Be;)Ke!==0&&(ut===0||!Be||xe.z<=Be.z)?($e=xe,xe=xe.nextZ,Ke--):($e=Be,Be=Be.nextZ,ut--),Ze?Ze.nextZ=$e:oe=$e,$e.prevZ=Ze,Ze=$e;xe=Be}Ze.nextZ=null,dt*=2}while(Ye>1)}(K)}(a,u,p,g);for(var T,D,I=a;a.prev!==a.next;)if(T=a.prev,D=a.next,g?Jk(a,u,p,g):Kk(a))n.push(T.i/s),n.push(a.i/s),n.push(D.i/s),wp(a),a=D.next,I=D.next;else if((a=D)===I){_?_===1?xp(a=Qk(Us(a),n,s),n,s,u,p,g,2):_===2&&ez(a,n,s,u,p,g):xp(Us(a),n,s,u,p,g,1);break}}}function Kk(a){var n=a.prev,s=a,u=a.next;if(Li(n,s,u)>=0)return!1;for(var p=a.next.next;p!==a.prev;){if(Yu(n.x,n.y,s.x,s.y,u.x,u.y,p.x,p.y)&&Li(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Jk(a,n,s,u){var p=a.prev,g=a,_=a.next;if(Li(p,g,_)>=0)return!1;for(var T=p.x>g.x?p.x>_.x?p.x:_.x:g.x>_.x?g.x:_.x,D=p.y>g.y?p.y>_.y?p.y:_.y:g.y>_.y?g.y:_.y,I=Sv(p.x=I&&N&&N.z<=z;){if(B!==a.prev&&B!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,B.x,B.y)&&Li(B.prev,B,B.next)>=0||(B=B.prevZ,N!==a.prev&&N!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,N.x,N.y)&&Li(N.prev,N,N.next)>=0))return!1;N=N.nextZ}for(;B&&B.z>=I;){if(B!==a.prev&&B!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,B.x,B.y)&&Li(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;N&&N.z<=z;){if(N!==a.prev&&N!==a.next&&Yu(p.x,p.y,g.x,g.y,_.x,_.y,N.x,N.y)&&Li(N.prev,N,N.next)>=0)return!1;N=N.nextZ}return!0}function Qk(a,n,s){var u=a;do{var p=u.prev,g=u.next.next;!kg(p,g)&&Yb(p,u,u.next,g)&&bp(p,g)&&bp(g,p)&&(n.push(p.i/s),n.push(u.i/s),n.push(g.i/s),wp(u),wp(u.next),u=a=g),u=u.next}while(u!==a);return Us(u)}function ez(a,n,s,u,p,g){var _=a;do{for(var T=_.next.next;T!==_.prev;){if(_.i!==T.i&&oz(_,T)){var D=Kb(_,T);return _=Us(_,_.next),D=Us(D,D.next),xp(_,n,s,u,p,g),void xp(D,n,s,u,p,g)}T=T.next}_=_.next}while(_!==a)}function tz(a,n){return a.x-n.x}function nz(a,n){var s=function(g,_){var T,D=_,I=g.x,z=g.y,B=-1/0;do{if(z<=D.y&&z>=D.next.y&&D.next.y!==D.y){var N=D.x+(z-D.y)*(D.next.x-D.x)/(D.next.y-D.y);if(N<=I&&N>B){if(B=N,N===I){if(z===D.y)return D;if(z===D.next.y)return D.next}T=D.x=D.x&&D.x>=oe&&I!==D.x&&Yu(zT.x||D.x===T.x&&iz(T,D)))&&(T=D,xe=W)),D=D.next;while(D!==K);return T}(a,n);if(!s)return n;var u=Kb(s,a),p=Us(s,s.next);return Us(u,u.next),n===s?p:n}function iz(a,n){return Li(a.prev,a,n.prev)<0&&Li(n.next,a,a.next)<0}function Sv(a,n,s,u,p){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-s)*p)|a<<8))|a<<4))|a<<2))|a<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-u)*p)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function rz(a){var n=a,s=a;do(n.x=0&&(a-_)*(u-T)-(s-_)*(n-T)>=0&&(s-_)*(g-T)-(p-_)*(u-T)>=0}function oz(a,n){return a.next.i!==n.i&&a.prev.i!==n.i&&!function(s,u){var p=s;do{if(p.i!==s.i&&p.next.i!==s.i&&p.i!==u.i&&p.next.i!==u.i&&Yb(p,p.next,s,u))return!0;p=p.next}while(p!==s);return!1}(a,n)&&(bp(a,n)&&bp(n,a)&&function(s,u){var p=s,g=!1,_=(s.x+u.x)/2,T=(s.y+u.y)/2;do p.y>T!=p.next.y>T&&p.next.y!==p.y&&_<(p.next.x-p.x)*(T-p.y)/(p.next.y-p.y)+p.x&&(g=!g),p=p.next;while(p!==s);return g}(a,n)&&(Li(a.prev,a,n.prev)||Li(a,n.prev,n))||kg(a,n)&&Li(a.prev,a,a.next)>0&&Li(n.prev,n,n.next)>0)}function Li(a,n,s){return(n.y-a.y)*(s.x-n.x)-(n.x-a.x)*(s.y-n.y)}function kg(a,n){return a.x===n.x&&a.y===n.y}function Yb(a,n,s,u){var p=Fg(Li(a,n,s)),g=Fg(Li(a,n,u)),_=Fg(Li(s,u,a)),T=Fg(Li(s,u,n));return p!==g&&_!==T||!(p!==0||!zg(a,s,n))||!(g!==0||!zg(a,u,n))||!(_!==0||!zg(s,a,u))||!(T!==0||!zg(s,n,u))}function zg(a,n,s){return n.x<=Math.max(a.x,s.x)&&n.x>=Math.min(a.x,s.x)&&n.y<=Math.max(a.y,s.y)&&n.y>=Math.min(a.y,s.y)}function Fg(a){return a>0?1:a<0?-1:0}function bp(a,n){return Li(a.prev,a,a.next)<0?Li(a,n,a.next)>=0&&Li(a,a.prev,n)>=0:Li(a,n,a.prev)<0||Li(a,a.next,n)<0}function Kb(a,n){var s=new Lv(a.i,a.x,a.y),u=new Lv(n.i,n.x,n.y),p=a.next,g=n.prev;return a.next=n,n.prev=a,s.next=p,p.prev=s,u.next=s,s.prev=u,g.next=u,u.prev=g,u}function Jb(a,n,s,u){var p=new Lv(a,n,s);return u?(p.next=u.next,p.prev=u,u.next.prev=p,u.next=p):(p.prev=p,p.next=p),p}function wp(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 Lv(a,n,s){this.i=a,this.x=n,this.y=s,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Iv(a,n,s,u){for(var p=0,g=n,_=s-u;gs;){if(u-s>600){var g=u-s+1,_=n-s+1,T=Math.log(g),D=.5*Math.exp(2*T/3),I=.5*Math.sqrt(T*D*(g-D)/g)*(_-g/2<0?-1:1);Qb(a,n,Math.max(s,Math.floor(n-_*D/g+I)),Math.min(u,Math.floor(n+(g-_)*D/g+I)),p)}var z=a[n],B=s,N=u;for(Mp(a,s,n),p(a[u],z)>0&&Mp(a,s,u);B0;)N--}p(a[s],z)===0?Mp(a,s,N):Mp(a,++N,u),N<=n&&(s=N+1),n<=N&&(u=N-1)}}function Mp(a,n,s){var u=a[n];a[n]=a[s],a[s]=u}function sz(a,n){return an?1:0}function Rv(a,n){const s=a.length;if(s<=1)return[a];const u=[];let p,g;for(let _=0;_1)for(let _=0;_0&&s.holes.push(u+=a[p-1].length)}return s},Ig.default=Yk;class Bg{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new De,this.indexArray=new qt,this.indexArray2=new Mn,this.programConfigurations=new ql(n.layers,n.zoom),this.segments=new Ei,this.segments2=new Ei,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.projection=n.projection}populate(n,s,u,p){this.hasPattern=kv("fill",this.layers,s);const g=this.layers[0].layout.get("fill-sort-key"),_=[];for(const{feature:T,id:D,index:I,sourceLayerIndex:z}of n){const B=this.layers[0]._featureFilter.needGeometry,N=Xl(T,B);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),N,u))continue;const W=g?g.evaluate(N,{},u,s.availableImages):void 0,K={id:D,properties:T.properties,type:T.type,sourceLayerIndex:z,index:I,geometry:B?N.geometry:Xa(T,u,p),patterns:{},sortKey:W};_.push(K)}g&&_.sort((T,D)=>T.sortKey-D.sortKey);for(const T of _){const{geometry:D,index:I,sourceLayerIndex:z}=T;if(this.hasPattern){const B=zv("fill",this.layers,T,this.zoom,s);this.patternFeatures.push(B)}else this.addFeature(T,D,I,u,{},s.availableImages);s.featureIndex.insert(n[I].feature,D,I,z,this.index)}}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}addFeatures(n,s,u,p,g){for(const _ of this.patternFeatures)this.addFeature(_,_.geometry,_.index,s,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Zk),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.indexBuffer2=n.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(n),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(n,s,u,p,g,_=[]){for(const T of Rv(s,500)){let D=0;for(const K of T)D+=K.length;const I=this.segments.prepareSegment(D,this.layoutVertexArray,this.indexArray),z=I.vertexLength,B=[],N=[];for(const K of T){if(K.length===0)continue;K!==T[0]&&N.push(B.length/2);const oe=this.segments2.prepareSegment(K.length,this.layoutVertexArray,this.indexArray2),ue=oe.vertexLength;this.layoutVertexArray.emplaceBack(K[0].x,K[0].y),this.indexArray2.emplaceBack(ue+K.length-1,ue),B.push(K[0].x),B.push(K[0].y);for(let xe=1;xe>3}if(p--,u===1||u===2)g+=a.readSVarint(),_+=a.readSVarint(),u===1&&(n&&T.push(n),n=[]),n.push(new b(g,_));else{if(u!==7)throw new Error("unknown command "+u);n&&n.push(n[0].clone())}}return n&&T.push(n),T},Ku.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var n=a.readVarint()+a.pos,s=1,u=0,p=0,g=0,_=1/0,T=-1/0,D=1/0,I=-1/0;a.pos>3}if(u--,s===1||s===2)(p+=a.readSVarint())<_&&(_=p),p>T&&(T=p),(g+=a.readSVarint())I&&(I=g);else if(s!==7)throw new Error("unknown command "+s)}return[_,D,T,I]},Ku.prototype.toGeoJSON=function(a,n,s){var u,p,g=this.extent*Math.pow(2,s),_=this.extent*a,T=this.extent*n,D=this.loadGeometry(),I=Ku.types[this.type];function z(W){for(var K=0;K>3;p=_===1?u.readString():_===2?u.readFloat():_===3?u.readDouble():_===4?u.readVarint64():_===5?u.readVarint():_===6?u.readSVarint():_===7?u.readBoolean():null}return p}(s))}function _z(a,n,s){if(a===3){var u=new tw(s,s.readVarint()+s.pos);u.length&&(n[u.name]=u)}}nw.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 n=this._pbf.readVarint()+this._pbf.pos;return new ew(this._pbf,n,this.extent,this._keys,this._values)};var Kl={VectorTile:function(a,n){this.layers=a.readFields(_z,{},n)},VectorTileFeature:ew,VectorTileLayer:tw};function Og(a,n,s,u){const p=[],g=u===0?(_,T,D,I,z,B)=>{_.push(new b(B,D+(B-T)/(I-T)*(z-D)))}:(_,T,D,I,z,B)=>{_.push(new b(T+(B-D)/(z-D)*(I-T),B))};for(const _ of a){const T=[];for(const D of _){if(D.length<=2)continue;const I=[];for(let N=0;Nn&&g(I,W,K,oe,ue,n):xe>s?Be=n&&g(I,W,K,oe,ue,n),Be>s&&xe<=s&&g(I,W,K,oe,ue,s)}let z=D[D.length-1];const B=u===0?z.x:z.y;B>=n&&B<=s&&I.push(z),I.length&&(z=I[I.length-1],I[0].x===z.x&&I[0].y===z.y||I.push(I[0]),T.push(I))}T.length&&p.push(T)}return p}const vz=Kl.VectorTileFeature.types,xz=Math.pow(2,13);function Tp(a,n,s,u,p,g,_,T){a.emplaceBack((n<<1)+_,(s<<1)+g,(Math.floor(u*xz)<<1)+p,Math.round(T))}function Ep(a,n,s){a.emplaceBack(n.x,n.y,n.z,s[0]*16384,s[1]*16384,s[2]*16384)}class iw{constructor(){this.acc=new b(0,0),this.polyCount=[]}startRing(n){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new b(n.x,n.y),this.max=new b(n.x,n.y))}append(n,s){this.currentPolyCount.edges++,this.acc._add(n);const u=this.min,p=this.max;n.xp.x&&(p.x=n.x),n.yp.y&&(p.y=n.y),((n.x===0||n.x===In)&&n.x===s.x)!=((n.y===0||n.y===In)&&n.y===s.y)&&this.processBorderOverlap(n,s),s.x<0!=n.x<0&&this.addBorderIntersection(0,yn(s.y,n.y,(0-s.x)/(n.x-s.x))),s.x>In!=n.x>In&&this.addBorderIntersection(1,yn(s.y,n.y,(In-s.x)/(n.x-s.x))),s.y<0!=n.y<0&&this.addBorderIntersection(2,yn(s.x,n.x,(0-s.y)/(n.y-s.y))),s.y>In!=n.y>In&&this.addBorderIntersection(3,yn(s.x,n.x,(In-s.y)/(n.y-s.y)))}addBorderIntersection(n,s){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 u=this.borders[n];su[1]&&(u[1]=s)}processBorderOverlap(n,s){if(n.x===s.x){if(n.y===s.y)return;const u=n.x===0?0:1;this.addBorderIntersection(u,s.y),this.addBorderIntersection(u,n.y)}else{const u=n.y===0?2:3;this.addBorderIntersection(u,s.x),this.addBorderIntersection(u,n.x)}}centroid(){const n=this.polyCount.reduce((s,u)=>s+u.edges,0);return n!==0?this.acc.div(n)._round():new b(0,0)}span(){return new b(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((n,s)=>n+ +(s[0]!==Number.MAX_VALUE),0)}}class Cp{constructor(n){this.zoom=n.zoom,this.canonical=n.canonical,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(s=>s.id),this.index=n.index,this.hasPattern=!1,this.projection=n.projection,this.layoutVertexArray=new ze,this.centroidVertexArray=new $l,this.indexArray=new qt,this.programConfigurations=new ql(n.layers,n.zoom),this.segments=new Ei,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.enableTerrain=n.enableTerrain}populate(n,s,u,p){this.features=[],this.hasPattern=kv("fill-extrusion",this.layers,s),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(g){const _=Math.exp(Math.PI*(1-g.y/(1<=0;oe--){const ue=N[oe];(ue.length===0||(W=ue[0]).every(xe=>xe.x<=0)||W.every(xe=>xe.x>=In)||W.every(xe=>xe.y<=0)||W.every(xe=>xe.y>=In))&&N.splice(oe,1)}var W;let K;if(z){const ue=1<{for(const Qt of An)st.push({polygon:Qt,bounds:Fn})},Pt=Math.ceil(Math.log2(ut)),Bt=Math.ceil(Math.log2(dt)),Rt=Pt-Bt,Ft=[];for(let An=0;An0?0:1);for(let An=0;AnFn+1?Un.push({polygons:Oi,bounds:Wn,depth:Fn+1}):mt(Oi,Wn)}if(Jn.length){const Wn=[new b(Qt===0?ui:Ht.x,Qt===1?ui:Ht.y),Vn];Ft.length>Fn+1?Un.push({polygons:Jn,bounds:Wn,depth:Fn+1}):mt(Jn,Wn)}}return st}(N,D,Math.ceil((Be-xe)/11.25),Math.ceil(($e-Ze)/11.25),1,(Ye,Ke,ut)=>{if(Ye===0)return .5*(Ke+ut);{const dt=rr((p.y+Ke/In)/ue);return(ju(.5*(rr((p.y+ut/In)/ue)+dt))*ue-p.y)*In}})}else{K=[];for(const oe of N)K.push({polygon:oe,bounds:D})}for(const oe of K){const ue=oe.polygon;let xe=0,Be=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let ut=0;ut=1){const mt=dt[Et-1];if(!bz(st,mt,oe.bounds)){B&&B.append(st,mt),Be.vertexLength+4>Ei.MAX_VERTEX_ARRAY_LENGTH&&(Be=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Pt=st.sub(mt)._perp(),Bt=Pt.x/(Math.abs(Pt.x)+Math.abs(Pt.y)),Rt=Pt.y>0?1:0,Ft=mt.dist(st);xt+Ft>32768&&(xt=0),Tp(this.layoutVertexArray,st.x,st.y,Bt,Rt,0,0,xt),Tp(this.layoutVertexArray,st.x,st.y,Bt,Rt,0,1,xt),xt+=Ft,Tp(this.layoutVertexArray,mt.x,mt.y,Bt,Rt,0,0,xt),Tp(this.layoutVertexArray,mt.x,mt.y,Bt,Rt,0,1,xt);const En=Be.vertexLength;if(this.indexArray.emplaceBack(En,En+2,En+1),this.indexArray.emplaceBack(En+1,En+2,En+3),Be.vertexLength+=4,Be.primitiveLength+=2,z){const Un=this.layoutVertexExtArray,An=I.projectTilePoint(st.x,st.y,p),Fn=I.projectTilePoint(mt.x,mt.y,p),Qt=I.upVector(p,st.x,st.y),Ht=I.upVector(p,mt.x,mt.y);Ep(Un,An,Qt),Ep(Un,An,Qt),Ep(Un,Fn,Ht),Ep(Un,Fn,Ht)}}}}}if(Be.vertexLength+xe>Ei.MAX_VERTEX_ARRAY_LENGTH&&(Be=this.segments.prepareSegment(xe,this.layoutVertexArray,this.indexArray)),vz[n.type]!=="Polygon")continue;const $e=[],Ze=[],Ye=Be.vertexLength;for(let ut=0;ut0){if(B.borders){B.vertexArrayOffset=this.centroidVertexArray.length;const oe=B.borders,ue=this.featuresOnBorder.push(B)-1;for(let xe=0;xe<4;xe++)oe[xe][0]!==Number.MAX_VALUE&&this.borders[xe].push(ue)}this.encodeCentroid(B.borders?void 0:B.centroid(),B)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,u,g,_,p)}sortBorders(){for(let n=0;n<4;n++)this.borders[n].sort((s,u)=>this.featuresOnBorder[s].borders[n][0]-this.featuresOnBorder[u].borders[n][0])}encodeCentroid(n,s,u=!0){let p,g;if(n)if(n.y!==0){const T=s.span()._mult(this.tileToMeter);p=(Math.max(n.x,1)<<3)+Math.min(7,Math.round(T.x/10)),g=(Math.max(n.y,1)<<3)+Math.min(7,Math.round(T.y/10))}else p=Math.ceil(7*(n.x+450)),g=0;else p=0,g=+u;let _=u?this.centroidVertexArray.length:s.vertexArrayOffset;for(const T of s.polyCount){u&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*T.edges+T.top);for(let D=0;D<2*T.edges;D++)this.centroidVertexArray.emplace(_++,0,g),this.centroidVertexArray.emplace(_++,p,g);for(let D=0;Ds[1].x)||a.y===n.y&&(a.ys[1].y)}$t(Cp,"FillExtrusionBucket",{omit:["layers","features"]}),$t(iw,"PartMetadata");var wz={paint:new Z({"fill-extrusion-opacity":new S(Te["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new k(Te["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new S(Te["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new S(Te["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new O(Te["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new k(Te["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new k(Te["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new S(Te["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Ap(a,n){return a.x*n.x+a.y*n.y}function rw(a,n){if(a.length===1){let s=0;const u=n[s++];let p;for(;!p||u.equals(p);)if(p=n[s++],!p)return 1/0;for(;ss.id),this.index=n.index,this.projection=n.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(s=>{this.gradients[s.id]={}}),this.layoutVertexArray=new Ee,this.layoutVertexArray2=new kt,this.indexArray=new qt,this.programConfigurations=new ql(n.layers,n.zoom),this.segments=new Ei,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id)}populate(n,s,u,p){this.hasPattern=kv("line",this.layers,s);const g=this.layers[0].layout.get("line-sort-key"),_=[];for(const{feature:z,id:B,index:N,sourceLayerIndex:W}of n){const K=this.layers[0]._featureFilter.needGeometry,oe=Xl(z,K);if(!this.layers[0]._featureFilter.filter(new ci(this.zoom),oe,u))continue;const ue=g?g.evaluate(oe,{},u):void 0,xe={id:B,properties:z.properties,type:z.type,sourceLayerIndex:W,index:N,geometry:K?oe.geometry:Xa(z,u,p),patterns:{},sortKey:ue};_.push(xe)}g&&_.sort((z,B)=>z.sortKey-B.sortKey);const{lineAtlas:T,featureIndex:D}=s,I=this.addConstantDashes(T);for(const z of _){const{geometry:B,index:N,sourceLayerIndex:W}=z;if(I&&this.addFeatureDashes(z,T),this.hasPattern){const K=zv("line",this.layers,z,this.zoom,s);this.patternFeatures.push(K)}else this.addFeature(z,B,N,u,T.positions,s.availableImages);D.insert(n[N].feature,B,N,W,this.index)}}addConstantDashes(n){let s=!1;for(const u of this.layers){const p=u.paint.get("line-dasharray").value,g=u.layout.get("line-cap").value;if(p.kind!=="constant"||g.kind!=="constant")s=!0;else{const _=g.value,T=p.value;if(!T)continue;n.addDash(T.from,_),n.addDash(T.to,_),T.other&&n.addDash(T.other,_)}}return s}addFeatureDashes(n,s){const u=this.zoom;for(const p of this.layers){const g=p.paint.get("line-dasharray").value,_=p.layout.get("line-cap").value;if(g.kind==="constant"&&_.kind==="constant")continue;let T,D,I,z,B,N;if(g.kind==="constant"){const ue=g.value;if(!ue)continue;T=ue.other||ue.to,D=ue.to,I=ue.from}else T=g.evaluate({zoom:u-1},n),D=g.evaluate({zoom:u},n),I=g.evaluate({zoom:u+1},n);_.kind==="constant"?z=B=N=_.value:(z=_.evaluate({zoom:u-1},n),B=_.evaluate({zoom:u},n),N=_.evaluate({zoom:u+1},n)),s.addDash(T,z),s.addDash(D,B),s.addDash(I,N);const W=s.getKey(T,z),K=s.getKey(D,B),oe=s.getKey(I,N);n.patterns[p.id]={min:W,mid:K,max:oe}}}update(n,s,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,s,this.stateDependentLayers,u,p)}addFeatures(n,s,u,p,g){for(const _ of this.patternFeatures)this.addFeature(_,_.geometry,_.index,s,u,p)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=n.createVertexBuffer(this.layoutVertexArray2,Az)),this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Ez),this.indexBuffer=n.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(n){if(n.properties&&n.properties.hasOwnProperty("mapbox_clip_start")&&n.properties.hasOwnProperty("mapbox_clip_end"))return{start:+n.properties.mapbox_clip_start,end:+n.properties.mapbox_clip_end}}addFeature(n,s,u,p,g,_){const T=this.layers[0].layout,D=T.get("line-join").evaluate(n,{}),I=T.get("line-cap").evaluate(n,{}),z=T.get("line-miter-limit"),B=T.get("line-round-limit");this.lineClips=this.lineFeatureClips(n);for(const N of s)this.addLine(N,n,D,I,z,B);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,u,g,_,p)}addLine(n,s,u,p,g,_){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let xe=0;xe=2&&n[D-1].equals(n[D-2]);)D--;let I=0;for(;I0;if(ut&&xe>I){const st=N.dist(W);if(st>2*z){const mt=N.sub(N.sub(W)._mult(z/st)._round());this.updateDistance(W,mt),this.addCurrentVertex(mt,oe,0,0,B),W=mt}}const xt=W&&K;let Et=xt?u:T?"butt":p;if(xt&&Et==="round"&&(Ye<_?Et="miter":Ye<=2&&(Et="fakeround")),Et==="miter"&&Ye>g&&(Et="bevel"),Et==="bevel"&&(Ye>2&&(Et="flipbevel"),Ye100)Be=ue.mult(-1);else{const st=Ye*oe.add(ue).mag()/oe.sub(ue).mag();Be._perp()._mult(st*(dt?-1:1))}this.addCurrentVertex(N,Be,0,0,B),this.addCurrentVertex(N,Be.mult(-1),0,0,B)}else if(Et==="bevel"||Et==="fakeround"){const st=-Math.sqrt(Ye*Ye-1),mt=dt?st:0,Pt=dt?0:st;if(W&&this.addCurrentVertex(N,oe,mt,Pt,B),Et==="fakeround"){const Bt=Math.round(180*Ke/Math.PI/20);for(let Rt=1;Rt2*z){const mt=N.add(K.sub(N)._mult(z/st)._round());this.updateDistance(N,mt),this.addCurrentVertex(mt,ue,0,0,B),N=mt}}}}addCurrentVertex(n,s,u,p,g,_=!1){const T=s.y*p-s.x,D=-s.y-s.x*p;this.addHalfVertex(n,s.x+s.y*u,s.y-s.x*u,_,!1,u,g),this.addHalfVertex(n,T,D,_,!0,-p,g)}addHalfVertex({x:n,y:s},u,p,g,_,T,D){this.layoutVertexArray.emplaceBack((n<<1)+(g?1:0),(s<<1)+(_?1:0),Math.round(63*u)+128,Math.round(63*p)+128,1+(T===0?0:T<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const I=D.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,I),D.primitiveLength++),_?this.e2=I:this.e1=I}updateScaledDistance(){if(this.lineClips){const n=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=n*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(n,s){this.distance+=n.dist(s),this.updateScaledDistance()}}$t(Ng,"LineBucket",{omit:["layers","patternFeatures"]});const Sz=new Z({"line-cap":new k(Te.layout_line["line-cap"]),"line-join":new k(Te.layout_line["line-join"]),"line-miter-limit":new S(Te.layout_line["line-miter-limit"]),"line-round-limit":new S(Te.layout_line["line-round-limit"]),"line-sort-key":new k(Te.layout_line["line-sort-key"])});var aw={paint:new Z({"line-opacity":new k(Te.paint_line["line-opacity"]),"line-color":new k(Te.paint_line["line-color"]),"line-translate":new S(Te.paint_line["line-translate"]),"line-translate-anchor":new S(Te.paint_line["line-translate-anchor"]),"line-width":new k(Te.paint_line["line-width"]),"line-gap-width":new k(Te.paint_line["line-gap-width"]),"line-offset":new k(Te.paint_line["line-offset"]),"line-blur":new k(Te.paint_line["line-blur"]),"line-dasharray":new O(Te.paint_line["line-dasharray"]),"line-pattern":new O(Te.paint_line["line-pattern"]),"line-gradient":new G(Te.paint_line["line-gradient"])}),layout:Sz};const sw=new class extends k{possiblyEvaluate(a,n){return n=new ci(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),super.possiblyEvaluate(a,n)}evaluate(a,n,s,u){return n=me({},n,{zoom:Math.floor(n.zoom)}),super.evaluate(a,n,s,u)}}(aw.paint.properties["line-width"].specification);function lw(a,n){return n>0?n+2*a:a}sw.useIntegerZoom=!0;const Lz=Le([{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),Iz=Le([{name:"a_projected_pos",components:3,type:"Float32"}],4);Le([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Rz=Le([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),kz=Le([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Le([{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 cw=Le([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),zz=Le([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Le([{name:"triangle",components:3,type:"Uint16"}]),Le([{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"}]),Le([{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"}]),Le([{type:"Float32",name:"offsetX"}]),Le([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var or=24;const ya=128;function Fv(a,n){const{expression:s}=n;if(s.kind==="constant")return{kind:"constant",layoutSize:s.evaluate(new ci(a+1))};if(s.kind==="source")return{kind:"source"};{const{zoomStops:u,interpolationType:p}=s;let g=0;for(;g{u.text=function(p,g,_){const T=g.layout.get("text-transform").evaluate(_,{});return T==="uppercase"?p=p.toLocaleUpperCase():T==="lowercase"&&(p=p.toLocaleLowerCase()),qr.applyArabicShaping&&(p=qr.applyArabicShaping(p)),p}(u.text,n,s)}),a}const Dp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function Oz(a){return a==="︶"||a==="﹈"||a==="︸"||a==="﹄"||a==="﹂"||a==="︾"||a==="︼"||a==="︺"||a==="︘"||a==="﹀"||a==="︐"||a==="︓"||a==="︔"||a==="`"||a===" ̄"||a==="︑"||a==="︒"}function Nz(a){return a==="︵"||a==="﹇"||a==="︷"||a==="﹃"||a==="﹁"||a==="︽"||a==="︻"||a==="︹"||a==="︗"||a==="︿"}var uw=function(a,n,s,u,p){var g,_,T=8*p-u-1,D=(1<>1,z=-7,B=s?p-1:0,N=s?-1:1,W=a[n+B];for(B+=N,g=W&(1<<-z)-1,W>>=-z,z+=T;z>0;g=256*g+a[n+B],B+=N,z-=8);for(_=g&(1<<-z)-1,g>>=-z,z+=u;z>0;_=256*_+a[n+B],B+=N,z-=8);if(g===0)g=1-I;else{if(g===D)return _?NaN:1/0*(W?-1:1);_+=Math.pow(2,u),g-=I}return(W?-1:1)*_*Math.pow(2,g-u)},hw=function(a,n,s,u,p,g){var _,T,D,I=8*g-p-1,z=(1<>1,N=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,W=u?0:g-1,K=u?1:-1,oe=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(T=isNaN(n)?1:0,_=z):(_=Math.floor(Math.log(n)/Math.LN2),n*(D=Math.pow(2,-_))<1&&(_--,D*=2),(n+=_+B>=1?N/D:N*Math.pow(2,1-B))*D>=2&&(_++,D/=2),_+B>=z?(T=0,_=z):_+B>=1?(T=(n*D-1)*Math.pow(2,p),_+=B):(T=n*Math.pow(2,B-1)*Math.pow(2,p),_=0));p>=8;a[s+W]=255&T,W+=K,T/=256,p-=8);for(_=_<0;a[s+W]=255&_,W+=K,_/=256,I-=8);a[s+W-K]|=128*oe},Pp=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 Bv=4294967296,dw=1/Bv,pw=typeof TextDecoder=="undefined"?null:new TextDecoder("utf8");function Ya(a){return a.type===si.Bytes?a.readVarint()+a.pos:a.pos+1}function Qu(a,n,s){return s?4294967296*n+(a>>>0):4294967296*(n>>>0)+(a>>>0)}function fw(a,n,s){var u=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));s.realloc(u);for(var p=s.pos-1;p>=a;p--)s.buf[p+u]=s.buf[p]}function Uz(a,n){for(var s=0;s>>8,a[s+2]=n>>>16,a[s+3]=n>>>24}function mw(a,n){return(a[n]|a[n+1]<<8|a[n+2]<<16)+(a[n+3]<<24)}function Zz(a,n,s){n.glyphs=[],a===1&&s.readMessage(Yz,n)}function Yz(a,n,s){if(a===3){const{id:u,bitmap:p,width:g,height:_,left:T,top:D,advance:I}=s.readMessage(Kz,{});n.glyphs.push({id:u,bitmap:new Za({width:g+6,height:_+6},p),metrics:{width:g,height:_,left:T,top:D,advance:I}})}else a===4?n.ascender=s.readSVarint():a===5&&(n.descender=s.readSVarint())}function Kz(a,n,s){a===1?n.id=s.readVarint():a===2?n.bitmap=s.readBytes():a===3?n.width=s.readVarint():a===4?n.height=s.readVarint():a===5?n.left=s.readSVarint():a===6?n.top=s.readSVarint():a===7&&(n.advance=s.readVarint())}function Ov(a){let n=0,s=0;for(const _ of a)n+=_.w*_.h,s=Math.max(s,_.w);a.sort((_,T)=>T.h-_.h);const u=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),s),h:1/0}];let p=0,g=0;for(const _ of a)for(let T=u.length-1;T>=0;T--){const D=u[T];if(!(_.w>D.w||_.h>D.h)){if(_.x=D.x,_.y=D.y,g=Math.max(g,_.y+_.h),p=Math.max(p,_.x+_.w),_.w===D.w&&_.h===D.h){const I=u.pop();T>3,g=this.pos;this.type=7&u,a(p,n,this),this.pos===g&&this.skip(u)}return n},readMessage:function(a,n){return this.readFields(a,n,this.readVarint()+this.pos)},readFixed32:function(){var a=Vg(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=mw(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=Vg(this.buf,this.pos)+Vg(this.buf,this.pos+4)*Bv;return this.pos+=8,a},readSFixed64:function(){var a=Vg(this.buf,this.pos)+mw(this.buf,this.pos+4)*Bv;return this.pos+=8,a},readFloat:function(){var a=uw(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=uw(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var n,s,u=this.buf;return n=127&(s=u[this.pos++]),s<128?n:(n|=(127&(s=u[this.pos++]))<<7,s<128?n:(n|=(127&(s=u[this.pos++]))<<14,s<128?n:(n|=(127&(s=u[this.pos++]))<<21,s<128?n:function(p,g,_){var T,D,I=_.buf;if(T=(112&(D=I[_.pos++]))>>4,D<128||(T|=(127&(D=I[_.pos++]))<<3,D<128)||(T|=(127&(D=I[_.pos++]))<<10,D<128)||(T|=(127&(D=I[_.pos++]))<<17,D<128)||(T|=(127&(D=I[_.pos++]))<<24,D<128)||(T|=(1&(D=I[_.pos++]))<<31,D<128))return Qu(p,T,g);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(s=u[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,n=this.pos;return this.pos=a,a-n>=12&&pw?function(s,u,p){return pw.decode(s.subarray(u,p))}(this.buf,n,a):function(s,u,p){for(var g="",_=u;_239?4:z>223?3:z>191?2:1;if(_+N>p)break;N===1?z<128&&(B=z):N===2?(192&(T=s[_+1]))==128&&(B=(31&z)<<6|63&T)<=127&&(B=null):N===3?(D=s[_+2],(192&(T=s[_+1]))==128&&(192&D)==128&&((B=(15&z)<<12|(63&T)<<6|63&D)<=2047||B>=55296&&B<=57343)&&(B=null)):N===4&&(D=s[_+2],I=s[_+3],(192&(T=s[_+1]))==128&&(192&D)==128&&(192&I)==128&&((B=(15&z)<<18|(63&T)<<12|(63&D)<<6|63&I)<=65535||B>=1114112)&&(B=null)),B===null?(B=65533,N=1):B>65535&&(B-=65536,g+=String.fromCharCode(B>>>10&1023|55296),B=56320|1023&B),g+=String.fromCharCode(B),_+=N}return g}(this.buf,n,a)},readBytes:function(){var a=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,a);return this.pos=a,n},readPackedVarint:function(a,n){if(this.type!==si.Bytes)return a.push(this.readVarint(n));var s=Ya(this);for(a=a||[];this.pos127;);else if(n===si.Bytes)this.pos=this.readVarint()+this.pos;else if(n===si.Fixed32)this.pos+=4;else{if(n!==si.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(a,n){this.writeVarint(a<<3|n)},realloc:function(a){for(var n=this.length||16;n268435455||a<0?function(n,s){var u,p;if(n>=0?(u=n%4294967296|0,p=n/4294967296|0):(p=~(-n/4294967296),4294967295^(u=~(-n%4294967296))?u=u+1|0:(u=0,p=p+1|0)),n>=18446744073709552e3||n<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(g,_,T){T.buf[T.pos++]=127&g|128,g>>>=7,T.buf[T.pos++]=127&g|128,g>>>=7,T.buf[T.pos++]=127&g|128,g>>>=7,T.buf[T.pos++]=127&g|128,T.buf[T.pos]=127&(g>>>=7)}(u,0,s),function(g,_){var T=(7&g)<<4;_.buf[_.pos++]|=T|((g>>>=3)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g|((g>>>=7)?128:0),g&&(_.buf[_.pos++]=127&g)))))}(p,s)}(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 n=this.pos;this.pos=function(u,p,g){for(var _,T,D=0;D55295&&_<57344){if(!T){_>56319||D+1===p.length?(u[g++]=239,u[g++]=191,u[g++]=189):T=_;continue}if(_<56320){u[g++]=239,u[g++]=191,u[g++]=189,T=_;continue}_=T-55296<<10|_-56320|65536,T=null}else T&&(u[g++]=239,u[g++]=191,u[g++]=189,T=null);_<128?u[g++]=_:(_<2048?u[g++]=_>>6|192:(_<65536?u[g++]=_>>12|224:(u[g++]=_>>18|240,u[g++]=_>>12&63|128),u[g++]=_>>6&63|128),u[g++]=63&_|128)}return g}(this.buf,a,this.pos);var s=this.pos-n;s>=128&&fw(n,s,this),this.pos=n-1,this.writeVarint(s),this.pos+=s},writeFloat:function(a){this.realloc(4),hw(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),hw(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var n=a.length;this.writeVarint(n),this.realloc(n);for(var s=0;s=128&&fw(s,u,this),this.pos=s-1,this.writeVarint(u),this.pos+=u},writeMessage:function(a,n,s){this.writeTag(a,si.Bytes),this.writeRawMessage(n,s)},writePackedVarint:function(a,n){n.length&&this.writeMessage(a,Uz,n)},writePackedSVarint:function(a,n){n.length&&this.writeMessage(a,Vz,n)},writePackedBoolean:function(a,n){n.length&&this.writeMessage(a,jz,n)},writePackedFloat:function(a,n){n.length&&this.writeMessage(a,Gz,n)},writePackedDouble:function(a,n){n.length&&this.writeMessage(a,Wz,n)},writePackedFixed32:function(a,n){n.length&&this.writeMessage(a,Hz,n)},writePackedSFixed32:function(a,n){n.length&&this.writeMessage(a,$z,n)},writePackedFixed64:function(a,n){n.length&&this.writeMessage(a,qz,n)},writePackedSFixed64:function(a,n){n.length&&this.writeMessage(a,Xz,n)},writeBytesField:function(a,n){this.writeTag(a,si.Bytes),this.writeBytes(n)},writeFixed32Field:function(a,n){this.writeTag(a,si.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(a,n){this.writeTag(a,si.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(a,n){this.writeTag(a,si.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(a,n){this.writeTag(a,si.Fixed64),this.writeSFixed64(n)},writeVarintField:function(a,n){this.writeTag(a,si.Varint),this.writeVarint(n)},writeSVarintField:function(a,n){this.writeTag(a,si.Varint),this.writeSVarint(n)},writeStringField:function(a,n){this.writeTag(a,si.Bytes),this.writeString(n)},writeFloatField:function(a,n){this.writeTag(a,si.Fixed32),this.writeFloat(n)},writeDoubleField:function(a,n){this.writeTag(a,si.Fixed64),this.writeDouble(n)},writeBooleanField:function(a,n){this.writeVarintField(a,!!n)}};class Nv{constructor(n,{pixelRatio:s,version:u,stretchX:p,stretchY:g,content:_}){this.paddedRect=n,this.pixelRatio=s,this.stretchX=p,this.stretchY=g,this.content=_,this.version=u}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 gw{constructor(n,s){const u={},p={};this.haveRenderCallbacks=[];const g=[];this.addImages(n,u,g),this.addImages(s,p,g);const{w:_,h:T}=Ov(g),D=new Yr({width:_||1,height:T||1});for(const I in n){const z=n[I],B=u[I].paddedRect;Yr.copy(z.data,D,{x:0,y:0},{x:B.x+1,y:B.y+1},z.data)}for(const I in s){const z=s[I],B=p[I].paddedRect,N=B.x+1,W=B.y+1,K=z.data.width,oe=z.data.height;Yr.copy(z.data,D,{x:0,y:0},{x:N,y:W},z.data),Yr.copy(z.data,D,{x:0,y:oe-1},{x:N,y:W-1},{width:K,height:1}),Yr.copy(z.data,D,{x:0,y:0},{x:N,y:W+oe},{width:K,height:1}),Yr.copy(z.data,D,{x:K-1,y:0},{x:N-1,y:W},{width:1,height:oe}),Yr.copy(z.data,D,{x:0,y:0},{x:N+K,y:W},{width:1,height:oe})}this.image=D,this.iconPositions=u,this.patternPositions=p}addImages(n,s,u){for(const p in n){const g=n[p],_={x:0,y:0,w:g.data.width+2,h:g.data.height+2};u.push(_),s[p]=new Nv(_,g),g.hasRenderCallback&&this.haveRenderCallbacks.push(p)}}patchUpdatedImages(n,s){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(u=>n.hasImage(u)),n.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const u in n.updatedImages)this.patchUpdatedImage(this.iconPositions[u],n.getImage(u),s),this.patchUpdatedImage(this.patternPositions[u],n.getImage(u),s)}patchUpdatedImage(n,s,u){if(!n||!s||n.version===s.version)return;n.version=s.version;const[p,g]=n.tl;u.update(s.data,void 0,{x:p,y:g})}}$t(Nv,"ImagePosition"),$t(gw,"ImageAtlas");const yo={horizontal:1,vertical:2,horizontalOnly:3};class Sp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(n,s){const u=new Sp;return u.scale=n||1,u.fontStack=s,u}static forImage(n){const s=new Sp;return s.imageName=n,s}}class th{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(n,s){const u=new th;for(let p=0;p=0&&u>=n&&Gg[this.text.charCodeAt(u)];u--)s--;this.text=this.text.substring(n,s),this.sectionIndex=this.sectionIndex.slice(n,s)}substring(n,s){const u=new th;return u.text=this.text.substring(n,s),u.sectionIndex=this.sectionIndex.slice(n,s),u.sections=this.sections,u}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((n,s)=>Math.max(n,this.sections[s].scale),0)}addTextSection(n,s){this.text+=n.text,this.sections.push(Sp.forText(n.scale,n.fontStack||s));const u=this.sections.length-1;for(let p=0;p=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Uv(a,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe){const ue=th.fromFeature(a,p);let xe;B===yo.vertical&&ue.verticalizePunctuation(N);const{processBidirectionalText:Be,processStyledBidirectionalText:$e}=qr;if(Be&&ue.sections.length===1){xe=[];const Ke=Be(ue.toString(),Vv(ue,I,g,n,u,W,K));for(const ut of Ke){const dt=new th;dt.text=ut,dt.sections=ue.sections;for(let xt=0;xt0&&Co>Ni&&(Ni=Co)}else{const dr=dt[xr.fontStack];if(!dr)continue;dr[er]&&(hi=dr[er]);const Ki=ut[xr.fontStack];if(!Ki)continue;const Co=Ki.glyphs[er];if(!Co)continue;if(fi=Co.metrics,br=er!==8203?or:0,Ht){const qs=Ki.ascender!==void 0?Math.abs(Ki.ascender):0,Up=Ki.descender!==void 0?Math.abs(Ki.descender):0,Vp=(qs+Up)*Yi;Zi=0;let z=0;for(let N=0;N-s/2;){if(_--,_<0)return!1;T-=a[_].dist(g),g=a[_]}T+=a[_].dist(a[_+1]),_++;const D=[];let I=0;for(;Tu;)I-=D.shift().angleDelta;if(I>p)return!1;_++,T+=z.dist(B)}return!0}function Tw(a){let n=0;for(let s=0;sI){const K=(I-D)/W,oe=yn(B.x,N.x,K),ue=yn(B.y,N.y,K),xe=new Ka(oe,ue,0,N.angleTo(B),z);return!_||Mw(a,xe,T,_,n)?xe:void 0}D+=W}}function nF(a,n,s,u,p,g,_,T,D){const I=Ew(u,g,_),z=Cw(u,p),B=z*_,N=a[0].x===0||a[0].x===D||a[0].y===0||a[0].y===D;return n-B=0&&Ze=0&&Ye=0&&N+I<=z){const Ke=new Ka(Ze,Ye,0,Be,K);Ke._round(),u&&!Mw(a,Ke,g,u,p)||W.push(Ke)}}B+=xe}return T||W.length||_||(W=Aw(a,B/2,s,u,p,g,_,!0,D)),W}function Dw(a,n,s,u,p){const g=[];for(let _=0;_=u&&B.x>=u||(z.x>=u?z=new b(u,z.y+(u-z.x)/(B.x-z.x)*(B.y-z.y))._round():B.x>=u&&(B=new b(u,z.y+(u-z.x)/(B.x-z.x)*(B.y-z.y))._round()),z.y>=p&&B.y>=p||(z.y>=p?z=new b(z.x+(p-z.y)/(B.y-z.y)*(B.x-z.x),p)._round():B.y>=p&&(B=new b(z.x+(p-z.y)/(B.y-z.y)*(B.x-z.x),p)._round()),D&&z.equals(D[D.length-1])||(D=[z],g.push(D)),D.push(B)))))}}return g}$t(Ka,"Anchor");const Lp=1e20;function Pw(a,n,s,u,p,g,_,T,D){for(let I=n;I-1);D++,g[D]=T,_[D]=I,_[D+1]=Lp}for(let T=0,D=0;T{let T=this.entries[p];T||(T=this.entries[p]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let D=T.glyphs[g];if(D!==void 0)return void _(null,{stack:p,id:g,glyph:D});if(D=this._tinySDF(T,p,g),D)return T.glyphs[g]=D,void _(null,{stack:p,id:g,glyph:D});const I=Math.floor(g/256);if(256*I>65535)return void _(new Error("glyphs > 65535 not supported"));if(T.ranges[I])return void _(null,{stack:p,id:g,glyph:D});let z=T.requests[I];z||(z=T.requests[I]=[],nh.loadGlyphRange(p,I,this.url,this.requestManager,(B,N)=>{if(N){T.ascender=N.ascender,T.descender=N.descender;for(const W in N.glyphs)this._doesCharSupportLocalGlyph(+W)||(T.glyphs[+W]=N.glyphs[+W]);T.ranges[I]=!0}for(const W of z)W(B,N);delete T.requests[I]})),z.push((B,N)=>{B?_(B):N&&_(null,{stack:p,id:g,glyph:N.glyphs[g]||null})})},(p,g)=>{if(p)s(p);else if(g){const _={};for(const{stack:T,id:D,glyph:I}of g)_[T]===void 0&&(_[T]={}),_[T].glyphs===void 0&&(_[T].glyphs={}),_[T].glyphs[D]=I&&{id:I.id,bitmap:I.bitmap.clone(),metrics:I.metrics},_[T].ascender=this.entries[T].ascender,_[T].descender=this.entries[T].descender;s(null,_)}})}_doesCharSupportLocalGlyph(n){return this.localGlyphMode!==Wv.none&&(this.localGlyphMode===Wv.all?!!this.localFontFamily:!!this.localFontFamily&&(rp(n)||_g(n)||Vl(n)||Fu(n)||zu(n)))}_tinySDF(n,s,u){const p=this.localFontFamily;if(!p||!this._doesCharSupportLocalGlyph(u))return;let g=n.tinySDF;if(!g){let oe="400";/bold/i.test(s)?oe="900":/medium/i.test(s)?oe="500":/light/i.test(s)&&(oe="200"),g=n.tinySDF=new nh.TinySDF({fontFamily:p,fontWeight:oe,fontSize:48,buffer:6,radius:16}),g.fontWeight=oe}if(this.localGlyphs[g.fontWeight][u])return this.localGlyphs[g.fontWeight][u];const _=String.fromCharCode(u),{data:T,width:D,height:I,glyphWidth:z,glyphHeight:B,glyphLeft:N,glyphTop:W,glyphAdvance:K}=g.draw(_);return this.localGlyphs[g.fontWeight][u]={id:u,bitmap:new Za({width:D,height:I},T),metrics:{width:z/2,height:B/2,left:N/2,top:W/2-27,advance:K/2,localGlyph:!0}}}}function Lw(a,n,s,u){const p=[],g=a.image,_=g.pixelRatio,T=g.paddedRect.w-2,D=g.paddedRect.h-2,I=a.right-a.left,z=a.bottom-a.top,B=g.stretchX||[[0,T]],N=g.stretchY||[[0,D]],W=(st,mt)=>st+mt[1]-mt[0],K=B.reduce(W,0),oe=N.reduce(W,0),ue=T-K,xe=D-oe;let Be=0,$e=K,Ze=0,Ye=oe,Ke=0,ut=ue,dt=0,xt=xe;if(g.content&&u){const st=g.content;Be=Wg(B,0,st[0]),Ze=Wg(N,0,st[1]),$e=Wg(B,st[0],st[2]),Ye=Wg(N,st[1],st[3]),Ke=st[0]-Be,dt=st[1]-Ze,ut=st[2]-st[0]-$e,xt=st[3]-st[1]-Ye}const Et=(st,mt,Pt,Bt)=>{const Rt=jg(st.stretch-Be,$e,I,a.left),Ft=Hg(st.fixed-Ke,ut,st.stretch,K),En=jg(mt.stretch-Ze,Ye,z,a.top),Un=Hg(mt.fixed-dt,xt,mt.stretch,oe),An=jg(Pt.stretch-Be,$e,I,a.left),Fn=Hg(Pt.fixed-Ke,ut,Pt.stretch,K),Qt=jg(Bt.stretch-Ze,Ye,z,a.top),Ht=Hg(Bt.fixed-dt,xt,Bt.stretch,oe),Vn=new b(Rt,En),Kn=new b(An,En),Bi=new b(An,Qt),ui=new b(Rt,Qt),Oi=new b(Ft/_,Un/_),Jn=new b(Fn/_,Ht/_),Wn=n*Math.PI/180;if(Wn){const Ci=Math.sin(Wn),Ni=Math.cos(Wn),Zi=[Ni,-Ci,Ci,Ni];Vn._matMult(Zi),Kn._matMult(Zi),ui._matMult(Zi),Bi._matMult(Zi)}const ni=st.stretch+st.fixed,wi=mt.stretch+mt.fixed;return{tl:Vn,tr:Kn,bl:ui,br:Bi,tex:{x:g.paddedRect.x+1+ni,y:g.paddedRect.y+1+wi,w:Pt.stretch+Pt.fixed-ni,h:Bt.stretch+Bt.fixed-wi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Oi,pixelOffsetBR:Jn,minFontScaleX:ut/_/I,minFontScaleY:xt/_/z,isSDF:s}};if(u&&(g.stretchX||g.stretchY)){const st=Iw(B,ue,K),mt=Iw(N,xe,oe);for(let Pt=0;Pt{if(D)p(D);else if(I){const z={},B=function(N){return new Pp(N).readFields(Zz,{})}(I);for(const N of B.glyphs)z[N.id]=N;p(null,{glyphs:z,ascender:B.ascender,descender:B.descender})}})},nh.TinySDF=class{constructor({fontSize:a=24,buffer:n=3,radius:s=8,cutoff:u=.25,fontFamily:p="sans-serif",fontWeight:g="normal",fontStyle:_="normal"}){this.buffer=n,this.cutoff=u,this.radius=s;const T=this.size=a+4*n,D=this._createCanvas(T),I=this.ctx=D.getContext("2d",{willReadFrequently:!0});I.font=`${_} ${g} ${a}px ${p}`,I.textBaseline="alphabetic",I.textAlign="left",I.fillStyle="black",this.gridOuter=new Float64Array(T*T),this.gridInner=new Float64Array(T*T),this.f=new Float64Array(T),this.z=new Float64Array(T+1),this.v=new Uint16Array(T)}_createCanvas(a){const n=document.createElement("canvas");return n.width=n.height=a,n}draw(a){const{width:n,actualBoundingBoxAscent:s,actualBoundingBoxDescent:u,actualBoundingBoxLeft:p,actualBoundingBoxRight:g}=this.ctx.measureText(a),_=Math.floor(s),T=Math.min(this.size-this.buffer,Math.ceil(g-p)),D=Math.min(this.size-this.buffer,Math.ceil(s)+Math.ceil(u)),I=T+2*this.buffer,z=D+2*this.buffer,B=I*z,N=new Uint8ClampedArray(B),W={data:N,width:I,height:z,glyphWidth:T,glyphHeight:D,glyphTop:_,glyphLeft:0,glyphAdvance:n};if(T===0||D===0)return W;const{ctx:K,buffer:oe,gridInner:ue,gridOuter:xe}=this;K.clearRect(oe,oe,T,D),K.fillText(a,oe,oe+_+1);const Be=K.getImageData(oe,oe,T,D);xe.fill(Lp,0,B),ue.fill(0,0,B);for(let $e=0;$e0?ut*ut:0,ue[Ke]=ut<0?ut*ut:0}}Pw(xe,0,0,I,z,I,this.f,this.v,this.z),Pw(ue,oe,oe,T,D,I,this.f,this.v,this.z);for(let $e=0;$e0)for(let u=(this.length>>1)-1;u>=0;u--)this._down(u)}push(n){this.data.push(n),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const n=this.data[0],s=this.data.pop();return this.length--,this.length>0&&(this.data[0]=s,this._down(0)),n}peek(){return this.data[0]}_up(n){const{data:s,compare:u}=this,p=s[n];for(;n>0;){const g=n-1>>1,_=s[g];if(u(p,_)>=0)break;s[n]=_,n=g}s[n]=p}_down(n){const{data:s,compare:u}=this,p=this.length>>1,g=s[n];for(;n=0)break;s[n]=T,n=_}s[n]=g}}function oF(a,n){return an?1:0}function aF(a,n=1,s=!1){let u=1/0,p=1/0,g=-1/0,_=-1/0;const T=a[0];for(let W=0;Wg)&&(g=K.x),(!W||K.y>_)&&(_=K.y)}const D=Math.min(g-u,_-p);let I=D/2;const z=new rF([],sF);if(D===0)return new b(u,p);for(let W=u;WB.d||!B.d)&&(B=W,s&&console.log("found best %d after %d probes",Math.round(1e4*W.d)/1e4,N)),W.max-B.d<=n||(I=W.h/2,z.push(new ih(W.p.x-I,W.p.y-I,I,a)),z.push(new ih(W.p.x+I,W.p.y-I,I,a)),z.push(new ih(W.p.x-I,W.p.y+I,I,a)),z.push(new ih(W.p.x+I,W.p.y+I,I,a)),N+=4)}return s&&(console.log(`num probes: ${N}`),console.log(`best distance: ${B.d}`)),B.p}function sF(a,n){return n.max-a.max}function ih(a,n,s,u){this.p=new b(a,n),this.h=s,this.d=function(p,g){let _=!1,T=1/0;for(let D=0;Dp.y!=K.y>p.y&&p.x<(K.x-W.x)*(p.y-W.y)/(K.y-W.y)+W.x&&(_=!_),T=Math.min(T,Db(p,W,K))}}return(_?1:-1)*Math.sqrt(T)}(this.p,u),this.max=this.d+this.h*Math.SQRT2}const jv=Number.POSITIVE_INFINITY,lF=Math.sqrt(2);function Rw(a,n){return n[1]!==jv?function(s,u,p){let g=0,_=0;switch(u=Math.abs(u),p=Math.abs(p),s){case"top-right":case"top-left":case"top":_=p-7;break;case"bottom-right":case"bottom-left":case"bottom":_=7-p}switch(s){case"top-right":case"bottom-right":case"right":g=-u;break;case"top-left":case"bottom-left":case"left":g=u}return[g,_]}(a,n[0],n[1]):function(s,u){let p=0,g=0;u<0&&(u=0);const _=u/lF;switch(s){case"top-right":case"top-left":g=_-7;break;case"bottom-right":case"bottom-left":g=7-_;break;case"bottom":g=7-u;break;case"top":g=u-7}switch(s){case"top-right":case"bottom-right":p=-_;break;case"top-left":case"bottom-left":p=_;break;case"left":p=u;break;case"right":p=-u}return[p,g]}(a,n[0])}function cF(a,n,s,u,p,g,_,T,D,I){a.createArrays(),a.tilePixelRatio=In/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const z=a.layers[0].layout,B=a.layers[0]._unevaluatedLayout._values,N={};if(a.textSizeData.kind==="composite"){const{minZoom:oe,maxZoom:ue}=a.textSizeData;N.compositeTextSizes=[B["text-size"].possiblyEvaluate(new ci(oe),T),B["text-size"].possiblyEvaluate(new ci(ue),T)]}if(a.iconSizeData.kind==="composite"){const{minZoom:oe,maxZoom:ue}=a.iconSizeData;N.compositeIconSizes=[B["icon-size"].possiblyEvaluate(new ci(oe),T),B["icon-size"].possiblyEvaluate(new ci(ue),T)]}N.layoutTextSize=B["text-size"].possiblyEvaluate(new ci(D+1),T),N.layoutIconSize=B["icon-size"].possiblyEvaluate(new ci(D+1),T),N.textMaxSize=B["text-size"].possiblyEvaluate(new ci(18),T);const W=z.get("text-rotation-alignment")==="map"&&z.get("symbol-placement")!=="point",K=z.get("text-size");for(const oe of a.features){const ue=z.get("text-font").evaluate(oe,{},T).join(","),xe=K.evaluate(oe,{},T),Be=N.layoutTextSize.evaluate(oe,{},T),$e=(N.layoutIconSize.evaluate(oe,{},T),{horizontal:{},vertical:void 0}),Ze=oe.text;let Ye,Ke=[0,0];if(Ze){const xt=Ze.toString(),Et=z.get("text-letter-spacing").evaluate(oe,{},T)*or,st=z.get("text-line-height").evaluate(oe,{},T)*or,mt=bg(xt)?Et:0,Pt=z.get("text-anchor").evaluate(oe,{},T),Bt=z.get("text-variable-anchor");if(!Bt){const Fn=z.get("text-radial-offset").evaluate(oe,{},T);Ke=Fn?Rw(Pt,[Fn*or,jv]):z.get("text-offset").evaluate(oe,{},T).map(Qt=>Qt*or)}let Rt=W?"center":z.get("text-justify").evaluate(oe,{},T);const Ft=z.get("symbol-placement"),En=Ft==="point",Un=Ft==="point"?z.get("text-max-width").evaluate(oe,{},T)*or:0,An=Fn=>{a.allowVerticalPlacement&&Ou(xt)&&($e.vertical=Uv(Ze,n,s,p,ue,Un,st,Pt,Fn,mt,Ke,yo.vertical,!0,Ft,Be,xe))};if(!W&&Bt){const Fn=Rt==="auto"?Bt.map(Ht=>Hv(Ht)):[Rt];let Qt=!1;for(let Ht=0;Ht=0||!Ou(xt)){const Fn=Uv(Ze,n,s,p,ue,Un,st,Pt,Rt,mt,Ke,yo.horizontal,!1,Ft,Be,xe);Fn&&($e.horizontal[Rt]=Fn)}An(Ft==="point"?"left":Rt)}}let ut=!1;if(oe.icon&&oe.icon.name){const xt=u[oe.icon.name];xt&&(Ye=eF(p[oe.icon.name],z.get("icon-offset").evaluate(oe,{},T),z.get("icon-anchor").evaluate(oe,{},T)),ut=xt.sdf,a.sdfIcons===void 0?a.sdfIcons=xt.sdf:a.sdfIcons!==xt.sdf&&be("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(xt.pixelRatio!==a.pixelRatio||z.get("icon-rotate").constantOr(1)!==0)&&(a.iconsNeedLinear=!0))}const dt=zw($e.horizontal)||$e.vertical;a.iconsInText||(a.iconsInText=!!dt&&dt.iconsInText),(dt||Ye)&&uF(a,oe,$e,Ye,u,N,Be,0,Ke,ut,_,T,I)}g&&a.generateCollisionDebugBuffers(D,a.collisionBoxArray)}function Hv(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 uF(a,n,s,u,p,g,_,T,D,I,z,B,N){let W=g.textMaxSize.evaluate(n,{},B);W===void 0&&(W=_);const K=a.layers[0].layout,oe=K.get("icon-offset").evaluate(n,{},B),ue=zw(s.horizontal)||s.vertical,xe=_/24,Be=a.tilePixelRatio*W/24,$e=(st=a.overscaling,a.zoom>18&&st>2&&(st>>=1),Math.max(In/(512*st),1)*K.get("symbol-spacing")),Ze=K.get("text-padding")*a.tilePixelRatio,Ye=K.get("icon-padding")*a.tilePixelRatio,Ke=F(K.get("text-max-angle")),ut=K.get("text-rotation-alignment")==="map"&&K.get("symbol-placement")!=="point",dt=K.get("icon-rotation-alignment")==="map"&&K.get("symbol-placement")!=="point",xt=K.get("symbol-placement"),Et=$e/2;var st;const mt=K.get("icon-text-fit");let Pt;u&&mt!=="none"&&(a.allowVerticalPlacement&&s.vertical&&(Pt=ww(u,s.vertical,mt,K.get("icon-text-fit-padding"),oe,xe)),ue&&(u=ww(u,ue,mt,K.get("icon-text-fit-padding"),oe,xe)));const Bt=(Rt,Ft,En)=>{if(Ft.x<0||Ft.x>=In||Ft.y<0||Ft.y>=In)return;const{x:Un,y:An,z:Fn}=N.projectTilePoint(Ft.x,Ft.y,En),Qt=new Ka(Un,An,Fn,0,void 0);(function(Ht,Vn,Kn,Bi,ui,Oi,Jn,Wn,ni,wi,Ci,Ni,Zi,Qr,Br,ii,xr,eo,er,Yi,fi,hi,Or,br,Ii){const wr=Ht.addToLineVertexArray(Vn,Bi);let dr,Ki,Co,qs,Up,Vp,yM,_M=0,vM=0,xM=0,bM=0,lx=-1,cx=-1;const ba={};let wM=fa(""),ux=0,hx=0;if(ni._unevaluatedLayout.getValue("text-radial-offset")===void 0?[ux,hx]=ni.layout.get("text-offset").evaluate(fi,{},Ii).map(to=>to*or):(ux=ni.layout.get("text-radial-offset").evaluate(fi,{},Ii)*or,hx=jv),Ht.allowVerticalPlacement&&ui.vertical){const to=ui.vertical;if(Br)Vp=$v(to),Wn&&(yM=$v(Wn));else{const no=ni.layout.get("text-rotate").evaluate(fi,{},Ii)+90;Co=$g(wi,Kn,Vn,Ci,Ni,Zi,to,Qr,no,ii),Wn&&(qs=$g(wi,Kn,Vn,Ci,Ni,Zi,Wn,eo,no))}}if(Oi){const to=ni.layout.get("icon-rotate").evaluate(fi,{},Ii),no=ni.layout.get("icon-text-fit")!=="none",Gp=Lw(Oi,to,Or,no),px=Wn?Lw(Wn,to,Or,no):void 0;Ki=$g(wi,Kn,Vn,Ci,Ni,Zi,Oi,eo,to),_M=4*Gp.length;const MM=Ht.iconSizeData;let ec=null;MM.kind==="source"?(ec=[ya*ni.layout.get("icon-size").evaluate(fi,{},Ii)],ec[0]>Vs&&be(`${Ht.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):MM.kind==="composite"&&(ec=[ya*hi.compositeIconSizes[0].evaluate(fi,{},Ii),ya*hi.compositeIconSizes[1].evaluate(fi,{},Ii)],(ec[0]>Vs||ec[1]>Vs)&&be(`${Ht.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ht.addSymbols(Ht.icon,Gp,ec,Yi,er,fi,!1,Kn,Vn,wr.lineStartIndex,wr.lineLength,-1,br,Ii),lx=Ht.icon.placedSymbolArray.length-1,px&&(vM=4*px.length,Ht.addSymbols(Ht.icon,px,ec,Yi,er,fi,yo.vertical,Kn,Vn,wr.lineStartIndex,wr.lineLength,-1,br,Ii),cx=Ht.icon.placedSymbolArray.length-1)}for(const to in ui.horizontal){const no=ui.horizontal[to];dr||(wM=fa(no.text),Br?Up=$v(no):dr=$g(wi,Kn,Vn,Ci,Ni,Zi,no,Qr,ni.layout.get("text-rotate").evaluate(fi,{},Ii),ii));const Gp=no.positionedLines.length===1;if(xM+=kw(Ht,Kn,Vn,no,Jn,ni,Br,fi,ii,wr,ui.vertical?yo.horizontal:yo.horizontalOnly,Gp?Object.keys(ui.horizontal):[to],ba,lx,hi,br,Ii),Gp)break}ui.vertical&&(bM+=kw(Ht,Kn,Vn,ui.vertical,Jn,ni,Br,fi,ii,wr,yo.vertical,["vertical"],ba,cx,hi,br,Ii));let Xs=-1;const dx=(to,no)=>to?Math.max(to,no):no;Xs=dx(Up,Xs),Xs=dx(Vp,Xs),Xs=dx(yM,Xs);const jF=Xs>-1?1:0;Ht.glyphOffsetArray.length>=Gs.MAX_GLYPHS&&be("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),fi.sortKey!==void 0&&Ht.addToSortKeyRanges(Ht.symbolInstances.length,fi.sortKey),Ht.symbolInstances.emplaceBack(Kn.x,Kn.y,Kn.z,Vn.x,Vn.y,ba.right>=0?ba.right:-1,ba.center>=0?ba.center:-1,ba.left>=0?ba.left:-1,ba.vertical>=0?ba.vertical:-1,lx,cx,wM,dr!==void 0?dr:Ht.collisionBoxArray.length,dr!==void 0?dr+1:Ht.collisionBoxArray.length,Co!==void 0?Co:Ht.collisionBoxArray.length,Co!==void 0?Co+1:Ht.collisionBoxArray.length,Ki!==void 0?Ki:Ht.collisionBoxArray.length,Ki!==void 0?Ki+1:Ht.collisionBoxArray.length,qs||Ht.collisionBoxArray.length,qs?qs+1:Ht.collisionBoxArray.length,Ci,xM,bM,_M,vM,jF,0,ux,hx,Xs)})(a,Ft,Qt,Rt,s,u,p,Pt,a.layers[0],a.collisionBoxArray,n.index,n.sourceLayerIndex,a.index,Ze,ut,D,0,Ye,dt,oe,n,g,I,z,B)};if(xt==="line")for(const Rt of Dw(n.geometry,0,0,In,In)){const Ft=nF(Rt,$e,Ke,s.vertical||ue,u,24,Be,a.overscaling,In);for(const En of Ft){const Un=ue;Un&&hF(a,Un.text,Et,En)||Bt(Rt,En,B)}}else if(xt==="line-center"){for(const Rt of n.geometry)if(Rt.length>1){const Ft=tF(Rt,Ke,s.vertical||ue,u,24,Be);Ft&&Bt(Rt,Ft,B)}}else if(n.type==="Polygon")for(const Rt of Rv(n.geometry,0)){const Ft=aF(Rt,16);Bt(Rt[0],new Ka(Ft.x,Ft.y,0,0,void 0),B)}else if(n.type==="LineString")for(const Rt of n.geometry)Bt(Rt,new Ka(Rt[0].x,Rt[0].y,0,0,void 0),B);else if(n.type==="Point")for(const Rt of n.geometry)for(const Ft of Rt)Bt([Ft],new Ka(Ft.x,Ft.y,0,0,void 0),B)}const Vs=32640;function kw(a,n,s,u,p,g,_,T,D,I,z,B,N,W,K,oe,ue){const xe=function(Ze,Ye,Ke,ut,dt,xt,Et,st){const mt=[];if(Ye.positionedLines.length===0)return mt;const Pt=ut.layout.get("text-rotate").evaluate(xt,{})*Math.PI/180,Bt=function(An){const Fn=An[0],Qt=An[1],Ht=Fn*Qt;return Ht>0?[Fn,-Qt]:Ht<0?[-Fn,Qt]:Fn===0?[Qt,Fn]:[Qt,-Fn]}(Ke);let Rt=Math.abs(Ye.top-Ye.bottom);for(const An of Ye.positionedLines)Rt-=An.lineOffset;const Ft=Ye.positionedLines.length,En=Rt/Ft;let Un=Ye.top-Ke[1];for(let An=0;AnVs&&be(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Be.kind==="composite"&&($e=[ya*K.compositeTextSizes[0].evaluate(T,{},ue),ya*K.compositeTextSizes[1].evaluate(T,{},ue)],($e[0]>Vs||$e[1]>Vs)&&be(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),a.addSymbols(a.text,xe,$e,D,_,T,z,n,s,I.lineStartIndex,I.lineLength,W,oe,ue);for(const Ze of B)N[Ze]=a.text.placedSymbolArray.length-1;return 4*xe.length}function zw(a){for(const n in a)return a[n];return null}function $g(a,n,s,u,p,g,_,T,D,I){let z=_.top,B=_.bottom,N=_.left,W=_.right;const K=_.collisionPadding;if(K&&(N-=K[0],z-=K[1],W+=K[2],B+=K[3]),D){const oe=new b(N,z),ue=new b(W,z),xe=new b(N,B),Be=new b(W,B),$e=F(D);let Ze=new b(0,0);I&&(Ze=new b(I[0],I[1])),oe._rotateAround($e,Ze),ue._rotateAround($e,Ze),xe._rotateAround($e,Ze),Be._rotateAround($e,Ze),N=Math.min(oe.x,ue.x,xe.x,Be.x),W=Math.max(oe.x,ue.x,xe.x,Be.x),z=Math.min(oe.y,ue.y,xe.y,Be.y),B=Math.max(oe.y,ue.y,xe.y,Be.y)}return a.emplaceBack(n.x,n.y,n.z,s.x,s.y,N,z,W,B,T,u,p,g),a.length-1}function $v(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const n=a.bottom-a.top;return n>0?Math.max(10,n):null}function hF(a,n,s,u){const p=a.compareText;if(n in p){const g=p[n];for(let _=g.length-1;_>=0;_--)if(u.dist(g[_])_.id),this.index=n.index,this.pixelRatio=n.pixelRatio,this.sourceLayerIndex=n.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ga([]),this.placementViewportMatrix=ga([]);const s=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fv(this.zoom,s["text-size"]),this.iconSizeData=Fv(this.zoom,s["icon-size"]);const u=this.layers[0].layout,p=u.get("symbol-sort-key"),g=u.get("symbol-z-order");this.canOverlap=u.get("text-allow-overlap")||u.get("icon-allow-overlap")||u.get("text-ignore-placement")||u.get("icon-ignore-placement"),this.sortFeaturesByKey=g!=="viewport-y"&&p.constantOr(1)!==void 0,this.sortFeaturesByY=(g==="viewport-y"||g==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=u.get("text-writing-mode").map(_=>yo[_]),this.stateDependentLayerIds=this.layers.filter(_=>_.isStateDependent()).map(_=>_.id),this.sourceID=n.sourceID,this.projection=n.projection}createArrays(){this.text=new Xv(new ql(this.layers,this.zoom,n=>/^text/.test(n))),this.icon=new Xv(new ql(this.layers,this.zoom,n=>/^icon/.test(n))),this.glyphOffsetArray=new Yn,this.lineVertexArray=new Si,this.symbolInstances=new Ti}calculateGlyphDependencies(n,s,u,p,g){for(let _=0;_0)&&(T.value.kind!=="constant"||T.value.value.length>0),B=I.value.kind!=="constant"||!!I.value.value||Object.keys(I.parameters).length>0,N=_.get("symbol-sort-key");if(this.features=[],!z&&!B)return;const W=s.iconDependencies,K=s.glyphDependencies,oe=s.availableImages,ue=new ci(this.zoom);for(const{feature:xe,id:Be,index:$e,sourceLayerIndex:Ze}of n){const Ye=g._featureFilter.needGeometry,Ke=Xl(xe,Ye);if(!g._featureFilter.filter(ue,Ke,u))continue;let ut,dt;if(Ye||(Ke.geometry=Xa(xe,u,p)),z){const Et=g.getValueAndResolveTokens("text-field",Ke,u,oe),st=Fi.factory(Et);fF(st)&&(this.hasRTLText=!0),(!this.hasRTLText||Gu()==="unavailable"||this.hasRTLText&&qr.isParsed())&&(ut=Bz(st,g,Ke))}if(B){const Et=g.getValueAndResolveTokens("icon-image",Ke,u,oe);dt=Et instanceof Pr?Et:Pr.fromString(Et)}if(!ut&&!dt)continue;const xt=this.sortFeaturesByKey?N.evaluate(Ke,{},u):void 0;if(this.features.push({id:Be,text:ut,icon:dt,index:$e,sourceLayerIndex:Ze,geometry:Ke.geometry,properties:xe.properties,type:dF[xe.type],sortKey:xt}),dt&&(W[dt.name]=!0),ut){const Et=T.evaluate(Ke,{},u).join(","),st=_.get("text-rotation-alignment")==="map"&&_.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(yo.vertical)>=0;for(const mt of ut.sections)if(mt.image)W[mt.image.name]=!0;else{const Pt=Ou(ut.toString()),Bt=mt.fontStack||Et,Rt=K[Bt]=K[Bt]||{};this.calculateGlyphDependencies(mt.text,Rt,st,this.allowVerticalPlacement,Pt)}}}_.get("symbol-placement")==="line"&&(this.features=function(xe){const Be={},$e={},Ze=[];let Ye=0;function Ke(Et){Ze.push(xe[Et]),Ye++}function ut(Et,st,mt){const Pt=$e[Et];return delete $e[Et],$e[st]=Pt,Ze[Pt].geometry[0].pop(),Ze[Pt].geometry[0]=Ze[Pt].geometry[0].concat(mt[0]),Pt}function dt(Et,st,mt){const Pt=Be[st];return delete Be[st],Be[Et]=Pt,Ze[Pt].geometry[0].shift(),Ze[Pt].geometry[0]=mt[0].concat(Ze[Pt].geometry[0]),Pt}function xt(Et,st,mt){const Pt=mt?st[0][st[0].length-1]:st[0][0];return`${Et}:${Pt.x}:${Pt.y}`}for(let Et=0;EtEt.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((xe,Be)=>xe.sortKey-Be.sortKey)}update(n,s,u,p){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(n,s,this.layers,u,p),this.icon.programConfigurations.updatePaintArrays(n,s,this.layers,u,p))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(n){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(n),this.iconCollisionBox.upload(n)),this.text.upload(n,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(n,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(n,s){const u=this.lineVertexArray.length,p=n.segment;if(p!==void 0){let g=n.dist(s[p+1]),_=n.dist(s[p]);const T={};for(let D=p+1;D=0;D--)T[D]={x:s[D].x,y:s[D].y,tileUnitDistanceFromAnchor:_},D>0&&(_+=s[D-1].dist(s[D]));for(let D=0;D=0?s.rightJustifiedTextSymbolIndex:s.centerJustifiedTextSymbolIndex>=0?s.centerJustifiedTextSymbolIndex:s.leftJustifiedTextSymbolIndex>=0?s.leftJustifiedTextSymbolIndex:s.verticalPlacedTextSymbolIndex>=0?s.verticalPlacedTextSymbolIndex:p),_=Ug(this.textSizeData,n,g)/or;return this.tilePixelRatio*_}getSymbolInstanceIconSize(n,s,u){const p=this.icon.placedSymbolArray.get(u),g=Ug(this.iconSizeData,n,p);return this.tilePixelRatio*g}_commitDebugCollisionVertexUpdate(n,s,u){n.emplaceBack(s,-u,-u),n.emplaceBack(s,u,-u),n.emplaceBack(s,u,u),n.emplaceBack(s,-u,u)}_updateTextDebugCollisionBoxes(n,s,u,p,g,_){for(let T=p;T0}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(n,s){const u=n.placedSymbolArray.get(s),p=u.vertexStartIndex+4*u.numGlyphs;for(let g=u.vertexStartIndex;gp[T]-p[D]||g[D]-g[T]),_}addToSortKeyRanges(n,s){const u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===s?u.symbolInstanceEnd=n+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:n,symbolInstanceEnd:n+1})}sortFeatures(n){if(this.sortFeaturesByY&&this.sortedAngle!==n&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(n),this.sortedAngle=n,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const s of this.symbolInstanceIndexes){const u=this.symbolInstances.get(s);this.featureSortOrder.push(u.featureIndex),[u.rightJustifiedTextSymbolIndex,u.centerJustifiedTextSymbolIndex,u.leftJustifiedTextSymbolIndex].forEach((p,g,_)=>{p>=0&&_.indexOf(p)===g&&this.addIndicesForPlacedSymbol(this.text,p)}),u.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,u.verticalPlacedTextSymbolIndex),u.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.placedIconSymbolIndex),u.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}$t(Gs,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Gs.MAX_GLYPHS=65535,Gs.addDynamicAttributes=qv;const mF=new Z({"symbol-placement":new S(Te.layout_symbol["symbol-placement"]),"symbol-spacing":new S(Te.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new S(Te.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new k(Te.layout_symbol["symbol-sort-key"]),"symbol-z-order":new S(Te.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new S(Te.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new S(Te.layout_symbol["icon-ignore-placement"]),"icon-optional":new S(Te.layout_symbol["icon-optional"]),"icon-rotation-alignment":new S(Te.layout_symbol["icon-rotation-alignment"]),"icon-size":new k(Te.layout_symbol["icon-size"]),"icon-text-fit":new S(Te.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new S(Te.layout_symbol["icon-text-fit-padding"]),"icon-image":new k(Te.layout_symbol["icon-image"]),"icon-rotate":new k(Te.layout_symbol["icon-rotate"]),"icon-padding":new S(Te.layout_symbol["icon-padding"]),"icon-keep-upright":new S(Te.layout_symbol["icon-keep-upright"]),"icon-offset":new k(Te.layout_symbol["icon-offset"]),"icon-anchor":new k(Te.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new S(Te.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new S(Te.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new S(Te.layout_symbol["text-rotation-alignment"]),"text-field":new k(Te.layout_symbol["text-field"]),"text-font":new k(Te.layout_symbol["text-font"]),"text-size":new k(Te.layout_symbol["text-size"]),"text-max-width":new k(Te.layout_symbol["text-max-width"]),"text-line-height":new k(Te.layout_symbol["text-line-height"]),"text-letter-spacing":new k(Te.layout_symbol["text-letter-spacing"]),"text-justify":new k(Te.layout_symbol["text-justify"]),"text-radial-offset":new k(Te.layout_symbol["text-radial-offset"]),"text-variable-anchor":new S(Te.layout_symbol["text-variable-anchor"]),"text-anchor":new k(Te.layout_symbol["text-anchor"]),"text-max-angle":new S(Te.layout_symbol["text-max-angle"]),"text-writing-mode":new S(Te.layout_symbol["text-writing-mode"]),"text-rotate":new k(Te.layout_symbol["text-rotate"]),"text-padding":new S(Te.layout_symbol["text-padding"]),"text-keep-upright":new S(Te.layout_symbol["text-keep-upright"]),"text-transform":new k(Te.layout_symbol["text-transform"]),"text-offset":new k(Te.layout_symbol["text-offset"]),"text-allow-overlap":new S(Te.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new S(Te.layout_symbol["text-ignore-placement"]),"text-optional":new S(Te.layout_symbol["text-optional"])});var Yv={paint:new Z({"icon-opacity":new k(Te.paint_symbol["icon-opacity"]),"icon-color":new k(Te.paint_symbol["icon-color"]),"icon-halo-color":new k(Te.paint_symbol["icon-halo-color"]),"icon-halo-width":new k(Te.paint_symbol["icon-halo-width"]),"icon-halo-blur":new k(Te.paint_symbol["icon-halo-blur"]),"icon-translate":new S(Te.paint_symbol["icon-translate"]),"icon-translate-anchor":new S(Te.paint_symbol["icon-translate-anchor"]),"text-opacity":new k(Te.paint_symbol["text-opacity"]),"text-color":new k(Te.paint_symbol["text-color"],{runtimeType:mn,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new k(Te.paint_symbol["text-halo-color"]),"text-halo-width":new k(Te.paint_symbol["text-halo-width"]),"text-halo-blur":new k(Te.paint_symbol["text-halo-blur"]),"text-translate":new S(Te.paint_symbol["text-translate"]),"text-translate-anchor":new S(Te.paint_symbol["text-translate-anchor"])}),layout:mF};class Fw{constructor(n){this.type=n.property.overrides?n.property.overrides.runtimeType:Ln,this.defaultValue=n}evaluate(n){if(n.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(n.formattedSection))return s.getOverride(n.formattedSection)}return n.feature&&n.featureState?this.defaultValue.evaluate(n.feature,n.featureState):this.defaultValue.property.specification.default}eachChild(n){this.defaultValue.isConstant()||n(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}$t(Fw,"FormatSectionOverride",{omit:["defaultValue"]});class Xg extends Wo{constructor(n){super(n,Yv)}recalculate(n,s){super.recalculate(n,s),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 u=this.layout.get("text-writing-mode");if(u){const p=[];for(const g of u)p.indexOf(g)<0&&p.push(g);this.layout._values["text-writing-mode"]=p}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(n,s,u,p){const g=this.layout.get(n).evaluate(s,{},u,p),_=this._unevaluatedLayout._values[n];return _.isDataDriven()||Ds(_.value)||!g?g:function(T,D){return D.replace(/{([^{}]+)}/g,(I,z)=>z in T?String(T[z]):"")}(s.properties,g)}createBucket(n){return new Gs(n)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const n of Yv.paint.overridableProperties){if(!Xg.hasPaintOverride(this.layout,n))continue;const s=this.paint.get(n),u=new Fw(s),p=new Du(u,s.property.specification);let g=null;g=s.value.kind==="constant"||s.value.kind==="source"?new Hd("source",p):new $d("composite",p,s.value.zoomStops,s.value._interpolationType),this.paint._values[n]=new E(s.property,g,s.parameters)}}_handleOverridablePaintPropertyUpdate(n,s,u){return!(!this.layout||s.isDataDriven()||u.isDataDriven())&&Xg.hasPaintOverride(this.layout,n)}static hasPaintOverride(n,s){const u=n.get("text-field"),p=Yv.paint.properties[s];let g=!1;const _=T=>{for(const D of T)if(p.overrides&&p.overrides.hasOverride(D))return void(g=!0)};if(u.value.kind==="constant"&&u.value.value instanceof Fi)_(u.value.value.sections);else if(u.value.kind==="source"){const T=I=>{g||(I instanceof Fo&&Pi(I.value)===Dr?_(I.value.sections):I instanceof Ms?_(I.sections):I.eachChild(T))},D=u.value;D._styleExpression&&T(D._styleExpression.expression)}return g}getProgramConfiguration(n){return new Bs(this,n)}}var gF={paint:new Z({"background-color":new S(Te.paint_background["background-color"]),"background-pattern":new U(Te.paint_background["background-pattern"]),"background-opacity":new S(Te.paint_background["background-opacity"])})},yF={paint:new Z({"raster-opacity":new S(Te.paint_raster["raster-opacity"]),"raster-hue-rotate":new S(Te.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new S(Te.paint_raster["raster-brightness-min"]),"raster-brightness-max":new S(Te.paint_raster["raster-brightness-max"]),"raster-saturation":new S(Te.paint_raster["raster-saturation"]),"raster-contrast":new S(Te.paint_raster["raster-contrast"]),"raster-resampling":new S(Te.paint_raster["raster-resampling"]),"raster-fade-duration":new S(Te.paint_raster["raster-fade-duration"])})};class _F extends Wo{constructor(n){super(n,{}),this.implementation=n}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(n){this.implementation.onAdd&&this.implementation.onAdd(n,n.painter.context.gl)}onRemove(n){this.implementation.onRemove&&this.implementation.onRemove(n,n.painter.context.gl)}}var vF={paint:new Z({"sky-type":new S(Te.paint_sky["sky-type"]),"sky-atmosphere-sun":new S(Te.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new S(Te.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new S(Te.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new S(Te.paint_sky["sky-gradient-radius"]),"sky-gradient":new G(Te.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new S(Te.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new S(Te.paint_sky["sky-atmosphere-color"]),"sky-opacity":new S(Te.paint_sky["sky-opacity"])})};function Kv(a,n,s){const u=[0,0,1],p=Gb([]);return function(g,_,T){T*=.5;var D=_[0],I=_[1],z=_[2],B=_[3],N=Math.sin(T),W=Math.cos(T);g[0]=D*W-z*N,g[1]=I*W+B*N,g[2]=z*W+D*N,g[3]=B*W-I*N}(p,p,s?-F(a)+Math.PI:F(a)),Wb(p,p,-F(n)),Ub(u,u,p),yp(u,u)}const xF={circle:class extends Wo{constructor(a){super(a,Nk)}createBucket(a){return new gv(a)}queryRadius(a){const n=a;return qu("circle-radius",this,n)+qu("circle-stroke-width",this,n)+Lg(this.paint.get("circle-translate"))}queryIntersectsFeature(a,n,s,u,p,g,_,T){const D=Ib(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),I=this.paint.get("circle-radius").evaluate(n,s)+this.paint.get("circle-stroke-width").evaluate(n,s);return jb(a,u,g,_,T,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",D,I)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new Bs(this,a)}},heatmap:class extends Wo{createBucket(a){return new $b(a)}constructor(a){super(a,$k),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){a==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Pv({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 qu("heatmap-radius",this,a)}queryIntersectsFeature(a,n,s,u,p,g,_,T){const D=this.paint.get("heatmap-radius").evaluate(n,s);return jb(a,u,g,_,T,!0,!0,new b(0,0),D)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new Bs(this,a)}},hillshade:class extends Wo{constructor(a){super(a,qk)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Wo{constructor(a){super(a,uz)}getProgramIds(){const a=this.paint.get("fill-pattern"),n=a&&a.constantOr(1),s=[n?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&s.push(n&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),s}getProgramConfiguration(a){return new Bs(this,a)}recalculate(a,n){super.recalculate(a,n);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new Bg(a)}queryRadius(){return Lg(this.paint.get("fill-translate"))}queryIntersectsFeature(a,n,s,u,p,g){return!a.queryGeometry.isAboveHorizon&&Ab(Lb(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),u)}isTileClipped(){return!0}},"fill-extrusion":class extends Wo{constructor(a){super(a,wz)}createBucket(a){return new Cp(a)}queryRadius(){return Lg(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 Bs(this,a)}queryIntersectsFeature(a,n,s,u,p,g,_,T,D){const I=Ib(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),z=this.paint.get("fill-extrusion-height").evaluate(n,s),B=this.paint.get("fill-extrusion-base").evaluate(n,s),N=[0,0],W=T&&g.elevation,K=g.elevation?g.elevation.exaggeration():1,oe=a.tile.getBucket(this);if(W&&oe instanceof Cp){const Be=oe.centroidVertexArray,$e=D+1;if($e=3){for(let K=0;K1&&(D=n[++T]);const z=Math.abs(I-D.left),B=Math.abs(I-D.right),N=Math.min(z,B);let W;const K=g/u*(p+1);if(D.isDash){const oe=p-Math.abs(K);W=Math.sqrt(N*N+oe*oe)}else W=p-Math.sqrt(N*N+K*K);this.image.data[_+I]=Math.max(0,Math.min(255,W+128))}}}addRegularDash(n,s){for(let D=n.length-1;D>=0;--D){const I=n[D],z=n[D+1];I.zeroLength?n.splice(D,1):z&&z.isDash===I.isDash&&(z.left=I.left,n.splice(D,1))}const u=n[0],p=n[n.length-1];u.isDash===p.isDash&&(u.left=p.left-this.width,p.right=u.right+this.width);const g=this.width*this.nextRow;let _=0,T=n[_];for(let D=0;D1&&(T=n[++_]);const I=Math.abs(D-T.left),z=Math.abs(D-T.right),B=Math.min(I,z);this.image.data[g+D]=Math.max(0,Math.min(255,(T.isDash?B:-B)+s+128))}}addDash(n,s){const u=this.getKey(n,s);if(this.positions[u])return this.positions[u];const p=s==="round",g=p?7:0,_=2*g+1;if(this.nextRow+_>this.height)return be("LineAtlas out of space"),null;n.length===0&&n.push(1);let T=0;for(let z=0;z{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 wF=L.performance;function Bw(a){const n=a?a.url.toString():void 0;return wF.getEntriesByName(n)}class MF{constructor(){this.tasks={},this.taskQueue=[],At(["process"],this),this.invoker=new bF(this.process),this.nextId=0}add(n,s){const u=this.nextId++,p=function({type:g,isSymbolTile:_,zoom:T}){return T=T||0,g==="message"?0:g!=="maybePrepare"||_?g!=="parseTile"||_?g==="parseTile"&&_?300-T:g==="maybePrepare"&&_?400-T:500:200-T:100-T}(s);if(p===0){ke();try{n()}finally{}return{cancel:()=>{}}}return this.tasks[u]={fn:n,metadata:s,priority:p,id:u},this.taskQueue.push(u),this.invoker.trigger(),{cancel:()=>{delete this.tasks[u]}}}process(){ke();try{if(this.taskQueue=this.taskQueue.filter(u=>!!this.tasks[u]),!this.taskQueue.length)return;const n=this.pick();if(n===null)return;const s=this.tasks[n];if(delete this.tasks[n],this.taskQueue.length&&this.invoker.trigger(),!s)return;s.fn()}finally{}}pick(){let n=null,s=1/0;for(let p=0;p1?null:function(u,p,g,_){const T=Math.sin(g);return u*(Math.sin((1-_)*g)/T)+p*(Math.sin(_*g)/T)}(a.a[n],a.b[n],a.angle,Q(s,0,1))+a.center[n]}function kp(a){if(a.z<=1)return CF[a.z+2*a.y+a.x];const[n,s]=ex(a),u=[Ja(n[0],n[1]),Ja(n[0],s[1]),Ja(s[0],n[1]),Ja(s[0],s[1])],p=[Jr,Jr,Jr],g=[Kr,Kr,Kr];for(const _ of u)p[0]=Math.min(p[0],_[0]),p[1]=Math.min(p[1],_[1]),p[2]=Math.min(p[2],_[2]),g[0]=Math.max(g[0],_[0]),g[1]=Math.max(g[1],_[1]),g[2]=Math.max(g[2],_[2]);return new go(p,g)}function DF(a,n,s){const u=n/a.worldSize,p=(mt,Pt)=>{gp(mt,mt,u),gp(Pt,Pt,u)},g=Number.MAX_VALUE,_=[-g,-g,-g],T=[g,g,g],D=jw(a);if(s.z<=1){const mt=kp(s).getCorners();for(let Pt=0;PtMath.abs(ut))Ye=Ke>=0?1:3,Ze=W;else{Ye=ut>=0?0:2;const mt=[D[4],D[5],D[6]];let Pt;Pt=ut>=0?-Math.sin(F(B.getSouth()))*rh:-Math.sin(F(B.getNorth()))*rh,Ze=Cv(Ze,W,mt,Pt)}const dt=N[Ye],xt=N[(Ye+1)%4],Et=new AF(dt,xt,Ze),st=[Qv(Et,0)||dt[0],Qv(Et,1)||dt[1],Qv(Et,2)||dt[2]];return T[2]=Math.min(dt[2],xt[2]),Tv(T,T,st),Ev(_,_,st),p(T,_),new go(T,_)}function ex(a){const n=1<0;z--)D=1<this.canonical.z?new vr(n,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vr(n,this.wrap,n,this.canonical.x>>s,this.canonical.y>>s)}calculateScaledKey(n,s=!0){if(this.overscaledZ===n&&s)return this.key;if(n>this.canonical.z)return zp(this.wrap*+s,n,this.canonical.z,this.canonical.x,this.canonical.y);{const u=this.canonical.z-n;return zp(this.wrap*+s,n,n,this.canonical.x>>u,this.canonical.y>>u)}}isChildOf(n){if(n.wrap!==this.wrap)return!1;const s=this.canonical.z-n.canonical.z;return n.overscaledZ===0||n.overscaledZ>s&&n.canonical.y===this.canonical.y>>s}children(n){if(this.overscaledZ>=n)return[new vr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,u=2*this.canonical.x,p=2*this.canonical.y;return[new vr(s,this.wrap,s,u,p),new vr(s,this.wrap,s,u+1,p),new vr(s,this.wrap,s,u,p+1),new vr(s,this.wrap,s,u+1,p+1)]}isLessThan(n){return this.wrapn.wrap)&&(this.overscaledZn.overscaledZ)&&(this.canonical.xn.canonical.x)&&this.canonical.y$e&&(Ze(Ke,Bt,dt,xt,mt,Pt),Ze(Bt,ut,mt,Pt,Et,st))}Ze(B,N,u,g,p,g),Ze(N,W,p,g,p,_),Ze(W,K,p,_,u,_),Ze(K,B,u,_,u,g),oe-=$e,ue-=$e,xe+=$e,Be+=$e;const Ye=1/Math.max(xe-oe,Be-ue);return{scale:Ye,x:oe*Ye,y:ue*Ye,x2:xe*Ye,y2:Be*Ye,projection:n}}$t(Zg,"CanonicalTileID"),$t(vr,"OverscaledTileID",{omit:["projMatrix"]});class Xw{constructor(n){this._stringToNumber={},this._numberToString=[];for(let s=0;s>=1)>1;){const I=s+p>>1,z=u+g>>1;1&n?(p=s,g=u,s=_,u=T):(s=p,u=g,p=_,g=T),_=I,T=z}const D=4*a;Ws[D+0]=s,Ws[D+1]=u,Ws[D+2]=p,Ws[D+3]=g}const va=new Uint16Array(2178),js=new Uint8Array(1089),Yg=new Uint16Array(1089);function Yw(a){return a===0?-.03125:a===32?.03125:0}var Kw=Le([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Jw={type:2,extent:In,loadGeometry:()=>[[new b(0,0),new b(8193,0),new b(8193,8193),new b(0,8193),new b(0,0)]]};class nx{constructor(n,s,u,p,g){this.tileID=n,this.uid=Oe(),this.uses=0,this.tileSize=s,this.tileZoom=u,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=g,this.expiredRequestCount=0,this.state="loading",p&&p.transform&&(this.projection=p.transform.projection)}registerFadeDuration(n){const s=n+this.timeAdded;sg.getLayer(I)).filter(Boolean);if(D.length!==0){T.layers=D,T.stateDependentLayerIds&&(T.stateDependentLayers=T.stateDependentLayerIds.map(I=>D.filter(z=>z.id===I)[0]));for(const I of D)_[I.id]=T}}return _}(n.buckets,s.style),this.hasSymbolBuckets=!1;for(const p in this.buckets){const g=this.buckets[p];if(g instanceof Gs){if(this.hasSymbolBuckets=!0,!u)break;g.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const p in this.buckets){const g=this.buckets[p];if(g instanceof Gs&&g.hasRTLText){this.hasRTLText=!0,qr.isLoading()||qr.isLoaded()||Gu()!=="deferred"||Rs();break}}this.queryPadding=0;for(const p in this.buckets){const g=this.buckets[p];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(p).queryRadius(g))}n.imageAtlas&&(this.imageAtlas=n.imageAtlas),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas)}else this.collisionBoxArray=new Uo}unloadVectorData(){if(this.hasData()){for(const n in this.buckets)this.buckets[n].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(n){return this.buckets[n.id]}upload(n){for(const u in this.buckets){const p=this.buckets[u];p.uploadPending()&&p.upload(n)}const s=n.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ip(n,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ip(n,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ip(n,this.lineAtlas.image,s.ALPHA),this.lineAtlas.uploaded=!0)}prepare(n){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture)}queryRenderedFeatures(n,s,u,p,g,_,T,D){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:p,pixelPosMatrix:T,transform:_,params:g,tileTransform:this.tileTransform},n,s,u):{}}querySourceFeatures(n,s){const u=this.latestFeatureIndex;if(!u||!u.rawTileData)return;const p=u.loadVTLayers(),g=s?s.sourceLayer:"",_=p._geojsonTileLayer||p[g];if(!_)return;const T=ca(s&&s.filter),{z:D,x:I,y:z}=this.tileID.canonical,B={z:D,x:I,y:z};for(let N=0;N<_.length;N++){const W=_.feature(N);if(T.needGeometry){const ue=Xl(W,!0);if(!T.filter(new ci(this.tileID.overscaledZ),ue,this.tileID.canonical))continue}else if(!T.filter(new ci(this.tileID.overscaledZ),W))continue;const K=u.getId(W,g),oe=new Zw(W,D,I,z,K);oe.tile=B,n.push(oe)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(n){const s=this.expirationTime;if(n.cacheControl){const u=ot(n.cacheControl);u["max-age"]&&(this.expirationTime=Date.now()+1e3*u["max-age"])}else n.expires&&(this.expirationTime=new Date(n.expires).getTime());if(this.expirationTime){const u=Date.now();let p=!1;if(this.expirationTime>u)p=!1;else if(s)if(this.expirationTime=0;ue--){const xe=4*ue,Be=Ws[xe+0],$e=Ws[xe+1],Ze=Ws[xe+2],Ye=Ws[xe+3],Ke=Be+Ze>>1,ut=$e+Ye>>1,dt=Ke+ut-$e,xt=ut+Be-Ke,Et=$e*_a+Be,st=Ye*_a+Ze,mt=ut*_a+Ke,Pt=Math.hypot((va[2*Et+0]+va[2*st+0])/2-va[2*mt+0],(va[2*Et+1]+va[2*st+1])/2-va[2*mt+1])>=16;if(js[mt]=js[mt]||(Pt?1:0),ue<1022){const Bt=($e+xt>>1)*_a+(Be+dt>>1),Rt=(Ye+xt>>1)*_a+(Ze+dt>>1);js[mt]=js[mt]||js[Bt]||js[Rt]}}const B=new ze,N=new qt;let W=0;function K(ue,xe){const Be=xe*_a+ue;return Yg[Be]===0&&(B.emplaceBack(va[2*Be+0],va[2*Be+1],ue*In/Eo,xe*In/Eo),Yg[Be]=++W),Yg[Be]-1}function oe(ue,xe,Be,$e,Ze,Ye){const Ke=ue+Be>>1,ut=xe+$e>>1;if(Math.abs(ue-Ze)+Math.abs(xe-Ye)>1&&js[ut*_a+Ke])oe(Ze,Ye,ue,xe,Ke,ut),oe(Be,$e,Ze,Ye,Ke,ut);else{const dt=K(ue,xe),xt=K(Be,$e),Et=K(Ze,Ye);N.emplaceBack(dt,xt,Et)}}return oe(0,0,Eo,Eo,Eo,0),oe(Eo,Eo,0,0,0,Eo),{vertices:B,indices:N}}(this.tileID.canonical,s);p=_.vertices,g=_.indices}else{p=new ze,g=new qt;for(const{x:T,y:D}of u)p.emplaceBack(T,D,0,0);const _=Ig(p.int16,void 0,4);for(let T=0;T<_.length;T+=3)g.emplaceBack(_[T],_[T+1],_[T+2])}this._tileBoundsBuffer=n.createVertexBuffer(p,Kw.members),this._tileBoundsIndexBuffer=n.createIndexBuffer(g),this._tileBoundsSegments=Ei.simpleSegment(0,0,p.length,g.length)}_makeGlobeTileDebugBuffers(n,s){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!s||s.name!=="globe")return;const u=this.tileID.canonical,p=Gw(kp(u));this._makeGlobeTileDebugBorderBuffer(n,u,p),this._makeGlobeTileDebugTextBuffer(n,u,p)}_makeGlobeTileDebugBorderBuffer(n,s,u){const p=new De,g=new $n,_=new Se,T=(I,z,B,N,W)=>{const K=(B-I)/(W-1),oe=(N-z)/(W-1),ue=p.length;for(let xe=0;xeT*I+z;for(let I=0;In[_])return null}else{const T=1/u[_];let D=(a[_]-s[_])*T,I=(n[_]-s[_])*T;if(D>I){const z=D;D=I,I=z}if(D>p&&(p=D),Ig)return null}return p}function tM(a,n,s,u,p,g,_,T,D,I,z){const B=u-a,N=p-n,W=g-s,K=_-a,oe=T-n,ue=D-s,xe=z[1]*ue-z[2]*oe,Be=z[2]*K-z[0]*ue,$e=z[0]*oe-z[1]*K,Ze=B*xe+N*Be+W*$e;if(Math.abs(Ze)<1e-15)return null;const Ye=1/Ze,Ke=I[0]-a,ut=I[1]-n,dt=I[2]-s,xt=(Ke*xe+ut*Be+dt*$e)*Ye;if(xt<0||xt>1)return null;const Et=ut*W-dt*N,st=dt*B-Ke*W,mt=Ke*N-ut*B,Pt=(z[0]*Et+z[1]*st+z[2]*mt)*Ye;return Pt<0||xt+Pt>1?null:(K*Et+oe*st+ue*mt)*Ye}function nM(a,n,s){return(a-n)/(s-n)}function iM(a,n,s,u,p,g,_,T,D){const I=1<{const Be=ue?1:0,$e=(W+1)*oe-Be,Ze=K*oe,Ye=(K+1)*oe-Be;xe[0]=W*oe,xe[1]=Ze,xe[2]=$e,xe[3]=Ye};let B=new Qw(D);const N=[];for(let W=0;W=1;D/=2){const W=T[T.length-1];B=new Qw(D);for(let K=0;K0;){const{idx:K,t:oe,nodex:ue,nodey:xe,depth:Be}=W.pop();if(this.leaves[K]){iM(ue,xe,Be,n,s,u,p,B,N);const Ze=1<=Ft[2])return oe}continue}let $e=0;for(let Ze=0;Ze=I[z[dt]]&&(z.splice(dt,0,Ze),ut=!0);ut||(z[$e]=Ze),$e++}}for(let Ze=0;Ze<$e;Ze++){const Ye=z[Ze];W.push({idx:this.childOffsets[K]+Ye,t:I[Ye],nodex:(ue<<1)+this._siblingOffset[Ye][0],nodey:(xe<<1)+this._siblingOffset[Ye][1],depth:Be+1})}}return null}_addNode(n,s,u){return this.minimums.push(n),this.maximums.push(s),this.leaves.push(u),this.childOffsets.push(0),this.nodeCount++}_construct(n,s,u,p,g){if(n[p].isLeaf(s,u)===1)return;this.childOffsets[g]||(this.childOffsets[g]=this.nodeCount);const _=p-1,T=n[_];let D=0,I=0;for(let z=0;z=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(s+1)*this.stride+(n+1)}_unpackMapbox(n,s,u){return(256*n*256+256*s+u)/10-1e4}_unpackTerrarium(n,s,u){return 256*n+s+u/256-32768}static pack(n,s){const u=[0,0,0,0],p=Kg.getUnpackVector(s);let g=Math.floor((n+p[3])/p[2]);return u[2]=g%256,g=Math.floor(g/256),u[1]=g%256,g=Math.floor(g/256),u[0]=g,u}getPixels(){return new Yr({width:this.stride,height:this.stride},this.pixels)}backfillBorder(n,s,u){if(this.dim!==n.dim)throw new Error("dem dimension mismatch");let p=s*this.dim,g=s*this.dim+this.dim,_=u*this.dim,T=u*this.dim+this.dim;switch(s){case-1:p=g-1;break;case 1:g=p+1}switch(u){case-1:_=T-1;break;case 1:T=_+1}const D=-s*this.dim,I=-u*this.dim;for(let z=_;z{this.remove(n,g)},u)),this.data[p].push(g),this.order.push(p),this.order.length>this.max){const _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}return this}has(n){return n.wrapped().key in this.data}getAndRemove(n){return this.has(n)?this._getAndRemoveByKey(n.wrapped().key):null}_getAndRemoveByKey(n){const s=this.data[n].shift();return s.timeout&&clearTimeout(s.timeout),this.data[n].length===0&&delete this.data[n],this.order.splice(this.order.indexOf(n),1),s.value}getByKey(n){const s=this.data[n];return s?s[0].value:null}get(n){return this.has(n)?this.data[n.wrapped().key][0].value:null}remove(n,s){if(!this.has(n))return this;const u=n.wrapped().key,p=s===void 0?0:this.data[u].indexOf(s),g=this.data[u][p];return this.data[u].splice(p,1),g.timeout&&clearTimeout(g.timeout),this.data[u].length===0&&delete this.data[u],this.onRemove(g.value),this.order.splice(this.order.indexOf(u),1),this}setMaxSize(n){for(this.max=n;this.order.length>this.max;){const s=this._getAndRemoveByKey(this.order[0]);s&&this.onRemove(s)}return this}filter(n){const s=[];for(const u in this.data)for(const p of this.data[u])n(p.value)||s.push(p);for(const u of s)this.remove(u.value.tileID,u)}}class oh{constructor(n,s,u){this.func=n,this.mask=s,this.range=u}}oh.ReadOnly=!1,oh.ReadWrite=!0,oh.disabled=new oh(519,oh.ReadOnly,[0,1]);const ix=7680;class rx{constructor(n,s,u,p,g,_){this.test=n,this.ref=s,this.mask=u,this.fail=p,this.depthFail=g,this.pass=_}}rx.disabled=new rx({func:519,mask:0},0,0,ix,ix,ix);class xa{constructor(n,s,u){this.blendFunction=n,this.blendColor=s,this.mask=u}}xa.Replace=[1,0],xa.disabled=new xa(xa.Replace,Xn.transparent,[!1,!1,!1,!1]),xa.unblended=new xa(xa.Replace,Xn.transparent,[!0,!0,!0,!0]),xa.alphaBlended=new xa([1,771],Xn.transparent,[!0,!0,!0,!0]);const ox=1029,ax=2305;class jo{constructor(n,s,u){this.enable=n,this.mode=s,this.frontFace=u}}jo.disabled=new jo(!1,ox,ax),jo.backCCW=new jo(!0,ox,ax),jo.backCW=new jo(!0,ox,2304),jo.frontCW=new jo(!0,1028,2304),jo.frontCCW=new jo(!0,1028,ax);class Ql extends Fe{constructor(n,s,u){super(),this.id=n,this._onlySymbols=u,s.on("data",p=>{p.dataType==="source"&&p.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&p.dataType==="source"&&p.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),s.on("error",()=>{this._sourceErrored=!0}),this._source=s,this._tiles={},this._cache=new RF(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=s.minTileCacheSize,this._maxTileCacheSize=s.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new IF,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(n){this.map=n,this._minTileCacheSize=this._minTileCacheSize===void 0&&n?n._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&n?n._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const n in this._tiles){const s=this._tiles[n];if(s.state!=="loaded"&&s.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const n=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,n&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(n,s){return n.isSymbolTile=this._onlySymbols,this._source.loadTile(n,s)}_unloadTile(n){if(this._source.unloadTile)return this._source.unloadTile(n,()=>{})}_abortTile(n){if(this._source.abortTile)return this._source.abortTile(n,()=>{})}serialize(){return this._source.serialize()}prepare(n){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const s in this._tiles){const u=this._tiles[s];this._source.prepareTile(u)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,u.tileID),u.upload(n),u.prepare(this.map.style.imageManager)}else for(const s in this._tiles){const u=this._tiles[s];u.upload(n),u.prepare(this.map.style.imageManager)}}getIds(){return fe(this._tiles).map(n=>n.tileID).sort(sM).map(n=>n.key)}getRenderableIds(n){const s=[];for(const u in this._tiles)this._isIdRenderable(+u,n)&&s.push(this._tiles[u]);return n?s.sort((u,p)=>{const g=u.tileID,_=p.tileID,T=new b(g.canonical.x,g.canonical.y)._rotate(this.transform.angle),D=new b(_.canonical.x,_.canonical.y)._rotate(this.transform.angle);return g.overscaledZ-_.overscaledZ||D.y-T.y||D.x-T.x}).map(u=>u.tileID.key):s.map(u=>u.tileID).sort(sM).map(u=>u.key)}hasRenderableParent(n){const s=this.findLoadedParent(n,0);return!!s&&this._isIdRenderable(s.tileID.key)}_isIdRenderable(n,s){return this._tiles[n]&&this._tiles[n].hasData()&&!this._coveredTiles[n]&&(s||!this._tiles[n].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)this._tiles[n].state!=="errored"&&this._reloadTile(+n,"reloading")}}_reloadTile(n,s){const u=this._tiles[n];u&&(u.state!=="loading"&&(u.state=s),this._loadTile(u,this._tileLoaded.bind(this,u,n,s)))}_tileLoaded(n,s,u,p){if(p)if(n.state="errored",p.status!==404)this._source.fire(new re(p,{tile:n}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const g=this.map.painter.terrain;this.update(this.transform,g.getScaledDemTileSize(),!0),g.resetTileLookupCache(this.id)}else this.update(this.transform);else n.timeAdded=wt.now(),u==="expired"&&(n.refreshedUponExpiration=!0),this._setTileReloadTimer(s,n),this._source.type==="raster-dem"&&n.dem&&this._backfillDEM(n),this._state.initializeTileState(n,this.map?this.map.painter:null),this._source.fire(new Y("data",{dataType:"source",tile:n,coord:n.tileID,sourceCacheId:this.id}))}_backfillDEM(n){const s=this.getRenderableIds();for(let p=0;p1||(Math.abs(_)>1&&(Math.abs(_+D)===1?_+=D:Math.abs(_-D)===1&&(_-=D)),g.dem&&p.dem&&(p.dem.backfillBorder(g.dem,_,T),p.neighboringTiles&&p.neighboringTiles[I]&&(p.neighboringTiles[I].backfilled=!0)))}}getTile(n){return this.getTileByID(n.key)}getTileByID(n){return this._tiles[n]}_retainLoadedChildren(n,s,u,p){for(const g in this._tiles){let _=this._tiles[g];if(p[g]||!_.hasData()||_.tileID.overscaledZ<=s||_.tileID.overscaledZ>u)continue;let T=_.tileID;for(;_&&_.tileID.overscaledZ>s+1;){const I=_.tileID.scaledTo(_.tileID.overscaledZ-1);_=this._tiles[I.key],_&&_.hasData()&&(T=I)}let D=T;for(;D.overscaledZ>s;)if(D=D.scaledTo(D.overscaledZ-1),n[D.key]){p[T.key]=T;break}}}findLoadedParent(n,s){if(n.key in this._loadedParentTiles){const u=this._loadedParentTiles[n.key];return u&&u.tileID.overscaledZ>=s?u:null}for(let u=n.overscaledZ-1;u>=s;u--){const p=n.scaledTo(u),g=this._getLoadedTile(p);if(g)return g}}_getLoadedTile(n){const s=this._tiles[n.key];return s&&s.hasData()?s:this._cache.getByKey(this._source.reparseOverscaled?n.wrapped().key:n.canonical.key)}updateCacheSize(n,s){s=s||this._source.tileSize;const u=Math.ceil(n.width/s)+1,p=Math.ceil(n.height/s)+1,g=Math.floor(u*p*5),_=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,g):g,T=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,_):_;this._cache.setMaxSize(T)}handleWrapJump(n){const s=Math.round((n-(this._prevLng===void 0?n:this._prevLng))/360);if(this._prevLng=n,s){const u={};for(const p in this._tiles){const g=this._tiles[p];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+s),u[g.tileID.key]=g}this._tiles=u;for(const p in this._timers)clearTimeout(this._timers[p]),delete this._timers[p];for(const p in this._tiles)this._setTileReloadTimer(+p,this._tiles[p])}}update(n,s,u){if(this.transform=n,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!u)return;let p;this.updateCacheSize(n,s),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?p=n.getVisibleUnwrappedCoordinates(this._source.tileID).map(T=>new vr(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y)):(p=n.coveringTiles({tileSize:s||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!u,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(p=p.filter(T=>this._source.hasTile(T)))):p=[];const g=this._updateRetainedTiles(p);if(lM(this._source.type)&&p.length!==0){const T={},D={},I=Object.keys(g);for(const B of I){const N=g[B],W=this._tiles[B];if(!W||W.fadeEndTime&&W.fadeEndTime<=wt.now())continue;const K=this.findLoadedParent(N,Math.max(N.overscaledZ-Ql.maxOverzooming,this._source.minzoom));K&&(this._addTile(K.tileID),T[K.tileID.key]=K.tileID),D[B]=N}const z=p[p.length-1].overscaledZ;for(const B in this._tiles){const N=this._tiles[B];if(g[B]||!N.hasData())continue;let W=N.tileID;for(;W.overscaledZ>z;){W=W.scaledTo(W.overscaledZ-1);const K=this._tiles[W.key];if(K&&K.hasData()&&D[W.key]){g[B]=N.tileID;break}}}for(const B in T)g[B]||(this._coveredTiles[B]=!0,g[B]=T[B])}for(const T in g)this._tiles[T].clearFadeHold();const _=function(T,D){const I=[];for(const z in T)z in D||I.push(z);return I}(this._tiles,g);for(const T of _){const D=this._tiles[T];D.hasSymbolBuckets&&!D.holdingForFade()?D.setHoldDuration(this.map._fadeDuration):D.hasSymbolBuckets&&!D.symbolFadeFinished()||this._removeTile(+T)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const n in this._tiles)this._tiles[n].holdingForFade()&&this._removeTile(+n)}_updateRetainedTiles(n){const s={};if(n.length===0)return s;const u={},p=n.reduce((I,z)=>Math.min(I,z.overscaledZ),1/0),g=n[0].overscaledZ,_=Math.max(g-Ql.maxOverzooming,this._source.minzoom),T=Math.max(g+Ql.maxUnderzooming,this._source.minzoom),D={};for(const I of n){const z=this._addTile(I);s[I.key]=I,z.hasData()||p=this._source.maxzoom){const N=I.children(this._source.maxzoom)[0],W=this.getTile(N);if(W&&W.hasData()){s[N.key]=N;continue}}else{const N=I.children(this._source.maxzoom);if(s[N[0].key]&&s[N[1].key]&&s[N[2].key]&&s[N[3].key])continue}let B=z.wasRequested();for(let N=I.overscaledZ-1;N>=_;--N){const W=I.scaledTo(N);if(u[W.key]||(u[W.key]=!0,z=this.getTile(W),!z&&B&&(z=this._addTile(W)),z&&(s[W.key]=W,B=z.wasRequested(),z.hasData())))break}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const n in this._tiles){const s=[];let u,p=this._tiles[n].tileID;for(;p.overscaledZ>0;){if(p.key in this._loadedParentTiles){u=this._loadedParentTiles[p.key];break}s.push(p.key);const g=p.scaledTo(p.overscaledZ-1);if(u=this._getLoadedTile(g),u)break;p=g}for(const g of s)this._loadedParentTiles[g]=u}}_addTile(n){let s=this._tiles[n.key];if(s)return this._source.prepareTile&&this._source.prepareTile(s),s;s=this._cache.getAndRemove(n),s&&(this._setTileReloadTimer(n.key,s),s.tileID=n,this._state.initializeTileState(s,this.map?this.map.painter:null),this._cacheTimers[n.key]&&(clearTimeout(this._cacheTimers[n.key]),delete this._cacheTimers[n.key],this._setTileReloadTimer(n.key,s)));const u=!!s;if(!u){const p=this.map?this.map.painter:null;s=new nx(n,this._source.tileSize*n.overscaleFactor(),this.transform.tileZoom,p,this._isRaster),this._source.prepareTile&&this._source.prepareTile(s)||this._loadTile(s,this._tileLoaded.bind(this,s,n.key,s.state))}return s?(s.uses++,this._tiles[n.key]=s,u||this._source.fire(new Y("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s):null}_setTileReloadTimer(n,s){n in this._timers&&(clearTimeout(this._timers[n]),delete this._timers[n]);const u=s.getExpiryTimeout();u&&(this._timers[n]=setTimeout(()=>{this._reloadTile(n,"expired"),delete this._timers[n]},u))}_removeTile(n){const s=this._tiles[n];s&&(s.uses--,delete this._tiles[n],this._timers[n]&&(clearTimeout(this._timers[n]),delete this._timers[n]),s.uses>0||(s.hasData()&&s.state!=="reloading"?this._cache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const n in this._tiles)this._removeTile(+n);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(n,s,u){const p=[],g=this.transform;if(!g)return p;for(const _ in this._tiles){const T=this._tiles[_];if(u&&T.clearQueryDebugViz(),T.holdingForFade())continue;const D=n.containsTile(T,g,s);D&&p.push(D)}return p}getVisibleCoordinates(n){const s=this.getRenderableIds(n).map(u=>this._tiles[u].tileID);for(const u of s)u.projMatrix=this.transform.calculateProjMatrix(u.toUnwrapped());return s}hasTransition(){if(this._source.hasTransition())return!0;if(lM(this._source.type))for(const n in this._tiles){const s=this._tiles[n];if(s.fadeEndTime!==void 0&&s.fadeEndTime>=wt.now())return!0}return!1}setFeatureState(n,s,u){this._state.updateState(n=n||"_geojsonTileLayer",s,u)}removeFeatureState(n,s,u){this._state.removeFeatureState(n=n||"_geojsonTileLayer",s,u)}getFeatureState(n,s){return this._state.getState(n=n||"_geojsonTileLayer",s)}setDependencies(n,s,u){const p=this._tiles[n];p&&p.setDependencies(s,u)}reloadTilesForDependencies(n,s){for(const u in this._tiles)this._tiles[u].hasDependency(n,s)&&this._reloadTile(+u,"reloading");this._cache.filter(u=>!u.hasDependency(n,s))}_preloadTiles(n,s){const u=new Map,p=Array.isArray(n)?n:[n],g=this.map.painter.terrain,_=this.usedForTerrain&&g?g.getScaledDemTileSize():this._source.tileSize;for(const T of p){const D=T.coveringTiles({tileSize:_,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const I of D)u.set(I.key,I);this.usedForTerrain&&T.updateElevation(!1)}le(Array.from(u.values()),(T,D)=>{const I=new nx(T,this._source.tileSize*T.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(I,z=>{this._source.type==="raster-dem"&&I.dem&&this._backfillDEM(I),D(z,I)})},s)}}function sM(a,n){const s=Math.abs(2*a.wrap)-+(a.wrap<0),u=Math.abs(2*n.wrap)-+(n.wrap<0);return a.overscaledZ-n.overscaledZ||u-s||n.canonical.y-a.canonical.y||n.canonical.x-a.canonical.x}function lM(a){return a==="raster"||a==="image"||a==="video"}Ql.maxOverzooming=10,Ql.maxUnderzooming=3;class Jg{constructor(n,s,u){this._demTile=n,this._dem=this._demTile.dem,this._scale=s,this._offset=u}static create(n,s,u){const p=u||n.findDEMTileFor(s);if(!p||!p.dem)return;const g=p.dem,_=p.tileID,T=1<=0&&B[3]>=0&&D.insert(T,B[0],B[1],B[2],B[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Kl.VectorTile(new Pp(this.rawTileData)).layers,this.sourceLayerCoder=new Xw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const n in this.vtLayers)this.vtFeatures[n]=[]}return this.vtLayers}query(n,s,u,p){this.loadVTLayers();const g=n.params||{},_=ca(g.filter),T=n.tileResult,D=n.transform,I=T.bufferedTilespaceBounds,z=this.grid.query(I.min.x,I.min.y,I.max.x,I.max.y,(K,oe,ue,xe)=>Sb(T.bufferedTilespaceGeometry,K,oe,ue,xe));z.sort(kF);let B=null;D.elevation&&z.length>0&&(B=Jg.create(D.elevation,this.tileID));const N={};let W;for(let K=0;K(xe||(xe=Xa(Be,this.tileID.canonical,n.tileTransform)),$e.queryIntersectsFeature(T,Be,Ze,xe,this.z,n.transform,n.pixelPosMatrix,B,Ye)))}return N}loadMatchingFeature(n,s,u,p,g,_,T,D,I){const{featureIndex:z,bucketIndex:B,sourceLayerIndex:N,layoutVertexArrayOffset:W}=s,K=this.bucketLayerIDs[B];if(p&&!function(Be,$e){for(let Ze=0;Ze=0)return!0;return!1}(p,K))return;const oe=this.sourceLayerCoder.decode(N),ue=this.vtLayers[oe].feature(z);if(u.needGeometry){const Be=Xl(ue,!0);if(!u.filter(new ci(this.tileID.overscaledZ),Be,this.tileID.canonical))return}else if(!u.filter(new ci(this.tileID.overscaledZ),ue))return;const xe=this.getId(ue,oe);for(let Be=0;Be{const T=n instanceof C?n.get(_):null;return T&&T.evaluate?T.evaluate(s,u,p):T})}function kF(a,n){return n-a}$t(cM,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class hM{constructor(n){const s={},u=[];for(const T in n){const D=n[T],I=s[T]={};for(const z in D.glyphs){const B=D.glyphs[+z];if(!B||B.bitmap.width===0||B.bitmap.height===0)continue;const N=B.metrics.localGlyph?2:1,W={x:0,y:0,w:B.bitmap.width+2*N,h:B.bitmap.height+2*N};u.push(W),I[z]=W}}const{w:p,h:g}=Ov(u),_=new Za({width:p||1,height:g||1});for(const T in n){const D=n[T];for(const I in D.glyphs){const z=D.glyphs[+I];if(!z||z.bitmap.width===0||z.bitmap.height===0)continue;const B=s[T][I],N=z.metrics.localGlyph?2:1;Za.copy(z.bitmap,_,{x:0,y:0},{x:B.x+N,y:B.y+N},z.bitmap)}}this.image=_,this.positions=s}}$t(hM,"GlyphAtlas");class zF{constructor(n){this.tileID=new vr(n.tileID.overscaledZ,n.tileID.wrap,n.tileID.canonical.z,n.tileID.canonical.x,n.tileID.canonical.y),this.tileZoom=n.tileZoom,this.uid=n.uid,this.zoom=n.zoom,this.canonical=n.tileID.canonical,this.pixelRatio=n.pixelRatio,this.tileSize=n.tileSize,this.source=n.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=n.showCollisionBoxes,this.collectResourceTiming=!!n.collectResourceTiming,this.returnDependencies=!!n.returnDependencies,this.promoteId=n.promoteId,this.enableTerrain=!!n.enableTerrain,this.isSymbolTile=n.isSymbolTile,this.tileTransform=Jl(n.tileID.canonical,n.projection),this.projection=n.projection}parse(n,s,u,p,g){this.status="parsing",this.data=n,this.collisionBoxArray=new Uo;const _=new Xw(Object.keys(n.layers).sort()),T=new cM(this.tileID,this.promoteId);T.bucketLayerIDs=[];const D={},I=new Jv(256,256),z={featureIndex:T,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:I,availableImages:u},B=s.familiesBySource[this.source];for(const Ye in B){const Ke=n.layers[Ye];if(!Ke)continue;let ut=!1,dt=!1;for(const st of B[Ye])st[0].type==="symbol"?ut=!0:dt=!0;if(this.isSymbolTile===!0&&!ut||this.isSymbolTile===!1&&!dt)continue;Ke.version===1&&be(`Vector tile source "${this.source}" layer "${Ye}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const xt=_.encode(Ye),Et=[];for(let st=0;st=mt.maxzoom||mt.visibility!=="none"&&(sx(st,this.zoom,u),(D[mt.id]=mt.createBucket({index:T.bucketLayerIDs.length,layers:st,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:xt,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.name,availableImages:u})).populate(Et,z,this.tileID.canonical,this.tileTransform),T.bucketLayerIDs.push(st.map(Pt=>Pt.id)))}}let N,W,K,oe;I.trim();const ue={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},xe=Dt(z.glyphDependencies,Ye=>Object.keys(Ye).map(Number));Object.keys(xe).length?p.send("getGlyphs",{uid:this.uid,stacks:xe},(Ye,Ke)=>{N||(N=Ye,W=Ke,Ze.call(this))},void 0,!1,ue):W={};const Be=Object.keys(z.iconDependencies);Be.length?p.send("getImages",{icons:Be,source:this.source,tileID:this.tileID,type:"icons"},(Ye,Ke)=>{N||(N=Ye,K=Ke,Ze.call(this))},void 0,!1,ue):K={};const $e=Object.keys(z.patternDependencies);function Ze(){if(N)return g(N);if(W&&K&&oe){const Ye=new hM(W),Ke=new gw(K,oe);for(const ut in D){const dt=D[ut];dt instanceof Gs?(sx(dt.layers,this.zoom,u),cF(dt,W,Ye.positions,K,Ke.iconPositions,this.showCollisionBoxes,u,this.tileID.canonical,this.tileZoom,this.projection)):dt.hasPattern&&(dt instanceof Ng||dt instanceof Bg||dt instanceof Cp)&&(sx(dt.layers,this.zoom,u),dt.addFeatures(z,this.tileID.canonical,Ke.patternPositions,u,this.tileTransform))}this.status="done",g(null,{buckets:fe(D).filter(ut=>!ut.isEmpty()),featureIndex:T,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ye.image,lineAtlas:I,imageAtlas:Ke,glyphMap:this.returnDependencies?W:null,iconMap:this.returnDependencies?K:null,glyphPositions:this.returnDependencies?Ye.positions:null})}}$e.length?p.send("getImages",{icons:$e,source:this.source,tileID:this.tileID,type:"patterns"},(Ye,Ke)=>{N||(N=Ye,oe=Ke,Ze.call(this))},void 0,!1,ue):oe={},Ze.call(this)}}function sx(a,n,s){const u=new ci(n);for(const p of a)p.recalculate(u,s)}class dM{constructor(n){this.entries={},this.scheduler=n}request(n,s,u,p){const g=this.entries[n]=this.entries[n]||{callbacks:[]};if(g.result){const[_,T]=g.result;return this.scheduler?this.scheduler.add(()=>{p(_,T)},s):p(_,T),()=>{}}return g.callbacks.push(p),g.cancel||(g.cancel=u((_,T)=>{g.result=[_,T];for(const D of g.callbacks)this.scheduler?this.scheduler.add(()=>{D(_,T)},s):D(_,T);setTimeout(()=>delete this.entries[n],3e3)})),()=>{g.result||(g.callbacks=g.callbacks.filter(_=>_!==p),g.callbacks.length||(g.cancel(),delete this.entries[n]))}}}function pM(a,n,s){const u=JSON.stringify(a.request);return a.data&&(this.deduped.entries[u]={result:[null,a.data]}),this.deduped.request(u,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},p=>{const g=Re(a.request,(_,T,D,I)=>{_?p(_):T&&p(null,{vectorTile:s?void 0:new Kl.VectorTile(new Pp(T)),rawData:T,cacheControl:D,expires:I})});return()=>{g.cancel(),p()}},n)}const FF=ga(new Float32Array(16));class $s{constructor(n){this.name=n.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(n,s){return{x:0,y:0,z:0}}unproject(n,s){return new ti(0,0)}projectTilePoint(n,s,u){return{x:n,y:s,z:0}}locationPoint(n,s){return n._coordinatePoint(n.locationCoordinate(s),!1)}pixelsPerMeter(n,s){return Hu(1,n)*s}farthestPixelDistance(n){return function(s,u){const p=s.fovAboveCenter,g=s.elevation?s.elevation.getMinElevationBelowMSL()*u:0,_=(s._camera.position[2]*s.worldSize-g)/Math.cos(s._pitch),T=Math.sin(p)*_/Math.sin(Math.max(Math.PI/2-s._pitch-p,.01)),D=Math.sin(s._pitch)*T+_;return Math.min(1.01*D,_*(1/s._horizonShift))}(n,n.pixelsPerMeter)}pointCoordinate(n,s,u,p){const g=n.horizonLineFromTop(!1),_=new b(s,Math.max(g,u));return n.rayIntersectionCoordinate(n.pointRayIntersection(_,p))}createInversionMatrix(n,s){return FF}createTileMatrix(n,s,u){let p,g,_;const T=u.canonical,D=ga(new Float64Array(16));if(this.isReprojectedInTileSpace){const I=Jl(T,this);p=1,g=I.x+u.wrap*I.scale,_=I.y,Ns(D,D,[p/I.scale,p/I.scale,n.pixelsPerMeter/s])}else p=s/n.zoomScale(T.z),g=(T.x+Math.pow(2,T.z)*u.wrap)*p,_=T.y*p;return Zl(D,D,[g,_,0]),Ns(D,D,[p/In,p/In,1]),D}upVector(n,s,u){return[0,0,1]}upVectorScale(n,s,u){return{metersToTile:1,metersToLabelSpace:1}}}class BF extends $s{constructor(n){super(n),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(n,s){return{x:fp(n),y:ju(s),z:0}}unproject(n,s){const u=To(n),p=rr(s);return new ti(u,p)}}class OF extends $s{constructor(n){super(n),this.range=[4,7],this.center=n.center||[-96,37.5];const[s,u]=this.parallels=n.parallels||[29.5,45.5],p=Math.sin(F(s));this.n=(p+Math.sin(F(u)))/2,this.c=1+p*(2*this.n-p),this.r0=Math.sqrt(this.c)/this.n}project(n,s){const{n:u,c:p,r0:g}=this,_=F(n-this.center[0]),T=F(s),D=Math.sqrt(p-2*u*Math.sin(T))/u;return{x:D*Math.sin(_*u),y:D*Math.cos(_*u)-g,z:0}}unproject(n,s){const{n:u,c:p,r0:g}=this,_=g+s;let T=Math.atan2(n,Math.abs(_))*Math.sign(_);_*u<0&&(T-=Math.PI*Math.sign(n)*Math.sign(_));const D=F(this.center[0])*u;T=ie(T,-Math.PI-D,Math.PI-D);const I=V(T/u)+this.center[0],z=Math.asin(Q((p-(n*n+_*_)*u*u)/(2*u),-1,1)),B=Q(V(z),-85.051129,ma);return new ti(I,B)}}const Fp=1.340264,Bp=-.081106,Op=893e-6,Np=.003796,Qg=Math.sqrt(3)/2;class NF extends $s{project(n,s){s=s/180*Math.PI,n=n/180*Math.PI;const u=Math.asin(Qg*Math.sin(s)),p=u*u,g=p*p*p;return{x:.5*(n*Math.cos(u)/(Qg*(Fp+3*Bp*p+g*(7*Op+9*Np*p)))/Math.PI+.5),y:1-.5*(u*(Fp+Bp*p+g*(Op+Np*p))/Math.PI+1),z:0}}unproject(n,s){n=(2*n-.5)*Math.PI;let u=s=(2*(1-s)-1)*Math.PI,p=u*u,g=p*p*p;for(let z,B,N,W=0;W<12&&(B=u*(Fp+Bp*p+g*(Op+Np*p))-s,N=Fp+3*Bp*p+g*(7*Op+9*Np*p),z=B/N,u=Q(u-z,-Math.PI/3,Math.PI/3),p=u*u,g=p*p*p,!(Math.abs(z)<1e-12));++W);const _=Qg*n*(Fp+3*Bp*p+g*(7*Op+9*Np*p))/Math.cos(u),T=Math.asin(Math.sin(u)/Qg),D=Q(180*_/Math.PI,-180,180),I=Q(180*T/Math.PI,-85.051129,ma);return new ti(D,I)}}class UF extends $s{constructor(n){super(n),this.wrap=!0,this.supportsWorldCopies=!0}project(n,s){return{x:.5+n/360,y:.5-s/360,z:0}}unproject(n,s){const u=360*(n-.5),p=Q(360*(.5-s),-85.051129,ma);return new ti(u,p)}}const ah=Math.PI/2;function ey(a){return Math.tan((ah+a)/2)}class VF extends $s{constructor(n){super(n),this.center=n.center||[0,30];const[s,u]=this.parallels=n.parallels||[30,30],p=F(s),g=F(u),_=Math.cos(p);this.n=p===g?Math.sin(p):Math.log(_/Math.cos(g))/Math.log(ey(g)/ey(p)),this.f=_*Math.pow(ey(p),this.n)/this.n}project(n,s){s=F(s),n=F(n-this.center[0]);const u=1e-6,{n:p,f:g}=this;g>0?s<-ah+u&&(s=-ah+u):s>ah-u&&(s=ah-u);const _=g/Math.pow(ey(s),p),T=_*Math.sin(p*n),D=g-_*Math.cos(p*n);return{x:.5*(T/Math.PI+.5),y:1-.5*(D/Math.PI+.5),z:0}}unproject(n,s){n=(2*n-.5)*Math.PI,s=(2*(1-s)-.5)*Math.PI;const{n:u,f:p}=this,g=p-s,_=Math.sign(g),T=Math.sign(u)*Math.sqrt(n*n+g*g);let D=Math.atan2(n,Math.abs(g))*_;g*u<0&&(D-=Math.PI*Math.sign(n)*_);const I=Q(V(D/u)+this.center[0],-180,180),z=Q(V(2*Math.atan(Math.pow(p/T,1/u))-ah),-85.051129,ma);return new ti(I,z)}}const fM=F(ma);class GF extends $s{project(n,s){const u=(s=F(s))*s,p=u*u;return{x:.5*((n=F(n))*(.8707-.131979*u+p*(p*(.003971*u-.001529*p)-.013791))/Math.PI+.5),y:1-.5*(s*(1.007226+u*(.015085+p*(.028874*u-.044475-.005916*p)))/Math.PI+1),z:0}}unproject(n,s){n=(2*n-.5)*Math.PI;let u=s=(2*(1-s)-1)*Math.PI,p=25,g=0,_=u*u;do{_=u*u;const I=_*_;g=(u*(1.007226+_*(.015085+I*(.028874*_-.044475-.005916*I)))-s)/(1.007226+_*(.045255+I*(.259866*_-.311325-.06507600000000001*I))),u=Q(u-g,-fM,fM)}while(Math.abs(g)>1e-6&&--p>0);_=u*u;const T=Q(V(n/(.8707+_*(_*(_*_*_*(.003971-.001529*_)-.013791)-.131979))),-180,180),D=V(u);return new ti(T,D)}}const mM=F(ma);class WF extends $s{project(n,s){s=F(s),n=F(n);const u=Math.cos(s),p=2/Math.PI,g=Math.acos(u*Math.cos(n/2)),_=Math.sin(g)/g,T=.5*(n*p+2*u*Math.sin(n/2)/_)||0,D=.5*(s+Math.sin(s)/_)||0;return{x:.5*(T/Math.PI+.5),y:1-.5*(D/Math.PI+1),z:0}}unproject(n,s){let u=n=(2*n-.5)*Math.PI,p=s=(2*(1-s)-1)*Math.PI,g=25;const _=1e-6;let T=0,D=0;do{const I=Math.cos(p),z=Math.sin(p),B=2*z*I,N=z*z,W=I*I,K=Math.cos(u/2),oe=Math.sin(u/2),ue=2*K*oe,xe=oe*oe,Be=1-W*K*K,$e=Be?1/Be:0,Ze=Be?Math.acos(I*K)*Math.sqrt(1/Be):0,Ye=.5*(2*Ze*I*oe+2*u/Math.PI)-n,Ke=.5*(Ze*z+p)-s,ut=.5*$e*(W*xe+Ze*I*K*N)+1/Math.PI,dt=$e*(ue*B/4-Ze*z*oe),xt=.125*$e*(B*oe-Ze*z*W*ue),Et=.5*$e*(N*K+Ze*xe*I)+.5,st=dt*xt-Et*ut;T=(Ke*dt-Ye*Et)/st,D=(Ye*xt-Ke*ut)/st,u=Q(u-T,-Math.PI,Math.PI),p=Q(p-D,-mM,mM)}while((Math.abs(T)>_||Math.abs(D)>_)&&--g>0);return new ti(V(u),V(p))}}class gM extends $s{constructor(n){super(n),this.center=n.center||[0,0],this.parallels=n.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(F(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(n,s){const{scale:u,cosPhi:p}=this;return{x:F(n)*p*u+.5,y:-Math.sin(F(s))/p*u+.5,z:0}}unproject(n,s){const{scale:u,cosPhi:p}=this,g=-(s-.5)/u,_=Q(V((n-.5)/u)/p,-180,180),T=Math.asin(Q(g*p,-1,1)),D=Q(V(T),-85.051129,ma);return new ti(_,D)}}r.ARRAY_TYPE=Zr,r.AUTH_ERR_MSG=wn,r.Aabb=go,r.Actor=class{constructor(a,n,s){this.target=a,this.parent=n,this.mapId=s,this.callbacks={},this.cancelCallbacks={},At(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ke()?a:L,this.scheduler=new MF}send(a,n,s,u,p=!1,g){const _=Math.round(1e18*Math.random()).toString(36).substring(0,10);s&&(s.metadata=g,this.callbacks[_]=s);const T=Je(this.globalScope)?void 0:[];return this.target.postMessage({id:_,type:a,hasCallback:!!s,targetMapId:u,mustQueue:p,sourceMapId:this.mapId,data:Nl(n,T)},T),{cancel:()=>{s&&delete this.callbacks[_],this.target.postMessage({id:_,type:"",targetMapId:u,sourceMapId:this.mapId})}}}receive(a){const n=a.data,s=n.id;if(s&&(!n.targetMapId||this.mapId===n.targetMapId))if(n.type===""){const u=this.cancelCallbacks[s];delete this.cancelCallbacks[s],u&&u.cancel()}else if(n.mustQueue||ke()){const u=this.callbacks[s];this.cancelCallbacks[s]=this.scheduler.add(()=>this.processTask(s,n),u&&u.metadata||{type:"message"})}else this.processTask(s,n)}processTask(a,n){if(n.type===""){const s=this.callbacks[a];delete this.callbacks[a],s&&(n.error?s(Ls(n.error)):s(null,Ls(n.data)))}else{const s=Je(this.globalScope)?void 0:[],u=n.hasCallback?(g,_)=>{delete this.cancelCallbacks[a],this.target.postMessage({id:a,type:"",sourceMapId:this.mapId,error:g?Nl(g):null,data:Nl(_,s)},s)}:g=>{},p=Ls(n.data);if(this.parent[n.type])this.parent[n.type](n.sourceMapId,p,u);else if(this.parent.getWorkerSource){const g=n.type.split(".");this.parent.getWorkerSource(n.sourceMapId,g[0],p.source)[g[1]](p,u)}else u(new Error(`Could not find function ${n.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},r.CanonicalTileID=Zg,r.Color=Xn,r.ColorMode=xa,r.CullFaceMode=jo,r.DEMData=Kg,r.DataConstantProperty=S,r.DedupedRequest=dM,r.DepthMode=oh,r.EXTENT=In,r.Elevation=class{isDataAvailableAtPoint(a){const n=this._source();if(!n||a.y<0||a.y>1)return!1;const s=n.getSource().maxzoom,u=1<1)return n;const p=u.getSource().maxzoom,g=1<{const g=this.getAtTileOffset(a,p.x,p.y),_=u.upVector(a.canonical,p.x,p.y);return gp(_,_,g*u.upVectorScale(a.canonical,n,s).metersToTile),_}}getForTilePoints(a,n,s,u){const p=Jg.create(this,a,u);return!!p&&(n.forEach(g=>{g[2]=this.exaggeration()*p.getElevationAt(g[0],g[1],s)}),!0)}getMinMaxForTile(a){const n=this.findDEMTileFor(a);if(!n||!n.dem)return null;const s=n.dem.tree,u=n.tileID,p=1<this._skuTokenExpiresAt}transformRequest(a,n){return this._transformRequestFn&&this._transformRequestFn(a,n)||{url:a}}normalizeStyleURL(a,n){if(!cn(a))return a;const s=Xt(a);return s.path=`/styles/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||n)}normalizeGlyphsURL(a,n){if(!cn(a))return a;const s=Xt(a);return s.path=`/fonts/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||n)}normalizeSourceURL(a,n){if(!cn(a))return a;const s=Xt(a);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),this._makeAPIURL(s,this._customAccessToken||n)}normalizeSpriteURL(a,n,s,u){const p=Xt(a);return cn(a)?(p.path=`/styles/v1${p.path}/sprite${n}${s}`,this._makeAPIURL(p,this._customAccessToken||u)):(p.path+=`${n}${s}`,Xe(p))}normalizeTileURL(a,n,s){if(this._isSkuTokenExpired()&&this._createSkuToken(),a&&!cn(a))return a;const u=Xt(a);u.path=u.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${n||s&&u.authority!=="raster"&&s===512?"@2x":""}${Me.supported?".webp":"$1"}`),u.authority==="raster"?u.path=`/${pe.RASTER_URL_PREFIX}${u.path}`:(u.path=u.path.replace(/^.+\/v4\//,"/"),u.path=`/${pe.TILE_URL_VERSION}${u.path}`);const p=this._customAccessToken||function(g){for(const _ of g){const T=_.match(/^access_token=(.*)$/);if(T)return T[1]}return null}(u.params)||pe.ACCESS_TOKEN;return pe.REQUIRE_ACCESS_TOKEN&&p&&this._skuToken&&u.params.push(`sku=${this._skuToken}`),this._makeAPIURL(u,p)}canonicalizeTileURL(a,n){const s=Xt(a);if(!s.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!s.path.match(/\.[\w]+$/))return a;let u="mapbox://";s.path.match(/^\/raster\/v1\//)?u+=`raster/${s.path.replace(`/${pe.RASTER_URL_PREFIX}/`,"")}`:u+=`tiles/${s.path.replace(`/${pe.TILE_URL_VERSION}/`,"")}`;let p=s.params;return n&&(p=p.filter(g=>!g.match(/^access_token=/))),p.length&&(u+=`?${p.join("&")}`),u}canonicalizeTileset(a,n){const s=!!n&&cn(n),u=[];for(const p of a.tiles||[])Wt(p)?u.push(this.canonicalizeTileURL(p,s)):u.push(p);return u}_makeAPIURL(a,n){const s="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",u=Xt(pe.API_URL);if(a.protocol=u.protocol,a.authority=u.authority,a.protocol==="http"){const p=a.params.indexOf("secure");p>=0&&a.params.splice(p,1)}if(u.path!=="/"&&(a.path=`${u.path}${a.path}`),!pe.REQUIRE_ACCESS_TOKEN)return Xe(a);if(n=n||pe.ACCESS_TOKEN,!this._silenceAuthErrors){if(!n)throw new Error(`An API access token is required to use Mapbox GL. ${s}`);if(n[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${s}`)}return a.params=a.params.filter(p=>p.indexOf("access_token")===-1),a.params.push(`access_token=${n||""}`),Xe(a)}},r.ResourceType=we,r.SegmentVector=Ei,r.SourceCache=Ql,r.StencilMode=rx,r.StructArrayLayout1ui2=$n,r.StructArrayLayout2f1f2i16=Jt,r.StructArrayLayout2i4=De,r.StructArrayLayout2ui4=Mn,r.StructArrayLayout3f12=kt,r.StructArrayLayout3ui6=qt,r.StructArrayLayout4i8=ze,r.Texture=Ip,r.Tile=nx,r.Transitionable=m,r.Uniform1f=Cg,r.Uniform1i=class extends $a{constructor(a,n){super(a,n),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},r.Uniform2f=class extends $a{constructor(a,n){super(a,n),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]))}},r.Uniform3f=class extends $a{constructor(a,n){super(a,n),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]))}},r.Uniform4f=xb,r.UniformColor=bb,r.UniformMatrix2f=class extends $a{constructor(a,n){super(a,n),this.current=Ek}set(a){for(let n=0;n<4;n++)if(a[n]!==this.current[n]){this.current=a,this.gl.uniformMatrix2fv(this.location,!1,a);break}}},r.UniformMatrix3f=class extends $a{constructor(a,n){super(a,n),this.current=Tk}set(a){for(let n=0;n<9;n++)if(a[n]!==this.current[n]){this.current=a,this.gl.uniformMatrix3fv(this.location,!1,a);break}}},r.UniformMatrix4f=class extends $a{constructor(a,n){super(a,n),this.current=Mk}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 n=1;n<16;n++)if(a[n]!==this.current[n]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},r.UnwrappedTileID=qw,r.ValidationError=jt,r.VectorTileWorkerSource=class extends Fe{constructor(a,n,s,u,p){super(),this.actor=a,this.layerIndex=n,this.availableImages=s,this.loadVectorData=p||pM,this.loading={},this.loaded={},this.deduped=new dM(a.scheduler),this.isSpriteLoaded=u,this.scheduler=a.scheduler}loadTile(a,n){const s=a.uid,u=a&&a.request,p=u&&u.collectResourceTiming,g=this.loading[s]=new zF(a);g.abort=this.loadVectorData(a,(_,T)=>{const D=!this.loading[s];if(delete this.loading[s],D||_||!T)return g.status="done",D||(this.loaded[s]=g),n(_);const I=T.rawData,z={};T.expires&&(z.expires=T.expires),T.cacheControl&&(z.cacheControl=T.cacheControl),g.vectorTile=T.vectorTile||new Kl.VectorTile(new Pp(I));const B=()=>{g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,(N,W)=>{if(N||!W)return n(N);const K={};if(p){const oe=Bw(u);oe.length>0&&(K.resourceTiming=JSON.parse(JSON.stringify(oe)))}n(null,me({rawTileData:I.slice(0)},W,z,K))})};this.isSpriteLoaded?B():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(B,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):B()}),this.loaded=this.loaded||{},this.loaded[s]=g})}reloadTile(a,n){const s=this.loaded,u=a.uid,p=this;if(s&&s[u]){const g=s[u];g.showCollisionBoxes=a.showCollisionBoxes,g.enableTerrain=!!a.enableTerrain,g.projection=a.projection,g.tileTransform=Jl(a.tileID.canonical,a.projection);const _=(T,D)=>{const I=g.reloadCallback;I&&(delete g.reloadCallback,g.parse(g.vectorTile,p.layerIndex,this.availableImages,p.actor,I)),n(T,D)};g.status==="parsing"?g.reloadCallback=_:g.status==="done"&&(g.vectorTile?g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,_):_())}}abortTile(a,n){const s=a.uid,u=this.loading[s];u&&(u.abort&&u.abort(),delete this.loading[s]),n()}removeTile(a,n){const s=this.loaded,u=a.uid;s&&s[u]&&delete s[u],n()}},r.WritingMode=yo,r.ZoomHistory=ep,r.add=Fb,r.addDynamicAttributes=qv,r.adjoint=function(a,n){var s=n[0],u=n[1],p=n[2],g=n[3],_=n[4],T=n[5],D=n[6],I=n[7],z=n[8];return a[0]=_*z-T*I,a[1]=p*I-u*z,a[2]=u*T-p*_,a[3]=T*D-g*z,a[4]=s*z-p*D,a[5]=p*g-s*T,a[6]=g*I-_*D,a[7]=u*D-s*I,a[8]=s*_-u*g,a},r.asyncAll=le,r.bezier=ne,r.bindAll=At,r.boundsAttributes=Kw,r.bufferConvexPolygon=function(a,n){const s=[];for(let u=0;ujr&&(a.getActor().send("enforceCacheSizeLimit",_i),Ar=0)},r.calculateGlobeLabelMatrix=function(a,n){const{lng:s,lat:u}=a._center,p=Ww(0,0,a.worldSize/a._projectionScaler,s,u);return xv(p,p,function(g){const _=ga(new Float64Array(16)),T=1/tx(g);return Zl(_,_,g.min),Ns(_,_,[T,T,T]),_}(kp(n)))},r.calculateGlobeMatrix=jw,r.calculateGlobeMercatorMatrix=function(a){const n=a.worldSize,s=a.point,u=Hu(1,a.center.lat)*n,p=a.pixelsPerMeter,g=n/(u/a.pixelsPerMeter),_=ga(new Float64Array(16));return Zl(_,_,[s.x,s.y,0]),Ns(_,_,[g,g,p]),Float32Array.from(_)},r.circumferenceAtLatitude=pv,r.clamp=Q,r.clearTileCache=function(a){const n=L.caches.delete(Di);a&&n.catch(a).then(()=>a())},r.clipLine=Dw,r.clone=function(a){var n=new Zr(16);return n[0]=a[0],n[1]=a[1],n[2]=a[2],n[3]=a[3],n[4]=a[4],n[5]=a[5],n[6]=a[6],n[7]=a[7],n[8]=a[8],n[9]=a[9],n[10]=a[10],n[11]=a[11],n[12]=a[12],n[13]=a[13],n[14]=a[14],n[15]=a[15],n},r.clone$1=Nt,r.collisionCircleLayout=zz,r.config=pe,r.conjugate=function(a,n){return a[0]=-n[0],a[1]=-n[1],a[2]=-n[2],a[3]=n[3],a},r.create=function(){var a=new Zr(16);return Zr!=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},r.create$1=Rb,r.createExpression=Ll,r.createLayout=Le,r.createStyleLayer=function(a){return a.type==="custom"?new _F(a):new xF[a.type](a)},r.cross=Nb,r.degToRad=F,r.div=function(a,n,s){return a[0]=n[0]/s[0],a[1]=n[1]/s[1],a[2]=n[2]/s[2],a},r.dot=_p,r.earthRadius=dv,r.ease=H,r.easeCubicInOut=J,r.emitValidationErrors=ag,r.endsWith=yt,r.enforceCacheSizeLimit=function(a){zi(),ei&&ei.then(n=>{n.keys().then(s=>{for(let u=0;ug&&(u+=(a[p]-g)*(a[p]-g)),n[p]{}}},r.globeECEFOrigin=function(a,n){const s=[0,0,0];return Yl(s,s,Gw(kp(n.canonical))),Yl(s,s,a),s},r.globePixelsToTileUnits=function(a,n){return In/(512*Math.pow(2,a))*tx(kp(n))},r.globePoleMatrixForTile=function(a,n,s){const u=ga(new Float64Array(16)),p=1<0&&(_=1/Math.sqrt(_)),a[0]=s*_,a[1]=u*_,a[2]=p*_,a[3]=g*_,a},r.number=yn,r.ortho=function(a,n,s,u,p,g,_){var T=1/(n-s),D=1/(u-p),I=1/(g-_);return a[0]=-2*T,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*D,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*I,a[11]=0,a[12]=(n+s)*T,a[13]=(p+u)*D,a[14]=(_+g)*I,a[15]=1,a},r.pbf=Pp,r.perspective=function(a,n,s,u,p){var g,_=1/Math.tan(n/2);return a[0]=_/s,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=_,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,p!=null&&p!==1/0?(a[10]=(p+u)*(g=1/(u-p)),a[14]=2*p*u*g):(a[10]=-1,a[14]=-2*u),a},r.pick=function(a,n){const s={};for(let u=0;uNo(ha(a)),r.validateFog=a=>No(og(a)),r.validateLayer=a=>No(eg(a)),r.validateLight=a=>No(ig(a)),r.validateSource=a=>No(ng(a)),r.validateStyle=Ol,r.validateTerrain=a=>No(rg(a)),r.values=fe,r.vectorTile=Kl,r.version=v,r.warnOnce=be,r.window=L,r.wrap=ie}),h(["./shared"],function(r){function v(we){if(typeof we=="number"||typeof we=="boolean"||typeof we=="string"||we==null)return JSON.stringify(we);if(Array.isArray(we)){let ee="[";for(const ye of we)ee+=`${v(ye)},`;return`${ee}]`}let $="{";for(const ee of Object.keys(we).sort())$+=`${ee}:${v(we[ee])},`;return`${$}}`}function x(we){let $="";for(const ee of r.refProperties)$+=`/${v(we[ee])}`;return $}class w{constructor($){this.keyCache={},$&&this.replace($)}replace($){this._layerConfigs={},this._layers={},this.update($,[])}update($,ee){for(const Re of $)this._layerConfigs[Re.id]=Re,(this._layers[Re.id]=r.createStyleLayer(Re)).compileFilter(),this.keyCache[Re.id]&&delete this.keyCache[Re.id];for(const Re of ee)delete this.keyCache[Re],delete this._layerConfigs[Re],delete this._layers[Re];this.familiesBySource={};const ye=function(Re,je){const et={};for(let qe=0;qethis._layers[Vt.id]),et=je[0];if(et.visibility==="none")continue;const tt=et.source||"";let qe=this.familiesBySource[tt];qe||(qe=this.familiesBySource[tt]={});const rt=et.sourceLayer||"_geojsonTileLayer";let vt=qe[rt];vt||(vt=qe[rt]=[]),vt.push(je)}}}class b{loadTile($,ee){const{uid:ye,encoding:Re,rawImageData:je,padding:et,buildQuadTree:tt}=$,qe=r.window.ImageBitmap&&je instanceof r.window.ImageBitmap?this.getImageData(je,et):je;ee(null,new r.DEMData(ye,qe,Re,et<1,tt))}getImageData($,ee){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas($.width,$.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=$.width,this.offscreenCanvas.height=$.height,this.offscreenCanvasContext.drawImage($,0,0,$.width,$.height);const ye=this.offscreenCanvasContext.getImageData(-ee,-ee,$.width+2*ee,$.height+2*ee);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ye}}var A=function we($,ee){var ye,Re=$&&$.type;if(Re==="FeatureCollection")for(ye=0;ye<$.features.length;ye++)we($.features[ye],ee);else if(Re==="GeometryCollection")for(ye=0;ye<$.geometries.length;ye++)we($.geometries[ye],ee);else if(Re==="Feature")we($.geometry,ee);else if(Re==="Polygon")L($.coordinates,ee);else if(Re==="MultiPolygon")for(ye=0;ye<$.coordinates.length;ye++)L($.coordinates[ye],ee);return $};function L(we,$){if(we.length!==0){P(we[0],$);for(var ee=1;ee=Math.abs(tt)?ee-qe+tt:tt-qe+ee,ee=qe}ee+ye>=0!=!!$&&we.reverse()}const R=r.vectorTile.VectorTileFeature.prototype.toGeoJSON;class F{constructor($){this._feature=$,this.extent=r.EXTENT,this.type=$.type,this.properties=$.tags,"id"in $&&!isNaN($.id)&&(this.id=parseInt($.id,10))}loadGeometry(){if(this._feature.type===1){const $=[];for(const ee of this._feature.geometry)$.push([new r.pointGeometry(ee[0],ee[1])]);return $}{const $=[];for(const ee of this._feature.geometry){const ye=[];for(const Re of ee)ye.push(new r.pointGeometry(Re[0],Re[1]));$.push(ye)}return $}}toGeoJSON($,ee,ye){return R.call(this,$,ee,ye)}}class V{constructor($){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=r.EXTENT,this.length=$.length,this._features=$}feature($){return new F(this._features[$])}}var j=r.vectorTile.VectorTileFeature,J=ne;function ne(we,$){this.options=$||{},this.features=we,this.length=we.length}function H(we,$){this.id=typeof we.id=="number"?we.id:void 0,this.type=we.type,this.rawGeometry=we.type===1?[we.geometry]:we.geometry,this.properties=we.tags,this.extent=$||4096}ne.prototype.feature=function(we){return new H(this.features[we],this.options.extent)},H.prototype.loadGeometry=function(){var we=this.rawGeometry;this.geometry=[];for(var $=0;$>31}function Ve(we,$){for(var ee=we.loadGeometry(),ye=we.type,Re=0,je=0,et=ee.length,tt=0;tt>1;At(we,$,et,ye,Re,je%2),at(we,$,ee,ye,et-1,je+1),at(we,$,ee,et+1,Re,je+1)}function At(we,$,ee,ye,Re,je){for(;Re>ye;){if(Re-ye>600){const rt=Re-ye+1,vt=ee-ye+1,Vt=Math.log(rt),Ct=.5*Math.exp(2*Vt/3),_n=.5*Math.sqrt(Vt*Ct*(rt-Ct)/rt)*(vt-rt/2<0?-1:1);At(we,$,ee,Math.max(ye,Math.floor(ee-vt*Ct/rt+_n)),Math.min(Re,Math.floor(ee+(rt-vt)*Ct/rt+_n)),je)}const et=$[2*ee+je];let tt=ye,qe=Re;for(yt(we,$,ye,ee),$[2*Re+je]>et&&yt(we,$,ye,Re);ttet;)qe--}$[2*ye+je]===et?yt(we,$,ye,qe):(qe++,yt(we,$,qe,Re)),qe<=ee&&(ye=qe+1),ee<=qe&&(Re=qe-1)}}function yt(we,$,ee,ye){Dt(we,ee,ye),Dt($,2*ee,2*ye),Dt($,2*ee+1,2*ye+1)}function Dt(we,$,ee){const ye=we[$];we[$]=we[ee],we[ee]=ye}function It(we,$,ee,ye){const Re=we-ee,je=$-ye;return Re*Re+je*je}Q.fromVectorTileJs=ie,Q.fromGeojsonVt=function(we,$){$=$||{};var ee={};for(var ye in we)ee[ye]=new J(we[ye].features,$),ee[ye].name=ye,ee[ye].version=$.version,ee[ye].extent=$.extent;return ie({layers:ee})},Q.GeoJSONWrapper=ae;const Nt=we=>we[0],Ie=we=>we[1];class be{constructor($,ee=Nt,ye=Ie,Re=64,je=Float64Array){this.nodeSize=Re,this.points=$;const et=$.length<65536?Uint16Array:Uint32Array,tt=this.ids=new et($.length),qe=this.coords=new je(2*$.length);for(let rt=0;rt<$.length;rt++)tt[rt]=rt,qe[2*rt]=ee($[rt]),qe[2*rt+1]=ye($[rt]);at(tt,qe,Re,0,tt.length-1,0)}range($,ee,ye,Re){return function(je,et,tt,qe,rt,vt,Vt){const Ct=[0,je.length-1,0],_n=[];let Y,re;for(;Ct.length;){const Fe=Ct.pop(),Te=Ct.pop(),Tt=Ct.pop();if(Te-Tt<=Vt){for(let rn=Tt;rn<=Te;rn++)Y=et[2*rn],re=et[2*rn+1],Y>=tt&&Y<=rt&&re>=qe&&re<=vt&&_n.push(je[rn]);continue}const _t=Math.floor((Tt+Te)/2);Y=et[2*_t],re=et[2*_t+1],Y>=tt&&Y<=rt&&re>=qe&&re<=vt&&_n.push(je[_t]);const Ot=(Fe+1)%2;(Fe===0?tt<=Y:qe<=re)&&(Ct.push(Tt),Ct.push(_t-1),Ct.push(Ot)),(Fe===0?rt>=Y:vt>=re)&&(Ct.push(_t+1),Ct.push(Te),Ct.push(Ot))}return _n}(this.ids,this.coords,$,ee,ye,Re,this.nodeSize)}within($,ee,ye){return function(Re,je,et,tt,qe,rt){const vt=[0,Re.length-1,0],Vt=[],Ct=qe*qe;for(;vt.length;){const _n=vt.pop(),Y=vt.pop(),re=vt.pop();if(Y-re<=rt){for(let Ot=re;Ot<=Y;Ot++)It(je[2*Ot],je[2*Ot+1],et,tt)<=Ct&&Vt.push(Re[Ot]);continue}const Fe=Math.floor((re+Y)/2),Te=je[2*Fe],Tt=je[2*Fe+1];It(Te,Tt,et,tt)<=Ct&&Vt.push(Re[Fe]);const _t=(_n+1)%2;(_n===0?et-qe<=Te:tt-qe<=Tt)&&(vt.push(re),vt.push(Fe-1),vt.push(_t)),(_n===0?et+qe>=Te:tt+qe>=Tt)&&(vt.push(Fe+1),vt.push(Y),vt.push(_t))}return Vt}(this.ids,this.coords,$,ee,ye,this.nodeSize)}}const We={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:we=>we},Ge=Math.fround||(ke=new Float32Array(1),we=>(ke[0]=+we,ke[0]));var ke;class ot{constructor($){this.options=wt(Object.create(We),$),this.trees=new Array(this.options.maxZoom+1)}load($){const{log:ee,minZoom:ye,maxZoom:Re,nodeSize:je}=this.options;ee&&console.time("total time");const et=`prepare ${$.length} points`;ee&&console.time(et),this.points=$;let tt=[];for(let qe=0;qe<$.length;qe++)$[qe].geometry&&tt.push(Ce($[qe],qe));this.trees[Re+1]=new be(tt,Gt,pe,je,Float32Array),ee&&console.timeEnd(et);for(let qe=Re;qe>=ye;qe--){const rt=+Date.now();tt=this._cluster(tt,qe),this.trees[qe]=new be(tt,Gt,pe,je,Float32Array),ee&&console.log("z%d: %d clusters in %dms",qe,tt.length,+Date.now()-rt)}return ee&&console.timeEnd("total time"),this}getClusters($,ee){let ye=(($[0]+180)%360+360)%360-180;const Re=Math.max(-90,Math.min(90,$[1]));let je=$[2]===180?180:(($[2]+180)%360+360)%360-180;const et=Math.max(-90,Math.min(90,$[3]));if($[2]-$[0]>=360)ye=-180,je=180;else if(ye>je){const vt=this.getClusters([ye,Re,180,et],ee),Vt=this.getClusters([-180,Re,je,et],ee);return vt.concat(Vt)}const tt=this.trees[this._limitZoom(ee)],qe=tt.range(Ne(ye),Je(et),Ne(je),Je(Re)),rt=[];for(const vt of qe){const Vt=tt.points[vt];rt.push(Vt.numPoints?Ae(Vt):this.points[Vt.index])}return rt}getChildren($){const ee=this._getOriginId($),ye=this._getOriginZoom($),Re="No cluster with the specified id.",je=this.trees[ye];if(!je)throw new Error(Re);const et=je.points[ee];if(!et)throw new Error(Re);const tt=this.options.radius/(this.options.extent*Math.pow(2,ye-1)),qe=je.within(et.x,et.y,tt),rt=[];for(const vt of qe){const Vt=je.points[vt];Vt.parentId===$&&rt.push(Vt.numPoints?Ae(Vt):this.points[Vt.index])}if(rt.length===0)throw new Error(Re);return rt}getLeaves($,ee,ye){const Re=[];return this._appendLeaves(Re,$,ee=ee||10,ye=ye||0,0),Re}getTile($,ee,ye){const Re=this.trees[this._limitZoom($)],je=Math.pow(2,$),{extent:et,radius:tt}=this.options,qe=tt/et,rt=(ye-qe)/je,vt=(ye+1+qe)/je,Vt={features:[]};return this._addTileFeatures(Re.range((ee-qe)/je,rt,(ee+1+qe)/je,vt),Re.points,ee,ye,je,Vt),ee===0&&this._addTileFeatures(Re.range(1-qe/je,rt,1,vt),Re.points,je,ye,je,Vt),ee===je-1&&this._addTileFeatures(Re.range(0,rt,qe/je,vt),Re.points,-1,ye,je,Vt),Vt.features.length?Vt:null}getClusterExpansionZoom($){let ee=this._getOriginZoom($)-1;for(;ee<=this.options.maxZoom;){const ye=this.getChildren($);if(ee++,ye.length!==1)break;$=ye[0].properties.cluster_id}return ee}_appendLeaves($,ee,ye,Re,je){const et=this.getChildren(ee);for(const tt of et){const qe=tt.properties;if(qe&&qe.cluster?je+qe.point_count<=Re?je+=qe.point_count:je=this._appendLeaves($,qe.cluster_id,ye,Re,je):jeee&&(Y+=Fe.numPoints||1)}if(Y>_n&&Y>=tt){let re=vt.x*_n,Fe=vt.y*_n,Te=et&&_n>1?this._map(vt,!0):null;const Tt=(rt<<5)+(ee+1)+this.points.length;for(const _t of Ct){const Ot=Vt.points[_t];if(Ot.zoom<=ee)continue;Ot.zoom=ee;const rn=Ot.numPoints||1;re+=Ot.x*rn,Fe+=Ot.y*rn,Ot.parentId=Tt,et&&(Te||(Te=this._map(vt,!0)),et(Te,this._map(Ot)))}vt.parentId=Tt,ye.push(ge(re/Y,Fe/Y,Tt,Y,Te))}else if(ye.push(vt),Y>1)for(const re of Ct){const Fe=Vt.points[re];Fe.zoom<=ee||(Fe.zoom=ee,ye.push(Fe))}}return ye}_getOriginId($){return $-this.points.length>>5}_getOriginZoom($){return($-this.points.length)%32}_map($,ee){if($.numPoints)return ee?wt({},$.properties):$.properties;const ye=this.points[$.index].properties,Re=this.options.map(ye);return ee&&Re===ye?wt({},Re):Re}}function ge(we,$,ee,ye,Re){return{x:Ge(we),y:Ge($),zoom:1/0,id:ee,parentId:-1,numPoints:ye,properties:Re}}function Ce(we,$){const[ee,ye]=we.geometry.coordinates;return{x:Ge(Ne(ee)),y:Ge(Je(ye)),zoom:1/0,index:$,parentId:-1}}function Ae(we){return{type:"Feature",id:we.id,properties:_e(we),geometry:{type:"Point",coordinates:[($=we.x,360*($-.5)),ct(we.y)]}};var $}function _e(we){const $=we.numPoints,ee=$>=1e4?`${Math.round($/1e3)}k`:$>=1e3?Math.round($/100)/10+"k":$;return wt(wt({},we.properties),{cluster:!0,cluster_id:we.id,point_count:$,point_count_abbreviated:ee})}function Ne(we){return we/360+.5}function Je(we){const $=Math.sin(we*Math.PI/180),ee=.5-.25*Math.log((1+$)/(1-$))/Math.PI;return ee<0?0:ee>1?1:ee}function ct(we){const $=(180-360*we)*Math.PI/180;return 360*Math.atan(Math.exp($))/Math.PI-90}function wt(we,$){for(const ee in $)we[ee]=$[ee];return we}function Gt(we){return we.x}function pe(we){return we.y}function Me(we,$,ee,ye){for(var Re,je=ye,et=ee-$>>1,tt=ee-$,qe=we[$],rt=we[$+1],vt=we[ee],Vt=we[ee+1],Ct=$+3;Ctje)Re=Ct,je=_n;else if(_n===je){var Y=Math.abs(Ct-et);Yye&&(Re-$>3&&Me(we,$,Re,ye),we[Re+2]=je,ee-Re>3&&Me(we,Re,ee,ye))}function bt(we,$,ee,ye,Re,je){var et=Re-ee,tt=je-ye;if(et!==0||tt!==0){var qe=((we-ee)*et+($-ye)*tt)/(et*et+tt*tt);qe>1?(ee=Re,ye=je):qe>0&&(ee+=et*qe,ye+=tt*qe)}return(et=we-ee)*et+(tt=$-ye)*tt}function gt(we,$,ee,ye){var Re={id:we===void 0?null:we,type:$,geometry:ee,tags:ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(je){var et=je.geometry,tt=je.type;if(tt==="Point"||tt==="MultiPoint"||tt==="LineString")bn(je,et);else if(tt==="Polygon"||tt==="MultiLineString")for(var qe=0;qe0&&(et+=ye?(Re*rt-qe*je)/2:Math.sqrt(Math.pow(qe-Re,2)+Math.pow(rt-je,2))),Re=qe,je=rt}var vt=$.length-3;$[2]=1,Me($,0,vt,ee),$[vt+2]=1,$.size=Math.abs(et),$.start=0,$.end=$.size}function wn(we,$,ee,ye){for(var Re=0;Re1?1:ee}function sn(we,$,ee,ye,Re,je,et,tt){if(ye/=$,je>=(ee/=$)&&et=ye)return null;for(var qe=[],rt=0;rt=ee&&Y=ye)){var re=[];if(Ct==="Point"||Ct==="MultiPoint")Xt(Vt,re,ee,ye,Re);else if(Ct==="LineString")Xe(Vt,re,ee,ye,Re,!1,tt.lineMetrics);else if(Ct==="MultiLineString")en(Vt,re,ee,ye,Re,!1);else if(Ct==="Polygon")en(Vt,re,ee,ye,Re,!0);else if(Ct==="MultiPolygon")for(var Fe=0;Fe=ee&&et<=ye&&($.push(we[je]),$.push(we[je+1]),$.push(we[je+2]))}}function Xe(we,$,ee,ye,Re,je,et){for(var tt,qe,rt=Ut(we),vt=Re===0?fn:On,Vt=we.start,Ct=0;Ctee&&(qe=vt(rt,_n,Y,Fe,Te,ee),et&&(rt.start=Vt+tt*qe)):Tt>ye?_t=ee&&(qe=vt(rt,_n,Y,Fe,Te,ee),Ot=!0),_t>ye&&Tt<=ye&&(qe=vt(rt,_n,Y,Fe,Te,ye),Ot=!0),!je&&Ot&&(et&&(rt.end=Vt+tt*qe),$.push(rt),rt=Ut(we)),et&&(Vt+=tt)}var rn=we.length-3;_n=we[rn],Y=we[rn+1],re=we[rn+2],(Tt=Re===0?_n:Y)>=ee&&Tt<=ye&&Pn(rt,_n,Y,re),rn=rt.length-3,je&&rn>=3&&(rt[rn]!==rt[0]||rt[rn+1]!==rt[1])&&Pn(rt,rt[0],rt[1],rt[2]),rt.length&&$.push(rt)}function Ut(we){var $=[];return $.size=we.size,$.start=we.start,$.end=we.end,$}function en(we,$,ee,ye,Re,je){for(var et=0;etet.maxX&&(et.maxX=vt),Vt>et.maxY&&(et.maxY=Vt)}return et}function ei(we,$,ee,ye){var Re=$.geometry,je=$.type,et=[];if(je==="Point"||je==="MultiPoint")for(var tt=0;tt0&&$.size<(Re?et:ye))ee.numPoints+=$.length/3;else{for(var tt=[],qe=0;qe<$.length;qe+=3)(ye===0||$[qe+2]>et)&&(ee.numSimplified++,tt.push($[qe]),tt.push($[qe+1])),ee.numPoints++;Re&&function(rt,vt){for(var Vt=0,Ct=0,_n=rt.length,Y=_n-2;Ct<_n;Y=Ct,Ct+=2)Vt+=(rt[Ct]-rt[Y])*(rt[Ct+1]+rt[Y+1]);if(Vt>0===vt)for(Ct=0,_n=rt.length;Ct<_n/2;Ct+=2){var re=rt[Ct],Fe=rt[Ct+1];rt[Ct]=rt[_n-2-Ct],rt[Ct+1]=rt[_n-1-Ct],rt[_n-2-Ct]=re,rt[_n-1-Ct]=Fe}}(tt,je),we.push(tt)}}function _i(we,$){var ee=($=this.options=function(Re,je){for(var et in je)Re[et]=je[et];return Re}(Object.create(this.options),$)).debug;if(ee&&console.time("preprocess data"),$.maxZoom<0||$.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if($.promoteId&&$.generateId)throw new Error("promoteId and generateId cannot be used together.");var ye=function(Re,je){var et=[];if(Re.type==="FeatureCollection")for(var tt=0;tt1&&console.time("creation"),Ct=this.tiles[Vt]=Di(we,$,ee,ye,qe),this.tileCoords.push({z:$,x:ee,y:ye}),rt)){rt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",$,ee,ye,Ct.numFeatures,Ct.numPoints,Ct.numSimplified),console.timeEnd("creation"));var _n="z"+$;this.stats[_n]=(this.stats[_n]||0)+1,this.total++}if(Ct.source=we,Re){if($===qe.maxZoom||$===Re)continue;var Y=1<1&&console.time("clipping");var re,Fe,Te,Tt,_t,Ot,rn=.5*qe.buffer/qe.extent,Sn=.5-rn,Ln=.5+rn,Mt=1+rn;re=Fe=Te=Tt=null,_t=sn(we,vt,ee-rn,ee+Ln,0,Ct.minX,Ct.maxX,qe),Ot=sn(we,vt,ee+Sn,ee+Mt,0,Ct.minX,Ct.maxX,qe),we=null,_t&&(re=sn(_t,vt,ye-rn,ye+Ln,1,Ct.minY,Ct.maxY,qe),Fe=sn(_t,vt,ye+Sn,ye+Mt,1,Ct.minY,Ct.maxY,qe),_t=null),Ot&&(Te=sn(Ot,vt,ye-rn,ye+Ln,1,Ct.minY,Ct.maxY,qe),Tt=sn(Ot,vt,ye+Sn,ye+Mt,1,Ct.minY,Ct.maxY,qe),Ot=null),rt>1&&console.timeEnd("clipping"),tt.push(re||[],$+1,2*ee,2*ye),tt.push(Fe||[],$+1,2*ee,2*ye+1),tt.push(Te||[],$+1,2*ee+1,2*ye),tt.push(Tt||[],$+1,2*ee+1,2*ye+1)}}},_i.prototype.getTile=function(we,$,ee){var ye=this.options,Re=ye.extent,je=ye.debug;if(we<0||we>24)return null;var et=1<1&&console.log("drilling down to z%d-%d-%d",we,$,ee);for(var qe,rt=we,vt=$,Vt=ee;!qe&&rt>0;)rt--,vt=Math.floor(vt/2),Vt=Math.floor(Vt/2),qe=this.tiles[jr(rt,vt,Vt)];return qe&&qe.source?(je>1&&console.log("found parent tile z%d-%d-%d",rt,vt,Vt),je>1&&console.time("drilling down"),this.splitTile(qe.source,rt,vt,Vt,we,$,ee),je>1&&console.timeEnd("drilling down"),this.tiles[tt]?ji(this.tiles[tt],Re):null):null};class Hr extends r.VectorTileWorkerSource{constructor($,ee,ye,Re,je){super($,ee,ye,Re,zi),je&&(this.loadGeoJSON=je)}loadData($,ee){const ye=$&&$.request,Re=ye&&ye.collectResourceTiming;this.loadGeoJSON($,(je,et)=>{if(je||!et)return ee(je);if(typeof et!="object")return ee(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`));{A(et,!0);try{if($.filter){const qe=r.createExpression($.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(qe.result==="error")throw new Error(qe.value.map(vt=>`${vt.key}: ${vt.message}`).join(", "));et={type:"FeatureCollection",features:et.features.filter(vt=>qe.value.evaluate({zoom:0},vt))}}this._geoJSONIndex=$.cluster?new ot(function({superclusterOptions:qe,clusterProperties:rt}){if(!rt||!qe)return qe;const vt={},Vt={},Ct={accumulated:null,zoom:0},_n={properties:null},Y=Object.keys(rt);for(const re of Y){const[Fe,Te]=rt[re],Tt=r.createExpression(Te),_t=r.createExpression(typeof Fe=="string"?[Fe,["accumulated"],["get",re]]:Fe);vt[re]=Tt.value,Vt[re]=_t.value}return qe.map=re=>{_n.properties=re;const Fe={};for(const Te of Y)Fe[Te]=vt[Te].evaluate(Ct,_n);return Fe},qe.reduce=(re,Fe)=>{_n.properties=Fe;for(const Te of Y)Ct.accumulated=re[Te],re[Te]=Vt[Te].evaluate(Ct,_n)},qe}($)).load(et.features):function(qe,rt){return new _i(qe,rt)}(et,$.geojsonVtOptions)}catch(qe){return ee(qe)}this.loaded={};const tt={};if(Re){const qe=r.getPerformanceMeasurement(ye);qe&&(tt.resourceTiming={},tt.resourceTiming[$.source]=JSON.parse(JSON.stringify(qe)))}ee(null,tt)}})}reloadTile($,ee){const ye=this.loaded;return ye&&ye[$.uid]?super.reloadTile($,ee):this.loadTile($,ee)}loadGeoJSON($,ee){if($.request)r.getJSON($.request,ee);else{if(typeof $.data!="string")return ee(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`));try{return ee(null,JSON.parse($.data))}catch(ye){return ee(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom($,ee){try{ee(null,this._geoJSONIndex.getClusterExpansionZoom($.clusterId))}catch(ye){ee(ye)}}getClusterChildren($,ee){try{ee(null,this._geoJSONIndex.getChildren($.clusterId))}catch(ye){ee(ye)}}getClusterLeaves($,ee){try{ee(null,this._geoJSONIndex.getLeaves($.clusterId,$.limit,$.offset))}catch(ye){ee(ye)}}}class Ar{constructor($){this.self=$,this.actor=new r.Actor($,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=r.getProjection({name:"mercator"}),this.workerSourceTypes={vector:r.VectorTileWorkerSource,geojson:Hr},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(ee,ye)=>{if(this.workerSourceTypes[ee])throw new Error(`Worker source with name "${ee}" already registered.`);this.workerSourceTypes[ee]=ye},this.self.registerRTLTextPlugin=ee=>{if(r.plugin.isParsed())throw new Error("RTL text plugin already registered.");r.plugin.applyArabicShaping=ee.applyArabicShaping,r.plugin.processBidirectionalText=ee.processBidirectionalText,r.plugin.processStyledBidirectionalText=ee.processStyledBidirectionalText}}clearCaches($,ee,ye){delete this.layerIndexes[$],delete this.availableImages[$],delete this.workerSources[$],delete this.demWorkerSources[$],ye()}checkIfReady($,ee,ye){ye()}setReferrer($,ee){this.referrer=ee}spriteLoaded($,ee){this.isSpriteLoaded[$]=ee;for(const ye in this.workerSources[$]){const Re=this.workerSources[$][ye];for(const je in Re)Re[je]instanceof r.VectorTileWorkerSource&&(Re[je].isSpriteLoaded=ee,Re[je].fire(new r.Event("isSpriteLoaded")))}}setImages($,ee,ye){this.availableImages[$]=ee;for(const Re in this.workerSources[$]){const je=this.workerSources[$][Re];for(const et in je)je[et].availableImages=ee}ye()}enableTerrain($,ee,ye){this.terrain=ee,ye()}setProjection($,ee){this.projections[$]=r.getProjection(ee)}setLayers($,ee,ye){this.getLayerIndex($).replace(ee),ye()}updateLayers($,ee,ye){this.getLayerIndex($).update(ee.layers,ee.removedIds),ye()}loadTile($,ee,ye){const Re=this.enableTerrain?r.extend({enableTerrain:this.terrain},ee):ee;Re.projection=this.projections[$]||this.defaultProjection,this.getWorkerSource($,ee.type,ee.source).loadTile(Re,ye)}loadDEMTile($,ee,ye){const Re=this.enableTerrain?r.extend({buildQuadTree:this.terrain},ee):ee;this.getDEMWorkerSource($,ee.source).loadTile(Re,ye)}reloadTile($,ee,ye){const Re=this.enableTerrain?r.extend({enableTerrain:this.terrain},ee):ee;Re.projection=this.projections[$]||this.defaultProjection,this.getWorkerSource($,ee.type,ee.source).reloadTile(Re,ye)}abortTile($,ee,ye){this.getWorkerSource($,ee.type,ee.source).abortTile(ee,ye)}removeTile($,ee,ye){this.getWorkerSource($,ee.type,ee.source).removeTile(ee,ye)}removeSource($,ee,ye){if(!this.workerSources[$]||!this.workerSources[$][ee.type]||!this.workerSources[$][ee.type][ee.source])return;const Re=this.workerSources[$][ee.type][ee.source];delete this.workerSources[$][ee.type][ee.source],Re.removeSource!==void 0?Re.removeSource(ee,ye):ye()}loadWorkerSource($,ee,ye){try{this.self.importScripts(ee.url),ye()}catch(Re){ye(Re.toString())}}syncRTLPluginState($,ee,ye){try{r.plugin.setState(ee);const Re=r.plugin.getPluginURL();if(r.plugin.isLoaded()&&!r.plugin.isParsed()&&Re!=null){this.self.importScripts(Re);const je=r.plugin.isParsed();ye(je?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Re}`),je)}}catch(Re){ye(Re.toString())}}getAvailableImages($){let ee=this.availableImages[$];return ee||(ee=[]),ee}getLayerIndex($){let ee=this.layerIndexes[$];return ee||(ee=this.layerIndexes[$]=new w),ee}getWorkerSource($,ee,ye){return this.workerSources[$]||(this.workerSources[$]={}),this.workerSources[$][ee]||(this.workerSources[$][ee]={}),this.workerSources[$][ee][ye]||(this.workerSources[$][ee][ye]=new this.workerSourceTypes[ee]({send:(Re,je,et,tt,qe,rt)=>{this.actor.send(Re,je,et,$,qe,rt)},scheduler:this.actor.scheduler},this.getLayerIndex($),this.getAvailableImages($),this.isSpriteLoaded[$])),this.workerSources[$][ee][ye]}getDEMWorkerSource($,ee){return this.demWorkerSources[$]||(this.demWorkerSources[$]={}),this.demWorkerSources[$][ee]||(this.demWorkerSources[$][ee]=new b),this.demWorkerSources[$][ee]}enforceCacheSizeLimit($,ee){r.enforceCacheSizeLimit(ee)}getWorkerPerformanceMetrics($,ee,ye){ye(void 0,void 0)}}return typeof WorkerGlobalScope!="undefined"&&typeof self!="undefined"&&self instanceof WorkerGlobalScope&&(self.worker=new Ar(self)),Ar}),h(["./shared"],function(r){var v=x;function x(m){return!function(o){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 y,E,C=new Blob([""],{type:"text/javascript"}),S=URL.createObjectURL(C);try{E=new Worker(S),y=!0}catch(k){y=!1}return E&&E.terminate(),URL.revokeObjectURL(S),y}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var y=document.createElement("canvas");y.width=y.height=1;var E=y.getContext("2d");if(!E)return!1;var C=E.getImageData(0,0,1,1);return C&&C.width===y.width}()?(w[d=o&&o.failIfMajorPerformanceCaveat]===void 0&&(w[d]=function(y){var E,C=function(S){var k=document.createElement("canvas"),O=Object.create(x.webGLContextAttributes);return O.failIfMajorPerformanceCaveat=S,k.getContext("webgl",O)||k.getContext("experimental-webgl",O)}(y);if(!C)return!1;try{E=C.createShader(C.VERTEX_SHADER)}catch(S){return!1}return!(!E||C.isContextLost())&&(C.shaderSource(E,"void main() {}"),C.compileShader(E),C.getShaderParameter(E,C.COMPILE_STATUS)===!0)}(d)),w[d]?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 d}(m)}var w={};function b(m,o){if(Array.isArray(m)){if(!Array.isArray(o)||m.length!==o.length)return!1;for(let d=0;d{r.window.removeEventListener("click",J,!0)},0)}function H(m,o){const d=m.getBoundingClientRect();return ie(m,d,o)}function Q(m,o){const d=m.getBoundingClientRect(),y=[];for(let E=0;E=0?0:m.button}function ie(m,o,d){const y=m.offsetWidth===o.width?1:m.offsetWidth/o.width;return new r.pointGeometry((d.clientX-o.left)*y,(d.clientY-o.top)*y)}function le(m,o){var d=o[0],y=o[1],E=o[2],C=o[3],S=d*C-E*y;return S?(m[0]=C*(S=1/S),m[1]=-y*S,m[2]=-E*S,m[3]=d*S,m):null}function fe(m){const{userImage:o}=m;return!!(o&&o.render&&o.render())&&(m.data.replace(new Uint8Array(o.data.buffer)),!0)}class me extends r.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new r.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(o){if(this.loaded!==o&&(this.loaded=o,o)){for(const{ids:d,callback:y}of this.requestors)this._notify(d,y);this.requestors=[]}}hasImage(o){return!!this.getImage(o)}getImage(o){return this.images[o]}addImage(o,d){this._validate(o,d)&&(this.images[o]=d)}_validate(o,d){let y=!0;return this._validateStretch(d.stretchX,d.data&&d.data.width)||(this.fire(new r.ErrorEvent(new Error(`Image "${o}" has invalid "stretchX" value`))),y=!1),this._validateStretch(d.stretchY,d.data&&d.data.height)||(this.fire(new r.ErrorEvent(new Error(`Image "${o}" has invalid "stretchY" value`))),y=!1),this._validateContent(d.content,d)||(this.fire(new r.ErrorEvent(new Error(`Image "${o}" has invalid "content" value`))),y=!1),y}_validateStretch(o,d){if(!o)return!0;let y=0;for(const E of o){if(E[0]{this.ready=!0})}broadcast(o,d,y){r.asyncAll(this.actors,(E,C)=>{E.send(o,d,C)},y=y||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(o=>{o.remove()}),this.actors=[],this.workerPool.release(this.id)}}function We(m,o,d){return o*(r.EXTENT/(m.tileSize*Math.pow(2,d-m.tileID.overscaledZ)))}be.Actor=r.Actor;class Ge{constructor(o,d,y,E){this.screenBounds=o,this.cameraPoint=d,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=y,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(C=>E.pointCoordinate3D(C)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(o,d){let y,E;if(o instanceof r.pointGeometry||typeof o[0]=="number"){const C=r.pointGeometry.convert(o);y=[r.pointGeometry.convert(o)],E=d.isPointAboveHorizon(C)}else{const C=r.pointGeometry.convert(o[0]),S=r.pointGeometry.convert(o[1]);y=[C,S],E=r.polygonizeBounds(C,S).every(k=>d.isPointAboveHorizon(k))}return new Ge(y,d.getCameraPoint(),E,d)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(o){return r.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],o)}bufferedCameraGeometry(o){const d=this.screenBounds[0],y=this.screenBounds.length===1?this.screenBounds[0].add(new r.pointGeometry(1,1)):this.screenBounds[1],E=r.polygonizeBounds(d,y,0,!1);return this.cameraPoint.y>y.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x=y.x?E[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(E[3]=this.cameraPoint)),r.bufferConvexPolygon(E,o)}containsTile(o,d,y){const E=o.queryPadding+1,C=o.tileID.wrap,S=y?this._bufferedCameraMercator(E,d).map(ce=>r.getTilePoint(o.tileTransform,ce,C)):this._bufferedScreenMercator(E,d).map(ce=>r.getTilePoint(o.tileTransform,ce,C)),k=this.screenGeometryMercator.map(ce=>r.getTileVec3(o.tileTransform,ce,C)),O=k.map(ce=>new r.pointGeometry(ce[0],ce[1])),U=d.getFreeCameraOptions().position||new r.MercatorCoordinate(0,0,0),G=r.getTileVec3(o.tileTransform,U,C),Z=k.map(ce=>{const te=r.sub(ce,ce,G);return r.normalize(te,te),new r.Ray(G,te)}),se=We(o,1,d.zoom);if(r.polygonIntersectsBox(S,0,0,r.EXTENT,r.EXTENT))return{queryGeometry:this,tilespaceGeometry:O,tilespaceRays:Z,bufferedTilespaceGeometry:S,bufferedTilespaceBounds:(de=r.getBounds(S),de.min.x=r.clamp(de.min.x,0,r.EXTENT),de.min.y=r.clamp(de.min.y,0,r.EXTENT),de.max.x=r.clamp(de.max.x,0,r.EXTENT),de.max.y=r.clamp(de.max.y,0,r.EXTENT),de),tile:o,tileID:o.tileID,pixelToTileUnitsFactor:se};var de}_bufferedScreenMercator(o,d){const y=ke(o);if(this._screenRaycastCache[y])return this._screenRaycastCache[y];{const E=this.bufferedScreenGeometry(o).map(C=>d.pointCoordinate3D(C));return this._screenRaycastCache[y]=E,E}}_bufferedCameraMercator(o,d){const y=ke(o);if(this._cameraRaycastCache[y])return this._cameraRaycastCache[y];{const E=this.bufferedCameraGeometry(o).map(C=>d.pointCoordinate3D(C));return this._cameraRaycastCache[y]=E,E}}}function ke(m){return 100*m|0}function ot(m,o,d){const y=function(E,C){if(E)return d(E);if(C){const S=r.pick(r.extend(C,m),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);C.vector_layers&&(S.vectorLayers=C.vector_layers,S.vectorLayerIds=S.vectorLayers.map(k=>k.id)),S.tiles=o.canonicalizeTileset(S,m.url),d(null,S)}};return m.url?r.getJSON(o.transformRequest(o.normalizeSourceURL(m.url),r.ResourceType.Source),y):r.exported.frame(()=>y(null,m))}class ge{constructor(o,d,y){this.bounds=r.LngLatBounds.convert(this.validateBounds(o)),this.minzoom=d||0,this.maxzoom=y||24}validateBounds(o){return Array.isArray(o)&&o.length===4?[Math.max(-180,o[0]),Math.max(-90,o[1]),Math.min(180,o[2]),Math.min(90,o[3])]:[-180,-90,180,90]}contains(o){const d=Math.pow(2,o.z),y=Math.floor(r.mercatorXfromLng(this.bounds.getWest())*d),E=Math.floor(r.mercatorYfromLat(this.bounds.getNorth())*d),C=Math.ceil(r.mercatorXfromLng(this.bounds.getEast())*d),S=Math.ceil(r.mercatorYfromLat(this.bounds.getSouth())*d);return o.x>=y&&o.x=E&&o.y{this._tileJSONRequest=null,this._loaded=!0,o?this.fire(new r.ErrorEvent(o)):d&&(r.extend(this,d),d.bounds&&(this.tileBounds=new ge(d.bounds,this.minzoom,this.maxzoom)),r.postTurnstileEvent(d.tiles),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(o){this.map=o,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return r.extend({},this._options)}hasTile(o){return!this.tileBounds||this.tileBounds.contains(o.canonical)}loadTile(o,d){const y=r.exported.devicePixelRatio>=2,E=this.map._requestManager.normalizeTileURL(o.tileID.canonical.url(this.tiles,this.scheme),y,this.tileSize);o.request=r.getImage(this.map._requestManager.transformRequest(E,r.ResourceType.Tile),(C,S,k,O)=>(delete o.request,o.aborted?(o.state="unloaded",d(null)):C?(o.state="errored",d(C)):S?(this.map._refreshExpiredTiles&&o.setExpiryData({cacheControl:k,expires:O}),o.setTexture(S,this.map.painter),o.state="loaded",r.cacheEntryPossiblyAdded(this.dispatcher),void d(null)):d(null)))}static loadTileData(o,d,y){o.setTexture(d,y)}static unloadTileData(o,d){o.texture&&d.saveTileTexture(o.texture)}abortTile(o,d){o.request&&(o.request.cancel(),delete o.request),d()}unloadTile(o,d){o.texture&&this.map.painter.saveTileTexture(o.texture),d()}hasTransition(){return!1}}let ye;function Re(m,o,d,y,E,C,S,k){const O=[m,d,E,o,y,C,1,1,1],U=[S,k,1],G=r.adjoint([],O),[Z,se,de]=r.transformMat3(U,U,r.transpose(G,G));return r.multiply(O,[Z,0,0,0,se,0,0,0,de],O)}class je extends r.Evented{constructor(o,d,y,E){super(),this.id=o,this.dispatcher=y,this.coordinates=d.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(E),this.options=d}load(o){this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this.url=this.options.url,r.getImage(this.map._requestManager.transformRequest(this.url,r.ResourceType.Image),(d,y)=>{if(this._loaded=!0,d)this.fire(new r.ErrorEvent(d));else if(y){const{HTMLImageElement:E}=r.window;this.image=y instanceof E?r.exported.getImageData(y):y,this.width=this.image.width,this.height=this.image.height,o&&(this.coordinates=o),this._finishLoading()}})}loaded(){return this._loaded}updateImage(o){return this.image&&o.url?(this.options.url=o.url,this.load(o.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(o){this.map=o,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(o){this.coordinates=o,this._boundsArray=void 0;const d=o.map(r.MercatorCoordinate.fromLngLat);return this.tileID=function(y){let E=1/0,C=1/0,S=-1/0,k=-1/0;for(const Z of y)E=Math.min(E,Z.x),C=Math.min(C,Z.y),S=Math.max(S,Z.x),k=Math.max(k,Z.y);const O=Math.max(S-E,k-C),U=Math.max(0,Math.floor(-Math.log(O)/Math.LN2)),G=Math.pow(2,U);return new r.CanonicalTileID(U,Math.floor((E+S)/2*G),Math.floor((C+k)/2*G))}(d),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(o){for(const O in this.tiles){const U=this.tiles[O];U.state!=="loaded"&&(U.state="loaded",U.texture=this.texture)}if(this._boundsArray)return;const d=r.tileTransform(this.tileID,this.map.transform.projection),[y,E,C,S]=this.coordinates.map(O=>{const U=d.projection.project(O[0],O[1]);return r.getTilePoint(d,U)._round()});this.perspectiveTransform=function(O,U,G,Z,se,de,ce,te,Le,ve){const De=Re(0,0,O,0,0,U,O,U),Se=Re(G,Z,se,de,ce,te,Le,ve);return r.multiply(Se,r.adjoint(De,De),Se),[Se[6]/Se[8]*O/r.EXTENT,Se[7]/Se[8]*U/r.EXTENT]}(this.width,this.height,y.x,y.y,E.x,E.y,S.x,S.y,C.x,C.y);const k=this._boundsArray=new r.StructArrayLayout4i8;k.emplaceBack(y.x,y.y,0,0),k.emplaceBack(E.x,E.y,r.EXTENT,0),k.emplaceBack(S.x,S.y,0,r.EXTENT),k.emplaceBack(C.x,C.y,r.EXTENT,r.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=o.createVertexBuffer(k,r.boundsAttributes.members),this.boundsSegments=r.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const o=this.map.painter.context,d=o.gl;this.texture?this.texture.update(this.image):(this.texture=new r.Texture(o,this.image,d.RGBA),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE)),this._prepareData(o)}loadTile(o,d){this.tileID&&this.tileID.equals(o.tileID.canonical)?(this.tiles[String(o.tileID.wrap)]=o,o.buckets={},d(null)):(o.state="errored",d(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const et={vector:class extends r.Evented{constructor(m,o,d,y){if(super(),this.id=m,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,r.extend(this,r.pick(o,["url","scheme","tileSize","promoteId"])),this._options=r.extend({type:"vector"},o),this._collectResourceTiming=o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(y),this._tileWorkers={},this._deduped=new r.DedupedRequest}load(){this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ot(this._options,this.map._requestManager,(m,o)=>{this._tileJSONRequest=null,this._loaded=!0,m?this.fire(new r.ErrorEvent(m)):o&&(r.extend(this,o),o.bounds&&(this.tileBounds=new ge(o.bounds,this.minzoom,this.maxzoom)),r.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(m){return!this.tileBounds||this.tileBounds.contains(m.canonical)}onAdd(m){this.map=m,this.load()}setSourceProperty(m){this._tileJSONRequest&&this._tileJSONRequest.cancel(),m();const o=this.map.style._getSourceCaches(this.id);for(const d of o)d.clearTiles();this.load()}setTiles(m){return this.setSourceProperty(()=>{this._options.tiles=m}),this}setUrl(m){return this.setSourceProperty(()=>{this.url=m,this._options.url=m}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return r.extend({},this._options)}loadTile(m,o){const d=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme)),y={request:this.map._requestManager.transformRequest(d,r.ResourceType.Tile),data:void 0,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,tileSize:this.tileSize*m.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:r.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:m.isSymbolTile};if(y.request.collectResourceTiming=this._collectResourceTiming,m.actor&&m.state!=="expired")m.state==="loading"?m.reloadCallback=o:m.request=m.actor.send("reloadTile",y,E.bind(this));else if(m.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)m.request=m.actor.send("loadTile",y,E.bind(this),void 0,!0);else{const C=r.loadVectorTile.call({deduped:this._deduped},y,(S,k)=>{S||!k?E.call(this,S):(y.data={cacheControl:k.cacheControl,expires:k.expires,rawData:k.rawData.slice(0)},m.actor&&m.actor.send("loadTile",y,E.bind(this),void 0,!0))},!0);m.request={cancel:C}}function E(C,S){return delete m.request,m.aborted?o(null):C&&C.status!==404?o(C):(S&&S.resourceTiming&&(m.resourceTiming=S.resourceTiming),this.map._refreshExpiredTiles&&S&&m.setExpiryData(S),m.loadVectorData(S,this.map.painter),r.cacheEntryPossiblyAdded(this.dispatcher),o(null),void(m.reloadCallback&&(this.loadTile(m,m.reloadCallback),m.reloadCallback=null)))}}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.actor&&m.actor.send("abortTile",{uid:m.uid,type:this.type,source:this.id})}unloadTile(m){m.unloadVectorData(),m.actor&&m.actor.send("removeTile",{uid:m.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ee,"raster-dem":class extends ee{constructor(m,o,d,y){super(m,o,d,y),this.type="raster-dem",this.maxzoom=22,this._options=r.extend({type:"raster-dem"},o),this.encoding=o.encoding||"mapbox"}loadTile(m,o){const d=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function y(E,C){E&&(m.state="errored",o(E)),C&&(m.dem=C,m.dem.onDeserialize(),m.needsHillshadePrepare=!0,m.needsDEMTextureUpload=!0,m.state="loaded",o(null))}m.request=r.getImage(this.map._requestManager.transformRequest(d,r.ResourceType.Tile),function(E,C,S,k){if(delete m.request,m.aborted)m.state="unloaded",o(null);else if(E)m.state="errored",o(E);else if(C){this.map._refreshExpiredTiles&&m.setExpiryData({cacheControl:S,expires:k});const O=r.window.ImageBitmap&&C instanceof r.window.ImageBitmap&&(ye==null&&(ye=r.window.OffscreenCanvas&&new r.window.OffscreenCanvas(1,1).getContext("2d")&&typeof r.window.createImageBitmap=="function"),ye),U=1-(C.width-r.prevPowerOfTwo(C.width))/2;U<1||m.neighboringTiles||(m.neighboringTiles=this._getNeighboringTiles(m.tileID));const G=O?C:r.exported.getImageData(C,U),Z={uid:m.uid,coord:m.tileID,source:this.id,rawImageData:G,encoding:this.encoding,padding:U};m.actor&&m.state!=="expired"||(m.actor=this.dispatcher.getActor(),m.actor.send("loadDEMTile",Z,y.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(m){const o=m.canonical,d=Math.pow(2,o.z),y=(o.x-1+d)%d,E=o.x===0?m.wrap-1:m.wrap,C=(o.x+1+d)%d,S=o.x+1===d?m.wrap+1:m.wrap,k={};return k[new r.OverscaledTileID(m.overscaledZ,E,o.z,y,o.y).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,S,o.z,C,o.y).key]={backfilled:!1},o.y>0&&(k[new r.OverscaledTileID(m.overscaledZ,E,o.z,y,o.y-1).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,m.wrap,o.z,o.x,o.y-1).key]={backfilled:!1},k[new r.OverscaledTileID(m.overscaledZ,S,o.z,C,o.y-1).key]={backfilled:!1}),o.y+1{if(this._loaded=!0,this._pendingLoad=null,d)this.fire(new r.ErrorEvent(d));else{const E={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&y&&y.resourceTiming&&y.resourceTiming[this.id]&&(E.resourceTiming=y.resourceTiming[this.id]),this.fire(new r.Event("data",E)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(m,o){const d=m.actor?"reloadTile":"loadTile";m.actor=this.actor,m.request=this.actor.send(d,{type:this.type,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:r.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(y,E)=>(delete m.request,m.unloadVectorData(),m.aborted?o(null):y?o(y):(m.loadVectorData(E,this.map.painter,d==="reloadTile"),o(null))),void 0,d==="loadTile")}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.aborted=!0}unloadTile(m){m.unloadVectorData(),this.actor.send("removeTile",{uid:m.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return r.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends je{constructor(m,o,d,y){super(m,o,d,y),this.roundZoom=!0,this.type="video",this.options=o}load(){this._loaded=!1;const m=this.options;this.urls=[];for(const o of m.urls)this.urls.push(this.map._requestManager.transformRequest(o,r.ResourceType.Source).url);r.getVideo(this.urls,(o,d)=>{this._loaded=!0,o?this.fire(new r.ErrorEvent(o)):d&&(this.video=d,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(m){if(this.video){const o=this.video.seekable;mo.end(0)?this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${o.start(0)} and ${o.end(0)}-second mark.`))):this.video.currentTime=m}}getVideo(){return this.video}onAdd(m){this.map||(this.map=m,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 m=this.map.painter.context,o=m.gl;this.texture?this.video.paused||(this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,this.video)):(this.texture=new r.Texture(m,this.video,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(m)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:je,canvas:class extends je{constructor(m,o,d,y){super(m,o,d,y),o.coordinates?Array.isArray(o.coordinates)&&o.coordinates.length===4&&!o.coordinates.some(E=>!Array.isArray(E)||E.length!==2||E.some(C=>typeof C!="number"))||this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'missing required property "coordinates"'))),o.animate&&typeof o.animate!="boolean"&&this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'optional "animate" property must be a boolean value'))),o.canvas?typeof o.canvas=="string"||o.canvas instanceof r.window.HTMLCanvasElement||this.fire(new r.ErrorEvent(new r.ValidationError(`sources.${m}`,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 r.ErrorEvent(new r.ValidationError(`sources.${m}`,null,'missing required property "canvas"'))),this.options=o,this.animate=o.animate===void 0||o.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof r.window.HTMLCanvasElement?this.options.canvas:r.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new r.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(m){this.map=m,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let m=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,m=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,m=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const o=this.map.painter.context;this.texture?(m||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new r.Texture(o,this.canvas,o.gl.RGBA,{premultiply:!0}),this._prepareData(o)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const m of[this.canvas.width,this.canvas.height])if(isNaN(m)||m<=0)return!0;return!1}},custom:class extends r.Evented{constructor(m,o,d,y){super(),this.id=m,this.type="custom",this._dataType="raster",this._dispatcher=d,this._implementation=o,this.setEventedParent(y),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new r.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new r.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ge(this._implementation.bounds,this.minzoom,this.maxzoom)),o.update=this._update.bind(this),o.coveringTiles=this._coveringTiles.bind(this),r.extend(this,r.pick(o,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return r.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new r.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(m){this._map=m,this._loaded=!1,this.fire(new r.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(m),this.load()}onRemove(m){this._implementation.onRemove&&this._implementation.onRemove(m)}hasTile(m){if(this._implementation.hasTile){const{x:o,y:d,z:y}=m.canonical;return this._implementation.hasTile({x:o,y:d,z:y})}return!this.tileBounds||this.tileBounds.contains(m.canonical)}loadTile(m,o){const{x:d,y,z:E}=m.tileID.canonical,C=new r.window.AbortController,S=this._implementation.loadTile({x:d,y,z:E},{signal:C.signal});if(!S)return this.loadTileData(m,{width:this.tileSize,height:this.tileSize,data:null}),m.state="loaded",o(null);S.cancel=()=>C.abort(),m.request=S.then(function(k){return delete m.request,m.aborted?(m.state="unloaded",o(null)):k?function(O){return O instanceof r.window.ImageData||O instanceof r.window.ImageBitmap||O instanceof r.window.HTMLCanvasElement}(k)?(this.loadTileData(m,k),m.state="loaded",void o(null)):(m.state="errored",o(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(m,{width:this.tileSize,height:this.tileSize,data:null}),m.state="loaded",o(null))}.bind(this)).catch(k=>{k.code!==20&&(m.state="errored",o(k))})}loadTileData(m,o){ee.loadTileData(m,o,this._map.painter)}unloadTileData(m){ee.unloadTileData(m,this._map.painter)}prepareTile(m){if(!this._implementation.prepareTile)return null;const{x:o,y:d,z:y}=m.tileID.canonical,E=this._implementation.prepareTile({x:o,y:d,z:y});return E?(this.loadTileData(m,E),m.state="loaded",E):null}unloadTile(m,o){if(this.unloadTileData(m),this._implementation.unloadTile){const{x:d,y,z:E}=m.tileID.canonical;this._implementation.unloadTile({x:d,y,z:E})}o()}abortTile(m,o){m.request&&m.request.cancel&&(m.request.cancel(),delete m.request),o()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(m=>({x:m.canonical.x,y:m.canonical.y,z:m.canonical.z}))}_update(){this.fire(new r.Event("data",{dataType:"source",sourceDataType:"content"}))}}},tt=function(m,o,d,y){const E=new et[o.type](m,o,d,y);if(E.id!==m)throw new Error(`Expected Source id to be ${m} instead of ${E.id}`);return r.bindAll(["load","abort","unload","serialize","prepare"],E),E};function qe(m,o){const d=r.identity([]);return r.scale(d,d,[.5*m.width,.5*-m.height,1]),r.translate(d,d,[1,-1,0]),r.multiply$1(d,d,m.calculateProjMatrix(o.toUnwrapped())),Float32Array.from(d)}function rt(m,o,d,y,E,C,S,k=!1){const O=m.tilesIn(y,S,k);O.sort(Vt);const U=[];for(const Z of O)U.push({wrappedTileID:Z.tile.tileID.wrapped().key,queryResults:Z.tile.queryRenderedFeatures(o,d,m._state,Z,E,C,qe(m.transform,Z.tile.tileID),k)});const G=function(Z){const se={},de={};for(const ce of Z){const te=ce.queryResults,Le=ce.wrappedTileID,ve=de[Le]=de[Le]||{};for(const De in te){const Se=te[De],ze=ve[De]=ve[De]||{},Ee=se[De]=se[De]||[];for(const Ue of Se)ze[Ue.featureIndex]||(ze[Ue.featureIndex]=!0,Ee.push(Ue))}}return se}(U);for(const Z in G)G[Z].forEach(se=>{const de=se.feature,ce=de.layer;ce&&ce.type!=="background"&&ce.type!=="sky"&&(de.source=ce.source,ce["source-layer"]&&(de.sourceLayer=ce["source-layer"]),de.state=de.id!==void 0?m.getFeatureState(ce["source-layer"],de.id):{})});return G}function vt(m,o){const d=m.getRenderableIds().map(C=>m.getTileByID(C)),y=[],E={};for(let C=0;C{d.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[_n]}numActive(){return Object.keys(this.active).length}}let re;function Fe(){return re||(re=new Y),re}function Te(m,o){const d={};for(const y in m)y!=="ref"&&(d[y]=m[y]);return r.refProperties.forEach(y=>{y in o&&(d[y]=o[y])}),d}function Tt(m){m=m.slice();const o=Object.create(null);for(let d=0;d0?(E-S)/k:0;return this.points[C].mult(1-O).add(this.points[d].mult(O))}}class Tn{constructor(o,d,y){const E=this.boxCells=[],C=this.circleCells=[];this.xCellCount=Math.ceil(o/y),this.yCellCount=Math.ceil(d/y);for(let S=0;Sthis.width||E<0||d>this.height)return!C&&[];const k=[];if(o<=0&&d<=0&&this.width<=y&&this.height<=E){if(C)return!0;for(let O=0;O0:k}_queryCircle(o,d,y,E,C){const S=o-y,k=o+y,O=d-y,U=d+y;if(k<0||S>this.width||U<0||O>this.height)return!E&&[];const G=[];return this._forEachCell(S,O,k,U,this._queryCellCircle,G,{hitTest:E,circle:{x:o,y:d,radius:y},seenUids:{box:{},circle:{}}},C),E?G.length>0:G}query(o,d,y,E,C){return this._query(o,d,y,E,!1,C)}hitTest(o,d,y,E,C){return this._query(o,d,y,E,!0,C)}hitTestCircle(o,d,y,E){return this._queryCircle(o,d,y,!0,E)}_queryCell(o,d,y,E,C,S,k,O){const U=k.seenUids,G=this.boxCells[C];if(G!==null){const se=this.bboxes;for(const de of G)if(!U.box[de]){U.box[de]=!0;const ce=4*de;if(o<=se[ce+2]&&d<=se[ce+3]&&y>=se[ce+0]&&E>=se[ce+1]&&(!O||O(this.boxKeys[de]))){if(k.hitTest)return S.push(!0),!0;S.push({key:this.boxKeys[de],x1:se[ce],y1:se[ce+1],x2:se[ce+2],y2:se[ce+3]})}}}const Z=this.circleCells[C];if(Z!==null){const se=this.circles;for(const de of Z)if(!U.circle[de]){U.circle[de]=!0;const ce=3*de;if(this._circleAndRectCollide(se[ce],se[ce+1],se[ce+2],o,d,y,E)&&(!O||O(this.circleKeys[de]))){if(k.hitTest)return S.push(!0),!0;{const te=se[ce],Le=se[ce+1],ve=se[ce+2];S.push({key:this.circleKeys[de],x1:te-ve,y1:Le-ve,x2:te+ve,y2:Le+ve})}}}}}_queryCellCircle(o,d,y,E,C,S,k,O){const U=k.circle,G=k.seenUids,Z=this.boxCells[C];if(Z!==null){const de=this.bboxes;for(const ce of Z)if(!G.box[ce]){G.box[ce]=!0;const te=4*ce;if(this._circleAndRectCollide(U.x,U.y,U.radius,de[te+0],de[te+1],de[te+2],de[te+3])&&(!O||O(this.boxKeys[ce])))return S.push(!0),!0}}const se=this.circleCells[C];if(se!==null){const de=this.circles;for(const ce of se)if(!G.circle[ce]){G.circle[ce]=!0;const te=3*ce;if(this._circlesCollide(de[te],de[te+1],de[te+2],U.x,U.y,U.radius)&&(!O||O(this.circleKeys[ce])))return S.push(!0),!0}}}_forEachCell(o,d,y,E,C,S,k,O){const U=this._convertToXCellCoord(o),G=this._convertToYCellCoord(d),Z=this._convertToXCellCoord(y),se=this._convertToYCellCoord(E);for(let de=U;de<=Z;de++)for(let ce=G;ce<=se;ce++)if(C.call(this,o,d,y,E,this.xCellCount*ce+de,S,k,O))return}_convertToXCellCoord(o){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(o*this.xScale)))}_convertToYCellCoord(o){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(o*this.yScale)))}_circlesCollide(o,d,y,E,C,S){const k=E-o,O=C-d,U=y+S;return U*U>k*k+O*O}_circleAndRectCollide(o,d,y,E,C,S,k){const O=(S-E)/2,U=Math.abs(o-(E+O));if(U>O+y)return!1;const G=(k-C)/2,Z=Math.abs(d-(C+G));if(Z>G+y)return!1;if(U<=O||Z<=G)return!0;const se=U-O,de=Z-G;return se*se+de*de<=y*y}}const Cn=Math.tan(85*Math.PI/180);function di(m,o,d,y,E,C){const S=r.create();if(d){if(E.projection.name==="globe")r.multiply$1(S,S,r.calculateGlobeLabelMatrix(E,o));else{const k=le([],C);S[0]=k[0],S[1]=k[1],S[4]=k[2],S[5]=k[3]}y||r.rotateZ(S,S,E.angle)}else r.multiply$1(S,E.labelPlaneMatrix,m);return S}function Dr(m,o,d,y,E,C){if(d){if(E.projection.name==="globe"){const S=di(m,o,d,y,E,C);return r.invert(S,S),r.multiply$1(S,m,S),S}{const S=r.clone(m),k=r.identity([]);return k[0]=C[0],k[1]=C[1],k[4]=C[2],k[5]=C[3],r.multiply$1(S,S,k),y||r.rotateZ(S,S,-E.angle),S}}return E.glCoordMatrix}function oi(m,o,d=0){const y=[m.x,m.y,d,1];d?r.transformMat4$1(y,y,o):Pr(y,y,o);const E=y[3];return{point:new r.pointGeometry(y[0]/E,y[1]/E),signedDistanceFromCamera:E}}function li(m,o){const d=[m[0],m[1],m[2],1];r.transformMat4$1(d,d,o);const y=d[3];return{point:new r.pointGeometry(d[0]/y,d[1]/y),signedDistanceFromCamera:y}}function ai(m,o){return Math.min(.5+m/o*.5,1.5)}function xs(m,o){const d=m[0]/m[3],y=m[1]/m[3];return d>=-o[0]&&d<=o[0]&&y>=-o[1]&&y<=o[1]}function ko(m,o,d,y,E,C,S,k,O,U){const G=d.transform,Z=y?m.textSizeData:m.iconSizeData,se=r.evaluateSizeForZoom(Z,d.transform.zoom),de=[256/d.width*2+1,256/d.height*2+1],ce=y?m.text.dynamicLayoutVertexArray:m.icon.dynamicLayoutVertexArray;ce.clear();const te=m.lineVertexArray,Le=y?m.text.placedSymbolArray:m.icon.placedSymbolArray,ve=d.transform.width/d.transform.height;let De=!1;for(let Se=0;SeMath.abs(d.x-o.x)*y?{useVertical:!0}:m.writingMode===r.WritingMode.vertical?o.yCn}(o,d,y)?m.flipState===1?{needsFlipping:!0}:null:o.x>d.x?{needsFlipping:!0}:null}function hu(m,o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le){const ve=o/24,De=m.lineOffsetX*ve,Se=m.lineOffsetY*ve;let ze;if(m.numGlyphs>1){const Ee=m.glyphStartIndex+m.numGlyphs,Ue=m.lineStartIndex,nt=m.lineStartIndex+m.lineLength,lt=uu(ve,k,De,Se,d,G,Z,m,O,C,se,ce,!1,te,Le);if(!lt)return{notEnoughRoom:!0};const pt=oi(lt.first.point,S).point,ht=oi(lt.last.point,S).point;if(y&&!d){const kt=bs(m,pt,ht,de);if(m.flipState=kt&&kt.needsFlipping?1:2,kt)return kt}ze=[lt.first];for(let kt=m.glyphStartIndex+1;kt0?pt.point:Xn(Z,lt,Ue,1,E,void 0,te,Le.canonical),de);if(m.flipState=ht&&ht.needsFlipping?1:2,ht)return ht}const Ee=ws(ve*k.getoffsetX(m.glyphStartIndex),De,Se,d,G,Z,m.segment,m.lineStartIndex,m.lineStartIndex+m.lineLength,O,C,se,ce,!1,!1,te,Le);if(!Ee)return{notEnoughRoom:!0};ze=[Ee]}for(const Ee of ze)r.addDynamicAttributes(U,Ee.point,Ee.angle);return{}}function Cd(m,o,d,y,E){const C=y.projectTilePoint(m.x,m.y,o);if(!E)return oi(C,d,C.z);const S=E(m);return oi(new r.pointGeometry(C.x+S[0],C.y+S[1]),d,C.z+S[2])}function Xn(m,o,d,y,E,C,S,k){const O=Cd(m.add(m.sub(o)._unit()),k,E,S,C).point,U=d.sub(O);return d.add(U._mult(y/U.mag()))}function ws(m,o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le){const ve=y?m-o:m+o;let De=ve>0?1:-1,Se=0;y&&(De*=-1,Se=Math.PI),De<0&&(Se+=Math.PI);let ze=De>0?k+S:k+S+1,Ee=E,Ue=E,nt=0,lt=0;const pt=Math.abs(ve),ht=[],kt=[];let it=C;const zt=()=>{const Zt=ze-De;return nt===0?C:new r.pointGeometry(U.getx(Zt),U.gety(Zt))},St=()=>Xn(zt(),it,Ue,pt-nt+1,G,se,te,Le.canonical);for(;nt+lt<=pt;){if(ze+=De,ze=O)return null;if(Ue=Ee,ht.push(Ee),de&&kt.push(it||zt()),Ee=Z[ze],Ee===void 0){it=new r.pointGeometry(U.getx(ze),U.gety(ze));const Zt=Cd(it,Le.canonical,G,te,se);Ee=Zt.signedDistanceFromCamera>0?Z[ze]=Zt.point:St()}else it=null;nt+=lt,lt=Ue.dist(Ee)}ce&&se&&(it=it||new r.pointGeometry(U.getx(ze),U.gety(ze)),Z[ze]=Ee=Z[ze]===void 0?Ee:St(),lt=Ue.dist(Ee));const Jt=(pt-nt)/lt,ft=Ee.sub(Ue),qt=ft.mult(Jt)._add(Ue);d&&qt._add(ft._unit()._perp()._mult(d*De));const gn=Se+Math.atan2(Ee.y-Ue.y,Ee.x-Ue.x);return ht.push(qt),de&&(it=it||new r.pointGeometry(U.getx(ze),U.gety(ze)),kt.push(function(Zt,Yt,xn){const zn=1-xn;return new r.pointGeometry(Zt.x*zn+Yt.x*xn,Zt.y*zn+Yt.y*xn)}(kt.length>0?kt[kt.length-1]:it,it,Jt))),{point:qt,angle:gn,path:ht,tilePath:kt}}const Ad=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Fi(m,o){for(let d=0;d0),ce=C*de.perspectiveRatio,te=(d.x1*o+y.x-d.padding)*ce+de.point.x,Le=(d.y1*o+y.y-d.padding)*ce+de.point.y,ve=(d.x2*o+y.x+d.padding)*ce+de.point.x,De=(d.y2*o+y.y+d.padding)*ce+de.point.y,Se=de.perspectiveRatio<=.55||de.occluded;return!this.isInsideGrid(te,Le,ve,De)||!E&&this.grid.hitTest(te,Le,ve,De,k)||Se?{box:[],offscreen:!1,occluded:de.occluded}:{box:[te,Le,ve,De],offscreen:this.isOffscreen(te,Le,ve,De),occluded:!1}}placeCollisionCircles(o,d,y,E,C,S,k,O,U,G,Z,se,de,ce){const te=[],Le=this.transform.elevation,ve=Le?Le.getAtTileOffsetFunc(ce,this.transform.center.lat,this.transform.worldSize,this.transform.projection):St=>[0,0,0],De=new r.pointGeometry(d.tileAnchorX,d.tileAnchorY),Se=this.transform.projection.projectTilePoint(d.tileAnchorX,d.tileAnchorY,ce.canonical),ze=ve(De),Ee=[Se.x+ze[0],Se.y+ze[1],Se.z+ze[2]],Ue=this.projectAndGetPerspectiveRatio(S,[Ee[0],Ee[1],Ee[2]],ce,this.transform.projection.name==="globe"||!!Le||this.transform.pitch>0),{perspectiveRatio:nt}=Ue,lt=(G?C/nt:C*nt)/r.ONE_EM,pt=oi(new r.pointGeometry(Ee[0],Ee[1]),k,Ee[2]).point,ht=Ue.signedDistanceFromCamera>0?uu(lt,E,d.lineOffsetX*lt,d.lineOffsetY*lt,!1,pt,De,d,y,k,{},Le&&!G?ve:null,G&&!!Le,this.transform.projection,ce):null;let kt=!1,it=!1,zt=!0;if(ht&&!Ue.occluded){const St=.5*se*nt+de,Jt=new r.pointGeometry(-100,-100),ft=new r.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),qt=new mn,gn=ht.first,Zt=ht.last;let Yt=[];for(let dn=gn.path.length-1;dn>=1;dn--)Yt.push(gn.path[dn]);for(let dn=1;dn{const vi=ve($noi(Mn,O));Yt=dn.some(Mn=>Mn.signedDistanceFromCamera<=0)?[]:dn.map(Mn=>Mn.point)}let zn=[];if(Yt.length>0){const dn=Yt[0].clone(),Mn=Yt[0].clone();for(let $n=1;$n=Jt.x&&Mn.x<=ft.x&&dn.y>=Jt.y&&Mn.y<=ft.y?[Yt]:Mn.xft.x||Mn.yft.y?[]:r.clipLine([Yt],Jt.x,Jt.y,ft.x,ft.y)}for(const dn of zn){qt.reset(dn,.25*St);let Mn=0;Mn=qt.length<=.5*St?1:Math.ceil(qt.paddedLength/xn)+1;for(let $n=0;$n0?(r.transformMat4$1(C,C,o),this.fogState&&y&&(S=function(k,O,U,G,Z,se){const de=se.calculateFogTileMatrix(Z),ce=[O,U,G];return r.transformMat4(ce,ce,de),yt(k,ce,se.pitch,se._fov)}(this.fogState,d[0],d[1],d[2],y.toUnwrapped(),this.transform)>.9)):Pr(C,C,o),{point:new r.pointGeometry((C[0]/C[3]+1)/2*this.transform.width+ho,(-C[1]/C[3]+1)/2*this.transform.height+ho),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/C[3]*.5,1.5),signedDistanceFromCamera:C[3],occluded:E&&C[2]>C[3]||S}}isOffscreen(o,d,y,E){return y=this.screenRightBoundary||Ethis.screenBottomBoundary}isInsideGrid(o,d,y,E){return y>=0&&o=0&&dy.collisionGroupID===d}}return this.collisionGroups[o]}}function Ms(m,o,d,y,E){const{horizontalAlign:C,verticalAlign:S}=r.getAnchorAlignment(m),k=-(C-.5)*o,O=-(S-.5)*d,U=r.evaluateVariableOffset(m,y);return new r.pointGeometry(k+U[0]*E,O+U[1]*E)}function Ts(m,o,d,y,E){const C=new r.pointGeometry(m,o);return d&&C._rotate(y?E:-E),C}class $_{constructor(o,d,y,E,C){this.transform=o.clone(),this.collisionIndex=new du(this.transform,C),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=d,this.retainedQueryData={},this.collisionGroups=new po(y),this.collisionCircleArrays={},this.prevPlacement=E,E&&(E.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(o,d,y,E){const C=y.getBucket(d),S=y.latestFeatureIndex;if(!C||!S||d.id!==C.layerIds[0])return;const k=C.layers[0].layout,O=y.collisionBoxArray,U=Math.pow(2,this.transform.zoom-y.tileID.overscaledZ),G=y.tileSize/r.EXTENT,Z=y.tileID.toUnwrapped(),se=this.transform.calculateProjMatrix(Z),de=k.get("text-pitch-alignment")==="map",ce=k.get("text-rotation-alignment")==="map";d.compileFilter();const te=d.dynamicFilter(),Le=d.dynamicFilterNeedsFeature(),ve=this.transform.calculatePixelsToTileUnitsMatrix(y),De=di(se,y.tileID.canonical,de,ce,this.transform,ve);let Se=null;if(de){const Ue=Dr(se,y.tileID.canonical,de,ce,this.transform,ve);Se=r.multiply$1([],this.transform.labelPlaneMatrix,Ue)}let ze=null;te&&y.latestFeatureIndex&&(ze={unwrappedTileID:Z,dynamicFilter:te,dynamicFilterNeedsFeature:Le,featureIndex:y.latestFeatureIndex}),this.retainedQueryData[C.bucketInstanceId]=new Dd(C.bucketInstanceId,S,C.sourceLayerIndex,C.index,y.tileID);const Ee={bucket:C,layout:k,posMatrix:se,textLabelPlaneMatrix:De,labelToScreenMatrix:Se,clippingData:ze,scale:U,textPixelRatio:G,holdingForFade:y.holdingForFade(),collisionBoxArray:O,partiallyEvaluatedTextSize:r.evaluateSizeForZoom(C.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:r.evaluateSizeForZoom(C.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(C.sourceID)};if(E)for(const Ue of C.sortKeyRanges){const{sortKey:nt,symbolInstanceStart:lt,symbolInstanceEnd:pt}=Ue;o.push({sortKey:nt,symbolInstanceStart:lt,symbolInstanceEnd:pt,parameters:Ee})}else o.push({symbolInstanceStart:0,symbolInstanceEnd:C.symbolInstances.length,parameters:Ee})}attemptAnchorPlacement(o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le,ve,De){const Se=[se.textOffset0,se.textOffset1],ze=Ms(o,y,E,Se,C),Ee=this.collisionIndex.placeCollisionBox(C,d,Ts(ze.x,ze.y,S,k,this.transform.angle),Z,O,U,G.predicate);if((!Le||this.collisionIndex.placeCollisionBox(ce.getSymbolInstanceIconSize(De,this.transform.zoom,de),Le,Ts(ze.x,ze.y,S,k,this.transform.angle),Z,O,U,G.predicate).box.length!==0)&&Ee.box.length>0){let Ue;return this.prevPlacement&&this.prevPlacement.variableOffsets[se.crossTileID]&&this.prevPlacement.placements[se.crossTileID]&&this.prevPlacement.placements[se.crossTileID].text&&(Ue=this.prevPlacement.variableOffsets[se.crossTileID].anchor),this.variableOffsets[se.crossTileID]={textOffset:Se,width:y,height:E,anchor:o,textScale:C,prevAnchor:Ue},this.markUsedJustification(ce,o,se,te),ce.allowVerticalPlacement&&(this.markUsedOrientation(ce,te,se),this.placedOrientations[se.crossTileID]=te),{shift:ze,placedGlyphBoxes:Ee}}}placeLayerBucketPart(o,d,y,E){const{bucket:C,layout:S,posMatrix:k,textLabelPlaneMatrix:O,labelToScreenMatrix:U,clippingData:G,textPixelRatio:Z,holdingForFade:se,collisionBoxArray:de,partiallyEvaluatedTextSize:ce,partiallyEvaluatedIconSize:te,collisionGroup:Le}=o.parameters,ve=S.get("text-optional"),De=S.get("icon-optional"),Se=S.get("text-allow-overlap"),ze=S.get("icon-allow-overlap"),Ee=S.get("text-rotation-alignment")==="map",Ue=S.get("text-pitch-alignment")==="map",nt=S.get("icon-text-fit")!=="none",lt=S.get("symbol-z-order")==="viewport-y";let pt=Se&&(ze||!C.hasIconData()||De),ht=ze&&(Se||!C.hasTextData()||ve);!C.collisionArrays&&de&&C.deserializeCollisionBoxes(de),y&&E&&C.updateCollisionDebugBuffers(this.transform.zoom,de);const kt=(it,zt,St)=>{if(G){const bi={zoom:this.transform.zoom,pitch:this.transform.pitch};let Ti=null;if(G.dynamicFilterNeedsFeature){const Yn=this.retainedQueryData[C.bucketInstanceId];Ti=G.featureIndex.loadFeature({featureIndex:it.featureIndex,bucketIndex:Yn.bucketIndex,sourceLayerIndex:Yn.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,G.dynamicFilter)(bi,Ti,this.retainedQueryData[C.bucketInstanceId].tileID.canonical,new r.pointGeometry(it.tileAnchorX,it.tileAnchorY),this.transform.calculateDistanceTileData(G.unwrappedTileID)))return this.placements[it.crossTileID]=new Fo(!1,!1,!1,!0),void(d[it.crossTileID]=!0)}if(d[it.crossTileID])return;if(se)return void(this.placements[it.crossTileID]=new Fo(!1,!1,!1));let Jt=!1,ft=!1,qt=!0,gn=!1,Zt=!1,Yt=null,xn={box:null,offscreen:null,occluded:null},zn={box:null,offscreen:null,occluded:null},dn=null,Mn=null,$n=null,vi=0,nr=0,ir=0;St.textFeatureIndex?vi=St.textFeatureIndex:it.useRuntimeCollisionCircles&&(vi=it.featureIndex),St.verticalTextFeatureIndex&&(nr=St.verticalTextFeatureIndex);const kr=bi=>{bi.tileID=this.retainedQueryData[C.bucketInstanceId].tileID,(this.transform.elevation||bi.elevation)&&(bi.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[C.bucketInstanceId].tileID,bi.tileAnchorX,bi.tileAnchorY):0)},mo=St.textBox;if(mo){kr(mo);const bi=Yn=>{let Si=r.WritingMode.horizontal;if(C.allowVerticalPlacement&&!Yn&&this.prevPlacement){const zr=this.prevPlacement.placedOrientations[it.crossTileID];zr&&(this.placedOrientations[it.crossTileID]=zr,Si=zr,this.markUsedOrientation(C,Si,it))}return Si},Ti=(Yn,Si)=>{if(C.allowVerticalPlacement&&it.numVerticalGlyphVertices>0&&St.verticalTextBox){for(const zr of C.writingModes)if(zr===r.WritingMode.vertical?(xn=Si(),zn=xn):xn=Yn(),xn&&xn.box&&xn.box.length)break}else xn=Yn()};if(S.get("text-variable-anchor")){let Yn=S.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[it.crossTileID]){const xi=this.prevPlacement.variableOffsets[it.crossTileID];Yn.indexOf(xi.anchor)>0&&(Yn=Yn.filter(Xr=>Xr!==xi.anchor),Yn.unshift(xi.anchor))}const Si=(xi,Xr,$l)=>{const Fr=C.getSymbolInstanceTextSize(ce,it,this.transform.zoom,zt),Ha=(xi.x2-xi.x1)*Fr+2*xi.padding,Mg=(xi.y2-xi.y1)*Fr+2*xi.padding,hp=nt&&!ze?Xr:null;hp&&kr(hp);let zs={box:[],offscreen:!1,occluded:!1};const cv=Se?2*Yn.length:Yn.length;for(let fa=0;fa=Yn.length,it,zt,C,$l,hp,ce,te);if(dp&&(zs=dp.placedGlyphBoxes,zs&&zs.box&&zs.box.length)){Jt=!0,Yt=dp.shift;break}}return zs};Ti(()=>Si(mo,St.iconBox,r.WritingMode.horizontal),()=>{const xi=St.verticalTextBox;return xi&&kr(xi),C.allowVerticalPlacement&&!(xn&&xn.box&&xn.box.length)&&it.numVerticalGlyphVertices>0&&xi?Si(xi,St.verticalIconBox,r.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),xn&&(Jt=xn.box,qt=xn.offscreen,gn=xn.occluded);const zr=bi(xn&&xn.box);if(!Jt&&this.prevPlacement){const xi=this.prevPlacement.variableOffsets[it.crossTileID];xi&&(this.variableOffsets[it.crossTileID]=xi,this.markUsedJustification(C,xi.anchor,it,zr))}}else{const Yn=(Si,zr)=>{const xi=C.getSymbolInstanceTextSize(ce,it,this.transform.zoom,zt),Xr=this.collisionIndex.placeCollisionBox(xi,Si,new r.pointGeometry(0,0),Se,Z,k,Le.predicate);return Xr&&Xr.box&&Xr.box.length&&(this.markUsedOrientation(C,zr,it),this.placedOrientations[it.crossTileID]=zr),Xr};Ti(()=>Yn(mo,r.WritingMode.horizontal),()=>{const Si=St.verticalTextBox;return C.allowVerticalPlacement&&it.numVerticalGlyphVertices>0&&Si?(kr(Si),Yn(Si,r.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),bi(xn&&xn.box&&xn.box.length)}}if(dn=xn,Jt=dn&&dn.box&&dn.box.length>0,qt=dn&&dn.offscreen,gn=dn&&dn.occluded,it.useRuntimeCollisionCircles){const bi=C.text.placedSymbolArray.get(it.centerJustifiedTextSymbolIndex>=0?it.centerJustifiedTextSymbolIndex:it.verticalPlacedTextSymbolIndex),Ti=r.evaluateSizeForFeature(C.textSizeData,ce,bi),Yn=S.get("text-padding");Mn=this.collisionIndex.placeCollisionCircles(Se,bi,C.lineVertexArray,C.glyphOffsetArray,Ti,k,O,U,y,Ue,Le.predicate,it.collisionCircleDiameter*Ti/r.ONE_EM,Yn,this.retainedQueryData[C.bucketInstanceId].tileID),Jt=Se||Mn.circles.length>0&&!Mn.collisionDetected,qt=qt&&Mn.offscreen,gn=Mn.occluded}if(St.iconFeatureIndex&&(ir=St.iconFeatureIndex),St.iconBox){const bi=Ti=>{kr(Ti);const Yn=nt&&Yt?Ts(Yt.x,Yt.y,Ee,Ue,this.transform.angle):new r.pointGeometry(0,0),Si=C.getSymbolInstanceIconSize(te,this.transform.zoom,zt);return this.collisionIndex.placeCollisionBox(Si,Ti,Yn,ze,Z,k,Le.predicate)};zn&&zn.box&&zn.box.length&&St.verticalIconBox?($n=bi(St.verticalIconBox),ft=$n.box.length>0):($n=bi(St.iconBox),ft=$n.box.length>0),qt=qt&&$n.offscreen,Zt=$n.occluded}const Uo=ve||it.numHorizontalGlyphVertices===0&&it.numVerticalGlyphVertices===0,pa=De||it.numIconVertices===0;if(Uo||pa?pa?Uo||(ft=ft&&Jt):Jt=ft&&Jt:ft=Jt=ft&&Jt,Jt&&dn&&dn.box&&this.collisionIndex.insertCollisionBox(dn.box,S.get("text-ignore-placement"),C.bucketInstanceId,zn&&zn.box&&nr?nr:vi,Le.ID),ft&&$n&&this.collisionIndex.insertCollisionBox($n.box,S.get("icon-ignore-placement"),C.bucketInstanceId,ir,Le.ID),Mn&&(Jt&&this.collisionIndex.insertCollisionCircles(Mn.circles,S.get("text-ignore-placement"),C.bucketInstanceId,vi,Le.ID),y)){const bi=C.bucketInstanceId;let Ti=this.collisionCircleArrays[bi];Ti===void 0&&(Ti=this.collisionCircleArrays[bi]=new Qi);for(let Yn=0;Yn=0;--zt){const St=it[zt];kt(C.symbolInstances.get(St),St,C.collisionArrays[St])}}else for(let it=o.symbolInstanceStart;it=0&&(o.text.placedSymbolArray.get(k).crossTileID=C>=0&&k!==C?0:y.crossTileID)}markUsedOrientation(o,d,y){const E=d===r.WritingMode.horizontal||d===r.WritingMode.horizontalOnly?d:0,C=d===r.WritingMode.vertical?d:0,S=[y.leftJustifiedTextSymbolIndex,y.centerJustifiedTextSymbolIndex,y.rightJustifiedTextSymbolIndex];for(const k of S)o.text.placedSymbolArray.get(k).placedOrientation=E;y.verticalPlacedTextSymbolIndex&&(o.text.placedSymbolArray.get(y.verticalPlacedTextSymbolIndex).placedOrientation=C)}commit(o){this.commitTime=o,this.zoomAtLastRecencyCheck=this.transform.zoom;const d=this.prevPlacement;let y=!1;this.prevZoomAdjustment=d?d.zoomAdjustment(this.transform.zoom):0;const E=d?d.symbolFadeChange(o):1,C=d?d.opacities:{},S=d?d.variableOffsets:{},k=d?d.placedOrientations:{};for(const O in this.placements){const U=this.placements[O],G=C[O];G?(this.opacities[O]=new zo(G,E,U.text,U.icon,null,U.clipped),y=y||U.text!==G.text.placed||U.icon!==G.icon.placed):(this.opacities[O]=new zo(null,E,U.text,U.icon,U.skipFade,U.clipped),y=y||U.text||U.icon)}for(const O in C){const U=C[O];if(!this.opacities[O]){const G=new zo(U,E,!1,!1);G.isHidden()||(this.opacities[O]=G,y=y||U.text.placed||U.icon.placed)}}for(const O in S)this.variableOffsets[O]||!this.opacities[O]||this.opacities[O].isHidden()||(this.variableOffsets[O]=S[O]);for(const O in k)this.placedOrientations[O]||!this.opacities[O]||this.opacities[O].isHidden()||(this.placedOrientations[O]=k[O]);y?this.lastPlacementChangeTime=o:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=d?d.lastPlacementChangeTime:o)}updateLayerOpacities(o,d){const y={};for(const E of d){const C=E.getBucket(o);C&&E.latestFeatureIndex&&o.id===C.layerIds[0]&&this.updateBucketOpacities(C,y,E.collisionBoxArray)}}updateBucketOpacities(o,d,y){o.hasTextData()&&o.text.opacityVertexArray.clear(),o.hasIconData()&&o.icon.opacityVertexArray.clear(),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexArray.clear(),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexArray.clear();const E=o.layers[0].layout,C=!!o.layers[0].dynamicFilter(),S=new zo(null,0,!1,!1,!0),k=E.get("text-allow-overlap"),O=E.get("icon-allow-overlap"),U=E.get("text-variable-anchor"),G=E.get("text-rotation-alignment")==="map",Z=E.get("text-pitch-alignment")==="map",se=E.get("icon-text-fit")!=="none",de=new zo(null,0,k&&(O||!o.hasIconData()||E.get("icon-optional")),O&&(k||!o.hasTextData()||E.get("text-optional")),!0);!o.collisionArrays&&y&&(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData())&&o.deserializeCollisionBoxes(y);const ce=(Le,ve,De)=>{for(let Se=0;Se0||Se>0,nt=ve.numIconVertices>0,lt=this.placedOrientations[ve.crossTileID],pt=lt===r.WritingMode.vertical,ht=lt===r.WritingMode.horizontal||lt===r.WritingMode.horizontalOnly;if(!Ue&&!nt||Ee.isHidden()||te++,Ue){const kt=Im(Ee.text);ce(o.text,De,pt?mu:kt),ce(o.text,Se,ht?mu:kt);const it=Ee.text.isHidden();[ve.rightJustifiedTextSymbolIndex,ve.centerJustifiedTextSymbolIndex,ve.leftJustifiedTextSymbolIndex].forEach(Jt=>{Jt>=0&&(o.text.placedSymbolArray.get(Jt).hidden=it||pt?1:0)}),ve.verticalPlacedTextSymbolIndex>=0&&(o.text.placedSymbolArray.get(ve.verticalPlacedTextSymbolIndex).hidden=it||ht?1:0);const zt=this.variableOffsets[ve.crossTileID];zt&&this.markUsedJustification(o,zt.anchor,ve,lt);const St=this.placedOrientations[ve.crossTileID];St&&(this.markUsedJustification(o,"left",ve,St),this.markUsedOrientation(o,St,ve))}if(nt){const kt=Im(Ee.icon);ve.placedIconSymbolIndex>=0&&(ce(o.icon,ve.numIconVertices,pt?mu:kt),o.icon.placedSymbolArray.get(ve.placedIconSymbolIndex).hidden=Ee.icon.isHidden()),ve.verticalPlacedIconSymbolIndex>=0&&(ce(o.icon,ve.numVerticalIconVertices,ht?mu:kt),o.icon.placedSymbolArray.get(ve.verticalPlacedIconSymbolIndex).hidden=Ee.icon.isHidden())}if(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData()){const kt=o.collisionArrays[Le];if(kt){let it=new r.pointGeometry(0,0),zt=!0;if(kt.textBox||kt.verticalTextBox){if(U){const Jt=this.variableOffsets[ze];Jt?(it=Ms(Jt.anchor,Jt.width,Jt.height,Jt.textOffset,Jt.textScale),G&&it._rotate(Z?this.transform.angle:-this.transform.angle)):zt=!1}C&&(zt=!Ee.clipped),kt.textBox&&fo(o.textCollisionBox.collisionVertexArray,Ee.text.placed,!zt||pt,it.x,it.y),kt.verticalTextBox&&fo(o.textCollisionBox.collisionVertexArray,Ee.text.placed,!zt||ht,it.x,it.y)}const St=zt&&!!(!ht&&kt.verticalIconBox);kt.iconBox&&fo(o.iconCollisionBox.collisionVertexArray,Ee.icon.placed,St,se?it.x:0,se?it.y:0),kt.verticalIconBox&&fo(o.iconCollisionBox.collisionVertexArray,Ee.icon.placed,!St,se?it.x:0,se?it.y:0)}}}if(o.fullyClipped=te===0,o.sortFeatures(this.transform.angle),this.retainedQueryData[o.bucketInstanceId]&&(this.retainedQueryData[o.bucketInstanceId].featureSortOrder=o.featureSortOrder),o.hasTextData()&&o.text.opacityVertexBuffer&&o.text.opacityVertexBuffer.updateData(o.text.opacityVertexArray),o.hasIconData()&&o.icon.opacityVertexBuffer&&o.icon.opacityVertexBuffer.updateData(o.icon.opacityVertexArray),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexBuffer&&o.iconCollisionBox.collisionVertexBuffer.updateData(o.iconCollisionBox.collisionVertexArray),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexBuffer&&o.textCollisionBox.collisionVertexBuffer.updateData(o.textCollisionBox.collisionVertexArray),o.bucketInstanceId in this.collisionCircleArrays){const Le=this.collisionCircleArrays[o.bucketInstanceId];o.placementInvProjMatrix=Le.invProjMatrix,o.placementViewportMatrix=Le.viewportMatrix,o.collisionCircleArray=Le.circles,delete this.collisionCircleArrays[o.bucketInstanceId]}}symbolFadeChange(o){return this.fadeDuration===0?1:(o-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(o){return Math.max(0,(this.transform.zoom-o)/1.5)}hasTransitions(o){return this.stale||o-this.lastPlacementChangeTimeo}setStale(){this.stale=!0}}function fo(m,o,d,y,E){m.emplaceBack(o?1:0,d?1:0,y||0,E||0),m.emplaceBack(o?1:0,d?1:0,y||0,E||0),m.emplaceBack(o?1:0,d?1:0,y||0,E||0),m.emplaceBack(o?1:0,d?1:0,y||0,E||0)}const q_=Math.pow(2,25),Lm=Math.pow(2,24),Sr=Math.pow(2,17),pu=Math.pow(2,16),ra=Math.pow(2,9),Pd=Math.pow(2,8),fu=Math.pow(2,1);function Im(m){if(m.opacity===0&&!m.placed)return 0;if(m.opacity===1&&m.placed)return 4294967295;const o=m.placed?1:0,d=Math.floor(127*m.opacity);return d*q_+o*Lm+d*Sr+o*pu+d*ra+o*Pd+d*fu+o}const mu=0;class Sd{constructor(o){this._sortAcrossTiles=o.layout.get("symbol-z-order")!=="viewport-y"&&o.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(o,d,y,E,C){const S=this._bucketParts;for(;this._currentTileIndexk.sortKey-O.sortKey));this._currentPartIndex{const S=r.exported.now()-E;return!this._forceFullPlacement&&S>2};for(;this._currentPlacementIndex>=0;){const S=d[o[this._currentPlacementIndex]],k=this.placement.collisionIndex.transform.zoom;if(S.type==="symbol"&&(!S.minzoom||S.minzoom<=k)&&(!S.maxzoom||S.maxzoom>k)){if(this._inProgressLayer||(this._inProgressLayer=new Sd(S)),this._inProgressLayer.continuePlacement(y[S.source],this.placement,this._showCollisionBoxes,S,C))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(o){return this.placement.commit(o),this.placement}}const Rm=512/r.EXTENT/2;class Z_{constructor(o,d,y){this.tileID=o,this.indexedSymbolInstances={},this.bucketInstanceId=y;for(let E=0;Eo.overscaledZ)for(const k in S){const O=S[k];O.tileID.isChildOf(o)&&O.findMatches(d.symbolInstances,o,E)}else{const k=S[o.scaledTo(Number(C)).key];k&&k.findMatches(d.symbolInstances,o,E)}}for(let C=0;C{d[y]=!0});for(const y in this.layerIndexes)d[y]||delete this.layerIndexes[y]}}const bl=(m,o)=>r.emitValidationErrors(m,o&&o.filter(d=>d.identifier!=="source.canvas")),zm=r.pick(_t,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Fm=r.pick(_t,["setCenter","setZoom","setBearing","setPitch"]),Bm={version:8,layers:[],sources:{}},Na={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class yr extends r.Evented{constructor(o,d={}){super(),this.map=o,this.dispatcher=new be(Fe(),this),this.imageManager=new me,this.imageManager.setEventedParent(this),this.glyphManager=new r.GlyphManager(o._requestManager,d.localFontFamily?r.LocalGlyphMode.all:d.localIdeographFontFamily?r.LocalGlyphMode.ideographs:r.LocalGlyphMode.none,d.localFontFamily||d.localIdeographFontFamily),this.lineAtlas=new r.LineAtlas(256,512),this.crossTileSymbolIndex=new gu,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new r.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",r.getReferrer());const y=this;this._rtlTextPluginCallback=yr.registerForPluginStateChange(E=>{y.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:E.pluginStatus,pluginURL:E.pluginURL},(C,S)=>{if(r.triggerPluginCompletionEvent(C),S&&S.every(k=>k))for(const k in y._sourceCaches){const O=y._sourceCaches[k],U=O.getSource().type;U!=="vector"&&U!=="geojson"||O.reload()}})}),this.on("data",E=>{if(E.dataType!=="source"||E.sourceDataType!=="metadata")return;const C=this.getSource(E.sourceId);if(C&&C.vectorLayerIds)for(const S in this._layers){const k=this._layers[S];k.source===C.id&&this._validateLayer(k)}})}loadURL(o,d={}){this.fire(new r.Event("dataloading",{dataType:"style"}));const y=typeof d.validate=="boolean"?d.validate:!r.isMapboxURL(o);o=this.map._requestManager.normalizeStyleURL(o,d.accessToken);const E=this.map._requestManager.transformRequest(o,r.ResourceType.Style);this._request=r.getJSON(E,(C,S)=>{this._request=null,C?this.fire(new r.ErrorEvent(C)):S&&this._load(S,y)})}loadJSON(o,d={}){this.fire(new r.Event("dataloading",{dataType:"style"})),this._request=r.exported.frame(()=>{this._request=null,this._load(o,d.validate!==!1)})}loadEmpty(){this.fire(new r.Event("dataloading",{dataType:"style"})),this._load(Bm,!1)}_updateLayerCount(o,d){const y=d?1:-1;o.is3D()&&(this._num3DLayers+=y),o.type==="circle"&&(this._numCircleLayers+=y),o.type==="symbol"&&(this._numSymbolLayers+=y)}_load(o,d){if(d&&bl(this,r.validateStyle(o)))return;this._loaded=!0,this.stylesheet=o,this._updateMapProjection();for(const E in o.sources)this.addSource(E,o.sources[E],{validate:!1});this._changed=!1,o.sprite?this._loadSprite(o.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(o.glyphs);const y=Tt(this.stylesheet.layers);this._order=y.map(E=>E.id),this._layers={},this._serializedLayers={};for(let E of y)E=r.createStyleLayer(E),E.setEventedParent(this,{layer:{id:E.id}}),this._layers[E.id]=E,this._serializedLayers[E.id]=E.serialize(),this._updateLayerCount(E,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Ve(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 r.Event("data",{dataType:"style"})),this.fire(new r.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(o){o?this.stylesheet.projection=o: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(o){this._spriteRequest=function(d,y,E){let C,S,k;const O=r.exported.devicePixelRatio>1?"@2x":"";let U=r.getJSON(y.transformRequest(y.normalizeSpriteURL(d,O,".json"),r.ResourceType.SpriteJSON),(se,de)=>{U=null,k||(k=se,C=de,Z())}),G=r.getImage(y.transformRequest(y.normalizeSpriteURL(d,O,".png"),r.ResourceType.SpriteImage),(se,de)=>{G=null,k||(k=se,S=de,Z())});function Z(){if(k)E(k);else if(C&&S){const se=r.exported.getImageData(S),de={};for(const ce in C){const{width:te,height:Le,x:ve,y:De,sdf:Se,pixelRatio:ze,stretchX:Ee,stretchY:Ue,content:nt}=C[ce],lt=new r.RGBAImage({width:te,height:Le});r.RGBAImage.copy(se,lt,{x:ve,y:De},{x:0,y:0},{width:te,height:Le}),de[ce]={data:lt,pixelRatio:ze,sdf:Se,stretchX:Ee,stretchY:Ue,content:nt}}E(null,de)}}return{cancel(){U&&(U.cancel(),U=null),G&&(G.cancel(),G=null)}}}(o,this.map._requestManager,(d,y)=>{if(this._spriteRequest=null,d)this.fire(new r.ErrorEvent(d));else if(y)for(const E in y)this.imageManager.addImage(E,y[E]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new r.Event("data",{dataType:"style"}))})}_validateLayer(o){const d=this.getSource(o.source);if(!d)return;const y=o.sourceLayer;y&&(d.type==="geojson"||d.vectorLayerIds&&d.vectorLayerIds.indexOf(y)===-1)&&this.fire(new r.ErrorEvent(new Error(`Source layer "${y}" does not exist on source "${d.id}" as specified by style layer "${o.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const o in this._sourceCaches)if(!this._sourceCaches[o].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(o){const d=[];for(const y of o){const E=this._layers[y];E.type!=="custom"&&d.push(E.serialize())}return d}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const o in this._sourceCaches)if(this._sourceCaches[o].hasTransition())return!0;for(const o in this._layers)if(this._layers[o].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(o){return!!this.terrain&&Na[o.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(o){if(!this._loaded)return;const d=this._changed;if(this._changed){const E=Object.keys(this._updatedLayers),C=Object.keys(this._removedLayers);(E.length||C.length)&&this._updateWorkerLayers(E,C);for(const S in this._updatedSources){const k=this._updatedSources[S];k==="reload"?this._reloadSource(S):k==="clear"&&this._clearSource(S)}this._updateTilesForChangedImages();for(const S in this._updatedPaintProps)this._layers[S].updateTransitions(o);this.light.updateTransitions(o),this.fog&&this.fog.updateTransitions(o),this._resetUpdates()}const y={};for(const E in this._sourceCaches){const C=this._sourceCaches[E];y[E]=C.used,C.used=!1}for(const E of this._order){const C=this._layers[E];if(C.recalculate(o,this._availableImages),!C.isHidden(o.zoom)){const k=this._getLayerSourceCache(C);k&&(k.used=!0)}const S=this.map.painter;if(S){const k=C.getProgramIds();if(!k)continue;const O=C.getProgramConfiguration(o.zoom);for(const U of k)S.useProgram(U,O)}}for(const E in y){const C=this._sourceCaches[E];y[E]!==C.used&&C.getSource().fire(new r.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:C.getSource().id}))}this.light.recalculate(o),this.terrain&&this.terrain.recalculate(o),this.fog&&this.fog.recalculate(o),this.z=o.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),d&&this.fire(new r.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const o=Object.keys(this._changedImages);if(o.length){for(const d in this._sourceCaches)this._sourceCaches[d].reloadTilesForDependencies(["icons","patterns"],o);this._changedImages={}}}_updateWorkerLayers(o,d){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(o),removedIds:d})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(o){if(this._checkLoaded(),bl(this,r.validateStyle(o)))return!1;(o=r.clone$1(o)).layers=Tt(o.layers);const d=function(E,C){if(!E)return[{command:_t.setStyle,args:[C]}];let S=[];try{if(!b(E.version,C.version))return[{command:_t.setStyle,args:[C]}];b(E.center,C.center)||S.push({command:_t.setCenter,args:[C.center]}),b(E.zoom,C.zoom)||S.push({command:_t.setZoom,args:[C.zoom]}),b(E.bearing,C.bearing)||S.push({command:_t.setBearing,args:[C.bearing]}),b(E.pitch,C.pitch)||S.push({command:_t.setPitch,args:[C.pitch]}),b(E.sprite,C.sprite)||S.push({command:_t.setSprite,args:[C.sprite]}),b(E.glyphs,C.glyphs)||S.push({command:_t.setGlyphs,args:[C.glyphs]}),b(E.transition,C.transition)||S.push({command:_t.setTransition,args:[C.transition]}),b(E.light,C.light)||S.push({command:_t.setLight,args:[C.light]}),b(E.fog,C.fog)||S.push({command:_t.setFog,args:[C.fog]}),b(E.projection,C.projection)||S.push({command:_t.setProjection,args:[C.projection]});const k={},O=[];(function(Z,se,de,ce){let te;for(te in se=se||{},Z=Z||{})Z.hasOwnProperty(te)&&(se.hasOwnProperty(te)||rn(te,de,ce));for(te in se)se.hasOwnProperty(te)&&(Z.hasOwnProperty(te)?b(Z[te],se[te])||(Z[te].type==="geojson"&&se[te].type==="geojson"&&Ln(Z,se,te)?de.push({command:_t.setGeoJSONSourceData,args:[te,se[te].data]}):Sn(te,se,de,ce)):Ot(te,se,de))})(E.sources,C.sources,O,k);const U=[];E.layers&&E.layers.forEach(Z=>{Z.source&&k[Z.source]?S.push({command:_t.removeLayer,args:[Z.id]}):U.push(Z)});let G=E.terrain;G&&k[G.source]&&(S.push({command:_t.setTerrain,args:[void 0]}),G=void 0),S=S.concat(O),b(G,C.terrain)||S.push({command:_t.setTerrain,args:[C.terrain]}),function(Z,se,de){se=se||[];const ce=(Z=Z||[]).map(un),te=se.map(un),Le=Z.reduce(Kt,{}),ve=se.reduce(Kt,{}),De=ce.slice(),Se=Object.create(null);let ze,Ee,Ue,nt,lt,pt,ht;for(ze=0,Ee=0;ze!(E.command in Fm));if(d.length===0)return!1;const y=d.filter(E=>!(E.command in zm));if(y.length>0)throw new Error(`Unimplemented: ${y.map(E=>E.command).join(", ")}.`);return d.forEach(E=>{E.command!=="setTransition"&&this[E.command].apply(this,E.args)}),this.stylesheet=o,this._updateMapProjection(),!0}addImage(o,d){return this.getImage(o)?this.fire(new r.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(o,d),this._afterImageUpdated(o),this)}updateImage(o,d){this.imageManager.updateImage(o,d)}getImage(o){return this.imageManager.getImage(o)}removeImage(o){return this.getImage(o)?(this.imageManager.removeImage(o),this._afterImageUpdated(o),this):this.fire(new r.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(o){this._availableImages=this.imageManager.listImages(),this._changedImages[o]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new r.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(o,d,y={}){if(this._checkLoaded(),this.getSource(o)!==void 0)throw new Error("There is already a source with this ID");if(!d.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(d).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(d.type)>=0&&this._validate(r.validateSource,`sources.${o}`,d,null,y))return;this.map&&this.map._collectResourceTiming&&(d.collectResourceTiming=!0);const E=tt(o,d,this.dispatcher,this);E.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(o),source:E.serialize(),sourceId:o}));const C=S=>{const k=(S?"symbol:":"other:")+o,O=this._sourceCaches[k]=new r.SourceCache(k,E,S);(S?this._symbolSourceCaches:this._otherSourceCaches)[o]=O,O.style=this,O.onAdd(this.map)};C(!1),d.type!=="vector"&&d.type!=="geojson"||C(!0),E.onAdd&&E.onAdd(this.map),this._changed=!0}removeSource(o){this._checkLoaded();const d=this.getSource(o);if(!d)throw new Error("There is no source with this ID");for(const E in this._layers)if(this._layers[E].source===o)return this.fire(new r.ErrorEvent(new Error(`Source "${o}" cannot be removed while layer "${E}" is using it.`)));if(this.terrain&&this.terrain.get().source===o)return this.fire(new r.ErrorEvent(new Error(`Source "${o}" cannot be removed while terrain is using it.`)));const y=this._getSourceCaches(o);for(const E of y)delete this._sourceCaches[E.id],delete this._updatedSources[E.id],E.fire(new r.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:E.getSource().id})),E.setEventedParent(null),E.clearTiles();return delete this._otherSourceCaches[o],delete this._symbolSourceCaches[o],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(o,d){this._checkLoaded(),this.getSource(o).setData(d),this._changed=!0}getSource(o){const d=this._getSourceCache(o);return d&&d.getSource()}addLayer(o,d,y={}){this._checkLoaded();const E=o.id;if(this.getLayer(E))return void this.fire(new r.ErrorEvent(new Error(`Layer with id "${E}" already exists on this map`)));let C;if(o.type==="custom"){if(bl(this,r.validateCustomStyleLayer(o)))return;C=r.createStyleLayer(o)}else{if(typeof o.source=="object"&&(this.addSource(E,o.source),o=r.clone$1(o),o=r.extend(o,{source:E})),this._validate(r.validateLayer,`layers.${E}`,o,{arrayIndex:-1},y))return;C=r.createStyleLayer(o),this._validateLayer(C),C.setEventedParent(this,{layer:{id:E}}),this._serializedLayers[C.id]=C.serialize(),this._updateLayerCount(C,!0)}const S=d?this._order.indexOf(d):this._order.length;if(d&&S===-1)return void this.fire(new r.ErrorEvent(new Error(`Layer with id "${d}" does not exist on this map.`)));this._order.splice(S,0,E),this._layerOrderChanged=!0,this._layers[E]=C;const k=this._getLayerSourceCache(C);if(this._removedLayers[E]&&C.source&&k&&C.type!=="custom"){const O=this._removedLayers[E];delete this._removedLayers[E],O.type!==C.type?this._updatedSources[C.source]="clear":(this._updatedSources[C.source]="reload",k.pause())}this._updateLayer(C),C.onAdd&&C.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(o,d){if(this._checkLoaded(),this._changed=!0,!this._layers[o])return void this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be moved.`)));if(o===d)return;const y=this._order.indexOf(o);this._order.splice(y,1);const E=d?this._order.indexOf(d):this._order.length;d&&E===-1?this.fire(new r.ErrorEvent(new Error(`Layer with id "${d}" does not exist on this map.`))):(this._order.splice(E,0,o),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(o){this._checkLoaded();const d=this._layers[o];if(!d)return void this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be removed.`)));d.setEventedParent(null),this._updateLayerCount(d,!1);const y=this._order.indexOf(o);this._order.splice(y,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[o]=d,delete this._layers[o],delete this._serializedLayers[o],delete this._updatedLayers[o],delete this._updatedPaintProps[o],d.onRemove&&d.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(o){return this._layers[o]}hasLayer(o){return o in this._layers}hasLayerType(o){for(const d in this._layers)if(this._layers[d].type===o)return!0;return!1}setLayerZoomRange(o,d,y){this._checkLoaded();const E=this.getLayer(o);E?E.minzoom===d&&E.maxzoom===y||(d!=null&&(E.minzoom=d),y!=null&&(E.maxzoom=y),this._updateLayer(E)):this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(o,d,y={}){this._checkLoaded();const E=this.getLayer(o);if(E){if(!b(E.filter,d))return d==null?(E.filter=void 0,void this._updateLayer(E)):void(this._validate(r.validateFilter,`layers.${E.id}.filter`,d,{layerType:E.type},y)||(E.filter=r.clone$1(d),this._updateLayer(E)))}else this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be filtered.`)))}getFilter(o){const d=this.getLayer(o);return d&&r.clone$1(d.filter)}setLayoutProperty(o,d,y,E={}){this._checkLoaded();const C=this.getLayer(o);C?b(C.getLayoutProperty(d),y)||(C.setLayoutProperty(d,y,E),this._updateLayer(C)):this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(o,d){const y=this.getLayer(o);if(y)return y.getLayoutProperty(d);this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style.`)))}setPaintProperty(o,d,y,E={}){this._checkLoaded();const C=this.getLayer(o);C?b(C.getPaintProperty(d),y)||(C.setPaintProperty(d,y,E)&&this._updateLayer(C),this._changed=!0,this._updatedPaintProps[o]=!0):this.fire(new r.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(o,d){const y=this.getLayer(o);return y&&y.getPaintProperty(d)}setFeatureState(o,d){this._checkLoaded();const y=o.source,E=o.sourceLayer,C=this.getSource(y);if(!C)return void this.fire(new r.ErrorEvent(new Error(`The source '${y}' does not exist in the map's style.`)));const S=C.type;if(S==="geojson"&&E)return void this.fire(new r.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(S==="vector"&&!E)return void this.fire(new r.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));o.id===void 0&&this.fire(new r.ErrorEvent(new Error("The feature id parameter must be provided.")));const k=this._getSourceCaches(y);for(const O of k)O.setFeatureState(E,o.id,d)}removeFeatureState(o,d){this._checkLoaded();const y=o.source,E=this.getSource(y);if(!E)return void this.fire(new r.ErrorEvent(new Error(`The source '${y}' does not exist in the map's style.`)));const C=E.type,S=C==="vector"?o.sourceLayer:void 0;if(C==="vector"&&!S)return void this.fire(new r.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&typeof o.id!="string"&&typeof o.id!="number")return void this.fire(new r.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const k=this._getSourceCaches(y);for(const O of k)O.removeFeatureState(S,o.id,d)}getFeatureState(o){this._checkLoaded();const d=o.source,y=o.sourceLayer,E=this.getSource(d);if(E){if(E.type!=="vector"||y)return o.id===void 0&&this.fire(new r.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(d)[0].getFeatureState(y,o.id);this.fire(new r.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new r.ErrorEvent(new Error(`The source '${d}' does not exist in the map's style.`)))}getTransition(){return r.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const o={};for(const d in this._sourceCaches){const y=this._sourceCaches[d].getSource();o[y.id]||(o[y.id]=y.serialize())}return r.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:o,layers:this._serializeLayers(this._order)},d=>d!==void 0)}_updateLayer(o){this._updatedLayers[o.id]=!0;const d=this._getLayerSourceCache(o);o.source&&!this._updatedSources[o.source]&&d&&d.getSource().type!=="raster"&&(this._updatedSources[o.source]="reload",d.pause()),this._changed=!0,o.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(o){const d=S=>this._layers[S].type==="fill-extrusion",y={},E=[];for(let S=this._order.length-1;S>=0;S--){const k=this._order[S];if(d(k)){y[k]=S;for(const O of o){const U=O[k];if(U)for(const G of U)E.push(G)}}}E.sort((S,k)=>k.intersectionZ-S.intersectionZ);const C=[];for(let S=this._order.length-1;S>=0;S--){const k=this._order[S];if(d(k))for(let O=E.length-1;O>=0;O--){const U=E[O].feature;if(y[U.layer.id]{const U=this.getLayer(O);return U&&U.is3D()}):this.has3DLayers(),k=Ge.createFromScreenPoints(o,y);for(const O in this._sourceCaches){const U=this._sourceCaches[O].getSource().id;d.layers&&!E[U]||C.push(rt(this._sourceCaches[O],this._layers,this._serializedLayers,k,d,y,S,!!this.map._showQueryGeometry))}return this.placement&&C.push(function(O,U,G,Z,se,de,ce){const te={},Le=de.queryRenderedSymbols(Z),ve=[];for(const De of Object.keys(Le).map(Number))ve.push(ce[De]);ve.sort(Vt);for(const De of ve){const Se=De.featureIndex.lookupSymbolFeatures(Le[De.bucketInstanceId],U,De.bucketIndex,De.sourceLayerIndex,se.filter,se.layers,se.availableImages,O);for(const ze in Se){const Ee=te[ze]=te[ze]||[],Ue=Se[ze];Ue.sort((nt,lt)=>{const pt=De.featureSortOrder;if(pt){const ht=pt.indexOf(nt.featureIndex);return pt.indexOf(lt.featureIndex)-ht}return lt.featureIndex-nt.featureIndex});for(const nt of Ue)Ee.push(nt)}}for(const De in te)te[De].forEach(Se=>{const ze=Se.feature,Ee=G(O[De]).getFeatureState(ze.layer["source-layer"],ze.id);ze.source=ze.layer.source,ze.layer["source-layer"]&&(ze.sourceLayer=ze.layer["source-layer"]),ze.state=Ee});return te}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),k.screenGeometry,d,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(C)}querySourceFeatures(o,d){d&&d.filter&&this._validate(r.validateFilter,"querySourceFeatures.filter",d.filter,null,d);const y=this._getSourceCaches(o);let E=[];for(const C of y)E=E.concat(vt(C,d));return E}addSourceType(o,d,y){return yr.getSourceType(o)?y(new Error(`A source type called "${o}" already exists.`)):(yr.setSourceType(o,d),d.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:o,url:d.workerSourceURL},y):y(null,null))}getLight(){return this.light.getLight()}setLight(o,d={}){this._checkLoaded();const y=this.light.getLight();let E=!1;for(const S in o)if(!b(o[S],y[S])){E=!0;break}if(!E)return;const C={now:r.exported.now(),transition:r.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(o,d),this.light.updateTransitions(C)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(o,d=1){if(this._checkLoaded(),!o)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(d===1){if(typeof o.source=="object"){const y="terrain-dem-src";this.addSource(y,o.source),o=r.clone$1(o),o=r.extend(o,{source:y})}if(this._validate(r.validateTerrain,"terrain",o))return}if(!this.terrain||this.terrain&&d!==this.terrain.drapeRenderMode)this._createTerrain(o,d);else{const y=this.terrain,E=y.get();for(const C in o)if(!b(o[C],E[C])){y.set(o),this.stylesheet.terrain=o;const S={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};y.updateTransitions(S);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(o){const d=this.fog=new Ie(o,this.map.transform);this.stylesheet.fog=o;const y={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(y)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const o of this.map._markers)o._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(o){if(this._checkLoaded(),!o)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const d=this.fog,y=d.get();for(const E in o)if(!b(o[E],y[E])){d.set(o),this.stylesheet.fog=o;const C={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(C);break}}else this._createFog(o);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const o=this._order.filter(y=>this.isLayerDraped(this._layers[y])),d=this._order.filter(y=>!this.isLayerDraped(this._layers[y]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...o),this._drapedFirstOrder.push(...d)}_createTerrain(o,d){const y=this.terrain=new At(o,d);this.stylesheet.terrain=o,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const E={now:r.exported.now(),transition:r.extend({duration:0},this.stylesheet.transition)};y.updateTransitions(E)}_force3DLayerUpdate(){for(const o in this._layers){const d=this._layers[o];d.type==="fill-extrusion"&&this._updateLayer(d)}}_forceSymbolLayerUpdate(){for(const o in this._layers){const d=this._layers[o];d.type==="symbol"&&this._updateLayer(d)}}_validate(o,d,y,E,C={}){return(!C||C.validate!==!1)&&bl(this,o.call(r.validateStyle,r.extend({key:d,style:this.serialize(),value:y,styleSpec:r.spec},E)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),r.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const o in this._layers)this._layers[o].setEventedParent(null);for(const o in this._sourceCaches)this._sourceCaches[o].clearTiles(),this._sourceCaches[o].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(o){const d=this._getSourceCaches(o);for(const y of d)y.clearTiles()}_reloadSource(o){const d=this._getSourceCaches(o);for(const y of d)y.resume(),y.reload()}_updateSources(o){for(const d in this._sourceCaches)this._sourceCaches[d].update(o)}_generateCollisionBoxes(){for(const o in this._sourceCaches){const d=this._sourceCaches[o];d.resume(),d.reload()}}_updatePlacement(o,d,y,E,C=!1){let S=!1,k=!1;const O={};for(const U of this._order){const G=this._layers[U];if(G.type!=="symbol")continue;if(!O[G.source]){const se=this._getLayerSourceCache(G);if(!se)continue;O[G.source]=se.getRenderableIds(!0).map(de=>se.getTileByID(de)).sort((de,ce)=>ce.tileID.overscaledZ-de.tileID.overscaledZ||(de.tileID.isLessThan(ce.tileID)?-1:1))}const Z=this.crossTileSymbolIndex.addLayer(G,O[G.source],o.center.lng,o.projection);S=S||Z}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),C=C||this._layerOrderChanged||y===0,this._layerOrderChanged&&this.fire(new r.Event("neworder")),(C||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(r.exported.now(),o.zoom))&&(this.pauseablePlacement=new X_(o,this._order,C,d,y,E,this.placement,this.fog&&o.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,O),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(r.exported.now()),k=!0),S&&this.pauseablePlacement.placement.setStale()),k||S)for(const U of this._order){const G=this._layers[U];G.type==="symbol"&&this.placement.updateLayerOpacities(G,O[G.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(r.exported.now())}_releaseSymbolFadeTiles(){for(const o in this._sourceCaches)this._sourceCaches[o].releaseSymbolFadeTiles()}getImages(o,d,y){this.imageManager.getImages(d.icons,y),this._updateTilesForChangedImages();const E=C=>{C&&C.setDependencies(d.tileID.key,d.type,d.icons)};E(this._otherSourceCaches[d.source]),E(this._symbolSourceCaches[d.source])}getGlyphs(o,d,y){this.glyphManager.getGlyphs(d.stacks,y)}getResource(o,d,y){return r.makeRequest(d,y)}_getSourceCache(o){return this._otherSourceCaches[o]}_getLayerSourceCache(o){return o.type==="symbol"?this._symbolSourceCaches[o.source]:this._otherSourceCaches[o.source]}_getSourceCaches(o){const d=[];return this._otherSourceCaches[o]&&d.push(this._otherSourceCaches[o]),this._symbolSourceCaches[o]&&d.push(this._symbolSourceCaches[o]),d}_isSourceCacheLoaded(o){const d=this._getSourceCaches(o);return d.length===0?(this.fire(new r.ErrorEvent(new Error(`There is no source with ID '${o}'`))),!1):d.every(y=>y.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)}}yr.getSourceType=function(m){return et[m]},yr.setSourceType=function(m,o){et[m]=o},yr.registerForPluginStateChange=r.registerForPluginStateChange;var wl=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #define EXTENT 8192.0 #define HALF_PI PI/2.0 #define QUARTER_PI PI/4.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0 #ifdef FOG 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);} #endif`,Ml="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 Ua={},oa={};Ua=yn("",` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW 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( 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;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif #ifdef TERRAIN #ifdef TERRAIN_DEM_FLOAT_FORMAT uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev; #else uniform sampler2D u_dem;uniform sampler2D u_dem_prev; #endif 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) { #ifdef TERRAIN_DEM_FLOAT_FORMAT 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; #else 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)); #ifdef TERRAIN_DEM_NEAREST_FILTER return u_exaggeration*tl; #endif 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); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT 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; #else 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); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) {return currentElevation(apos);} #endif float unpack_depth(vec4 rgba_depth) {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( 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)) );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) { #ifdef TERRAIN_DEM_FLOAT_FORMAT 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; #else 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); #endif 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);} #else float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; } #endif`,!0),oa=yn(`#ifdef FOG 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);} #endif`,`#ifdef FOG 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);} #endif`,!0);const yu=yn(` 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;} #ifdef TERRAIN 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;} #endif`,` 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;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT 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; #else return vec3(0.0); #endif }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);} #endif 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( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}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.`),Tl=wl;var El={background:yn(`uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color; #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),backgroundPattern:yn(`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); #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),circle:yn(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity 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( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif gl_FragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`#define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 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; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity 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) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }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); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5); #ifdef PROJECTION_GLOBE_VIEW 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); #else mat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1); #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif #if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW) view_scale*=a_scale; #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step(); #ifdef PITCH_WITH_MAP 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; #else vec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center; #endif 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); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:yn("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:yn(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight 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); #ifdef FOG gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius 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); #ifdef PROJECTION_GLOBE_VIEW 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); #else vec3 pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:yn(`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; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"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:yn("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( 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:yn("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( 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( 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:yn("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; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3; #endif 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; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1); #else gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1); #endif }`),fill:yn(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec4 out_color=color; #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutline:yn(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color; #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutlinePattern:yn(`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; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to 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); #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillPattern:yn(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to 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); #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillExtrusion:yn(`varying vec4 v_color;void main() {vec4 color=v_color; #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec4 v_color; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color 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); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif #ifdef TERRAIN 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); #else vec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base); #endif #ifdef PROJECTION_GLOBE_VIEW 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); #endif 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*=( (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; #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillExtrusionPattern:yn(`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; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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; #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif #ifdef TERRAIN 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); #else vec3 p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW 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); #endif 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 ? pos_nx.xy : 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*=( (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; #ifdef FOG v_fog_pos=fog_position(p); #endif }`),hillshadePrepare:yn(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) { #ifdef TERRAIN_DEM_FLOAT_FORMAT return texture2D(u_image,coord).a/4.0; #else vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0; #endif }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( (c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"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:yn(`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; #ifdef FOG gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos)); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),line:yn(`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; #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image;varying highp vec2 v_uv; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash_from #pragma mapbox: define lowp vec4 dash_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash_from #pragma mapbox: initialize lowp vec4 dash_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity 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); #ifdef RENDER_LINE_DASH 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); #endif #ifdef RENDER_LINE_GRADIENT vec4 out_color=texture2D(u_gradient_image,v_uv); #else vec4 out_color=color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef RENDER_LINE_ALPHA_DISCARD if (alpha < u_alpha_discard_threshold) {discard;} #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define EXTRUDE_SCALE 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data; #ifdef RENDER_LINE_GRADIENT attribute vec3 a_packed; #else attribute float a_linesofar; #endif 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; #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height;varying highp vec2 v_uv; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash_from #pragma mapbox: define lowp vec4 dash_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash_from #pragma mapbox: initialize lowp vec4 dash_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width 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; #ifndef RENDER_TO_TEXTURE 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; #else v_gamma_scale=1.0; #endif #ifdef RENDER_LINE_GRADIENT 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); #endif #ifdef RENDER_LINE_DASH 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); #endif v_width2=vec2(outset,inset); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),linePattern:yn(`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; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity 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); #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 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; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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; #ifndef RENDER_TO_TEXTURE 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; #else v_gamma_scale=1.0; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth; #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),raster:yn(`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( 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); #ifdef FOG out_color=fog_dither(fog_apply(out_color,v_fog_pos)); #endif gl_FragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),symbolIcon:yn(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity 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); #ifdef PROJECTION_GLOBE_VIEW 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; #else vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0; #endif 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 ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 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);} #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition); #else vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z); #endif #ifdef PROJECTED_POS_ON_VIEWPORT vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0); #else vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0); #endif 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); #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif 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; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif 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:yn(`#define SDF_PX 8.0 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; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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); #ifdef PROJECTION_GLOBE_VIEW 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; #else vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0; #endif 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 ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 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);} #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition); #else vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z); #endif #ifdef PROJECTED_POS_ON_VIEWPORT vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0); #else vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0); #endif 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); #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif 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; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif 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:yn(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 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; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif 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); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef PROJECTION_GLOBE_VIEW 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; #endif varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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); #ifdef PROJECTION_GLOBE_VIEW 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; #else vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0; #endif 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 ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 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);} #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition); #else vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z); #endif #ifdef PROJECTED_POS_ON_VIEWPORT vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0); #else vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0); #endif 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); #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif 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; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif 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:yn(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif void main() {vec4 color=texture2D(u_image0,v_pos0); #ifdef FOG color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif 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; #ifdef TERRAIN_WIREFRAME elevation+=u_skirt_height*u_skirt_height*wireframeOffset; #endif vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif }`),terrainDepth:yn(`#ifdef GL_ES precision highp float; #endif 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:yn(` 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( 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; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif 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); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,Ml),skyboxGradient:yn(`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)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,Ml),skyboxCapture:yn(` 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; #ifdef GL_ES precision highp float; #endif #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 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:yn(`uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0); #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`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; #ifdef GLOBE_POLES attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv; #else attribute vec2 a_pos; #endif 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() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv; #else 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); #endif v_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv); #ifdef TERRAIN_WIREFRAME height+=wireframeOffset; #endif 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:yn(`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) 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 yn(m,o,d){const y=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,E=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,C=o.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),S=m.match(E),k=o.match(E),O=wl.match(E);let U=k?k.concat(S):S;d||(Ua.staticUniforms&&(U=Ua.staticUniforms.concat(U)),oa.staticUniforms&&(U=oa.staticUniforms.concat(U))),U&&(U=U.concat(O));const G={};return{fragmentSource:m=m.replace(y,(Z,se,de,ce,te)=>(G[te]=!0,se==="define"?` #ifndef HAS_UNIFORM_u_${te} varying ${de} ${ce} ${te}; #else uniform ${de} ${ce} u_${te}; #endif `:` #ifdef HAS_UNIFORM_u_${te} ${de} ${ce} ${te} = u_${te}; #endif `)),vertexSource:o=o.replace(y,(Z,se,de,ce,te)=>{const Le=ce==="float"?"vec2":"vec4",ve=te.match(/color/)?"color":Le;return G[te]?se==="define"?` #ifndef HAS_UNIFORM_u_${te} uniform lowp float u_${te}_t; attribute ${de} ${Le} a_${te}; varying ${de} ${ce} ${te}; #else uniform ${de} ${ce} u_${te}; #endif `:ve==="vec4"?` #ifndef HAS_UNIFORM_u_${te} ${te} = a_${te}; #else ${de} ${ce} ${te} = u_${te}; #endif `:` #ifndef HAS_UNIFORM_u_${te} ${te} = unpack_mix_${ve}(a_${te}, u_${te}_t); #else ${de} ${ce} ${te} = u_${te}; #endif `:se==="define"?` #ifndef HAS_UNIFORM_u_${te} uniform lowp float u_${te}_t; attribute ${de} ${Le} a_${te}; #else uniform ${de} ${ce} u_${te}; #endif `:ve==="vec4"?` #ifndef HAS_UNIFORM_u_${te} ${de} ${ce} ${te} = a_${te}; #else ${de} ${ce} ${te} = u_${te}; #endif `:` #ifndef HAS_UNIFORM_u_${te} ${de} ${ce} ${te} = unpack_mix_${ve}(a_${te}, u_${te}_t); #else ${de} ${ce} ${te} = u_${te}; #endif `}),staticAttributes:C,staticUniforms:U}}class _u{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(o,d,y,E,C,S,k,O){this.context=o;let U=this.boundPaintVertexBuffers.length!==E.length;for(let G=0;!U&&G{const Se=ve.paint.get("hillshade-shadow-color"),ze=ve.paint.get("hillshade-highlight-color"),Ee=ve.paint.get("hillshade-accent-color");let Ue=ve.paint.get("hillshade-illumination-direction")*(Math.PI/180);ve.paint.get("hillshade-illumination-anchor")==="viewport"&&(Ue-=te.transform.angle);const nt=!te.options.moving;return{u_matrix:De||te.transform.calculateProjMatrix(Le.tileID.toUnwrapped(),nt),u_image:0,u_latrange:Om(0,Le.tileID),u_light:[ve.paint.get("hillshade-exaggeration"),Ue],u_shadow:Se,u_highlight:ze,u_accent:Ee}})(m,d,y,m.terrain?o.projMatrix:null);m.prepareDrawProgram(k,G,o.toUnwrapped());const{tileBoundsBuffer:se,tileBoundsIndexBuffer:de,tileBoundsSegments:ce}=m.getTileBoundsBuffers(d);G.draw(k,O.TRIANGLES,E,C,S,r.CullFaceMode.disabled,Z,y.id,se,de,ce)}function Ld(m,o,d){if(!o.needsDEMTextureUpload)return;const y=m.context,E=y.gl;y.pixelStoreUnpackPremultiplyAlpha.set(!1),o.demTexture=o.demTexture||m.getTileTexture(d.stride);const C=d.getPixels();o.demTexture?o.demTexture.update(C,{premultiply:!1}):o.demTexture=new r.Texture(y,C,E.RGBA,{premultiply:!1}),o.needsDEMTextureUpload=!1}function Id(m,o,d,y,E,C){const S=m.context,k=S.gl;if(!o.dem)return;const O=o.dem;if(S.activeTexture.set(k.TEXTURE1),Ld(m,o,O),!o.demTexture)return;o.demTexture.bind(k.NEAREST,k.CLAMP_TO_EDGE);const U=O.dim;S.activeTexture.set(k.TEXTURE0);let G=o.fbo;if(!G){const ce=new r.Texture(S,{width:U,height:U,data:null},k.RGBA);ce.bind(k.LINEAR,k.CLAMP_TO_EDGE),G=o.fbo=S.createFramebuffer(U,U,!0),G.colorAttachment.set(ce.texture)}S.bindFramebuffer.set(G.framebuffer),S.viewport.set([0,0,U,U]);const{tileBoundsBuffer:Z,tileBoundsIndexBuffer:se,tileBoundsSegments:de}=m.getMercatorTileBoundsBuffers();m.useProgram("hillshadePrepare").draw(S,k.TRIANGLES,y,E,C,r.CullFaceMode.disabled,((ce,te)=>{const Le=te.stride,ve=r.create();return r.ortho(ve,0,r.EXTENT,-r.EXTENT,0,0,1),r.translate(ve,ve,[0,-r.EXTENT,0]),{u_matrix:ve,u_image:1,u_dimension:[Le,Le],u_zoom:ce.overscaledZ,u_unpack:te.unpackVector}})(o.tileID,O),d.id,Z,se,de),o.needsHillshadePrepare=!1}const Rd=(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image0:new r.Uniform1i(m,o.u_image0),u_skirt_height:new r.Uniform1f(m,o.u_skirt_height)}),Um=(m,o)=>({u_matrix:m,u_image0:0,u_skirt_height:o}),Vm=(m,o,d,y,E,C)=>({u_proj_matrix:Float32Array.from(m),u_globe_matrix:o,u_merc_matrix:d,u_zoom_transition:y,u_merc_center:E,u_image0:0,u_grid_matrix:C?Float32Array.from(C):new Float32Array(9)});function vu(m,o){return m!=null&&o!=null&&!(!m.hasData()||!o.hasData())&&m.demTexture!=null&&o.demTexture!=null&&m.tileID.key!==o.tileID.key}const aa=new class{constructor(){this.operations={}}newMorphing(m,o,d,y,E){if(m in this.operations){const C=this.operations[m];C.to.tileID.key!==d.tileID.key&&(C.queued=d)}else this.operations[m]={startTime:y,phase:0,duration:E,from:o,to:d,queued:null}}getMorphValuesForProxy(m){if(!(m in this.operations))return null;const o=this.operations[m];return{from:o.from,to:o.to,phase:o.phase}}update(m){for(const o in this.operations){const d=this.operations[o];for(d.phase=(m-d.startTime)/d.duration;d.phase>=1||!this._validOp(d);)if(!this._nextOp(d,m)){delete this.operations[o];break}}}_nextOp(m,o){return!!m.queued&&(m.from=m.to,m.to=m.queued,m.queued=null,m.phase=0,m.startTime=o,!0)}_validOp(m){return m.from.hasData()&&m.to.hasData()}},Es={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function kd(m,o){const d=1<({u_matrix:m});function zd(m,o,d,y,E){if(E>0){const C=r.exported.now(),S=(C-m.timeAdded)/E,k=o?(C-o.timeAdded)/E:-1,O=d.getSource(),U=y.coveringZoomLevel({tileSize:O.tileSize,roundZoom:O.roundZoom}),G=!o||Math.abs(o.tileID.overscaledZ-U)>Math.abs(m.tileID.overscaledZ-U),Z=G&&m.refreshedUponExpiration?1:r.clamp(G?S:1-k,0,1);return m.refreshedUponExpiration&&S>=1&&(m.refreshedUponExpiration=!1),o?{opacity:1,mix:1-Z}:{opacity:Z,mix:0}}return{opacity:1,mix:0}}const K_=2*r.mercatorZfromAltitude(1,0)*r.GLOBE_RADIUS*Math.PI;class Cl extends r.SourceCache{constructor(o){const d={type:"raster-dem",maxzoom:o.transform.maxZoom},y=new be(Fe(),null),E=tt("mock-dem",d,y,o.style);super("mock-dem",E,!1),E.setEventedParent(this),this._sourceLoaded=!0}_loadTile(o,d){o.state="loaded",d(null)}}class Al extends r.SourceCache{constructor(o){const d=tt("proxy",{type:"geojson",maxzoom:o.transform.maxZoom},new be(Fe(),null),o.style);super("proxy",d,!1),d.setEventedParent(this),this.map=this.getSource().map=o,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(o,d,y){if(o.freezeTileCoverage)return;this.transform=o;const E=o.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((C,S)=>{if(C[S.key]="",!this._tiles[S.key]){const k=new r.Tile(S,this._source.tileSize*S.overscaleFactor(),o.tileZoom);k.state="loaded",this._tiles[S.key]=k}return C},{});for(const C in this._tiles)C in E||(this.freeFBO(C),this._tiles[C].unloadVectorData(),delete this._tiles[C])}freeFBO(o){const d=this.proxyCachedFBO[o];if(d!==void 0){const y=Object.values(d);this.renderCachePool.push(...y),delete this.proxyCachedFBO[o]}}deallocRenderCache(){this.renderCache.forEach(o=>o.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Fd extends r.OverscaledTileID{constructor(o,d,y){super(o.overscaledZ,o.wrap,o.canonical.z,o.canonical.x,o.canonical.y),this.proxyTileKey=d,this.projMatrix=y}}class Lr extends r.Elevation{constructor(o,d){super(),this.painter=o,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[y,E,C]=function(O){const U=new r.StructArrayLayout4i8,G=new r.StructArrayLayout3ui6,Z=131;U.reserve(17161),G.reserve(33800);const se=r.EXTENT/128,de=r.EXTENT+se/2,ce=de+se;for(let Le=-se;Lede||Le<0||Le>de?24575:0,Se=r.clamp(Math.round(ve),0,r.EXTENT),ze=r.clamp(Math.round(Le),0,r.EXTENT);U.emplaceBack(Se+De,ze,Se,ze)}const te=(Le,ve)=>{const De=ve*Z+Le;G.emplaceBack(De+1,De,De+Z),G.emplaceBack(De+Z,De+Z+1,De+1)};for(let Le=1;Le<129;Le++)for(let ve=1;ve<129;ve++)te(ve,Le);return[0,129].forEach(Le=>{for(let ve=0;ve<130;ve++)te(ve,Le),te(Le,ve)}),[U,G,32768]}(),S=o.context;this.gridBuffer=S.createVertexBuffer(y,r.boundsAttributes.members),this.gridIndexBuffer=S.createIndexBuffer(E),this.gridSegments=r.SegmentVector.simpleSegment(0,0,y.length,E.length),this.gridNoSkirtSegments=r.SegmentVector.simpleSegment(0,0,y.length,C),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Al(d.map),this.orthoMatrix=r.create(),r.ortho(this.orthoMatrix,0,r.EXTENT,0,r.EXTENT,0,1);const k=S.gl;this._overlapStencilMode=new r.StencilMode({func:k.GEQUAL,mask:255},0,255,k.KEEP,k.KEEP,k.REPLACE),this._previousZoom=o.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=d,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Cl(d.map)}set style(o){o.on("data",this._onStyleDataEvent.bind(this)),o.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=o,this._checkRenderCacheEfficiency()}update(o,d,y){if(o&&o.terrain){this._style!==o&&(this.style=o),this.enabled=!0;const E=o.terrain.properties;this.sourceCache=o.terrain.drapeRenderMode===0?this._mockSourceCache:o._getSourceCache(E.get("source")),this._exaggeration=E.get("exaggeration");const C=()=>{this.sourceCache.used&&r.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. 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(d,S,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,C(),this._initializing=!0),C(),d.updateElevation(!y),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(d),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(o){this._findCoveringTileCache[o]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const o=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||o.efficiency!==100&&r.warnOnce(`Terrain render cache efficiency is not optimal (${o.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer with id '${o.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(o){o.coord&&o.dataType==="source"?this._clearRenderCacheForTile(o.sourceCacheId,o.coord):o.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const o in this._style._sourceCaches)this._style._sourceCaches[o].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(o=>o.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 o=2*this.proxySourceCache.getSource().tileSize;return[o,o]}set useVertexMorphing(o){this._useVertexMorphing=o}updateTileBinding(o){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const d=this.proxySourceCache,y=this.painter.transform;this._initializing&&(this._initializing=y._centerAltitude===0&&this.getAtPointOrZero(r.MercatorCoordinate.fromLngLat(y.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const E=this.proxyCoords=d.getIds().map(O=>{const U=d.getTileByID(O).tileID;return U.projMatrix=y.calculateProjMatrix(U.toUnwrapped()),U});(function(O,U){const G=U.transform.pointCoordinate(U.transform.getCameraPoint()),Z=new r.pointGeometry(G.x,G.y);O.sort((se,de)=>{if(de.overscaledZ-se.overscaledZ)return de.overscaledZ-se.overscaledZ;const ce=new r.pointGeometry(se.canonical.x+(1<{this.proxyToSource[O.key]={}}),this.terrainTileForTile={};const S=this._style._sourceCaches;for(const O in S){const U=S[O];if(!U.used||(U!==this.sourceCache&&this.resetTileLookupCache(U.id),this._setupProxiedCoordsForOrtho(U,o[O],C),U.usedForTerrain))continue;const G=o[O];U.getSource().reparseOverscaled&&this._assignTerrainTiles(G)}this.proxiedCoords[d.id]=E.map(O=>new Fd(O,O.key,this.orthoMatrix)),this._assignTerrainTiles(E),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(C),this.renderingToTexture=!1,this._updateTimestamp=r.exported.now();const k={};this._visibleDemTiles=[];for(const O of this.proxyCoords){const U=this.terrainTileForTile[O.key];if(!U)continue;const G=U.tileID.key;G in k||(this._visibleDemTiles.push(U),k[G]=G)}}_assignTerrainTiles(o){this._initializing||o.forEach(d=>{if(this.terrainTileForTile[d.key])return;const y=this._findTileCoveringTileID(d,this.sourceCache);y&&(this.terrainTileForTile[d.key]=y)})}_prepareDEMTextures(){const o=this.painter.context,d=o.gl;for(const y in this.terrainTileForTile){const E=this.terrainTileForTile[y],C=E.dem;!C||E.demTexture&&!E.needsDEMTextureUpload||(o.activeTexture.set(d.TEXTURE1),Ld(this.painter,E,C))}}_prepareDemTileUniforms(o,d,y,E){if(!d||d.demTexture==null)return!1;const C=o.tileID.canonical,S=Math.pow(2,d.tileID.canonical.z-C.z),k=E||"";return y[`u_dem_tl${k}`]=[C.x*S%1,C.y*S%1],y[`u_dem_scale${k}`]=S,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const o=this.painter.context,d=o.gl;if(!this._emptyDepthBufferTexture){const y=new r.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new r.Texture(o,y,d.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let o=0;const d=this._visibleDemTiles.reduce((y,E)=>{if(!E.dem)return y;const C=E.dem.tree.minimums[0];return C>0&&o++,y+C},0);return o?d/o:0}_updateEmptyDEMTexture(){const o=this.painter.context,d=o.gl;o.activeTexture.set(d.TEXTURE2);const y=this._getLoadedAreaMinimum(),E=new r.RGBAImage({width:1,height:1},new Uint8Array(r.DEMData.pack(y,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let C=this._emptyDEMTexture;return C?C.update(E,{premultiply:!1}):C=this._emptyDEMTexture=new r.Texture(o,E,d.RGBA,{premultiply:!1}),C}setupElevationDraw(o,d,y){const E=this.painter.context,C=E.gl,S=(k=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:r.DEMData.getUnpackVector(k),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 k;S.u_dem_size=this.sourceCache.getSource().tileSize,S.u_exaggeration=this.exaggeration();const O=this.painter.transform,U=O.projection,G=o.tileID.canonical;S.u_tile_tl_up=U.upVector(G,0,0),S.u_tile_tr_up=U.upVector(G,r.EXTENT,0),S.u_tile_br_up=U.upVector(G,r.EXTENT,r.EXTENT),S.u_tile_bl_up=U.upVector(G,0,r.EXTENT),S.u_tile_up_scale=y&&y.useDenormalizedUpVectorScale?K_:U.upVectorScale(G,O.center.lat,O.worldSize).metersToTile;let Z=null,se=null,de=1;if(y&&y.morphing&&this._useVertexMorphing){const ce=y.morphing.srcDemTile,te=y.morphing.dstDemTile;de=y.morphing.phase,ce&&te&&(this._prepareDemTileUniforms(o,ce,S,"_prev")&&(se=ce),this._prepareDemTileUniforms(o,te,S)&&(Z=te))}if(se&&Z?(E.activeTexture.set(C.TEXTURE2),Z.demTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE,C.NEAREST),E.activeTexture.set(C.TEXTURE4),se.demTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE,C.NEAREST),S.u_dem_lerp=de):(Z=this.terrainTileForTile[o.tileID.key],E.activeTexture.set(C.TEXTURE2),(this._prepareDemTileUniforms(o,Z,S)?Z.demTexture:this.emptyDEMTexture).bind(C.NEAREST,C.CLAMP_TO_EDGE)),E.activeTexture.set(C.TEXTURE3),y&&y.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE),this._depthFBO&&(S.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(C.NEAREST,C.CLAMP_TO_EDGE),S.u_depth_size_inv=[1,1]),y&&y.useMeterToDem&&Z){const ce=(1<{if(ve===ht)return;const it=[Es[ht],"PROJECTION_GLOBE_VIEW"];kt&&it.push(Es[De]),Le=U.useProgram("globeRaster",null,it),ve=ht},ze=U.colorModeForRenderPass(),Ee=new r.DepthMode(te.LEQUAL,r.DepthMode.ReadWrite,U.depthRangeFor3D);aa.update(de);const Ue=U.transform,nt=r.calculateGlobeMercatorMatrix(Ue),lt=[r.mercatorXfromLng(Ue.center.lng),r.mercatorYfromLat(Ue.center.lat)],pt=U.globeSharedBuffers;if((De?[!1,!0]:[!1]).forEach(ht=>{ve=-1;const kt=ht?te.LINES:te.TRIANGLES;for(const it of se){const zt=Z.getTile(it),St=r.StencilMode.disabled,Jt=G.prevTerrainTileForTile[it.key],ft=G.terrainTileForTile[it.key];vu(Jt,ft)&&aa.newMorphing(it.key,Jt,ft,de,250),ce.activeTexture.set(te.TEXTURE0),zt.texture.bind(te.LINEAR,te.CLAMP_TO_EDGE);const qt=aa.getMorphValuesForProxy(it.key),gn=qt?1:0,Zt={useDenormalizedUpVectorScale:!0};qt&&r.extend$1(Zt,{morphing:{srcDemTile:qt.from,dstDemTile:qt.to,phase:r.easeCubicInOut(qt.phase)}});const Yt=Float32Array.from(Ue.globeMatrix),xn=r.globeTileLatLngCorners(it.canonical),zn=r.getGridMatrix(it.canonical,xn),dn=Vm(Ue.projMatrix,Yt,nt,r.globeToMercatorTransition(Ue.zoom),lt,zn);if(Se(gn,ht),G.setupElevationDraw(zt,Le,Zt),U.prepareDrawProgram(ce,Le,it.toUnwrapped()),pt){const[Mn,$n,vi]=ht?pt.getWirefameBuffers(U.context):pt.getGridBuffers();Le.draw(ce,kt,Ee,St,ze,r.CullFaceMode.backCCW,dn,"globe_raster",Mn,$n,vi)}}}),pt){Le=U.useProgram("globeRaster",null,["GLOBE_POLES","PROJECTION_GLOBE_VIEW"]);for(const ht of se){const{x:kt,y:it,z:zt}=ht.canonical,St=it===0,Jt=it===(1<dn.draw(ce,te.TRIANGLES,Ee,r.StencilMode.disabled,ze,r.CullFaceMode.disabled,Vm(Ue.projMatrix,xn,xn,0,lt),"globe_pole_raster",Mn,gn,Zt);G.setupElevationDraw(Yt,Le,{}),U.prepareDrawProgram(ce,Le,ht.toUnwrapped()),St&&zn(Le,ft),Jt&&(xn=r.scale(r.create(),xn,[1,-1,1]),zn(Le,qt))}}}})(E,C,S,k,O);else{const U=E.context,G=U.gl;let Z,se;const de=E.options.showTerrainWireframe?2:0,ce=(Se,ze)=>{if(se===Se)return;const Ee=[Es[Se]];ze&&Ee.push(Es[de]),Z=E.useProgram("terrainRaster",null,Ee),se=Se},te=E.colorModeForRenderPass(),Le=new r.DepthMode(G.LEQUAL,r.DepthMode.ReadWrite,E.depthRangeFor3D);aa.update(O);const ve=E.transform,De=6*Math.pow(1.5,22-ve.zoom)*C.exaggeration();(de?[!1,!0]:[!1]).forEach(Se=>{se=-1;const ze=Se?G.LINES:G.TRIANGLES,[Ee,Ue]=Se?C.getWirefameBuffer():[C.gridIndexBuffer,C.gridSegments];for(const nt of k){const lt=S.getTile(nt),pt=r.StencilMode.disabled,ht=C.prevTerrainTileForTile[nt.key],kt=C.terrainTileForTile[nt.key];vu(ht,kt)&&aa.newMorphing(nt.key,ht,kt,O,250),U.activeTexture.set(G.TEXTURE0),lt.texture.bind(G.LINEAR,G.CLAMP_TO_EDGE,G.LINEAR_MIPMAP_NEAREST);const it=aa.getMorphValuesForProxy(nt.key),zt=it?1:0;let St;it&&(St={morphing:{srcDemTile:it.from,dstDemTile:it.to,phase:r.easeCubicInOut(it.phase)}});const Jt=Um(nt.projMatrix,kd(nt.canonical,ve.renderWorldCopies)?De/10:De);ce(zt,Se),C.setupElevationDraw(lt,Z,St),E.prepareDrawProgram(U,Z,nt.toUnwrapped()),Z.draw(U,ze,Le,pt,te,r.CullFaceMode.backCCW,Jt,"terrain_raster",C.gridBuffer,Ee,Ue)}})}}(d,this,this.proxySourceCache,o,this._updateTimestamp),this.renderingToTexture=!0,o.splice(0,o.length))}renderBatch(o){if(this._drapedRenderBatches.length===0)return o+1;this.renderingToTexture=!0;const d=this.painter,y=this.painter.context,E=this.proxySourceCache,C=this.proxiedCoords[E.id],S=this._drapedRenderBatches.shift(),k=[],O=d.style.order;let U=0;for(const G of C){const Z=E.getTileByID(G.proxyTileKey),se=E.proxyCachedFBO[G.key]?E.proxyCachedFBO[G.key][o]:void 0,de=se!==void 0?E.renderCache[se]:this.pool[U++],ce=se!==void 0;if(Z.texture=de.tex,ce&&!de.dirty){k.push(Z.tileID);continue}let te;y.bindFramebuffer.set(de.fb.framebuffer),this.renderedToTile=!1,de.dirty&&(y.clear({color:r.Color.transparent,stencil:0}),de.dirty=!1);for(let Le=S.start;Le<=S.end;++Le){const ve=d.style._layers[O[Le]];if(ve.isHidden(d.transform.zoom))continue;const De=d.style._getLayerSourceCache(ve),Se=De?this.proxyToSource[G.key][De.id]:[G];if(!Se)continue;const ze=Se;y.viewport.set([0,0,de.fb.width,de.fb.height]),te!==(De?De.id:null)&&(this._setupStencil(de,Se,ve,De),te=De?De.id:null),d.renderLayer(d,De,ve,ze)}this.renderedToTile?(de.dirty=!0,k.push(Z.tileID)):ce||--U,U===5&&(U=0,this.renderToBackBuffer(k))}return this.renderToBackBuffer(k),this.renderingToTexture=!1,y.bindFramebuffer.set(null),y.viewport.set([0,0,d.width,d.height]),S.end+1}postRender(){}renderCacheEfficiency(o){const d=o.order.length;if(d===0)return{efficiency:100};let y,E=0,C=0,S=!1;for(let k=0;kd.dem).forEach(d=>{o=Math.min(o,d.dem.tree.minimums[0])}),o===0?o:(o-30)*this._exaggeration}raycast(o,d,y){if(!this._visibleDemTiles)return null;const E=this._visibleDemTiles.filter(C=>C.dem).map(C=>{const S=C.tileID,k=Math.pow(2,S.overscaledZ),{x:O,y:U}=S.canonical,G=O/k,Z=(O+1)/k,se=U/k,de=(U+1)/k;return{minx:G,miny:se,maxx:Z,maxy:de,t:C.dem.tree.raycastRoot(G,se,Z,de,o,d,y),tile:C}});E.sort((C,S)=>(C.t!==null?C.t:Number.MAX_VALUE)-(S.t!==null?S.t:Number.MAX_VALUE));for(const C of E){if(C.t==null)return null;const S=C.tile.dem.tree.raycast(C.minx,C.miny,C.maxx,C.maxy,o,d,y);if(S!=null)return S}return null}_createFBO(){const o=this.painter.context,d=o.gl,y=this.drapeBufferSize;o.activeTexture.set(d.TEXTURE0);const E=new r.Texture(o,{width:y[0],height:y[1],data:null},d.RGBA);E.bind(d.LINEAR,d.CLAMP_TO_EDGE);const C=o.createFramebuffer(y[0],y[1],!1);return C.colorAttachment.set(E.texture),C.depthAttachment=new Ar(o,C.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=o.createRenderbuffer(o.gl.DEPTH_STENCIL,y[0],y[1]),this._stencilRef=0,C.depthAttachment.set(this._sharedDepthStencil),o.clear({stencil:0})):C.depthAttachment.set(this._sharedDepthStencil),o.extTextureFilterAnisotropic&&!o.extTextureFilterAnisotropicForceOff&&d.texParameterf(d.TEXTURE_2D,o.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,o.extTextureFilterAnisotropicMax),{fb:C,tex:E,dirty:!1}}_initFBOPool(){for(;this.pool.length{const d=this._style._layers[o],y=d.isHidden(this.painter.transform.zoom),E=d.getCrossfadeParameters(),C=!!E&&E.t!==1,S=d.hasTransition();return d.type!=="custom"&&!y&&(C||S)})}_clearRasterFadeFromRenderCache(){let o=!1;for(const d in this._style._sourceCaches)if(this._style._sourceCaches[d]._source instanceof ee){o=!0;break}if(o)for(let d=0;dd.renderCachePool.length){const S=Object.values(d.proxyCachedFBO);d.proxyCachedFBO={};for(let k=0;k=0;S--){const k=y[S];if(d.getTileByID(k.key),d.proxyCachedFBO[k.key]!==void 0){const O=o[k.key],U=this.proxyToSource[k.key];let G=0;for(const Z in U){const se=U[Z],de=O[Z];if(!de||de.length!==se.length||se.some((ce,te)=>ce!==de[te]||E[Z]&&E[Z].hasOwnProperty(ce.key))){G=-1;break}++G}for(const Z in d.proxyCachedFBO[k.key])d.renderCache[d.proxyCachedFBO[k.key][Z]].dirty=G<0||G!==Object.values(O).length}}const C=[...this._drapedRenderBatches];C.sort((S,k)=>k.end-k.start-(S.end-S.start));for(const S of C)for(const k of y){if(d.proxyCachedFBO[k.key])continue;let O=d.renderCachePool.pop();O===void 0&&d.renderCache.length<50&&(O=d.renderCache.length,d.renderCache.push(this._createFBO())),O!==void 0&&(d.proxyCachedFBO[k.key]={},d.proxyCachedFBO[k.key][S.start]=O,d.renderCache[O].dirty=!0)}this._tilesDirty={}}_setupStencil(o,d,y,E){if(!E||!this._sourceTilesOverlap[E.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const C=this.painter.context,S=C.gl;if(d.length<=1)return void(this._overlapStencilType=!1);let k;if(y.isTileClipped())k=d.length,this._overlapStencilMode.test={func:S.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(d[0].overscaledZ>d[d.length-1].overscaledZ))return void(this._overlapStencilType=!1);k=1,this._overlapStencilMode.test={func:S.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+k>255&&(C.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=k,this._overlapStencilMode.ref=this._stencilRef,y.isTileClipped()&&this._renderTileClippingMasks(d,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(o){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(o.key)||0),this._overlapStencilMode):r.StencilMode.disabled}_renderTileClippingMasks(o,d){const y=this.painter,E=this.painter.context,C=E.gl;y._tileClippingMaskIDs.clear(),E.setColorMode(r.ColorMode.disabled),E.setDepthMode(r.DepthMode.disabled);const S=y.useProgram("clippingMask");for(const k of o){const O=--d;y._tileClippingMaskIDs.set(k.key,O),S.draw(E,C.TRIANGLES,r.DepthMode.disabled,new r.StencilMode({func:C.ALWAYS,mask:0},O,255,C.KEEP,C.KEEP,C.REPLACE),r.ColorMode.disabled,r.CullFaceMode.disabled,xu(k.projMatrix),"$clipping",y.tileExtentBuffer,y.quadTriangleIndexBuffer,y.tileExtentSegments)}}pointCoordinate(o){const d=this.painter.transform;if(o.x<0||o.x>d.width||o.y<0||o.y>d.height)return null;const y=[o.x,o.y,1,1];r.transformMat4$1(y,y,d.pixelMatrixInverse),r.scale$1(y,y,1/y[3]),y[0]/=d.worldSize,y[1]/=d.worldSize;const E=d._camera.position,C=r.mercatorZfromAltitude(1,d.center.lat),S=[E[0],E[1],E[2]/C,0],k=r.subtract([],y.slice(0,3),S);r.normalize(k,k);const O=this.raycast(S,k,this._exaggeration);return O!==null&&O?(r.scaleAndAdd(S,S,k,O),S[3]=S[2],S[2]*=C,S):null}drawDepth(){const o=this.painter,d=o.context,y=this.proxySourceCache,E=Math.ceil(o.width),C=Math.ceil(o.height);if(!this._depthFBO||this._depthFBO.width===E&&this._depthFBO.height===C||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const S=d.gl,k=d.createFramebuffer(E,C,!0);d.activeTexture.set(S.TEXTURE0);const O=new r.Texture(d,{width:E,height:C,data:null},S.RGBA);O.bind(S.NEAREST,S.CLAMP_TO_EDGE),k.colorAttachment.set(O.texture);const U=d.createRenderbuffer(d.gl.DEPTH_COMPONENT16,E,C);k.depthAttachment.set(U),this._depthFBO=k,this._depthTexture=O}d.bindFramebuffer.set(this._depthFBO.framebuffer),d.viewport.set([0,0,E,C]),function(S,k,O,U){if(S.transform.projection.name==="globe")return;const G=S.context,Z=G.gl;G.clear({depth:1});const se=S.useProgram("terrainDepth"),de=new r.DepthMode(Z.LESS,r.DepthMode.ReadWrite,S.depthRangeFor3D);for(const ce of U){const te=O.getTile(ce),Le=Um(ce.projMatrix,0);k.setupElevationDraw(te,se),se.draw(G,Z.TRIANGLES,de,r.StencilMode.disabled,r.ColorMode.unblended,r.CullFaceMode.backCCW,Le,"terrain_depth",k.gridBuffer,k.gridIndexBuffer,k.gridNoSkirtSegments)}}(o,this,y,this.proxyCoords)}_setupProxiedCoordsForOrtho(o,d,y){if(o.getSource()instanceof je)return this._setupProxiedCoordsForImageSource(o,d,y);this._findCoveringTileCache[o.id]=this._findCoveringTileCache[o.id]||{};const E=this.proxiedCoords[o.id]=[],C=this.proxyCoords;for(let k=0;k(G.min.x=Math.min(G.min.x,Z.x-k.x),G.min.y=Math.min(G.min.y,Z.y-k.y),G.max.x=Math.max(G.max.x,Z.x-k.x),G.max.y=Math.max(G.max.y,Z.y-k.y),G),{min:new r.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new r.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),U=(G,Z)=>{const se=G.wrap+G.canonical.x/(1<te+O.max.x||de+ceLe+O.max.y};for(let G=0;GS.key===d.tileID.key);if(C)return C}if(d.tileID.key!==o.key){const C=o.canonical.z-d.tileID.canonical.z;let S,k,O;E=r.create();const U=d.tileID.wrap-o.wrap<0?(S=r.EXTENT>>C,k=S*((d.tileID.canonical.x<=Z){const se=o.canonical.z-Z;d.getSource().reparseOverscaled?(k=Math.max(o.canonical.z+2,d.transform.tileZoom),S=new r.OverscaledTileID(k,o.wrap,Z,o.canonical.x>>se,o.canonical.y>>se)):se!==0&&(k=Z,S=new r.OverscaledTileID(k,o.wrap,Z,o.canonical.x>>se,o.canonical.y>>se))}S.key!==o.key&&(U.push(S.key),y=d.getTile(S))}const G=Z=>{U.forEach(se=>{E[se]=Z}),U.length=0};for(k-=1;k>=O&&(!y||!y.hasData());k--){y&&G(y.tileID.key);const Z=S.calculateScaledKey(k);if(y=d.getTileByID(Z),y&&y.hasData())break;const se=E[Z];if(se===null)break;se===void 0?U.push(Z):y=d.getTileByID(se)}return G(y?y.tileID.key:null),y&&y.hasData()?y:null}findDEMTileFor(o){return this.enabled?this._findTileCoveringTileID(o,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(o,d){let y=this._tilesDirty[o];y||(y=this._tilesDirty[o]={}),y[d.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const o=function(d){let y=0;const E=new r.StructArrayLayout2ui4,C=131;for(let S=1;S<129;S++){for(let k=1;k<129;k++)y=S*C+k,E.emplaceBack(y,y+1),E.emplaceBack(y,y+C),E.emplaceBack(y+1,y+C),S===128&&E.emplaceBack(y+C,y+C+1);E.emplaceBack(y+1,y+1+C)}return E}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(o),this.wireframeSegments=r.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,o.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function bu(m){const o=[];for(let d=0;d`#define ${Ee}`));const Le=te.concat(` #ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`,Tl,yu.fragmentSource,oa.fragmentSource,y.fragmentSource).join(` `),ve=te.concat(` #ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`,Tl,yu.vertexSource,oa.vertexSource,Ua.vertexSource,y.vertexSource).join(` `),De=k.createShader(k.FRAGMENT_SHADER);if(k.isContextLost())return void(this.failedToCreate=!0);k.shaderSource(De,Le),k.compileShader(De),k.attachShader(this.program,De);const Se=k.createShader(k.VERTEX_SHADER);if(k.isContextLost())return void(this.failedToCreate=!0);k.shaderSource(Se,ve),k.compileShader(Se),k.attachShader(this.program,Se),this.attributes={};const ze={};this.numAttributes=G.length;for(let Ee=0;Ee({u_dem:new r.Uniform1i(Ee,Ue.u_dem),u_dem_prev:new r.Uniform1i(Ee,Ue.u_dem_prev),u_dem_unpack:new r.Uniform4f(Ee,Ue.u_dem_unpack),u_dem_tl:new r.Uniform2f(Ee,Ue.u_dem_tl),u_dem_scale:new r.Uniform1f(Ee,Ue.u_dem_scale),u_dem_tl_prev:new r.Uniform2f(Ee,Ue.u_dem_tl_prev),u_dem_scale_prev:new r.Uniform1f(Ee,Ue.u_dem_scale_prev),u_dem_size:new r.Uniform1f(Ee,Ue.u_dem_size),u_dem_lerp:new r.Uniform1f(Ee,Ue.u_dem_lerp),u_exaggeration:new r.Uniform1f(Ee,Ue.u_exaggeration),u_depth:new r.Uniform1i(Ee,Ue.u_depth),u_depth_size_inv:new r.Uniform2f(Ee,Ue.u_depth_size_inv),u_meter_to_dem:new r.Uniform1f(Ee,Ue.u_meter_to_dem),u_label_plane_matrix_inv:new r.UniformMatrix4f(Ee,Ue.u_label_plane_matrix_inv),u_tile_tl_up:new r.Uniform3f(Ee,Ue.u_tile_tl_up),u_tile_tr_up:new r.Uniform3f(Ee,Ue.u_tile_tr_up),u_tile_br_up:new r.Uniform3f(Ee,Ue.u_tile_br_up),u_tile_bl_up:new r.Uniform3f(Ee,Ue.u_tile_bl_up),u_tile_up_scale:new r.Uniform1f(Ee,Ue.u_tile_up_scale)}))(o,ze)),S.indexOf("FOG")!==-1&&(this.fogUniforms=((Ee,Ue)=>({u_fog_matrix:new r.UniformMatrix4f(Ee,Ue.u_fog_matrix),u_fog_range:new r.Uniform2f(Ee,Ue.u_fog_range),u_fog_color:new r.Uniform4f(Ee,Ue.u_fog_color),u_fog_horizon_blend:new r.Uniform1f(Ee,Ue.u_fog_horizon_blend),u_fog_temporal_offset:new r.Uniform1f(Ee,Ue.u_fog_temporal_offset)}))(o,ze))}setTerrainUniformValues(o,d){if(!this.terrainUniforms)return;const y=this.terrainUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const E in d)y[E].set(d[E])}}setFogUniformValues(o,d){if(!this.fogUniforms)return;const y=this.fogUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const E in d)y[E].location&&y[E].set(d[E])}}draw(o,d,y,E,C,S,k,O,U,G,Z,se,de,ce,te,Le){const ve=o.gl;if(this.failedToCreate)return;o.program.set(this.program),o.setDepthMode(y),o.setStencilMode(E),o.setColorMode(C),o.setCullFace(S);for(const Se of Object.keys(this.fixedUniforms))this.fixedUniforms[Se].set(k[Se]);ce&&ce.setUniforms(o,this.binderUniforms,se,{zoom:de});const De={[ve.LINES]:2,[ve.TRIANGLES]:3,[ve.LINE_STRIP]:1}[d];for(const Se of Z.get()){const ze=Se.vaos||(Se.vaos={});(ze[O]||(ze[O]=new _u)).bind(o,this,U,ce?ce.getPaintVertexBuffers():[],G,Se.vertexOffset,te,Le),ve.drawElements(d,Se.primitiveLength*De,ve.UNSIGNED_SHORT,Se.primitiveOffset*De*2)}}}function Pl(m,o,d){const y=1/We(d,1,o.transform.tileZoom),E=Math.pow(2,d.tileID.overscaledZ),C=d.tileSize*Math.pow(2,o.transform.tileZoom)/E,S=C*(d.tileID.canonical.x+d.tileID.wrap*E),k=C*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[y,m.fromScale,m.toScale],u_fade:m.t,u_pixel_coord_upper:[S>>16,k>>16],u_pixel_coord_lower:[65535&S,65535&k]}}const Bd=r.create(),wu=(m,o,d,y,E,C,S,k,O)=>{const U=o.style.light,G=U.properties.get("position"),Z=[G.x,G.y,G.z],se=r.create$1();U.properties.get("anchor")==="viewport"&&(r.fromRotation(se,-o.transform.angle),r.transformMat3(Z,Z,se));const de=U.properties.get("color"),ce=o.transform,te={u_matrix:m,u_lightpos:Z,u_lightintensity:U.properties.get("intensity"),u_lightcolor:[de.r,de.g,de.b],u_vertical_gradient:+d,u_opacity:y,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Bd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return ce.projection.name==="globe"&&(te.u_tile_id=[E.canonical.x,E.canonical.y,1<{const Z=wu(m,o,d,y,E,k,O,U,G),se={u_height_factor:-Math.pow(2,E.overscaledZ)/S.tileSize/8};return r.extend(Z,Pl(C,o,S),se)},Tu=m=>({u_matrix:m}),Eu=(m,o,d,y)=>r.extend(Tu(m),Pl(d,o,y)),Cu=(m,o)=>({u_matrix:m,u_world:o}),Gm=(m,o,d,y,E)=>r.extend(Eu(m,o,d,y),{u_world:E}),Wm=r.create(),Cs=(m,o,d,y,E,C)=>{const S=m.transform,k=S.projection.name==="globe";let O;if(C.paint.get("circle-pitch-alignment")==="map")if(k){const G=r.globePixelsToTileUnits(S.zoom,o.canonical);O=Float32Array.from([G,0,0,G])}else O=S.calculatePixelsToTileUnitsMatrix(d);else O=new Float32Array([S.pixelsToGLUnits[0],0,0,S.pixelsToGLUnits[1]]);const U={u_camera_to_center_distance:S.cameraToCenterDistance,u_matrix:m.translatePosMatrix(o.projMatrix,d,C.paint.get("circle-translate"),C.paint.get("circle-translate-anchor")),u_device_pixel_ratio:r.exported.devicePixelRatio,u_extrude_scale:O,u_inv_rot_matrix:Wm,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return k&&(U.u_inv_rot_matrix=y,U.u_merc_center=E,U.u_tile_id=[o.canonical.x,o.canonical.y,1<{const o=[];return m.paint.get("circle-pitch-alignment")==="map"&&o.push("PITCH_WITH_MAP"),m.paint.get("circle-pitch-scale")==="map"&&o.push("SCALE_WITH_MAP"),o},Q_=(m,o,d)=>{const y=r.EXTENT/d.tileSize;return{u_matrix:m,u_camera_to_center_distance:o.cameraToCenterDistance,u_extrude_scale:[o.pixelsToGLUnits[0]/y,o.pixelsToGLUnits[1]/y]}},jm=(m,o,d=1)=>({u_matrix:m,u_color:o,u_overlay:0,u_overlay_scale:d}),ev=r.create(),tv=(m,o,d,y,E,C,S)=>{const k=m.transform,O=k.projection.name==="globe",U=O?r.globePixelsToTileUnits(k.zoom,o.canonical):We(d,1,C),G={u_matrix:o.projMatrix,u_extrude_scale:U,u_intensity:S,u_inv_rot_matrix:ev,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return O&&(G.u_inv_rot_matrix=y,G.u_merc_center=E,G.u_tile_id=[o.canonical.x,o.canonical.y,1<{const k=m.transform,O=k.calculatePixelsToTileUnitsMatrix(o),U={u_matrix:Va(m,o,d,E),u_pixels_to_tile_units:O,u_device_pixel_ratio:S,u_units_to_pixels:[1/k.pixelsToGLUnits[0],1/k.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:C,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Nd(d)){const G=Au(o,m.transform);U.u_texsize=o.lineAtlasTexture.size,U.u_scale=[G,y.fromScale,y.toScale],U.u_mix=y.t}return U},Od=(m,o,d,y,E,C)=>{const S=m.transform,k=Au(o,S);return{u_matrix:Va(m,o,d,E),u_texsize:o.imageAtlasTexture.size,u_pixels_to_tile_units:S.calculatePixelsToTileUnitsMatrix(o),u_device_pixel_ratio:C,u_image:0,u_scale:[k,y.fromScale,y.toScale],u_fade:y.t,u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Au(m,o){return 1/We(m,1,o.tileZoom)}function Va(m,o,d,y){return m.translatePosMatrix(y||o.tileID.projMatrix,o,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}function Nd(m){const o=m.paint.get("line-dasharray").value;return o.value||o.kind!=="constant"}const Hm=(m,o,d,y,E,C)=>{return{u_matrix:m,u_tl_parent:o,u_scale_parent:d,u_fade_t:y.mix,u_opacity:y.opacity*E.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:E.paint.get("raster-brightness-min"),u_brightness_high:E.paint.get("raster-brightness-max"),u_saturation_factor:(k=E.paint.get("raster-saturation"),k>0?1-1/(1.001-k):-k),u_contrast_factor:(S=E.paint.get("raster-contrast"),S>0?1/(1-S):1+S),u_spin_weights:Ud(E.paint.get("raster-hue-rotate")),u_perspective_transform:C};var S,k};function Ud(m){m*=Math.PI/180;const o=Math.sin(m),d=Math.cos(m);return[(2*d+1)/3,(-Math.sqrt(3)*o-d+1)/3,(Math.sqrt(3)*o-d+1)/3]}const sa=r.create(),Vd=(m,o,d,y,E,C,S,k,O,U,G,Z,se,de)=>{const ce=E.transform,te={u_is_size_zoom_constant:+(m==="constant"||m==="source"),u_is_size_feature_constant:+(m==="constant"||m==="camera"),u_size_t:o?o.uSizeT:0,u_size:o?o.uSize:0,u_camera_to_center_distance:ce.cameraToCenterDistance,u_rotate_symbol:+d,u_aspect_ratio:ce.width/ce.height,u_fade_change:E.options.fadeDuration?E.symbolFadeChange:1,u_matrix:C,u_label_plane_matrix:S,u_coord_matrix:k,u_is_text:+O,u_pitch_with_map:+y,u_texsize:U,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:sa,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:sa};return ce.projection.name==="globe"&&(te.u_tile_id=[G.canonical.x,G.canonical.y,1<{const{cameraToCenterDistance:te,_pitch:Le}=E.transform;return r.extend(Vd(m,o,d,y,E,C,S,k,O,U,Z,se,de,ce),{u_gamma_scale:y?te*Math.cos(E.terrain?0:Le):1,u_device_pixel_ratio:r.exported.devicePixelRatio,u_is_halo:+G})},As=(m,o,d,y,E,C,S,k,O,U,G,Z,se,de)=>r.extend(Ga(m,o,d,y,E,C,S,k,!0,O,!0,G,Z,se,de),{u_texsize_icon:U,u_texture_icon:1}),$m=(m,o,d)=>({u_matrix:m,u_opacity:o,u_color:d}),Gd=(m,o,d,y,E,C)=>r.extend(function(S,k,O,U){const G=O.imageManager.getPattern(S.from.toString()),Z=O.imageManager.getPattern(S.to.toString()),{width:se,height:de}=O.imageManager.getPixelSize(),ce=Math.pow(2,U.tileID.overscaledZ),te=U.tileSize*Math.pow(2,O.transform.tileZoom)/ce,Le=te*(U.tileID.canonical.x+U.tileID.wrap*ce),ve=te*U.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:G.tl,u_pattern_br_a:G.br,u_pattern_tl_b:Z.tl,u_pattern_br_b:Z.br,u_texsize:[se,de],u_mix:k.t,u_pattern_size_a:G.displaySize,u_pattern_size_b:Z.displaySize,u_scale_a:k.fromScale,u_scale_b:k.toScale,u_tile_units_to_pixels:1/We(U,1,O.transform.tileZoom),u_pixel_coord_upper:[Le>>16,ve>>16],u_pixel_coord_lower:[65535&Le,65535&ve]}}(y,C,d,E),{u_matrix:m,u_opacity:o}),Qn={fillExtrusion:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_lightpos:new r.Uniform3f(m,o.u_lightpos),u_lightintensity:new r.Uniform1f(m,o.u_lightintensity),u_lightcolor:new r.Uniform3f(m,o.u_lightcolor),u_vertical_gradient:new r.Uniform1f(m,o.u_vertical_gradient),u_opacity:new r.Uniform1f(m,o.u_opacity),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_up_dir:new r.Uniform3f(m,o.u_up_dir),u_height_lift:new r.Uniform1f(m,o.u_height_lift)}),fillExtrusionPattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_lightpos:new r.Uniform3f(m,o.u_lightpos),u_lightintensity:new r.Uniform1f(m,o.u_lightintensity),u_lightcolor:new r.Uniform3f(m,o.u_lightcolor),u_vertical_gradient:new r.Uniform1f(m,o.u_vertical_gradient),u_height_factor:new r.Uniform1f(m,o.u_height_factor),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_up_dir:new r.Uniform3f(m,o.u_up_dir),u_height_lift:new r.Uniform1f(m,o.u_height_lift),u_image:new r.Uniform1i(m,o.u_image),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade),u_opacity:new r.Uniform1f(m,o.u_opacity)}),fill:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix)}),fillPattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image:new r.Uniform1i(m,o.u_image),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade)}),fillOutline:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_world:new r.Uniform2f(m,o.u_world)}),fillOutlinePattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_world:new r.Uniform2f(m,o.u_world),u_image:new r.Uniform1i(m,o.u_image),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade)}),circle:(m,o)=>({u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_extrude_scale:new r.UniformMatrix2f(m,o.u_extrude_scale),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_up_dir:new r.Uniform3f(m,o.u_up_dir)}),collisionBox:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_extrude_scale:new r.Uniform2f(m,o.u_extrude_scale)}),collisionCircle:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_inv_matrix:new r.UniformMatrix4f(m,o.u_inv_matrix),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_viewport_size:new r.Uniform2f(m,o.u_viewport_size)}),debug:(m,o)=>({u_color:new r.UniformColor(m,o.u_color),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_overlay:new r.Uniform1i(m,o.u_overlay),u_overlay_scale:new r.Uniform1f(m,o.u_overlay_scale)}),clippingMask:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix)}),heatmap:(m,o)=>({u_extrude_scale:new r.Uniform1f(m,o.u_extrude_scale),u_intensity:new r.Uniform1f(m,o.u_intensity),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_up_dir:new r.Uniform3f(m,o.u_up_dir)}),heatmapTexture:(m,o)=>({u_image:new r.Uniform1i(m,o.u_image),u_color_ramp:new r.Uniform1i(m,o.u_color_ramp),u_opacity:new r.Uniform1f(m,o.u_opacity)}),hillshade:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image:new r.Uniform1i(m,o.u_image),u_latrange:new r.Uniform2f(m,o.u_latrange),u_light:new r.Uniform2f(m,o.u_light),u_shadow:new r.UniformColor(m,o.u_shadow),u_highlight:new r.UniformColor(m,o.u_highlight),u_accent:new r.UniformColor(m,o.u_accent)}),hillshadePrepare:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_image:new r.Uniform1i(m,o.u_image),u_dimension:new r.Uniform2f(m,o.u_dimension),u_zoom:new r.Uniform1f(m,o.u_zoom),u_unpack:new r.Uniform4f(m,o.u_unpack)}),line:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_pixels_to_tile_units:new r.UniformMatrix2f(m,o.u_pixels_to_tile_units),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_units_to_pixels:new r.Uniform2f(m,o.u_units_to_pixels),u_dash_image:new r.Uniform1i(m,o.u_dash_image),u_gradient_image:new r.Uniform1i(m,o.u_gradient_image),u_image_height:new r.Uniform1f(m,o.u_image_height),u_texsize:new r.Uniform2f(m,o.u_texsize),u_scale:new r.Uniform3f(m,o.u_scale),u_mix:new r.Uniform1f(m,o.u_mix),u_alpha_discard_threshold:new r.Uniform1f(m,o.u_alpha_discard_threshold)}),linePattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_texsize:new r.Uniform2f(m,o.u_texsize),u_pixels_to_tile_units:new r.UniformMatrix2f(m,o.u_pixels_to_tile_units),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_image:new r.Uniform1i(m,o.u_image),u_units_to_pixels:new r.Uniform2f(m,o.u_units_to_pixels),u_scale:new r.Uniform3f(m,o.u_scale),u_fade:new r.Uniform1f(m,o.u_fade),u_alpha_discard_threshold:new r.Uniform1f(m,o.u_alpha_discard_threshold)}),raster:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_tl_parent:new r.Uniform2f(m,o.u_tl_parent),u_scale_parent:new r.Uniform1f(m,o.u_scale_parent),u_fade_t:new r.Uniform1f(m,o.u_fade_t),u_opacity:new r.Uniform1f(m,o.u_opacity),u_image0:new r.Uniform1i(m,o.u_image0),u_image1:new r.Uniform1i(m,o.u_image1),u_brightness_low:new r.Uniform1f(m,o.u_brightness_low),u_brightness_high:new r.Uniform1f(m,o.u_brightness_high),u_saturation_factor:new r.Uniform1f(m,o.u_saturation_factor),u_contrast_factor:new r.Uniform1f(m,o.u_contrast_factor),u_spin_weights:new r.Uniform3f(m,o.u_spin_weights),u_perspective_transform:new r.Uniform2f(m,o.u_perspective_transform)}),symbolIcon:(m,o)=>({u_is_size_zoom_constant:new r.Uniform1i(m,o.u_is_size_zoom_constant),u_is_size_feature_constant:new r.Uniform1i(m,o.u_is_size_feature_constant),u_size_t:new r.Uniform1f(m,o.u_size_t),u_size:new r.Uniform1f(m,o.u_size),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_rotate_symbol:new r.Uniform1i(m,o.u_rotate_symbol),u_aspect_ratio:new r.Uniform1f(m,o.u_aspect_ratio),u_fade_change:new r.Uniform1f(m,o.u_fade_change),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_label_plane_matrix:new r.UniformMatrix4f(m,o.u_label_plane_matrix),u_coord_matrix:new r.UniformMatrix4f(m,o.u_coord_matrix),u_is_text:new r.Uniform1i(m,o.u_is_text),u_pitch_with_map:new r.Uniform1i(m,o.u_pitch_with_map),u_texsize:new r.Uniform2f(m,o.u_texsize),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_camera_forward:new r.Uniform3f(m,o.u_camera_forward),u_tile_matrix:new r.UniformMatrix4f(m,o.u_tile_matrix),u_ecef_origin:new r.Uniform3f(m,o.u_ecef_origin),u_texture:new r.Uniform1i(m,o.u_texture)}),symbolSDF:(m,o)=>({u_is_size_zoom_constant:new r.Uniform1i(m,o.u_is_size_zoom_constant),u_is_size_feature_constant:new r.Uniform1i(m,o.u_is_size_feature_constant),u_size_t:new r.Uniform1f(m,o.u_size_t),u_size:new r.Uniform1f(m,o.u_size),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_rotate_symbol:new r.Uniform1i(m,o.u_rotate_symbol),u_aspect_ratio:new r.Uniform1f(m,o.u_aspect_ratio),u_fade_change:new r.Uniform1f(m,o.u_fade_change),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_label_plane_matrix:new r.UniformMatrix4f(m,o.u_label_plane_matrix),u_coord_matrix:new r.UniformMatrix4f(m,o.u_coord_matrix),u_is_text:new r.Uniform1i(m,o.u_is_text),u_pitch_with_map:new r.Uniform1i(m,o.u_pitch_with_map),u_texsize:new r.Uniform2f(m,o.u_texsize),u_texture:new r.Uniform1i(m,o.u_texture),u_gamma_scale:new r.Uniform1f(m,o.u_gamma_scale),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_tile_id:new r.Uniform3f(m,o.u_tile_id),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_inv_rot_matrix:new r.UniformMatrix4f(m,o.u_inv_rot_matrix),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_camera_forward:new r.Uniform3f(m,o.u_camera_forward),u_tile_matrix:new r.UniformMatrix4f(m,o.u_tile_matrix),u_ecef_origin:new r.Uniform3f(m,o.u_ecef_origin),u_is_halo:new r.Uniform1i(m,o.u_is_halo)}),symbolTextAndIcon:(m,o)=>({u_is_size_zoom_constant:new r.Uniform1i(m,o.u_is_size_zoom_constant),u_is_size_feature_constant:new r.Uniform1i(m,o.u_is_size_feature_constant),u_size_t:new r.Uniform1f(m,o.u_size_t),u_size:new r.Uniform1f(m,o.u_size),u_camera_to_center_distance:new r.Uniform1f(m,o.u_camera_to_center_distance),u_rotate_symbol:new r.Uniform1i(m,o.u_rotate_symbol),u_aspect_ratio:new r.Uniform1f(m,o.u_aspect_ratio),u_fade_change:new r.Uniform1f(m,o.u_fade_change),u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_label_plane_matrix:new r.UniformMatrix4f(m,o.u_label_plane_matrix),u_coord_matrix:new r.UniformMatrix4f(m,o.u_coord_matrix),u_is_text:new r.Uniform1i(m,o.u_is_text),u_pitch_with_map:new r.Uniform1i(m,o.u_pitch_with_map),u_texsize:new r.Uniform2f(m,o.u_texsize),u_texsize_icon:new r.Uniform2f(m,o.u_texsize_icon),u_texture:new r.Uniform1i(m,o.u_texture),u_texture_icon:new r.Uniform1i(m,o.u_texture_icon),u_gamma_scale:new r.Uniform1f(m,o.u_gamma_scale),u_device_pixel_ratio:new r.Uniform1f(m,o.u_device_pixel_ratio),u_is_halo:new r.Uniform1i(m,o.u_is_halo)}),background:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_opacity:new r.Uniform1f(m,o.u_opacity),u_color:new r.UniformColor(m,o.u_color)}),backgroundPattern:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_opacity:new r.Uniform1f(m,o.u_opacity),u_image:new r.Uniform1i(m,o.u_image),u_pattern_tl_a:new r.Uniform2f(m,o.u_pattern_tl_a),u_pattern_br_a:new r.Uniform2f(m,o.u_pattern_br_a),u_pattern_tl_b:new r.Uniform2f(m,o.u_pattern_tl_b),u_pattern_br_b:new r.Uniform2f(m,o.u_pattern_br_b),u_texsize:new r.Uniform2f(m,o.u_texsize),u_mix:new r.Uniform1f(m,o.u_mix),u_pattern_size_a:new r.Uniform2f(m,o.u_pattern_size_a),u_pattern_size_b:new r.Uniform2f(m,o.u_pattern_size_b),u_scale_a:new r.Uniform1f(m,o.u_scale_a),u_scale_b:new r.Uniform1f(m,o.u_scale_b),u_pixel_coord_upper:new r.Uniform2f(m,o.u_pixel_coord_upper),u_pixel_coord_lower:new r.Uniform2f(m,o.u_pixel_coord_lower),u_tile_units_to_pixels:new r.Uniform1f(m,o.u_tile_units_to_pixels)}),terrainRaster:Rd,terrainDepth:Rd,skybox:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_sun_direction:new r.Uniform3f(m,o.u_sun_direction),u_cubemap:new r.Uniform1i(m,o.u_cubemap),u_opacity:new r.Uniform1f(m,o.u_opacity),u_temporal_offset:new r.Uniform1f(m,o.u_temporal_offset)}),skyboxGradient:(m,o)=>({u_matrix:new r.UniformMatrix4f(m,o.u_matrix),u_color_ramp:new r.Uniform1i(m,o.u_color_ramp),u_center_direction:new r.Uniform3f(m,o.u_center_direction),u_radius:new r.Uniform1f(m,o.u_radius),u_opacity:new r.Uniform1f(m,o.u_opacity),u_temporal_offset:new r.Uniform1f(m,o.u_temporal_offset)}),skyboxCapture:(m,o)=>({u_matrix_3f:new r.UniformMatrix3f(m,o.u_matrix_3f),u_sun_direction:new r.Uniform3f(m,o.u_sun_direction),u_sun_intensity:new r.Uniform1f(m,o.u_sun_intensity),u_color_tint_r:new r.Uniform4f(m,o.u_color_tint_r),u_color_tint_m:new r.Uniform4f(m,o.u_color_tint_m),u_luminance:new r.Uniform1f(m,o.u_luminance)}),globeRaster:(m,o)=>({u_proj_matrix:new r.UniformMatrix4f(m,o.u_proj_matrix),u_globe_matrix:new r.UniformMatrix4f(m,o.u_globe_matrix),u_merc_matrix:new r.UniformMatrix4f(m,o.u_merc_matrix),u_zoom_transition:new r.Uniform1f(m,o.u_zoom_transition),u_merc_center:new r.Uniform2f(m,o.u_merc_center),u_image0:new r.Uniform1i(m,o.u_image0),u_grid_matrix:new r.UniformMatrix3f(m,o.u_grid_matrix)}),globeAtmosphere:(m,o)=>({u_frustum_tl:new r.Uniform3f(m,o.u_frustum_tl),u_frustum_tr:new r.Uniform3f(m,o.u_frustum_tr),u_frustum_br:new r.Uniform3f(m,o.u_frustum_br),u_frustum_bl:new r.Uniform3f(m,o.u_frustum_bl),u_globe_pos:new r.Uniform3f(m,o.u_globe_pos),u_globe_radius:new r.Uniform1f(m,o.u_globe_radius),u_opacity:new r.Uniform1f(m,o.u_opacity),u_fadeout_range:new r.Uniform1f(m,o.u_fadeout_range),u_start_color:new r.Uniform3f(m,o.u_start_color),u_end_color:new r.Uniform3f(m,o.u_end_color)})};let Wa;function qm(m,o,d,y,E,C,S){const k=m.context,O=k.gl,U=m.useProgram("collisionBox"),G=[];let Z=0,se=0;for(let Se=0;Se0){const ht=r.create(),kt=nt;r.mul(ht,Ue.placementInvProjMatrix,m.transform.glCoordMatrix),r.mul(ht,ht,Ue.placementViewportMatrix),G.push({circleArray:pt,circleOffset:se,transform:kt,invTransform:ht}),Z+=pt.length/4,se=Z}lt&&(m.terrain&&m.terrain.setupElevationDraw(Ee,U),U.draw(k,O.LINES,r.DepthMode.disabled,r.StencilMode.disabled,m.colorModeForRenderPass(),r.CullFaceMode.disabled,Q_(nt,m.transform,Ee),d.id,lt.layoutVertexBuffer,lt.indexBuffer,lt.segments,null,m.transform.zoom,null,lt.collisionVertexBuffer,lt.collisionVertexBufferExt))}if(!S||!G.length)return;const de=m.useProgram("collisionCircle"),ce=new r.StructArrayLayout2f1f2i16;ce.resize(4*Z),ce._trim();let te=0;for(const Se of G)for(let ze=0;ze=0&&(te[ze.associatedIconIndex]={shiftedAnchor:Zt,angle:Yt})}else Fi(ze.numGlyphs,de)}if(G){ce.clear();const Se=m.icon.placedSymbolArray;for(let ze=0;ze[0,0,0];ko(St,it.projMatrix,m,E,ir,mo,Le,U,Ha,it)}const Vo=ve||E&&nt||pa,bi=m.translatePosMatrix(it.projMatrix,zt,C,S),Ti=Vo?Wd:ir,Yn=m.translatePosMatrix(mo,zt,C,S,!0),Si=ce.projection.createInversionMatrix(ce,it.canonical),zr=Vo?kt.concat(["PROJECTED_POS_ON_VIEWPORT"]):kt,xi=qt&&d.paint.get(E?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Xr;Xr=qt?St.iconsInText?As(gn.kind,Yt,De,Le,m,bi,Ti,Yn,xn,$n,it,pt,Ue,Si):Ga(gn.kind,Yt,De,Le,m,bi,Ti,Yn,E,xn,!0,it,pt,Ue,Si):Vd(gn.kind,Yt,De,Le,m,bi,Ti,Yn,E,xn,it,pt,Ue,Si);const $l={program:m.useProgram(rv(qt,E,St),ft,zr),buffers:Jt,uniformValues:Xr,atlasTexture:zn,atlasTextureIcon:vi,atlasInterpolation:dn,atlasInterpolationIcon:Mn,isSDF:qt,hasHalo:xi,tile:zt,labelPlaneMatrixInv:kr};if(Se&&St.canOverlap){ze=!0;const Fr=Jt.segments.get();for(const Ha of Fr)ht.push({segments:new r.SegmentVector([Ha]),sortKey:Ha.sortKey,state:$l})}else ht.push({segments:Jt.segments,sortKey:0,state:$l})}ze&&ht.sort((it,zt)=>it.sortKey-zt.sortKey);for(const it of ht){const zt=it.state;if(m.terrain&&m.terrain.setupElevationDraw(zt.tile,zt.program,{useDepthForOcclusion:!lt,labelPlaneMatrixInv:zt.labelPlaneMatrixInv}),se.activeTexture.set(de.TEXTURE0),zt.atlasTexture.bind(zt.atlasInterpolation,de.CLAMP_TO_EDGE),zt.atlasTextureIcon&&(se.activeTexture.set(de.TEXTURE1),zt.atlasTextureIcon&&zt.atlasTextureIcon.bind(zt.atlasInterpolationIcon,de.CLAMP_TO_EDGE)),zt.isSDF){const St=zt.uniformValues;zt.hasHalo&&(St.u_is_halo=1,Xm(zt.buffers,it.segments,d,m,zt.program,Ee,G,Z,St)),St.u_is_halo=0}Xm(zt.buffers,it.segments,d,m,zt.program,Ee,G,Z,zt.uniformValues)}}function Xm(m,o,d,y,E,C,S,k,O){const U=y.context;E.draw(U,U.gl.TRIANGLES,C,S,k,r.CullFaceMode.disabled,O,d.id,m.layoutVertexBuffer,m.indexBuffer,o,d.paint,y.transform.zoom,m.programConfigurations.get(d.id),m.dynamicLayoutVertexBuffer,m.opacityVertexBuffer)}function Du(m,o,d,y,E,C,S){const k=m.context.gl,O=d.paint.get("fill-pattern"),U=O&&O.constantOr(1),G=d.getCrossfadeParameters();let Z,se,de,ce,te;S?(se=U&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",Z=k.LINES):(se=U?"fillPattern":"fill",Z=k.TRIANGLES);for(const Le of y){const ve=o.getTile(Le);if(U&&!ve.patternsLoaded())continue;const De=ve.getBucket(d);if(!De)continue;m.prepareDrawTile();const Se=De.programConfigurations.get(d.id),ze=m.useProgram(se,Se);U&&(m.context.activeTexture.set(k.TEXTURE0),ve.imageAtlasTexture.bind(k.LINEAR,k.CLAMP_TO_EDGE),Se.updatePaintBuffers(G));const Ee=O.constantOr(null);if(Ee&&ve.imageAtlas){const nt=ve.imageAtlas,lt=nt.patternPositions[Ee.to.toString()],pt=nt.patternPositions[Ee.from.toString()];lt&&pt&&Se.setConstantPatternPositions(lt,pt)}const Ue=m.translatePosMatrix(Le.projMatrix,ve,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(S){ce=De.indexBuffer2,te=De.segments2;const nt=m.terrain&&m.terrain.renderingToTexture?m.terrain.drapeBufferSize:[k.drawingBufferWidth,k.drawingBufferHeight];de=se==="fillOutlinePattern"&&U?Gm(Ue,m,G,ve,nt):Cu(Ue,nt)}else ce=De.indexBuffer,te=De.segments,de=U?Eu(Ue,m,G,ve):Tu(Ue);m.prepareDrawProgram(m.context,ze,Le.toUnwrapped()),ze.draw(m.context,Z,E,m.stencilModeForClipping(Le),C,r.CullFaceMode.disabled,de,d.id,De.layoutVertexBuffer,ce,te,d.paint,m.transform.zoom,Se)}}function Ds(m,o,d,y,E,C,S){const k=m.context,O=k.gl,U=m.transform,G=d.paint.get("fill-extrusion-pattern"),Z=G.constantOr(1),se=d.getCrossfadeParameters(),de=d.paint.get("fill-extrusion-opacity"),ce=function(Se){if(Se.projection.name!=="globe")return 0;const ze=Math.PI/32,Ee=Math.tan(ze),Ue=r.earthRadius;return Ue*Math.sqrt(1+2*Ee*Ee)-Ue}(U),te=U.projection.name==="globe",Le=te?r.globeToMercatorTransition(U.zoom):0,ve=[r.mercatorXfromLng(U.center.lng),r.mercatorYfromLat(U.center.lat)],De=[];te&&De.push("PROJECTION_GLOBE_VIEW");for(const Se of y){const ze=o.getTile(Se),Ee=ze.getBucket(d);if(!Ee||Ee.projection!==U.projection.name)continue;const Ue=Ee.programConfigurations.get(d.id),nt=m.useProgram(Z?"fillExtrusionPattern":"fillExtrusion",Ue,De);if(m.terrain){const zt=m.terrain;if(m.style.terrainSetForDrapingOnly())zt.setupElevationDraw(ze,nt,{useMeterToDem:!0});else{if(!Ee.enableTerrain)continue;if(zt.setupElevationDraw(ze,nt,{useMeterToDem:!0}),Ll(k,o,Se,Ee,d,zt),!Ee.centroidVertexBuffer){const St=nt.attributes.a_centroid_pos;St!==void 0&&O.vertexAttrib2f(St,0,0)}}}Z&&(m.context.activeTexture.set(O.TEXTURE0),ze.imageAtlasTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),Ue.updatePaintBuffers(se));const lt=G.constantOr(null);if(lt&&ze.imageAtlas){const zt=ze.imageAtlas,St=zt.patternPositions[lt.to.toString()],Jt=zt.patternPositions[lt.from.toString()];St&&Jt&&Ue.setConstantPatternPositions(St,Jt)}const pt=m.translatePosMatrix(Se.projMatrix,ze,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),ht=U.projection.createInversionMatrix(U,Se.canonical),kt=d.paint.get("fill-extrusion-vertical-gradient"),it=Z?Mu(pt,m,kt,de,Se,se,ze,ce,Le,ve,ht):wu(pt,m,kt,de,Se,ce,Le,ve,ht);m.prepareDrawProgram(k,nt,Se.toUnwrapped()),nt.draw(k,k.gl.TRIANGLES,E,C,S,r.CullFaceMode.backCCW,it,d.id,Ee.layoutVertexBuffer,Ee.indexBuffer,Ee.segments,d.paint,m.transform.zoom,Ue,m.terrain?Ee.centroidVertexBuffer:null,te?Ee.layoutVertexExtBuffer:null)}}function Ll(m,o,d,y,E,C){const S=[ve=>{let De=ve.canonical.x-1,Se=ve.wrap;return De<0&&(De=(1<{let De=ve.canonical.x+1,Se=ve.wrap;return De===1<new r.OverscaledTileID(ve.overscaledZ,ve.wrap,ve.canonical.z,ve.canonical.x,(ve.canonical.y===0?1<new r.OverscaledTileID(ve.overscaledZ,ve.wrap,ve.canonical.z,ve.canonical.x,ve.canonical.y===(1<{const De=o.getSource().minzoom,Se=Ee=>{const Ue=o.getTileByID(Ee);if(Ue&&Ue.hasData())return Ue.getBucket(E)},ze=[0,-1,1];for(const Ee of ze){if(ve.overscaledZ+Ee(O[0]=Math.min(ve.min.y,De.min.y),O[1]=Math.max(ve.max.y,De.max.y),O[2]=r.EXTENT-De.min.x>ve.max.x?De.min.x-r.EXTENT:ve.max.x,O),G=(ve,De)=>(O[0]=Math.min(ve.min.x,De.min.x),O[1]=Math.max(ve.max.x,De.max.x),O[2]=r.EXTENT-De.min.y>ve.max.y?De.min.y-r.EXTENT:ve.max.y,O),Z=[(ve,De)=>U(ve,De),(ve,De)=>U(De,ve),(ve,De)=>G(ve,De),(ve,De)=>G(De,ve)],se=new r.pointGeometry(0,0);let de,ce,te;const Le=(ve,De,Se,ze,Ee)=>{const Ue=[[ze?Se:ve,ze?ve:Se,0],[ze?Se:De,ze?De:Se,0]],nt=Ee<0?r.EXTENT+Ee:Ee,lt=[ze?nt:(ve+De)/2,ze?(ve+De)/2:nt,0];return Se===0&&Ee<0||Se!==0&&Ee>0?C.getForTilePoints(te,[lt],!0,ce):Ue.push(lt),C.getForTilePoints(d,Ue,!0,de),Math.max(Ue[0][2],Ue[1][2],lt[2])/C.exaggeration()};for(let ve=0;ve<4;ve++){const De=(ve<2?1:5)-ve,Se=y.borders[ve];if(Se.length===0)continue;const ze=te=S[ve](d),Ee=k(ze);if(!(Ee&&Ee instanceof r.FillExtrusionBucket&&Ee.enableTerrain)||y.borderDoneWithNeighborZ[ve]===Ee.canonical.z&&Ee.borderDoneWithNeighborZ[De]===y.canonical.z||(ce=C.findDEMTileFor(ze),!ce||!ce.dem))continue;if(!de){const pt=C.findDEMTileFor(d);if(!pt||!pt.dem)return;de=pt}const Ue=Ee.borders[De];let nt=0;const lt=Ee.borderDoneWithNeighborZ[De]!==y.canonical.z;if(y.canonical.z===Ee.canonical.z){for(let pt=0;ptkt[0]+3));)lt&&Ee.encodeCentroid(void 0,it,!1),nt++;if(it&&ntkt[1]-3)&&(St++,++nt!==Ue.length);)it=Ee.featuresOnBorder[Ue[nt]];if(it=Ee.featuresOnBorder[Ue[zt]],ht.intersectsCount()>1||it.intersectsCount()>1||St!==1){St!==1&&(nt=zt),y.encodeCentroid(void 0,ht,!1),lt&&Ee.encodeCentroid(void 0,it,!1);continue}const Jt=Z[ve](ht,it),ft=ve%2?r.EXTENT-1:0;se.x=Le(Jt[0],Math.min(r.EXTENT-1,Jt[1]),ft,ve<2,Jt[2]),se.y=0,y.encodeCentroid(se,ht,!1),lt&&Ee.encodeCentroid(se,it,!1)}else y.encodeCentroid(void 0,ht,!1)}y.borderDoneWithNeighborZ[ve]=Ee.canonical.z,y.needsCentroidUpdate=!0,lt&&(Ee.borderDoneWithNeighborZ[De]=y.canonical.z,Ee.needsCentroidUpdate=!0)}else{for(const pt of Se)y.encodeCentroid(void 0,y.featuresOnBorder[pt],!1);if(lt){for(const pt of Ue)Ee.encodeCentroid(void 0,Ee.featuresOnBorder[pt],!1);Ee.borderDoneWithNeighborZ[De]=y.canonical.z,Ee.needsCentroidUpdate=!0}y.borderDoneWithNeighborZ[ve]=Ee.canonical.z,y.needsCentroidUpdate=!0}}(y.needsCentroidUpdate||!y.centroidVertexBuffer&&y.centroidVertexArray.length!==0)&&y.uploadCentroid(m)}const Hd=new r.Color(1,0,0,1),$d=new r.Color(0,1,0,1),Zm=new r.Color(0,0,1,1),Pu=new r.Color(1,0,1,1),Su=new r.Color(0,1,1,1);function jt(m,o,d,y){Il(m,0,o+d/2,m.transform.width,d,y)}function $r(m,o,d,y){Il(m,o-d/2,0,d,m.transform.height,y)}function Il(m,o,d,y,E,C){const S=m.context,k=S.gl;k.enable(k.SCISSOR_TEST),k.scissor(o*r.exported.devicePixelRatio,d*r.exported.devicePixelRatio,y*r.exported.devicePixelRatio,E*r.exported.devicePixelRatio),S.clear({color:C}),k.disable(k.SCISSOR_TEST)}function Ym(m,o,d){const y=m.context,E=y.gl,C=m.transform.projection.name==="globe",S=d.projMatrix,k=m.useProgram("debug",null,C?["PROJECTION_GLOBE_VIEW"]:null),O=o.getTileByID(d.key);m.terrain&&m.terrain.setupElevationDraw(O,k);const U=r.DepthMode.disabled,G=r.StencilMode.disabled,Z=m.colorModeForRenderPass(),se="$debug";y.activeTexture.set(E.TEXTURE0),m.emptyTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),C?O._makeGlobeTileDebugBuffers(m.context,m.transform.projection):O._makeDebugTileBoundsBuffers(m.context,m.transform.projection);const de=O._tileDebugBuffer||m.debugBuffer,ce=O._tileDebugIndexBuffer||m.debugIndexBuffer,te=O._tileDebugSegments||m.debugSegments;k.draw(y,E.LINE_STRIP,U,G,Z,r.CullFaceMode.disabled,jm(S,r.Color.red),se,de,ce,te,null,null,null,O._globeTileDebugBorderBuffer);const Le=O.latestRawTileData,ve=Math.floor((Le&&Le.byteLength||0)/1024),De=o.getTile(d).tileSize,Se=512/Math.min(De,512)*(d.overscaledZ/m.transform.zoom)*.5;let ze=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(ze+=` => ${d.overscaledZ}`),function(lt,pt){lt.initDebugOverlayCanvas();const ht=lt.debugOverlayCanvas,kt=lt.context.gl,it=lt.debugOverlayCanvas.getContext("2d");it.clearRect(0,0,ht.width,ht.height),it.shadowColor="white",it.shadowBlur=2,it.lineWidth=1.5,it.strokeStyle="white",it.textBaseline="top",it.font="bold 36px Open Sans, sans-serif",it.fillText(pt,5,5),it.strokeText(pt,5,5),lt.debugOverlayTexture.update(ht),lt.debugOverlayTexture.bind(kt.LINEAR,kt.CLAMP_TO_EDGE)}(m,`${ze} ${ve}kb`);const Ee=O._tileDebugTextBuffer||m.debugBuffer,Ue=O._tileDebugTextIndexBuffer||m.quadTriangleIndexBuffer,nt=O._tileDebugTextSegments||m.debugSegments;k.draw(y,E.TRIANGLES,U,G,r.ColorMode.alphaBlended,r.CullFaceMode.disabled,jm(S,r.Color.transparent,Se),se,Ee,Ue,nt,null,null,null,O._globeTileDebugTextBuffer)}const Km=r.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Ps}=Km;function Bo(m,o,d,y){m.emplaceBack(o,d,y)}class Rl{constructor(o){this.vertexArray=new r.StructArrayLayout3f12,this.indices=new r.StructArrayLayout3ui6,Bo(this.vertexArray,-1,-1,1),Bo(this.vertexArray,1,-1,1),Bo(this.vertexArray,-1,1,1),Bo(this.vertexArray,1,1,1),Bo(this.vertexArray,-1,-1,-1),Bo(this.vertexArray,1,-1,-1),Bo(this.vertexArray,-1,1,-1),Bo(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=o.createVertexBuffer(this.vertexArray,Ps),this.indexBuffer=o.createIndexBuffer(this.indices),this.segment=r.SegmentVector.simpleSegment(0,0,36,12)}}function la(m,o,d,y,E,C){const S=m.gl,k=o.paint.get("sky-atmosphere-color"),O=o.paint.get("sky-atmosphere-halo-color"),U=o.paint.get("sky-atmosphere-sun-intensity"),G=((Z,se,de,ce,te)=>({u_matrix_3f:Z,u_sun_direction:se,u_sun_intensity:de,u_color_tint_r:[ce.r,ce.g,ce.b,ce.a],u_color_tint_m:[te.r,te.g,te.b,te.a],u_luminance:5e-5}))(r.fromMat4(r.create$1(),y),E,U,k,O);S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT0,S.TEXTURE_CUBE_MAP_POSITIVE_X+C,o.skyboxTexture,0),d.draw(m,S.TRIANGLES,r.DepthMode.disabled,r.StencilMode.disabled,r.ColorMode.unblended,r.CullFaceMode.frontCW,G,"skyboxCapture",o.skyboxGeometry.vertexBuffer,o.skyboxGeometry.indexBuffer,o.skyboxGeometry.segment)}function ca(m,o){return r.transformMat4(m,m,o)}const qd={symbol:function(m,o,d,y,E){if(m.renderPass!=="translucent")return;const C=r.StencilMode.disabled,S=m.colorModeForRenderPass();d.layout.get("text-variable-anchor")&&function(k,O,U,G,Z,se,de){const ce=O.transform,te=Z==="map",Le=se==="map";for(const ve of k){const De=G.getTile(ve),Se=De.getBucket(U);if(!Se||Se.projection!==ce.projection.name||!Se.text||!Se.text.segments.get().length)continue;const ze=r.evaluateSizeForZoom(Se.textSizeData,ce.zoom),Ee=O.transform.calculatePixelsToTileUnitsMatrix(De),Ue=di(ve.projMatrix,De.tileID.canonical,Le,te,O.transform,Ee),nt=U.layout.get("icon-text-fit")!=="none"&&Se.hasIconData();if(ze){const lt=Math.pow(2,ce.zoom-De.tileID.overscaledZ);iv(Se,te,Le,de,r.symbolSize,ce,Ue,ve,lt,ze,nt,ce.projection)}}}(y,m,d,o,d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),E),d.paint.get("icon-opacity").constantOr(1)!==0&&jd(m,o,d,y,!1,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),d.layout.get("icon-rotation-alignment"),d.layout.get("icon-pitch-alignment"),d.layout.get("icon-keep-upright"),C,S),d.paint.get("text-opacity").constantOr(1)!==0&&jd(m,o,d,y,!0,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.layout.get("text-keep-upright"),C,S),o.map.showCollisionBoxes&&(qm(m,o,d,y,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),!0),qm(m,o,d,y,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),!1))},circle:function(m,o,d,y){if(m.renderPass!=="translucent")return;const E=d.paint.get("circle-opacity"),C=d.paint.get("circle-stroke-width"),S=d.paint.get("circle-stroke-opacity"),k=d.layout.get("circle-sort-key").constantOr(1)!==void 0;if(E.constantOr(1)===0&&(C.constantOr(1)===0||S.constantOr(1)===0))return;const O=m.context,U=O.gl,G=m.transform,Z=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),se=r.StencilMode.disabled,de=m.colorModeForRenderPass(),ce=G.projection.name==="globe",te=[r.mercatorXfromLng(G.center.lng),r.mercatorYfromLat(G.center.lat)],Le=[];for(let De=0;DeDe.sortKey-Se.sortKey);const ve={useDepthForOcclusion:!ce};for(const De of Le){const{programConfiguration:Se,program:ze,layoutVertexBuffer:Ee,globeExtVertexBuffer:Ue,indexBuffer:nt,uniformValues:lt,tile:pt}=De.state,ht=De.segments;m.terrain&&m.terrain.setupElevationDraw(pt,ze,ve),m.prepareDrawProgram(O,ze,pt.tileID.toUnwrapped()),ze.draw(O,U.TRIANGLES,Z,se,de,r.CullFaceMode.disabled,lt,d.id,Ee,nt,ht,d.paint,G.zoom,Se,ce?Ue:null)}},heatmap:function(m,o,d,y){if(d.paint.get("heatmap-opacity")!==0)if(m.renderPass==="offscreen"){const E=m.context,C=E.gl,S=r.StencilMode.disabled,k=new r.ColorMode([C.ONE,C.ONE],r.Color.transparent,[!0,!0,!0,!0]);(function(se,de,ce){const te=se.gl;se.activeTexture.set(te.TEXTURE1),se.viewport.set([0,0,de.width/4,de.height/4]);let Le=ce.heatmapFbo;if(Le)te.bindTexture(te.TEXTURE_2D,Le.colorAttachment.get()),se.bindFramebuffer.set(Le.framebuffer);else{const ve=te.createTexture();te.bindTexture(te.TEXTURE_2D,ve),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_WRAP_S,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_WRAP_T,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MIN_FILTER,te.LINEAR),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MAG_FILTER,te.LINEAR),Le=ce.heatmapFbo=se.createFramebuffer(de.width/4,de.height/4,!1),function(De,Se,ze,Ee){const Ue=De.gl;Ue.texImage2D(Ue.TEXTURE_2D,0,Ue.RGBA,Se.width/4,Se.height/4,0,Ue.RGBA,De.extRenderToTextureHalfFloat?De.extTextureHalfFloat.HALF_FLOAT_OES:Ue.UNSIGNED_BYTE,null),Ee.colorAttachment.set(ze)}(se,de,ve,Le)}})(E,m,d),E.clear({color:r.Color.transparent});const O=m.transform,U=O.projection.name==="globe",G=U?["PROJECTION_GLOBE_VIEW"]:null,Z=[r.mercatorXfromLng(O.center.lng),r.mercatorYfromLat(O.center.lat)];for(let se=0;se({u_image:0,u_color_ramp:1,u_opacity:Z.paint.get("heatmap-opacity")}))(0,C),C.id,E.viewportBuffer,E.quadTriangleIndexBuffer,E.viewportSegments,C.paint,E.transform.zoom)}(m,d))},line:function(m,o,d,y){if(m.renderPass!=="translucent")return;const E=d.paint.get("line-opacity"),C=d.paint.get("line-width");if(E.constantOr(1)===0||C.constantOr(1)===0)return;const S=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),k=m.colorModeForRenderPass(),O=m.terrain&&m.terrain.renderingToTexture?1:r.exported.devicePixelRatio,U=d.paint.get("line-dasharray"),G=U.constantOr(1),Z=d.layout.get("line-cap"),se=d.paint.get("line-pattern"),de=se.constantOr(1),ce=d.paint.get("line-gradient"),te=d.getCrossfadeParameters(),Le=de?"linePattern":"line",ve=m.context,De=ve.gl,Se=(Ee=>{const Ue=[];Nd(Ee)&&Ue.push("RENDER_LINE_DASH"),Ee.paint.get("line-gradient")&&Ue.push("RENDER_LINE_GRADIENT");const nt=Ee.paint.get("line-pattern").constantOr(1),lt=Ee.paint.get("line-opacity").constantOr(1)!==1;return!nt&<&&Ue.push("RENDER_LINE_ALPHA_DISCARD"),Ue})(d);let ze=Se.includes("RENDER_LINE_ALPHA_DISCARD");m.terrain&&m.terrain.clipOrMaskOverlapStencilType()&&(ze=!1);for(const Ee of y){const Ue=o.getTile(Ee);if(de&&!Ue.patternsLoaded())continue;const nt=Ue.getBucket(d);if(!nt)continue;m.prepareDrawTile();const lt=nt.programConfigurations.get(d.id),pt=m.useProgram(Le,lt,Se),ht=se.constantOr(null);if(ht&&Ue.imageAtlas){const ft=Ue.imageAtlas,qt=ft.patternPositions[ht.to.toString()],gn=ft.patternPositions[ht.from.toString()];qt&&gn&<.setConstantPatternPositions(qt,gn)}const kt=U.constantOr(null),it=Z.constantOr(null);if(!de&&kt&&it&&Ue.lineAtlas){const ft=Ue.lineAtlas,qt=ft.getDash(kt.to,it),gn=ft.getDash(kt.from,it);qt&&gn&<.setConstantPatternPositions(qt,gn)}const zt=m.terrain?Ee.projMatrix:null,St=de?Od(m,Ue,d,te,zt,O):nv(m,Ue,d,te,zt,nt.lineClipsArray.length,O);if(ce){const ft=nt.gradients[d.id];let qt=ft.texture;if(d.gradientVersion!==ft.version){let gn=256;if(d.stepInterpolant){const Zt=o.getSource().maxzoom,Yt=Ee.canonical.z===Zt?Math.ceil(1<{pt.draw(ve,De.TRIANGLES,S,ft,k,r.CullFaceMode.disabled,St,d.id,nt.layoutVertexBuffer,nt.indexBuffer,nt.segments,d.paint,m.transform.zoom,lt,nt.layoutVertexBuffer2)};if(ze){const ft=m.stencilModeForClipping(Ee).ref;ft===0&&m.terrain&&ve.clear({stencil:0});const qt={func:De.EQUAL,mask:255};St.u_alpha_discard_threshold=.8,Jt(new r.StencilMode(qt,ft,255,De.KEEP,De.KEEP,De.INVERT)),St.u_alpha_discard_threshold=0,Jt(new r.StencilMode(qt,ft,255,De.KEEP,De.KEEP,De.KEEP))}else Jt(m.stencilModeForClipping(Ee))}ze&&(m.resetStencilClippingMasks(),m.terrain&&ve.clear({stencil:0}))},fill:function(m,o,d,y){const E=d.paint.get("fill-color"),C=d.paint.get("fill-opacity");if(C.constantOr(1)===0)return;const S=m.colorModeForRenderPass(),k=d.paint.get("fill-pattern"),O=m.opaquePassEnabledForLayer()&&!k.constantOr(1)&&E.constantOr(r.Color.transparent).a===1&&C.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===O){const U=m.depthModeForSublayer(1,m.renderPass==="opaque"?r.DepthMode.ReadWrite:r.DepthMode.ReadOnly);Du(m,o,d,y,U,S,!1)}if(m.renderPass==="translucent"&&d.paint.get("fill-antialias")){const U=m.depthModeForSublayer(d.getPaintProperty("fill-outline-color")?2:0,r.DepthMode.ReadOnly);Du(m,o,d,y,U,S,!0)}},"fill-extrusion":function(m,o,d,y){const E=d.paint.get("fill-extrusion-opacity");if(E!==0&&m.renderPass==="translucent"){const C=new r.DepthMode(m.context.gl.LEQUAL,r.DepthMode.ReadWrite,m.depthRangeFor3D);if(E!==1||d.paint.get("fill-extrusion-pattern").constantOr(1))Ds(m,o,d,y,C,r.StencilMode.disabled,r.ColorMode.disabled),Ds(m,o,d,y,C,m.stencilModeFor3D(),m.colorModeForRenderPass()),m.resetStencilClippingMasks();else{const S=m.colorModeForRenderPass();Ds(m,o,d,y,C,r.StencilMode.disabled,S)}}},hillshade:function(m,o,d,y){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;const E=m.context,C=m.depthModeForSublayer(0,r.DepthMode.ReadOnly),S=m.colorModeForRenderPass(),k=m.terrain&&m.terrain.renderingToTexture,[O,U]=m.renderPass!=="translucent"||k?[{},y]:m.stencilConfigForOverlap(y);for(const G of U){const Z=o.getTile(G);if(Z.needsHillshadePrepare&&m.renderPass==="offscreen")Id(m,Z,d,C,r.StencilMode.disabled,S);else if(m.renderPass==="translucent"){const se=k&&m.terrain?m.terrain.stencilModeForRTTOverlap(G):O[G.overscaledZ];Nm(m,G,Z,d,C,se,S)}}E.viewport.set([0,0,m.width,m.height]),m.resetStencilClippingMasks()},raster:function(m,o,d,y,E,C){if(m.renderPass!=="translucent"||d.paint.get("raster-opacity")===0||!y.length)return;const S=m.context,k=S.gl,O=o.getSource(),U=m.useProgram("raster"),G=m.colorModeForRenderPass(),Z=m.terrain&&m.terrain.renderingToTexture,[se,de]=O instanceof je||Z?[{},y]:m.stencilConfigForOverlap(y),ce=de[de.length-1].overscaledZ,te=!m.options.moving;for(const Le of de){const ve=Z?r.DepthMode.disabled:m.depthModeForSublayer(Le.overscaledZ-ce,d.paint.get("raster-opacity")===1?r.DepthMode.ReadWrite:r.DepthMode.ReadOnly,k.LESS),De=Le.toUnwrapped(),Se=o.getTile(Le);if(Z&&(!Se||!Se.hasData()))continue;const ze=Z?Le.projMatrix:m.transform.calculateProjMatrix(De,te),Ee=m.terrain&&Z?m.terrain.stencilModeForRTTOverlap(Le):se[Le.overscaledZ],Ue=C?0:d.paint.get("raster-fade-duration");Se.registerFadeDuration(Ue);const nt=o.findLoadedParent(Le,0),lt=zd(Se,nt,o,m.transform,Ue);let pt,ht;m.terrain&&m.terrain.prepareDrawTile();const kt=d.paint.get("raster-resampling")==="nearest"?k.NEAREST:k.LINEAR;S.activeTexture.set(k.TEXTURE0),Se.texture.bind(kt,k.CLAMP_TO_EDGE),S.activeTexture.set(k.TEXTURE1),nt?(nt.texture.bind(kt,k.CLAMP_TO_EDGE),pt=Math.pow(2,nt.tileID.overscaledZ-Se.tileID.overscaledZ),ht=[Se.tileID.canonical.x*pt%1,Se.tileID.canonical.y*pt%1]):Se.texture.bind(kt,k.CLAMP_TO_EDGE);const it=Hm(ze,ht||[0,0],pt||1,lt,d,O instanceof je?O.perspectiveTransform:[0,0]);if(m.prepareDrawProgram(S,U,De),O instanceof je)O.boundsBuffer&&O.boundsSegments&&U.draw(S,k.TRIANGLES,ve,r.StencilMode.disabled,G,r.CullFaceMode.disabled,it,d.id,O.boundsBuffer,m.quadTriangleIndexBuffer,O.boundsSegments);else{const{tileBoundsBuffer:zt,tileBoundsIndexBuffer:St,tileBoundsSegments:Jt}=m.getTileBoundsBuffers(Se);U.draw(S,k.TRIANGLES,ve,Ee,G,r.CullFaceMode.disabled,it,d.id,zt,St,Jt)}}m.resetStencilClippingMasks()},background:function(m,o,d,y){const E=d.paint.get("background-color"),C=d.paint.get("background-opacity");if(C===0)return;const S=m.context,k=S.gl,O=m.transform,U=O.tileSize,G=d.paint.get("background-pattern");if(m.isPatternMissing(G))return;const Z=!G&&E.a===1&&C===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==Z)return;const se=r.StencilMode.disabled,de=m.depthModeForSublayer(0,Z==="opaque"?r.DepthMode.ReadWrite:r.DepthMode.ReadOnly),ce=m.colorModeForRenderPass(),te=m.useProgram(G?"backgroundPattern":"background");let Le,ve=y;ve||(Le=m.getBackgroundTiles(),ve=Object.values(Le).map(Se=>Se.tileID)),G&&(S.activeTexture.set(k.TEXTURE0),m.imageManager.bind(m.context));const De=d.getCrossfadeParameters();for(const Se of ve){const ze=Se.toUnwrapped(),Ee=y?Se.projMatrix:m.transform.calculateProjMatrix(ze);m.prepareDrawTile();const Ue=o?o.getTile(Se):Le?Le[Se.key]:new r.Tile(Se,U,O.zoom,m),nt=G?Gd(Ee,C,m,G,{tileID:Se,tileSize:U},De):$m(Ee,C,E);m.prepareDrawProgram(S,te,ze);const{tileBoundsBuffer:lt,tileBoundsIndexBuffer:pt,tileBoundsSegments:ht}=m.getTileBoundsBuffers(Ue);te.draw(S,k.TRIANGLES,de,se,ce,r.CullFaceMode.disabled,nt,d.id,lt,pt,ht)}},sky:function(m,o,d){const y=m.transform,E=y.projection.name==="mercator"||y.projection.name==="globe"?1:r.smoothstep(7,8,y.zoom),C=d.paint.get("sky-opacity")*E;if(C===0)return;const S=m.context,k=d.paint.get("sky-type"),O=new r.DepthMode(S.gl.LEQUAL,r.DepthMode.ReadOnly,[0,1]),U=m.frameCounter/1e3%1;k==="atmosphere"?m.renderPass==="offscreen"?d.needsSkyboxCapture(m)&&(function(G,Z,se,de){const ce=G.context,te=ce.gl;let Le=Z.skyboxFbo;if(!Le){Le=Z.skyboxFbo=ce.createFramebuffer(32,32,!1),Z.skyboxGeometry=new Rl(ce),Z.skyboxTexture=ce.gl.createTexture(),te.bindTexture(te.TEXTURE_CUBE_MAP,Z.skyboxTexture),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_WRAP_S,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_WRAP_T,te.CLAMP_TO_EDGE),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_MIN_FILTER,te.LINEAR),te.texParameteri(te.TEXTURE_CUBE_MAP,te.TEXTURE_MAG_FILTER,te.LINEAR);for(let ze=0;ze<6;++ze)te.texImage2D(te.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,te.RGBA,32,32,0,te.RGBA,te.UNSIGNED_BYTE,null)}ce.bindFramebuffer.set(Le.framebuffer),ce.viewport.set([0,0,32,32]);const ve=Z.getCenter(G,!0),De=G.useProgram("skyboxCapture"),Se=new Float64Array(16);r.identity(Se),r.rotateY(Se,Se,.5*-Math.PI),la(ce,Z,De,Se,ve,0),r.identity(Se),r.rotateY(Se,Se,.5*Math.PI),la(ce,Z,De,Se,ve,1),r.identity(Se),r.rotateX(Se,Se,.5*-Math.PI),la(ce,Z,De,Se,ve,2),r.identity(Se),r.rotateX(Se,Se,.5*Math.PI),la(ce,Z,De,Se,ve,3),r.identity(Se),la(ce,Z,De,Se,ve,4),r.identity(Se),r.rotateY(Se,Se,Math.PI),la(ce,Z,De,Se,ve,5),ce.viewport.set([0,0,G.width,G.height])}(m,d),d.markSkyboxValid(m)):m.renderPass==="sky"&&function(G,Z,se,de,ce){const te=G.context,Le=te.gl,ve=G.transform,De=G.useProgram("skybox");te.activeTexture.set(Le.TEXTURE0),Le.bindTexture(Le.TEXTURE_CUBE_MAP,Z.skyboxTexture);const Se=((ze,Ee,Ue,nt,lt)=>({u_matrix:ze,u_sun_direction:Ee,u_cubemap:0,u_opacity:nt,u_temporal_offset:lt}))(ve.skyboxMatrix,Z.getCenter(G,!1),0,de,ce);G.prepareDrawProgram(te,De),De.draw(te,Le.TRIANGLES,se,r.StencilMode.disabled,G.colorModeForRenderPass(),r.CullFaceMode.backCW,Se,"skybox",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(m,d,O,C,U):k==="gradient"&&m.renderPass==="sky"&&function(G,Z,se,de,ce){const te=G.context,Le=te.gl,ve=G.transform,De=G.useProgram("skyboxGradient");Z.skyboxGeometry||(Z.skyboxGeometry=new Rl(te)),te.activeTexture.set(Le.TEXTURE0);let Se=Z.colorRampTexture;Se||(Se=Z.colorRampTexture=new r.Texture(te,Z.colorRamp,Le.RGBA)),Se.bind(Le.LINEAR,Le.CLAMP_TO_EDGE);const ze=((Ee,Ue,nt,lt,pt)=>({u_matrix:Ee,u_color_ramp:0,u_center_direction:Ue,u_radius:r.degToRad(nt),u_opacity:lt,u_temporal_offset:pt}))(ve.skyboxMatrix,Z.getCenter(G,!1),Z.paint.get("sky-gradient-radius"),de,ce);G.prepareDrawProgram(te,De),De.draw(te,Le.TRIANGLES,se,r.StencilMode.disabled,G.colorModeForRenderPass(),r.CullFaceMode.backCW,ze,"skyboxGradient",Z.skyboxGeometry.vertexBuffer,Z.skyboxGeometry.indexBuffer,Z.skyboxGeometry.segment)}(m,d,O,C,U)},debug:function(m,o,d){for(let y=0;yE)return void(this.transform.fogCullDistSq=null);const C=y+.78*(E-y);this.transform.fogCullDistSq=C*C}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(o,d){if(this.width=o*r.exported.devicePixelRatio,this.height=d*r.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const y of this.style.order)this.style._layers[y].resize()}setup(){const o=this.context,d=new r.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(r.EXTENT,0),d.emplaceBack(0,r.EXTENT),d.emplaceBack(r.EXTENT,r.EXTENT),this.tileExtentBuffer=o.createVertexBuffer(d,r.posAttributes.members),this.tileExtentSegments=r.SegmentVector.simpleSegment(0,0,4,2);const y=new r.StructArrayLayout2i4;y.emplaceBack(0,0),y.emplaceBack(r.EXTENT,0),y.emplaceBack(0,r.EXTENT),y.emplaceBack(r.EXTENT,r.EXTENT),this.debugBuffer=o.createVertexBuffer(y,r.posAttributes.members),this.debugSegments=r.SegmentVector.simpleSegment(0,0,4,5);const E=new r.StructArrayLayout2i4;E.emplaceBack(-1,-1),E.emplaceBack(1,-1),E.emplaceBack(-1,1),E.emplaceBack(1,1),this.viewportBuffer=o.createVertexBuffer(E,r.posAttributes.members),this.viewportSegments=r.SegmentVector.simpleSegment(0,0,4,2);const C=new r.StructArrayLayout4i8;C.emplaceBack(0,0,0,0),C.emplaceBack(r.EXTENT,0,r.EXTENT,0),C.emplaceBack(0,r.EXTENT,0,r.EXTENT),C.emplaceBack(r.EXTENT,r.EXTENT,r.EXTENT,r.EXTENT),this.mercatorBoundsBuffer=o.createVertexBuffer(C,r.boundsAttributes.members),this.mercatorBoundsSegments=r.SegmentVector.simpleSegment(0,0,4,2);const S=new r.StructArrayLayout3ui6;S.emplaceBack(0,1,2),S.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=o.createIndexBuffer(S);const k=new r.StructArrayLayout1ui2;for(const U of[0,1,3,2,0])k.emplaceBack(U);this.debugIndexBuffer=o.createIndexBuffer(k),this.emptyTexture=new r.Texture(o,new r.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),o.gl.RGBA),this.identityMat=r.create();const O=this.context.gl;this.stencilClearMode=new r.StencilMode({func:O.ALWAYS,mask:0},0,255,O.ZERO,O.ZERO,O.ZERO),this.loadTimeStamps.push(r.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(o){return o._makeTileBoundsBuffers(this.context,this.transform.projection),o._tileBoundsBuffer?{tileBoundsBuffer:o._tileBoundsBuffer,tileBoundsIndexBuffer:o._tileBoundsIndexBuffer,tileBoundsSegments:o._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const o=this.context,d=o.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(o,d.TRIANGLES,r.DepthMode.disabled,this.stencilClearMode,r.ColorMode.disabled,r.CullFaceMode.disabled,xu(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(o,d,y){if(!d||this.currentStencilSource===d.id||!o.isTileClipped()||!y||y.length===0)return;const E=[];let C=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(const G of y)if(this._tileClippingMaskIDs.has(G.key)||(C=!0),this._skippedStencilTileIDs.has(G.key)){if(!d.getTile(G).getBucket(o))continue;this._skippedStencilTileIDs.delete(G.key),E.push(G)}if(!C&&E.length===0)return}const S=this.context,k=S.gl;S.setColorMode(r.ColorMode.disabled),S.setDepthMode(r.DepthMode.disabled);const O=this.useProgram("clippingMask"),U=G=>{const Z=d.getTile(G),{tileBoundsBuffer:se,tileBoundsIndexBuffer:de,tileBoundsSegments:ce}=this.getTileBoundsBuffers(Z);O.draw(S,k.TRIANGLES,r.DepthMode.disabled,new r.StencilMode({func:k.GREATER,mask:255},this._tileClippingMaskIDs.get(G.key)||0,255,k.KEEP,k.KEEP,k.REPLACE),r.ColorMode.disabled,r.CullFaceMode.disabled,xu(G.projMatrix),"$clipping",se,de,ce)};if(!C&&E.length>0)for(const G of E)U(G);else{(this._tileClippingMaskIDs.size===0||this.nextStencilID+y.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(const G of y)this._tileClippingMaskIDs.set(G.key,this.nextStencilID++),d.getTile(G).getBucket(o)?U(G):this._skippedStencilTileIDs.add(G.key)}this._skippedStencilTileIDs.size===0&&(this.currentStencilSource=d.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const o=this.nextStencilID++,d=this.context.gl;return new r.StencilMode({func:d.NOTEQUAL,mask:255},o,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(o){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(o);const d=this.context.gl;return new r.StencilMode({func:d.EQUAL,mask:255},this._tileClippingMaskIDs.get(o.key)||0,0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(o){const d=this.context.gl,y=o.sort((S,k)=>k.overscaledZ-S.overscaledZ),E=y[y.length-1].overscaledZ,C=y[0].overscaledZ-E+1;if(C>1){this.currentStencilSource=void 0,this.nextStencilID+C>256&&this.clearStencil();const S={};for(let k=0;k=0;this.currentLayer--){const U=this.style._layers[y[this.currentLayer]],G=o._getLayerSourceCache(U);if(U.isSky())continue;const Z=G?S[G.id]:void 0;this._renderTileClippingMasks(U,G,Z),this.renderLayer(this,G,U,Z)}if(this.renderPass="sky",(r.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const Z=o._getLayerSourceCache(G);Z&&!G.isHidden(this.transform.zoom)&&(!U||U.getSource().maxzoom0?d.pop():null}isPatternMissing(o){if(!o)return!1;if(!o.from||!o.to)return!0;const d=this.imageManager.getPattern(o.from.toString()),y=this.imageManager.getPattern(o.to.toString());return!d||!y}currentGlobalDefines(){const o=this.terrain&&this.terrain.renderingToTexture,d=this.style&&this.style.fog,y=[];return this.terrain&&!this.terrain.renderingToTexture&&y.push("TERRAIN"),d&&!o&&d.getOpacity(this.transform.pitch)!==0&&y.push("FOG"),o&&y.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&y.push("OVERDRAW_INSPECTOR"),y}useProgram(o,d,y){this.cache=this.cache||{};const E=y||[],C=this.currentGlobalDefines().concat(E),S=Dl.cacheKey(o,C,d);return this.cache[S]||(this.cache[S]=new Dl(this.context,o,El[o],d,Qn[o],C)),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 o=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(o.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=r.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new r.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(o,d,y){if(this.terrain&&this.terrain.renderingToTexture)return;const E=this.style.fog;if(E){const C=E.getOpacity(this.transform.pitch);C!==0&&d.setFogUniformValues(o,((S,k,O,U)=>{const G=k.properties.get("color"),Z=S.frameCounter/1e3%1,se=[G.r/G.a,G.g/G.a,G.b/G.a,U];return{u_fog_matrix:O?S.transform.calculateFogTileMatrix(O):S.identityMat,u_fog_range:k.getFovAdjustedRange(S.transform._fov),u_fog_color:se,u_fog_horizon_blend:k.properties.get("horizon-blend"),u_fog_temporal_offset:Z}})(this,E,y,C))}}setTileLoadedFlag(o){this.tileLoaded=o}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const o=this.context.gl,d=o.createTexture();return o.bindTexture(o.TEXTURE_2D,d),o.copyTexImage2D(o.TEXTURE_2D,0,o.RGBA,0,0,o.drawingBufferWidth,o.drawingBufferHeight,0),d}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const o=this.style&&this.style.fog;return!!o&&o.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const o=this._backgroundTiles,d=this._backgroundTiles={},y=this.transform.coveringTiles({tileSize:512});for(const E of y)d[E.key]=o[E.key]||new r.Tile(E,512,this.transform.tileZoom,this);return d}clearBackgroundTiles(){this._backgroundTiles={}}}class ua{constructor(o=0,d=0,y=0,E=0){if(isNaN(o)||o<0||isNaN(d)||d<0||isNaN(y)||y<0||isNaN(E)||E<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=o,this.bottom=d,this.left=y,this.right=E}interpolate(o,d,y){return d.top!=null&&o.top!=null&&(this.top=r.number(o.top,d.top,y)),d.bottom!=null&&o.bottom!=null&&(this.bottom=r.number(o.bottom,d.bottom,y)),d.left!=null&&o.left!=null&&(this.left=r.number(o.left,d.left,y)),d.right!=null&&o.right!=null&&(this.right=r.number(o.right,d.right,y)),this}getCenter(o,d){const y=r.clamp((this.left+o-this.right)/2,0,o),E=r.clamp((this.top+d-this.bottom)/2,0,d);return new r.pointGeometry(y,E)}equals(o){return this.top===o.top&&this.bottom===o.bottom&&this.left===o.left&&this.right===o.right}clone(){return new ua(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qm(m,o){const d=r.getColumn(m,3);r.fromQuat(m,o),r.setColumn(m,3,d)}function Xd(m,o){const d=r.identity$1([]);return r.rotateZ$1(d,d,-o),r.rotateX$1(d,d,-m),d}function Lu(m,o){const d=[m[0],m[1],0],y=[o[0],o[1],0];if(r.length(d)>=1e-15){const S=r.normalize([],d);r.scale$2(y,S,r.dot(y,S)),o[0]=y[0],o[1]=y[1]}const E=r.cross([],o,m);if(r.len(E)<1e-15)return null;const C=Math.atan2(-E[1],E[0]);return Xd(Math.atan2(Math.sqrt(m[0]*m[0]+m[1]*m[1]),-m[2]),C)}class kl{constructor(o,d){this.position=o,this.orientation=d}get position(){return this._position}set position(o){if(o){const d=o instanceof r.MercatorCoordinate?o:new r.MercatorCoordinate(o[0],o[1],o[2]);this._renderWorldCopies&&(d.x=r.wrap(d.x,0,1)),this._position=d}else this._position=null}lookAtPoint(o,d){if(this.orientation=null,!this.position)return;const y=this._elevation?this._elevation.getAtPointOrZero(r.MercatorCoordinate.fromLngLat(o)):0,E=this.position,C=r.MercatorCoordinate.fromLngLat(o,y),S=[C.x-E.x,C.y-E.y,C.z-E.z];d||(d=[0,0,1]),d[2]=Math.abs(d[2]),this.orientation=Lu(S,d)}setPitchBearing(o,d){this.orientation=Xd(r.degToRad(o),r.degToRad(-d))}}class zl{constructor(o,d){this._transform=r.identity([]),this.orientation=d,this.position=o}get mercatorPosition(){const o=this.position;return new r.MercatorCoordinate(o[0],o[1],o[2])}get position(){const o=r.getColumn(this._transform,3);return[o[0],o[1],o[2]]}set position(o){var d;o&&r.setColumn(this._transform,3,[(d=o)[0],d[1],d[2],1])}get orientation(){return this._orientation}set orientation(o){this._orientation=o||r.identity$1([]),o&&Qm(this._transform,this._orientation)}getPitchBearing(){const o=this.forward(),d=this.right();return{bearing:Math.atan2(-d[1],d[0]),pitch:Math.atan2(Math.sqrt(o[0]*o[0]+o[1]*o[1]),-o[2])}}setPitchBearing(o,d){this._orientation=Xd(o,d),Qm(this._transform,this._orientation)}forward(){const o=r.getColumn(this._transform,2);return[-o[0],-o[1],-o[2]]}up(){const o=r.getColumn(this._transform,1);return[-o[0],-o[1],-o[2]]}right(){const o=r.getColumn(this._transform,0);return[o[0],o[1],o[2]]}getCameraToWorld(o,d){const y=new Float64Array(16);return r.invert(y,this.getWorldToCamera(o,d)),y}getWorldToCameraPosition(o,d,y){const E=this.position;r.scale$2(E,E,-o);const C=new Float64Array(16);return r.fromScaling(C,[y,y,y]),r.translate(C,C,E),C[10]*=d,C}getWorldToCamera(o,d){const y=new Float64Array(16),E=new Float64Array(4),C=this.position;return r.conjugate(E,this._orientation),r.scale$2(C,C,-o),r.fromQuat(y,E),r.translate(y,y,C),y[1]*=-1,y[5]*=-1,y[9]*=-1,y[13]*=-1,y[8]*=d,y[9]*=d,y[10]*=d,y[11]*=d,y}getCameraToClipPerspective(o,d,y,E){const C=new Float64Array(16);return r.perspective(C,o,d,y,E),C}getDistanceToElevation(o){const d=o===0?0:r.mercatorZfromAltitude(o,this.position[1]),y=this.forward();return(d-this.position[2])/y[2]}clone(){return new zl([...this.position],[...this.orientation])}}function Zd(m,o){const d=Fl(m),y=function(C,S,k,O,U){const G=new r.LngLat(k.lng-180*ha,k.lat),Z=new r.LngLat(k.lng+180*ha,k.lat),se=C.project(G.lng,G.lat),de=C.project(Z.lng,Z.lat),ce=-Math.atan2(de.y-se.y,de.x-se.x),te=r.MercatorCoordinate.fromLngLat(k);te.y=r.clamp(te.y,-.999975,.999975);const Le=te.toLngLat(),ve=C.project(Le.lng,Le.lat),De=r.MercatorCoordinate.fromLngLat(Le);De.x+=ha;const Se=De.toLngLat(),ze=C.project(Se.lng,Se.lat),Ee=Jd(ze.x-ve.x,ze.y-ve.y,ce),Ue=r.MercatorCoordinate.fromLngLat(Le);Ue.y+=ha;const nt=Ue.toLngLat(),lt=C.project(nt.lng,nt.lat),pt=Jd(lt.x-ve.x,lt.y-ve.y,ce),ht=Math.abs(Ee.x)/Math.abs(pt.y),kt=r.identity([]);r.rotateZ(kt,kt,-ce*(1-(U?0:O)));const it=r.identity([]);return r.scale(it,it,[1,1-(1-ht)*O,1]),it[4]=-pt.x/pt.y*O,r.rotateZ(it,it,ce),r.multiply$1(it,kt,it),it}(m.projection,0,m.center,d,o),E=Yd(m);return r.scale(y,y,[E,E,1]),y}function Yd(m){const o=m.projection,d=Fl(m),y=Kd(o,m.center),E=Kd(o,r.LngLat.convert(o.center));return Math.pow(2,y*d+(1-d)*E)}function Fl(m){const o=m.projection.range;if(!o)return 0;const d=Math.max(m.width,m.height),y=Math.log(d/1024)/Math.LN2;return r.smoothstep(o[0]+y,o[1]+y,m.zoom)}const ha=1/4e4;function Kd(m,o){const d=r.clamp(o.lat,-r.MAX_MERCATOR_LATITUDE,r.MAX_MERCATOR_LATITUDE),y=new r.LngLat(o.lng-180*ha,d),E=new r.LngLat(o.lng+180*ha,d),C=m.project(y.lng,d),S=m.project(E.lng,d),k=r.MercatorCoordinate.fromLngLat(y),O=r.MercatorCoordinate.fromLngLat(E),U=S.x-C.x,G=S.y-C.y,Z=O.x-k.x,se=O.y-k.y,de=Math.sqrt((Z*Z+se*se)/(U*U+G*G));return Math.log(de)/Math.LN2}function Jd(m,o,d){const y=Math.cos(d),E=Math.sin(d);return{x:m*y-o*E,y:m*E+o*y}}class Iu{constructor(o,d,y,E,C,S,k){this.tileSize=512,this._renderWorldCopies=C===void 0||C,this._minZoom=o||0,this._maxZoom=d||22,this._minPitch=y==null?0:y,this._maxPitch=E==null?60:E,this.setProjection(S),this.setMaxBounds(k),this.width=0,this.height=0,this._center=new r.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 ua,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new zl,this._centerAltitude=0,this._centerAltitudeValidForExaggeration=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const o=new Iu(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return o._elevation=this._elevation,o._centerAltitude=this._centerAltitude,o._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,o.tileSize=this.tileSize,o.width=this.width,o.height=this.height,o.cameraElevationReference=this.cameraElevationReference,o._center=this._center,o._setZoom(this.zoom),o._seaLevelZoom=this._seaLevelZoom,o.angle=this.angle,o._fov=this._fov,o._pitch=this._pitch,o._nearZ=this._nearZ,o._farZ=this._farZ,o._averageElevation=this._averageElevation,o._unmodified=this._unmodified,o._edgeInsets=this._edgeInsets.clone(),o._camera=this._camera.clone(),o._calcMatrices(),o.freezeTileCoverage=this.freezeTileCoverage,o}get elevation(){return this._elevation}set elevation(o){this._elevation!==o&&(this._elevation=o,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(o){const d=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||d)&&this._updateCameraOnTerrain(),(o||d)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return r.pick(this.projection,["name","center","parallels"])}setProjection(o){o==null&&(o={name:"mercator"}),this.projectionOptions=o;const d=this.projection?this.getProjection():void 0;this.projection=r.getProjection(o);const y=this.getProjection();return b(d,y)?null:(this._calcMatrices(),y)}get minZoom(){return this._minZoom}set minZoom(o){this._minZoom!==o&&(this._minZoom=o,this.zoom=Math.max(this.zoom,o))}get maxZoom(){return this._maxZoom}set maxZoom(o){this._maxZoom!==o&&(this._maxZoom=o,this.zoom=Math.min(this.zoom,o))}get minPitch(){return this._minPitch}set minPitch(o){this._minPitch!==o&&(this._minPitch=o,this.pitch=Math.max(this.pitch,o))}get maxPitch(){return this._maxPitch}set maxPitch(o){this._maxPitch!==o&&(this._maxPitch=o,this.pitch=Math.min(this.pitch,o))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(o){o===void 0?o=!0:o===null&&(o=!1),this._renderWorldCopies=o}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const o=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(o))}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 r.pointGeometry(this.width,this.height)}get bearing(){return r.wrap(this.rotation,-180,180)}set bearing(o){this.rotation=o}get rotation(){return-this.angle/Math.PI*180}set rotation(o){const d=-o*Math.PI/180;var y;this.angle!==d&&(this._unmodified=!1,this.angle=d,this._calcMatrices(),this.rotationMatrix=(y=new r.ARRAY_TYPE(4),r.ARRAY_TYPE!=Float32Array&&(y[1]=0,y[2]=0),y[0]=1,y[3]=1,y),function(E,C,S){var k=C[0],O=C[1],U=C[2],G=C[3],Z=Math.sin(S),se=Math.cos(S);E[0]=k*se+U*Z,E[1]=O*se+G*Z,E[2]=k*-Z+U*se,E[3]=O*-Z+G*se}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(o){const d=r.clamp(o,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==d&&(this._unmodified=!1,this._pitch=d,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(o){o=Math.max(.01,Math.min(60,o)),this._fov!==o&&(this._unmodified=!1,this._fov=o/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(o){this._averageElevation=o,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(o){const d=Math.min(Math.max(o,this.minZoom),this.maxZoom);this._zoom!==d&&(this._unmodified=!1,this._setZoom(d),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(o){this._zoom=o,this.scale=this.zoomScale(o),this.tileZoom=Math.floor(o),this.zoomFraction=o-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 o=this._elevation;this._centerAltitude=o.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=o.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 o=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],y=this.horizonLineFromTop();let E=0,C=0;for(let S=0;So.maxzoom&&(d=o.maxzoom);const S=this.locationCoordinate(this.center),k=this.center.lat,O=1<{const gn=new r.MercatorCoordinate(ft.x+25e-6,ft.y,ft.z),Zt=new r.MercatorCoordinate(ft.x,ft.y+25e-6,ft.z),Yt=ft.toLngLat(),xn=gn.toLngLat(),zn=Zt.toLngLat(),dn=this.locationCoordinate(Yt),Mn=this.locationCoordinate(xn),$n=this.locationCoordinate(zn),vi=Math.hypot(Mn.x-dn.x,Mn.y-dn.y),nr=Math.hypot($n.x-dn.x,$n.y-dn.y);return Math.sqrt(vi*nr)*Ee/25e-6},nt=ft=>{const qt=Se,gn=ze;return{aabb:r.tileAABB(this,O,0,0,0,ft,gn,qt,this.projection),zoom:0,x:0,y:0,minZ:gn,maxZ:qt,wrap:ft,fullyVisible:!1}},lt=[];let pt=[];const ht=d,kt=o.reparseOverscaled?y:d,it=ft=>ft*ft,zt=it((te-this._centerAltitude)*ce),St=ft=>{if(!this._elevation||!ft.tileID||!C)return;const qt=this._elevation.getMinMaxForTile(ft.tileID),gn=ft.aabb;qt?(gn.min[2]=qt.min,gn.max[2]=qt.max,gn.center[2]=(gn.min[2]+gn.max[2])/2):(ft.shouldSplit=Jt(ft),ft.shouldSplit||(gn.min[2]=gn.max[2]=gn.center[2]=this._centerAltitude))},Jt=ft=>{if(ft.zoom.85?1:dn}const xn=qt*qt+gn*gn+Zt;return xn{if(dn*it(.707)0;){const ft=lt.pop(),qt=ft.x,gn=ft.y;let Zt=ft.fullyVisible;if(!Zt){const Yt=ft.aabb.intersects(se);if(Yt===0)continue;Zt=Yt===2}if(ft.zoom!==ht&&Jt(ft))for(let Yt=0;Yt<4;Yt++){const xn=(qt<<1)+Yt%2,zn=(gn<<1)+(Yt>>1),dn={aabb:C?ft.aabb.quadrant(Yt):r.tileAABB(this,O,ft.zoom+1,xn,zn,ft.wrap,ft.minZ,ft.maxZ,this.projection),zoom:ft.zoom+1,x:xn,y:zn,wrap:ft.wrap,fullyVisible:Zt,tileID:void 0,shouldSplit:void 0,minZ:ft.minZ,maxZ:ft.maxZ};E&&!G&&(dn.tileID=new r.OverscaledTileID(ft.zoom+1===ht?kt:ft.zoom+1,ft.wrap,ft.zoom+1,xn,zn),St(dn)),lt.push(dn)}else{const Yt=ft.zoom===ht?kt:ft.zoom;if(o.minzoom&&o.minzoom>Yt)continue;const xn=U[0]-(.5+qt+(ft.wrap<{const Zt=[0,0,0,1],Yt=[r.EXTENT,r.EXTENT,0,1],xn=this.calculateFogTileMatrix(gn.tileID.toUnwrapped());r.transformMat4$1(Zt,Zt,xn),r.transformMat4$1(Yt,Yt,xn);const zn=r.getAABBPointSquareDist(Zt,Yt);if(zn===0)return!0;let dn=!1;const Mn=this._elevation;if(Mn&&zn>ft&&qt!==0){const $n=this.calculateProjMatrix(gn.tileID.toUnwrapped());let vi;o.isTerrainDEM||(vi=Mn.getMinMaxForTile(gn.tileID)),vi||(vi={min:ze,max:Se});const nr=r.furthestTileCorner(this.rotation),ir=[nr[0]*r.EXTENT,nr[1]*r.EXTENT,vi.max];r.transformMat4(ir,ir,$n),dn=(1-ir[1])*this.height*.5ft.distanceSq-qt.distanceSq).map(ft=>ft.tileID)}resize(o,d){this.width=o,this.height=d,this.pixelsToGLUnits=[2/o,-2/d],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(o){return Math.pow(2,o)}scaleZoom(o){return Math.log(o)/Math.LN2}project(o){const d=r.clamp(o.lat,-r.MAX_MERCATOR_LATITUDE,r.MAX_MERCATOR_LATITUDE),y=this.projection.project(o.lng,d);return new r.pointGeometry(y.x*this.worldSize,y.y*this.worldSize)}unproject(o){return this.projection.unproject(o.x/this.worldSize,o.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(o,d){let y,E;const C=this.centerPoint;if(this.projection.name==="globe"){const k=this.worldSize;y=(d.x-C.x)/k,E=(d.y-C.y)/k}else{const k=this.pointCoordinate(d),O=this.pointCoordinate(C);y=k.x-O.x,E=k.y-O.y}const S=this.locationCoordinate(o);this.setLocation(new r.MercatorCoordinate(S.x-y,S.y-E))}setLocation(o){this.center=this.coordinateLocation(o),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(o){return this.projection.locationPoint(this,o)}locationPoint3D(o){return this._coordinatePoint(this.locationCoordinate(o),!0)}pointLocation(o){return this.coordinateLocation(this.pointCoordinate(o))}pointLocation3D(o){return this.coordinateLocation(this.pointCoordinate3D(o))}locationCoordinate(o,d){const y=d?r.mercatorZfromAltitude(d,o.lat):void 0,E=this.projection.project(o.lng,o.lat);return new r.MercatorCoordinate(E.x,E.y,y)}coordinateLocation(o){return this.projection.unproject(o.x,o.y)}pointRayIntersection(o,d){const y=d!=null?d:this._centerAltitude,E=[o.x,o.y,0,1],C=[o.x,o.y,1,1];r.transformMat4$1(E,E,this.pixelMatrixInverse),r.transformMat4$1(C,C,this.pixelMatrixInverse);const S=C[3];r.scale$1(E,E,1/E[3]),r.scale$1(C,C,1/S);const k=E[2],O=C[2];return{p0:E,p1:C,t:k===O?0:(y-k)/(O-k)}}screenPointToMercatorRay(o){const d=[o.x,o.y,0,1],y=[o.x,o.y,1,1];return r.transformMat4$1(d,d,this.pixelMatrixInverse),r.transformMat4$1(y,y,this.pixelMatrixInverse),r.scale$1(d,d,1/d[3]),r.scale$1(y,y,1/y[3]),d[2]=r.mercatorZfromAltitude(d[2],this._center.lat)*this.worldSize,y[2]=r.mercatorZfromAltitude(y[2],this._center.lat)*this.worldSize,r.scale$1(d,d,1/this.worldSize),r.scale$1(y,y,1/this.worldSize),new r.Ray([d[0],d[1],d[2]],r.normalize([],r.sub([],y,d)))}rayIntersectionCoordinate(o){const{p0:d,p1:y,t:E}=o,C=r.mercatorZfromAltitude(d[2],this._center.lat),S=r.mercatorZfromAltitude(y[2],this._center.lat);return new r.MercatorCoordinate(r.number(d[0],y[0],E)/this.worldSize,r.number(d[1],y[1],E)/this.worldSize,r.number(C,S,E))}pointCoordinate(o,d=this._centerAltitude){return this.projection.pointCoordinate(this,o.x,o.y,d)}pointCoordinate3D(o){if(!this.elevation)return this.pointCoordinate(o);const d=this.elevation;let y=this.elevation.pointCoordinate(o);if(y)return new r.MercatorCoordinate(y[0],y[1],y[2]);let E=0,C=this.horizonLineFromTop();if(o.y>C)return this.pointCoordinate(o);const S=.02*C,k=o.clone();for(let O=0;O<10&&C-E>S;O++){k.y=r.number(E,C,.66);const U=d.pointCoordinate(k);U?(C=k.y,y=U):E=k.y}return y?new r.MercatorCoordinate(y[0],y[1],y[2]):this.pointCoordinate(o)}isPointAboveHorizon(o){if(this.elevation)return!this.elevation.pointCoordinate(o);{const d=this.horizonLineFromTop();return o.y0?new r.pointGeometry(E[0]/E[3],E[1]/E[3]):new r.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(o,d){const y=new r.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),E=new r.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),C=new r.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),S=new r.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let k=this.pointCoordinate(y,o),O=this.pointCoordinate(E,o);const U=this.pointCoordinate(C,d),G=this.pointCoordinate(S,d),Z=(se,de)=>(de.y-se.y)/(de.x-se.x);return k.y>1&&O.y>=0?k=new r.MercatorCoordinate((1-G.y)/Z(G,k)+G.x,1):k.y<0&&O.y<=1&&(k=new r.MercatorCoordinate(-G.y/Z(G,k)+G.x,0)),O.y>1&&k.y>=0?O=new r.MercatorCoordinate((1-U.y)/Z(U,O)+U.x,1):O.y<0&&k.y<=1&&(O=new r.MercatorCoordinate(-U.y/Z(U,O)+U.x,0)),new r.LngLatBounds().extend(this.coordinateLocation(k)).extend(this.coordinateLocation(O)).extend(this.coordinateLocation(G)).extend(this.coordinateLocation(U))}_getBounds3D(){const o=this.elevation;if(!o.visibleDemTiles.length)return this._getBounds(0,0);const d=o.visibleDemTiles.reduce((y,E)=>{if(E.dem){const C=E.dem.tree;y.min=Math.min(y.min,C.minimums[0]),y.max=Math.max(y.max,C.maximums[0])}return y},{min:Number.MAX_VALUE,max:0});return this._getBounds(d.min*o.exaggeration(),d.max*o.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(o=!0){const d=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,y=this.height/2-d*(1-this._horizonShift);return o?Math.max(0,y):y}getMaxBounds(){return this.maxBounds}setMaxBounds(o){this.maxBounds=o,this.minLat=-r.MAX_MERCATOR_LATITUDE,this.maxLat=r.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,o&&(this.minLat=o.getSouth(),this.maxLat=o.getNorth(),this.minLng=o.getWest(),this.maxLng=o.getEast(),this.maxLngG&&(S=G-O),G-Use&&(C=se-k),se-Z.5?ve-1:ve,De>.5?De-1:De,0]),this.alignedProjMatrix=Se,S=r.create(),r.scale(S,S,[this.width/2,-this.height/2,1]),r.translate(S,S,[1,-1,0]),this.labelPlaneMatrix=S,S=r.create(),r.scale(S,S,[1,-1,1]),r.translate(S,S,[-1,-1,0]),r.scale(S,S,[2/this.width,2/this.height,1]),this.glCoordMatrix=S,this.pixelMatrix=r.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},S=r.invert(new Float64Array(16),this.pixelMatrix),!S)throw new Error("failed to invert matrix");this.pixelMatrixInverse=S,this.globeMatrix=this.projection.name==="globe"?r.calculateGlobeMatrix(this):S,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const o=this.cameraWorldSize,d=this.cameraPixelsPerMeter,y=this._camera.position,E=1/this.height,C=[o,o,d];r.scale$2(C,C,E),r.scale$2(y,y,-1),r.multiply$2(y,y,C);const S=r.create();r.translate(S,S,y),r.scale(S,S,C),this.mercatorFogMatrix=S,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(o,d,E)}_computeCameraPosition(o){const d=(o=o||this.pixelsPerMeter)/this.pixelsPerMeter,y=this._camera.forward(),E=this.point,C=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*d-o/this.worldSize*this._centerAltitude;return[E.x/this.worldSize-y[0]*C,E.y/this.worldSize-y[1]*C,o/this.worldSize*this._centerAltitude-y[2]*C]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(o){const d=this._maxCameraBoundsDistance()*Math.cos(this._pitch),y=o[2];let E=1;y>0&&(E=Math.min((d-this._camera.position[2])/y,1)),this._camera.position=r.scaleAndAdd([],this._camera.position,o,E),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const o=this._camera.position,d=this._camera.forward(),{pitch:y,bearing:E}=this._camera.getPitchBearing(),C=r.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,S=this._mercatorZfromZoom(this._maxZoom)*Math.cos(r.degToRad(this._maxPitch)),k=Math.max((o[2]-C)/Math.cos(y),S),O=this._zoomFromMercatorZ(k);r.scaleAndAdd(o,o,d,k),this._pitch=r.clamp(y,r.degToRad(this.minPitch),r.degToRad(this.maxPitch)),this.angle=r.wrap(E,-Math.PI,Math.PI),this._setZoom(r.clamp(O,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new r.MercatorCoordinate(o[0],o[1],o[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(o){return Math.pow(2,o)*this.tileSize}_mercatorZfromZoom(o){return this.cameraToCenterDistance/this._worldSizeFromZoom(o)}_minimumHeightOverTerrain(){const o=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(o)}_zoomFromMercatorZ(o){return this.scaleZoom(this.cameraToCenterDistance/(o*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(r.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(o,d){const y=Math.min(o.x,d.x),E=Math.max(o.x,d.x),C=Math.min(o.y,d.y),S=Math.max(o.y,d.y);if(CU||se.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+r.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new r.pointGeometry(0,0),new r.pointGeometry(this.width,this.height))}zoomDeltaToMovement(o,d){const y=r.length(r.sub([],this._camera.position,o)),E=this._zoomFromMercatorZ(y)+d;return y-this._mercatorZfromZoom(E)}getCameraPoint(){const o=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new r.pointGeometry(0,o))}}function Qd(m,o){let d=!1,y=null;const E=()=>{y=null,d&&(m(),y=setTimeout(E,o),d=!1)};return()=>(d=!0,y||E(),y)}class eg{constructor(o){this._hashName=o&&encodeURIComponent(o),r.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Qd(this._updateHashUnthrottled.bind(this),300)}addTo(o){return this._map=o,r.window.addEventListener("hashchange",this._onHashChange,!1),o.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),r.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(o){const d=this._map;if(!d)return"";const y=d.getCenter(),E=Math.round(100*d.getZoom())/100,C=Math.ceil((E*Math.LN2+Math.log(512/360/.5))/Math.LN10),S=Math.pow(10,C),k=Math.round(y.lng*S)/S,O=Math.round(y.lat*S)/S,U=d.getBearing(),G=d.getPitch();let Z="";if(Z+=o?`/${k}/${O}/${E}`:`${E}/${O}/${k}`,(U||G)&&(Z+="/"+Math.round(10*U)/10),G&&(Z+=`/${Math.round(G)}`),this._hashName){const se=this._hashName;let de=!1;const ce=r.window.location.hash.slice(1).split("&").map(te=>{const Le=te.split("=")[0];return Le===se?(de=!0,`${Le}=${Z}`):te}).filter(te=>te);return de||ce.push(`${se}=${Z}`),`#${ce.join("&")}`}return`#${Z}`}_getCurrentHash(){const o=r.window.location.hash.replace("#","");if(this._hashName){let d;return o.split("&").map(y=>y.split("=")).forEach(y=>{y[0]===this._hashName&&(d=y)}),(d&&d[1]||"").split("/")}return o.split("/")}_onHashChange(){const o=this._map;if(!o)return!1;const d=this._getCurrentHash();if(d.length>=3&&!d.some(y=>isNaN(y))){const y=o.dragRotate.isEnabled()&&o.touchZoomRotate.isEnabled()?+(d[3]||0):o.getBearing();return o.jumpTo({center:[+d[2],+d[1]],zoom:+d[0],bearing:y,pitch:+(d[4]||0)}),!0}return!1}_updateHashUnthrottled(){const o=r.window.location.href.replace(/(#.+)?$/,this.getHashString());r.window.history.replaceState(r.window.history.state,null,o)}}const Oo={linearity:.3,easing:r.bezier(0,0,.3,1)},tg=r.extend({deceleration:2500,maxSpeed:1400},Oo),ng=r.extend({deceleration:20,maxSpeed:1400},Oo),ig=r.extend({deceleration:1e3,maxSpeed:360},Oo),rg=r.extend({deceleration:1e3,maxSpeed:90},Oo);class og{constructor(o){this._map=o,this.clear()}clear(){this._inertiaBuffer=[]}record(o){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:r.exported.now(),settings:o})}_drainInertiaBuffer(){const o=this._inertiaBuffer,d=r.exported.now();for(;o.length>0&&d-o[0].time>160;)o.shift()}_onMoveEnd(o){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const d={zoom:0,bearing:0,pitch:0,pan:new r.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:C}of this._inertiaBuffer)d.zoom+=C.zoomDelta||0,d.bearing+=C.bearingDelta||0,d.pitch+=C.pitchDelta||0,C.panDelta&&d.pan._add(C.panDelta),C.around&&(d.around=C.around),C.pinchAround&&(d.pinchAround=C.pinchAround);const y=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,E={};if(d.pan.mag()){const C=Hi(d.pan.mag(),y,r.extend({},tg,o||{}));E.offset=d.pan.mult(C.amount/d.pan.mag()),E.center=this._map.transform.center,Bl(E,C)}if(d.zoom){const C=Hi(d.zoom,y,ng);E.zoom=this._map.transform.zoom+C.amount,Bl(E,C)}if(d.bearing){const C=Hi(d.bearing,y,ig);E.bearing=this._map.transform.bearing+r.clamp(C.amount,-179,179),Bl(E,C)}if(d.pitch){const C=Hi(d.pitch,y,rg);E.pitch=this._map.transform.pitch+C.amount,Bl(E,C)}if(E.zoom||E.bearing){const C=d.pinchAround===void 0?d.around:d.pinchAround;E.around=C?this._map.unproject(C):this._map.getCenter()}return this.clear(),E.noMoveStart=!0,E}}function Bl(m,o){(!m.duration||m.durationd.unproject(O)),k=C.reduce((O,U,G,Z)=>O.add(U.div(Z.length)),new r.pointGeometry(0,0));super(o,{points:C,point:k,lngLats:S,lngLat:d.unproject(k),originalEvent:y}),this._defaultPrevented=!1}}class ov extends r.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,y){super(o,{originalEvent:y}),this._defaultPrevented=!1}}class av{constructor(o,d){this._map=o,this._clickTolerance=d.clickTolerance}reset(){this._mousedownPos=void 0}wheel(o){return this._firePreventable(new ov(o.type,this._map,o))}mousedown(o,d){return this._mousedownPos=d,this._firePreventable(new Ir(o.type,this._map,o))}mouseup(o){this._map.fire(new Ir(o.type,this._map,o))}preclick(o){const d=r.extend({},o);d.type="preclick",this._map.fire(new Ir(d.type,this._map,d))}click(o,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||(this.preclick(o),this._map.fire(new Ir(o.type,this._map,o)))}dblclick(o){return this._firePreventable(new Ir(o.type,this._map,o))}mouseover(o){this._map.fire(new Ir(o.type,this._map,o))}mouseout(o){this._map.fire(new Ir(o.type,this._map,o))}touchstart(o){return this._firePreventable(new Ol(o.type,this._map,o))}touchmove(o){this._map.fire(new Ol(o.type,this._map,o))}touchend(o){this._map.fire(new Ol(o.type,this._map,o))}touchcancel(o){this._map.fire(new Ol(o.type,this._map,o))}_firePreventable(o){if(this._map.fire(o),o.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class No{constructor(o){this._map=o}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(o){this._map.fire(new Ir(o.type,this._map,o))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ir("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(o){this._delayContextMenu?this._contextMenuEvent=o:this._map.fire(new Ir(o.type,this._map,o)),this._map.listens("contextmenu")&&o.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ag{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._container=o.getContainer(),this._clickTolerance=d.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(o,d){this.isEnabled()&&o.shiftKey&&o.button===0&&(V(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(o,d){if(!this._active)return;const y=d;if(this._lastPos.equals(y)||!this._box&&y.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${C}px,${k}px)`,this._box.style.width=S-C+"px",this._box.style.height=O-k+"px")})}mouseupWindow(o,d){if(!this._active||o.button!==0)return;const y=this._startPos,E=d;if(this.reset(),ne(),y.x!==E.x||y.y!==E.y)return this._map.fire(new r.Event("boxzoomend",{originalEvent:o})),{cameraAnimation:C=>C.fitScreenCoordinates(y,E,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",o)}keydown(o){this._active&&o.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",o))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),j(),delete this._startPos,delete this._lastPos}_fireEvent(o,d){return this._map.fire(new r.Event(o,{originalEvent:d}))}}function da(m,o){const d={};for(let y=0;ythis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=o.timeStamp),y.length===this.numTouches&&(this.centroid=function(E){const C=new r.pointGeometry(0,0);for(const S of E)C._add(S);return C.div(E.length)}(d),this.touches=da(y,d)))}touchmove(o,d,y){if(this.aborted||!this.centroid)return;const E=da(y,d);for(const C in this.touches){const S=this.touches[C],k=E[C];(!k||k.dist(S)>30)&&(this.aborted=!0)}}touchend(o,d,y){if((!this.centroid||o.timeStamp-this.startTime>500)&&(this.aborted=!0),y.length===0){const E=!this.aborted&&this.centroid;if(this.reset(),E)return E}}}class Ss{constructor(o){this.singleTap=new Mo(o),this.numTaps=o.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(o,d,y){this.singleTap.touchstart(o,d,y)}touchmove(o,d,y){this.singleTap.touchmove(o,d,y)}touchend(o,d,y){const E=this.singleTap.touchend(o,d,y);if(E){const C=o.timeStamp-this.lastTime<500,S=!this.lastTap||this.lastTap.dist(E)<30;if(C&&S||this.reset(),this.count++,this.lastTime=o.timeStamp,this.lastTap=E,this.count===this.numTaps)return this.reset(),E}}}class $t{constructor(){this._zoomIn=new Ss({numTouches:1,numTaps:2}),this._zoomOut=new Ss({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(o,d,y){this._zoomIn.touchstart(o,d,y),this._zoomOut.touchstart(o,d,y)}touchmove(o,d,y){this._zoomIn.touchmove(o,d,y),this._zoomOut.touchmove(o,d,y)}touchend(o,d,y){const E=this._zoomIn.touchend(o,d,y),C=this._zoomOut.touchend(o,d,y);return E?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()+1,around:S.unproject(E)},{originalEvent:o})}):C?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:S=>S.easeTo({duration:300,zoom:S.getZoom()-1,around:S.unproject(C)},{originalEvent:o})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const sg={0:1,2:2};class Ru{constructor(o){this.reset(),this._clickTolerance=o.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(o,d){return!1}_move(o,d){return{}}mousedown(o,d){if(this._lastPoint)return;const y=ae(o);this._correctButton(o,y)&&(this._lastPoint=d,this._eventButton=y)}mousemoveWindow(o,d){const y=this._lastPoint;if(y){if(o.preventDefault(),this._eventButton!=null&&function(E,C){const S=sg[C];return E.buttons===void 0||(E.buttons&S)!==S}(o,this._eventButton))this.reset();else if(this._moved||!(d.dist(y)0&&(this._active=!0);const E=da(y,d),C=new r.pointGeometry(0,0),S=new r.pointGeometry(0,0);let k=0;for(const U in E){const G=E[U],Z=this._touches[U];Z&&(C._add(G),S._add(G.sub(Z)),k++,E[U]=G)}if(this._touches=E,k{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class ku{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(o){}_move(o,d,y){return{}}touchstart(o,d,y){this._firstTwoTouches||y.length<2||(this._firstTwoTouches=[y[0].identifier,y[1].identifier],this._start([d[0],d[1]]))}touchmove(o,d,y){const E=this._firstTwoTouches;if(!E)return;o.preventDefault();const[C,S]=E,k=Ul(y,d,C),O=Ul(y,d,S);if(!k||!O)return;const U=this._aroundCenter?null:k.add(O).div(2);return this._move([k,O],U,o)}touchend(o,d,y){if(!this._firstTwoTouches)return;const[E,C]=this._firstTwoTouches,S=Ul(y,d,E),k=Ul(y,d,C);S&&k||(this._active&&ne(),this.reset())}touchcancel(){this.reset()}enable(o){this._enabled=!0,this._aroundCenter=!!o&&o.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ul(m,o,d){for(let y=0;yMath.abs(m.x)}class Fu extends ku{constructor(o){super(),this._map=o}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(o){this._lastPoints=o,Vl(o[0].sub(o[1]))&&(this._valid=!1)}_move(o,d,y){const E=this._lastPoints;if(!E)return;const C=o[0].sub(E[0]),S=o[1].sub(E[1]);return this._map._cooperativeGestures&&y.touches.length<3||(this._valid=this.gestureBeginsVertically(C,S,y.timeStamp),!this._valid)?void 0:(this._lastPoints=o,this._active=!0,{pitchDelta:(C.y+S.y)/2*-.5})}gestureBeginsVertically(o,d,y){if(this._valid!==void 0)return this._valid;const E=o.mag()>=2,C=d.mag()>=2;if(!E&&!C)return;if(!E||!C)return this._firstMove==null&&(this._firstMove=y),y-this._firstMove<100&&void 0;const S=o.y>0==d.y>0;return Vl(o)&&Vl(d)&&S}}const ug={panStep:100,bearingStep:15,pitchStep:10};class hg{constructor(){const o=ug;this._panStep=o.panStep,this._bearingStep=o.bearingStep,this._pitchStep=o.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(o){if(o.altKey||o.ctrlKey||o.metaKey)return;let d=0,y=0,E=0,C=0,S=0;switch(o.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:o.shiftKey?y=-1:(o.preventDefault(),C=-1);break;case 39:o.shiftKey?y=1:(o.preventDefault(),C=1);break;case 38:o.shiftKey?E=1:(o.preventDefault(),S=-1);break;case 40:o.shiftKey?E=-1:(o.preventDefault(),S=1);break;default:return}return this._rotationDisabled&&(y=0,E=0),{cameraAnimation:k=>{const O=k.getZoom();k.easeTo({duration:300,easeId:"keyboardHandler",easing:dg,zoom:d?Math.round(O)+d*(o.shiftKey?2:1):O,bearing:k.getBearing()+y*this._bearingStep,pitch:k.getPitch()+E*this._pitchStep,offset:[-C*this._panStep,-S*this._panStep],center:k.getCenter()},{originalEvent:o})}}}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 dg(m){return m*(2-m)}const ip=4.000244140625;class pg{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._handler=d,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,r.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(o){this._defaultZoomRate=o}setWheelZoomRate(o){this._wheelZoomRate=o}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(o){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!o&&o.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(o){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(o.ctrlKey||o.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let d=o.deltaMode===r.window.WheelEvent.DOM_DELTA_LINE?40*o.deltaY:o.deltaY;const y=r.exported.now(),E=y-(this._lastWheelEventTime||0);this._lastWheelEventTime=y,d!==0&&d%ip==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":E>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,o)):this._type||(this._type=Math.abs(E*d)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,d+=this._lastValue)),o.shiftKey&&d&&(d/=4),this._type&&(this._lastWheelEvent=o,this._delta-=d,this._active||this._start(o)),o.preventDefault()}_onTimeout(o){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)}_start(o){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 d=H(this._el,o);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:d,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 o=this._map.transform,d=()=>o._terrainEnabled()&&this._aroundCoord?o.computeZoomRelativeTo(this._aroundCoord):o.zoom;if(this._delta!==0){const O=this._type==="wheel"&&Math.abs(this._delta)>ip?this._wheelZoomRate:this._defaultZoomRate;let U=2/(1+Math.exp(-Math.abs(this._delta*O)));this._delta<0&&U!==0&&(U=1/U);const G=d(),Z=Math.pow(2,G),se=typeof this._targetZoom=="number"?o.zoomScale(this._targetZoom):Z;this._targetZoom=Math.min(o.maxZoom,Math.max(o.minZoom,o.scaleZoom(se*U))),this._type==="wheel"&&(this._startZoom=d(),this._easing=this._smoothOutEasing(200)),this._delta=0}const y=typeof this._targetZoom=="number"?this._targetZoom:d(),E=this._startZoom,C=this._easing;let S,k=!1;if(this._type==="wheel"&&E&&C){const O=Math.min((r.exported.now()-this._lastWheelEventTime)/200,1),U=C(O);S=r.number(E,y,U),O<1?this._frameId||(this._frameId=!0):k=!0}else S=y,k=!0;return this._active=!0,k&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!k,zoomDelta:S-d(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(o){let d=r.ease;if(this._prevEase){const y=this._prevEase,E=(r.exported.now()-y.start)/y.duration,C=y.easing(E+.01)-y.easing(E),S=.27/Math.sqrt(C*C+1e-4)*.01,k=Math.sqrt(.0729-S*S);d=r.bezier(S,k,.25,1)}return this._prevEase={start:r.exported.now(),duration:o,easing:d},d}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=A("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(r.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!!r.window.document.fullscreenElement||!!r.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 fg{constructor(o,d){this._clickZoom=o,this._tapZoom=d}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 mg{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(o,d){return o.preventDefault(),{cameraAnimation:y=>{y.easeTo({duration:300,zoom:y.getZoom()+(o.shiftKey?-1:1),around:y.unproject(d)},{originalEvent:o})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class rp{constructor(){this._tap=new Ss({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(o,d,y){this._swipePoint||(this._tapTime&&o.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?y.length>0&&(this._swipePoint=d[0],this._swipeTouch=y[0].identifier):this._tap.touchstart(o,d,y))}touchmove(o,d,y){if(this._tapTime){if(this._swipePoint){if(y[0].identifier!==this._swipeTouch)return;const E=d[0],C=E.y-this._swipePoint.y;return this._swipePoint=E,o.preventDefault(),this._active=!0,{zoomDelta:C/128}}}else this._tap.touchmove(o,d,y)}touchend(o,d,y){this._tapTime?this._swipePoint&&y.length===0&&this.reset():this._tap.touchend(o,d,y)&&(this._tapTime=o.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class gg{constructor(o,d,y){this._el=o,this._mousePan=d,this._touchPan=y}enable(o){this._inertiaOptions=o||{},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 yg{constructor(o,d,y){this._pitchWithRotate=o.pitchWithRotate,this._mouseRotate=d,this._mousePitch=y}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 _g{constructor(o,d,y,E){this._el=o,this._touchZoom=d,this._touchRotate=y,this._tapDragZoom=E,this._rotationDisabled=!1,this._enabled=!0}enable(o){this._touchZoom.enable(o),this._rotationDisabled||this._touchRotate.enable(o),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 Gl=m=>m.zoom||m.drag||m.pitch||m.rotate;class op extends r.Event{}class vg{constructor(){this.constants=[1,1,.01],this.radius=0}setup(o,d){const y=r.sub([],d,o);this.radius=r.length(y[2]<0?r.div([],y,this.constants):[y[0],y[1],0])}projectRay(o){r.div(o,o,this.constants),r.normalize(o,o),r.mul$1(o,o,this.constants);const d=r.scale$2([],o,this.radius);if(d[2]>0){const y=r.scale$2([],[0,0,1],r.dot(d,[0,0,1])),E=r.scale$2([],r.normalize([],[d[0],d[1],0]),this.radius),C=r.add([],d,r.scale$2([],r.sub([],r.add([],E,y),d),2));d[0]=C[0],d[1]=C[1]}return d}}function Is(m){return m.panDelta&&m.panDelta.mag()||m.zoomDelta||m.bearingDelta||m.pitchDelta}class xg{constructor(o,d){this._map=o,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new og(o),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new vg,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),r.bindAll(["handleEvent","handleWindowEvent"],this);const y=this._el;this._listeners=[[y,"touchstart",{passive:!0}],[y,"touchmove",{passive:!1}],[y,"touchend",void 0],[y,"touchcancel",void 0],[y,"mousedown",void 0],[y,"mousemove",void 0],[y,"mouseup",void 0],[r.window.document,"mousemove",{capture:!0}],[r.window.document,"mouseup",void 0],[y,"mouseover",void 0],[y,"mouseout",void 0],[y,"dblclick",void 0],[y,"click",void 0],[y,"keydown",{capture:!1}],[y,"keyup",void 0],[y,"wheel",{passive:!1}],[y,"contextmenu",void 0],[r.window,"blur",void 0]];for(const[E,C,S]of this._listeners)E.addEventListener(C,E===r.window.document?this.handleWindowEvent:this.handleEvent,S)}destroy(){for(const[o,d,y]of this._listeners)o.removeEventListener(d,o===r.window.document?this.handleWindowEvent:this.handleEvent,y)}_addDefaultHandlers(o){const d=this._map,y=d.getCanvasContainer();this._add("mapEvent",new av(d,o));const E=d.boxZoom=new ag(d,o);this._add("boxZoom",E);const C=new $t,S=new mg;d.doubleClickZoom=new fg(S,C),this._add("tapZoom",C),this._add("clickZoom",S);const k=new rp;this._add("tapDragZoom",k);const O=d.touchPitch=new Fu(d);this._add("touchPitch",O);const U=new Ls(o),G=new ep(o);d.dragRotate=new yg(o,U,G),this._add("mouseRotate",U,["mousePitch"]),this._add("mousePitch",G,["mouseRotate"]);const Z=new Nl(o),se=new lg(d,o);d.dragPan=new gg(y,Z,se),this._add("mousePan",Z),this._add("touchPan",se,["touchZoom","touchRotate"]);const de=new zu,ce=new cg;d.touchZoomRotate=new _g(y,ce,de,k),this._add("touchRotate",de,["touchPan","touchZoom"]),this._add("touchZoom",ce,["touchPan","touchRotate"]),this._add("blockableMapEvent",new No(d));const te=d.scrollZoom=new pg(d,this);this._add("scrollZoom",te,["mousePan"]);const Le=d.keyboard=new hg;this._add("keyboard",Le);for(const ve of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])o.interactive&&o[ve]&&d[ve].enable(o[ve])}_add(o,d,y){this._handlers.push({handlerName:o,handler:d,allowed:y}),this._handlersById[o]=d}stop(o){if(!this._updatingCamera){for(const{handler:d}of this._handlers)d.reset();this._inertia.clear(),this._fireEvents({},{},o),this._changes=[]}}isActive(){for(const{handler:o}of this._handlers)if(o.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Gl(this._eventsInProgress)||this.isZooming()}_blockedByActive(o,d,y){for(const E in o)if(E!==y&&(!d||d.indexOf(E)<0))return!0;return!1}handleWindowEvent(o){this.handleEvent(o,`${o.type}Window`)}_getMapTouches(o){const d=[];for(const y of o)this._el.contains(y.target)&&d.push(y);return d}handleEvent(o,d){this._updatingCamera=!0;const y=o.type==="renderFrame",E=y?void 0:o,C={needsRenderFrame:!1},S={},k={},O=o.touches?this._getMapTouches(o.touches):void 0,U=O?Q(this._el,O):y?void 0:H(this._el,o);for(const{handlerName:se,handler:de,allowed:ce}of this._handlers){if(!de.isEnabled())continue;let te;this._blockedByActive(k,ce,se)?de.reset():de[d||o.type]&&(te=de[d||o.type](o,U,O),this.mergeHandlerResult(C,S,te,se,E),te&&te.needsRenderFrame&&this._triggerRenderFrame()),(te||de.isActive())&&(k[se]=de)}const G={};for(const se in this._previousActiveHandlers)k[se]||(G[se]=E);this._previousActiveHandlers=k,(Object.keys(G).length||Is(C))&&(this._changes.push([C,S,G]),this._triggerRenderFrame()),(Object.keys(k).length||Is(C))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Z}=C;Z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Z(this._map))}mergeHandlerResult(o,d,y,E,C){if(!y)return;r.extend(o,y);const S={handlerName:E,originalEvent:y.originalEvent||C};y.zoomDelta!==void 0&&(d.zoom=S),y.panDelta!==void 0&&(d.drag=S),y.pitchDelta!==void 0&&(d.pitch=S),y.bearingDelta!==void 0&&(d.rotate=S)}_applyChanges(){const o={},d={},y={};for(const[E,C,S]of this._changes)E.panDelta&&(o.panDelta=(o.panDelta||new r.pointGeometry(0,0))._add(E.panDelta)),E.zoomDelta&&(o.zoomDelta=(o.zoomDelta||0)+E.zoomDelta),E.bearingDelta&&(o.bearingDelta=(o.bearingDelta||0)+E.bearingDelta),E.pitchDelta&&(o.pitchDelta=(o.pitchDelta||0)+E.pitchDelta),E.around!==void 0&&(o.around=E.around),E.aroundCoord!==void 0&&(o.aroundCoord=E.aroundCoord),E.pinchAround!==void 0&&(o.pinchAround=E.pinchAround),E.noInertia&&(o.noInertia=E.noInertia),r.extend(d,C),r.extend(y,S);this._updateMapTransform(o,d,y),this._changes=[]}_updateMapTransform(o,d,y){const E=this._map,C=E.transform,S=De=>[De.x,De.y,De.z];if((De=>{const Se=this._eventsInProgress.drag;return Se&&!this._handlersById[Se.handlerName].isActive()})()&&!Is(o)){const De=C.zoom;C.cameraElevationReference="sea",C.recenterOnTerrain(),C.cameraElevationReference="ground",De!==C.zoom&&this._map._update(!0)}if(!Is(o))return void this._fireEvents(d,y,!0);let{panDelta:k,zoomDelta:O,bearingDelta:U,pitchDelta:G,around:Z,aroundCoord:se,pinchAround:de}=o;de!==void 0&&(Z=de),(De=>d.drag&&!this._eventsInProgress.drag)()&&Z&&(this._dragOrigin=S(C.pointCoordinate3D(Z)),this._trackingEllipsoid.setup(C._camera.position,this._dragOrigin)),C.cameraElevationReference="sea",E._stop(!0),Z=Z||E.transform.centerPoint,U&&(C.bearing+=U),G&&(C.pitch+=G),C._updateCameraState();const ce=[0,0,0];if(k){const De=C.pointCoordinate(Z);if(C.projection.name==="globe"){const Se=r.latFromMercatorY(De.y),ze=C.center.lat,Ee=Math.min(r.mercatorZfromAltitude(1,Se)/r.mercatorZfromAltitude(1,ze),2);k=k.rotate(-C.angle),ce[0]=-k.x/C.worldSize*Ee,ce[1]=-k.y/C.worldSize*Ee}else{const Se=C.pointCoordinate(Z.sub(k));De&&Se&&(ce[0]=Se.x-De.x,ce[1]=Se.y-De.y)}}const te=C.zoom,Le=[0,0,0];if(O){const De=S(se||C.pointCoordinate3D(Z)),Se={dir:r.normalize([],r.sub([],De,C._camera.position))};if(Se.dir[2]<0){const ze=C.zoomDeltaToMovement(De,O);r.scale$2(Le,Se.dir,ze)}}const ve=r.add(ce,ce,Le);C._translateCameraConstrained(ve),O&&Math.abs(C.zoom-te)>1e-4&&C.recenterOnTerrain(),C.cameraElevationReference="ground",this._map._update(),o.noInertia||this._inertia.record(o),this._fireEvents(d,y,!0)}_fireEvents(o,d,y){const E=Gl(this._eventsInProgress),C=Gl(o),S={};for(const G in o){const{originalEvent:Z}=o[G];this._eventsInProgress[G]||(S[`${G}start`]=Z),this._eventsInProgress[G]=o[G]}!E&&C&&this._fireEvent("movestart",C.originalEvent);for(const G in S)this._fireEvent(G,S[G]);C&&this._fireEvent("move",C.originalEvent);for(const G in o){const{originalEvent:Z}=o[G];this._fireEvent(G,Z)}const k={};let O;for(const G in this._eventsInProgress){const{handlerName:Z,originalEvent:se}=this._eventsInProgress[G];this._handlersById[Z].isActive()||(delete this._eventsInProgress[G],O=d[Z]||se,k[`${G}end`]=O)}for(const G in k)this._fireEvent(G,k[G]);const U=Gl(this._eventsInProgress);if(y&&(E||C)&&!U){this._updatingCamera=!0;const G=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Z=se=>se!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new op("renderFrame",{timeStamp:o})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Bu="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ap extends r.Evented{constructor(o,d){super(),this._moving=!1,this._zooming=!1,this.transform=o,this._bearingSnap=d.bearingSnap,r.bindAll(["_renderFrameCallback"],this)}getCenter(){return new r.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(o,d){return this.jumpTo({center:o},d)}panBy(o,d,y){return o=r.pointGeometry.convert(o).mult(-1),this.panTo(this.transform.center,r.extend({offset:o},d),y)}panTo(o,d,y){return this.easeTo(r.extend({center:o},d),y)}getZoom(){return this.transform.zoom}setZoom(o,d){return this.jumpTo({zoom:o},d),this}zoomTo(o,d,y){return this.easeTo(r.extend({zoom:o},d),y)}zoomIn(o,d){return this.zoomTo(this.getZoom()+1,o,d),this}zoomOut(o,d){return this.zoomTo(this.getZoom()-1,o,d),this}getBearing(){return this.transform.bearing}setBearing(o,d){return this.jumpTo({bearing:o},d),this}getPadding(){return this.transform.padding}setPadding(o,d){return this.jumpTo({padding:o},d),this}rotateTo(o,d,y){return this.easeTo(r.extend({bearing:o},d),y)}resetNorth(o,d){return this.rotateTo(0,r.extend({duration:1e3},o),d),this}resetNorthPitch(o,d){return this.easeTo(r.extend({bearing:0,pitch:0,duration:1e3},o),d),this}snapToNorth(o,d){return Math.abs(this.getBearing())ht=>{if(Se&&(pt.zoom=r.number(E,O,ht)),ze&&(pt.bearing=r.number(C,U,ht)),Ee&&(pt.pitch=r.number(S,G,ht)),Ue&&(pt.interpolatePadding(k,Z,ht),de=pt.centerPoint.add(se)),ve)pt.setLocationAtPoint(ve,De);else{const kt=pt.zoomScale(pt.zoom-E),it=O>E?Math.min(2,Le):Math.max(.5,Le),zt=Math.pow(it,1-ht),St=pt.unproject(ce.add(te.mult(ht*zt)).mult(kt));pt.setLocationAtPoint(pt.renderWorldCopies?St.wrap():St,de)}return o.preloadOnly||this._fireMoveEvents(d),pt};if(o.preloadOnly){const pt=this._emulate(nt,o.duration,y);return this._preloadTiles(pt),this}const lt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Se,this._rotating=ze,this._pitching=Ee,this._padding=Ue,this._easeId=o.easeId,this._prepareEase(d,o.noMoveStart,lt),this._ease(nt(y),pt=>{y.recenterOnTerrain(),this._afterEase(d,pt)},o),this}_prepareEase(o,d,y={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||y.moving||this.fire(new r.Event("movestart",o)),this._zooming&&!y.zooming&&this.fire(new r.Event("zoomstart",o)),this._rotating&&!y.rotating&&this.fire(new r.Event("rotatestart",o)),this._pitching&&!y.pitching&&this.fire(new r.Event("pitchstart",o))}_fireMoveEvents(o){this.fire(new r.Event("move",o)),this._zooming&&this.fire(new r.Event("zoom",o)),this._rotating&&this.fire(new r.Event("rotate",o)),this._pitching&&this.fire(new r.Event("pitch",o))}_afterEase(o,d){if(this._easeId&&d&&this._easeId===d)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const y=this._zooming,E=this._rotating,C=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,y&&this.fire(new r.Event("zoomend",o)),E&&this.fire(new r.Event("rotateend",o)),C&&this.fire(new r.Event("pitchend",o)),this.fire(new r.Event("moveend",o))}flyTo(o,d){if(!o.essential&&r.exported.prefersReducedMotion){const Zt=r.pick(o,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Zt,d)}this.stop(),o=r.extend({offset:[0,0],speed:1.2,curve:1.42,easing:r.ease},o);const y=this.transform,E=this.getZoom(),C=this.getBearing(),S=this.getPitch(),k=this.getPadding(),O="zoom"in o?r.clamp(+o.zoom,y.minZoom,y.maxZoom):E,U="bearing"in o?this._normalizeBearing(o.bearing,C):C,G="pitch"in o?+o.pitch:S,Z="padding"in o?o.padding:y.padding,se=y.zoomScale(O-E),de=r.pointGeometry.convert(o.offset);let ce=y.centerPoint.add(de);const te=y.pointLocation(ce),Le=r.LngLat.convert(o.center||te);this._normalizeCenter(Le);const ve=y.project(te),De=y.project(Le).sub(ve);let Se=o.curve;const ze=Math.max(y.width,y.height),Ee=ze/se,Ue=De.mag();if("minZoom"in o){const Zt=r.clamp(Math.min(o.minZoom,E,O),y.minZoom,y.maxZoom),Yt=ze/y.zoomScale(Zt-E);Se=Math.sqrt(Yt/Ue*2)}const nt=Se*Se;function lt(Zt){const Yt=(Ee*Ee-ze*ze+(Zt?-1:1)*nt*nt*Ue*Ue)/(2*(Zt?Ee:ze)*nt*Ue);return Math.log(Math.sqrt(Yt*Yt+1)-Yt)}function pt(Zt){return(Math.exp(Zt)-Math.exp(-Zt))/2}function ht(Zt){return(Math.exp(Zt)+Math.exp(-Zt))/2}const kt=lt(0);let it=function(Zt){return ht(kt)/ht(kt+Se*Zt)},zt=function(Zt){return ze*((ht(kt)*(pt(Yt=kt+Se*Zt)/ht(Yt))-pt(kt))/nt)/Ue;var Yt},St=(lt(1)-kt)/Se;if(Math.abs(Ue)<1e-6||!isFinite(St)){if(Math.abs(ze-Ee)<1e-6)return this.easeTo(o,d);const Zt=Eeo.maxDuration&&(o.duration=0);const Jt=C!==U,ft=G!==S,qt=!y.isPaddingEqual(Z),gn=Zt=>Yt=>{const xn=Yt*St,zn=1/it(xn);Zt.zoom=Yt===1?O:E+Zt.scaleZoom(zn),Jt&&(Zt.bearing=r.number(C,U,Yt)),ft&&(Zt.pitch=r.number(S,G,Yt)),qt&&(Zt.interpolatePadding(k,Z,Yt),ce=Zt.centerPoint.add(de));const dn=Yt===1?Le:Zt.unproject(ve.add(De.mult(zt(xn))).mult(zn));return Zt.setLocationAtPoint(Zt.renderWorldCopies?dn.wrap():dn,ce),Zt._updateCameraOnTerrain(),o.preloadOnly||this._fireMoveEvents(d),Zt};if(o.preloadOnly){const Zt=this._emulate(gn,o.duration,y);return this._preloadTiles(Zt),this}return this._zooming=!0,this._rotating=Jt,this._pitching=ft,this._padding=qt,this._prepareEase(d,!1),this._ease(gn(y),()=>this._afterEase(d),o),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(o,d){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const y=this._onEaseEnd;this._onEaseEnd=void 0,y.call(this,d)}if(!o){const y=this.handlers;y&&y.stop(!1)}return this}_ease(o,d,y){y.animate===!1||y.duration===0?(o(1),d()):(this._easeStart=r.exported.now(),this._easeOptions=y,this._onEaseFrame=o,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const o=Math.min((r.exported.now()-this._easeStart)/this._easeOptions.duration,1),d=this._onEaseFrame;d&&d(this._easeOptions.easing(o)),o<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(o,d){o=r.wrap(o,-180,180);const y=Math.abs(o-d);return Math.abs(o-360-d)180?-360:y<-180?360:0}_emulate(o,d,y){const E=Math.ceil(15*d/1e3),C=[],S=o(y.clone());for(let k=0;k<=E;k++){const O=S(k/E);C.push(O.clone())}return C}}class Ou{constructor(o={}){this.options=o,r.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(o){const d=this.options&&this.options.compact;return this._map=o,this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=A("button","mapboxgl-ctrl-attrib-button",this._container),A("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=A("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),d&&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),d===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(o,d){const y=this._map._getUIString(`AttributionControl.${d}`);o.setAttribute("aria-label",y),o.removeAttribute("title"),o.firstElementChild&&o.firstElementChild.setAttribute("title",y)}_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 o=this._editLink;o||(o=this._editLink=this._container.querySelector(".mapbox-improve-map"));const d=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||r.config.ACCESS_TOKEN}];if(o){const y=d.reduce((E,C,S)=>(C.value&&(E+=`${C.key}=${C.value}${SE.length-C.length),o=o.filter((E,C)=>{for(let S=C+1;S=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?o=[...this.options.customAttribution,...o]:o.unshift(this.options.customAttribution));const y=o.join(" | ");y!==this._attribHTML&&(this._attribHTML=y,o.length?(this._innerContainer.innerHTML=y,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 bg{constructor(){r.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(o){this._map=o,this._container=A("div","mapboxgl-ctrl");const d=A("a","mapboxgl-ctrl-logo");return d.target="_blank",d.rel="noopener nofollow",d.href="https://www.mapbox.com/",d.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),d.setAttribute("rel","noopener nofollow"),this._container.appendChild(d),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(o){o&&o.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const o=this._map.style._sourceCaches;if(Object.entries(o).length===0)return!0;for(const d in o){const y=o[d].getSource();if(y.hasOwnProperty("mapbox_logo")&&!y.mapbox_logo)return!1}return!0}_updateCompact(){const o=this._container.children;if(o.length){const d=o[0];this._map.getCanvasContainer().offsetWidth<250?d.classList.add("mapboxgl-compact"):d.classList.remove("mapboxgl-compact")}}}class wg{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(o){const d=++this._id;return this._queue.push({callback:o,id:d,cancelled:!1}),d}remove(o){const d=this._currentlyRunning,y=d?this._queue.concat(d):this._queue;for(const E of y)if(E.id===o)return void(E.cancelled=!0)}run(o=0){const d=this._currentlyRunning=this._queue;this._queue=[];for(const y of d)if(!y.cancelled&&(y.callback(o),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Nu(m,o,d){if(m=new r.LngLat(m.lng,m.lat),o){const y=new r.LngLat(m.lng-360,m.lat),E=new r.LngLat(m.lng+360,m.lat),C=360*Math.ceil(Math.abs(m.lng-d.center.lng)/360),S=d.locationPoint(m).distSqr(o),k=o.x<0||o.y<0||o.x>d.width||o.y>d.height;d.locationPoint(y).distSqr(o)180;){const y=d.locationPoint(m);if(y.x>=0&&y.y>=0&&y.x<=d.width&&y.y<=d.height)break;m.lng>d.center.lng?m.lng-=360:m.lng+=360}return m}const Uu={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 Vu extends r.Evented{constructor(o,d){if(super(),(o instanceof r.window.HTMLElement||d)&&(o=r.extend({element:o},d)),r.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=o&&o.anchor||"center",this._color=o&&o.color||"#3FB1CE",this._scale=o&&o.scale||1,this._draggable=o&&o.draggable||!1,this._clickTolerance=o&&o.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=o&&o.rotation||0,this._rotationAlignment=o&&o.rotationAlignment||"auto",this._pitchAlignment=o&&o.pitchAlignment&&o.pitchAlignment!=="auto"?o.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),o&&o.element)this._element=o.element,this._offset=r.pointGeometry.convert(o&&o.offset||[0,0]);else{this._defaultMarker=!0,this._element=A("div");const E=41,C=27,S=L("svg",{display:"block",height:E*this._scale+"px",width:C*this._scale+"px",viewBox:`0 0 ${C} ${E}`},this._element),k=L("radialGradient",{id:"shadowGradient"},L("defs",{},S));L("stop",{offset:"10%","stop-opacity":.4},k),L("stop",{offset:"100%","stop-opacity":.05},k),L("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},S),L("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),L("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),L("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},S),this._offset=r.pointGeometry.convert(o&&o.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",E=>{E.preventDefault()}),this._element.addEventListener("mousedown",E=>{E.preventDefault()});const y=this._element.classList;for(const E in Uu)y.remove(`mapboxgl-marker-anchor-${E}`);y.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(o){return o===this._map||(this.remove(),this._map=o,o.getCanvasContainer().appendChild(this._element),o.on("move",this._updateMoving),o.on("moveend",this._update),o.on("remove",this._clearFadeTimer),o._addMarker(this),this.setDraggable(this._draggable),this._update(),o.on("click",this._onMapClick)),this}remove(){const o=this._map;return o&&(o.off("click",this._onMapClick),o.off("move",this._updateMoving),o.off("moveend",this._update),o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler),o.off("mouseup",this._onUp),o.off("touchend",this._onUp),o.off("mousemove",this._onMove),o.off("touchmove",this._onMove),o.off("remove",this._clearFadeTimer),o._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(o){return this._lngLat=r.LngLat.convert(o),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(o){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")),o){if(!("offset"in o.options)){const E=Math.sqrt(Math.pow(13.5,2)/2);o.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[E,-1*(24.6+E)],"bottom-right":[-E,-1*(24.6+E)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=o,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(o){const d=o.code,y=o.charCode||o.keyCode;d!=="Space"&&d!=="Enter"&&y!==32&&y!==13||this.togglePopup()}_onMapClick(o){const d=o.originalEvent.target,y=this._element;this._popup&&(d===y||y.contains(d))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const o=this._popup;return o?(o.isOpen()?(o.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(o.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const o=this._map;if(!o)return;const d=this._pos;if(!d||d.x<0||d.x>o.transform.width||d.y<0||d.y>o.transform.height)return void this._clearFadeTimer();const y=o.unproject(d);let E=!1;if(o.transform._terrainEnabled()&&o.getTerrain()){const S=o.getFreeCameraOptions();if(S.position){const k=S.position.toLngLat();E=k.distanceTo(y)<.9*k.distanceTo(this._lngLat)}}const C=(1-o._queryFogOpacity(y))*(E?.2:1);this._element.style.opacity=`${C}`,this._popup&&this._popup._setOpacity(`${C}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const o=this._pos;if(!o)return;const d=this._offset.mult(this._scale),y=this._calculatePitch(),E=this._calculateRotation();this._element.style.transform=` translate(${o.x}px, ${o.y}px) ${Uu[this._anchor]} rotateX(${y}deg) rotateZ(${E}deg) translate(${d.x}px, ${d.y}px) `}_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(o){r.window.cancelAnimationFrame(this._updateFrameId);const d=this._map;d&&(d.transform.renderWorldCopies&&(this._lngLat=Nu(this._lngLat,this._pos,d.transform)),this._pos=d.project(this._lngLat),o===!0?this._updateFrameId=r.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),d._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!d.getTerrain()&&!d.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(o){return this._offset=r.pointGeometry.convert(o),this._update(),this}_onMove(o){const d=this._map;if(d){if(!this._isDragging){const y=this._clickTolerance||d._clickTolerance;this._isDragging=o.point.dist(this._pointerdownPos)>=y}this._isDragging&&(this._pos=o.point.sub(this._positionDelta),this._lngLat=d.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new r.Event("dragstart"))),this.fire(new r.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const o=this._map;o&&(o.off("mousemove",this._onMove),o.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new r.Event("dragend")),this._state="inactive"}_addDragHandler(o){const d=this._map;d&&this._element.contains(o.originalEvent.target)&&(o.preventDefault(),this._positionDelta=o.point.sub(this._pos),this._pointerdownPos=o.point,this._state="pending",d.on("mousemove",this._onMove),d.on("touchmove",this._onMove),d.once("mouseup",this._onUp),d.once("touchend",this._onUp))}setDraggable(o){this._draggable=!!o;const d=this._map;return d&&(o?(d.on("mousedown",this._addDragHandler),d.on("touchstart",this._addDragHandler)):(d.off("mousedown",this._addDragHandler),d.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(o){return this._rotation=o||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(o){return this._rotationAlignment=o||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(o){return this._pitchAlignment=o&&o!=="auto"?o:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class sv{constructor(o){this.jumpTo(o)}getValue(o){if(o<=this._startTime)return this._start;if(o>=this._endTime)return this._end;const d=r.easeCubicInOut((o-this._startTime)/(this._endTime-this._startTime));return this._start*(1-d)+this._end*d}isEasing(o){return o>=this._startTime&&o<=this._endTime}jumpTo(o){this._startTime=-1/0,this._endTime=-1/0,this._start=o,this._end=o}easeTo(o,d,y){this._start=this.getValue(d),this._end=o,this._startTime=d,this._endTime=d+y}}const lv={"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"},sp={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 Wl(m){m.parentNode&&m.parentNode.removeChild(m)}const lp={showCompass:!0,showZoom:!0,visualizePitch:!1};class cp{constructor(o,d,y=!1){this._clickTolerance=10,this.element=d,this.mouseRotate=new Ls({clickTolerance:o.dragRotate._mouseRotate._clickTolerance}),this.map=o,y&&(this.mousePitch=new ep({clickTolerance:o.dragRotate._mousePitch._clickTolerance})),r.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),d.addEventListener("mousedown",this.mousedown),d.addEventListener("touchstart",this.touchstart,{passive:!1}),d.addEventListener("touchmove",this.touchmove),d.addEventListener("touchend",this.touchend),d.addEventListener("touchcancel",this.reset)}down(o,d){this.mouseRotate.mousedown(o,d),this.mousePitch&&this.mousePitch.mousedown(o,d),V()}move(o,d){const y=this.map,E=this.mouseRotate.mousemoveWindow(o,d),C=E&&E.bearingDelta;if(C&&y.setBearing(y.getBearing()+C),this.mousePitch){const S=this.mousePitch.mousemoveWindow(o,d),k=S&&S.pitchDelta;k&&y.setPitch(y.getPitch()+k)}}off(){const o=this.element;o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart,{passive:!1}),o.removeEventListener("touchmove",this.touchmove),o.removeEventListener("touchend",this.touchend),o.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){j(),r.window.removeEventListener("mousemove",this.mousemove),r.window.removeEventListener("mouseup",this.mouseup)}mousedown(o){this.down(r.extend({},o,{ctrlKey:!0,preventDefault:()=>o.preventDefault()}),H(this.element,o)),r.window.addEventListener("mousemove",this.mousemove),r.window.addEventListener("mouseup",this.mouseup)}mousemove(o){this.move(o,H(this.element,o))}mouseup(o){this.mouseRotate.mouseupWindow(o),this.mousePitch&&this.mousePitch.mouseupWindow(o),this.offTemp()}touchstart(o){o.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=Q(this.element,o.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>o.preventDefault()},this._startPos))}touchmove(o){o.targetTouches.length!==1?this.reset():(this._lastPos=Q(this.element,o.targetTouches)[0],this.move({preventDefault:()=>o.preventDefault()},this._lastPos))}touchend(o){o.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?Rs(o,y,U/5280,m._getUIString("ScaleControl.Miles"),m):Rs(o,y,U,m._getUIString("ScaleControl.Feet"),m)}else d&&d.unit==="nautical"?Rs(o,y,O/1852,m._getUIString("ScaleControl.NauticalMiles"),m):O>=1e3?Rs(o,y,O/1e3,m._getUIString("ScaleControl.Kilometers"),m):Rs(o,y,O,m._getUIString("ScaleControl.Meters"),m)}function Rs(m,o,d,y,E){const C=function(k){const O=Math.pow(10,`${Math.floor(k)}`.length-1);let U=k/O;return U=U>=10?10:U>=5?5:U>=3?3:U>=2?2:U>=1?1:function(G){const Z=Math.pow(10,Math.ceil(-Math.log(G)/Math.LN10));return Math.round(G*Z)/Z}(U),O*U}(d),S=C/d;E._requestDomTask(()=>{m.style.width=o*S+"px",m.innerHTML=`${C} ${y}`})}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 Hl(m=new r.pointGeometry(0,0),o="bottom"){if(typeof m=="number"){const d=Math.round(Math.sqrt(.5*Math.pow(m,2)));switch(o){case"top":return new r.pointGeometry(0,m);case"top-left":return new r.pointGeometry(d,d);case"top-right":return new r.pointGeometry(-d,d);case"bottom":return new r.pointGeometry(0,-m);case"bottom-left":return new r.pointGeometry(d,-d);case"bottom-right":return new r.pointGeometry(-d,-d);case"left":return new r.pointGeometry(m,0);case"right":return new r.pointGeometry(-m,0)}return new r.pointGeometry(0,0)}return m instanceof r.pointGeometry||Array.isArray(m)?r.pointGeometry.convert(m):r.pointGeometry.convert(m[o]||[0,0])}const ks={version:r.version,supported:v,setRTLTextPlugin:r.setRTLTextPlugin,getRTLTextPluginStatus:r.getRTLTextPluginStatus,Map:class extends ap{constructor(m){if((m=r.extend({},sp,m)).minZoom!=null&&m.maxZoom!=null&&m.minZoom>m.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(m.minPitch!=null&&m.maxPitch!=null&&m.minPitch>m.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(m.minPitch!=null&&m.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(m.maxPitch!=null&&m.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(m.antialias&&r.isSafariWithAntialiasingBug(r.window)&&(m.antialias=!1,r.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Iu(m.minZoom,m.maxZoom,m.minPitch,m.maxPitch,m.renderWorldCopies),m),this._interactive=m.interactive,this._minTileCacheSize=m.minTileCacheSize,this._maxTileCacheSize=m.maxTileCacheSize,this._failIfMajorPerformanceCaveat=m.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=m.preserveDrawingBuffer,this._antialias=m.antialias,this._trackResize=m.trackResize,this._bearingSnap=m.bearingSnap,this._refreshExpiredTiles=m.refreshExpiredTiles,this._fadeDuration=m.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=m.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=m.collectResourceTiming,this._optimizeForTerrain=m.optimizeForTerrain,this._renderTaskQueue=new wg,this._domRenderTaskQueue=new wg,this._controls=[],this._markers=[],this._mapId=r.uniqueId(),this._locale=r.extend({},lv,m.locale),this._clickTolerance=m.clickTolerance,this._cooperativeGestures=m.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new sv(0),this._explicitProjection=null,this._requestManager=new r.RequestManager(m.transformRequest,m.accessToken,m.testMode),this._silenceAuthErrors=!!m.testMode,typeof m.container=="string"){if(this._container=r.window.document.getElementById(m.container),!this._container)throw new Error(`Container '${m.container}' not found.`)}else{if(!(m.container instanceof r.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=m.container}if(this._container.childNodes.length>0&&r.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."),m.maxBounds&&this.setMaxBounds(m.maxBounds),r.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)),r.window!==void 0&&(r.window.addEventListener("online",this._onWindowOnline,!1),r.window.addEventListener("resize",this._onWindowResize,!1),r.window.addEventListener("orientationchange",this._onWindowResize,!1),r.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new xg(this,m),this._localFontFamily=m.localFontFamily,this._localIdeographFontFamily=m.localIdeographFontFamily,m.style&&this.setStyle(m.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),m.projection&&this.setProjection(m.projection),this._hash=m.hash&&new eg(typeof m.hash=="string"&&m.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:m.center,zoom:m.zoom,bearing:m.bearing,pitch:m.pitch}),m.bounds&&(this.resize(),this.fitBounds(m.bounds,r.extend({},m.fitBoundsOptions,{duration:0})))),this.resize(),m.attributionControl&&this.addControl(new Ou({customAttribution:m.customAttribution})),this._logoControl=new bg,this.addControl(this._logoControl,m.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",o=>{this._update(o.dataType==="style"),this.fire(new r.Event(`${o.dataType}data`,o))}),this.on("dataloading",o=>{this.fire(new r.Event(`${o.dataType}dataloading`,o))})}_getMapId(){return this._mapId}addControl(m,o){if(o===void 0&&(o=m.getDefaultPosition?m.getDefaultPosition():"top-right"),!m||!m.onAdd)return this.fire(new r.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=m.onAdd(this);this._controls.push(m);const y=this._controlPositions[o];return o.indexOf("bottom")!==-1?y.insertBefore(d,y.firstChild):y.appendChild(d),this}removeControl(m){if(!m||!m.onRemove)return this.fire(new r.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const o=this._controls.indexOf(m);return o>-1&&this._controls.splice(o,1),m.onRemove(this),this}hasControl(m){return this._controls.indexOf(m)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(m){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 o=!this._moving;return o&&this.fire(new r.Event("movestart",m)).fire(new r.Event("move",m)),this.fire(new r.Event("resize",m)),o&&this.fire(new r.Event("moveend",m)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(m){return this.transform.setMaxBounds(r.LngLatBounds.convert(m)),this._update()}setMinZoom(m){if((m=m==null?-2:m)>=-2&&m<=this.transform.maxZoom)return this.transform.minZoom=m,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=m,this._update(),this.getZoom()>m?this.setZoom(m):this.fire(new r.Event("zoomstart")).fire(new r.Event("zoom")).fire(new r.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(m){if((m=m==null?0:m)<0)throw new Error("minPitch must be greater than or equal to 0");if(m>=0&&m<=this.transform.maxPitch)return this.transform.minPitch=m,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(m>=this.transform.minPitch)return this.transform.maxPitch=m,this._update(),this.getPitch()>m?this.setPitch(m):this.fire(new r.Event("pitchstart")).fire(new r.Event("pitch")).fire(new r.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(m){return this.transform.renderWorldCopies=m,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(m){return this._lazyInitEmptyStyle(),m?typeof m=="string"&&(m={name:m}):m=null,this._updateProjection(m)}_updateProjection(m){m===null&&(this._explicitProjection=null);const o=m||this.getProjection(),d=this.transform.setProjection(o);if(m&&(this._explicitProjection=this.transform.getProjection()),d){this.painter.clearBackgroundTiles();for(const y in this.style._sourceCaches)this.style._sourceCaches[y].clearTiles();this.style.applyProjectionUpdate(),this._update(!0)}return this}project(m){return this.transform.locationPoint3D(r.LngLat.convert(m))}unproject(m){return this.transform.pointLocation3D(r.pointGeometry.convert(m))}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(m,o,d){if(m==="mouseenter"||m==="mouseover"){let y=!1;const E=S=>{const k=o.filter(U=>this.getLayer(U)),O=k.length?this.queryRenderedFeatures(S.point,{layers:k}):[];O.length?y||(y=!0,d.call(this,new Ir(m,this,S.originalEvent,{features:O}))):y=!1},C=()=>{y=!1};return{layers:new Set(o),listener:d,delegates:{mousemove:E,mouseout:C}}}if(m==="mouseleave"||m==="mouseout"){let y=!1;const E=S=>{const k=o.filter(O=>this.getLayer(O));(k.length?this.queryRenderedFeatures(S.point,{layers:k}):[]).length?y=!0:y&&(y=!1,d.call(this,new Ir(m,this,S.originalEvent)))},C=S=>{y&&(y=!1,d.call(this,new Ir(m,this,S.originalEvent)))};return{layers:new Set(o),listener:d,delegates:{mousemove:E,mouseout:C}}}{const y=E=>{const C=o.filter(k=>this.getLayer(k)),S=C.length?this.queryRenderedFeatures(E.point,{layers:C}):[];S.length&&(E.features=S,d.call(this,E),delete E.features)};return{layers:new Set(o),listener:d,delegates:{[m]:y}}}}on(m,o,d){if(d===void 0)return super.on(m,o);Array.isArray(o)||(o=[o]);const y=this._createDelegatedListener(m,o,d);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[m]=this._delegatedListeners[m]||[],this._delegatedListeners[m].push(y);for(const E in y.delegates)this.on(E,y.delegates[E]);return this}once(m,o,d){if(d===void 0)return super.once(m,o);Array.isArray(o)||(o=[o]);const y=this._createDelegatedListener(m,o,d);for(const E in y.delegates)this.once(E,y.delegates[E]);return this}off(m,o,d){if(d===void 0)return super.off(m,o);o=new Set(Array.isArray(o)?o:[o]);const y=(C,S)=>{if(C.size!==S.size)return!1;for(const k of C)if(!S.has(k))return!1;return!0},E=this._delegatedListeners?this._delegatedListeners[m]:void 0;return E&&(C=>{for(let S=0;S{E?this.fire(new r.ErrorEvent(E)):C&&this._updateDiff(C,o)})}else typeof m=="object"&&this._updateDiff(m,o)}_updateDiff(m,o){try{this.style.setState(m)&&this._update(!0)}catch(d){r.warnOnce(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(m,o)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(r.warnOnce("There is no style added to the map."),!1)}addSource(m,o){return this._lazyInitEmptyStyle(),this.style.addSource(m,o),this._update(!0)}isSourceLoaded(m){return!!this.style&&this.style._isSourceCacheLoaded(m)}areTilesLoaded(){const m=this.style&&this.style._sourceCaches;for(const o in m){const d=m[o]._tiles;for(const y in d){const E=d[y];if(E.state!=="loaded"&&E.state!=="errored")return!1}}return!0}addSourceType(m,o,d){this._lazyInitEmptyStyle(),this.style.addSourceType(m,o,d)}removeSource(m){return this.style.removeSource(m),this._updateTerrain(),this._update(!0)}getSource(m){return this.style.getSource(m)}addImage(m,o,{pixelRatio:d=1,sdf:y=!1,stretchX:E,stretchY:C,content:S}={}){if(this._lazyInitEmptyStyle(),o instanceof r.window.HTMLImageElement||r.window.ImageBitmap&&o instanceof r.window.ImageBitmap){const{width:k,height:O,data:U}=r.exported.getImageData(o);this.style.addImage(m,{data:new r.RGBAImage({width:k,height:O},U),pixelRatio:d,stretchX:E,stretchY:C,content:S,sdf:y,version:0})}else if(o.width===void 0||o.height===void 0)this.fire(new r.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:k,height:O}=o,U=o;this.style.addImage(m,{data:new r.RGBAImage({width:k,height:O},new Uint8Array(U.data)),pixelRatio:d,stretchX:E,stretchY:C,content:S,sdf:y,version:0,userImage:U}),U.onAdd&&U.onAdd(this,m)}}updateImage(m,o){const d=this.style.getImage(m);if(!d)return void this.fire(new r.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const y=o instanceof r.window.HTMLImageElement||r.window.ImageBitmap&&o instanceof r.window.ImageBitmap?r.exported.getImageData(o):o,{width:E,height:C}=y;E!==void 0&&C!==void 0?E===d.data.width&&C===d.data.height?(d.data.replace(y.data,!(o instanceof r.window.HTMLImageElement||r.window.ImageBitmap&&o instanceof r.window.ImageBitmap)),this.style.updateImage(m,d)):this.fire(new r.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 r.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(m){return m?!!this.style.getImage(m):(this.fire(new r.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(m){this.style.removeImage(m)}loadImage(m,o){r.getImage(this._requestManager.transformRequest(m,r.ResourceType.Image),(d,y)=>{o(d,y instanceof r.window.HTMLImageElement?r.exported.getImageData(y):y)})}listImages(){return this.style.listImages()}addLayer(m,o){return this._lazyInitEmptyStyle(),this.style.addLayer(m,o),this._update(!0)}moveLayer(m,o){return this.style.moveLayer(m,o),this._update(!0)}removeLayer(m){return this.style.removeLayer(m),this._update(!0)}getLayer(m){return this.style.getLayer(m)}setLayerZoomRange(m,o,d){return this.style.setLayerZoomRange(m,o,d),this._update(!0)}setFilter(m,o,d={}){return this.style.setFilter(m,o,d),this._update(!0)}getFilter(m){return this.style.getFilter(m)}setPaintProperty(m,o,d,y={}){return this.style.setPaintProperty(m,o,d,y),this._update(!0)}getPaintProperty(m,o){return this.style.getPaintProperty(m,o)}setLayoutProperty(m,o,d,y={}){return this.style.setLayoutProperty(m,o,d,y),this._update(!0)}getLayoutProperty(m,o){return this.style.getLayoutProperty(m,o)}setLight(m,o={}){return this._lazyInitEmptyStyle(),this.style.setLight(m,o),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(m){return this._lazyInitEmptyStyle(),!m&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(m),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(m){return this._lazyInitEmptyStyle(),this.style.setFog(m),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(m){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(r.LngLat.convert(m),this.transform):0}setFeatureState(m,o){return this.style.setFeatureState(m,o),this._update()}removeFeatureState(m,o){return this.style.removeFeatureState(m,o),this._update()}getFeatureState(m){return this.style.getFeatureState(m)}_updateContainerDimensions(){if(!this._container)return;const m=this._container.getBoundingClientRect().width||400,o=this._container.getBoundingClientRect().height||300;let d,y,E,C=this._container;for(;C&&(!y||!E);){const S=r.window.getComputedStyle(C).transform;S&&S!=="none"&&(d=S.match(/matrix.*\((.+)\)/)[1].split(", "),d[0]&&d[0]!=="0"&&d[0]!=="1"&&(y=d[0]),d[3]&&d[3]!=="0"&&d[3]!=="1"&&(E=d[3])),C=C.parentElement}this._containerWidth=y?Math.abs(m/y):m,this._containerHeight=E?Math.abs(o/E):o}_detectMissingCSS(){r.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&r.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 m=this._container;m.classList.add("mapboxgl-map"),(this._missingCSSCanary=A("div","mapboxgl-canary",m)).style.visibility="hidden",this._detectMissingCSS();const o=this._canvasContainer=A("div","mapboxgl-canvas-container",m);this._interactive&&o.classList.add("mapboxgl-interactive"),this._canvas=A("canvas","mapboxgl-canvas",o),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 d=this._controlContainer=A("div","mapboxgl-control-container",m),y=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(E=>{y[E]=A("div",`mapboxgl-ctrl-${E}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(m,o){const d=r.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(m),this._canvas.height=d*Math.ceil(o),this._canvas.style.width=`${m}px`,this._canvas.style.height=`${o}px`}_addMarker(m){this._markers.push(m)}_removeMarker(m){const o=this._markers.indexOf(m);o!==-1&&this._markers.splice(o,1)}_setupPainter(){const m=r.extend({},v.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._canvas.getContext("webgl",m)||this._canvas.getContext("experimental-webgl",m);o?(r.storeAuthState(o,!0),this.painter=new Jm(o,this.transform),this.on("data",d=>{d.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),r.exported$1.testSupport(o)):this.fire(new r.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(m){m.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new r.Event("webglcontextlost",{originalEvent:m}))}_contextRestored(m){this._setupPainter(),this.resize(),this._update(),this.fire(new r.Event("webglcontextrestored",{originalEvent:m}))}_onMapScroll(m){if(m.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(m){return this.style?(this._styleDirty=this._styleDirty||m,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(m){return this._update(),this._renderTaskQueue.add(m)}_cancelRenderFrame(m){this._renderTaskQueue.remove(m)}_requestDomTask(m){!this.loaded()||this.loaded()&&!this.isMoving()?m():this._domRenderTaskQueue.add(m)}_render(m){let o;const d=this.painter.context.extTimerQuery,y=r.exported.now();if(this.listens("gpu-timing-frame")&&(o=d.createQueryEXT(),d.beginQueryEXT(d.TIME_ELAPSED_EXT,o)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(m),this._domRenderTaskQueue.run(m),this._removed)return;let E=!1;const C=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const O=this.transform.zoom,U=this.transform.pitch,G=r.exported.now();this.style.zoomHistory.update(O,G);const Z=new r.EvaluationParameters(O,{now:G,fadeDuration:C,pitch:U,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),se=Z.crossFadingFactor();se===1&&se===this._crossFadingFactor||(E=!0,this._crossFadingFactor=se),this.style.update(Z)}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(y),this.style._updateSources(this.transform),this._forceMarkerUpdate()):S=this._updateAverageElevation(y),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,C,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:C,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new r.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new r.Event("load"))),this.style&&(this.style.hasTransitions()||E)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const O=r.exported.now()-y;d.endQueryEXT(d.TIME_ELAPSED_EXT,o),setTimeout(()=>{const U=d.getQueryObjectEXT(o,d.QUERY_RESULT_EXT)/1e6;d.deleteQueryEXT(o),this.fire(new r.Event("gpu-timing-frame",{cpuTime:O,gpuTime:U}))},50)}if(this.listens("gpu-timing-layer")){const O=this.painter.collectGpuTimers();setTimeout(()=>{const U=this.painter.queryGpuTimers(O);this.fire(new r.Event("gpu-timing-layer",{layerTimes:U}))},50)}const k=this._sourcesDirty||this._styleDirty||this._placementDirty||S;if(k||this._repaint)this.triggerRepaint();else{const O=!this.isMoving()&&this.loaded();if(O&&(S=this._updateAverageElevation(y,!0)),S)this.triggerRepaint();else if(this._triggerFrame(!1),O&&(this.fire(new r.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const U=this._calculateSpeedIndex();this.fire(new r.Event("speedindexcompleted",{speedIndex:U})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||k||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const m of this._markers)m._update()}_updateAverageElevation(m,o=!1){const d=y=>(this.transform.averageElevation=y,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&d(0);if((o||m-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(m)){const y=this.transform.averageElevation;let E=this.transform.sampleAverageElevation(),C=!1;this.transform.elevation&&(C=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(E)?E=0:this._averageElevationLastSampledAt=m;const S=Math.abs(y-E);if(S>1){if(this._isInitialLoad||C)return this._averageElevation.jumpTo(E),d(E);this._averageElevation.easeTo(E,m,300)}else if(S>1e-4)return this._averageElevation.jumpTo(E),d(E)}return!!this._averageElevation.isEasing(m)&&d(this._averageElevation.getValue(m))}_authenticate(){r.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,m=>{if(m&&(m.message===r.AUTH_ERR_MSG||m.status===401)){const o=this.painter.context.gl;r.storeAuthState(o,!1),this._logoControl instanceof bg&&this._logoControl._updateLogo(),o&&o.clear(o.DEPTH_BUFFER_BIT|o.COLOR_BUFFER_BIT|o.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new r.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/")))}}),r.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const m=this.painter.canvasCopy(),o=this.painter.getCanvasCopiesAndTimestamps();o.timeStamps.push(performance.now());const d=this.painter.context.gl,y=d.createFramebuffer();function E(C){d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,C,0);const S=new Uint8Array(d.drawingBufferWidth*d.drawingBufferHeight*4);return d.readPixels(0,0,d.drawingBufferWidth,d.drawingBufferHeight,d.RGBA,d.UNSIGNED_BYTE,S),S}return d.bindFramebuffer(d.FRAMEBUFFER,y),this._canvasPixelComparison(E(m),o.canvasCopies.map(E),o.timeStamps)}_canvasPixelComparison(m,o,d){let y=d[1]-d[0];const E=m.length/4;for(let C=0;C{const d=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,d&&this._render(o)}))}_preloadTiles(m){const o=this.style?Object.values(this.style._sourceCaches):[];return r.asyncAll(o,(d,y)=>d._preloadTiles(m,y),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(m){this._trackResize&&this.resize({originalEvent:m})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(m){this._showTileBoundaries!==m&&(this._showTileBoundaries=m,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(m){this._showTerrainWireframe!==m&&(this._showTerrainWireframe=m,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(m){this._speedIndexTiming!==m&&(this._speedIndexTiming=m,this._update())}get showPadding(){return!!this._showPadding}set showPadding(m){this._showPadding!==m&&(this._showPadding=m,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(m){this._showCollisionBoxes!==m&&(this._showCollisionBoxes=m,m?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(m){this._showOverdrawInspector!==m&&(this._showOverdrawInspector=m,this._update())}get repaint(){return!!this._repaint}set repaint(m){this._repaint!==m&&(this._repaint=m,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(m){this._vertices=m,this._update()}_setCacheLimits(m,o){r.setCacheLimits(m,o)}get version(){return r.version}},NavigationControl:class{constructor(m){this.options=r.extend({},lp,m),this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",o=>o.preventDefault()),this.options.showZoom&&(r.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",o=>{this._map&&this._map.zoomIn({},{originalEvent:o})}),A("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",o=>{this._map&&this._map.zoomOut({},{originalEvent:o})}),A("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(r.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",o=>{const d=this._map;d&&(this.options.visualizePitch?d.resetNorthPitch({},{originalEvent:o}):d.resetNorth({},{originalEvent:o}))}),this._compassIcon=A("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const m=this._map;if(!m)return;const o=m.getZoom(),d=o===m.getMaxZoom(),y=o===m.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=y,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",y.toString())}_rotateCompassArrow(){const m=this._map;if(!m)return;const o=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(m.transform.pitch*(Math.PI/180)),.5)}) rotateX(${m.transform.pitch}deg) rotateZ(${m.transform.angle*(180/Math.PI)}deg)`:`rotate(${m.transform.angle*(180/Math.PI)}deg)`;m._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=o)})}onAdd(m){return this._map=m,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),m.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&m.on("pitch",this._rotateCompassArrow),m.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new cp(m,this._compass,this.options.visualizePitch)),this._container}onRemove(){const m=this._map;m&&(this._container.remove(),this.options.showZoom&&m.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&m.off("pitch",this._rotateCompassArrow),m.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(m,o){const d=A("button",m,this._container);return d.type="button",d.addEventListener("click",o),d}_setButtonTitle(m,o){if(!this._map)return;const d=this._map._getUIString(`NavigationControl.${o}`);m.setAttribute("aria-label",d),m.firstElementChild&&m.firstElementChild.setAttribute("title",d)}},GeolocateControl:class extends r.Evented{constructor(m){super(),this.options=r.extend({},_r,m),r.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Qd(this._updateMarkerRotation,20)}onAdd(m){var o;return this._map=m,this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-group"),o=this._setupUI,Rr!==void 0?o(Rr):r.window.navigator.permissions!==void 0?r.window.navigator.permissions.query({name:"geolocation"}).then(d=>{Rr=d.state!=="denied",o(Rr)}):(Rr=!!r.window.navigator.geolocation,o(Rr)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(r.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,jl=0,ja=!1}_isOutOfMapMaxBounds(m){const o=this._map.getMaxBounds(),d=m.coords;return!!o&&(d.longitudeo.getEast()||d.latitudeo.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(m){if(this._map){if(this._isOutOfMapMaxBounds(m))return this._setErrorState(),this.fire(new r.Event("outofmaxbounds",m)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=m,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(m),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(m),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new r.Event("geolocate",m)),this._finish()}}_updateCamera(m){const o=new r.LngLat(m.coords.longitude,m.coords.latitude),d=m.coords.accuracy,y=this._map.getBearing(),E=r.extend({bearing:y},this.options.fitBoundsOptions);this._map.fitBounds(o.toBounds(d),E,{geolocateSource:!0})}_updateMarker(m){if(m){const o=new r.LngLat(m.coords.longitude,m.coords.latitude);this._accuracyCircleMarker.setLngLat(o).addTo(this._map),this._userLocationDotMarker.setLngLat(o).addTo(this._map),this._accuracy=m.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const m=this._map._containerHeight/2,o=this._map.unproject([0,m]),d=this._map.unproject([100,m]),y=o.distanceTo(d)/100,E=Math.ceil(2*this._accuracy/y);this._circleElement.style.width=`${E}px`,this._circleElement.style.height=`${E}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(m){if(this._map){if(this.options.trackUserLocation)if(m.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 o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(m.code===3&&ja)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new r.Event("error",m)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(m){if(this._container.addEventListener("contextmenu",o=>o.preventDefault()),this._geolocateButton=A("button","mapboxgl-ctrl-geolocate",this._container),A("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",m===!1){r.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}else{const o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=A("div","mapboxgl-user-location"),this._dotElement.appendChild(A("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(A("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Vu({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=A("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Vu({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",o=>{o.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o.originalEvent&&o.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 r.Event("trackuserlocationend")))})}_onDeviceOrientation(m){this._userLocationDotMarker&&(m.webkitCompassHeading?this._heading=m.webkitCompassHeading:m.absolute===!0&&(this._heading=-1*m.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return r.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 r.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":jl--,ja=!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 r.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 r.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 m;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),jl++,jl>1?(m={maximumAge:6e5,timeout:0},ja=!0):(m=this.options.positionOptions,ja=!1),this._geolocationWatchID=r.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,m),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else r.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const m=()=>{r.window.addEventListener("ondeviceorientationabsolute"in r.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};r.window.DeviceMotionEvent!==void 0&&typeof r.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(o=>{o==="granted"&&m()}).catch(console.error):m()}_clearWatch(){r.window.navigator.geolocation.clearWatch(this._geolocationWatchID),r.window.removeEventListener("deviceorientation",this._onDeviceOrientation),r.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:Ou,ScaleControl:class{constructor(m){this.options=r.extend({},up,m),r.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Gu(this._map,this._container,this.options)}onAdd(m){return this._map=m,this._container=A("div","mapboxgl-ctrl mapboxgl-ctrl-scale",m.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(m){this.options.unit=m,Gu(this._map,this._container,this.options)}},FullscreenControl:class{constructor(m){this._fullscreen=!1,m&&m.container&&(m.container instanceof r.window.HTMLElement?this._container=m.container:r.warnOnce("Full screen control 'container' must be a DOM element.")),r.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in r.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in r.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(m){return this._map=m,this._container||(this._container=this._map.getContainer()),this._controlContainer=A("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",r.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,r.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!r.window.document.fullscreenEnabled&&!r.window.document.webkitFullscreenEnabled)}_setupUI(){const m=this._fullscreenButton=A("button","mapboxgl-ctrl-fullscreen",this._controlContainer);A("span","mapboxgl-ctrl-icon",m).setAttribute("aria-hidden","true"),m.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),r.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const m=this._getTitle();this._fullscreenButton.setAttribute("aria-label",m),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",m)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(r.window.document.fullscreenElement||r.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()?r.window.document.exitFullscreen?r.window.document.exitFullscreen():r.window.document.webkitCancelFullScreen&&r.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends r.Evented{constructor(m){super(),this.options=r.extend(Object.create(qr),m),r.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(m&&m.className?m.className.trim().split(/\s+/):[])}addTo(m){return this._map&&this.remove(),this._map=m,this.options.closeOnClick&&m.on("preclick",this._onClose),this.options.closeOnMove&&m.on("move",this._onClose),m.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(m.on("mousemove",this._onMouseEvent),m.on("mouseup",this._onMouseEvent),m._canvasContainer.classList.add("mapboxgl-track-pointer")):m.on("move",this._update),this.fire(new r.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const m=this._map;return m&&(m.off("move",this._update),m.off("move",this._onClose),m.off("preclick",this._onClose),m.off("click",this._onClose),m.off("remove",this.remove),m.off("mousemove",this._onMouseEvent),m.off("mouseup",this._onMouseEvent),m.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new r.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(m){this._lngLat=r.LngLat.convert(m),this._pos=null,this._trackPointer=!1,this._update();const o=this._map;return o&&(o.on("move",this._update),o.off("mousemove",this._onMouseEvent),o._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const m=this._map;return m&&(m.off("move",this._update),m.on("mousemove",this._onMouseEvent),m.on("drag",this._onMouseEvent),m._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(m){return this.setDOMContent(r.window.document.createTextNode(m))}setHTML(m){const o=r.window.document.createDocumentFragment(),d=r.window.document.createElement("body");let y;for(d.innerHTML=m;y=d.firstChild,y;)o.appendChild(y);return this.setDOMContent(o)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(m){return this.options.maxWidth=m,this._update(),this}setDOMContent(m){let o=this._content;if(o)for(;o.hasChildNodes();)o.firstChild&&o.removeChild(o.firstChild);else o=this._content=A("div","mapboxgl-popup-content",this._container||void 0);if(o.appendChild(m),this.options.closeButton){const d=this._closeButton=A("button","mapboxgl-popup-close-button",o);d.type="button",d.setAttribute("aria-label","Close popup"),d.setAttribute("aria-hidden","true"),d.innerHTML="×",d.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(m){return this._classList.add(m),this._updateClassList(),this}removeClassName(m){return this._classList.delete(m),this._updateClassList(),this}setOffset(m){return this.options.offset=m,this._update(),this}toggleClassName(m){let o;return this._classList.delete(m)?o=!1:(this._classList.add(m),o=!0),this._updateClassList(),o}_onMouseEvent(m){this._update(m.point)}_getAnchor(m){if(this.options.anchor)return this.options.anchor;const o=this._map,d=this._container,y=this._pos;if(!o||!d||!y)return"bottom";const E=d.offsetWidth,C=d.offsetHeight,S=y.xo.transform.width-E/2;if(y.y+mo.transform.height-C){if(S)return"bottom-left";if(k)return"bottom-right"}return S?"left":k?"right":"bottom"}_updateClassList(){const m=this._container;if(!m)return;const o=[...this._classList];o.push("mapboxgl-popup"),this._anchor&&o.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&o.push("mapboxgl-popup-track-pointer"),m.className=o.join(" ")}_update(m){const o=this._map,d=this._content;if(!o||!this._lngLat&&!this._trackPointer||!d)return;let y=this._container;if(y||(y=this._container=A("div","mapboxgl-popup",o.getContainer()),this._tip=A("div","mapboxgl-popup-tip",y),y.appendChild(d)),this.options.maxWidth&&y.style.maxWidth!==this.options.maxWidth&&(y.style.maxWidth=this.options.maxWidth),o.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Nu(this._lngLat,this._pos,o.transform)),!this._trackPointer||m){const E=this._pos=this._trackPointer&&m?m:o.project(this._lngLat),C=Hl(this.options.offset),S=this._anchor=this._getAnchor(C.y),k=Hl(this.options.offset,S),O=E.add(k).round();o._requestDomTask(()=>{this._container&&S&&(this._container.style.transform=`${Uu[S]} translate(${O.x}px,${O.y}px)`)})}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const m=this._container.querySelector(ci);m&&m.focus()}_onClose(){this.remove()}_setOpacity(m){this._content&&(this._content.style.opacity=m),this._tip&&(this._tip.style.opacity=m)}},Marker:Vu,Style:yr,LngLat:r.LngLat,LngLatBounds:r.LngLatBounds,Point:r.pointGeometry,MercatorCoordinate:r.MercatorCoordinate,FreeCameraOptions:kl,Evented:r.Evented,config:r.config,prewarm:function(){Fe().acquire(_n)},clearPrewarmedResources:function(){const m=re;m&&(m.isPreloaded()&&m.numActive()===1?(m.release(_n),re=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 r.config.ACCESS_TOKEN},set accessToken(m){r.config.ACCESS_TOKEN=m},get baseApiUrl(){return r.config.API_URL},set baseApiUrl(m){r.config.API_URL=m},get workerCount(){return Y.workerCount},set workerCount(m){Y.workerCount=m},get maxParallelImageRequests(){return r.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(m){r.config.MAX_PARALLEL_IMAGE_REQUESTS=m},clearStorage(m){r.clearTileCache(m)},workerUrl:"",workerClass:null,setNow:r.exported.setNow,restoreNow:r.exported.restoreNow};return ks});var f=c;return f})})(lb);var LR=lb.exports;const IR=Z1(LR),su={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 RR(e){const t="./gis/radar.tiff";console.log(t);let i=(114.06825863001939-104.18084906665138)*.005,l=(32.396413467808586-22.54283198132819)*.005,c=114.07867152431874,h=22.563727343812303;e.addSource("radar",{type:"image",url:t,coordinates:[[c-i*.5,h+l*.5],[c+i*.5,h+l*.5],[c+i*.5,h-l*.5],[c-i*.5,h-l*.5]]}),e.addLayer({id:"radar-layer",type:"raster",source:"radar",paint:{"raster-fade-duration":0}})}function kR(e){var t="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:[t],tileSize:256}),e.addLayer({id:"wmts-layer",type:"raster",source:"wmts-source",paint:{"raster-opacity":.95}})}function zR(){return{TianDiTu:{Normal:{Map:"http://t{s}.tianditu.com/DataServer?T=vec_w&X={x}&Y={y}&L={z}&tk={key}",Annotion:"http://t{s}.tianditu.com/DataServer?T=cva_w&X={x}&Y={y}&L={z}&tk={key}",minzoom:0,maxzoom:18},Satellite:{Map:"http://t{s}.tianditu.com/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk={key}",Annotion:"http://t{s}.tianditu.com/DataServer?T=cia_w&X={x}&Y={y}&L={z}&tk={key}",minzoom:0,maxzoom:18},Terrain:{Map:"http://t{s}.tianditu.com/DataServer?T=ter_w&X={x}&Y={y}&L={z}&tk={key}",Annotion:"http://t{s}.tianditu.com/DataServer?T=cta_w&X={x}&Y={y}&L={z}&tk={key}",minzoom:0,maxzoom:14},Subdomains:["0","1","2","3","4","5","6","7"],key:""},GaoDe:{Normal:{Map:"http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",minzoom:0,maxzoom:18},Normal_NoTag:{Map:"https://wprd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&scl=1<ype=11&x={x}&y={y}&z={z}",minzoom:3,maxzoom:18},Satellite:{Map:"http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",Annotion:"http://webst0{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}",minzoom:3,maxzoom:18},Subdomains:["1","2","3","4"]},Baidu:{Normal:{Map:"http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&scaler=1&p=1"},Satellite:{Map:"http://shangetu{s}.map.bdimg.com/it/u=x={x};y={y};z={z};v=009;type=sate&fm=46",Annotion:"http://online{s}.map.bdimg.com/tile/?qt=tile&x={x}&y={y}&z={z}&styles=sl&v=020"},Subdomains:"0123456789",tileType:"bd09"},Geoq:{Normal:{Map:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}",PurplishBlue:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}",Gray:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServer/tile/{z}/{y}/{x}",Warm:"http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer/tile/{z}/{y}/{x}",minzoom:3,maxzoom:16},Subdomains:[]},OSM:{Normal:{Map:"http://{s}.tile.osm.org/{z}/{x}/{y}.png",minzoom:0,maxzoom:18},Subdomains:["a","b","c"]}}}function FR(){return["https://0pn.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}","https://0pn.cn/maps/vt?lyrs=s,m&gl=CN&x={x}&y={y}&z={z}"]}let Td,Ro;function BR(e){Td.on("click",function(t){return Qe(this,null,function*(){let{lng:i,lat:l}=t.lngLat;if(e){let f=M.mx_gcj02_To_gps84(i,l);i=f.lng,l=f.lat}console.log("经纬度坐标:",JSON.stringify([i,l]));let c=IR.MercatorCoordinate.fromLngLat([i,l],0);console.log("墨卡托坐标:",JSON.stringify(Ro.map_lnglat_to_meters(i,l)));let h=Ro.mercatorCoord2CAD(c.x,c.y);console.log("CAD坐标:",JSON.stringify(h))})})}let Ed=!1,Sm=!0;Sm=!1,Sm&&(Ed=!1);function OR(){let e=new M.MxCADPluginMapDefaultData;e.cadOrigin=[116275.977014,19273.279085],e.mapOrigin=[114.06825863001939,22.54283198132819],e.meterInCADUnits=1,e.openFile="./demo/road.dwg.mxweb";let t=X.MxFun.getQueryString("maptype");if(!Sm)if(t=="google"){let i=M.mx_gps84_To_gcj02(e.mapOrigin[0],e.mapOrigin[1]);e.mapOrigin=[i.lng,i.lat],Ed=!0,e.viewColor={red:0,green:0,blue:0}}else{let i=su.gdslwzj();t=="gdslwzj"?i=su.gdslwzj():t=="gdyx"?i=su.gdyx():t=="tdtsl"?i=su.tdtsl():t=="bdsl"?i=su.bdsl():t=="geoq"&&(i=su.geoq()),e.rasterTileLayerList=i.layers,i.key&&(e.rasterTileKey=i.key),e.providers=zR()}return e}function NR(e){Ro=e,Td=e.getMapbox(),Ed&&M.MxMapAddGoogleCnLayer(Td,["Image","Lable"],FR()),BR(Ed),Sm?kR(Td):RR(Td)}function UR(){return Qe(this,null,function*(){let e=new M.MxCADUiPrPoint;e.setMessage(` 指定下载范围第一点:`);let t=yield e.go();if(!t)return;e.setMessage(` 指定下载范围第二点:`),e.setUserDraw((x,w)=>{w.setColor(16711680);let b=new M.McDbPolyline;b.addVertexAt(t),b.addVertexAt(new M.McGePoint3d(t.x,x.y)),b.addVertexAt(x),b.addVertexAt(new M.McGePoint3d(x.x,t.y)),b.constantWidth=X.MxFun.screenCoordLong2Doc(2),b.isClosed=!0,w.drawMcDbEntity(b);let A=[];A.push(t.toVector3()),A.push(new THREE.Vector3(t.x,x.y)),A.push(x.toVector3()),A.push(new THREE.Vector3(x.x,t.y)),w.setColor(12868),w.drawSolid(A,.5)}),e.setDisableOsnap(!0),e.setDisableOrthoTrace(!0),e.setDynamicInputType(X.DynamicInputType.kXYCoordInput);let i=yield e.go();if(!i)return;let l=Ro.cadTolnglat(t.toVector3()),c=Ro.cadTolnglat(i.toVector3()),h=Ro.map_lnglat_to_meters(l[0],l[1]),f=Ro.map_lnglat_to_meters(c[0],c[1]);if(Ed&&!(Ro.outOfChina(l[0],l[1])&&Ro.outOfChina(c[0],c[1]))){let x=M.mx_gcj02_To_gps84(l[0],l[1]),w=M.mx_gcj02_To_gps84(c[0],c[1]);h=Ro.map_lnglat_to_meters(x.lng,x.lat),f=Ro.map_lnglat_to_meters(w.lng,w.lat)}let r={url:"https://0pn.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",polygon:[h[0],h[1],f[0],f[1]],zoom:18,auto_close:!1,no_repeated_download:!0,download_dir:"",thread_count:32};X.MxFun.acutPrintf(` 使用教程:https://help.mxdraw.com/?pid=111`),X.MxFun.acutPrintf(` 复制下面的范围,到下载器下载地图,下载范围:`);let v=` `+JSON.stringify([h[0],h[1],f[0],f[1]]);X.MxFun.acutPrintf(v),X.MxFun.acutPrintf(` `),Wp({method:"post",url:"http://localhost:1337/users/mxgis/download",data:r}).then(x=>{console.log(x.data),alert(JSON.stringify(x.data))}).catch(x=>{console.log("网络错误")})})}window._iconfont_svg_string_4337873='',function(e){var i=(i=document.getElementsByTagName("script"))[i.length-1],t=i.getAttribute("data-injectcss"),i=i.getAttribute("data-disable-injectsvg");if(!i){var l,c,h,f,r,v=function(b,A){A.parentNode.insertBefore(b,A)};if(t&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(b){console&&console.log(b)}}l=function(){var b,A=document.createElement("div");A.innerHTML=e._iconfont_svg_string_4337873,(A=A.getElementsByTagName("svg")[0])&&(A.setAttribute("aria-hidden","true"),A.style.position="absolute",A.style.width=0,A.style.height=0,A.style.overflow="hidden",A=A,(b=document.body).firstChild?v(A,b.firstChild):b.appendChild(A))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(c=function(){document.removeEventListener("DOMContentLoaded",c,!1),l()},document.addEventListener("DOMContentLoaded",c,!1)):document.attachEvent&&(h=l,f=e.document,r=!1,w(),f.onreadystatechange=function(){f.readyState=="complete"&&(f.onreadystatechange=null,x())})}function x(){r||(r=!0,h())}function w(){try{f.documentElement.doScroll("left")}catch(b){return void setTimeout(w,50)}x()}}(window),window._iconfont_svg_string_4604696='',function(e){var i=(i=document.getElementsByTagName("script"))[i.length-1],t=i.getAttribute("data-injectcss"),i=i.getAttribute("data-disable-injectsvg");if(!i){var l,c,h,f,r,v=function(b,A){A.parentNode.insertBefore(b,A)};if(t&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(b){console&&console.log(b)}}l=function(){var b,A=document.createElement("div");A.innerHTML=e._iconfont_svg_string_4604696,(A=A.getElementsByTagName("svg")[0])&&(A.setAttribute("aria-hidden","true"),A.style.position="absolute",A.style.width=0,A.style.height=0,A.style.overflow="hidden",A=A,(b=document.body).firstChild?v(A,b.firstChild):b.appendChild(A))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(l,0):(c=function(){document.removeEventListener("DOMContentLoaded",c,!1),l()},document.addEventListener("DOMContentLoaded",c,!1)):document.attachEvent&&(h=l,f=e.document,r=!1,w(),f.onreadystatechange=function(){f.readyState=="complete"&&(f.onreadystatechange=null,x())})}function x(){r||(r=!0,h())}function w(){try{f.documentElement.doScroll("left")}catch(b){return void setTimeout(w,50)}x()}}(window);var VR=function(){function e(Ie){ri.call(this,Ie),this.dracoLoader=null,this.ddsLoader=null}e.prototype=Object.assign(Object.create(ri.prototype),{constructor:e,load:function(Ie,be,We,Ge){var ke=this,ot;this.resourcePath!==""?ot=this.resourcePath:this.path!==""?ot=this.path:ot=dl.extractUrlBase(Ie),ke.manager.itemStart(Ie);var ge=function(Ae){Ge?Ge(Ae):console.error(Ae),ke.manager.itemError(Ie),ke.manager.itemEnd(Ie)},Ce=new xo(ke.manager);Ce.setPath(this.path),Ce.setResponseType("arraybuffer"),ke.crossOrigin==="use-credentials"&&Ce.setWithCredentials(!0),Ce.load(Ie,function(Ae){try{ke.parse(Ae,ot,function(_e){be(_e),ke.manager.itemEnd(Ie)},ge)}catch(_e){ge(_e)}},We,ge)},setDRACOLoader:function(Ie){return this.dracoLoader=Ie,this},setDDSLoader:function(Ie){return this.ddsLoader=Ie,this},parse:function(Ie,be,We,Ge){var ke,ot={};if(typeof Ie=="string")ke=Ie;else{var ge=dl.decodeText(new Uint8Array(Ie,0,4));if(ge===f){try{ot[i.KHR_BINARY_GLTF]=new x(Ie)}catch(ct){Ge&&Ge(ct);return}ke=ot[i.KHR_BINARY_GLTF].content}else ke=dl.decodeText(new Uint8Array(Ie))}var Ce=JSON.parse(ke);if(Ce.asset===void 0||Ce.asset.version[0]<2){Ge&&Ge(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}if(Ce.extensionsUsed)for(var Ae=0;Ae=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_e+'".')}}var Je=new yt(Ce,ot,{path:be||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager});Je.parse(We,Ge)}});function t(){var Ie={};return{get:function(be){return Ie[be]},add:function(be,We){Ie[be]=We},remove:function(be){delete Ie[be]},removeAll:function(){Ie={}}}}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(Ie){if(!Ie)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=i.MSFT_TEXTURE_DDS,this.ddsLoader=Ie}function c(Ie){this.name=i.KHR_LIGHTS_PUNCTUAL;var be=Ie.extensions&&Ie.extensions[i.KHR_LIGHTS_PUNCTUAL]||{};this.lightDefs=be.lights||[]}c.prototype.loadLight=function(Ie){var be=this.lightDefs[Ie],We,Ge=new tn(16777215);be.color!==void 0&&Ge.fromArray(be.color);var ke=be.range!==void 0?be.range:0;switch(be.type){case"directional":We=new am(Ge),We.target.position.set(0,0,-1),We.add(We.target);break;case"point":We=new om(Ge),We.distance=ke;break;case"spot":We=new rm(Ge),We.distance=ke,be.spot=be.spot||{},be.spot.innerConeAngle=be.spot.innerConeAngle!==void 0?be.spot.innerConeAngle:0,be.spot.outerConeAngle=be.spot.outerConeAngle!==void 0?be.spot.outerConeAngle:Math.PI/4,We.angle=be.spot.outerConeAngle,We.penumbra=1-be.spot.innerConeAngle/be.spot.outerConeAngle,We.target.position.set(0,0,-1),We.add(We.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+be.type+'".')}return We.position.set(0,0,0),We.decay=2,be.intensity!==void 0&&(We.intensity=be.intensity),We.name=be.name||"light_"+Ie,Promise.resolve(We)};function h(){this.name=i.KHR_MATERIALS_UNLIT}h.prototype.getMaterialType=function(){return cr},h.prototype.extendParams=function(Ie,be,We){var Ge=[];Ie.color=new tn(1,1,1),Ie.opacity=1;var ke=be.pbrMetallicRoughness;if(ke){if(Array.isArray(ke.baseColorFactor)){var ot=ke.baseColorFactor;Ie.color.fromArray(ot),Ie.opacity=ot[3]}ke.baseColorTexture!==void 0&&Ge.push(We.assignTexture(Ie,"map",ke.baseColorTexture))}return Promise.all(Ge)};var f="glTF",r=12,v={JSON:1313821514,BIN:5130562};function x(Ie){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;var be=new DataView(Ie,0,r);if(this.header={magic:dl.decodeText(new Uint8Array(Ie.slice(0,4))),version:be.getUint32(4,!0),length:be.getUint32(8,!0)},this.header.magic!==f)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 We=new DataView(Ie,r),Ge=0;Ge",be),Ce.fragmentShader=Ce.fragmentShader.replace("#include ",We),Ce.fragmentShader=Ce.fragmentShader.replace("#include ",Ge),Ce.fragmentShader=Ce.fragmentShader.replace("#include ",ke),Ce.fragmentShader=Ce.fragmentShader.replace("#include ",ot)},Object.defineProperties(this,{specular:{get:function(){return ge.specular.value},set:function(Ce){ge.specular.value=Ce}},specularMap:{get:function(){return ge.specularMap.value},set:function(Ce){ge.specularMap.value=Ce}},glossiness:{get:function(){return ge.glossiness.value},set:function(Ce){ge.glossiness.value=Ce}},glossinessMap:{get:function(){return ge.glossinessMap.value},set:function(Ce){ge.glossinessMap.value=Ce,Ce?(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(Ie)}A.prototype=Object.create(Vr.prototype),A.prototype.constructor=A,A.prototype.copy=function(Ie){return Vr.prototype.copy.call(this,Ie),this.specularMap=Ie.specularMap,this.specular.copy(Ie.specular),this.glossinessMap=Ie.glossinessMap,this.glossiness=Ie.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function L(){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 A},extendParams:function(Ie,be,We){var Ge=be.extensions[this.name];Ie.color=new tn(1,1,1),Ie.opacity=1;var ke=[];if(Array.isArray(Ge.diffuseFactor)){var ot=Ge.diffuseFactor;Ie.color.fromArray(ot),Ie.opacity=ot[3]}if(Ge.diffuseTexture!==void 0&&ke.push(We.assignTexture(Ie,"map",Ge.diffuseTexture)),Ie.emissive=new tn(0,0,0),Ie.glossiness=Ge.glossinessFactor!==void 0?Ge.glossinessFactor:1,Ie.specular=new tn(1,1,1),Array.isArray(Ge.specularFactor)&&Ie.specular.fromArray(Ge.specularFactor),Ge.specularGlossinessTexture!==void 0){var ge=Ge.specularGlossinessTexture;ke.push(We.assignTexture(Ie,"glossinessMap",ge)),ke.push(We.assignTexture(Ie,"specularMap",ge))}return Promise.all(ke)},createMaterial:function(Ie){var be=new A(Ie);return be.fog=!0,be.color=Ie.color,be.map=Ie.map===void 0?null:Ie.map,be.lightMap=null,be.lightMapIntensity=1,be.aoMap=Ie.aoMap===void 0?null:Ie.aoMap,be.aoMapIntensity=1,be.emissive=Ie.emissive,be.emissiveIntensity=1,be.emissiveMap=Ie.emissiveMap===void 0?null:Ie.emissiveMap,be.bumpMap=Ie.bumpMap===void 0?null:Ie.bumpMap,be.bumpScale=1,be.normalMap=Ie.normalMap===void 0?null:Ie.normalMap,be.normalMapType=Ys,Ie.normalScale&&(be.normalScale=Ie.normalScale),be.displacementMap=null,be.displacementScale=1,be.displacementBias=0,be.specularMap=Ie.specularMap===void 0?null:Ie.specularMap,be.specular=Ie.specular,be.glossinessMap=Ie.glossinessMap===void 0?null:Ie.glossinessMap,be.glossiness=Ie.glossiness,be.alphaMap=null,be.envMap=Ie.envMap===void 0?null:Ie.envMap,be.envMapIntensity=1,be.refractionRatio=.98,be}}}function P(){this.name=i.KHR_MESH_QUANTIZATION}function R(Ie,be,We,Ge){Gr.call(this,Ie,be,We,Ge)}R.prototype=Object.create(Gr.prototype),R.prototype.constructor=R,R.prototype.copySampleValue_=function(Ie){for(var be=this.resultBuffer,We=this.sampleValues,Ge=this.valueSize,ke=Ie*Ge*3+Ge,ot=0;ot!==Ge;ot++)be[ot]=We[ke+ot];return be},R.prototype.beforeStart_=R.prototype.copySampleValue_,R.prototype.afterEnd_=R.prototype.copySampleValue_,R.prototype.interpolate_=function(Ie,be,We,Ge){for(var ke=this.resultBuffer,ot=this.sampleValues,ge=this.valueSize,Ce=ge*2,Ae=ge*3,_e=Ge-be,Ne=(We-be)/_e,Je=Ne*Ne,ct=Je*Ne,wt=Ie*Ae,Gt=wt-Ae,pe=-2*ct+3*Je,Me=ct-Je,bt=1-pe,gt=Me-Je+Ne,bn=0;bn!==ge;bn++){var hn=ot[Gt+bn+ge],nn=ot[Gt+bn+Ce]*_e,pn=ot[wt+bn+ge],wn=ot[wt+bn]*_e;ke[bn]=bt*hn+gt*nn+pe*pn+Me*wn}return ke};var F={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},V={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},j={9728:Ui,9729:$i,9984:Yp,9985:uy,9986:Kp,9987:oc},J={33071:Mr,33648:fh,10497:Zs},ne={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},H={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Q={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ae={CUBICSPLINE:void 0,LINEAR:sc,STEP:yh},ie={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},le={"image/png":Ao,"image/jpeg":Ma};function fe(Ie,be){return typeof Ie!="string"||Ie===""?"":(/^https?:\/\//i.test(be)&&/^\//.test(Ie)&&(be=be.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(Ie)||/^data:.*,.*$/i.test(Ie)||/^blob:.*$/i.test(Ie)?Ie:be+Ie)}function me(Ie){return Ie.DefaultMaterial===void 0&&(Ie.DefaultMaterial=new Vr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:nc})),Ie.DefaultMaterial}function he(Ie,be,We){for(var Ge in We.extensions)Ie[Ge]===void 0&&(be.userData.gltfExtensions=be.userData.gltfExtensions||{},be.userData.gltfExtensions[Ge]=We.extensions[Ge])}function Oe(Ie,be){be.extras!==void 0&&(typeof be.extras=="object"?Object.assign(Ie.userData,be.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+be.extras))}function Ve(Ie,be,We){for(var Ge=!1,ke=!1,ot=0,ge=be.length;ot=2&&pe.setY(Xt,cn[Wt*Ce+1]),Ce>=3&&pe.setZ(Xt,cn[Wt*Ce+2]),Ce>=4&&pe.setW(Xt,cn[Wt*Ce+3]),Ce>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return pe})},yt.prototype.loadTexture=function(Ie){var be=this,We=this.json,Ge=this.options,ke=this.textureLoader,ot=window.URL||window.webkitURL,ge=We.textures[Ie],Ce=ge.extensions||{},Ae;Ce[i.MSFT_TEXTURE_DDS]?Ae=We.images[Ce[i.MSFT_TEXTURE_DDS].source]:Ae=We.images[ge.source];var _e=Ae.uri,Ne=!1;return Ae.bufferView!==void 0&&(_e=be.getDependency("bufferView",Ae.bufferView).then(function(Je){Ne=!0;var ct=new Blob([Je],{type:Ae.mimeType});return _e=ot.createObjectURL(ct),_e})),Promise.resolve(_e).then(function(Je){var ct=Ge.manager.getHandler(Je);return ct||(ct=Ce[i.MSFT_TEXTURE_DDS]?be.extensions[i.MSFT_TEXTURE_DDS].ddsLoader:ke),new Promise(function(wt,Gt){ct.load(fe(Je,Ge.path),wt,void 0,Gt)})}).then(function(Je){Ne===!0&&ot.revokeObjectURL(_e),Je.flipY=!1,ge.name!==void 0&&(Je.name=ge.name),Ae.mimeType in le&&(Je.format=le[Ae.mimeType]);var ct=We.samplers||{},wt=ct[ge.sampler]||{};return Je.magFilter=j[wt.magFilter]||$i,Je.minFilter=j[wt.minFilter]||oc,Je.wrapS=J[wt.wrapS]||Zs,Je.wrapT=J[wt.wrapT]||Zs,Je})},yt.prototype.assignTexture=function(Ie,be,We){var Ge=this;return this.getDependency("texture",We.index).then(function(ke){if(!ke.isCompressedTexture)switch(be){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":ke.format=Ma;break}if(We.texCoord!==void 0&&We.texCoord!=0&&!(be==="aoMap"&&We.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+We.texCoord+" for texture "+be+" not yet supported."),Ge.extensions[i.KHR_TEXTURE_TRANSFORM]){var ot=We.extensions!==void 0?We.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;ot&&(ke=Ge.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(ke,ot))}Ie[be]=ke})},yt.prototype.assignFinalMaterial=function(Ie){var be=Ie.geometry,We=Ie.material;this.extensions;var Ge=be.attributes.tangent!==void 0,ke=be.attributes.color!==void 0,ot=be.attributes.normal===void 0,ge=Ie.isSkinnedMesh===!0,Ce=Object.keys(be.morphAttributes).length>0,Ae=Ce&&be.morphAttributes.normal!==void 0;if(Ie.isPoints){var _e="PointsMaterial:"+We.uuid,Ne=this.cache.get(_e);Ne||(Ne=new ss,Rn.prototype.copy.call(Ne,We),Ne.color.copy(We.color),Ne.map=We.map,Ne.sizeAttenuation=!1,this.cache.add(_e,Ne)),We=Ne}else if(Ie.isLine){var _e="LineBasicMaterial:"+We.uuid,Je=this.cache.get(_e);Je||(Je=new Ri,Rn.prototype.copy.call(Je,We),Je.color.copy(We.color),this.cache.add(_e,Je)),We=Je}if(Ge||ke||ot||ge||Ce){var _e="ClonedMaterial:"+We.uuid+":";We.isGLTFSpecularGlossinessMaterial&&(_e+="specular-glossiness:"),ge&&(_e+="skinning:"),Ge&&(_e+="vertex-tangents:"),ke&&(_e+="vertex-colors:"),ot&&(_e+="flat-shading:"),Ce&&(_e+="morph-targets:"),Ae&&(_e+="morph-normals:");var ct=this.cache.get(_e);ct||(ct=We.clone(),ge&&(ct.skinning=!0),Ge&&(ct.vertexTangents=!0),ke&&(ct.vertexColors=ic),ot&&(ct.flatShading=!0),Ce&&(ct.morphTargets=!0),Ae&&(ct.morphNormals=!0),this.cache.add(_e,ct)),We=ct}We.aoMap&&be.attributes.uv2===void 0&&be.attributes.uv!==void 0&&be.setAttribute("uv2",new kn(be.attributes.uv.array,2)),We.normalScale&&!Ge&&(We.normalScale.y=-We.normalScale.y),Ie.material=We},yt.prototype.loadMaterial=function(Ie){var be=this,We=this.json,Ge=this.extensions,ke=We.materials[Ie],ot,ge={},Ce=ke.extensions||{},Ae=[];if(Ce[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var _e=Ge[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];ot=_e.getMaterialType(),Ae.push(_e.extendParams(ge,ke,be))}else if(Ce[i.KHR_MATERIALS_UNLIT]){var Ne=Ge[i.KHR_MATERIALS_UNLIT];ot=Ne.getMaterialType(),Ae.push(Ne.extendParams(ge,ke,be))}else{ot=Vr;var Je=ke.pbrMetallicRoughness||{};if(ge.color=new tn(1,1,1),ge.opacity=1,Array.isArray(Je.baseColorFactor)){var ct=Je.baseColorFactor;ge.color.fromArray(ct),ge.opacity=ct[3]}Je.baseColorTexture!==void 0&&Ae.push(be.assignTexture(ge,"map",Je.baseColorTexture)),ge.metalness=Je.metallicFactor!==void 0?Je.metallicFactor:1,ge.roughness=Je.roughnessFactor!==void 0?Je.roughnessFactor:1,Je.metallicRoughnessTexture!==void 0&&(Ae.push(be.assignTexture(ge,"metalnessMap",Je.metallicRoughnessTexture)),Ae.push(be.assignTexture(ge,"roughnessMap",Je.metallicRoughnessTexture)))}ke.doubleSided===!0&&(ge.side=hh);var wt=ke.alphaMode||ie.OPAQUE;return wt===ie.BLEND?ge.transparent=!0:(ge.transparent=!1,wt===ie.MASK&&(ge.alphaTest=ke.alphaCutoff!==void 0?ke.alphaCutoff:.5)),ke.normalTexture!==void 0&&ot!==cr&&(Ae.push(be.assignTexture(ge,"normalMap",ke.normalTexture)),ge.normalScale=new Lt(1,1),ke.normalTexture.scale!==void 0&&ge.normalScale.set(ke.normalTexture.scale,ke.normalTexture.scale)),ke.occlusionTexture!==void 0&&ot!==cr&&(Ae.push(be.assignTexture(ge,"aoMap",ke.occlusionTexture)),ke.occlusionTexture.strength!==void 0&&(ge.aoMapIntensity=ke.occlusionTexture.strength)),ke.emissiveFactor!==void 0&&ot!==cr&&(ge.emissive=new tn().fromArray(ke.emissiveFactor)),ke.emissiveTexture!==void 0&&ot!==cr&&Ae.push(be.assignTexture(ge,"emissiveMap",ke.emissiveTexture)),Promise.all(Ae).then(function(){var Gt;return ot===A?Gt=Ge[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(ge):Gt=new ot(ge),ke.name!==void 0&&(Gt.name=ke.name),Gt.map&&(Gt.map.encoding=_h),Gt.emissiveMap&&(Gt.emissiveMap.encoding=_h),Oe(Gt,ke),ke.extensions&&he(Ge,Gt,ke),Gt})};function Dt(Ie,be,We){var Ge=be.attributes,ke=new Po;if(Ge.POSITION!==void 0){var ot=We.json.accessors[Ge.POSITION],ge=ot.min,Ce=ot.max;if(ge!==void 0&&Ce!==void 0)ke.set(new Pe(ge[0],ge[1],ge[2]),new Pe(Ce[0],Ce[1],Ce[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var Ae=be.targets;if(Ae!==void 0)for(var _e=new Pe,Ne=0,Je=Ae.length;Ne0&&He(bt,Ge),bt.name=Ge.name||"mesh_"+Ie,Je.length>1&&(bt.name+="_"+wt),Oe(bt,Ge),be.assignFinalMaterial(bt),ct.push(bt)}if(ct.length===1)return ct[0];for(var bn=new al,wt=0,Gt=ct.length;wt1){var Ne=ot[ge.mesh]++;_e=Ae.clone(),_e.name+="_instance_"+Ne}else _e=Ae;return ge.weights!==void 0&&_e.traverse(function(Je){if(Je.isMesh)for(var ct=0,wt=ge.weights.length;ct1?Ae=new al:Ce.length===1?Ae=Ce[0]:Ae=new on,Ae!==Ce[0])for(var _e=0,Ne=Ce.length;_e{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)})}const cb=[{type:"参数绘图",name:"画直线",code:`import { MxCpp, McGePoint3d, McDbLine, McCmColor} from "mxcad"; //画直线 function drawLine() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); // 绘制直线 let line_1 = new McDbLine() let pt1 = new McGePoint3d(1000, 200, 0) let pt2 = new McGePoint3d(-1000, -200, 0) line_1.startPoint = pt1 line_1.endPoint = pt2 line_1.trueColor = new McCmColor(0, 255, 0) mxcad.drawEntity(line_1) let line_2 = new McDbLine(1000, 500, 0, -1000, -500, 0) line_2.trueColor = new McCmColor(255, 0, 0) line_2.linetypeScale = 0.4 mxcad.drawEntity(line_2) mxcad.drawLine(1000, 800, -1000, -800) mxcad.zoomAll() mxcad.zoomScale(0.8) }; // 调用画直线方法 drawLine(); `},{type:"参数绘图",name:"画圆",code:`import {MxCpp, McDbCircle , McCmColor, McGePoint3d} from "mxcad" //画圆 function drawCircle() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); //绘制圆 const circle_1 = new McDbCircle(-100, 300, 0, 20) circle_1.trueColor = new McCmColor(255, 0, 0) mxcad.drawEntity(circle_1) const circle_2 = new McDbCircle() circle_2.center = new McGePoint3d(-100, 300, 0) circle_2.radius = 10 circle_2.trueColor = new McCmColor(0, 255, 0) mxcad.drawEntity(circle_2) mxcad.drawCircle(-100, 300, 30) mxcad.zoomAll() mxcad.zoomScale(0.8) }; // 调用画圆方法 drawCircle(); `},{type:"参数绘图",name:"画点",code:`import { MxCpp, McDbPoint, McCmColor } from "mxcad" //画点 function drawPoint() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); // 循环画点 const point = new McDbPoint() const color = new McCmColor(0, 255, 0) point.trueColor = color for (let i = 0; i < 100; i++) { point.setPosition(i, 200 + i) mxcad.drawEntity(point) } for (let i = 0; i < 100; i++) { mxcad.drawPoint(i, 150 + i) } mxcad.zoomAll() mxcad.zoomScale(0.8) }; // 调用画点的函数 drawPoint();`},{type:"参数绘图",name:"画圆弧",code:`import { MxCpp, McDbArc, McGePoint3d, McCmColor} from "mxcad"; //画圆弧 function drawArc() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); const arc = new McDbArc() arc.center = new McGePoint3d(-100, -100), arc.radius = 20 arc.startAngle = Math.PI / 2 arc.endAngle = Math.PI * 3 / 2 arc.trueColor = new McCmColor(255, 233, 0) mxcad.drawEntity(arc) const arc_1 = new McDbArc() const pt1 = new McGePoint3d(-60, -80) const pt2 = new McGePoint3d(-80, -100) const pt3 = new McGePoint3d(-60, -120) arc_1.trueColor = new McCmColor(0, 255, 0) arc_1.computeArc(pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y) mxcad.drawEntity(arc_1) mxcad.drawArc(-120, -100, 20, 100, 250); mxcad.drawColor = new McCmColor(255, 0, 0) mxcad.drawArc2(-80, -80, -100, -100, -80, -120) mxcad.drawColor = new McCmColor(0, 0, 255) mxcad.drawArc3(-40, -80, -40, -120, 1) mxcad.zoomAll() mxcad.zoomScale(0.8) }; // 调用绘圆方法 drawArc()`},{type:"参数绘图",name:"画图片",code:`import { MxCpp, McGePoint3d } from "mxcad"; //画图片 function drawImg() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); //图片插入点 const pt = new McGePoint3d(0, 0, 0) //图片地址 let imagUrl = "https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg"; mxcad.loadImage(imagUrl, (image) => { if (!image) { console.log("loadImage failed"); return; } let width = mxcad.mxdraw.viewCoordLong2Cad(100); let height = (image.height / image.width) * width; mxcad.drawImage((pt as any).x, (pt as any).y, width, height, 0, imagUrl); mxcad.updateDisplay(); }); }; // 调用绘图片方法 drawImg();`},{type:"参数绘图",name:"画多段线",code:`import { MxCpp, McDbPolyline, McGePoint3d } from "mxcad" //画多段线 function drawPolyline() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); // 画多段线 const polyline = new McDbPolyline() polyline.isClosed = true // 设置闭合 polyline.constantWidth = 5 // 设置线宽 // 添加多段线顶点 polyline.addVertexAt(new McGePoint3d(800, 300, 0)) polyline.addVertexAt(new McGePoint3d(900, 300, 0)) polyline.addVertexAt(new McGePoint3d(900, 400, 0)) mxcad.drawEntity(polyline) mxcad.zoomAll() mxcad.zoomScale(0.8) } // 调用画多段线的方法 drawPolyline()`},{type:"参数绘图",name:"画椭圆",code:`import {McDbEllipse, McGeVector3d, MxCpp, McGePoint3d, McCmColor } from "mxcad"; //画椭圆弧 function drawEllipse() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); //绘制椭圆 const ellipse = new McDbEllipse(); ellipse.center = new McGePoint3d(-200, -200); ellipse.majorAxis = new McGeVector3d(0, 300, 0); ellipse.radiusRatio = 0.5; ellipse.trueColor = new McCmColor(255, 233, 0); mxcad.drawEntity(ellipse); const ellipse_arc = new McDbEllipse(); ellipse_arc.center = new McGePoint3d(-380, -200); ellipse_arc.majorAxis = new McGeVector3d(0, 150, 0); ellipse_arc.minorAxis = new McGeVector3d(280, 0, 0); ellipse_arc.startAngle = Math.PI / 2; ellipse_arc.endAngle = Math.PI * 3 / 2; ellipse_arc.trueColor = new McCmColor(0, 255, 255); mxcad.drawEntity(ellipse_arc); mxcad.drawEllipse(0, -200, 200, 0, 1.5); mxcad.drawColor = new McCmColor(0, 255, 0); mxcad.drawEllipseArc(200, -200, 200, 0, 1.5, 100, 650); mxcad.zoomAll(); mxcad.zoomScale(0.8); }; // 调用画椭圆的方法 drawEllipse();`},{type:"参数绘图",name:"画文字",code:`import { MxCpp, McGePoint3d, McDbText, McCmColor } from "mxcad"; function drawText() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); // 绘制文字 let text = new McDbText() text.textString = 'Hello World' text.position = new McGePoint3d(1000, 200, 0) text.height = 50 text.trueColor = new McCmColor(0, 255, 0) mxcad.drawEntity(text) mxcad.zoomAll() mxcad.zoomScale(0.8) }; // 调用画文字的方法 drawText();`},{type:"参数绘图",name:"画多行文字",code:`import { MxCpp } from "mxcad";\r \r function drawMtext() {\r let mxcad = MxCpp.getCurrentMxCAD();\r //清空当前显示内容\r mxcad.newFile();\r \r //把颜色改回黑白色\r mxcad.drawColorIndex = 0;\r \r mxcad.addLayer("MtextLayer");\r \r //设置当前图层为"MtextLayer"\r \r mxcad.drawLayer = "MtextLayer"; \r \r mxcad.drawTextStyle = "";\r \r mxcad.drawMText(0, -100, "控件:\\\\P多行文字测试", 50, 400, 0, 1);\r \r mxcad.zoomAll();\r mxcad.updateDisplay();\r };\r \r // 调用画多行文字的方法\r drawMtext();`},{type:"参数绘图",name:"画尺寸标注",code:` import { McDbAlignedDimension,McDb, McDbRotatedDimension, MxCpp, McGePoint3d, McCmColor } from "mxcad"; //画标注 function drawDimension() { const mxcad = MxCpp.getCurrentMxCAD(); // 创建新画布 mxcad.newFile(); // 画标注 const mDimension = new McDbAlignedDimension() mDimension.xLine1Point = new McGePoint3d(-1800, 800) mDimension.xLine2Point = new McGePoint3d(1800, 800) mDimension.dimLinePoint = new McGePoint3d(800, 500) mDimension.textAttachment = McDb.AttachmentPoint.kTopLeft mDimension.trueColor = new McCmColor(200, 255, 0) mDimension.oblique = 0 mxcad.drawEntity(mDimension) const rDimension = new McDbRotatedDimension() rDimension.xLine1Point = new McGePoint3d(-1800, -800) rDimension.xLine2Point = new McGePoint3d(1800, -800) rDimension.dimLinePoint = new McGePoint3d(-800, -500) rDimension.textAttachment = McDb.AttachmentPoint.kTopLeft rDimension.textRotation = 0.6 rDimension.trueColor = new McCmColor(200, 255, 0) rDimension.oblique = 0 rDimension.rotation = 0 rDimension.dimensionText = "标注文本" mxcad.drawEntity(rDimension) mxcad.zoomCenter(0, 0) }; // 调用画标注方法 drawDimension();`},{type:"参数绘图",name:"画路径",code:`import { MxCpp } from "mxcad";\r \r // 画路径\r function drawPath() {\r const mxcad = MxCpp.getCurrentMxCAD();\r // 创建新画布\r mxcad.newFile();\r //用路径 绘制矩形框\r //定义一个路径的开始点\r mxcad.pathMoveTo(0, 300);\r //路径的一下个点\r mxcad.pathLineTo(100, 300);\r //路径的一下个点\r mxcad.pathLineTo(100, 400);\r //路径的一下个点\r mxcad.pathLineTo(0, 400);\r //把路径设置成闭合\r mxcad.pathMakeClosed();\r //生成一个矩形框的多义线\r mxcad.drawPathToPolyline();\r \r //定义一个路径的开始点\r mxcad.pathMoveTo(170, 320)\r mxcad.pathLineTo(200, 320)\r mxcad.pathLineTo(200, 340)\r mxcad.pathLineTo(170, 340)\r // 把上面定义的路径定义填充排除区域.\r mxcad.pathMakeExclude(true)\r mxcad.pathMoveTo(150, 300)\r mxcad.pathLineTo(250, 300)\r mxcad.pathLineTo(250, 400)\r mxcad.pathLineTo(150, 400)\r mxcad.pathMakeClosed();\r // 将路径生成一个填充 这里的参数是图案缩放比例\r mxcad.drawPathToHatch(1);\r \r mxcad.zoomAll();\r mxcad.zoomScale(0.8)\r };\r \r // 调用画路径的函数\r drawPath();`},{type:"参数绘图",name:"画填充",code:`import { MxCpp, McCmColor } from "mxcad";\r \r // 画填充\r function drawHatch() {\r const mxcad = MxCpp.getCurrentMxCAD();\r // 创建新画布\r mxcad.newFile();\r // 绘制一个实心填充\r //定义一个路径的开始点\r mxcad.pathMoveTo(150, 3300);\r //路径的一下个点\r mxcad.pathLineTo(250, 3300);\r //路径的一下个点\r mxcad.pathLineTo(250, 3400);\r //路径的一下个点\r mxcad.pathLineTo(150, 3300);\r //把路径拟合成一个样线\r mxcad.drawColor = new McCmColor(255, 0, 0);\r mxcad.drawPathToHatch(1);\r \r // 绘制一个图形填充\r mxcad.addPatternDefinition("MyHatchPattern1", "((45, 0,0, 0,0.125))");\r mxcad.drawPatternDefinition = "MyHatchPattern1";\r //定义一个路径的开始点\r mxcad.pathMoveTo(250, 3300);\r //路径的一下个点\r mxcad.pathLineTo(350, 3300);\r //路径的一下个点\r mxcad.pathLineTo(350, 3400);\r //路径的一下个点\r mxcad.pathLineTo(250, 3300);\r mxcad.drawColor = new McCmColor(255, 255, 0);\r //把路径变成一个填充,80,是填充图案的缩放比例.\r mxcad.drawPathToHatch(100);\r mxcad.zoomAll()\r mxcad.zoomScale(0.8)\r };\r \r // 调用画填充的方法\r drawHatch();`},{type:"参数绘图",name:"画图块",code:`import { MxCpp, McDbBlockTableRecord, McDbLine, McDbCircle, McCmColor, McDbBlockReference, McGePoint3d } from "mxcad";\r \r // 画图块\r function drawBlock() {\r const mxcad = MxCpp.getCurrentMxCAD();\r // 创建新画布\r mxcad.newFile();\r \r // 先从数据库中得到图块表\r let blkTable = mxcad.getDatabase().getBlockTable();\r // 将一个新的图块记录添加到图块表中\r let blkRecId = blkTable.add(new McDbBlockTableRecord());\r \r // 根据ObjectId再次得到刚刚添加的图块记录\r let blkTableRecord = blkRecId.getMcDbBlockTableRecord()\r \r // 添加两条线段再图块记录中 这里每条线段的具体属性比如开始点和结束点自行赋值\r const line = new McDbLine(50, 50, 0, -50, -50, 0)\r line.trueColor = new McCmColor(0, 255, 0)\r const line1 = new McDbLine(-50, 50, 0, 50, -50, 0)\r const circle = new McDbCircle(0, 0, 0, 50)\r circle.trueColor = new McCmColor(255, 255, 0)\r blkTableRecord.appendAcDbEntity(line);\r blkTableRecord.appendAcDbEntity(line1);\r blkTableRecord.appendAcDbEntity(circle);\r \r // 设置图块的基点 一般是包围盒内的点, 可以任意指定\r blkTableRecord.origin = new McGePoint3d(0, 0, 0);\r \r // 实例化块参照 这里需要设置我们刚刚添加图块记录得到的ObjectId\r let blkRef = new McDbBlockReference();\r blkRef.blockTableRecordId = blkRecId;\r // 最后设置位置 渲染图块\r blkRef.position = new McGePoint3d(0, 0, 0);\r \r mxcad.drawEntity(blkRef);\r \r mxcad.zoomAll()\r mxcad.zoomScale(0.8)\r };\r \r // 调用画图块方法\r drawBlock();`},{type:"参数绘图",name:"画文本自定义实体",code:`import {\r MxCpp, McDbLine, McGePoint3d, McDbCustomEntity, IMcDbDwgFiler,MxCADWorldDraw,McGePoint3dArray,\r McGeVector3d,McDbText,McDb,MxCADResbuf,MxCADSelectionSet,McObjectId,McDbCircle } from "mxcad"\r \r // 线文本自定义实体\r // 新创建 McDbLineText 类,继承McDbCustomEntity\r class McDbTestLineText extends McDbCustomEntity {\r //设置McDbLineText类中的两个直线端点 pt1、pt2\r //以及显示线段长度的文字_text和文字大小_textsize\r private pt1: McGePoint3d = new McGePoint3d();\r private pt2: McGePoint3d = new McGePoint3d();\r private _text: string = "";\r private _textsize: number = 10;\r //构造函数\r constructor(imp?: any) {\r super(imp);\r }\r //创建函数\r public create(imp: any) {\r return new McDbTestLineText(imp)\r }\r //获取类型\r public getTypeName(): string {\r return "McDbTestLineText";\r }\r //设置或获取文本值\r public set text(val: string) {\r this._text = val;\r }\r public get text(): string {\r return this._text;\r }\r //设置或获取文本大小\r public set textsize(val: number) {\r this._textsize = val;\r }\r public get textsize(): number {\r return this._textsize;\r }\r //读取自定义实体数据pt1、pt2、_text、_textsize\r public dwgInFields(filter: IMcDbDwgFiler): boolean {\r this.pt1 = filter.readPoint("pt1").val;\r this.pt2 = filter.readPoint("pt2").val;\r this._text = filter.readString("text").val;\r this._textsize = filter.readDouble("textsize").val;\r return true;\r }\r //写入自定义实体数据pt1、pt2、_text、_textsize\r public dwgOutFields(filter: IMcDbDwgFiler): boolean {\r filter.writePoint("pt1", this.pt1);\r filter.writePoint("pt2", this.pt2);\r filter.writeString("text", this._text);\r filter.writeDouble("textsize", this._textsize);\r return true;\r }\r //自定义同步函数,当其他对象与该对象相连时同步数据\r private fineLink(pt: McGePoint3d): any {\r let ret: any = {};\r let myId = this.getObjectID();\r let dSearch = this._textsize * 0.5;;\r let filter = new MxCADResbuf();\r filter.AddString("McDbCustomEntity", 5020);\r let ss = new MxCADSelectionSet();\r ss.crossingSelect(pt.x - dSearch, pt.y - dSearch, pt.x + dSearch, pt.y + dSearch, filter);\r ss.forEach((id) => {\r if (id == myId)\r return;\r let ent = id.getMcDbEntity();\r if (!ent) return;\r if (ent instanceof McDbLineText) {\r let line = (ent as McDbLineText);\r let linkPoint = line.getPoint1();\r let link_pos = 0;\r // 得到直线与图块连接的端点坐标.\r let dist = line.getPoint1().distanceTo(pt);\r if (dist > line.getPoint2().distanceTo(pt)) {\r dist = line.getPoint2().distanceTo(pt);\r linkPoint = line.getPoint2();\r link_pos = 1;\r }\r if (dist < dSearch) {\r ret[id.id] = { link_point: linkPoint,link_pos:link_pos };\r }\r }\r });\r return ret;\r }\r //处理夹点编辑效果\r public moveGripPointsAt(iIndex: number, dXOffset: number, dYOffset: number, dZOffset: number) {\r this.assertWrite();\r let pt:McGePoint3d = this.pt1.clone();\r let new_pt:McGePoint3d = pt;\r if (iIndex == 0) {\r this.pt1.x += dXOffset;\r this.pt1.y += dYOffset;\r this.pt1.z += dZOffset;\r new_pt = this.pt1;\r }\r else if (iIndex == 1) {\r pt = this.pt2.clone();\r this.pt2.x += dXOffset;\r this.pt2.y += dYOffset;\r this.pt2.z += dZOffset;\r new_pt = this.pt2;\r }\r if (this.getObjectID().isValid()) {\r // 同步,与连接的其它对象。\r let linkobj = this.fineLink(pt)\r Object.keys(linkobj).forEach((id_val:any)=>{\r let idFind = new McObjectId(id_val);\r let lineFind = (idFind.getMcDbEntity() as McDbLineText);\r if(linkobj[id_val].link_pos == 0){\r lineFind.setPoint1(new_pt);\r }\r else{\r lineFind.setPoint2(new_pt);\r }\r });\r }\r };\r //设置对象编辑点位\r public getGripPoints(): McGePoint3dArray {\r let ret = new McGePoint3dArray()\r ret.append(this.pt1);\r ret.append(this.pt2);\r return ret;\r };\r //动态绘制\r public worldDraw(draw: MxCADWorldDraw): void {\r let circle_r = this._textsize * 0.4;\r let vec2 = this.pt2.sub(this.pt1);\r vec2.normalize().mult(circle_r);\r let tmpline = new McDbLine(this.pt1.clone().addvec(vec2),\r this.pt2.clone().subvec(vec2));\r draw.drawEntity(tmpline);\r let vec = this.pt2.sub(this.pt1).mult(0.5);\r let midpt = this.pt1.clone().addvec(vec);\r if (vec.dotProduct(McGeVector3d.kXAxis) < 0) {\r vec.negate();\r }\r let ange = vec.angleTo2(McGeVector3d.kXAxis, McGeVector3d.kNegateZAxis);\r let str = this._text;\r if (str.length == 0) {\r str = this.pt1.distanceTo(this.pt2).toFixed(2);\r }\r vec.perpVector();\r if (vec.dotProduct(McGeVector3d.kYAxis) < 0) {\r vec.negate();\r }\r vec.normalize().mult(this._textsize * 0.2);\r let text = new McDbText();\r text.textString = str;\r text.position = midpt.clone().addvec(vec);\r text.alignmentPoint = midpt.clone().addvec(vec);\r text.rotation = ange;\r text.verticalMode = McDb.TextVertMode.kTextBottom;\r text.horizontalMode = McDb.TextHorzMode.kTextCenter;\r text.height = this._textsize;\r draw.drawEntity(text)\r let circle1 = new McDbCircle();\r circle1.center = this.pt1;\r circle1.radius = circle_r;\r draw.drawEntity(circle1);\r \r let circle2= new McDbCircle();\r circle2.center = this.pt2;\r circle2.radius = circle_r;\r draw.drawEntity(circle2);\r }\r // 设置pt1\r public setPoint1(pt1: McGePoint3d) {\r this.assertWrite();\r this.pt1 = pt1.clone();\r }\r // 设置pt2\r public setPoint2(pt2: McGePoint3d) {\r this.assertWrite();\r this.pt2 = pt2.clone();\r }\r // 获取pt1\r public getPoint1() {\r return this.pt1;\r }\r //获取pt2\r public getPoint2() {\r return this.pt2;\r }\r }\r \r // 绘线文本自定义实体\r async function MxTest_LineText() {\r let mxcad = MxCpp.getCurrentMxCAD();\r //清空当前显示内容\r mxcad.newFile();\r \r let pt1 = new McGePoint3d(100, 100, 0);\r let pt2 = new McGePoint3d(200, 150, 0);\r let pt3 = new McGePoint3d(400, 50, 0);\r let pt4 = new McGePoint3d(600, 60, 0);\r let pt5 = new McGePoint3d(200, 300, 0);\r \r let textsize = 5;\r \r let myline1 = new McDbTestLineText();\r myline1.setPoint1(pt1);\r myline1.setPoint2(pt2);\r myline1.textsize = textsize;\r myline1.text = "xxxx";\r mxcad.drawEntity(myline1);\r \r \r let myline2 = new McDbTestLineText();\r myline2.setPoint1(pt2);\r myline2.setPoint2(pt3);\r myline2.textsize = textsize;\r mxcad.drawEntity(myline2);\r \r let myline3 = new McDbTestLineText();\r myline3.setPoint1(pt3);\r myline3.setPoint2(pt4);\r myline3.textsize = textsize;\r mxcad.drawEntity(myline3);\r \r \r let myline4 = new McDbTestLineText();\r myline4.setPoint1(pt2);\r myline4.setPoint2(pt5);\r myline4.textsize = textsize;\r mxcad.drawEntity(myline4);\r \r \r //把所有的实体都放到当前显示视区\r mxcad.zoomW(new McGePoint3d(-300, -300, 0), new McGePoint3d(650, 500, 0));\r //更新视区显示\r mxcad.updateDisplay();\r }\r \r // 自定义实体注册\r new McDbTestLineText().rxInit();\r // 调用绘线文本自定义实体方法\r MxTest_LineText();\r \r `},{type:"参数绘图",name:"画多种线型的直线",code:`import { McCmColor, MxCpp} from "mxcad"\r \r // 绘制多种线型直线\r function Mx_Test_DrawLine() {\r let mxcad = MxCpp.getCurrentMxCAD();\r //清空当前显示内容\r mxcad.newFile();\r //把颜色改回黑白色\r mxcad.drawColorIndex = 0;\r //把线型改成实线\r mxcad.drawLinetype = "";\r //设置线宽 4\r mxcad.drawLineWidth = 0;\r \r \r //创建一个图层,名为"LineLayer"\r mxcad.addLayer("LineLayer");\r //设置当前图层为"LineLayer"\r mxcad.drawLayer = "LineLayer";\r // 直接绘制一个实线\r // 参数一直线的开始点x坐标,参数二直线的开始点y坐标,参数三直线的结束点x坐标,参数四直线的结束点y坐标\r mxcad.drawLine(0, 0, 100, 0);\r // 绘制一个实斜线\r mxcad.drawLine(200, 0, 300, 100);\r \r \r //----------------------------------------------------------------------------------------------------------\r //绘制一个虚线\r //定义虚线数据据,"MyLineType"是线型名,"6,-8"是虚线的一个单位定义,6是实线长,-8是空格长。\r mxcad.addLinetype("MyLineType", "6,-10");\r //设计当前线型为"MyLineType"\r mxcad.drawLinetype = "MyLineType";\r // 绘制一个虚线\r mxcad.drawLine(0, 30, 100, 30);\r // 绘制一个斜虚线\r mxcad.drawLine(200, 30, 300, 130);\r \r //---------------------------------------------------------------------------------------------------------\r // 修改绘线的颜色为 16711680(蓝色), 16711680转成16进制是0xFF 00 00,其中,FF是蓝色,00是绿色,第个二00是红色。\r mxcad.drawColor = new McCmColor(0, 0, 255);\r // 绘制一个蓝色的虚线\r \r mxcad.drawLine(0, 60, 100, 60);\r // 绘制一个蓝色的斜虚线\r mxcad.drawLine(200, 60, 300, 160);\r //---------------------------------------------------------------------------------------------------------\r //把颜色改回黑白色\r mxcad.drawColorIndex = 0;\r //把线型改成实线\r mxcad.drawLinetype = "";\r //设置线宽 4\r mxcad.drawLineWidth = 4;\r //绘制一个带宽度的直线。\r mxcad.drawLine(0, 90, 100, 90);\r // 绘制一个带宽度的斜线\r mxcad.drawLine(200, 90, 300, 190);\r \r //---------------------------------------------------------------------------------------------------------\r //绘制一个点划线虚线\r mxcad.addLinetype("MyLineType2", "10,-2,3,-2");\r //把线型改点划线\r mxcad.drawLinetype = "MyLineType2";\r // 修改绘线的颜色为 255(红色), 255转成16进制是0x00 00 FF,其中,00是蓝色,第个二00是绿色,FF是红色。\r mxcad.drawColor = new McCmColor(255, 0, 0);\r //绘制一个带宽度的红色点划线。\r mxcad.drawLine(0, 120, 100, 120);\r // 绘制一个带宽度红色点划斜线\r mxcad.drawLine(200, 120, 300, 220);\r //---------------------------------------------------------------------------------------------------------\r //增加一个带有形的线型\r mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);\r mxcad.addLinetypeEx("MyLineType3", "(12.7,(\\"T=MxDraw\\",\\"S=2.54\\",\\"L=-5.08\\",\\"R=0.0\\",\\"X=-2.54\\",\\"Y=-1.27\\"),-10.08)", "MyLineTypeTextStyle");\r mxcad.drawLinetype = "MyLineType3";\r mxcad.drawLineWidth = 0;\r //绘制一个带宽度的红色点划线。\r mxcad.drawLine(350, 120, 600, 120);\r //---------------------------------------------------------------------------------------------------------\r //增加一个带有形的线型\r //把颜色改回黑白色\r mxcad.drawColorIndex = 0;\r mxcad.drawLineWidth = 4;\r //绘制一个带宽度的红色点划线。\r mxcad.drawLine(350, 220, 600, 220);\r \r //把所有的实体都放到当前显示视区\r mxcad.zoomAll();\r //更新视区显示\r mxcad.updateDisplay();\r }\r \r // 调用绘制多种线型直线的方法\r Mx_Test_DrawLine()`},{type:"参数绘图",name:"画多种文字样式的文字",code:`import { MxCpp, McCmColor } from "mxcad";\r \r function Mx_Test_TrueText() {\r let mxcad = MxCpp.getCurrentMxCAD();\r //清空当前显示内容\r mxcad.newFile();\r MxCpp.App.loadFonts([], [], ["syadobe", "simsun"], () => {\r \r // 添加一个黑体文字样式\r mxcad.AddTureTypeTextStyle("ht_style", "syadobe");\r \r // 添加一个宋体文字样式\r mxcad.AddTureTypeTextStyle("st_style", "simsun");\r \r // 设置当前样式为黑体\r mxcad.drawTextStyle = "ht_style";\r \r mxcad.drawColor = new McCmColor(200, 255, 50);\r mxcad.drawText(0, 3500, "绘图控件TrueType文字测试1", 100, 0, 0, 1);\r \r // 设置当前样式为黑体\r mxcad.drawTextStyle = "st_style";\r mxcad.drawColor = new McCmColor(200, 100, 0);\r mxcad.drawText(0, 3200, "绘图控件TrueType文字测试2", 100, 0, 0, 1);\r \r mxcad.zoomAll();\r mxcad.regen();\r mxcad.updateDisplay();\r });\r };\r \r // 调用画多种文字样式的文字的方法\r Mx_Test_TrueText()`},{type:"交互绘图",name:"取点画圆弧",code:`import { MxCADUiPrPoint, McDbPolyline, McDbArc, MxCpp } from "mxcad"; //画圆弧 async function Mx_drawArc() { // 根据起点,中点,端点三个点确定一段圆弧 // 获取起点 let getFristPoint = new MxCADUiPrPoint(); getFristPoint.setMessage('指定起点'); let fristPoint = await getFristPoint.go(); if (!fristPoint) return // 获取第二个点 let getSecondPoint = new MxCADUiPrPoint(); getSecondPoint.setMessage('指定圆弧的第二个点'); //动态绘制取点对象 getSecondPoint.setUserDraw((pt, pw) => { let pl = new McDbPolyline(); pl.addVertexAt(fristPoint) pl.addVertexAt(pt); pw.drawMcDbEntity(pl) }) let secondPoint = await getSecondPoint.go(); if (!secondPoint) return; // 获取端点 let getThirdPoint = new MxCADUiPrPoint(); getThirdPoint.setMessage('指定圆弧的端点'); //动态绘制圆弧 getThirdPoint.setUserDraw((pt, pw) => { let arc = new McDbArc(); arc.computeArc(fristPoint.x, fristPoint.y, secondPoint.x, secondPoint.y, pt.x, pt.y);//三点画圆弧 pw.drawMcDbEntity(arc) }); let thirdPoint = await getThirdPoint.go(); if (!thirdPoint) return // 画圆弧 let arc = new McDbArc(); arc.computeArc(fristPoint.x, fristPoint.y, secondPoint.x, secondPoint.y, thirdPoint.x, thirdPoint.y);//三点画圆弧 const mxcad = MxCpp.getCurrentMxCAD(); mxcad.drawEntity(arc); }; // 调用画圆弧的方法 Mx_drawArc(); `},{type:"交互绘图",name:"取点画直线",code:`import {MxCADUiPrPoint, McDbLine, MxCpp} from "mxcad";\r \r //画线\r async function Mx_drawLine() {\r // 获取线段起点\r let getFristPoint = new MxCADUiPrPoint();\r getFristPoint.setMessage("请点击确定起始点");\r let fristPoint: any = await getFristPoint.go();\r if (!fristPoint) return\r \r // 获取线段终点\r let getSecondPoint = new MxCADUiPrPoint();\r getSecondPoint.setMessage("请点击确定终点");\r getSecondPoint.setUserDraw((pt, pw) => {\r let line = new McDbLine(fristPoint.x, fristPoint.y, fristPoint.z, pt.x, pt.y, pt.z);\r pw.drawMcDbEntity(line)\r })\r let secondPoint: any = await getSecondPoint.go();\r if (!secondPoint) return\r \r // 绘制线段\r let line = new McDbLine(fristPoint.x, fristPoint.y, fristPoint.z, secondPoint.x, secondPoint.y, secondPoint.z);\r const mxcad = MxCpp.getCurrentMxCAD();\r mxcad.drawEntity(line)\r };\r \r // 调用画线的方法\r \r Mx_drawLine();`},{type:"交互绘图",name:"取点画文字",code:`import { McDbText, MxCADUiPrDist, MxCADUiPrPoint, MxCADUiPrString, MxCpp } from "mxcad";\r \r async function Mx_drawText() {\r // 创建文字对象\r const text = new McDbText();\r \r // 设置文字内容\r const getStr = new MxCADUiPrString()\r getStr.setMessage("请输入文字内容")\r const str = await getStr.go()\r if (!str) return\r text.textString = str;\r \r // 设置文字高度\r const getDist = new MxCADUiPrDist()\r getDist.setMessage("请输入文字高度")\r const height = await getDist.go()\r if (!height) return\r text.height = getDist.value();\r \r // 设置文字高度\r const getPoint = new MxCADUiPrPoint()\r getPoint.setMessage("请点击确定文字位置")\r getPoint.setUserDraw((pt, pw) => {\r text.position = pt;\r text.alignmentPoint = pt;\r pw.drawMcDbEntity(text)\r })\r const position = await getPoint.go()\r if (!position) return\r text.position = position;\r text.alignmentPoint = position\r \r const mxcad = MxCpp.getCurrentMxCAD();\r mxcad.drawEntity(text);\r };\r \r // 调用绘制文字的方法\r Mx_drawText();`},{type:"交互绘图",name:"取点画圆",code:`import {McDbCircle, MxCADUiPrDist, MxCADUiPrPoint, MxCpp} from "mxcad";\r \r // 画圆\r async function Mx_drawCircle(){\r // 创建圆\r const circle = new McDbCircle();\r \r // 获取圆心\r const getCenter = new MxCADUiPrPoint();\r getCenter.setMessage('请确定圆心位置\\n');\r const center = await getCenter.go();\r if (!center) return;\r circle.center = center;\r \r // 获取圆半径\r const getRadius = new MxCADUiPrDist();\r getRadius.setBasePt(center);\r getRadius.setMessage('请输入圆半径');\r // 动态绘制圆\r getRadius.setUserDraw((pt, pw) => {\r const r = pt.distanceTo(center);\r circle.radius = r;\r pw.drawMcDbEntity(circle)\r })\r const radiusVal = await getRadius.go();\r if (!radiusVal) return;\r circle.radius = getRadius.value();\r \r // 绘制圆\r const mxobj = MxCpp.getCurrentMxCAD();\r mxobj.drawEntity(circle);\r };\r \r // 调用画圆的方法\r Mx_drawCircle();`},{type:"交互绘图",name:"取点画图片",code:`import {MxCADUiPrPoint, MxCpp} from "mxcad";\r \r //画图片\r async function Mx_drawImg() {\r // 设置图片插入点\r const getPoint = new MxCADUiPrPoint();\r getPoint.setMessage("\\n指定插入点:");\r let pt = await getPoint.go();\r if (!pt) return;\r \r const mxcad = MxCpp.getCurrentMxCAD();\r // 设置图片地址\r let imagUrl = "https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg";\r mxcad.loadImage(imagUrl,(image)=>{\r if(!image ){ \r console.log("loadImage failed");\r return;\r }\r // 设置图片宽高\r let width = mxcad.mxdraw.viewCoordLong2Cad(100);\r let height = (image.height / image.width) * width;\r mxcad.drawImage((pt as any).x,(pt as any).y,width,height,0,imagUrl);\r mxcad.updateDisplay();\r });\r };\r \r // 调用画图片的方法\r Mx_drawImg();`},{type:"交互绘图",name:"取点画多段线",code:`import { MxCpp, MxCADUiPrPoint, McDbPolyline, MxCADUiPrDist, McGeVector3d, McGePoint3d, McDbArc, MxCADUtility, McDbLine, McDb} from "mxcad";\r \r // 画多段线\r async function Mx_drawPolyline() {\r // 获取画布实例\r const mxcad = MxCpp.App.getCurrentMxCAD();\r const getPoint = new MxCADUiPrPoint();\r getPoint.setMessage("\\n指定起点:");\r let firstPoint = await getPoint.go();\r if (!firstPoint) return;\r let pointArr: any[] = [];\r let drawObjIds: any[] = [];\r let isArc: boolean = false;\r let dStartWidth: number = 0;\r let dEndWidth: number = 0;\r pointArr.push({ pt: firstPoint, dBulge: 0, dStartWidth, dEndWidth })\r let isAutoClose: boolean = false;\r let isReverse: boolean = false;//圆弧方向是否取反\r let arcDirection: any = null //指定圆弧切向\r while (true) {\r if (!isArc) {\r //绘直线\r const getNextPoint = new MxCADUiPrPoint;\r getNextPoint.setMessage("\\n指定下一个点");\r // 提示消息\r if (pointArr.length < 2) {\r getNextPoint.setKeyWords('[圆弧(A)/宽度(W)]')\r } else {\r getNextPoint.setKeyWords('[放弃(U)/圆弧(A)/宽度(W)/闭合(C)]')\r }\r let lastPoint = pointArr[pointArr.length - 1];//鼠标点击的最后一个点\r // 等待鼠标点击期间会执行setUserDraw动态绘制函数中的回调函数\r getNextPoint.setUserDraw((pt, pw) => {\r // pt 就是鼠标所在图纸位置的坐标\r // pw 是提供了一些动态绘制方法的对象\r let pl = new McDbPolyline();\r pl.addVertexAt(lastPoint.pt, lastPoint.dBulge, lastPoint.dStartWidth, lastPoint.dEndWidth)\r pl.addVertexAt(pt, 0, dStartWidth, dEndWidth);\r pw.drawMcDbEntity(pl);\r })\r let nextPoint = await getNextPoint.go();\r if (nextPoint !== null) {\r // 获取到了鼠标点击点\r pointArr.push({ pt: nextPoint, dBulge: 0, dStartWidth, dEndWidth });\r let pl = new McDbPolyline();\r pl.addVertexAt(lastPoint.pt, lastPoint.dBulge, lastPoint.dStartWidth, lastPoint.dEndWidth);\r pl.addVertexAt(nextPoint, 0, dStartWidth, dEndWidth);\r drawObjIds.push(mxcad.drawEntity(pl))\r } else if (getNextPoint.getStatus() === Mx.MrxDbgUiPrBaseReturn.kKeyWord) {\r // 用户输入关键字\r let keyWord = getNextPoint.keyWordPicked()\r if (keyWord === 'A') {\r // 绘制圆弧\r isArc = true;\r } else if (keyWord === 'W') {\r // 设置宽度\r /**\r * 输入空格宽度不变\r */\r let getWidth = new MxCADUiPrDist();\r getWidth.setMessage('指定起点宽度:');\r // 获取线宽\r let dWVal = await getWidth.go();\r if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r dStartWidth = getWidth.value();\r pointArr[pointArr.length - 1].dStartWidth = dStartWidth;\r }\r getWidth.setMessage('指定端点宽度');\r dWVal = await getWidth.go();\r if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r dEndWidth = getWidth.value();\r pointArr[pointArr.length - 1].dEndWidth = dEndWidth;\r }\r } else if (keyWord === 'U') {\r // 回退操作\r if (pointArr.length > 1 && drawObjIds.length > 1) {\r pointArr.pop();\r drawObjIds[drawObjIds.length - 1].erase();\r drawObjIds.pop();\r }\r } else if (keyWord === 'C') {\r isAutoClose = true;\r break;\r }\r } else {\r break;\r }\r } else {\r // 绘制圆弧\r let getNextPoint = new MxCADUiPrPoint();\r getNextPoint.setMessage('指定圆弧的端点(按住 ctrl 键取相反方向)\\n');\r getNextPoint.setKeyWords('[第二个点(S)/角度(A)/圆心(CE)/放弃(U)/直线(L)/宽度(W)/闭合(CL)]');\r // 计算圆弧的切向量.\r let vecArcTangent = new McGeVector3d();\r // 开端的圆弧切向量取水平方向./获取圆弧切向\r if (pointArr.length < 2) {\r // 开端的圆弧切向量取水平方向.\r vecArcTangent.copy(McGeVector3d.kYAxis);\r } else {\r let length = pointArr.length;\r let p1 = pointArr[length - 2].pt;\r let dBulge = pointArr[length - 2].dBulge;\r let p2 = pointArr[length - 1].pt;\r if (dBulge === 0) {\r // 前一段是个直线.\r vecArcTangent = new McGePoint3d(p2.x, p2.y, 0.0).sub(new McGePoint3d(p1.x, p1.y, 0.0));\r }\r else {\r // 前一段为曲线,求圆弧的切向量\r let tmpPl = new McDbPolyline;\r tmpPl.addVertexAt(p1, dBulge);\r tmpPl.addVertexAt(p2);\r let tmpVec = tmpPl.getFirstDeriv(new McGePoint3d(p2.x, p2.y, 0.0));//曲线上任意一点的切向量\r if (tmpVec.ret) {\r vecArcTangent = tmpVec.val;\r }\r else {\r vecArcTangent.copy(McGeVector3d.kXAxis);\r }\r }\r }\r let lastPoint = pointArr[pointArr.length - 1];\r //监听ctrl键是否被按下\r document.addEventListener('keydown', function (event) {\r if (event.ctrlKey && event.keyCode === 17) {\r isReverse = true;\r }\r });\r // ctrl键松开\r document.addEventListener('keyup', function () {\r isReverse = false;\r });\r getNextPoint.setUserDraw((pt, pw) => {\r let pl = new McDbPolyline();\r let d = CMxDrawPolylineDragArcDraw_CalcArcBulge(lastPoint.pt, pt, arcDirection ? arcDirection : vecArcTangent);\r if (isReverse) d = -d;\r pl.addVertexAt(lastPoint.pt, d, lastPoint.dStartWidth, lastPoint.dEndWidth);\r pl.addVertexAt(pt, 0, dStartWidth, dEndWidth);\r pw.drawMcDbEntity(pl);\r })\r let nextPoint = await getNextPoint.go();\r if (nextPoint != null) {\r let dBulge = CMxDrawPolylineDragArcDraw_CalcArcBulge(lastPoint.pt, nextPoint, arcDirection ? arcDirection : vecArcTangent);\r if (isReverse) dBulge = -dBulge;\r lastPoint.dBulge = dBulge;\r pointArr.push({ pt: nextPoint, dBulge: 0, dStartWidth, dEndWidth });\r let pl = new McDbPolyline();\r pl.addVertexAt(lastPoint.pt, dBulge, lastPoint.dStartWidth, lastPoint.dEndWidth);\r pl.addVertexAt(nextPoint, 0, dStartWidth, dEndWidth);\r drawObjIds.push(mxcad.drawEntity(pl));\r } else if (getNextPoint.getStatus() === Mx.MrxDbgUiPrBaseReturn.kKeyWord) {\r // 获取用户输入关键字\r let keyWord = getNextPoint.keyWordPicked();\r if (keyWord === 'L') {\r // 变直线\r isArc = false;\r } else if (keyWord === 'U') {\r // 回退\r if (pointArr.length > 1 && drawObjIds.length > 1) {\r pointArr.pop();\r drawObjIds[drawObjIds.length - 1].erase();\r drawObjIds.pop();\r }\r } else if (keyWord === 'S') {\r // 用户指定圆弧的第二个点\r let getPoint2 = new MxCADUiPrPoint();//用户输入的指定点\r getPoint2.setMessage("指定圆弧的第二个点");\r let pt2: any = await getPoint2.go();\r if (pt2 === null) return\r let getPoint3 = new MxCADUiPrPoint();\r getPoint3.setMessage("指定圆弧的端点");\r let lastPoint = pointArr[pointArr.length - 1]\r getPoint3.setUserDraw((pt, pw) => {\r let arc = new McDbArc();\r arc.computeArc(lastPoint.pt.x, lastPoint.pt.y, pt2.x, pt2.y, pt.x, pt.y);//三点绘制圆弧\r pw.drawMcDbEntity(arc);\r });\r let pt3 = await getPoint3.go();\r if (!pt3) break;\r let retB = MxCADUtility.calcBulge(lastPoint.pt, pt2, pt3);//开始点,中点,结束点 三点计算当前弧线的凸度\r if (!retB.ret) break;\r pointArr[pointArr.length - 1] = retB.val;\r pointArr.push({ pt: pt3, dBulge: 0, dStartWidth, dEndWidth });//最后一个点\r let pl = new McDbPolyline();\r pl.addVertexAt(lastPoint.pt, retB.val, dStartWidth, dEndWidth);\r pl.addVertexAt(pt3);\r drawObjIds.push(mxcad.drawEntity(pl));\r } else if (keyWord === 'W') {\r // 设置宽度\r let getWidth = new MxCADUiPrDist();\r getWidth.setMessage('指定起点宽度:');\r // 获取线宽\r let dWVal = await getWidth.go();\r if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r dStartWidth = getWidth.value();\r pointArr[pointArr.length - 1].dStartWidth = dStartWidth;\r }\r getWidth.setMessage('指定端点宽度');\r dWVal = await getWidth.go();\r if (dWVal !== null && getWidth.getStatus() !== Mx.MrxDbgUiPrBaseReturn.kNone) {\r dEndWidth = getWidth.value();\r pointArr[pointArr.length - 1].dEndWidth = dEndWidth;\r }\r } else if (keyWord === 'D') {\r // 指定圆弧切向\r let getDirection = new MxCADUiPrPoint();\r getDirection.setMessage('指定圆弧起点的切向:');\r let dirVal = await getDirection.go();\r if (dirVal === null) break;\r arcDirection = new McGeVector3d(dirVal.x, dirVal.y, dirVal.z)\r } else if (keyWord === 'CE') {\r // 确定圆心\r let getCenter = new MxCADUiPrPoint();\r getCenter.setMessage('指定圆弧的圆心:');\r let arcCenter: any = await getCenter.go();\r if (!arcCenter) return;\r // 起始角度:起点与圆心的连线与X轴正方向的夹角\r // 结束角度:结束点与圆心的连线与X轴正方向的夹角\r let getNextPoint = new MxCADUiPrPoint();\r let lastPoint = pointArr[pointArr.length - 1];\r let r: number = 0;//圆弧凸度\r let arc = new McDbArc();//圆弧\r // 开端的圆弧切向量取水平方向./获取圆弧切向\r getNextPoint.setUserDraw(async (pt, pw) => {\r // 起始角度\r arc.startAngle = lastPoint.pt.sub(arcCenter).angleTo1(new McGeVector3d(arcCenter.x, 0, 0))//始终不变\r arc.endAngle = pt.sub(arcCenter).angleTo1(new McGeVector3d(arcCenter.x, 0, 0))\r arc.center = arcCenter;\r arc.radius = arcCenter.distanceTo(lastPoint.pt);\r if (pt.y < arcCenter.y) arc.endAngle = -arc.endAngle;\r // // 获取圆弧上的第三个点\r let lineX = new McDbPolyline();\r lineX.addVertexAt(new McGePoint3d(arcCenter.x, 0, 0));\r lineX.addVertexAt(new McGePoint3d(0, 0, 0));\r let pointsX = arc.IntersectWith(lineX, 3);//X轴交点\r // 获取凸度\r let rLine = new McDbPolyline();\r rLine.addVertexAt(arcCenter);\r rLine.addVertexAt(pt);\r let currentPoint = arc.IntersectWith(rLine, 2);//当前线段与圆弧的交点\r let cp: any = null;\r if (currentPoint.length() === 1) {\r cp = currentPoint.at(0);\r } else {\r if (pt.distanceTo(currentPoint.at(0)) <= pt.distanceTo(currentPoint.at(1))) {\r cp = currentPoint.at(0);\r } else {\r cp = currentPoint.at(1);\r }\r }\r let retB = MxCADUtility.calcBulge(lastPoint.pt, pointsX.at(0), cp);\r if (retB.ret) {\r r = retB.val;\r let pl = new McDbPolyline()\r pl.addVertexAt(lastPoint.pt, r);\r pl.addVertexAt(cp);\r pw.drawMcDbEntity(pl)\r }\r })\r let nextPoint = await getNextPoint.go();\r if (!nextPoint) break;\r // 获取凸度\r let rLine = new McDbPolyline();\r rLine.addVertexAt(arcCenter);\r rLine.addVertexAt(nextPoint);\r let currentPoint = arc.IntersectWith(rLine, 2);\r let cp: any = null;\r if (currentPoint.length() === 1) {\r cp = currentPoint.at(0);\r } else {\r if (nextPoint.distanceTo(currentPoint.at(0)) <= nextPoint.distanceTo(currentPoint.at(1))) {\r cp = currentPoint.at(0);\r } else {\r cp = currentPoint.at(1);\r }\r }\r let pl = new McDbPolyline()\r pl.addVertexAt(lastPoint.pt, r, dStartWidth, dEndWidth);\r pl.addVertexAt(cp);\r pointArr[pointArr.length - 1].dBulge = r;\r pointArr.push({ pt: cp, dBulge: 0, dStartWidth, dEndWidth })\r drawObjIds.push(mxcad.drawEntity(pl));\r \r } else if (keyWord === 'CL') {\r // 闭合\r isAutoClose = true;\r break;\r }\r } else {\r break;\r }\r \r }\r }\r // 删除监听事件\r document.removeEventListener('keydown', () => isReverse = false)\r document.removeEventListener('keyup', () => isReverse = false)\r // 最终绘制\r /**\r * 先删除所有临时对象再重新绘制多边形\r */\r for (let i = 0; i < drawObjIds.length; i++) {\r drawObjIds[i].erase();\r }\r if (pointArr.length > 1) {\r let pl = new McDbPolyline();\r pointArr.forEach(item => {\r pl.addVertexAt(item.pt, item.dBulge, item.dStartWidth, item.dEndWidth)\r })\r pl.isClosed = isAutoClose;\r mxcad.drawEntity(pl);\r }\r }\r \r // 计算圆弧凸度\r function CMxDrawPolylineDragArcDraw_CalcArcBulge(firstPoint, nextPoint, vecArcTangent): number {\r if (firstPoint.isEqualTo(nextPoint))\r return 0.0;\r let midPt = firstPoint.c().addvec(nextPoint.c().sub(firstPoint).mult(0.5));\r \r let vecMid = nextPoint.c().sub(firstPoint);\r vecMid.rotateBy(Math.PI / 2.0, McGeVector3d.kZAxis);\r \r let tmpMidLine = new McDbLine(midPt, midPt.c().addvec(vecMid));\r \r let vecVertical = vecArcTangent.c();\r vecVertical.rotateBy(Math.PI / 2.0, McGeVector3d.kZAxis);\r \r let tmpVerticalLine = new McDbLine(firstPoint, firstPoint.c().addvec(vecVertical));\r \r let aryPoint = tmpMidLine.IntersectWith(tmpVerticalLine, McDb.Intersect.kExtendBoth);\r if (aryPoint.isEmpty())\r return 0.0;\r \r let arcCenPoint = aryPoint.at(0);\r \r let dR = arcCenPoint.distanceTo(firstPoint);\r \r vecMid.normalize();\r vecMid.mult(dR);\r \r let arcMidPt1 = arcCenPoint.c().addvec(vecMid);\r let arcMidPt2 = arcCenPoint.c().subvec(vecMid);\r let vecArcDir1 = arcMidPt1.c().sub(firstPoint);\r let vecArcDir2 = arcMidPt2.c().sub(firstPoint);\r let arcMidPt = arcMidPt1;\r if (vecArcDir1.angleTo1(vecArcTangent) > vecArcDir2.angleTo1(vecArcTangent)) {\r arcMidPt = arcMidPt2;\r }\r return MxCADUtility.calcBulge(firstPoint, arcMidPt, nextPoint).val;\r }\r \r // 调用画多段线的方法\r Mx_drawPolyline();`},{type:"交互绘图",name:"取点画椭圆",code:`import { McDbEllipse,MxCADUiPrPoint, McDbLine, McGePoint3d, MxCADUiPrDist, MxCpp } from "mxcad";\r \r // 绘制椭圆\r async function drawMxDbEllipse() {\r \r // 创建椭圆对象\r const ellipse = new McDbEllipse();\r \r // 指定椭圆的轴端点\r const getPt1 = new MxCADUiPrPoint();\r getPt1.setMessage("\\n指定椭圆的轴端点:");\r const pt1 = await getPt1.go();\r if (!pt1) return;\r \r // 指定椭圆轴的另一个端点\r const getPt2 = new MxCADUiPrPoint();\r getPt2.setMessage("\\n指定椭圆轴的另一个端点:");\r getPt2.setUserDraw((pt, pw) => {\r const line = new McDbLine(pt, pt1);\r pw.drawMcDbEntity(line);\r })\r const pt2 = await getPt2.go();\r if (!pt2) return;\r \r // 获取椭圆中心点\r const center = new McGePoint3d((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2);\r ellipse.center = center;\r ellipse.majorAxis = pt1.sub(pt2);\r const xRadius = pt1.distanceTo(pt2) / 2\r \r // 指定另一条半轴长度\r const getDist = new MxCADUiPrDist();\r getDist.setMessage("指定另一条半轴长度")\r getDist.setBasePt(center)\r getDist.setUserDraw((pt, pw) => {\r const yRadius = center.distanceTo(pt) / 2\r // 设置椭圆的副轴长度与主轴长度的比值\r ellipse.radiusRatio = yRadius / xRadius\r pw.drawMcDbEntity(ellipse)\r })\r let length = await getDist.go()\r if (!length) return\r if (getDist.getDetailedResult() === Mx.DetailedResult.kCoordIn) {\r const yRadius = length / 2\r ellipse.radiusRatio = yRadius / xRadius\r }\r MxCpp.getCurrentMxCAD().drawEntity(ellipse)\r };\r \r // 调用绘制椭圆的方法\r drawMxDbEllipse();`},{type:"交互绘图",name:"选点填充",code:`import { MxCADUiPrPoint, MxCADUtility, MxCpp } from "mxcad";\r \r // 选点填充\r async function MxTest_DrawHatchFormPoint() {\r // 指定填充区域内部一点\r const getPoint = new MxCADUiPrPoint();\r getPoint.setMessage("\\n指定填充区域内部一点:");\r getPoint.disableAllTrace(true);\r getPoint.setDisableOsnap(true);\r let pt = await getPoint.go();\r if (!pt) return;\r \r // 绘制填充\r let hatch = MxCADUtility.builderHatchFromPoint(pt);\r if (!hatch) {\r Mx.MxFun.acutPrintf("没有找到闭合区域\\n")\r return;\r }\r \r let mxcad = MxCpp.getCurrentMxCAD();\r mxcad.drawEntity(hatch);\r };\r \r // 调用选点填充的方法\r MxTest_DrawHatchFormPoint();`},{type:"交互绘图",name:"插入图块",code:`import { McDbBlockReference, MxCADUiPrPoint, MxCpp } from "mxcad";\r \r function getHostUrl(): string {\r let host = window.location.hostname;\r if (host.substring(0, 4) != "http") {\r host = document.location.protocol + "//" + host;\r }\r return host;\r }\r \r // 插入图块\r async function MxTest_InsertBlock() {\r let baseUrl = "http://localhost:3000/mxcad/"\r if (baseUrl.substring(0, 16) == "http://localhost") {\r baseUrl = getHostUrl() + baseUrl.substring(16);\r }\r // 设置图块路径\r let blkFilePath = baseUrl + "tree.mxweb";\r \r // 插入图块文件\r let mxcad = MxCpp.App.getCurrentMxCAD();\r let blkrecId = await mxcad.insertBlock(blkFilePath, "tree");\r if (!blkrecId.isValid()) {\r // 插入图块\r return;\r }\r \r // 设置图块大小\r let blkRef = new McDbBlockReference();\r blkRef.blockTableRecordId = blkrecId;\r let box = blkRef.getBoundingBox();\r if (box.ret) {\r let dLen = box.maxPt.distanceTo(box.minPt);\r if (dLen > 0.00001) {\r blkRef.setScale(mxcad.getMxDrawObject().screenCoordLong2Doc(100) / dLen);\r }\r }\r \r // 指定插入基点\r let getPoint = new MxCADUiPrPoint();\r getPoint.setMessage("\\指定插入基点");\r \r // 动态绘制图块\r getPoint.setUserDraw((v, worldDraw) => {\r blkRef.position = v;\r worldDraw.drawMcDbEntity(blkRef);\r });\r \r let pt = await getPoint.go();\r if (!pt) return;\r blkRef.position = pt;\r // 绘制图块\r let newBlkRefId = mxcad.drawEntity(blkRef);\r if (!newBlkRefId.isValid) {\r console.log("insert error");\r return;\r }\r };\r \r // 调用插入图块方法\r MxTest_InsertBlock();`},{type:"交互绘图",name:"绘制矩形",code:`import { IMcDbDwgFiler, McDbCustomEntity, McDbPolyline, McGePoint3d, McGePoint3dArray, MxCADUiPrPoint, MxCADWorldDraw, MxCpp } from "mxcad";\r \r // 新创建 McDbTestLineCustomEntity 类继承 McDbCustomEntity\r class McDbTestRectangle extends McDbCustomEntity {\r // 定义McDbTestLineCustomEntity内部的点对象 \r // 矩形角点pt1、pt2\r private pt1: McGePoint3d = new McGePoint3d();\r private pt2: McGePoint3d = new McGePoint3d();\r // 构造函数\r constructor(imp?: any) {\r super(imp);\r }\r // 创建函数\r public create(imp: any) {\r return new McDbTestRectangle(imp)\r }\r // 获取类名\r public getTypeName(): string {\r return "McDbTestRectangle";\r }\r // 读取自定义实体数据pt1、pt2\r public dwgInFields(filter: IMcDbDwgFiler): boolean {\r this.pt1 = filter.readPoint("pt1").val;\r this.pt2 = filter.readPoint("pt2").val;\r return true;\r }\r // 写入自定义实体数据pt1、pt2\r public dwgOutFields(filter: IMcDbDwgFiler): boolean {\r filter.writePoint("pt1", this.pt1);\r filter.writePoint("pt2", this.pt2);\r return true;\r }\r \r // 移动自定义对象的夹点\r public moveGripPointsAt(iIndex: number, dXOffset: number, dYOffset: number, dZOffset: number) {\r this.assertWrite();\r if (iIndex == 0) {\r this.pt1.x += dXOffset;\r this.pt1.y += dYOffset;\r this.pt1.z += dZOffset;\r }\r else if (iIndex == 1) {\r this.pt2.x += dXOffset;\r this.pt2.y += dYOffset;\r this.pt2.z += dZOffset;\r }\r };\r // 获取自定义对象的夹点\r public getGripPoints(): McGePoint3dArray {\r let ret = new McGePoint3dArray()\r ret.append(this.pt1);\r ret.append(this.pt2);\r return ret;\r };\r // 绘制实体\r public worldDraw(draw: MxCADWorldDraw): void {\r const pl = new McDbPolyline();\r pl.isClosed = true;\r pl.addVertexAt(this.pt1);\r pl.addVertexAt(new McGePoint3d(this.pt2.x, this.pt1.y));\r pl.addVertexAt(this.pt2);\r pl.addVertexAt(new McGePoint3d(this.pt1.x, this.pt2.y));\r draw.drawEntity(pl);\r }\r // 设置pt1\r public setPoint1(pt1: McGePoint3d) {\r this.assertWrite();\r this.pt1 = pt1.clone();\r }\r // 设置pt2\r public setPoint2(pt2: McGePoint3d) {\r this.assertWrite();\r this.pt2 = pt2.clone();\r }\r // 获取pt1\r public getPoint1() {\r return this.pt1;\r }\r // 获取pt2\r public getPoint2() {\r return this.pt2;\r }\r }\r \r \r async function MxTest_DrawCustomEntity() {\r let mxcad = MxCpp.getCurrentMxCAD();\r const getPoint = new MxCADUiPrPoint();\r getPoint.setMessage("\\n指定第一个角点:");\r let pt1 = await getPoint.go();\r if (!pt1) return;\r const myRect = new McDbTestRectangle();\r myRect.setPoint1(pt1);\r \r getPoint.setMessage("\\n指定第二个角点:");\r getPoint.setUserDraw((pt, pw) => {\r myRect.setPoint2(pt);\r pw.drawMcDbEntity(myRect);\r })\r let pt2 = await getPoint.go();\r if (!pt2) return;\r \r myRect.setPoint2(pt2);\r mxcad.drawEntity(myRect);\r }\r \r // 注册自定义实体\r new McDbTestRectangle().rxInit();\r // 调用方法绘制自定义实体\r MxTest_DrawCustomEntity();\r `},{type:"图纸数据库",name:"得到图纸所有对象",code:`import { McDbAlignedDimension, McDbArc, McDbBlockReference, McDbCircle, McDbDimension, McDbHatch, McDbLine, McDbMText, McDbPolyline, McDbRasterImage, McDbRotatedDimension, McDbText, MxCADSelectionSet } from "mxcad";\r \r \r // 点对象转字符串\r function McGePoint3dToString(pt): string {\r return "x=" + pt.x + ",y=" + pt.y + ",z=" + pt.z;\r }\r \r // 实体对象转json对象\r function McDbEntityToJsonObject(ent): object {\r let obj: any = {}\r obj.ObjectName = ent.objectName;// 对象名\r obj.id = ent.getObjectID().id;// 对象id\r obj.handle = ent.getHandle(); // 对象句柄\r obj.layer = ent.layer; // 对象所在图层\r obj.color = ent.trueColor.getColorString(); // 对象颜色说明字符串\r obj.colorVal = ent.trueColor.getColorValue(ent.layerId); // 对象颜色字符串\r obj.linetype = ent.linetype; // 对象线型\r obj.textStyle = ent.textStyle; // 对象文字样式\r obj.dxf0 = ent.dxf0;// 得到对象的DXF组码的类型名\r \r if (ent instanceof McDbText) {\r // 文字对象\r let txt = ent as McDbText;\r obj.position = McGePoint3dToString(txt.position);\r obj.textString = txt.textString;\r }\r else if (ent instanceof McDbMText) {\r // 多行文字对象\r let mtxt = ent as McDbMText;\r obj.contents = mtxt.contents;\r obj.location = McGePoint3dToString(mtxt.location);\r }\r else if (ent instanceof McDbLine) {\r // 直线对象\r let line = ent as McDbLine;\r obj.startPoint = McGePoint3dToString(line.startPoint);\r obj.endPoint = McGePoint3dToString(line.endPoint);\r }\r else if (ent instanceof McDbCircle) {\r // 圆对象\r let circle = ent as McDbCircle;\r obj.center = McGePoint3dToString(circle.center);\r obj.radius = circle.radius;\r }\r else if (ent instanceof McDbArc) {\r // 圆弧对象\r let arc = ent as McDbArc;\r obj.center = McGePoint3dToString(arc.center);\r obj.startAngle = arc.startAngle;\r obj.endAngle = arc.endAngle;\r }\r else if (ent instanceof McDbPolyline) {\r // 多段线对象\r let polyline = ent as McDbPolyline;\r let num = polyline.numVerts();\r obj.num = num;\r for (let i = 0; i < num; i++) {\r let pt = polyline.getPointAt(i);\r let bulge = polyline.getBulgeAt(i);\r obj["pt" + i] = McGePoint3dToString(pt.val);\r obj["bulge" + i] = bulge;\r }\r }\r else if (ent instanceof McDbBlockReference) {\r // 块引用对象\r let blkRef = ent as McDbBlockReference;\r obj.position = McGePoint3dToString(blkRef.position);\r obj.blockTransform = blkRef.blockTransform;\r obj.blockName = blkRef.blockName;\r }\r else if (ent instanceof McDbAlignedDimension) {\r // 对齐标注对象\r let alignedDim = ent as McDbAlignedDimension;\r obj.xLine1Point = McGePoint3dToString(alignedDim.xLine1Point);\r obj.xLine2Point = McGePoint3dToString(alignedDim.xLine2Point);\r let txts = alignedDim.GetAllText();\r txts.forEach((val, index) => {\r obj["txt:" + index] = val;\r });\r }\r else if (ent instanceof McDbRotatedDimension) {\r // 旋转标注对象\r let rotatedDim = ent as McDbRotatedDimension;\r obj.xLine1Point = McGePoint3dToString(rotatedDim.xLine1Point);\r obj.xLine2Point = McGePoint3dToString(rotatedDim.xLine2Point);\r let txts = rotatedDim.GetAllText();\r txts.forEach((val, index) => {\r obj["txt:" + index] = val;\r });\r }\r else if (ent instanceof McDbDimension) {\r // 标注对象\r let dim = ent as McDbDimension;\r let txts = dim.GetAllText();\r txts.forEach((val, index) => {\r obj["txt:" + index] = val;\r });\r }\r else if (ent instanceof McDbHatch) {\r // 填充对象\r let hatch = ent as McDbHatch;\r obj.patternType = hatch.patternType();\r obj.patternName = hatch.patternName();\r obj.patternAngle = hatch.patternAngle;\r obj.patternScale = hatch.patternScale;\r obj.patternSpace = hatch.patternSpace;\r obj.patternDouble = hatch.patternDouble;\r obj.hatchStyle = hatch.hatchStyle();\r obj.isSolid = hatch.isSolid();\r obj.numLoops = hatch.numLoops;\r for (let i = 0; i < obj.numLoops; i++) {\r let loop: any = hatch.getLoopAt(i);\r loop.vertices.forEach((val: any, inidex: number) => {\r loop["pt:" + inidex] = {};\r loop["pt:" + inidex].x = val.x;\r loop["pt:" + inidex].y = val.y;\r loop["pt:" + inidex].z = val.z;\r })\r obj["loop:" + i] = loop;\r };\r obj.numPatternDefinitions = hatch.numPatternDefinitions;\r for (let i = 0; i < obj.numPatternDefinitions; i++) {\r obj["patternDefinitions:" + i] = hatch.getPatternDefinitionAt(i);\r };\r }\r else if (ent instanceof McDbRasterImage) {\r // 位图对象\r let image = ent as McDbRasterImage;\r let orientation = image.getOrientation();\r obj.orientation = {};\r obj.orientation.origin = orientation.origin.toVector3();\r obj.orientation.uCorner = orientation.uCorner.toVector3();\r obj.orientation.vOnPlane = orientation.vOnPlane.toVector3();\r \r let clipBoundary = image.clipBoundary();\r obj.clipBoundary = {};\r clipBoundary.forEach((pt, index) => {\r obj.clipBoundary["pt" + index] = pt.toVector3();\r });\r \r obj.clipBoundaryType = image.clipBoundaryType();\r \r let imageDef = image.imageDefId().getMcDbRasterImageDef();\r if (imageDef) {\r obj.filePath = imageDef.sourceFileName;\r }\r }\r \r return obj;\r }\r // 得到图纸所有对象\r async function TestGetAllEntity() {\r \r let ss = new MxCADSelectionSet();\r ss.allSelect();\r ss.forEach((id) => {\r let ent: any = id.getMcDbEntity();\r if (!ent) return;\r ent = McDbEntityToJsonObject(ent);\r console.log(JSON.stringify(ent));\r })\r };\r \r // 调用得到图纸所有对象的方法\r TestGetAllEntity()`},{type:"图纸数据库",name:"添加图层",code:`import { McDbLayerTableRecord, MxCpp } from "mxcad";\r \r // 添加图层\r function MxTest_AddLayer() {\r // 获取当前mxcad对象\r let mxcad = MxCpp.App.getCurrentMxCAD();\r \r // 获取数据库图层表\r let layerTable = mxcad.getDatabase().getLayerTable();\r // 判断图层表中是否存在xxx11图层\r if (!layerTable.has("xxx11")) {\r // 不存在则创建xxx11图层\r let newLayer = new McDbLayerTableRecord();\r newLayer.name = "xxx11";\r layerTable.add(newLayer);\r }\r \r if (layerTable.has("xxx11")) {\r // 存在则打印日志\r console.log("add layer ok");\r }\r };\r \r // 调用添加图层的方法\r MxTest_AddLayer(); `},{type:"图纸数据库",name:"得到图纸所有图块",code:`import { MxCpp } from "mxcad";\r \r function MxTest_GetAllBlock() {\r // 获取当前mxcad对象\r let mxcad = MxCpp.App.getCurrentMxCAD();\r // 获取数据库块表\r let blockTable = mxcad.getDatabase().getBlockTable();\r // 获取所有块表记录的id数组\r let aryId = blockTable.getAllRecordId();\r // 遍历所有块表记录\r aryId.forEach((id) => {\r let blkRec = id.getMcDbBlockTableRecord();\r if (blkRec === null) return;\r console.log(blkRec);\r console.log("blkRec.name:" + blkRec.name);\r console.log("blkRec.origin:" + blkRec.origin);\r });\r };\r \r // 调用获取所有图块的方法\r MxTest_GetAllBlock();\r `},{type:"图纸数据库",name:"得到图纸所有图层",code:`import { MxCpp } from "mxcad";\r import { MxFun } from "mxdraw";\r \r // 获取所有图层\r function MxTest_GetAllLayer() {\r // 获取当前mxcad对象\r let mxcad = MxCpp.App.getCurrentMxCAD();\r // 获取图层表\r let layerTable = mxcad.getDatabase().getLayerTable();\r // 获取所有记录id\r let aryId = layerTable.getAllRecordId();\r let ret = [];\r // 遍历图层id\r aryId.forEach((id) => {\r let layerRec = id.getMcDbLayerTableRecord();\r if (layerRec === null) return;\r \r console.log(layerRec);\r console.log("layerRec.color:" + layerRec.color.getColorString());\r console.log("layerRec.name:" + layerRec.name);\r let layer: any = {};\r layer.name = layerRec.name;\r \r layer.color = layerRec.color.getColorString();\r ret.push(layer);\r });\r \r MxFun.postMessageToParentFrame(ret);\r return ret;\r };\r \r // 调用获取所有图层的方法\r MxTest_GetAllLayer();`},{type:"图纸数据库",name:"得到图纸所有线型样式",code:`import { MxCpp } from "mxcad"\r \r // 获取所有线型样式\r function MxTest_GetAllLinetype() {\r // 获取当前mxcad对象\r let mxobj = MxCpp.getCurrentMxCAD();\r // 获取数据库线型样式表\r let linetypeTable = mxobj.getDatabase().getLinetypeTable();\r // 获取所有线型记录的ID数组\r let aryId = linetypeTable.getAllRecordId();\r // 遍历线型记录\r aryId.forEach((id) => {\r let linetypeRec = id.getMcDbLinetypeTableRecord();\r if (linetypeRec === null) return;\r console.log(linetypeRec);\r });\r };\r \r // 调用获取所有线型样式\r MxTest_GetAllLinetype()`},{type:"图纸数据库",name:"得到图纸所有文字样式",code:`import { MxCpp } from "mxcad";\r \r // 获取所有文字样式\r function MxTest_GetAllTextStyle() {\r // 获取当前mxcad对象\r let mxobj = MxCpp.getCurrentMxCAD();\r // 获取文字样式表\r let textSyleTable = mxobj.getDatabase().getTextStyleTable();\r // 获取文字样式表记录id数组\r let aryId = textSyleTable.getAllRecordId();\r // 遍历文字样式表记录\r aryId.forEach((id) => {\r let textSyleRec = id.getMcDbTextStyleTableRecord();\r if (textSyleRec === null) return;\r let out: any = {};\r out.name = textSyleRec.name;\r out.font = textSyleRec.font();\r out.fileName = textSyleRec.fileName;\r out.bigFontFileName = textSyleRec.bigFontFileName;\r out.textSize = textSyleRec.textSize;\r out.xScale = textSyleRec.xScale;\r console.log(out);\r });\r };\r \r // 调用获取所有文字样式的方法\r MxTest_GetAllTextStyle();\r `},{type:"图纸数据库",name:"读扩展数据",code:`import { MxCADUiPrEntity } from "mxcad";\r \r // 读取扩展数据。\r async function MxTest_ReadxData() {\r // 选择对象\r let selEntity = new MxCADUiPrEntity();\r selEntity.setMessage("选择对象");\r let id = await selEntity.go();\r if (!id.isValid()) return;\r \r // 获取对象\r let ent = id.getMcDbEntity();\r if (ent === null) return; \r \r // 得到对象的扩展数据\r let data = ent.getxData();\r //data.PrintData();\r data.forEach((val, type, dxf) => {\r console.log(JSON.stringify({ val: val, type: type, dxf: dxf }));\r })\r \r //let data = ent.getxDataString("DataName");\r //MxFun.acutPrintf(data.val + "\\n");\r };\r \r // 调用读取扩展数据的方法\r MxTest_ReadxData()`},{type:"图纸数据库",name:"写入扩展数据",code:`import { MxCADUiPrEntity } from "mxcad";\r \r // 写扩展数据\r async function MxTest_WritexData() {\r // 选择对象\r let selEntity = new MxCADUiPrEntity();\r selEntity.setMessage("选择对象");\r let id = await selEntity.go();\r if (!id.isValid()) return;\r \r // 获取对象\r let ent = id.getMcDbEntity();\r if (ent === null) return;\r // 写扩展数据\r ent.setxDataString("DataName", "xxxxx");\r //ent.setxData(new MxCADResbuf([{type:MxCADResbufDataType.kExDataName,val:"DataName"},{type:MxCADResbufDataType.kString,val:"yyyyy"}]));\r };\r \r // 调用写扩展数据的方法\r MxTest_WritexData();\r \r `},{type:"图纸数据库",name:"得到命名字典",code:`import { MxCpp, McDbDictionary, McDbXrecord } from "mxcad";\r \r // 字典数据遍历\r function MxTest_DictionaryData(dict) {\r let aryName = dict.getAllObjectName();\r aryName.forEach((name) => {\r console.log(name);\r let id = dict.getAt(name);\r let obj = id.getMcDbObject();\r if (obj instanceof McDbDictionary) {\r let dict = obj as McDbDictionary;\r console.log(dict);\r MxTest_DictionaryData(dict);\r }\r else if (obj instanceof McDbXrecord) {\r let xrec = obj as McDbXrecord;\r let data = xrec.getData()\r data.PrintData();\r }\r })\r }\r \r // 得到命名字典\r async function MxTest_GetNamedObjectsDictionary() {\r let mxcad = MxCpp.getCurrentMxCAD();\r let dict = mxcad.getDatabase().getNamedObjectsDictionary();\r let aryName = dict.getAllObjectName();\r aryName.forEach((name) => {\r console.log(name);\r let id = dict.getAt(name);\r let obj = id.getMcDbObject();\r if (obj instanceof McDbDictionary) {\r let dict = obj as McDbDictionary;\r console.log(dict);\r MxTest_DictionaryData(dict);\r }\r })\r }\r \r // 调用得到命名字典方法\r MxTest_GetNamedObjectsDictionary()`}];function WR(e,t,i){const c=e.distanceTo(t)/2,h=c*i,f=(c*c+h*h)/(2*h),r=(e.x+t.x)/2,v=(e.y+t.y)/2;return new M.McGePoint3d(r,v).addvec(t.clone().sub(e).perpVector().normalize().mult(f-h))}function jR(e,t,i){const l=Math.PI*2/360;let c=Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI*l,h=Math.atan2(i.y-e.y,i.x-e.x)*180/Math.PI*l;return{startAngle:c,endAngle:h}}X.MxFun.addCommand("list",()=>Qe(this,null,function*(){const e=yield M.MxCADUtility.userSelect("选择对象"),t=new M.MxCADUiPrPoint;X.MxFun.acutPrintf("找到"+e.length+`个 `);const i=e.pop();if(!i)return;const l=i.getMcDbEntity();if(!i.isValid()||!l)X.MxFun.acutPrintf(`对象无效 `);else if((yield db(l))===!1)return;for(;e.length;){if(t.setMessage("按 ENTER 键继续"),t.setDisableDynInput(!0),yield t.go(),t.getDetailedResult()===X.DetailedResult.kCodeAbort||t.getDetailedResult()===X.DetailedResult.kEcsIn||t.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;const c=e.pop();if(!c)break;const h=c.getMcDbEntity();if(!c.isValid()||!h){X.MxFun.acutPrintf(`对象无效 `);continue}if((yield db(h))===!1)return}}));const HR={McDbPoint:"点",McDbLine:"直线",McDbPolyline:"多段线",McDbArc:"圆弧",McDbCircle:"圆",McDbEllipse:"椭圆",McDbHatch:"填充",McDbText:"单行文本",McDbMText:"多行文本",McDbRasterImage:"光栅图片",McDbBlockReference:"块参照"},ub={Top:"上",Middle:"中",Bottom:"下",Base:"基",Left:"左",Center:"中",Right:"右",Align:"对齐",Fit:"适应",Mid:"中"},hb=e=>e.replace(/k(\w+)/g,function(t,i){return i.replace(/([A-Z])/g,"-$1").split("-").reduce((f,r)=>ub[r]?f+ub[r]:"")});function db(e){return Qe(this,null,function*(){const t=e.layer,c=M.MxCpp.getCurrentDatabase().currentSpace.name==="*Model_Space"?"模型空间":"图纸空间",h=e.getHandle();console.log(e.objectName);let f=HR[e.objectName]||e.objectName;if(e instanceof M.McDbDimension&&(f="标注"),X.MxFun.acutPrintf(` ${f} 图层: "${t}"`),X.MxFun.acutPrintf(` 空间: "${c}"`),X.MxFun.acutPrintf(` 句柄 = ${h}`),e instanceof M.McDbPoint&&X.MxFun.acutPrintf(` 于 点, X= ${e.position.x.toFixed(4)} Y= ${e.position.y.toFixed(4)} Z= ${e.position.z.toFixed(4)}`),e instanceof M.McDbLine){X.MxFun.acutPrintf(` 自 点, X= ${e.startPoint.x.toFixed(4)} Y= ${e.startPoint.y.toFixed(4)} Z= ${e.startPoint.z.toFixed(4)}`),X.MxFun.acutPrintf(` 到 点, X= ${e.startPoint.x.toFixed(4)} Y= ${e.startPoint.y.toFixed(4)} Z= ${e.startPoint.z.toFixed(4)}`);let r=e.endPoint.x-e.startPoint.x,v=e.endPoint.y-e.startPoint.y,x=e.endPoint.z-e.startPoint.z,w=THREE.MathUtils.radToDeg(Math.atan2(v,r));X.MxFun.acutPrintf(` 长度 = ${e.getLength().val.toFixed(4)},在 XY 平面中的角度 = ${Math.floor(w)}`),X.MxFun.acutPrintf(` 增量 X = ${r.toFixed(4)},增量 Y = ${v.toFixed(4)},增量 Z = ${x.toFixed(4)}`)}if(e instanceof M.McDbPolyline){X.MxFun.acutPrintf(` ${e.isClosed?"闭合":"打开"}`),X.MxFun.acutPrintf(` 固定宽度 ${e.constantWidth.toFixed(4)}`),X.MxFun.acutPrintf(` 面积 ${e.getArea().val.toFixed(4)}`),X.MxFun.acutPrintf(` 周长 ${e.getLength().val.toFixed(4)}`);const r=e.numVerts(),v=new M.MxCADUiPrPoint,x=[],w=[];let b=!1;for(let P=0;PL)for(;;){v.setMessage("按 ENTER 键继续"),v.disableAllTrace(),v.clearLastInputPoint(),v.setDynamicInputType(X.DynamicInputType.kNoInput);const V=yield v.go();if(v.getDetailedResult()===X.DetailedResult.kCodeAbort||v.getDetailedResult()===X.DetailedResult.kEcsIn)return;if(v.getDetailedResult()===X.DetailedResult.kNewCommadIn)return!1;if(v.getDetailedResult()===X.DetailedResult.kNullEnterIn||v.getDetailedResult()===X.DetailedResult.kNullSpaceIn||V){A=0;break}}const R=e.getPointAt(P).val,F=w[P];if(X.MxFun.acutPrintf(` 于端点 X= ${R.x.toFixed(1)} Y= ${R.y.toFixed(1)} Z= ${R.z.toFixed(1)}`),b&&(X.MxFun.acutPrintf(` 起点宽度 ${x[P].val1.toFixed(4)}`),X.MxFun.acutPrintf(` 端点宽度 ${x[P].val2.toFixed(4)}`)),Math.abs(F)>0){X.MxFun.acutPrintf(` 凸度 ${F.toFixed(1)}`);const V=e.getPointAt(P+1).val,j=WR(R,V,F);X.MxFun.acutPrintf(` 圆心 X= ${j.x.toFixed(1)} Y= ${j.y.toFixed(1)} Z= ${j.z.toFixed(1)}`),X.MxFun.acutPrintf(` 半径 ${j.distanceTo(R).toFixed(1)}`);const{startAngle:J,endAngle:ne}=jR(j,R,V);X.MxFun.acutPrintf(` 起点角度 ${THREE.MathUtils.radToDeg(J).toFixed(0)}`),X.MxFun.acutPrintf(` 端点角度 ${THREE.MathUtils.radToDeg(ne).toFixed(0)}`),P===r-1&&X.MxFun.acutPrintf(` 于端点 X= ${V.x.toFixed(1)} Y= ${V.y.toFixed(1)} Z= ${V.z.toFixed(1)}`)}A++}}if(e instanceof M.McDbArc&&(X.MxFun.acutPrintf(` 圆心 点, X= ${e.center.x.toFixed(4)} Y= ${e.center.y.toFixed(4)} Z= ${e.center.z.toFixed(4)}`),X.MxFun.acutPrintf(` 半径 ${e.radius.toFixed(4)}`),X.MxFun.acutPrintf(` 起点 角度 ${THREE.MathUtils.radToDeg(e.startAngle).toFixed(0)}`),X.MxFun.acutPrintf(` 端点 角度 ${THREE.MathUtils.radToDeg(e.endAngle).toFixed(0)}`),X.MxFun.acutPrintf(` 长度 ${e.getLength().val.toFixed(4)}`)),e instanceof M.McDbCircle&&(X.MxFun.acutPrintf(` 圆心 点, X= ${e.center.x.toFixed(4)} Y= ${e.center.y.toFixed(4)} Z= ${e.center.z.toFixed(4)}`),X.MxFun.acutPrintf(` 半径 ${e.radius.toFixed(4)}`),X.MxFun.acutPrintf(` 周长 ${e.getLength().val.toFixed(4)}`),X.MxFun.acutPrintf(` 面积 ${(Math.PI*e.radius*e.radius).toFixed(4)}`)),e instanceof M.McDbEllipse){const r=e.majorAxis.length(),v=e.minorAxis.length(),x=e.startAngle===0&&e.endAngle===2*Math.PI;if(x){const L=(P,R)=>{const F=Math.pow(P-R,2)/Math.pow(P+R,R);return Math.PI*(P+R)*(1+3*F/(10+Math.sqrt(4-3*F)))};X.MxFun.acutPrintf(` 面积: ${(Math.PI*r*v).toFixed(4)}`),X.MxFun.acutPrintf(` 圆周: ${L(r,v).toFixed(4)}`)}else{const L=(P,R,F,V,j)=>{const J=function(Q){return Math.sqrt(P*P*Math.sin(Q)*Math.sin(Q)+R*R*Math.cos(Q)*Math.cos(Q))};let ne=0;const H=(V-F)/j;for(let Q=0;Q<=j;Q++){const ae=F+Q*H;Q===0||Q===j?ne+=J(ae):Q%2===0?ne+=2*J(ae):ne+=4*J(ae)}return ne*=H/3,Math.abs(ne)};X.MxFun.acutPrintf(` 长度: ${L(r,v,e.startAngle,e.endAngle,30).toFixed(4)}`)}X.MxFun.acutPrintf(` 中心点: X = ${e.center.x.toFixed(4)} , Y = ${e.center.y.toFixed(4)} , Z = ${e.center.z.toFixed(4)}`);const w=r>v,b=w?e.majorAxis:e.minorAxis,A=w?e.minorAxis:e.majorAxis;if(X.MxFun.acutPrintf(` 长轴: X = ${b.x.toFixed(4)} , Y = ${b.y.toFixed(4)} , Z = ${b.z.toFixed(4)}`),X.MxFun.acutPrintf(` 短轴: X = ${A.x.toFixed(4)} , Y = ${A.y.toFixed(4)} , Z = ${A.z.toFixed(4)}`),!x){const L=(F,V,j,J,ne)=>{const H=F.x,Q=F.y,ae=V.x,ie=V.y,le=j.x,fe=j.y,me=Math.atan2(ie,ae),he=Math.sqrt(ae*ae+ie*ie),Oe=Math.sqrt(le*le+fe*fe),Ve=H+he*Math.cos(J)*Math.cos(me)-Oe*Math.sin(J)*Math.sin(me),He=Q+he*Math.cos(J)*Math.sin(me)+Oe*Math.sin(J)*Math.cos(me),at=H+he*Math.cos(ne)*Math.cos(me)-Oe*Math.sin(ne)*Math.sin(me),At=Q+he*Math.cos(ne)*Math.sin(me)+Oe*Math.sin(ne)*Math.cos(me);return{startPoint:new M.McGePoint3d(Ve,He),endPoint:new M.McGePoint3d(at,At)}},{startPoint:P,endPoint:R}=L(e.center,e.majorAxis,e.minorAxis,e.startAngle,e.endAngle);X.MxFun.acutPrintf(` 起点: X = ${P.x.toFixed(4)} , Y = ${P.y.toFixed(4)} , Z = ${P.z.toFixed(4)}`),X.MxFun.acutPrintf(` 端点: X = ${R.x.toFixed(4)} , Y = ${R.y.toFixed(4)} , Z = ${R.z.toFixed(4)}`),X.MxFun.acutPrintf(` 起点角度: ${THREE.MathUtils.radToDeg(e.startAngle).toFixed(0)}`),X.MxFun.acutPrintf(` 端点角度: ${THREE.MathUtils.radToDeg(e.endAngle).toFixed(0)}`)}X.MxFun.acutPrintf(` 半径比例: ${e.radiusRatio.toFixed(4)}`)}if(e instanceof M.McDbHatch){const r=e.patternName();X.MxFun.acutPrintf(` 填充图案 ${r}`),X.MxFun.acutPrintf(` 图案填充比例 ${e.patternScale.toFixed(4)}`),X.MxFun.acutPrintf(` 图案填充角度 ${THREE.MathUtils.radToDeg(e.patternAngle).toFixed(0)}`);const v=new M.McDbPolyline,x=[];v.isClosed=!0;for(let b=0;b{const F=L[R];v.addVertexAt(P,Number(F.toFixed(14)))}),x.push(v),M.MxCpp.getCurrentMxCAD().drawEntity(v)}const w=x.reduce((b,A)=>b+A.getArea().val,0);X.MxFun.acutPrintf(` 面积 ${w.toFixed(4)}`)}if(e instanceof M.McDbText&&(X.MxFun.acutPrintf(` 样式 = "${e.textStyle}"`),X.MxFun.acutPrintf(` 起点 点, X= ${e.position.x.toFixed(4)} Y= ${e.position.y.toFixed(4)} Z= ${e.position.z.toFixed(4)}`),X.MxFun.acutPrintf(` 高度 ${e.height.toFixed(4)}`),X.MxFun.acutPrintf(` 文字 ${e.textString}`),X.MxFun.acutPrintf(` 旋转 角度 ${e.rotation.toFixed(0)}`),X.MxFun.acutPrintf(` 宽度 比例因子 ${e.widthFactor.toFixed(4)}`)),e instanceof M.McDbMText&&(X.MxFun.acutPrintf(` 样式 = "${e.textStyle}"`),X.MxFun.acutPrintf(` 位置: X= ${e.location.x.toFixed(4)} Y= ${e.location.y.toFixed(4)} Z= ${e.location.z.toFixed(4)}`),X.MxFun.acutPrintf(` 宽度: ${e.width.toFixed(4)}`),X.MxFun.acutPrintf(` 法向: X= ${e.normal.x.toFixed(4)} Y= ${e.normal.y.toFixed(4)} Z= ${e.normal.z.toFixed(4)}`),X.MxFun.acutPrintf(` 旋转: ${e.rotation.toFixed(0)}`),X.MxFun.acutPrintf(` 文字高度: ${e.textHeight.toFixed(4)}`),X.MxFun.acutPrintf(` 附着: ${hb(M.McDb.AttachmentPoint[e.attachment])}`),X.MxFun.acutPrintf(` 内容: ${e.contents}`)),e instanceof M.McDbRasterImage){const r=e.imageDefId().getMcDbRasterImageDef(),v=b=>b.split("/").pop().split("\\").pop();X.MxFun.acutPrintf(` 图像: ${v(r.sourceFileName)}`);const x=b=>{const A=b.clipBoundaryType();if(A===M.McDb.ClipBoundaryType.kInvalid)return"无效";if(A===M.McDb.ClipBoundaryType.kPoly)return"多边形";if(A===M.McDb.ClipBoundaryType.kRect)return"矩形"};X.MxFun.acutPrintf(` 剪裁边界类型: ${x(e)}`);const w=e.clipBoundary();X.MxFun.acutPrintf(` 边界点数目: ${w.length()}`),e.clipBoundary().forEach(b=>{X.MxFun.acutPrintf(` 位于点,X= ${b.x.toFixed(4)}, Y= ${b.y.toFixed(4)}, Z= ${b.z.toFixed(4)}`)})}if(e instanceof M.McDbBlockReference&&(X.MxFun.acutPrintf(` 块名: "${e.blockName}"`),X.MxFun.acutPrintf(` 插入点: X= ${e.position.x.toFixed(4)}, Y= ${e.position.y.toFixed(4)}, Z= ${e.position.z.toFixed(4)}`),X.MxFun.acutPrintf(` X 比例因子: ${e.scaleFactors.x.toFixed(4)}`),X.MxFun.acutPrintf(` Y 比例因子: ${e.scaleFactors.y.toFixed(4)}`),X.MxFun.acutPrintf(` 旋转角度: ${e.rotation.toFixed(0)}`),X.MxFun.acutPrintf(` Z 比例因子: ${e.scaleFactors.z.toFixed(4)}`),X.MxFun.acutPrintf(` Z 比例因子: ${e.scaleFactors.z.toFixed(4)}`),X.MxFun.acutPrintf(` 缩放比例: ${e.getScale().toFixed(4)}`)),e instanceof M.McDbDimension){X.MxFun.acutPrintf(` 文字位置: X= ${e.textPosition.x.toFixed(4)} Y= ${e.textPosition.y.toFixed(4)} Z= ${e.textPosition.z.toFixed(4)}`),X.MxFun.acutPrintf(` 是否使用的默认文字位置: ${e.isUsingDefaultTextPosition()}`),X.MxFun.acutPrintf(` 高度: ${e.elevation.toFixed(4)}`),X.MxFun.acutPrintf(` 文本内容: ${e.dimensionText}`),X.MxFun.acutPrintf(` 文本旋转角度: ${THREE.MathUtils.radToDeg(e.textRotation).toFixed(0)}`);const r=e.dimensionStyle.getMcDbDimStyleTableRecord();X.MxFun.acutPrintf(` 标注样式: ${r.name}`),X.MxFun.acutPrintf(` 文字附着: ${hb(M.McDb.AttachmentPoint[e.textAttachment])}`),X.MxFun.acutPrintf(` 水平旋转角度: ${THREE.MathUtils.radToDeg(e.horizontalRotation).toFixed(0)}`),X.MxFun.acutPrintf(` 水平旋转角度: ${THREE.MathUtils.radToDeg(e.horizontalRotation).toFixed(0)}`)}X.MxFun.acutPrintf(` 命令`)})}X.MxFun.addCommand("group",()=>Qe(this,null,function*(){let e,t="",i="",l;const c=M.MxCpp.getCurrentDatabase(),h=c.GetGroupDictionary();for(;;){const f=yield M.MxCADUtility.userSelect("选择对象",null,(r,v)=>{v.setKeyWords("[名称(N)/说明(D)]"),e=v});if(e.getDetailedResult()===X.DetailedResult.kEcsIn||e.getDetailedResult()===X.DetailedResult.kCodeAbort||e.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(f&&(l=f),e.isKeyWordPicked("N")){for(;;){const r=new M.MxCADUiPrString;r.setMessage("输入编组名"),r.setKeyWords("[查询(A)]");const v=yield r.go();if(r.getDetailedResult()===X.DetailedResult.kCodeAbort||r.getDetailedResult()===X.DetailedResult.kEcsIn||r.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(r.isKeyWordPicked("A")){r.setMessage("请输入要列出的编码组名<*>"),r.setKeyWords("");const b=yield r.go();if(console.log(b),r.getDetailedResult()===X.DetailedResult.kCodeAbort||r.getDetailedResult()===X.DetailedResult.kEcsIn||r.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(b&&b!=="*"){const L=h.getAt(b).getMcDbObject();X.MxFun.acutPrintf(` 定义的编组:`),L&&X.MxFun.acutPrintf(` ${L.name}`)}else if(b==="*"||r.getDetailedResult()===X.DetailedResult.kNullEnterIn||r.getDetailedResult()===X.DetailedResult.kNullSpaceIn){const A=h.getAllObject();X.MxFun.acutPrintf(` 定义的编组:`),A.forEach(L=>{const P=L.getMcDbObject();P&&X.MxFun.acutPrintf(` ${P.name}`)})}continue}if(!v)return;const x=h.getAt(t);if(x.getMcDbObject()&&x.isValid()){X.MxFun.acutPrintf(`编组 ${t} 已经存在`);continue}t=v;break}continue}if(e.isKeyWordPicked("D")){const r=new M.MxCADUiPrString;r.setMessage("输入编组说明");const v=yield r.go();if(!v)return;i=v;continue}if(e.getDetailedResult()===X.DetailedResult.kNullEnterIn||e.getDetailedResult()===X.DetailedResult.kNullSpaceIn){if(l.some(v=>c.getEntitiesInTheGroup(v).length!==0)){const v=new M.MxCADUiPrKeyWord;v.setMessage("包含相同对象的组已经存在。仍要创建新的组?"),v.setKeyWords("[是(Y)/否(N)]");const x=yield v.go();if((x==null?void 0:x.toLocaleUpperCase())==="N"||!x)return}if(c.CreateGroup(l,t)){const x=h.getAt(t).getMcDbObject();x.description=i}}break}})),X.MxFun.addCommand("ungroup",()=>Qe(this,null,function*(){let e;const i=M.MxCpp.getCurrentDatabase().GetGroupDictionary();for(;;){const l=new M.MxCADUiPrEntity;l.setMessage("选择对象"),l.setKeyWords("[名称(N)]");const c=yield l.go();if(l.getDetailedResult()===X.DetailedResult.kEcsIn||l.getDetailedResult()===X.DetailedResult.kCodeAbort||l.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(l.isKeyWordPicked("N")){for(;;){const h=new M.MxCADUiPrString;h.setMessage("输入编组名"),h.setKeyWords("[查询(A)]");const f=yield h.go();if(h.getDetailedResult()===X.DetailedResult.kCodeAbort||h.getDetailedResult()===X.DetailedResult.kEcsIn||h.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(h.isKeyWordPicked("A")){h.setMessage("请输入要列出的编码组名<*>"),h.setKeyWords("");const x=yield h.go();if(h.getDetailedResult()===X.DetailedResult.kCodeAbort||h.getDetailedResult()===X.DetailedResult.kEcsIn||h.getDetailedResult()===X.DetailedResult.kNewCommadIn)return;if(x&&x!=="*"){const b=i.getAt(x).getMcDbObject();X.MxFun.acutPrintf(` 定义的编组:`),b&&X.MxFun.acutPrintf(` ${b.name}`)}else if(x==="*"||h.getDetailedResult()===X.DetailedResult.kNullEnterIn||h.getDetailedResult()===X.DetailedResult.kNullSpaceIn){const w=i.getAllObject();X.MxFun.acutPrintf(` 定义的编组:`),w.forEach(b=>{const A=b.getMcDbObject();A&&X.MxFun.acutPrintf(` ${A.name}`)})}continue}if(!f)return;const r=i.getAt(e);if(r.getMcDbObject()&&r.isValid()){X.MxFun.acutPrintf(`编组 ${e} 已经存在`);continue}e=f;break}continue}if(c){const h=c.getMcDbEntity();if(h){const f=h.getHandle(),r=i.getAllObjectName(),v=r.length();for(let x=0;x{const R=P.getMcDbEntity();return(R==null?void 0:R.getHandle())===f?(e=w,!0):!1})}}}if(e){const f=i.getAt(e).getMcDbObject();if(f)f.clear(),i.remove(e),X.MxFun.acutPrintf(` 组 ${e} 已分解`);else{X.MxFun.acutPrintf(` 对象不是组成员`);continue}}else{X.MxFun.acutPrintf(` 对象不是组成员`);continue}break}}));const $R=`/////////////////////////////////////////////////////////////////////////////// //版权所有(C)2002-2022,成都梦想凯德科技有限公司。 //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明 //此应用程序应与成都梦想凯德科技有限公司达成协议,使用本软件、其文档或相关材料 //https://www.mxdraw.com/ /////////////////////////////////////////////////////////////////////////////// import { McDbEntity, McDbLine, McDbPoint, McDbPolyline, MxCADUiPrPoint, MxCADUtility, MxCpp, McGePoint3d, McDbArc, McDbCircle, McDbEllipse, McGeVector3d, McDbHatch, McDbText, McDbMText, McDb, McDbRasterImageDef, McDbRasterImage, McDbBlockReference, McDbDimension } from "mxcad"; import { DetailedResult, DynamicInputType, MxDbRegularPolygonShape, MxFun } from "mxdraw"; function calculateCenter(start: McGePoint3d, end: McGePoint3d, bulge: number) { const dist = start.distanceTo(end) const dx = dist / 2 const dy = dx * bulge const r = (dx * dx + dy * dy) / (2 * dy) const midX = (start.x + end.x) / 2 const midY = (start.y + end.y) / 2 return new McGePoint3d(midX, midY).addvec(end.clone().sub(start).perpVector().normalize().mult(r - dy)) } function calculateLineAngle(center: McGePoint3d, start: McGePoint3d, end: McGePoint3d) { const deg = (Math.PI * 2) / 360 // 计算直线的角度 let startAngle = ((Math.atan2(start.y - center.y, start.x - center.x) * 180) / Math.PI) * deg let endAngle = ((Math.atan2(end.y - center.y, end.x - center.x) * 180) / Math.PI) * deg return { startAngle, endAngle } } MxFun.addCommand("list", async () => { // 选择对象获取信息 const objIds = await MxCADUtility.userSelect("选择对象") const getPoint = new MxCADUiPrPoint() MxFun.acutPrintf("找到" + objIds.length + "个\\n") const objId = objIds.pop() if (!objId) return const ent = objId.getMcDbEntity() if (!objId.isValid() || !ent) { MxFun.acutPrintf("对象无效\\n") } else { if (await printInfo(ent) === false) return } while (objIds.length) { getPoint.setMessage("按 ENTER 键继续") getPoint.setDisableDynInput(true) await getPoint.go() // 程序中止、按下Esc键、新的命令运行时退出 if (getPoint.getDetailedResult() === DetailedResult.kCodeAbort) return if (getPoint.getDetailedResult() === DetailedResult.kEcsIn) return if (getPoint.getDetailedResult() === DetailedResult.kNewCommadIn) return const objId = objIds.pop() if (!objId) break; const ent = objId.getMcDbEntity() if (!objId.isValid() || !ent) { MxFun.acutPrintf("对象无效\\n") continue } if (await printInfo(ent) === false) return } }) // 记录对象的名称 const entNames = { "McDbPoint": "点", "McDbLine": "直线", "McDbPolyline": "多段线", "McDbArc": "圆弧", "McDbCircle": "圆", "McDbEllipse": "椭圆", "McDbHatch": "填充", "McDbText": "单行文本", "McDbMText": "多行文本", "McDbRasterImage": "光栅图片", "McDbBlockReference": "块参照", } // 附着名称字典 const map = { Top: "上", Middle: "中", Bottom: "下", Base: "基", Left: "左", Center: "中", Right: "右", Align: "对齐", Fit: "适应", Mid: "中" }; // 获取文字的附着名称 const getAttachmentName = (str: string) => { return str.replace(/k(\\w+)/g, function (_, p1) { let key = p1.replace(/([A-Z])/g, "-$1") as string const arr = key.split("-") const name = arr.reduce((name, key) => { if (map[key]) { return name + map[key]; } else { return ""; } }) return name }); } // 打印信息 async function printInfo(ent: McDbEntity) { // 得到所有对象的基本信息 const layer = ent.layer const layoutBlockName = MxCpp.getCurrentDatabase().currentSpace.name const isMainModel = layoutBlockName === "*Model_Space" const modeName = isMainModel ? "模型空间" : "图纸空间" const handle = ent.getHandle() console.log(ent.objectName) let entName = entNames[ent.objectName] || ent.objectName if(ent instanceof McDbDimension) { entName = "标注" } MxFun.acutPrintf(\`\\n \${entName} 图层: "\${layer}"\`) MxFun.acutPrintf(\`\\n 空间: "\${modeName}"\`) MxFun.acutPrintf(\`\\n 句柄 = \${handle}\`) // 点对象的信息 if (ent instanceof McDbPoint) { MxFun.acutPrintf(\`\\n 于 点, X= \${ent.position.x.toFixed(4)} Y= \${ent.position.y.toFixed(4)} Z= \${ent.position.z.toFixed(4)}\`) } // 直线对象的信息 if (ent instanceof McDbLine) { MxFun.acutPrintf(\`\\n 自 点, X= \${ent.startPoint.x.toFixed(4)} Y= \${ent.startPoint.y.toFixed(4)} Z= \${ent.startPoint.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 到 点, X= \${ent.startPoint.x.toFixed(4)} Y= \${ent.startPoint.y.toFixed(4)} Z= \${ent.startPoint.z.toFixed(4)}\`) let deltaX = ent.endPoint.x - ent.startPoint.x; let deltaY = ent.endPoint.y - ent.startPoint.y; let deltaZ = ent.endPoint.z - ent.startPoint.z; // 使用atan2计算角度,结果是弧度,转换为度 let angleInDegrees = THREE.MathUtils.radToDeg(Math.atan2(deltaY, deltaX)); MxFun.acutPrintf(\`\\n 长度 = \${ent.getLength().val.toFixed(4)},在 XY 平面中的角度 = \${Math.floor(angleInDegrees)}\`) MxFun.acutPrintf(\`\\n 增量 X = \${deltaX.toFixed(4)},增量 Y = \${deltaY.toFixed(4)},增量 Z = \${deltaZ.toFixed(4)}\`) } // 多段线对象的信息 if (ent instanceof McDbPolyline) { MxFun.acutPrintf(\`\\n \${ent.isClosed ? "闭合" : "打开"}\`) MxFun.acutPrintf(\`\\n 固定宽度 \${ent.constantWidth.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 面积 \${ent.getArea().val.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 周长 \${ent.getLength().val.toFixed(4)}\`) // 输出多段线的每个点的信息 const num = ent.numVerts() // 通过取点对象控制输出量 只有在按下空格或者回车才会继续打印剩余信息 const getPoint = new MxCADUiPrPoint() // 记录点包含的其他信息如线宽、凸度值等 const widthInfos: { val1: number; val2: number; ret: boolean; }[] = [] const bulges: number[] = [] // 记录是否打印线宽 let isPrintWidth = false for (let index = 0; index < num; index++) { const width = ent.getWidthsAt(index) const bulge = ent.getBulgeAt(index) if (width.val1 !== 0 || width.val2 !== 0) { isPrintWidth = true } widthInfos.push(width) bulges.push(bulge) } // 控制输出打印量 let accumulated = 0 const maxIndex = 3 for (let index = 0; index < num; index++) { if (accumulated > maxIndex) { while (true) { getPoint.setMessage("按 ENTER 键继续") getPoint.disableAllTrace() getPoint.clearLastInputPoint() // 设置不需要动态的输入框 getPoint.setDynamicInputType(DynamicInputType.kNoInput) const pt = await getPoint.go() if (getPoint.getDetailedResult() === DetailedResult.kCodeAbort) return if (getPoint.getDetailedResult() === DetailedResult.kEcsIn) return if (getPoint.getDetailedResult() === DetailedResult.kNewCommadIn) return false // 只有回车和空格或者鼠标左键点击才能继续往下走打印的流程, 否则始终循环等待用户输入 if (getPoint.getDetailedResult() === DetailedResult.kNullEnterIn || getPoint.getDetailedResult() === DetailedResult.kNullSpaceIn || pt) { accumulated = 0 break; } } } const point = ent.getPointAt(index).val const bulge = bulges[index] MxFun.acutPrintf(\`\\n 于端点 X= \${point.x.toFixed(1)} Y= \${point.y.toFixed(1)} Z= \${point.z.toFixed(1)}\`) if (isPrintWidth) { MxFun.acutPrintf(\`\\n 起点宽度 \${widthInfos[index].val1.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 端点宽度 \${widthInfos[index].val2.toFixed(4)}\`) } // 凸度不为0时 且 if (Math.abs(bulge) > 0) { MxFun.acutPrintf(\`\\n 凸度 \${bulge.toFixed(1)}\`) const nextPoint = ent.getPointAt(index + 1).val const center = calculateCenter(point, nextPoint, bulge) MxFun.acutPrintf(\`\\n 圆心 X= \${center.x.toFixed(1)} Y= \${center.y.toFixed(1)} Z= \${center.z.toFixed(1)}\`) MxFun.acutPrintf(\`\\n 半径 \${center.distanceTo(point).toFixed(1)}\`) const { startAngle, endAngle } = calculateLineAngle(center, point, nextPoint) MxFun.acutPrintf(\`\\n 起点角度 \${THREE.MathUtils.radToDeg(startAngle).toFixed(0)}\`) MxFun.acutPrintf(\`\\n 端点角度 \${THREE.MathUtils.radToDeg(endAngle).toFixed(0)}\`) // 最后一次循环加上最后一个端点信息 if (index === num - 1) { MxFun.acutPrintf(\`\\n 于端点 X= \${nextPoint.x.toFixed(1)} Y= \${nextPoint.y.toFixed(1)} Z= \${nextPoint.z.toFixed(1)}\`) } } accumulated++ } } // 圆弧的信息 if (ent instanceof McDbArc) { MxFun.acutPrintf(\`\\n 圆心 点, X= \${ent.center.x.toFixed(4)} Y= \${ent.center.y.toFixed(4)} Z= \${ent.center.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 半径 \${ent.radius.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 起点 角度 \${THREE.MathUtils.radToDeg(ent.startAngle).toFixed(0)}\`) MxFun.acutPrintf(\`\\n 端点 角度 \${THREE.MathUtils.radToDeg(ent.endAngle).toFixed(0)}\`) MxFun.acutPrintf(\`\\n 长度 \${ent.getLength().val.toFixed(4)}\`) } // 圆的信息 if (ent instanceof McDbCircle) { MxFun.acutPrintf(\`\\n 圆心 点, X= \${ent.center.x.toFixed(4)} Y= \${ent.center.y.toFixed(4)} Z= \${ent.center.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 半径 \${ent.radius.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 周长 \${ent.getLength().val.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 面积 \${(Math.PI * ent.radius * ent.radius).toFixed(4)}\`) } // 椭圆的信息 if (ent instanceof McDbEllipse) { // 得到椭圆的半轴长度 const radius1 = ent.majorAxis.length() const radius2 = ent.minorAxis.length() // 是否是椭圆 为false表示是椭圆弧 const isEllipse = ent.startAngle === 0 && ent.endAngle === 2 * Math.PI if (isEllipse) { const calculateEllipseCircumference = (radius1: number, radius2: number) => { const h = Math.pow((radius1 - radius2), 2) / Math.pow((radius1 + radius2), radius2); const circumference = Math.PI * (radius1 + radius2) * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h))); return circumference; } MxFun.acutPrintf(\`\\n 面积: \${(Math.PI * radius1 * radius2).toFixed(4)}\`) MxFun.acutPrintf(\`\\n 圆周: \${calculateEllipseCircumference(radius1, radius2).toFixed(4)}\`) } else { // 计算椭圆弧的长度 const arcLengthOfEllipse = (a: number, b: number, theta1: number, theta2: number, numSteps: number) => { // a: 长半轴 // b: 短半轴 // 定义被积函数 const integrand = function (theta: number) { return Math.sqrt(a * a * Math.sin(theta) * Math.sin(theta) + b * b * Math.cos(theta) * Math.cos(theta)); }; // 使用复合辛普森法则进行数值积分 let integral = 0; const stepSize = (theta2 - theta1) / numSteps; for (let i = 0; i <= numSteps; i++) { const theta = theta1 + i * stepSize; if (i === 0 || i === numSteps) { integral += integrand(theta); } else if (i % 2 === 0) { integral += 2 * integrand(theta); } else { integral += 4 * integrand(theta); } } integral *= stepSize / 3; return Math.abs(integral); } MxFun.acutPrintf(\`\\n 长度: \${arcLengthOfEllipse(radius1, radius2, ent.startAngle, ent.endAngle, 30).toFixed(4)}\`) } MxFun.acutPrintf(\`\\n 中心点: X = \${ent.center.x.toFixed(4)} , Y = \${ent.center.y.toFixed(4)} , Z = \${ent.center.z.toFixed(4)}\`) // 判断哪个是半轴长度较长的轴 const isMaxAxis = radius1 > radius2 const maxAxis = isMaxAxis ? ent.majorAxis : ent.minorAxis const minAxis = isMaxAxis ? ent.minorAxis : ent.majorAxis MxFun.acutPrintf(\`\\n 长轴: X = \${maxAxis.x.toFixed(4)} , Y = \${maxAxis.y.toFixed(4)} , Z = \${maxAxis.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 短轴: X = \${minAxis.x.toFixed(4)} , Y = \${minAxis.y.toFixed(4)} , Z = \${minAxis.z.toFixed(4)}\`) // 椭圆弧的其他信息 if (!isEllipse) { // 计算椭圆弧的起点和端点 const calculateEllipseEndpoints = (center: McGePoint3d, v1: McGeVector3d, v2: McGeVector3d, theta1: number, theta2: number) => { // 椭圆中心坐标 const cx = center.x; const cy = center.y; // 主轴向量 const vx1 = v1.x; const vy1 = v1.y; // 副轴向量 const vx2 = v2.x; const vy2 = v2.y; // 计算椭圆的起始点和结束点 const alpha = Math.atan2(vy1, vx1) const a = Math.sqrt(vx1 * vx1 + vy1 * vy1); // 长轴半径 const b = Math.sqrt(vx2 * vx2 + vy2 * vy2); // 短轴半径 // 根据角度计算起始点和结束点 const startEndpointX = cx + a * Math.cos(theta1) * Math.cos(alpha) - b * Math.sin(theta1) * Math.sin(alpha); const startEndpointY = cy + a * Math.cos(theta1) * Math.sin(alpha) + b * Math.sin(theta1) * Math.cos(alpha); const endEndpointX = cx + a * Math.cos(theta2) * Math.cos(alpha) - b * Math.sin(theta2) * Math.sin(alpha); const endEndpointY = cy + a * Math.cos(theta2) * Math.sin(alpha) + b * Math.sin(theta2) * Math.cos(alpha); return { startPoint: new McGePoint3d(startEndpointX, startEndpointY), endPoint: new McGePoint3d(endEndpointX, endEndpointY) }; } const { startPoint, endPoint } = calculateEllipseEndpoints(ent.center, ent.majorAxis, ent.minorAxis, ent.startAngle, ent.endAngle) MxFun.acutPrintf(\`\\n 起点: X = \${startPoint.x.toFixed(4)} , Y = \${startPoint.y.toFixed(4)} , Z = \${startPoint.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 端点: X = \${endPoint.x.toFixed(4)} , Y = \${endPoint.y.toFixed(4)} , Z = \${endPoint.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 起点角度: \${THREE.MathUtils.radToDeg(ent.startAngle).toFixed(0)}\`) MxFun.acutPrintf(\`\\n 端点角度: \${THREE.MathUtils.radToDeg(ent.endAngle).toFixed(0)}\`) } MxFun.acutPrintf(\`\\n 半径比例: \${ent.radiusRatio.toFixed(4)}\`) } // 填充对象信息 if(ent instanceof McDbHatch) { const patternName = ent.patternName() MxFun.acutPrintf(\`\\n 填充图案 \${patternName}\`) MxFun.acutPrintf(\`\\n 图案填充比例 \${ent.patternScale.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 图案填充角度 \${THREE.MathUtils.radToDeg(ent.patternAngle).toFixed(0)}\`) const pl = new McDbPolyline() const pls: McDbPolyline[] = [] pl.isClosed = true for (let index = 0; index < ent.numLoops; index++) { const { vertices, bulges } = ent.getLoopAt(index) vertices.forEach((pt, index)=> { const bulge = bulges[index] pl.addVertexAt(pt, Number(bulge.toFixed(14))) }) pls.push(pl) MxCpp.getCurrentMxCAD().drawEntity(pl) } const totalArea = pls.reduce((totalArea, pl)=> totalArea + pl.getArea().val, 0) MxFun.acutPrintf(\`\\n 面积 \${totalArea.toFixed(4)}\`) } // 单行文字信息 if(ent instanceof McDbText) { MxFun.acutPrintf(\`\\n 样式 = "\${ent.textStyle}"\`) MxFun.acutPrintf(\`\\n 起点 点, X= \${ent.position.x.toFixed(4)} Y= \${ent.position.y.toFixed(4)} Z= \${ent.position.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 高度 \${ent.height.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 文字 \${ent.textString}\`) MxFun.acutPrintf(\`\\n 旋转 角度 \${ent.rotation.toFixed(0)}\`) MxFun.acutPrintf(\`\\n 宽度 比例因子 \${ent.widthFactor.toFixed(4)}\`) } // 多行文字信息 if(ent instanceof McDbMText) { MxFun.acutPrintf(\`\\n 样式 = "\${ent.textStyle}"\`) MxFun.acutPrintf(\`\\n位置: X= \${ent.location.x.toFixed(4)} Y= \${ent.location.y.toFixed(4)} Z= \${ent.location.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n宽度: \${ent.width.toFixed(4)}\`) MxFun.acutPrintf(\`\\n法向: X= \${ent.normal.x.toFixed(4)} Y= \${ent.normal.y.toFixed(4)} Z= \${ent.normal.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n旋转: \${ent.rotation.toFixed(0)}\`) MxFun.acutPrintf(\`\\n文字高度: \${ent.textHeight.toFixed(4)}\`) MxFun.acutPrintf(\`\\n附着: \${getAttachmentName(McDb.AttachmentPoint[ent.attachment])}\`) MxFun.acutPrintf(\`\\n内容: \${ent.contents}\`) } // 光栅图片信息 if(ent instanceof McDbRasterImage) { const imgDef = ent.imageDefId().getMcDbRasterImageDef() const getFileNameFromPath = (path: string)=> { return path.split('/').pop().split('\\\\').pop(); } MxFun.acutPrintf(\`\\n图像: \${getFileNameFromPath(imgDef.sourceFileName)}\`) const getClipBoundaryType = (ent: McDbRasterImage)=> { const type = ent.clipBoundaryType() if(type === McDb.ClipBoundaryType.kInvalid) return "无效" if(type === McDb.ClipBoundaryType.kPoly) return "多边形" if(type === McDb.ClipBoundaryType.kRect) return "矩形" } MxFun.acutPrintf(\`\\n剪裁边界类型: \${getClipBoundaryType(ent)}\`) const clipBoundary = ent.clipBoundary() MxFun.acutPrintf(\`\\n边界点数目: \${clipBoundary.length()}\`) ent.clipBoundary().forEach((pt)=> { MxFun.acutPrintf(\`\\n 位于点,X= \${pt.x.toFixed(4)}, Y= \${pt.y.toFixed(4)}, Z= \${pt.z.toFixed(4)}\`) }) } // 图块信息 if(ent instanceof McDbBlockReference) { MxFun.acutPrintf(\`\\n块名: "\${ent.blockName}"\`) MxFun.acutPrintf(\`\\n插入点: X= \${ent.position.x.toFixed(4)}, Y= \${ent.position.y.toFixed(4)}, Z= \${ent.position.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\nX 比例因子: \${ent.scaleFactors.x.toFixed(4)}\`) MxFun.acutPrintf(\`\\nY 比例因子: \${ent.scaleFactors.y.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 旋转角度: \${ent.rotation.toFixed(0)}\`) MxFun.acutPrintf(\`\\nZ 比例因子: \${ent.scaleFactors.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\nZ 比例因子: \${ent.scaleFactors.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n 缩放比例: \${ent.getScale().toFixed(4)}\`) } // 标注信息 if(ent instanceof McDbDimension) { MxFun.acutPrintf(\`\\n文字位置: X= \${ent.textPosition.x.toFixed(4)} Y= \${ent.textPosition.y.toFixed(4)} Z= \${ent.textPosition.z.toFixed(4)}\`) MxFun.acutPrintf(\`\\n是否使用的默认文字位置: \${ent.isUsingDefaultTextPosition()}\`) MxFun.acutPrintf(\`\\n高度: \${ent.elevation.toFixed(4)}\`) MxFun.acutPrintf(\`\\n文本内容: \${ent.dimensionText}\`) MxFun.acutPrintf(\`\\n文本旋转角度: \${THREE.MathUtils.radToDeg(ent.textRotation).toFixed(0)}\`) const dimStyle = ent.dimensionStyle.getMcDbDimStyleTableRecord() MxFun.acutPrintf(\`\\n标注样式: \${dimStyle.name}\`) MxFun.acutPrintf(\`\\n文字附着: \${getAttachmentName(McDb.AttachmentPoint[ent.textAttachment])}\`) MxFun.acutPrintf(\`\\n水平旋转角度: \${THREE.MathUtils.radToDeg(ent.horizontalRotation).toFixed(0)}\`) MxFun.acutPrintf(\`\\n水平旋转角度: \${THREE.MathUtils.radToDeg(ent.horizontalRotation).toFixed(0)}\`) } MxFun.acutPrintf("\\n命令") } `,qR=e=>{const t=/\/\/{24}[\s\S]*\/\/{24}/g;return e.replace(t,"")};(e=>{e.push({type:"命令实现",name:"list 命令",code:qR($R)})})(cb);class XR extends M.MxCADPluginBase{constructor(){super(),this.map_default_data=OR(),this.sampleCode=cb}}let lu;const{showModal:ZR,hideModal:vl,showTools:YR}=$p();function KR(){return Qe(this,null,function*(){ZR({title:"My Test Draw",text:"测试Modal",oncancel:()=>{vl()},onsubmit:()=>{vl()},ongetallentity:()=>{vl(),X.MxFun.sendStringToExecute("TestGetAllEntity")},ondrawline:()=>{vl(),X.MxFun.sendStringToExecute("Mx_Circle")},docommand:e=>{vl(),X.MxFun.sendStringToExecute(e)}})})}function JR(){return Qe(this,null,function*(){YR({title:"My Extension Tools",text:"扩展工具",oncancel:()=>{vl()},docommand:e=>{vl(),X.MxFun.sendStringToExecute(e)}})})}const pb=document.createElement("div");document.body.appendChild(pb),q.createApp(W2).mount(pb),H2(),X.MxFun.onInitSync(()=>new Promise(e=>{e(!0)})),X.MxFun.on("mxcadApplicationStart",e=>{lu=e,lu.init(new XR)}),X.MxFun.on("mxcadApplicationInitMap",()=>{NR(lu.mxmap)}),X.MxFun.on("mxcadApplicationStartCreatingMxCADObject",e=>{let t=e.mxdraw;t.setViewMovementMethod(!0),t.on("openFileComplete",()=>{window.parent.postMessage({cmd:"MKY_Open_File_Complete"})}),t.addControlsEvent("mousedown",i=>{let l=i.offsetX,c=i.offsetY,h=t.viewCoord2Cad(l,c,0);return console.log("mousedown:",h),0})}),X.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{let t=lu.getServerConfig();M.MxCpp.App.addNetworkLoadingFont(t.font||["txt.shx","simplex.shx","gdt.shx","aaa.shx","ltypeshp.shx","complex.shx"]),M.MxCpp.App.addNetworkLoadingBigFont(t.bigFont||["hztxt.shx","gbcbig.shx"]),t.trueTypeFont?M.MxCpp.App.addNetworkLoadingTrueTypeFont(t.trueTypeFont[0],t.trueTypeFont[1],t.trueTypeFont[2]):M.MxCpp.App.addNetworkLoadingTrueTypeFont(["syadobe"],["思原黑体"],["syadobe.otf"]);let i=e.mxcad;i.setAttribute({DisplayPrecision:35}),i.on("selectChange",l=>{if(l.length==0)return;let c=l[0],h=c.getMxDbEntity();if(h!==null){console.log(h.getTypeName()),h instanceof X.MxDbRectBoxLeadComment&&console.log(h.text);return}let f=c.getMcDbEntity();f!==null&&(console.log(f.objectName),f instanceof M.McDbText?console.log(f.textString):f instanceof M.McDbBlockReference&&f.getAllAttribute().forEach(x=>{let w=x.getMcDbEntity();console.log(w.textString),console.log(w.tag)}))}),M.MxCpp.PropertiesWindow.onEvent_getProperties(l=>{let c=l.getMcDbEntity();if(!c)return[];let h=c.getxDataDouble("DN"),f=c.getxDataDouble("LEN"),r=[];return h.ret&&r.push({sVarName:"DN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),f.ret&&r.push({sVarName:"LEN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:f.val,isOnlyRead:!1}),r}),M.MxCpp.PropertiesWindow.onEvent_setProperties((l,c)=>{let h=l.getMcDbEntity();h&&(c.sVarName=="DN"?h.setxDataDouble("DN",c.val):c.sVarName=="LEN"&&h.setxDataDouble("LEN",c.val))})});function xl(){return lu}function Cr(e){return"x="+e.x+",y="+e.y+",z="+e.z}function QR(){window.open("https://demo.mxdraw3d.com:3562/MxCADCode.7z")}function ek(){window.open("https://demo.mxdraw3d.com:3562/MxDrawCloudServer1.0TryVersion.7z")}function cu(e){var t=window.location.href;return t.indexOf("?")!=-1&&(t=t.replace(/(\?|#)[^'"]*/,"")),`${t}?map=true&maptype=${e}`}function tk(){window.open(cu("gdslwzj"))}function nk(){window.open(cu("google"))}function ik(){window.open(cu("gdyx"))}function rk(){window.open(cu("tdtsl"))}function ok(){window.open(cu("bdsl"))}function ak(){window.open(cu("geoq"))}function sk(){M.MxCpp.getCurrentMxCAD().setViewBackgroundColor(255,255,255),X.MxFun.callEvent("updateBackgroundColor",new M.McCmColor(255,255,255))}function fb(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择要需要开启自定义属性的对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity();M.MxCpp.PropertiesWindow.setEntitySupportCustom(t),i.setxDataDouble("DN",100),i.setxDataDouble("LEN",2e3)})}function lk(){M.MxCpp.getCurrentMxCAD().openWebFile("http://localhost:1337/mxcad/file/a9cbed3d3a351b79f24484e87bd78338.DWG.mxweb")}function ck(){return Qe(this,null,function*(){})}function uk(){return Qe(this,null,function*(){let e=new M.MxCADUiPrEntity;e.setMessage("选择要隐藏的对象");let t=yield e.go();if(!t.isValid())return;let i=t.getMcDbEntity(),l=M.MxCpp.getCurrentMxCAD(),f=l.getDatabase().getLayerTable().get(i.layer).getMcDbLayerTableRecord();f!==null&&(f.isOff=!0,l.updateLayerDisplayStatus(),l.updateDisplay())})}function hk(){return window.location.origin+window.location.pathname}let H_;function dk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定插入点:`);let t=yield e.go();if(!t)return;let i=M.MxCpp.getCurrentMxCAD(),l=hk()+"mxcad.jpg";i.loadImage(l,c=>{if(!c){console.log("loadImage failed");return}let h=i.mxdraw.viewCoordLong2Cad(100),f=c.height/c.width*h;H_=i.drawImage(t.x,t.y,h,f,0,l,!0),i.updateDisplay()})})}function pk(){if(!H_)return;let e=M.MxCpp.getCurrentMxCAD(),t="https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg";e.loadImage(t,i=>{if(!i){console.log("loadImage failed");return}let l=e.addImageDefine(t,"winter-7593872_960_720.jpg",!0),c=H_.getMcDbEntity();c&&c.setImageDefId(l),e.updateDisplay()})}function mb(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD(),t=new M.MxCADUiPrPoint,i=yield t.go();if(i==null)return;t.setBasePt(i);let l=yield t.go();if(l==null)return;let c=e.drawLine(i.x,i.y,l.x,l.y);e.addCurrentSelect(c)})}let gb=0;function yb(){return Qe(this,null,function*(){gb+=Math.PI*.5,M.MxCpp.getCurrentMxCAD().zoomAngle(gb)})}function _b(){M.MxCpp.getCurrentMxCAD().zoomCenter(900,900)}function fk(){let e=M.MxCpp.getCurrentMxCAD();e.newFile();let t=new M.McDbPolyline;t.setType(M.McDb.PolylineType.k3dPolyline),t.addVertexAt(new M.McGePoint3d(100,100,100)),t.addVertexAt(new M.McGePoint3d(200,100,500)),t.addVertexAt(new M.McGePoint3d(300,400,200)),e.drawEntity(t),e.zoomAll(),e.updateDisplay()}function mk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定一点:`);let t=yield e.go();if(!t)return;const i=new M.MxCADUiPrAngle;i.setMessage("指定夹角"),i.setKeyWords(""),i.setBasePt(t);const l=yield i.go();console.log(l)})}function gk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定一点:`),e.setOffsetInputPostion(!0);let t=yield e.go();if(!t)return;e.setBasePt(t),e.setUseBasePt(!0),e.setMessage(` 指定二点:`);let i=yield e.go();i&&M.MxCpp.getCurrentMxCAD().drawLine(t.x,t.y,i.x,i.y)})}function yk(){return Qe(this,null,function*(){let e=new M.MxCADSelectionSet;if(!(yield e.userSelect("选择要做成组的对象:"))||e.count()==0)return;M.MxCpp.getCurrentMxCAD().getDatabase().CreateGroup(e.getIds())})}function _k(){return Qe(this,null,function*(){let e=M.MxCpp.getCurrentMxCAD();const t=new M.MxCADUiPrPoint;t.setMessage(` 指定第一点:`);let i=yield t.go();if(!i)return;t.setMessage(` 指定第二点:`),t.setBasePt(i);let l=yield t.go();if(!l)return;let c=l.sub(i);c.rotateBy(Math.PI*.5).normalize().mult(X.MxFun.screenCoordLong2Doc(10));let h=i.clone().addvec(c),f=i.clone().subvec(c),r=l.clone().addvec(c),v=l.clone().subvec(c),x=new M.McGeBound([h,f,r,v]),w=x.minPoint,b=x.maxPoint,A=new M.MxCADSelectionSet;A.crossingSelect(w.x,w.y,b.x,b.y,new M.MxCADResbuf([M.DxfCode.kEntityType,"LINE,ARC,CIRCLE,LWPOLYLINE"]));let L=X.MxFun.screenCoordLong2Doc(5),P=new M.McDbLine(i,l);A.forEach(R=>{let V=R.getMcDbEntity().IntersectWith(P,M.McDb.Intersect.kOnBothOperands);if(V.length()!=0){let j=V.at(0);e.drawCircle(j.x,j.y,L)}})})}X.MxFun.on("mxcadApplicationCreatedMxCADObject",e=>{e.mxcad.on("selectChange",i=>{if(i.length==0)return;let l=i[0],c=l.getMxDbEntity();if(c!==null){console.log(c.getTypeName()),c instanceof X.MxDbRectBoxLeadComment&&console.log(c.text);return}let h=l.getMcDbEntity();h!==null&&(console.log(h.objectName),h instanceof M.McDbText?console.log(h.textString):h instanceof M.McDbBlockReference&&h.getAllAttribute().forEach(v=>{let x=v.getMcDbEntity();console.log(x.textString),console.log(x.tag)}))}),M.MxCpp.PropertiesWindow.onEvent_getProperties(i=>{let l=i.getMcDbEntity();if(!l)return[];let c=l.getxDataDouble("DN"),h=l.getxDataDouble("LEN"),f=[];return c.ret&&f.push({sVarName:"DN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:c.val,isOnlyRead:!1}),h.ret&&f.push({sVarName:"LEN",iVarType:M.MxPropertiesWindowCustomValueType.kDouble,val:h.val,isOnlyRead:!1}),f}),M.MxCpp.PropertiesWindow.onEvent_setProperties((i,l)=>{let c=i.getMcDbEntity();c&&(l.sVarName=="DN"?c.setxDataDouble("DN",l.val):l.sVarName=="LEN"&&c.setxDataDouble("LEN",l.val))}),wk()});function vk(){return Qe(this,null,function*(){const e=yield M.MxCADUtility.getCorner("选择截图范围",void 0,void 0,!1,!0);if(!e)return;let t=M.MxCpp.getCurrentMxCAD(),i=Math.abs(e.pt1.x-e.pt2.x),l=Math.abs(e.pt1.y-e.pt2.y);if(i<1||l<1)return;let c=200,h=c*l/i;t.mxdraw.createCanvasImageData(f=>{let r=window.open();r!=null&&r.document.write('')},{width:c,height:h,range_pt1:e.pt1.toVector3(),range_pt2:e.pt2.toVector3()})})}function xk(){return Qe(this,null,function*(){for(;;){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定一点:`),e.setOffsetInputPostion(!0),e.clearLastInputPoint();let t=yield e.go();if(!t)return;let i=X.MxFun.getCurrentDraw();i.getTempMarkDraw().drawCircleMark(t.toVector3(),i.viewCoordLong2Cad(50),16711680),i.updateDisplay()}})}function bk(){return Qe(this,null,function*(){const e=new M.MxCADUiPrPoint;e.setMessage(` 指定第一点:`);let t=yield e.go();if(!t)return;let i=yield M.MxCADUtility.getCorner(` 指定第二点:`,t);if(!i)return;let l=i.pt2,c=new M.McGePoint3dArray;c.append(t),c.append(new M.McGePoint3d(t.x,l.y,0)),c.append(new M.McGePoint3d(l.x,l.y,0)),c.append(new M.McGePoint3d(l.x,t.y,0));let h=new M.McDbWipeout;h.setVertices(c),h=M.MxCpp.getCurrentMxCAD().drawEntity(h).getMcDbObject();let v=M.MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder().maxDrawOrder+1;h.drawOrder=v})}function wk(){X.MxFun.addCommand("My_PluginTest",KR),X.MxFun.addCommand("My_Extool",JR),X.MxFun.addCommand("Mx_Open_DemoCode",QR),X.MxFun.addCommand("Mx_Open_DevInstall",ek),X.MxFun.addCommand("Mx_Open_Map_gdslwzj",tk),X.MxFun.addCommand("Mx_Open_Map_gdyx",ik),X.MxFun.addCommand("Mx_Open_Map_tdtsl",rk),X.MxFun.addCommand("Mx_Open_Map_bdsl",ok),X.MxFun.addCommand("Mx_Open_Map_geoq",ak),X.MxFun.addCommand("Mx_Open_Map_googlecn",nk),X.MxFun.addCommand("Mx_ViewBackgroundColor",sk),X.MxFun.addCommand("Mx_TestExProp",fb),X.MxFun.addCommand("Mx_Test_OpenFile",lk),X.MxFun.addCommand("Mx_Test_GetFile",ck),X.MxFun.addCommand("Mx_TestExProp",fb),X.MxFun.addCommand("Mx_SelectEntitHideLayer",uk),X.MxFun.addCommand("MxTest_TestAddCurrentSelect",mb),X.MxFun.addCommand("MxTest_TestSetViewAngle",yb),X.MxFun.addCommand("MxText_ZoomCenter",_b),X.MxFun.addCommand("MxTest_Map_Download",UR),X.MxFun.addCommand("Mx_Test_DrawImage",dk),X.MxFun.addCommand("Mx_Test_ModifyImage",pk),X.MxFun.addCommand("Mx_Test_Draw3DPolyline",fk),X.MxFun.addCommand("MxTemp_Test",mk),X.MxFun.addCommand("Mx_Test_IntersectWith",_k),X.MxFun.addCommand("Mx_Test_OffsetIn_DrawLine",gk),X.MxFun.addCommand("Mx_Test_CreateGroup",yk),X.MxFun.addCommand("Mx_ScreenToJpg",vk),X.MxFun.addCommand("Mx_Test_DrawMarkCircle",xk),X.MxFun.addCommand("Mx_Test_Wipeout",bk),eT(),yT(),jS(),$S(),E3(),k3(),O3(),W3(),H3(),bL(),DL(),U3(),zL(),cI(),LI(),$I(),lR(),SR(),NL(),lu.mxmap&&GR(X.MxFun.getCurrentDraw())}return ar.McGePoint3dToString=Cr,ar.MxTest_TestAddCurrentSelect=mb,ar.MxTest_TestSetViewAngle=yb,ar.MxText_ZoomCenter=_b,ar.getMxCADUi=xl,Object.defineProperty(ar,Symbol.toStringTag,{value:"Module"}),ar}({},Mx,MxCAD,Vue,axios); //# sourceMappingURL=test.js.map