!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mars3d")):"function"==typeof define&&define.amd?define(["exports","mars3d"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["mars3d-widget"]={},e.mars3d)}(this,(function(e,t){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,t}var n=i(t);function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function o(e){for(var t=1;t-1&&t.splice(i,1),0===t.length&&n()}e?h.test(e)?function(e,t,i){var n=document.createElement("link");n.rel="stylesheet",g(n,i,"css"),n.async=!0,n.href=e,p.appendChild(n)}(e,0,r):function(e,t,i){var n=document.createElement("script");n.charset="utf-8",g(n,i,"js"),n.async=!t.sync,n.src=e,p.appendChild(n)}(e,i,r):setTimeout((function(){r()}))}function _(e,t,i){var n=function(){i&&i()};if(0!==(e=Array.prototype.slice.call(e||[])).length)for(var r=0,o=e.length;r1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";O=e,j=i,V=[],C=n.Util.merge({windowOptions:{position:"rt",maxmin:!1,resize:!0},autoDisable:!0,disableOther:!0},t.defaultOptions),"time"===(I=t.version)&&(I=(new Date).getTime());var r=t.openAtStart;if(r&&r.length>0)for(var a=0;a0){for(var u=0;u ",P&&!l._nodebug&&A("#widget-testbar").append(f)}else{if(!l.hasOwnProperty("uri")||""===l.uri){console.error("widget未配置uri",l);continue}if(P&&!l._nodebug){var p='";A("#widget-testbar").append(p)}D(l),l._firstConfigBak=o({},l),V.push(l)}}P&&A("#widget-testbar .widget-btn").each((function(){A(this).click((function(e){var t=A(this).attr("data-widget");t&&""!==t&&(R(t)?U(t):z(t))}))}))}for(var v=0;v0?e[1]:void 0}function D(e){if(C)for(var t in C)"windowOptions"===t||e.hasOwnProperty(t)||(e[t]=C[t]);var i,n;e.path=(i=j+e.uri,n=i.lastIndexOf("/"),i.substring(0,n+1)),e.name=e.name||e.label}function z(e,t){var i;!O&&e.map&&B(e.map,{},e.basePath),"string"==typeof e?(e={uri:e},null!=t&&(e.disableOther=!t)):e.uri||console.error("activate激活widget时需要uri参数!",e);for(var n=0;n=0;i--)if((e=t[i].src)&&-1!==e.indexOf("widgets"))return e;return""}(),i=0;i0){for(var t=[],i=0;i=t._viewcreate_allcount&&t._startActivate(i)}),this);break;default:this._openWindow(e)}}},{key:"_openWindow",value:function(e){var t=this,i=this._getUrl(e.url),r={type:2,content:[i,"no"],success:function(r,o){if(t.isActivate){e._layerIdx!==o&&(ee.close(e._layerIdx),e._layerIdx=o),e._layerOpening=!1,e._dom=r;var a,s=window[r.find("iframe")[0].name];s.map=t.map,s.mars3d=n,s.Cesium=n.Cesium,t.options.css&&Z("#layui-layer"+e._layerIdx).css(t.options.css),e.windowOptions.hasOwnProperty("show")&&!e.windowOptions.show&&Z(r).hide(),ee.setTop(r),t.winCreateOK(e,s),J.fire(k.openView,{sourceTarget:t,view:e,dom:r}),t._viewcreate_okcount++,t._viewcreate_okcount>=t._viewcreate_allcount&&t._startActivate(r),s&&s.initWidgetView?(null!==(a=t.config)&&void 0!==a&&a.style&&Z(s.document.body).addClass(t.config.style),s.initWidgetView(t)):n.Log.logError(i+"页面没有定义function initWidgetView(widget)方法,无法初始化widget页面!")}else ee.close(o)}};e._layerIdx&&e._layerIdx>0&&(ee.close(e._layerIdx),e._layerIdx=-1),e._layerOpening=!0,e._layerIdx=ee.open(this._getWinOpt(e,r))}},{key:"_openDivWindow",value:function(e){var t=this,i=this._getUrl(e.url);this.getHtml(i,(function(i){var n={type:1,content:i,success:function(i,n){t.isActivate?(e._layerIdx!==n&&(ee.close(e._layerIdx),e._layerIdx=n),e._layerOpening=!1,e._dom=i,e.windowOptions.hasOwnProperty("show")&&!e.windowOptions.show&&Z(i).hide(),ee.setTop(i),t.winCreateOK(e,i),J.fire(k.openView,{sourceTarget:t,view:e,dom:i}),t._viewcreate_okcount++,t._viewcreate_okcount>=t._viewcreate_allcount&&t._startActivate(i)):ee.close(n)}};e._layerOpening=!0,e._layerIdx=ee.open(t._getWinOpt(e,n))}))}},{key:"_getUrl",value:function(e){return(e=this.addCacheVersion(e)).startsWith("/")||e.startsWith(".")||e.startsWith("http")?e:this.path+e}},{key:"_getWinOpt",value:function(e,t){var i=o(o(o({},E()),e.windowOptions),this.options.windowOptions);e.windowOptions=i;var n=this,r=this._getWinSize(i),a=!1;return i.noTitle||(a=this.options.name||" ",this.options.icon&&(a=' '+a)),o(o(o({},{title:a,area:r.area,offset:r.offset,shade:0,maxmin:!1,beforeEnd:function(){n.beforeDisable()},end:function(){e._layerIdx=-1,e._dom=null,n.disableBase()},full:function(e){n.winFull(e)},min:function(e){n.winMin(e)},restore:function(e){n.winRestore(e)}}),i),t)}},{key:"_getWinSize",value:function(e){var t=this.bfb2Number(e.width,document.documentElement.clientWidth,e),i=this.bfb2Number(e.height,document.documentElement.clientHeight,e),n="",r=e.position;if(r)if("string"==typeof r)n=r;else if("object"===a(r)){var o,s;if(r.hasOwnProperty("top")&&null!=r.top&&(o=this.bfb2Number(r.top,document.documentElement.clientHeight,e)),r.hasOwnProperty("bottom")&&null!=r.bottom){e._hasresize=!0;var c=this.bfb2Number(r.bottom,document.documentElement.clientHeight,e);null!=o?i=document.documentElement.clientHeight-o-c:o=document.documentElement.clientHeight-i-c}if(r.hasOwnProperty("left")&&null!=r.left&&(s=this.bfb2Number(r.left,document.documentElement.clientWidth,e)),r.hasOwnProperty("right")&&null!=r.right){e._hasresize=!0;var u=this.bfb2Number(r.right,document.documentElement.clientWidth,e);null!=s?t=document.documentElement.clientWidth-s-u:s=document.documentElement.clientWidth-t-u}null!=o&&void 0!==o||(o=(document.documentElement.clientHeight-i)/2),null!=s&&void 0!==s||(s=(document.documentElement.clientWidth-t)/2),n=[o+"px",s+"px"]}return e.hasOwnProperty("minHeight")&&ie.maxHeight&&(e._hasresize=!0,i=e.maxHeight),e.hasOwnProperty("minWidth")&&te.maxWidth&&(e._hasresize=!0,t=e.maxWidth),{area:t&&i?[t+"px",i+"px"]:t+"px",offset:n}}},{key:"indexResize",value:function(){if(this.isActivate){var e=this;this.eachView((function(t){if(t._layerIdx&&-1!==t._layerIdx&&t.windowOptions&&t.windowOptions._hasresize){var i=e._getWinSize(t.windowOptions),n={};Array.isArray(i.area)&&(i.area[0]&&(n.width=i.area[0]),i.area[1]&&(n.height=i.area[1])),Array.isArray(i.offset)&&(i.offset[1]&&(n.top=i.offset[0]),i.offset[1]&&(n.left=i.offset[1])),Z(t._dom).attr("myTopLeft",!0),ee.style(t._layerIdx,n),"divwindow"===t.type&&ee.iframeAuto(t._layerIdx)}}))}}},{key:"_appendView",value:function(e,t){e._dom=Z(t).appendTo(e.parent||"body"),this.options.css&&Z(e._dom).css(this.options.css),this.winCreateOK(e,t),this._viewcreate_okcount++,this._viewcreate_okcount>=this._viewcreate_allcount&&this._startActivate(t)}},{key:"winCreateOK",value:function(e,t){}},{key:"winFull",value:function(){}},{key:"winMin",value:function(){}},{key:"minView",value:function(){this.eachView((function(e){e._layerIdx&&ee.min(e._layerIdx,e)}))}},{key:"restoreView",value:function(){this.eachView((function(e){e._layerIdx&&ee.restore(e._layerIdx)}))}},{key:"fullView",value:function(){this.eachView((function(e){e._layerIdx&&ee.full(e._layerIdx,e)}))}},{key:"winRestore",value:function(){}},{key:"_startActivate",value:function(e){this.activate(e),J.fire(k.activated,{sourceTarget:this}),this.options.success&&(this.options.success(this),delete this.options.success),this.isActivate||this.disableBase()}},{key:"beforeActivate",value:function(){}},{key:"activate",value:function(){}},{key:"disableBase",value:function(){this.isActivate&&(this.isActivate=!1,this.beforeDisable(),J.fire(k.beforeDisable,{sourceTarget:this}),this.eachView((function(e){return e._layerIdx&&e._layerIdx>0?(ee.close(e._layerIdx),e._layerOpening||(e._layerIdx=-1),!0):("append"===e.type&&e._dom&&(e._dom.remove(),e._dom=null),"custom"===e.type&&e.close&&e.close(),!1)})),this.disable(),this.options.autoReset&&this.resetConfig(),J.fire(k.disabled,{sourceTarget:this}))}},{key:"beforeDisable",value:function(){}},{key:"disable",value:function(){}},{key:"bfb2Number",value:function(e,t,i){return"string"==typeof e&&-1!==e.indexOf("%")?(i._hasresize=!0,t*Number(e.replace("%",""))/100):e}},{key:"addCacheVersion",value:function(e){if(!e)return e;var t=$();return t&&(-1===e.indexOf("?")?e+="?cache="+t:-1===e.indexOf("cache="+t)&&(e+="&cache="+t)),e}},{key:"resetConfig",value:function(){if(this.options._firstConfigBak){var e=this.options._firstConfigBak;for(var t in e)"uri"!==t&&(this.options[t]=e[t])}}},{key:"setViewShow",value:function(e,t){this.eachView((function(t){t._layerIdx&&t._layerIdx>0?e?Z("#layui-layer"+t._layerIdx).show():Z("#layui-layer"+t._layerIdx).hide():"append"===t.type&&t._dom&&(e?Z(t._dom).show():Z(t._dom).hide())}),t)}},{key:"setViewCss",value:function(e,t){this.eachView((function(t){null!=t._layerIdx&&t._layerIdx>0?ee.style(t._layerIdx,e):"append"===t.type&&t._dom&&Z(t._dom).css(e)}),t)}},{key:"setTitle",value:function(e,t){this.eachView((function(t){t._dom&&t._dom.find(".layui-layer-title").html(e)}),t)}},{key:"getHtml",value:function(e,t){Z.ajax({url:e,type:"GET",dataType:"html",timeout:0,success:function(e){t(e)}})}}],i&&s(t.prototype,i),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),u}(te);n.widget=Y,n.widget.BaseWidget=ne,n.widget.WidgetEventType=k,n.widget.EventType=k,e.widget=Y,Object.defineProperty(e,"__esModule",{value:!0})}));