@nocobase/plugin-map 1.5.0-alpha.4 → 1.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,4 +7,118 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5"),require("react-i18next"),require("@formily/shared"),require("@emotion/css"),require("lodash"),require("ahooks"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-map",["@nocobase/client","@ant-design/icons","@formily/react","react","@formily/antd-v5","react-i18next","@formily/shared","@emotion/css","lodash","ahooks","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-map"]=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5"),require("react-i18next"),require("@formily/shared"),require("@emotion/css"),require("lodash"),require("ahooks"),require("antd")):e["@nocobase/plugin-map"]=t(e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"],e.react,e["@formily/antd-v5"],e["react-i18next"],e["@formily/shared"],e["@emotion/css"],e.lodash,e.ahooks,e.antd)}(self,function(e,t,n,r,o,i,a,l,c,u,s){return function(){var p={49:function(e){"use strict";var t,n;t=0,n=function(){function e(e){var t=[];return e.AMapUI&&t.push(function(e){return new Promise(function(t,a){var l=[];if(e.plugins)for(var c=0;c<e.plugins.length;c+=1)-1==r.AMapUI.plugins.indexOf(e.plugins[c])&&l.push(e.plugins[c]);if(o.AMapUI===n.failed)a("前次请求 AMapUI 失败");else if(o.AMapUI===n.notload){o.AMapUI=n.loading,r.AMapUI.version=e.version||r.AMapUI.version,c=r.AMapUI.version;var u=document.body||document.head,s=document.createElement("script");s.type="text/javascript",s.src="https://webapi.amap.com/ui/"+c+"/main.js",s.onerror=function(e){o.AMapUI=n.failed,a("请求 AMapUI 失败")},s.onload=function(){if(o.AMapUI=n.loaded,l.length)window.AMapUI.loadUI(l,function(){for(var e=0,n=l.length;e<n;e++){var r=l[e].split("/").slice(-1)[0];window.AMapUI[r]=arguments[e]}for(t();i.AMapUI.length;)i.AMapUI.splice(0,1)[0]()});else for(t();i.AMapUI.length;)i.AMapUI.splice(0,1)[0]()},u.appendChild(s)}else o.AMapUI===n.loaded?e.version&&e.version!==r.AMapUI.version?a("不允许多个版本 AMapUI 混用"):l.length?window.AMapUI.loadUI(l,function(){for(var e=0,n=l.length;e<n;e++){var r=l[e].split("/").slice(-1)[0];window.AMapUI[r]=arguments[e]}t()}):t():e.version&&e.version!==r.AMapUI.version?a("不允许多个版本 AMapUI 混用"):i.AMapUI.push(function(e){e?a(e):l.length?window.AMapUI.loadUI(l,function(){for(var e=0,n=l.length;e<n;e++){var r=l[e].split("/").slice(-1)[0];window.AMapUI[r]=arguments[e]}t()}):t()})})}(e.AMapUI)),e.Loca&&t.push(function(e){return new Promise(function(t,a){if(o.Loca===n.failed)a("前次请求 Loca 失败");else if(o.Loca===n.notload){o.Loca=n.loading,r.Loca.version=e.version||r.Loca.version;var l=r.Loca.version,c=r.AMap.version.startsWith("2"),u=l.startsWith("2");if(c&&!u||!c&&u)a("JSAPI 与 Loca 版本不对应!!");else{c=r.key,u=document.body||document.head;var s=document.createElement("script");s.type="text/javascript",s.src="https://webapi.amap.com/loca?v="+l+"&key="+c,s.onerror=function(e){o.Loca=n.failed,a("请求 AMapUI 失败")},s.onload=function(){for(o.Loca=n.loaded,t();i.Loca.length;)i.Loca.splice(0,1)[0]()},u.appendChild(s)}}else o.Loca===n.loaded?e.version&&e.version!==r.Loca.version?a("不允许多个版本 Loca 混用"):t():e.version&&e.version!==r.Loca.version?a("不允许多个版本 Loca 混用"):i.Loca.push(function(e){e?a(e):a()})})}(e.Loca)),Promise.all(t)}if(!window)throw Error("AMap JSAPI can only be used in Browser.");(t=n||(n={})).notload="notload",t.loading="loading",t.loaded="loaded",t.failed="failed";var t,n,r={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},o={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},i={AMap:[],AMapUI:[],Loca:[]},a=[],l=function(e){"function"==typeof e&&(o.AMap===n.loaded?e(window.AMap):a.push(e))};return{load:function(t){return new Promise(function(i,c){if(o.AMap==n.failed)c("");else if(o.AMap==n.notload){var u=t.key,s=t.version,p=t.plugins;u?(window.AMap&&"lbs.amap.com"!==location.host&&c("禁止多种API加载方式混用"),r.key=u,r.AMap.version=s||r.AMap.version,r.AMap.plugins=p||r.AMap.plugins,o.AMap=n.loading,s=document.body||document.head,window.___onAPILoaded=function(r){if(delete window.___onAPILoaded,r)o.AMap=n.failed,c(r);else for(o.AMap=n.loaded,e(t).then(function(){i(window.AMap)}).catch(c);a.length;)a.splice(0,1)[0]()},(p=document.createElement("script")).type="text/javascript",p.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+r.AMap.version+"&key="+u+"&plugin="+r.AMap.plugins.join(","),p.onerror=function(e){o.AMap=n.failed,c(e)},s.appendChild(p)):c("请填写key")}else if(o.AMap==n.loaded){if(t.key&&t.key!==r.key)c("多个不一致的 key");else if(t.version&&t.version!==r.AMap.version)c("不允许多个版本 JSAPI 混用");else{if(u=[],t.plugins)for(s=0;s<t.plugins.length;s+=1)-1==r.AMap.plugins.indexOf(t.plugins[s])&&u.push(t.plugins[s]);u.length?window.AMap.plugin(u,function(){e(t).then(function(){i(window.AMap)}).catch(c)}):e(t).then(function(){i(window.AMap)}).catch(c)}}else if(t.key&&t.key!==r.key)c("多个不一致的 key");else if(t.version&&t.version!==r.AMap.version)c("不允许多个版本 JSAPI 混用");else{var f=[];if(t.plugins)for(s=0;s<t.plugins.length;s+=1)-1==r.AMap.plugins.indexOf(t.plugins[s])&&f.push(t.plugins[s]);l(function(){f.length?window.AMap.plugin(f,function(){e(t).then(function(){i(window.AMap)}).catch(c)}):e(t).then(function(){i(window.AMap)}).catch(c)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,r={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},o={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},i={AMap:[],AMapUI:[],Loca:[]}}}},e.exports=n()},603:function(e){e.exports={}},482:function(e){"use strict";e.exports=t},964:function(e){"use strict";e.exports=l},632:function(e){"use strict";e.exports=o},505:function(e){"use strict";e.exports=n},875:function(e){"use strict";e.exports=a},772:function(t){"use strict";t.exports=e},749:function(e){"use strict";e.exports=u},721:function(e){"use strict";e.exports=s},467:function(e){"use strict";e.exports=c},156:function(e){"use strict";e.exports=r},238:function(e){"use strict";e.exports=i}},f={};function d(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e].call(n.exports,n,n.exports,d),n.exports}d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var m={};return!function(){"use strict";d.r(m),d.d(m,{PluginMapClient:function(){return tH},default:function(){return tQ}});var e,t,n=d("772"),r=d("156"),o=d.n(r),i=d("467"),a=d.n(i),l=d("482"),c=d("749"),u=d("721"),s=d("238");function p(e){return"{{t('".concat(e,"', { ns: '").concat("map","', nsMode: 'fallback' })}}")}function f(){return(0,s.useTranslation)(["map","client"],{nsMode:"fallback"})}var y=[{label:p("AMap"),value:"amap"},{label:p("Google Maps"),value:"google"}],v="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV3iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==",b=function(e,t,n){var r=null==t?void 0:t.reduce(function(e,r,o){return o===t.length-1&&("o2m"===n||"m2m"===n)?null==e?void 0:e.map(function(e){return e[r]}).filter(function(e){return null!=e}):null==e?void 0:e[r]},e);return"o2m"===n||"m2m"===n?r:[r]},h=d("505"),O=function(e){var t=(0,n.useCollectionRecordData)(),i=(0,n.useCollection)(),a=(0,h.useFieldSchema)(),l=(0,r.useMemo)(function(){return a.reduceProperties(function(e,t){return"drawer"===t.name?t:e},null)},[a]);return l?o().createElement(n.VariablePopupRecordProvider,{recordData:t,collection:i},o().createElement(h.RecursionField,{schema:l,name:l.name})):null},w=d("49"),S=d.n(w);d("603");var P="map-configuration",A=function(e){return"NOCOBASE_PLUGIN_MAP_CONFIGURATION_".concat(e)},j=function(e){var t=(0,r.useMemo)(function(){var t=sessionStorage.getItem(A(e));return t?JSON.parse(t):t},[e]),o=(0,n.useRequest)({resource:P,action:"get",params:{type:e}},{onSuccess:function(t){sessionStorage.setItem(A(e),JSON.stringify(null==t?void 0:t.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!t}).data;return t?t:null==o?void 0:o.data},x=function(){var e,t,r=(0,n.useDataBlockHeight)(),o=u.theme.useToken().token,i=(0,n.useDesignable)().designable,a=(((0,n.useBlockHeightProps)()||{}).heightProps||{}).title,l=(0,h.useFieldSchema)();if(!!r){var c=Object.keys((null===(t=l.parent)||void 0===t?void 0:null===(e=t.properties.actions)||void 0===e?void 0:e.properties)||{}).length>0;return r-(i||c?o.paddingLG+o.controlHeight+o.margin:o.paddingLG+o.margin)-o.paddingLG-(a?o.fontSizeLG*o.lineHeightLG+2*o.padding-1:0)}};function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function E(){var e,t,n=(e=["\n position: absolute;\n top: 10px;\n left: 10px;\n z-index: 10;\n width: calc(100% - 20px);\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return E=function(){return n},n}var M=function(e){var t,i,a=e.aMap,l=e.toCenter,s=f().t,p=(0,r.useRef)();var d=(t=(0,r.useState)([]),i=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return C(e,t)}}(t,i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=d[0],y=d[1];(0,r.useEffect)(function(){null==a||a.plugin("AMap.PlaceSearch",function(){p.current=new a.PlaceSearch({city:"全国",pageSize:30})})},[a]);var v=(0,c.useDebounceFn)(function(e){if(!!p.current)p.current.search(e||" ",function(e,t){if("complete"===e)y(t.poiList.pois.map(function(e){var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={label:"".concat(e.name,"-").concat(e.address),value:e.id},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}));else{if("no_data"===e){y([]);return}u.message.error(s("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}).run;return o().createElement("div",{className:(0,n.css)(E())},o().createElement(u.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:s("Enter keywords to search"),filterOption:!1,onSearch:v,onSelect:function(e){var t=m.find(function(t){return t.value===e});(null==t?void 0:t.location)&&l(t.location)},options:m,popupMatchSelectWidth:!1}))};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){I(e,t,n[t])})}return e}function D(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function L(){var e=T(["\n position: relative;\n height: ","px !important;\n "]);return L=function(){return e},e}function R(){var e=T(["\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n "]);return R=function(){return e},e}function B(){var e=T(["\n position: absolute;\n bottom: 80px;\n right: 20px;\n z-index: 10;\n "]);return B=function(){return e},e}function N(){var e=T(["\n position: absolute;\n bottom: 20px;\n left: 10px;\n z-index: 2;\n pointer-events: none;\n "]);return N=function(){return e},e}function _(){var e=T(["\n position: absolute;\n bottom: 20px;\n right: 20px;\n z-index: 2;\n "]);return _=function(){return e},e}var U={point:{mouseTool:"marker",propertyKey:"position",overlay:"Marker"},polygon:{mouseTool:"polygon",editor:"PolygonEditor",propertyKey:"path",overlay:"Polygon"},lineString:{mouseTool:"polyline",editor:"PolylineEditor",propertyKey:"path",overlay:"Polyline"},circle:{mouseTool:"circle",editor:"CircleEditor",transformOptions:function(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},K=o().forwardRef(function(e,t){var i=j(e.mapType)||{},a=i.accessKey,s=i.securityJsCode,p=e.value,d=e.onChange,m=e.block,y=void 0!==m&&m,v=e.readonly,g=e.disabled,b=void 0===g?y:g,O=e.zoom,w=void 0===O?13:O,P=e.overlayCommonOptions,A=f().t,C=(0,h.useFieldSchema)(),E=(0,r.useRef)(),k=(0,r.useRef)(),T=(0,r.useRef)(),K=z((0,r.useState)([]),2),G=K[0],q=K[1],V=z((0,r.useState)(""),2),W=V[0],J=V[1],Y=(0,n.useCollection_deprecated)().getField,Z=(0,r.useMemo)(function(){if(e.type)return e.type;var t=Y(null==C?void 0:C.name);return null==t?void 0:t.interface},[null==e?void 0:e.type,null==C?void 0:C.name]),X=(0,r.useRef)(),H=(0,r.useRef)(null),Q=(0,n.useNavigateNoUpdate)(),$=(0,r.useRef)("nocobase-map-".concat(Z||"","-").concat(Date.now().toString(32))),ee=u.App.useApp().modal,et=x(),en=z((0,r.useState)(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},P)),1)[0];(0,r.useEffect)(function(){k.current&&k.current.setZoom(w)},[w]);var er=(0,c.useMemoizedFn)(function(){X.current&&X.current.remove()}),eo=(0,c.useMemoizedFn)(function(){(!b||y)&&"point"!==Z&&H.current&&(H.current.setTarget(X.current),H.current.open())}),ei=(0,c.useMemoizedFn)(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null;if("point"===Z){var r=e.getPosition(),o=r.lat;n=[r.lng,o]}else if("polygon"===Z||"lineString"===Z){if((n=e.getPath().map(function(e){return[e.lng,e.lat]})).length<2)return}else if("circle"===Z){var i=e.getCenter(),a=e.getRadius();n=[i.lng,i.lat,a]}!t&&(er(),X.current=e,eo()),null==d||d(n)}),ea=(0,c.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z,t=U[e];if(t&&"editor"in t&&!H.current)return H.current=new E.current[t.editor](k.current,null,{createOptions:en,editOptions:en,controlPoint:D(F({},en),{strokeWeight:3}),midControlPoint:D(F({},en),{strokeWeight:2,fillColor:"#fff"})}),H.current.on("adjust",function(e){ei(e.target,!0)}),H.current.on("move",function(e){ei(e.target,!0)}),H.current}),el=(0,c.useMemoizedFn)(function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z;if(!(!T.current||(null===(e=H.current)||void 0===e?void 0:e.getTarget()))){var n=U[t];if(!n)return;T.current[n.mouseTool](F({},en))}}),ec=(0,c.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z;!T.current&&(T.current=new E.current.MouseTool(k.current),T.current.on("draw",function(e){ei(e.obj)}),el(e))}),eu=(0,r.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p,n=arguments.length>2?arguments[2]:void 0,r=U[e];if(!!r){var o=F({},en,n);return"transformOptions"in r?Object.assign(o,r.transformOptions(t)):"propertyKey"in r&&(o[r.propertyKey]=t),new E.current[r.overlay](o)}},[en]),es=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p,n=arguments.length>2?arguments[2]:void 0;if(E.current){var r=eu(e,t,n);return r.setMap(k.current),r}};(0,r.useEffect)(function(){if(E.current){if(!!p&&(!!v||!X.current)){var e=es();k.current.setFitView([e]),X.current=e,!b&&(ea(),eo())}}},[p,G,Z,en,b,v]),(0,r.useEffect)(function(){var e,t,n;T.current&&(b?(null===(e=T.current)||void 0===e||e.close(),null===(t=H.current)||void 0===t||t.close()):(el(),null===(n=H.current)||void 0===n||n.open()))},[b]),(0,r.useEffect)(function(){E.current&&Z&&!b&&(ec(),ea())},[b,G,Z]),(0,r.useEffect)(function(){if(!p&&(T.current||H.current)&&(er(),H.current&&(H.current.setTarget(),H.current.close()),null==d||d(null)),T.current&&H.current){var e,t;H.current.getTarget()?null===(e=(t=T.current).close)||void 0===e||e.call(t):el()}},[Z,p]),(0,r.useEffect)(function(){if(a&&!k.current){s&&(window._AMapSecurityConfig=I({},s.endsWith("_AMapService")?"serviceHOST":"securityJsCode",s));var e=window.define;if(window.define=void 0,window.AMap)try{requestIdleCallback(function(){k.current=new AMap.Map($.current,{resizeEnable:!0,zoom:w}),E.current=AMap,J(""),q([])});return}catch(e){J(e)}return S().load({key:a,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(function(t){return window.define=e,requestIdleCallback(function(){k.current=new t.Map($.current,{resizeEnable:!0,zoom:w}),E.current=t,J(""),q([])})}).catch(function(e){"string"==typeof e?e.includes("多个不一致的 key")?J(A("The AccessKey is incorrect, please check it")):J(e):(null==e?void 0:e.type)==="error"&&J("Something went wrong, please refresh the page and try again")}),function(){var e;null===(e=k.current)||void 0===e||e.destroy(),E.current=null,k.current=null,T.current=null,H.current=null,S().reset()}}},[a,Z,s]),(0,r.useImperativeHandle)(t,function(){return{setOverlay:es,getOverlay:eu,createMouseTool:ec,createEditor:ea,executeMouseTool:el,aMap:E.current,map:k.current,overlay:X.current,mouseTool:function(){return T.current},editor:function(){return H.current},errMessage:W}});var ep=(0,n.useApp)();return!a||W?o().createElement(u.Alert,{action:o().createElement(u.Button,{type:"primary",onClick:function(){return Q(ep.pluginSettingsManager.getRoutePath("map"))}},A("Go to the configuration page")),message:W||A("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):o().createElement("div",{className:(0,n.css)(L(),et||500),id:$.current,style:null==e?void 0:e.style},!E.current&&o().createElement("div",{className:(0,n.css)(R())},o().createElement(u.Spin,null)),b?null:o().createElement(o().Fragment,null,o().createElement(M,{toCenter:function(e,t){k.current&&k.current.setZoomAndCenter(18,e,t)},aMap:E.current}),o().createElement("div",{className:(0,n.css)(B())},o().createElement(u.Button,{onClick:function(){X.current&&k.current.setFitView([X.current])},disabled:!X.current,type:"primary",shape:"round",size:"large",icon:o().createElement(l.SyncOutlined,null)})),"point"!==Z?o().createElement("div",{className:(0,n.css)(N())},o().createElement(u.Alert,{message:A("Click to select the starting point and double-click to end the drawing"),type:"info"})):null,o().createElement("div",{className:(0,n.css)(_())},o().createElement(u.Button,{disabled:!p,style:{height:"40px"},onClick:function(){var e=function(){er(),H.current&&(H.current.setTarget(),H.current.close()),null==d||d(null)};ee.confirm({title:A("Clear the canvas"),content:A("Are you sure to clear the canvas?"),okText:A("Confirm"),cancelText:A("Cancel"),getContainer:function(){return document.getElementById($.current)},onOk:function(){e()}})},type:"primary",danger:!0},A("Clear")))))});function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}K.displayName="AMapComponent";function q(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||Y(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function J(e){return function(e){if(Array.isArray(e))return G(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Y(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(e,t){if(e){if("string"==typeof e)return G(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(e,t)}}function Z(){var e=W(["\n position: relative;\n height: 100%;\n "]);return Z=function(){return e},e}function X(){var e=W(["\n position: absolute;\n left: 10px;\n top: 10px;\n z-index: 999;\n "]);return X=function(){return e},e}function H(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function ee(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function et(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var en=function(e){var t=e.type,i=e.children,a=f().t,l=et((0,c.useBoolean)(!1),2),s=l[0],p=l[1],d=(0,n.useAPIClient)(),m=et(u.Form.useForm(),1)[0],y=j(t);(0,r.useEffect)(function(){y&&(m.setFieldsValue(y),p.toggle())},[y]);var v=(0,r.useMemo)(function(){return d.resource(P)},[d]);return o().createElement(u.Form,{disabled:s,form:m,layout:"vertical",onFinish:function(e){v.set(ee($({},e),{type:t})).then(function(e){sessionStorage.removeItem(A(t)),p.toggle(),u.message.success(a("Saved successfully"))}).catch(function(e){u.message.success(a("Saved failed"))})}},i,s?o().createElement(u.Button,{disabled:!1,onClick:p.toggle},a("Edit")):o().createElement(u.Form.Item,null,o().createElement(u.Button,{disabled:!1,type:"primary",htmlType:"submit"},a("Save"))))},er={amap:function(){var e=f().t;return o().createElement(en,{type:"amap"},o().createElement(u.Form.Item,{required:!0,name:"accessKey",label:e("Access key")},o().createElement(u.Input,null)),o().createElement(u.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost")},o().createElement(u.Input,null)))},google:function(){var e=f().t;return o().createElement(en,{type:"google"},o().createElement(u.Form.Item,{required:!0,name:"accessKey",label:e("Api key")},o().createElement(u.Input,null)))}},eo=y.map(function(e){return ee($({},e),{component:er[e.value]})}),ei=function(){var e=(0,n.useCompile)(),t=new URLSearchParams((0,n.useLocationSearch)());return o().createElement(u.Card,{bordered:!0},o().createElement(u.Tabs,{type:"card",defaultActiveKey:t.get("tab")},eo.map(function(t){return o().createElement(u.Tabs.TabPane,{key:t.value,tab:e(t.label)},o().createElement(t.component,{type:t.value}))})))},ea=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!=o--;){var r,o,i,a=i[o];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n};let el="__googleMapsScriptId";(e=t||(t={}))[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE";class ec{constructor({apiKey:e,authReferrerPolicy:t,channel:n,client:r,id:o=el,language:i,libraries:a=[],mapIds:l,nonce:c,region:u,retries:s=3,url:p="https://maps.googleapis.com/maps/api/js",version:f}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=n,this.client=r,this.id=o||el,this.language=i,this.libraries=a,this.mapIds=l,this.nonce=c,this.region=u,this.retries=s,this.url=p,this.version=f,ec.instance){if(!ea(this.options,ec.instance.options))throw Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ec.instance.options)}`);return ec.instance}ec.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?t.FAILURE:this.done?t.SUCCESS:this.loading?t.LOADING:t.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`&region=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){let e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(n=>{n?t(n.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id)){this.callback();return}let n={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(n).forEach(e=>!n[e]&&delete n[e]),!(null===(t=null===(e=null==window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.importLibrary)&&(e=>{let t,n,r,o="The Google Maps JavaScript API",i="google",a="importLibrary",l="__ib__",c=document,u=window,s=(u=u[i]||(u[i]={})).maps||(u.maps={}),p=new Set,f=new URLSearchParams,d=()=>t||(t=new Promise((a,u)=>{var d,m,y,v;return d=this,m=void 0,y=void 0,v=function*(){var d;for(r in yield n=c.createElement("script"),n.id=this.id,f.set("libraries",[...p]+""),e)f.set(r.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[r]);f.set("callback",i+".maps."+l),n.src=this.url+"?"+f,s[l]=a,n.onerror=()=>t=u(Error(o+" could not load.")),n.nonce=this.nonce||(null===(d=c.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",c.head.append(n)},new(y||(y=Promise))(function(e,t){function n(e){try{o(v.next(e))}catch(e){t(e)}}function r(e){try{o(v.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):((o=t.value)instanceof y?o:new y(function(e){e(o)})).then(n,r)}o((v=v.apply(d,m||[])).next())})}));s[a]?console.warn(o+" only loads once. Ignoring:",e):s[a]=(e,...t)=>p.add(e)&&d().then(()=>s[a](e,...t))})(n);let r=this.libraries.map(e=>this.importLibrary(e));!r.length&&r.push(this.importLibrary("core")),Promise.all(r).then(()=>this.callback(),e=>{let t=new ErrorEvent("error",{error:e});this.loadErrorCallback(t)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){let e=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},e)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setScript())}}}function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(){var e,t,n=(e=["\n position: absolute;\n top: 10px;\n left: 10px;\n z-index: 10;\n width: calc(100% - 20px);\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return es=function(){return n},n}var ep=function(e){var t,i,a=e.toCenter,l=e.mapRef,s=f().t,p=(0,r.useRef)();var d=(t=(0,r.useState)([]),i=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(e,t)}}(t,i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=d[0],y=d[1];(0,r.useEffect)(function(){google.maps.importLibrary("places").then(function(e){p.current=new e.AutocompleteService}).catch(function(){u.message.error("Please configure the Google API Key correctly")})},[l]);var v=(0,c.useDebounceFn)(function(e){if(!!p.current)p.current.getPlacePredictions({input:e||" "},function(e,t){if(t===google.maps.places.PlacesServiceStatus.OK)y(e.map(function(e){var t,n,r=e.structured_formatting;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={label:"".concat(r.main_text).concat(r.secondary_text?" "+r.secondary_text:""),value:e.place_id},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}));else{y([]);return}})},{wait:300}).run;return o().createElement("div",{className:(0,n.css)(es())},o().createElement(u.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:s("Enter keywords to search"),filterOption:!1,onSearch:v,onSelect:function(e){var t=m.find(function(t){return t.value===e});new google.maps.places.PlacesService(l.current).getDetails({placeId:t.place_id,fields:["geometry"]},function(e,t){t===google.maps.places.PlacesServiceStatus.OK&&a(e.geometry.location)})},options:m}))},ef=function(e){return{url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(9.5,42)}};function ed(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function em(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function ey(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function ev(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function eg(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eb(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||eO(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eh(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eO(e,t){if(e){if("string"==typeof e)return ed(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ed(e,t)}}function ew(){var e=eh(["\n position: relative;\n height: ","px !important;\n "]);return ew=function(){return e},e}function eS(){var e=eh(["\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n "]);return eS=function(){return e},e}function eP(){var e=eh(["\n position: absolute;\n bottom: 80px;\n right: 20px;\n z-index: 10;\n "]);return eP=function(){return e},e}function eA(){var e=eh(["\n position: absolute;\n bottom: 20px;\n left: 10px;\n z-index: 2;\n pointer-events: none;\n "]);return eA=function(){return e},e}function ej(){var e=eh(["\n position: absolute;\n bottom: 20px;\n right: 20px;\n z-index: 2;\n "]);return ej=function(){return e},e}function ex(){var e=eh(["\n width: 100%;\n height: 100%;\n "]);return ex=function(){return e},e}var eC={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions:function(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},eE=o().forwardRef(function(e,t){var i,a=e.value,s=e.onChange,p=e.block,d=e.readonly,m=e.disabled,y=void 0===m?void 0!==p&&p:m,v=e.zoom,b=void 0===v?13:v,O=e.overlayCommonOptions,w=(j(e.mapType)||{}).accessKey,S=f().t,P=(0,n.useCollection_deprecated)().getField,A=(0,h.useFieldSchema)(),C=(0,r.useRef)(),E=(0,r.useRef)(),M=(0,r.useRef)(),k=eb((0,r.useState)([]),2),I=k[0],F=k[1],D=eb((0,r.useState)(""),2),z=D[0],T=D[1],L=(0,n.useAPIClient)(),R=u.App.useApp().modal,B=x();(0,r.useEffect)(function(){E.current&&E.current.setZoom(b)},[b]);var N=(0,r.useMemo)(function(){if(e.type)return e.type;var t=P(null==A?void 0:A.name);return null==t?void 0:t.interface},[null==e?void 0:e.type,null==A?void 0:A.name]);var _=(0,r.useRef)("point"===(i=N)?"marker":"lineString"===i?"polyline":i),U=eb((0,r.useState)(ev({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!y,draggable:!y},O)),1)[0],K=(0,n.useNavigateNoUpdate)(),G=(0,r.useRef)(),q=(0,r.useRef)(new Set),V=(0,c.useMemoizedFn)(function(e){if(q.current.forEach(function(e){q.current.delete(e)}),"getPath"in e){var t=e.getPath();["insert_at","remove_at","set_at"].forEach(function(n){q.current.add(t.addListener(n,function(){X(e,!0)}).remove)})}else ey(e,google.maps.Circle)&&["center_changed","radius_changed"].forEach(function(t){q.current.add(e.addListener(t,function(){X(e,!0)}).remove)})}),W=(0,c.useMemoizedFn)(function(){if(M.current&&(M.current.unbindAll(),M.current.setMap(null)),"point"!==N){var e;null===(e=C.current)||void 0===e||e.setDrawingMode(null)}}),J=(0,c.useMemoizedFn)(function(e){E.current&&(E.current.setCenter(e),E.current.setZoom(b))}),Y=(0,c.useMemoizedFn)(function(e){W(),V(e),M.current=e}),Z=(0,c.useMemoizedFn)(function(e){var t=new google.maps.LatLngBounds;e.forEach(function(e){if(ey(e,google.maps.Marker))t.extend(e.getPosition());else if(ey(e,google.maps.Polyline)||ey(e,google.maps.Polygon)){for(var n=e.getPath(),r=0;r<n.getLength();r++)t.extend(n.getAt(r))}else ey(e,google.maps.Circle)&&t.union(e.getBounds())}),E.current.setCenter(t.getCenter())}),X=(0,c.useMemoizedFn)(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null;if("point"===N){var r=e.getPosition(),o=r.lat;n=[(0,r.lng)(),o()]}else if("polygon"===N||"lineString"===N){if((n=e.getPath().getArray().map(function(e){return[e.lng(),e.lat()]})).length<2)return}else if("circle"===N){var i=e.getCenter(),a=e.getRadius();n=[i.lng(),i.lat(),a]}!t&&Y(e),null==s||s(n)}),H=(0,c.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0,n=eg(ev({},U,t),{map:E.current});return C.current=new google.maps.drawing.DrawingManager({drawingMode:_.current,drawingControl:!1,markerOptions:eg(ev({},n),{icon:ef(g)}),polygonOptions:n,polylineOptions:n,circleOptions:n,map:E.current}),!e&&C.current.addListener("overlaycomplete",function(e){X(e.overlay)}),C.current}),Q=(0,c.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,n=arguments.length>2?arguments[2]:void 0,r=eC[e];if(!!r){var o=ev(eg(ev({},U),{icon:ef(g)}),n);return"transformOptions"in r?Object.assign(o,r.transformOptions(t)):"propertyKey"in r&&(o[r.propertyKey]=Array.isArray(t[0])?t.map(function(e){return new google.maps.LatLng(e[1],e[0])}):new google.maps.LatLng(t[1],t[0])),new google.maps[r.overlay](o)}}),$=(0,c.useMemoizedFn)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,n=arguments.length>2?arguments[2]:void 0;if(E.current)return Q(e,t,eg(ev({},n),{map:E.current}))});(0,r.useEffect)(function(){if(!a&&E.current){var e,t;W(),null==C||null===(t=C.current)||void 0===t||null===(e=t.setDrawingMode)||void 0===e||e.call(t,_.current),null==s||s(null)}if(E.current){if(!a||!d&&M.current)return;var n=$();Y(n),Z([n])}},[a,I,N,y,d,$,Z,Y]),(0,r.useEffect)(function(){if(w&&!E.current&&G.current){try{n=new ec({apiKey:w,version:"weekly",language:L.auth.getLocale()})}catch(e){T(S("Load google maps failed, Please check the Api key and refresh the page"));return}var e,t,n,r=console.error;return console.error=function(e){for(var t,n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];(null==e?void 0:e.includes("InvalidKeyMapError"))&&T(S("Load google maps failed, Please check the Api key and refresh the page")),r.apply(void 0,[e].concat(function(e){if(Array.isArray(e))return ed(e)}(t=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||eO(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))},Promise.all([n.importLibrary("drawing"),n.importLibrary("core"),n.importLibrary("geometry")]).then((t=(e=function(e){var t;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e){var t=function(){e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(function(t){var n=t.coords;e({lat:n.latitude,lng:n.longitude})},function(){t()}):t()})];case 1:return t=e.sent(),E.current=new google.maps.Map(G.current,{zoom:b,center:t,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),T(""),F([]),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){em(i,r,o,a,l,"next",e)}function l(e){em(i,r,o,a,l,"throw",e)}a(void 0)})}),function(e){return t.apply(this,arguments)})).catch(function(e){if(ey(e,Error)){T(e.message);return}}),function(){var e,t;null===(e=E.current)||void 0===e||e.unbindAll(),E.current=null,null===(t=C.current)||void 0===t||t.unbindAll()}}},[w,L.auth,N,b]),(0,r.useEffect)(function(){E.current&&N&&!y&&!C.current&&H()},[H,y,I,N]),(0,r.useImperativeHandle)(t,function(){return{setOverlay:$,getOverlay:Q,setFitView:Z,createDraw:H,map:E.current,overlay:M.current,drawingManager:C.current,errMessage:z}});var ee=(0,c.useMemoizedFn)(function(){var e=function(){W(),C.current.setDrawingMode(_.current),null==s||s(null)};R.confirm({title:S("Clear the canvas"),content:S("Are you sure to clear the canvas?"),okText:S("Confirm"),cancelText:S("Cancel"),getContainer:function(){return G.current},onOk:function(){e()}})}),et=(0,n.useApp)();return!w||z?o().createElement(u.Alert,{action:o().createElement(u.Button,{type:"primary",onClick:function(){return K(et.pluginSettingsManager.getRoutePath("map")+"?tab=google")}},S("Go to the configuration page")),message:z||S("Please configure the Api key first"),type:"error"}):o().createElement("div",{className:(0,n.css)(ew(),B||500)},!E.current&&o().createElement("div",{className:(0,n.css)(eS())},o().createElement(u.Spin,null)),y?null:o().createElement(o().Fragment,null,E.current&&o().createElement(ep,{toCenter:J,mapRef:E}),o().createElement("div",{className:(0,n.css)(eP())},o().createElement(u.Button,{onClick:function(){M.current&&Z([M.current])},disabled:!M.current,type:"primary",shape:"round",size:"large",icon:o().createElement(l.SyncOutlined,null)})),"lineString"===N||"polygon"===N?o().createElement("div",{className:(0,n.css)(eA())},o().createElement(u.Alert,{message:S("Click to select the starting point and double-click to end the drawing"),type:"info"})):null,o().createElement("div",{className:(0,n.css)(ej())},o().createElement(u.Button,{disabled:!a,style:{height:"40px"},onClick:ee,type:"primary",danger:!0},S("Clear")))),o().createElement("div",{ref:G,className:(0,n.css)(ex()),style:null==e?void 0:e.style}))});function eM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}eE.displayName="GoogleMapsComponent";function ek(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function eI(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function eF(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||eT(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eD(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function ez(e){return function(e){if(Array.isArray(e))return eM(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eT(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eT(e,t){if(e){if("string"==typeof e)return eM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eM(e,t)}}function eL(){var e=eD(["\n margin-top: 6px;\n padding: 2px 4px;\n background: #fff;\n border: 1px solid #0000f5;\n"]);return eL=function(){return e},e}function eR(){var e=eD(["\n margin-top: -64px;\n padding: 2px 4px;\n background: #fff;\n border: 1px solid #0000f5;\n"]);return eR=function(){return e},e}function eB(){var e=eD(["\n position: relative;\n height: 100%;\n "]);return eB=function(){return e},e}function eN(){var e=eD(["\n position: absolute;\n left: 10px;\n top: 10px;\n z-index: 999;\n "]);return eN=function(){return e},e}var e_="google-maps-overlay-id",eU="google-maps-overlay-selected",eK=(0,n.css)(eL()),eG=(0,n.css)(eR());function eq(e){if(ek(e,google.maps.Marker))return e.setIcon(ef(g));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}var eV={amap:K,google:eE},eW=o().forwardRef(function(e,t){var n=f().t,i=e.mapType,a=(0,r.useMemo)(function(){return eV[i]},[i]);return a?o().createElement(a,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({ref:t},e)):o().createElement("div",null,n("The ".concat(i," cannot found")))});eW.displayName="MapComponent";function eJ(){var e,t,n=(e=["\n height: 100%;\n border: 1px solid transparent;\n .ant-formily-item-error & {\n border: 1px solid #ff4d4f;\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eJ=function(){return n},n}var eY=(0,h.connect)(function(e){return o().createElement("div",{className:(0,n.css)(eJ())},o().createElement(eW,e))},(0,h.mapReadPretty)(function(e){var t,r,i=e.value,a=(0,h.useFieldSchema)(),l=(0,n.useCollection)().getField(a.name),c=e.mapType||(null==l?void 0:null===(t=l.uiSchema["x-component-props"])||void 0===t?void 0:t.mapType),u=(0,h.useForm)(),s=(0,h.useField)();return((0,n.useFieldTitle)(),!u.readPretty||s.readPretty)?o().createElement("div",null,o().createElement(n.EllipsisWithTooltip,{ellipsis:!0},null==i?void 0:null===(r=i.map)||void 0===r?void 0:r.call(i,function(e){return Array.isArray(e)?"(".concat(e.join(","),")"):e}).join(","))):o().createElement(eW,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({readonly:!0,mapType:c},e))}));eY.Designer=function(){var e,t=(0,n.useCollectionManager_deprecated)().getCollectionJoinField,r=(0,n.useCollection_deprecated)().getField,i=(0,n.useFormBlockContext)().form,l=(0,h.useField)(),c=(0,h.useFieldSchema)(),u=f().t,s=(0,n.useDesignable)(),p=s.dn;s.refresh;var d=r(c.name)||t(c["x-collection-field"]),m=null==d?void 0:null===(e=d.uiSchema)||void 0===e?void 0:e.title,y={title:l.title===m?void 0:l.title};!l.readPretty&&(y.required=l.required);var v="editable";return!0===c["x-disabled"]&&(v="readonly"),!0===c["x-read-pretty"]&&(v="read-pretty"),o().createElement(n.GeneralSchemaDesigner,null,o().createElement(n.GeneralSchemaItems,null),i&&!(null==i?void 0:i.readPretty)&&!(0,n.isPatternDisabled)(c)&&o().createElement(n.SchemaSettingsSelectItem,{key:"pattern",title:u("Pattern"),options:[{label:u("Editable"),value:"editable"},{label:u("Readonly"),value:"readonly"},{label:u("Easy-reading"),value:"read-pretty"}],value:v,onChange:function(e){var t,n,r,o=(t={},n="x-uid",r=c["x-uid"],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t);switch(e){case"readonly":c["x-read-pretty"]=!1,c["x-disabled"]=!0,o["x-read-pretty"]=!1,o["x-disabled"]=!0,l.readPretty=!1,l.disabled=!0;break;case"read-pretty":c["x-read-pretty"]=!0,c["x-disabled"]=!1,o["x-read-pretty"]=!0,o["x-disabled"]=!1,l.readPretty=!0;break;default:c["x-read-pretty"]=!1,c["x-disabled"]=!1,o["x-read-pretty"]=!1,o["x-disabled"]=!1,l.readPretty=!1,l.disabled=!1}p.emit("patch",{schema:o}),p.refresh()}}),o().createElement(n.SchemaSettingsModalItem,{key:"map-zoom",title:u("Set default zoom level"),schema:{type:"object",title:u("Set default zoom level"),properties:{zoom:{title:u("Zoom"),default:l.componentProps.zoom||13,description:u("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:function(e){var t=e.zoom;t&&(a().set(c,"x-component-props.zoom",t),Object.assign(l.componentProps,c["x-component-props"]),p.emit("patch",{schema:{"x-uid":c["x-uid"],"x-component-props":l.componentProps}})),p.refresh()}}),o().createElement(n.SchemaSettingsRemove,{key:"remove",removeParentsIfNoChildren:!0,confirm:{title:u("Delete field")},breakRemoveOn:{"x-component":"Grid"}}))};var eZ={amap:function(e){var t,i,a,s,p,d,m,y=(0,n.useProps)(e),h=y.collectionField,w=y.fieldNames,S=y.dataSource,P=y.fixedBlock,A=y.zoom,j=y.setSelectedRecordKeys,x=y.lineSort,C=(0,n.useCollection_deprecated)(),E=C.name,M=C.getPrimaryKey,k=(0,n.useCollectionManager_deprecated)().getCollectionJoinField,I=M(),F=V((0,r.useState)(!1),2),D=F[0],z=F[1],T=(0,r.useRef)(),L=null===(s=T.current)||void 0===s?void 0:null===(a=s.aMap)||void 0===a?void 0:a.GeometryUtil,R=V((0,r.useState)(),2),B=R[0],N=R[1],_=V((0,r.useState)(""),2),U=_[0],G=_[1],W=f().t,Y=(0,n.useCompile)(),Q=(0,n.useFilterAPI)(),$=Q.isConnected,ee=Q.doFilter,et=V((0,r.useState)(null),2)[1],en=(0,r.useRef)(U);en.current=U;var er=(0,n.useCollection)().fields,eo=(0,n.useCollectionParentRecordData)(),ei=(0,n.usePopupUtils)().openPopup,ea=null===(p=er.find(function(e){return e.name===(null==w?void 0:w.marker)}))||void 0===p?void 0:p.uiSchema,el=function(e,t){var n=e.getExtData(),r=void 0===t?n.selected:!t;n.selected=!r,"setIcon"in e&&e.setIcon(new T.current.aMap.Icon({imageSize:[19,32],image:r?g:v})),e.setOptions(q({extData:n},r?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},ec=function(){var e,t,n;T.current&&(null===(e=T.current)||void 0===e||e.mouseTool().close(!0),null===(t=T.current)||void 0===t||t.editor().setTarget(null),null===(n=T.current)||void 0===n||n.editor().close())};(0,r.useEffect)(function(){var e,t,n,r;if("selection"===U)return(null===(e=T.current)||void 0===e?void 0:e.editor())?null===(r=T.current)||void 0===r||r.executeMouseTool("polygon"):(null===(t=T.current)||void 0===t||t.createEditor("polygon"),null===(n=T.current)||void 0===n||n.createMouseTool("polygon")),function(){ec()}},[U]),(0,r.useEffect)(function(){if(U)return function(){if(!en.current){var e;null===(e=T.current)||void 0===e||e.map.getAllOverlays().forEach(function(e){el(e,!1)})}}},[U]);var eu=(0,c.useMemoizedFn)(function(){var e,t,n,r=null===(e=T.current)||void 0===e?void 0:e.editor().getTarget(),o=null===(t=T.current)||void 0===t?void 0:t.map.getAllOverlays(),i=null==o?void 0:o.filter(function(e){if(e!==r&&void 0!==e.getExtData().id)return"getPosition"in e?L.isPointInRing(e.getPosition(),null==r?void 0:r.getPath()):L.doesRingRingIntersect(e.getPath(),null==r?void 0:r.getPath())}),a=null==i?void 0:i.map(function(e){return el(e,!0),e.getExtData().id});j(function(e){return null==a?void 0:a.concat(e)}),null==r||r.remove(),null===(n=T.current)||void 0===n||n.editor().close()});(0,r.useEffect)(function(){if(h&&T.current&&S){var e=k([E].concat(J(Array.isArray(null==w?void 0:w.field)&&(null==w?void 0:w.field.length)>1?null==w?void 0:w.field.slice(0,-1):null==w?void 0:w.field)).flat().join(".")),t=S.map(function(t){var r,o=null===(r=b(t,null==w?void 0:w.field,null==e?void 0:e.interface))||void 0===r?void 0:r.filter(Boolean),i=(0,n.getLabelFormatValue)(ea,t[w.marker]);return(null==o?void 0:o.length)?o.map(function(e){var n;return null===(n=T.current)||void 0===n?void 0:n.setOverlay(h.type,e,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:(null==w?void 0:w.marker)?Y(i):void 0},extData:{id:t[I]}})}):[]}).flat().filter(Boolean);null===(i=T.current)||void 0===i||null===(o=i.map)||void 0===o||o.setFitView(t);var r=t.map(function(e){var t=function(t){var n=t.target,r=n.getExtData();if(r){if(en.current){"click"===en.current&&(j(function(e){return r.selected?e.filter(function(e){return e!==r.id}):J(e).concat([r.id])}),el(n));return}var o=S.find(function(e){return r.id===e[I]});if($){et(function(t){return(t&&H(t),t===e)?(H(e),ee(null),null):(function(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}(e),ee(o[I],function(e){return e.field||I},"$eq"),e)});return}o&&(N(o),ei({recordData:o}))}};return e.on("click",t),function(){return e.off("click",t)}});if("point"===h.type&&(null==x?void 0:x.length)&&(null==t?void 0:t.length)>1){var o,i,a,l=t.map(function(e){return e.getPosition()});t[0].setzIndex(13),t[t.length-1].setzIndex(13);var c=function(){var e,t,n=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(null===(e=T.current)||void 0===e?void 0:e.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:n?W("Start point"):W("End point")},position:l[n?0:l.length-1],map:null===(t=T.current)||void 0===t?void 0:t.map})};t.push.apply(t,J([null===(a=T.current)||void 0===a?void 0:a.setOverlay("lineString",l,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),c(),c(!1)].filter(Boolean)))}return function(){t.forEach(function(e){e.remove()}),r.forEach(function(e){return e()})}}},[S,D,w,E,I,h.type,$,x,ei]),(0,r.useEffect)(function(){setTimeout(function(){j([])})},[S]);return o().createElement("div",{className:(0,n.css)(Z())},o().createElement("div",{className:(0,n.css)(X())},!D||(null===(d=T.current)||void 0===d?void 0:d.errMessage)?null:o().createElement(u.Space,{direction:"vertical"},o().createElement(u.Button,{style:{color:U?void 0:"#F18b62",borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),G("")},icon:o().createElement(l.EnvironmentOutlined,null)}),o().createElement(u.Button,{style:{color:"selection"===U?"#F18b62":void 0,borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),G("selection")},icon:o().createElement(l.ExpandOutlined,null)}),"selection"===U?o().createElement(u.Button,{type:"primary",icon:o().createElement(l.CheckOutlined,null),title:W("Confirm selection"),onClick:eu}):null)),o().createElement(n.RecordProvider,{record:B,parent:eo},o().createElement(O,null)),o().createElement(K,(t=q({},null==h?void 0:null===(m=h.uiSchema)||void 0===m?void 0:m["x-component-props"]),i=(i={ref:function(e){T.current=e,z(!!(null==e?void 0:e.map)&&!e.errMessage)},style:{height:P?"100%":null},zoom:A,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}},i),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}),t)))},google:function(e){var t,i,a,s=(0,n.useProps)(e),p=s.collectionField,d=s.fieldNames,m=s.dataSource,y=s.fixedBlock,h=s.zoom,w=s.setSelectedRecordKeys,S=s.lineSort,P=(0,(0,n.useCollection_deprecated)().getPrimaryKey)(),A=d.marker,j=eF((0,r.useState)(!1),2),x=j[0],C=j[1],E=(0,r.useRef)(),M=eF((0,r.useState)(),2),k=M[0],I=M[1],F=eF((0,r.useState)(""),2),D=F[0],z=F[1],T=f().t,L=(0,n.useCompile)(),R=(0,n.useFilterAPI)(),B=R.isConnected,N=R.doFilter,_=eF((0,r.useState)(null),2)[1],U=(0,r.useRef)(D),K=(0,r.useRef)(null),G=(0,r.useRef)([]);U.current=D;var q=(0,n.useCollection)().fields,V=(0,n.useCollectionParentRecordData)(),W=null===(a=q.find(function(e){return e.name===(null==d?void 0:d.marker)}))||void 0===a?void 0:a.uiSchema,J=(0,n.useCollectionManager_deprecated)().getCollectionJoinField,Y=(0,n.usePopupUtils)().openPopup,Z=function(e,t){var n=void 0!==t?!t:e.get(eU);e.set(eU,!n),e.setOptions(eI({},n?{icon:ef(g),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:ef(v),strokeColor:"#F18b62",fillColor:"#F18b62"}))};(0,r.useEffect)(function(){if("selection"===D){E.current&&!(null===(e=E.current)||void 0===e?void 0:e.drawingManager)&&(E.current.drawingManager=null===(r=E.current)||void 0===r?void 0:r.createDraw(!0,{editable:!0,draggable:!0}));var e,t,n,r,o=new Set;return null===(t=E.current)||void 0===t||t.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),null===(n=E.current)||void 0===n||n.drawingManager.addListener("overlaycomplete",function(e){var t,n=e.overlay;null===(t=E.current)||void 0===t||t.drawingManager.setDrawingMode(null),K.current=n;var r=n.getPath();["insert_at","remove_at","set_at"].forEach(function(e){o.add(r.addListener(e,function(){}).remove)})}),function(){var e,t,n,r;o.forEach(function(e){e()}),E.current&&(null===(e=K.current)||void 0===e||e.unbindAll(),null===(t=K.current)||void 0===t||t.setMap(null),K.current=null,null===(n=E.current)||void 0===n||n.drawingManager.setDrawingMode(null),null===(r=E.current)||void 0===r||r.drawingManager.unbindAll())}}},[D]),(0,r.useEffect)(function(){if(D)return function(){!U.current&&G.current.forEach(function(e){Z(e,!1)})}},[D]);var X=(0,c.useMemoizedFn)(function(){var e,t=K.current,n=G.current,r=google.maps.geometry.poly,o=n.filter(function(e){if(e!==t&&void 0!==e.get(e_)){if(ek(e,google.maps.Marker))return r.containsLocation(e.getPosition(),t);else if(ek(e,google.maps.Circle))return r.containsLocation(e.getCenter(),t);else return e.getPath().getArray().some(function(e){return r.containsLocation(e,t)})}}).map(function(e){return Z(e,!0),e.get(e_)});w(function(e){return o.concat(e)}),null==t||t.unbindAll(),null==t||t.setMap(null),null===(e=E.current)||void 0===e||e.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});(0,r.useEffect)(function(){if(p&&(null==m?void 0:m.length)&&(null===(o=E.current)||void 0===o?void 0:o.map)){var e=J([name].concat(ez(Array.isArray(null==d?void 0:d.field)&&(null==d?void 0:d.field.length)>1?null==d?void 0:d.field.slice(0,-1):null==d?void 0:d.field)).flat().join(".")),t=m.map(function(t){var r=b(t,null==d?void 0:d.field,null==e?void 0:e.interface),o=(0,n.getLabelFormatValue)(W,t[d.marker]);return(null==r?void 0:r.length)?null==r?void 0:r.filter(Boolean).map(function(e){if(r){var n,i=null===(n=E.current)||void 0===n?void 0:n.setOverlay(p.type,e,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:eK,fontFamily:"inherit",fontSize:"13px",color:"#333",text:(null==d?void 0:d.marker)?L(o):void 0}});return null==i||i.set(e_,t[P]),i}}):[]}).flat().filter(Boolean);G.current=t;var r=t.map(function(e){return e.addListener("click",function(t){var n=e.get(e_);if(n){var r=null==m?void 0:m.find(function(e){return n===e[P]});if(B){_(function(t){return(t&&eq(e),t===e)?(eq(e),N(null),null):(function(e){if(ek(e,google.maps.Marker))return e.setIcon(ef(v));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}(e),N(r[P],function(e){return e.field||P},"$eq"),e)});return}r&&(I(r),Y({recordData:r}))}}),function(){return e.unbindAll()}});if("point"===p.type&&(null==S?void 0:S.length)&&(null==t?void 0:t.length)>1){var o,i,a=t.map(function(e){return e.getPosition()});t[0].setZIndex(138),t[t.length-1].setZIndex(138);var l=function(){var e,t=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(null===(e=E.current)||void 0===e?void 0:e.map)return new google.maps.Marker({label:{className:eG,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t?T("Start point"):T("End point")},icon:ef(g),position:t?a[0]:a[a.length-1],map:E.current.map})};t.push.apply(t,ez([E.current.setOverlay("lineString",a.map(function(e){return[e.lng(),e.lat()]}),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),l(),l(!1)].filter(Boolean)))}return null===(i=E.current)||void 0===i||i.setFitView(t),function(){t.forEach(function(e){e.setMap(null),e.unbindAll()}),r.forEach(function(e){return e()})}}},[m,x,void 0===A?"id":A,p.type,B,Y]),(0,r.useEffect)(function(){setTimeout(function(){w([])})},[m]);return o().createElement("div",{className:(0,n.css)(eB())},x&&o().createElement(o().Fragment,null,o().createElement("div",{className:(0,n.css)(eN())},o().createElement(u.Space,{direction:"vertical"},o().createElement(u.Button,{style:{color:D?void 0:"#F18b62",borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),z("")},icon:o().createElement(l.EnvironmentOutlined,null)}),o().createElement(u.Button,{style:{color:"selection"===D?"#F18b62":void 0,borderColor:"currentcolor"},onClick:function(e){e.stopPropagation(),z("selection")},icon:o().createElement(l.ExpandOutlined,null)}),"selection"===D?o().createElement(u.Button,{type:"primary",icon:o().createElement(l.CheckOutlined,null),title:T("Confirm selection"),onClick:X}):null)),o().createElement(n.RecordProvider,{record:k,parent:V},o().createElement(O,null))),o().createElement(eE,(t=eI({},e),i=(i={ref:function(e){E.current=e,C(!!(null==e?void 0:e.map)&&!e.errMessage)},style:{height:y?"100%":null},zoom:h,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}},i),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}),t)))}},eX=function(e){var t=f().t,i=e.mapType,a=(0,r.useMemo)(function(){return eZ[i]},[i]);return a?o().createElement(n.PopupContextProvider,null,o().createElement(a,e)):o().createElement("div",null,t("The ".concat(i," cannot found")))},eH=(0,n.withDynamicSchemaProps)(function(e){var t,i,l,c,u=(0,n.usePopupUtils)().context;if(u.currentLevel&&!a().isNil(null===(l=u.params)||void 0===l?void 0:l.filterbytk))return o().createElement(n.PopupContextProvider,null,o().createElement(O,null));var s=(0,n.useProps)(e).fieldNames,p=(0,n.useCollectionManager_deprecated)().getCollectionJoinField,f=(0,n.useCollection_deprecated)().name,d=(0,r.useMemo)(function(){return p([f,null==s?void 0:s.field].flat().join("."))},[f,null==s?void 0:s.field]),m=null==d?void 0:null===(c=d.uiSchema)||void 0===c?void 0:c["x-component-props"];return o().createElement(eX,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},m,e),i=(i={collectionField:d},i),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}),t))}),eQ=function(){var e=(0,n.useCollection)(),t=e.name,r=e.title,i=(0,n.useSchemaTemplate)();return o().createElement(n.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:i,title:r||t})},e$=d("632"),e0=d("875"),e1=function(e){var t,n,r,o=e.collectionName,i=e.fieldNames,a=e.dataSource;return{type:"void","x-acl-action":"".concat(o,":list"),"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:a,action:"list",fieldNames:i,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:(t={actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{}}},n=(0,e0.uid)(),r={type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}},n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t)}},e2=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return"string"==typeof e&&(e=[e]),null==e?void 0:e.reduce(function(t,n,r){var o=null==t?void 0:t.find(function(e){return e.value===n});return r===e.length-1?o:null==o?void 0:o.children},t)};function e4(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function e3(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var e5=function(){var e,t,i=(0,n.useSchemaInitializerItem)(),a=(0,n.useSchemaInitializer)().insert,c=(0,r.useContext)(h.SchemaOptionsContext),u=(0,n.useCollectionManager_deprecated)().getCollectionFieldsOptions,s=f().t,p=(0,n.useGlobalTheme)().theme;return o().createElement(n.DataBlockInitializer,e3({componentType:"Map",icon:o().createElement(l.TableOutlined,null),onCreateBlockSchema:(t=(e=function(e){var t,r,i,l;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(f){switch(f.label){case 0:return r=u((t=e.item).name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:t.dataSource}),i=u(t.name,"string",{dataSource:t.dataSource}),[4,(0,n.FormDialog)(s("Create map block"),function(){var e;return o().createElement(n.SchemaComponentOptions,{scope:c.scope,components:e3({},c.components)},o().createElement(e$.FormLayout,{layout:"vertical"},o().createElement(n.SchemaComponent,{schema:{properties:{field:{title:s("Map field"),enum:r,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:r.length?[r[0].value,null===(e=r[0].children)||void 0===e?void 0:e[0].value].filter(function(e){return null!=e}):[]},marker:{title:s("Marker field"),enum:i,"x-component":"Select","x-decorator":"FormItem","x-reactions":function(e){var t=e.form.values.field;if(!!(null==t?void 0:t.length)){var n=e2(t,r);n&&(e.hidden="point"!==n.type)}}}}}})))},p).open({initialValues:{}})];case 1:return l=f.sent(),a(e1({collectionName:t.name,dataSource:t.dataSource,fieldNames:e3({},l)})),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){e4(i,r,o,a,l,"next",e)}function l(e){e4(i,r,o,a,l,"throw",e)}a(void 0)})}),function(e){return t.apply(this,arguments)}),title:s("Map block")},i))},e8=d("964");function e6(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function e9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function e7(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function te(){var e,t,n=(e=["\n .nb-action-bar {\n margin-bottom: ","px;\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return te=function(){return n},n}var tt=(0,r.createContext)({});tt.displayName="MapBlockContext";var tn=function(e){var t,i,a,l=e.fieldNames,c=(0,h.useFieldSchema)(),s=(0,h.useField)(),p=(0,n.useBlockRequestContext)(),f=p.resource,d=p.service;var m=(t=(0,r.useState)([]),i=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return e6(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e6(e,t)}}(t,i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),y=m[0],v=m[1],g=u.theme.useToken().token;return o().createElement(n.FixedBlockWrapper,null,o().createElement(n.SchemaComponentOptions,{scope:{selectedRecordKeys:y}},o().createElement(tt.Provider,{value:{field:s,service:d,resource:f,fieldNames:l,fixedBlock:null==c?void 0:null===(a=c["x-decorator-props"])||void 0===a?void 0:a.fixedBlock,selectedRecordKeys:y,setSelectedRecordKeys:v}}," ",o().createElement("div",{className:(0,e8.css)(te(),g.margin)},e.children))))},tr=function(e){var t=(0,n.useParsedFilter)({filterOption:null==e?void 0:e.filter}),r=t.filter,o=t.parseVariableLoading;return{params:e7(e9({},e),{filter:r}),parseVariableLoading:o}},to=function(e){var t=(0,h.useField)(),r=e.fieldNames,i=tr(e.params),a=i.params;if(i.parseVariableLoading)return null;var l=a.appends||[],c=(r||{}).field;return Array.isArray(c)&&c.length>1&&l.push(c[0]),o().createElement(n.BlockProvider,e7(e9({name:"map"},e),{runWhenParamsChanged:!0,params:e7(e9({},a),{appends:l,paginate:!1,sort:t.componentProps.lineSort})}),o().createElement(tn,e))},ti=function(){return(0,r.useContext)(tt)},ta=function(){var e,t,n,r,o,i,a=ti();return e7(e9({},a),{dataSource:null==a?void 0:null===(t=a.service)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.data,zoom:(null==a?void 0:null===(r=a.field)||void 0===r?void 0:null===(n=r.componentProps)||void 0===n?void 0:n.zoom)||13,lineSort:null==a?void 0:null===(i=a.field)||void 0===i?void 0:null===(o=i.componentProps)||void 0===o?void 0:o.lineSort})},tl=function(e){return o().createElement(n.SchemaComponentOptions,{scope:{useMapBlockProps:ta},components:{MapBlockInitializer:e5,MapBlockDesigner:eQ,MapBlockProvider:to,MapBlock:eH}},e.children)};function tc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var tu={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,n.useActionAvailable)("create")}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},ts=new n.CompatibleSchemaInitializer(tc({name:"MapActionInitializers"},tu)),tp=new n.CompatibleSchemaInitializer(tc({name:"map:configureActions"},tu),ts);function tf(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var td={name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps:function(){var e,t=f().t,r=(0,h.useFieldSchema)(),o=(0,h.useField)(),i=(0,n.useDesignable)().dn,l=(null==r?void 0:null===(e=r["x-component-props"])||void 0===e?void 0:e.zoom)||13;return{title:t("The default zoom level of the map"),schema:{type:"object",title:t("Set default zoom level"),properties:{zoom:{title:t("Zoom"),default:l,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:function(e){var t=e.zoom;a().set(r,"x-component-props.zoom",t),o.componentProps.zoom=t,i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),i.refresh()}}},useVisible:function(){return!(0,n.useColumnSchema)().fieldSchema}},tm=new n.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:n.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:n.SchemaSettingsBlockHeightItem},{name:"mapField",Component:n.SchemaSettingsCascaderItem,useComponentProps:function(){var e,t=(0,n.useCollectionManager_deprecated)().getCollectionFieldsOptions,r=f().t,o=(0,h.useFieldSchema)(),i=(null==o?void 0:null===(e=o["x-decorator-props"])||void 0===e?void 0:e.fieldNames)||{},a=(0,h.useField)(),l=(0,n.useDesignable)().dn,c=ti().service,u=t((0,n.useCollection)().name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:r("Map field"),value:i.field,options:u,allowClear:!1,onChange:function(e){var t,n=a.decoratorProps.fieldNames||{};n.field=e,a.decoratorProps.fieldNames=n,o["x-decorator-props"].fieldNames=n,c.refresh(),l.emit("patch",{schema:(tf(t={},"x-uid",o["x-uid"]),tf(t,"x-decorator-props",a.decoratorProps),t)}),l.refresh()}}}},{name:"markerField",Component:n.SchemaSettingsSelectItem,useComponentProps:function(){var e,t=f().t,r=(0,h.useFieldSchema)(),o=(null==r?void 0:null===(e=r["x-decorator-props"])||void 0===e?void 0:e.fieldNames)||{},i=ti().service,a=(0,h.useField)(),l=(0,n.useDesignable)().dn,c=(0,(0,n.useCollectionManager_deprecated)().getCollectionFieldsOptions)((0,n.useCollection)().name,"string");return{title:t("Marker field"),value:o.marker,options:c,onChange:function(e){var t,n=a.decoratorProps.fieldNames||{};n.marker=e,a.decoratorProps.fieldNames=n,r["x-decorator-props"].fieldNames=n,i.refresh(),l.emit("patch",{schema:(tf(t={},"x-uid",r["x-uid"]),tf(t,"x-decorator-props",a.decoratorProps),t)}),l.refresh()}}},useVisible:function(){var e,t,r=(0,h.useFieldSchema)(),o=(0,n.useCollectionManager_deprecated)().getCollectionFieldsOptions,i=(0,n.useCollection)().name,a=(null==r?void 0:null===(e=r["x-decorator-props"])||void 0===e?void 0:e.fieldNames)||{},l=o(i,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return(null===(t=e2(a.field,l))||void 0===t?void 0:t.type)==="point"}},{name:"setDefaultSortingRules",Component:n.SchemaSettingsDefaultSortingRules,useComponentProps:function(){return{path:"x-component-props.lineSort",title:(0,f().t)("Concatenation order field")}}},n.setDataLoadingModeSettingsItem,td,{name:"dataScope",Component:n.SchemaSettingsDataScope,useComponentProps:function(){var e,t,r=(0,n.useCollection)().name,o=(0,h.useFieldSchema)(),i=(0,n.useFormBlockContext)().form,a=(0,h.useField)(),l=ti().service,c=(0,n.useDesignable)().dn;return{collectionName:r,defaultFilter:(null==o?void 0:null===(t=o["x-decorator-props"])||void 0===t?void 0:null===(e=t.params)||void 0===e?void 0:e.filter)||{},form:i,onSubmit:function(e){var t,n,r,i=e.filter,u=a.decoratorProps.params||{};u.filter=i,a.decoratorProps.params=u,o["x-decorator-props"].params=u,null===(n=l.params)||void 0===n||null===(t=n[1])||void 0===t||t.filters,c.emit("patch",{schema:(tf(r={},"x-uid",o["x-uid"]),tf(r,"x-decorator-props",o["x-decorator-props"]),r)})}}}},{name:"ConnectDataBlocks",Component:n.SchemaSettingsConnectDataBlocks,useComponentProps:function(){var e=f().t;return{type:n.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:n.SchemaSettingsTemplate,useComponentProps:function(){var e,t,r=(0,n.useCollection)().name,o=(0,h.useFieldSchema)(),i=(0,n.useBlockTemplateContext)().componentNamePrefix,a=(null==o?void 0:null===(e=o["x-decorator-props"])||void 0===e?void 0:e.resource)||(null==o?void 0:null===(t=o["x-decorator-props"])||void 0===t?void 0:t.association);return{componentName:"".concat(i,"Map"),collectionName:r,resourceName:a}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});function ty(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tv(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tg(e){return(tg=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tb(e,t){return(tb=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function th(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(th=function(){return!!e})()}var tO=n.interfacesProperties.defaultProps;Array.isArray(n.interfacesProperties.type.enum)&&n.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});var tw=function(e){var t,n,r;function o(){var e,t,n,r,i,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=tg(n),tv(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,th()?Reflect.construct(n,r||[],tg(t).constructor):n.apply(t,r)),"properties",(i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){tv(e,t,n[t])})}return e}({},tO),a=(a={"uiSchema.x-component-props.mapType":{title:p("Map type"),type:"string",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1},"x-disabled":"{{ isOverride || !createOnly }}",default:"amap",enum:y}},a),Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i)),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tb(e,t)}(o,e),t=o,n=[{key:"schemaInitialize",value:function(e,t){"Form"===t.block&&Object.assign(e,{"x-designer":"Map.Designer"})}}],ty(t.prototype,n),o}(n.CollectionFieldInterface);function tS(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tP(e){return(tP=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tA(e,t){return(tA=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tj(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tj=function(){return!!e})()}var tx=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=tP(r),tS(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,tj()?Reflect.construct(r,o||[],tP(n).constructor):r.apply(n,o)),"name","circle"),tS(e,"type","object"),tS(e,"group","map"),tS(e,"order",3),tS(e,"title",p("Circle")),tS(e,"availableTypes",["circle","json"]),tS(e,"description",p("Circle")),tS(e,"sortable",!0),tS(e,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tA(e,t)}(t,e),t}(tw);function tC(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tE(e){return(tE=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tM(e,t){return(tM=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tk(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tk=function(){return!!e})()}var tI=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=tE(r),tC(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,tk()?Reflect.construct(r,o||[],tE(n).constructor):r.apply(n,o)),"name","lineString"),tC(e,"type","object"),tC(e,"group","map"),tC(e,"order",2),tC(e,"title",p("Line")),tC(e,"description",p("Line")),tC(e,"availableTypes",["lineString","json"]),tC(e,"sortable",!0),tC(e,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tM(e,t)}(t,e),t}(tw);function tF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tD(e){return(tD=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tz(e,t){return(tz=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tT(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tT=function(){return!!e})()}var tL=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=tD(r),tF(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,tT()?Reflect.construct(r,o||[],tD(n).constructor):r.apply(n,o)),"name","point"),tF(e,"type","object"),tF(e,"group","map"),tF(e,"order",1),tF(e,"title",p("Point")),tF(e,"description",p("Point")),tF(e,"availableTypes",["point","json"]),tF(e,"sortable",!0),tF(e,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tz(e,t)}(t,e),t}(tw);function tR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tB(e){return(tB=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tN(e,t){return(tN=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function t_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(t_=function(){return!!e})()}var tU=[tL,function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=tB(r),tR(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,t_()?Reflect.construct(r,o||[],tB(n).constructor):r.apply(n,o)),"name","polygon"),tR(e,"type","object"),tR(e,"group","map"),tR(e,"order",4),tR(e,"title",p("Polygon")),tR(e,"description",p("Polygon")),tR(e,"availableTypes",["polygon","json"]),tR(e,"sortable",!0),tR(e,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tN(e,t)}(t,e),t}(tw),tI,tx],tK=new n.SchemaSettings({name:"fieldSettings:component:Map",items:[td]});function tG(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function tq(e,t,n){return(tq=tZ()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&tJ(o,n.prototype),o}).apply(null,arguments)}function tV(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tW(e){return(tW=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tJ(e,t){return(tJ=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tY(e){var t="function"==typeof Map?new Map:void 0;return(tY=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return tq(e,arguments,tW(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),tJ(r,e)})(e)}function tZ(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tZ=function(){return!!e})()}var tX=o().memo(function(e){return o().createElement(n.SchemaComponentOptions,{components:{Map:eY}},o().createElement(tl,null,e.children))});tX.displayName="MapProvider";var tH=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=tW(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,tZ()?Reflect.construct(t,n||[],tW(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tJ(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){var e;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(n){return t.app.use(tX),t.app.dataSourceManager.addFieldInterfaces(tU),t.app.dataSourceManager.addFieldInterfaceGroups({map:{label:p("Map-based geometry"),order:51}}),t.app.schemaInitializerManager.add(ts),t.app.schemaInitializerManager.add(tp),t.schemaSettingsManager.add(tm),t.schemaSettingsManager.add(tK),null==(e=t.app.schemaInitializerManager.get("page:addBlock"))||e.add("dataBlocks.map",{title:p("Map"),Component:"MapBlockInitializer"}),t.app.schemaInitializerManager.addItem("mobile:addBlock","dataBlocks.map",{title:p("Map"),Component:"MapBlockInitializer"}),t.app.pluginSettingsManager.add("map",{title:'{{t("Map Manager", { ns: "'.concat("map",'" })}}'),icon:"EnvironmentOutlined",Component:ei,aclSnippet:"pm.map.configuration"}),t.app.addScopes({useMapBlockProps:ta}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){tG(i,r,o,a,l,"next",e)}function l(e){tG(i,r,o,a,l,"throw",e)}a(void 0)})})()}}],tV(t.prototype,n),o}(tY(n.Plugin)),tQ=tH}(),m}()});
10
+ (function(D,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("lodash"),require("@ant-design/icons"),require("ahooks"),require("antd"),require("react-i18next"),require("@formily/react"),require("@formily/antd-v5"),require("@formily/shared"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","lodash","@ant-design/icons","ahooks","antd","react-i18next","@formily/react","@formily/antd-v5","@formily/shared","@emotion/css"],i):(D=typeof globalThis!="undefined"?globalThis:D||self,i(D["@nocobase/plugin-map"]={},D.jsxRuntime,D["@nocobase/client"],D.react,D.lodash,D["@ant-design/icons"],D.ahooks,D.antd,D["react-i18next"],D["@formily/react"],D["@formily/antd-v5"],D["@formily/shared"],D["@emotion/css"]))})(this,function(D,i,r,h,me,ee,G,x,le,z,et,tt,ot){"use strict";var Vt=Object.defineProperty,Wt=Object.defineProperties;var Yt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var De=(D,i,r)=>i in D?Vt(D,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):D[i]=r,O=(D,i)=>{for(var r in i||(i={}))Ht.call(i,r)&&De(D,r,i[r]);if(Re)for(var r of Re(i))Jt.call(i,r)&&De(D,r,i[r]);return D},W=(D,i)=>Wt(D,Yt(i));var E=(D,i,r)=>(De(D,typeof i!="symbol"?i+"":i,r),r);var Ce=(D,i,r)=>new Promise((h,me)=>{var ee=le=>{try{x(r.next(le))}catch(z){me(z)}},G=le=>{try{x(r.throw(le))}catch(z){me(z)}},x=le=>le.done?h(le.value):Promise.resolve(le.value).then(ee,G);x((r=r.apply(D,i)).next())});const be="map";function X(e){return`{{t('${e}', { ns: '${be}', nsMode: 'fallback' })}}`}function Y(){return le.useTranslation([be,"client"],{nsMode:"fallback"})}const Te=[{label:X("AMap"),value:"amap"},{label:X("Google Maps"),value:"google"}],Se="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV3iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==",ze=(e,o,t)=>{const n=o==null?void 0:o.reduce((l,a,c)=>c===o.length-1&&(t==="o2m"||t==="m2m")?l==null?void 0:l.map(g=>g[a]).filter(g=>g!=null):l==null?void 0:l[a],e);return t==="o2m"||t==="m2m"?n:[n]},xe=e=>{const o=r.useCollectionRecordData(),t=r.useCollection(),n=z.useFieldSchema(),l=h.useMemo(()=>n.reduceProperties((a,c)=>c.name==="drawer"?c:a,null),[n]);return l?i.jsx(r.VariablePopupRecordProvider,{recordData:o,collection:t,children:i.jsx(z.RecursionField,{schema:l,name:l.name})}):null};var rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Be={exports:{}};(function(e,o){(function(t,n){e.exports=n()})(rt,function(){function t(p){var y=[];return p.AMapUI&&y.push(n(p.AMapUI)),p.Loca&&y.push(l(p.Loca)),Promise.all(y)}function n(p){return new Promise(function(y,d){var f=[];if(p.plugins)for(var C=0;C<p.plugins.length;C+=1)c.AMapUI.plugins.indexOf(p.plugins[C])==-1&&f.push(p.plugins[C]);if(g.AMapUI===a.failed)d("前次请求 AMapUI 失败");else if(g.AMapUI===a.notload){g.AMapUI=a.loading,c.AMapUI.version=p.version||c.AMapUI.version,C=c.AMapUI.version;var L=document.body||document.head,B=document.createElement("script");B.type="text/javascript",B.src="https://webapi.amap.com/ui/"+C+"/main.js",B.onerror=function(w){g.AMapUI=a.failed,d("请求 AMapUI 失败")},B.onload=function(){if(g.AMapUI=a.loaded,f.length)window.AMapUI.loadUI(f,function(){for(var w=0,U=f.length;w<U;w++){var q=f[w].split("/").slice(-1)[0];window.AMapUI[q]=arguments[w]}for(y();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()});else for(y();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()},L.appendChild(B)}else g.AMapUI===a.loaded?p.version&&p.version!==c.AMapUI.version?d("不允许多个版本 AMapUI 混用"):f.length?window.AMapUI.loadUI(f,function(){for(var w=0,U=f.length;w<U;w++){var q=f[w].split("/").slice(-1)[0];window.AMapUI[q]=arguments[w]}y()}):y():p.version&&p.version!==c.AMapUI.version?d("不允许多个版本 AMapUI 混用"):A.AMapUI.push(function(w){w?d(w):f.length?window.AMapUI.loadUI(f,function(){for(var U=0,q=f.length;U<q;U++){var K=f[U].split("/").slice(-1)[0];window.AMapUI[K]=arguments[U]}y()}):y()})})}function l(p){return new Promise(function(y,d){if(g.Loca===a.failed)d("前次请求 Loca 失败");else if(g.Loca===a.notload){g.Loca=a.loading,c.Loca.version=p.version||c.Loca.version;var f=c.Loca.version,C=c.AMap.version.startsWith("2"),L=f.startsWith("2");if(C&&!L||!C&&L)d("JSAPI 与 Loca 版本不对应!!");else{C=c.key,L=document.body||document.head;var B=document.createElement("script");B.type="text/javascript",B.src="https://webapi.amap.com/loca?v="+f+"&key="+C,B.onerror=function(w){g.Loca=a.failed,d("请求 AMapUI 失败")},B.onload=function(){for(g.Loca=a.loaded,y();A.Loca.length;)A.Loca.splice(0,1)[0]()},L.appendChild(B)}}else g.Loca===a.loaded?p.version&&p.version!==c.Loca.version?d("不允许多个版本 Loca 混用"):y():p.version&&p.version!==c.Loca.version?d("不允许多个版本 Loca 混用"):A.Loca.push(function(w){w?d(w):d()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var a;(function(p){p.notload="notload",p.loading="loading",p.loaded="loaded",p.failed="failed"})(a||(a={}));var c={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},g={AMap:a.notload,AMapUI:a.notload,Loca:a.notload},A={AMap:[],AMapUI:[],Loca:[]},v=[],b=function(p){typeof p=="function"&&(g.AMap===a.loaded?p(window.AMap):v.push(p))};return{load:function(p){return new Promise(function(y,d){if(g.AMap==a.failed)d("");else if(g.AMap==a.notload){var f=p.key,C=p.version,L=p.plugins;f?(window.AMap&&location.host!=="lbs.amap.com"&&d("禁止多种API加载方式混用"),c.key=f,c.AMap.version=C||c.AMap.version,c.AMap.plugins=L||c.AMap.plugins,g.AMap=a.loading,C=document.body||document.head,window.___onAPILoaded=function(w){if(delete window.___onAPILoaded,w)g.AMap=a.failed,d(w);else for(g.AMap=a.loaded,t(p).then(function(){y(window.AMap)}).catch(d);v.length;)v.splice(0,1)[0]()},L=document.createElement("script"),L.type="text/javascript",L.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+c.AMap.version+"&key="+f+"&plugin="+c.AMap.plugins.join(","),L.onerror=function(w){g.AMap=a.failed,d(w)},C.appendChild(L)):d("请填写key")}else if(g.AMap==a.loaded)if(p.key&&p.key!==c.key)d("多个不一致的 key");else if(p.version&&p.version!==c.AMap.version)d("不允许多个版本 JSAPI 混用");else{if(f=[],p.plugins)for(C=0;C<p.plugins.length;C+=1)c.AMap.plugins.indexOf(p.plugins[C])==-1&&f.push(p.plugins[C]);f.length?window.AMap.plugin(f,function(){t(p).then(function(){y(window.AMap)}).catch(d)}):t(p).then(function(){y(window.AMap)}).catch(d)}else if(p.key&&p.key!==c.key)d("多个不一致的 key");else if(p.version&&p.version!==c.AMap.version)d("不允许多个版本 JSAPI 混用");else{var B=[];if(p.plugins)for(C=0;C<p.plugins.length;C+=1)c.AMap.plugins.indexOf(p.plugins[C])==-1&&B.push(p.plugins[C]);b(function(){B.length?window.AMap.plugin(B,function(){t(p).then(function(){y(window.AMap)}).catch(d)}):t(p).then(function(){y(window.AMap)}).catch(d)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,c={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},g={AMap:a.notload,AMapUI:a.notload,Loca:a.notload},A={AMap:[],AMapUI:[],Loca:[]}}}})})(Be);var st=Be.exports;const Ue=nt(st),Ke="map-configuration",we=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Pe=e=>{const o=h.useMemo(()=>{const n=sessionStorage.getItem(we(e));return n&&JSON.parse(n)},[e]),{data:t}=r.useRequest({resource:Ke,action:"get",params:{type:e}},{onSuccess(n){sessionStorage.setItem(we(e),JSON.stringify(n==null?void 0:n.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Ne=()=>{var b,p;const e=r.useDataBlockHeight(),{token:o}=x.theme.useToken(),{designable:t}=r.useDesignable(),{heightProps:n}=r.useBlockHeightProps()||{},{title:l}=n||{},a=z.useFieldSchema();if(!e)return;const c=Object.keys(((p=(b=a.parent)==null?void 0:b.properties.actions)==null?void 0:p.properties)||{}).length>0,g=t||c?o.paddingLG+o.controlHeight+o.margin:o.paddingLG+o.margin,A=o.paddingLG,v=l?o.fontSizeLG*o.lineHeightLG+o.padding*2-1:0;return e-g-A-v},it=e=>{const{aMap:o,toCenter:t}=e,{t:n}=Y(),l=h.useRef(),[a,c]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{l.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:g}=G.useDebounceFn(v=>{l.current&&l.current.search(v||" ",(b,p)=>{if(b==="complete")c(p.poiList.pois.map(y=>W(O({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(b==="no_data"){c([]);return}x.message.error(n("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),A=v=>{const b=a.find(p=>p.value===v);b!=null&&b.location&&t(b.location)};return i.jsx("div",{className:r.css`
11
+ position: absolute;
12
+ top: 10px;
13
+ left: 10px;
14
+ z-index: 10;
15
+ width: calc(100% - 20px);
16
+ `,children:i.jsx(x.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:n("Enter keywords to search"),filterOption:!1,onSearch:g,onSelect:A,options:a,popupMatchSelectWidth:!1})})},Ie={point:{mouseTool:"marker",propertyKey:"position",overlay:"Marker"},polygon:{mouseTool:"polygon",editor:"PolygonEditor",propertyKey:"path",overlay:"Polygon"},lineString:{mouseTool:"polyline",editor:"PolylineEditor",propertyKey:"path",overlay:"Polyline"},circle:{mouseTool:"circle",editor:"CircleEditor",transformOptions(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},ke=h.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:n}=Pe(e.mapType)||{},{value:l,onChange:a,block:c=!1,readonly:g,disabled:A=c,zoom:v=13,overlayCommonOptions:b}=e,{t:p}=Y(),y=z.useFieldSchema(),d=h.useRef(),f=h.useRef(),C=h.useRef(),[L,B]=h.useState([]),[w,U]=h.useState(""),{getField:q}=r.useCollection_deprecated(),K=h.useMemo(()=>{if(e.type)return e.type;const s=q(y==null?void 0:y.name);return s==null?void 0:s.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),V=h.useRef(),P=h.useRef(null),Q=r.useNavigateNoUpdate(),J=h.useRef(`nocobase-map-${K||""}-${Date.now().toString(32)}`),{modal:fe}=x.App.useApp(),re=Ne(),[H]=h.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},b));h.useEffect(()=>{f.current&&f.current.setZoom(v)},[v]);const ce=G.useMemoizedFn(()=>{V.current&&V.current.remove()}),$=G.useMemoizedFn(()=>{(!A||c)&&K!=="point"&&P.current&&(P.current.setTarget(V.current),P.current.open())}),ne=G.useMemoizedFn((s,u=!1)=>{let m=null;if(K==="point"){const{lat:M,lng:F}=s.getPosition();m=[F,M]}else if(K==="polygon"||K==="lineString"){if(m=s.getPath().map(M=>[M.lng,M.lat]),m.length<2)return}else if(K==="circle"){const M=s.getCenter(),F=s.getRadius();m=[M.lng,M.lat,F]}u||(ce(),V.current=s,$()),a==null||a(m)}),te=G.useMemoizedFn((s=K)=>{const u=Ie[s];if(u&&"editor"in u&&!P.current)return P.current=new d.current[u.editor](f.current,null,{createOptions:H,editOptions:H,controlPoint:W(O({},H),{strokeWeight:3}),midControlPoint:W(O({},H),{strokeWeight:2,fillColor:"#fff"})}),P.current.on("adjust",function({target:m}){ne(m,!0)}),P.current.on("move",function({target:m}){ne(m,!0)}),P.current}),R=G.useMemoizedFn((s=K)=>{var m;if(!C.current||(m=P.current)!=null&&m.getTarget())return;const u=Ie[s];u&&C.current[u.mouseTool](O({},H))}),se=G.useMemoizedFn((s=K)=>{C.current||(C.current=new d.current.MouseTool(f.current),C.current.on("draw",function({obj:u}){ne(u)}),R(s))}),I=(s,u)=>{f.current&&f.current.setZoomAndCenter(18,s,u)},_=()=>{const s=()=>{ce(),P.current&&(P.current.setTarget(),P.current.close()),a==null||a(null)};fe.confirm({title:p("Clear the canvas"),content:p("Are you sure to clear the canvas?"),okText:p("Confirm"),cancelText:p("Cancel"),getContainer:()=>document.getElementById(J.current),onOk(){s()}})},N=()=>{V.current&&f.current.setFitView([V.current])},Z=h.useCallback((s=K,u=l,m)=>{const M=Ie[s];if(!M)return;const F=O(O({},H),m);return"transformOptions"in M?Object.assign(F,M.transformOptions(u)):"propertyKey"in M&&(F[M.propertyKey]=u),new d.current[M.overlay](F)},[H]),S=(s=K,u=l,m)=>{if(!d.current)return;const M=Z(s,u,m);return M.setMap(f.current),M};h.useEffect(()=>{if(!d.current||!l||!g&&V.current)return;const s=S();f.current.setFitView([s]),V.current=s,A||(te(),$())},[l,L,K,H,A,g]),h.useEffect(()=>{var s,u,m;C.current&&(A?((s=C.current)==null||s.close(),(u=P.current)==null||u.close()):(R(),(m=P.current)==null||m.open()))},[A]),h.useEffect(()=>{!d.current||!K||A||(se(),te())},[A,L,K]),h.useEffect(()=>{var u,m;if(!l&&(C.current||P.current)&&(ce(),P.current&&(P.current.setTarget(),P.current.close()),a==null||a(null)),!C.current||!P.current)return;P.current.getTarget()?(m=(u=C.current).close)==null||m.call(u):R()},[K,l]),h.useEffect(()=>{if(!t||f.current)return;n&&(window._AMapSecurityConfig={[n.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:n});const s=window.define;if(window.define=void 0,window.AMap)try{requestIdleCallback(()=>{f.current=new AMap.Map(J.current,{resizeEnable:!0,zoom:v}),d.current=AMap,U(""),B([])});return}catch(u){U(u)}return Ue.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(u=>(window.define=s,requestIdleCallback(()=>{f.current=new u.Map(J.current,{resizeEnable:!0,zoom:v}),d.current=u,U(""),B([])}))).catch(u=>{typeof u=="string"?u.includes("多个不一致的 key")?U(p("The AccessKey is incorrect, please check it")):U(u):(u==null?void 0:u.type)==="error"&&U("Something went wrong, please refresh the page and try again")}),()=>{var u;(u=f.current)==null||u.destroy(),d.current=null,f.current=null,C.current=null,P.current=null,Ue.reset()}},[t,K,n]),h.useImperativeHandle(o,()=>({setOverlay:S,getOverlay:Z,createMouseTool:se,createEditor:te,executeMouseTool:R,aMap:d.current,map:f.current,overlay:V.current,mouseTool:()=>C.current,editor:()=>P.current,errMessage:w}));const T=r.useApp();return!t||w?i.jsx(x.Alert,{action:i.jsx(x.Button,{type:"primary",onClick:()=>Q(T.pluginSettingsManager.getRoutePath("map")),children:p("Go to the configuration page")}),message:w||p("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):i.jsxs("div",{className:r.css`
17
+ position: relative;
18
+ height: ${re||500}px !important;
19
+ `,id:J.current,style:e==null?void 0:e.style,children:[!d.current&&i.jsx("div",{className:r.css`
20
+ position: absolute;
21
+ inset: 0;
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: center;
25
+ `,children:i.jsx(x.Spin,{})}),A?null:i.jsxs(i.Fragment,{children:[i.jsx(it,{toCenter:I,aMap:d.current}),i.jsx("div",{className:r.css`
26
+ position: absolute;
27
+ bottom: 80px;
28
+ right: 20px;
29
+ z-index: 10;
30
+ `,children:i.jsx(x.Button,{onClick:N,disabled:!V.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),K!=="point"?i.jsx("div",{className:r.css`
31
+ position: absolute;
32
+ bottom: 20px;
33
+ left: 10px;
34
+ z-index: 2;
35
+ pointer-events: none;
36
+ `,children:i.jsx(x.Alert,{message:p("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,i.jsx("div",{className:r.css`
37
+ position: absolute;
38
+ bottom: 20px;
39
+ right: 20px;
40
+ z-index: 2;
41
+ `,children:i.jsx(x.Button,{disabled:!l,style:{height:"40px"},onClick:_,type:"primary",danger:!0,children:p("Clear")})})]})]})});ke.displayName="AMapComponent";const at=e=>{var se,I,_,N,Z;const{collectionField:o,fieldNames:t,dataSource:n,fixedBlock:l,zoom:a,setSelectedRecordKeys:c,lineSort:g}=r.useProps(e),{name:A,getPrimaryKey:v}=r.useCollection_deprecated(),{getCollectionJoinField:b}=r.useCollectionManager_deprecated(),p=v(),[y,d]=h.useState(!1),f=h.useRef(),C=(I=(se=f.current)==null?void 0:se.aMap)==null?void 0:I.GeometryUtil,[L,B]=h.useState(),[w,U]=h.useState(""),{t:q}=Y(),K=r.useCompile(),{isConnected:V,doFilter:P}=r.useFilterAPI(),[,Q]=h.useState(null),J=h.useRef(w);J.current=w;const{fields:fe}=r.useCollection(),re=r.useCollectionParentRecordData(),{openPopup:H}=r.usePopupUtils(),ce=(_=fe.find(S=>S.name===(t==null?void 0:t.marker)))==null?void 0:_.uiSchema,$=(S,T)=>{const s=S.getExtData(),u=typeof T=="undefined"?s.selected:!T;s.selected=!u,"setIcon"in S&&S.setIcon(new f.current.aMap.Icon({imageSize:[19,32],image:u?ge:Se})),S.setOptions(O({extData:s},u?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},ne=()=>{var S,T,s;f.current&&((S=f.current)==null||S.mouseTool().close(!0),(T=f.current)==null||T.editor().setTarget(null),(s=f.current)==null||s.editor().close())};h.useEffect(()=>{var S,T,s,u;if(w==="selection")return(S=f.current)!=null&&S.editor()?(u=f.current)==null||u.executeMouseTool("polygon"):((T=f.current)==null||T.createEditor("polygon"),(s=f.current)==null||s.createMouseTool("polygon")),()=>{ne()}},[w]),h.useEffect(()=>{if(w)return()=>{var S;J.current||(S=f.current)==null||S.map.getAllOverlays().forEach(T=>{$(T,!1)})}},[w]);const te=G.useMemoizedFn(()=>{var m,M,F;const S=(m=f.current)==null?void 0:m.editor().getTarget(),T=(M=f.current)==null?void 0:M.map.getAllOverlays(),s=T==null?void 0:T.filter(k=>{if(!(k===S||k.getExtData().id===void 0))return"getPosition"in k?C.isPointInRing(k.getPosition(),S==null?void 0:S.getPath()):C.doesRingRingIntersect(k.getPath(),S==null?void 0:S.getPath())}),u=s==null?void 0:s.map(k=>($(k,!0),k.getExtData().id));c(k=>u==null?void 0:u.concat(k)),S==null||S.remove(),(F=f.current)==null||F.editor().close()});h.useEffect(()=>{var m,M,F;if(!o||!f.current||!n)return;const S=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,T=b([A,...S].flat().join(".")),s=n.map(k=>{var pe;const j=(pe=ze(k,t==null?void 0:t.field,T==null?void 0:T.interface))==null?void 0:pe.filter(Boolean),ie=r.getLabelFormatValue(ce,k[t.marker]);return j!=null&&j.length?j.map(ae=>{var oe;return(oe=f.current)==null?void 0:oe.setOverlay(o.type,ae,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?K(ie):void 0},extData:{id:k[p]}})}):[]}).flat().filter(Boolean);(M=(m=f.current)==null?void 0:m.map)==null||M.setFitView(s);const u=s.map(k=>{const j=ie=>{const pe=ie.target,ae=pe.getExtData();if(!ae)return;if(J.current){J.current==="click"&&(c(oe=>ae.selected?oe.filter(Le=>Le!==ae.id):[...oe,ae.id]),$(pe));return}const ye=n.find(oe=>ae.id===oe[p]);if(V){Q(oe=>(oe&&Ge(oe),oe===k?(Ge(k),P(null),null):(lt(k),P(ye[p],Le=>Le.field||p,"$eq"),k)));return}ye&&(B(ye),H({recordData:ye}))};return k.on("click",j),()=>k.off("click",j)});if(o.type==="point"&&(g!=null&&g.length)&&(s==null?void 0:s.length)>1){const k=s.map(ie=>ie.getPosition());s[0].setzIndex(13),s[s.length-1].setzIndex(13);const j=(ie=!0)=>{var pe,ae;if((pe=f.current)!=null&&pe.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:q(ie?"Start point":"End point")},position:k[ie?0:k.length-1],map:(ae=f.current)==null?void 0:ae.map})};s.push(...[(F=f.current)==null?void 0:F.setOverlay("lineString",k,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),j(),j(!1)].filter(Boolean))}return()=>{s.forEach(k=>{k.remove()}),u.forEach(k=>k())}},[n,y,t,A,p,o.type,V,g,H]),h.useEffect(()=>{setTimeout(()=>{c([])})},[n]);const R=S=>{f.current=S,d(!!(S!=null&&S.map)&&!S.errMessage)};return i.jsxs("div",{className:r.css`
42
+ position: relative;
43
+ height: 100%;
44
+ `,children:[i.jsx("div",{className:r.css`
45
+ position: absolute;
46
+ left: 10px;
47
+ top: 10px;
48
+ z-index: 999;
49
+ `,children:y&&!((N=f.current)!=null&&N.errMessage)?i.jsxs(x.Space,{direction:"vertical",children:[i.jsx(x.Button,{style:{color:w?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),U("")},icon:i.jsx(ee.EnvironmentOutlined,{})}),i.jsx(x.Button,{style:{color:w==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),U("selection")},icon:i.jsx(ee.ExpandOutlined,{})}),w==="selection"?i.jsx(x.Button,{type:"primary",icon:i.jsx(ee.CheckOutlined,{}),title:q("Confirm selection"),onClick:te}):null]}):null}),i.jsx(r.RecordProvider,{record:L,parent:re,children:i.jsx(xe,{})}),i.jsx(ke,W(O({},(Z=o==null?void 0:o.uiSchema)==null?void 0:Z["x-component-props"]),{ref:R,style:{height:l?"100%":null},zoom:a,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})};function Ge(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function lt(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const je=({type:e,children:o})=>{const{t}=Y(),[n,l]=G.useBoolean(!1),a=r.useAPIClient(),[c]=x.Form.useForm(),g=Pe(e);h.useEffect(()=>{g&&(c.setFieldsValue(g),l.toggle())},[g]);const A=h.useMemo(()=>a.resource(Ke),[a]),v=b=>{A.set(W(O({},b),{type:e})).then(p=>{sessionStorage.removeItem(we(e)),l.toggle(),x.message.success(t("Saved successfully"))}).catch(p=>{x.message.success(t("Saved failed"))})};return i.jsxs(x.Form,{disabled:n,form:c,layout:"vertical",onFinish:v,children:[o,n?i.jsx(x.Button,{disabled:!1,onClick:l.toggle,children:t("Edit")}):i.jsx(x.Form.Item,{children:i.jsx(x.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},ct={amap:()=>{const{t:e}=Y();return i.jsxs(je,{type:"amap",children:[i.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:i.jsx(x.Input,{})}),i.jsx(x.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:i.jsx(x.Input,{})})]})},google:()=>{const{t:e}=Y();return i.jsx(je,{type:"google",children:i.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:i.jsx(x.Input,{})})})}},pt=Te.map(e=>W(O({},e),{component:ct[e.value]})),ut=()=>{const e=r.useCompile(),o=r.useLocationSearch(),t=new URLSearchParams(o);return i.jsx(x.Card,{bordered:!0,children:i.jsx(x.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:pt.map(n=>i.jsx(x.Tabs.TabPane,{tab:e(n.label),children:i.jsx(n.component,{type:n.value})},n.value))})})};/*! *****************************************************************************
50
+ Copyright (c) Microsoft Corporation.
51
+
52
+ Permission to use, copy, modify, and/or distribute this software for any
53
+ purpose with or without fee is hereby granted.
54
+
55
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
56
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
57
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
58
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
59
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
60
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
61
+ PERFORMANCE OF THIS SOFTWARE.
62
+ ***************************************************************************** */function dt(e,o,t,n){function l(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function g(b){try{v(n.next(b))}catch(p){c(p)}}function A(b){try{v(n.throw(b))}catch(p){c(p)}}function v(b){b.done?a(b.value):l(b.value).then(g,A)}v((n=n.apply(e,[])).next())})}var ft=function e(o,t){if(o===t)return!0;if(o&&t&&typeof o=="object"&&typeof t=="object"){if(o.constructor!==t.constructor)return!1;var n,l,a;if(Array.isArray(o)){if(n=o.length,n!=t.length)return!1;for(l=n;l--!==0;)if(!e(o[l],t[l]))return!1;return!0}if(o.constructor===RegExp)return o.source===t.source&&o.flags===t.flags;if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===t.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===t.toString();if(a=Object.keys(o),n=a.length,n!==Object.keys(t).length)return!1;for(l=n;l--!==0;)if(!Object.prototype.hasOwnProperty.call(t,a[l]))return!1;for(l=n;l--!==0;){var c=a[l];if(!e(o[c],t[c]))return!1}return!0}return o!==o&&t!==t};const qe="__googleMapsScriptId";var he;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(he||(he={}));class ue{constructor({apiKey:o,authReferrerPolicy:t,channel:n,client:l,id:a=qe,language:c,libraries:g=[],mapIds:A,nonce:v,region:b,retries:p=3,url:y="https://maps.googleapis.com/maps/api/js",version:d}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=n,this.client=l,this.id=a||qe,this.language=c,this.libraries=g,this.mapIds=A,this.nonce=v,this.region=b,this.retries=p,this.url=y,this.version=d,ue.instance){if(!ft(this.options,ue.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ue.instance.options)}`);return ue.instance}ue.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?he.FAILURE:this.done?he.SUCCESS:this.loading?he.LOADING:he.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let o=this.url;return o+="?callback=__googleMapsCallback",this.apiKey&&(o+=`&key=${this.apiKey}`),this.channel&&(o+=`&channel=${this.channel}`),this.client&&(o+=`&client=${this.client}`),this.libraries.length>0&&(o+=`&libraries=${this.libraries.join(",")}`),this.language&&(o+=`&language=${this.language}`),this.region&&(o+=`&region=${this.region}`),this.version&&(o+=`&v=${this.version}`),this.mapIds&&(o+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(o+=`&auth_referrer_policy=${this.authReferrerPolicy}`),o}deleteScript(){const o=document.getElementById(this.id);o&&o.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((o,t)=>{this.loadCallback(n=>{n?t(n.error):o(window.google)})})}importLibrary(o){return this.execute(),google.maps.importLibrary(o)}loadCallback(o){this.callbacks.push(o),this.execute()}setScript(){var o,t;if(document.getElementById(this.id)){this.callback();return}const n={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(n).forEach(a=>!n[a]&&delete n[a]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(a=>{let c,g,A,v="The Google Maps JavaScript API",b="google",p="importLibrary",y="__ib__",d=document,f=window;f=f[b]||(f[b]={});const C=f.maps||(f.maps={}),L=new Set,B=new URLSearchParams,w=()=>c||(c=new Promise((U,q)=>dt(this,void 0,void 0,function*(){var K;yield g=d.createElement("script"),g.id=this.id,B.set("libraries",[...L]+"");for(A in a)B.set(A.replace(/[A-Z]/g,V=>"_"+V[0].toLowerCase()),a[A]);B.set("callback",b+".maps."+y),g.src=this.url+"?"+B,C[y]=U,g.onerror=()=>c=q(Error(v+" could not load.")),g.nonce=this.nonce||((K=d.querySelector("script[nonce]"))===null||K===void 0?void 0:K.nonce)||"",d.head.append(g)})));C[p]?console.warn(v+" only loads once. Ignoring:",a):C[p]=(U,...q)=>L.add(U)&&w().then(()=>C[p](U,...q))})(n);const l=this.libraries.map(a=>this.importLibrary(a));l.length||l.push(this.importLibrary("core")),Promise.all(l).then(()=>this.callback(),a=>{const c=new ErrorEvent("error",{error:a});this.loadErrorCallback(c)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(o){if(this.errors.push(o),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=o,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(o=>{o(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setScript())}}}const mt=e=>{const{toCenter:o,mapRef:t}=e,{t:n}=Y(),l=h.useRef(),[a,c]=h.useState([]);h.useEffect(()=>{google.maps.importLibrary("places").then(v=>{l.current=new v.AutocompleteService}).catch(()=>{x.message.error("Please configure the Google API Key correctly")})},[t]);const{run:g}=G.useDebounceFn(v=>{l.current&&l.current.getPlacePredictions({input:v||" "},(b,p)=>{if(p===google.maps.places.PlacesServiceStatus.OK)c(b.map(y=>{const d=y.structured_formatting;return W(O({},y),{label:`${d.main_text}${d.secondary_text?" "+d.secondary_text:""}`,value:y.place_id})}));else{c([]);return}})},{wait:300}),A=v=>{const b=a.find(y=>y.value===v);new google.maps.places.PlacesService(t.current).getDetails({placeId:b.place_id,fields:["geometry"]},(y,d)=>{d===google.maps.places.PlacesServiceStatus.OK&&o(y.geometry.location)})};return i.jsx("div",{className:r.css`
63
+ position: absolute;
64
+ top: 10px;
65
+ left: 10px;
66
+ z-index: 10;
67
+ width: calc(100% - 20px);
68
+ `,children:i.jsx(x.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:n("Enter keywords to search"),filterOption:!1,onSearch:g,onSelect:A,options:a})})},de=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),gt=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:n,longitude:l}=t.coords;e({lat:n,lng:l})},()=>{o()},{timeout:2e3,maximumAge:0}):o()}),ht=e=>e==="point"?"marker":e==="lineString"?"polyline":e,yt={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},Fe=h.forwardRef((e,o)=>{const{value:t,onChange:n,block:l=!1,readonly:a,disabled:c=l,zoom:g=13,overlayCommonOptions:A}=e,{accessKey:v}=Pe(e.mapType)||{},{t:b}=Y(),{getField:p}=r.useCollection_deprecated(),y=z.useFieldSchema(),d=h.useRef(),f=h.useRef(),C=h.useRef(),[L,B]=h.useState([]),[w,U]=h.useState(""),q=r.useAPIClient(),{modal:K}=x.App.useApp(),V=Ne();h.useEffect(()=>{f.current&&f.current.setZoom(g)},[g]);const P=h.useMemo(()=>{if(e.type)return e.type;const s=p(y==null?void 0:y.name);return s==null?void 0:s.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),Q=h.useRef(ht(P)),[J]=h.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!c,draggable:!c},A)),fe=r.useNavigateNoUpdate(),re=h.useRef(),H=h.useRef(new Set),ce=G.useMemoizedFn(s=>{if(H.current.forEach(u=>{H.current.delete(u)}),"getPath"in s){const u=s.getPath();["insert_at","remove_at","set_at"].forEach(m=>{H.current.add(u.addListener(m,()=>{I(s,!0)}).remove)})}else s instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(u=>{H.current.add(s.addListener(u,()=>{I(s,!0)}).remove)})}),$=G.useMemoizedFn(()=>{var s;C.current&&(C.current.unbindAll(),C.current.setMap(null)),P!=="point"&&((s=d.current)==null||s.setDrawingMode(null))}),ne=G.useMemoizedFn(s=>{var u,m;f.current&&s&&((u=f.current)==null||u.setCenter(s),(m=f.current)==null||m.setZoom(g))}),te=G.useMemoizedFn(s=>{$(),ce(s),C.current=s}),R=G.useMemoizedFn(s=>{var m,M;const u=new google.maps.LatLngBounds;s.forEach(F=>{if(F instanceof google.maps.Marker)u.extend(F.getPosition());else if(F instanceof google.maps.Polyline||F instanceof google.maps.Polygon){const k=F.getPath();for(let j=0;j<k.getLength();j++)u.extend(k.getAt(j))}else F instanceof google.maps.Circle&&u.union(F.getBounds())}),(M=(m=f.current)==null?void 0:m.setCenter)==null||M.call(m,u.getCenter())}),se=()=>{C.current&&R([C.current])},I=G.useMemoizedFn((s,u=!1)=>{let m=null;if(P==="point"){const{lat:M,lng:F}=s.getPosition();m=[F(),M()]}else if(P==="polygon"||P==="lineString"){if(m=s.getPath().getArray().map(M=>[M.lng(),M.lat()]),m.length<2)return}else if(P==="circle"){const M=s.getCenter(),F=s.getRadius();m=[M.lng(),M.lat(),F]}u||te(s),n==null||n(m)}),_=G.useMemoizedFn((s=!1,u)=>{const m=W(O(O({},J),u),{map:f.current});return d.current=new google.maps.drawing.DrawingManager({drawingMode:Q.current,drawingControl:!1,markerOptions:W(O({},m),{icon:de(ge)}),polygonOptions:m,polylineOptions:m,circleOptions:m,map:f.current}),s||d.current.addListener("overlaycomplete",M=>{const F=M.overlay;I(F)}),d.current}),N=G.useMemoizedFn((s=P,u=t,m)=>{const M=yt[s];if(!M)return;const F=O(W(O({},J),{icon:de(ge)}),m);return"transformOptions"in M?Object.assign(F,M.transformOptions(u)):"propertyKey"in M&&(F[M.propertyKey]=Array.isArray(u[0])?u.map(j=>new google.maps.LatLng(j[1],j[0])):new google.maps.LatLng(u[1],u[0])),new google.maps[M.overlay](F)}),Z=G.useMemoizedFn((s=P,u=t,m)=>f.current?N(s,u,W(O({},m),{map:f.current})):void 0);h.useEffect(()=>{var u,m;if(!t&&f.current&&($(),(m=(u=d==null?void 0:d.current)==null?void 0:u.setDrawingMode)==null||m.call(u,Q.current),n==null||n(null)),!f.current||!t||!a&&C.current)return;const s=Z();te(s),R([s])},[t,L,P,c,a,Z,R,te]),h.useEffect(()=>{if(!v||f.current||!re.current)return;let s;try{s=new ue({apiKey:v,version:"weekly",language:q.auth.getLocale()})}catch(m){U(b("Load google maps failed, Please check the Api key and refresh the page"));return}const u=console.error;return console.error=(m,...M)=>{m!=null&&m.includes("InvalidKeyMapError")&&U(b("Load google maps failed, Please check the Api key and refresh the page")),u(m,...M)},Promise.all([s.importLibrary("drawing"),s.importLibrary("core"),s.importLibrary("geometry")]).then(m=>Ce(this,null,function*(){const M=yield gt();f.current=new google.maps.Map(re.current,{zoom:g,center:M,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),U(""),B([])})).catch(m=>{if(m instanceof Error){U(m.message);return}}),()=>{var m,M;(m=f.current)==null||m.unbindAll(),f.current=null,(M=d.current)==null||M.unbindAll()}},[v,q.auth,P,g]),h.useEffect(()=>{!f.current||!P||c||d.current||_()},[_,c,L,P]),h.useImperativeHandle(o,()=>({setOverlay:Z,getOverlay:N,setFitView:R,createDraw:_,map:f.current,overlay:C.current,drawingManager:d.current,errMessage:w}));const S=G.useMemoizedFn(()=>{const s=()=>{$(),d.current.setDrawingMode(Q.current),n==null||n(null)};K.confirm({title:b("Clear the canvas"),content:b("Are you sure to clear the canvas?"),okText:b("Confirm"),cancelText:b("Cancel"),getContainer:()=>re.current,onOk(){s()}})}),T=r.useApp();return!v||w?i.jsx(x.Alert,{action:i.jsx(x.Button,{type:"primary",onClick:()=>fe(T.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:b("Go to the configuration page")}),message:w||b("Please configure the Api key first"),type:"error"}):i.jsxs("div",{className:r.css`
69
+ position: relative;
70
+ height: ${V||500}px !important;
71
+ `,children:[!f.current&&i.jsx("div",{className:r.css`
72
+ position: absolute;
73
+ inset: 0;
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ `,children:i.jsx(x.Spin,{})}),c?null:i.jsxs(i.Fragment,{children:[f.current&&i.jsx(mt,{toCenter:ne,mapRef:f}),i.jsx("div",{className:r.css`
78
+ position: absolute;
79
+ bottom: 80px;
80
+ right: 20px;
81
+ z-index: 10;
82
+ `,children:i.jsx(x.Button,{onClick:se,disabled:!C.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),P==="lineString"||P==="polygon"?i.jsx("div",{className:r.css`
83
+ position: absolute;
84
+ bottom: 20px;
85
+ left: 10px;
86
+ z-index: 2;
87
+ pointer-events: none;
88
+ `,children:i.jsx(x.Alert,{message:b("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,i.jsx("div",{className:r.css`
89
+ position: absolute;
90
+ bottom: 20px;
91
+ right: 20px;
92
+ z-index: 2;
93
+ `,children:i.jsx(x.Button,{disabled:!t,style:{height:"40px"},onClick:S,type:"primary",danger:!0,children:b("Clear")})})]}),i.jsx("div",{ref:re,className:r.css`
94
+ width: 100%;
95
+ height: 100%;
96
+ `,style:e==null?void 0:e.style})]})});Fe.displayName="GoogleMapsComponent";const Me="google-maps-overlay-id",_e="google-maps-overlay-selected",bt=r.css`
97
+ margin-top: 6px;
98
+ padding: 2px 4px;
99
+ background: #fff;
100
+ border: 1px solid #0000f5;
101
+ `,Mt=r.css`
102
+ margin-top: -64px;
103
+ padding: 2px 4px;
104
+ background: #fff;
105
+ border: 1px solid #0000f5;
106
+ `,At=e=>{var se;const{collectionField:o,fieldNames:t,dataSource:n,fixedBlock:l,zoom:a,setSelectedRecordKeys:c,lineSort:g}=r.useProps(e),{getPrimaryKey:A}=r.useCollection_deprecated(),v=A(),{marker:b="id"}=t,[p,y]=h.useState(!1),d=h.useRef(),[f,C]=h.useState(),[L,B]=h.useState(""),{t:w}=Y(),U=r.useCompile(),{isConnected:q,doFilter:K}=r.useFilterAPI(),[,V]=h.useState(null),P=h.useRef(L),Q=h.useRef(null),J=h.useRef([]);P.current=L;const{fields:fe}=r.useCollection(),re=r.useCollectionParentRecordData(),H=(se=fe.find(I=>I.name===(t==null?void 0:t.marker)))==null?void 0:se.uiSchema,{getCollectionJoinField:ce}=r.useCollectionManager_deprecated(),{openPopup:$}=r.usePopupUtils(),ne=(I,_)=>{const N=typeof _!="undefined"?!_:I.get(_e);I.set(_e,!N),I.setOptions(O({},N?{icon:de(ge),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:de(Se),strokeColor:"#F18b62",fillColor:"#F18b62"}))};h.useEffect(()=>{var _,N,Z,S;if(L!=="selection")return;d.current&&!((_=d.current)!=null&&_.drawingManager)&&(d.current.drawingManager=(N=d.current)==null?void 0:N.createDraw(!0,{editable:!0,draggable:!0}));const I=new Set;return(Z=d.current)==null||Z.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=d.current)==null||S.drawingManager.addListener("overlaycomplete",T=>{var m;const s=T.overlay;(m=d.current)==null||m.drawingManager.setDrawingMode(null),Q.current=s;const u=s.getPath();["insert_at","remove_at","set_at"].forEach(M=>{I.add(u.addListener(M,()=>{}).remove)})}),()=>{var T,s,u,m;I.forEach(M=>{M()}),d.current&&((T=Q.current)==null||T.unbindAll(),(s=Q.current)==null||s.setMap(null),Q.current=null,(u=d.current)==null||u.drawingManager.setDrawingMode(null),(m=d.current)==null||m.drawingManager.unbindAll())}},[L]),h.useEffect(()=>{if(L)return()=>{P.current||J.current.forEach(I=>{ne(I,!1)})}},[L]);const te=G.useMemoizedFn(()=>{var T;const I=Q.current,_=J.current,N=google.maps.geometry.poly,S=_.filter(s=>{if(!(s===I||s.get(Me)===void 0))return s instanceof google.maps.Marker?N.containsLocation(s.getPosition(),I):s instanceof google.maps.Circle?N.containsLocation(s.getCenter(),I):s.getPath().getArray().some(u=>N.containsLocation(u,I))}).map(s=>(ne(s,!0),s.get(Me)));c(s=>S.concat(s)),I==null||I.unbindAll(),I==null||I.setMap(null),(T=d.current)==null||T.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});h.useEffect(()=>{var S,T;if(!o||!(n!=null&&n.length)||!((S=d.current)!=null&&S.map))return;const I=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,_=ce([name,...I].flat().join(".")),N=n.map(s=>{const u=ze(s,t==null?void 0:t.field,_==null?void 0:_.interface),m=r.getLabelFormatValue(H,s[t.marker]);return u!=null&&u.length?u==null?void 0:u.filter(Boolean).map(M=>{var k;if(!u)return;const F=(k=d.current)==null?void 0:k.setOverlay(o.type,M,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:bt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?U(m):void 0}});return F==null||F.set(Me,s[v]),F}):[]}).flat().filter(Boolean);J.current=N;const Z=N.map(s=>{const u=m=>{const M=s,F=M.get(Me);if(!F)return;const k=n==null?void 0:n.find(j=>F===j[v]);if(q){V(j=>(j&&Ve(M),j===s?(Ve(M),K(null),null):(vt(M),K(k[v],ie=>ie.field||v,"$eq"),M)));return}k&&(C(k),$({recordData:k}))};return s.addListener("click",u),()=>s.unbindAll()});if(o.type==="point"&&(g!=null&&g.length)&&(N==null?void 0:N.length)>1){const s=N.map(m=>m.getPosition());N[0].setZIndex(138),N[N.length-1].setZIndex(138);const u=(m=!0)=>{var M;if((M=d.current)!=null&&M.map)return new google.maps.Marker({label:{className:Mt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:w(m?"Start point":"End point")},icon:de(ge),position:m?s[0]:s[s.length-1],map:d.current.map})};N.push(...[d.current.setOverlay("lineString",s.map(m=>[m.lng(),m.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),u(),u(!1)].filter(Boolean))}return(T=d.current)==null||T.setFitView(N),()=>{N.forEach(s=>{s.setMap(null),s.unbindAll()}),Z.forEach(s=>s())}},[n,p,b,o.type,q,$]),h.useEffect(()=>{setTimeout(()=>{c([])})},[n]);const R=I=>{d.current=I,y(!!(I!=null&&I.map)&&!I.errMessage)};return i.jsxs("div",{className:r.css`
107
+ position: relative;
108
+ height: 100%;
109
+ `,children:[p&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:r.css`
110
+ position: absolute;
111
+ left: 10px;
112
+ top: 10px;
113
+ z-index: 999;
114
+ `,children:i.jsxs(x.Space,{direction:"vertical",children:[i.jsx(x.Button,{style:{color:L?void 0:"#F18b62",borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),B("")},icon:i.jsx(ee.EnvironmentOutlined,{})}),i.jsx(x.Button,{style:{color:L==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),B("selection")},icon:i.jsx(ee.ExpandOutlined,{})}),L==="selection"?i.jsx(x.Button,{type:"primary",icon:i.jsx(ee.CheckOutlined,{}),title:w("Confirm selection"),onClick:te}):null]})}),i.jsx(r.RecordProvider,{record:f,parent:re,children:i.jsx(xe,{})})]}),i.jsx(Fe,W(O({},e),{ref:R,style:{height:l?"100%":null},zoom:a,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})};function Ve(e){if(e instanceof google.maps.Marker)return e.setIcon(de(ge));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function vt(e){if(e instanceof google.maps.Marker)return e.setIcon(de(Se));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const Ct=()=>{var p;const{getCollectionJoinField:e}=r.useCollectionManager_deprecated(),{getField:o}=r.useCollection_deprecated(),{form:t}=r.useFormBlockContext(),n=z.useField(),l=z.useFieldSchema(),{t:a}=Y(),{dn:c,refresh:g}=r.useDesignable(),A=o(l.name)||e(l["x-collection-field"]),v=(p=A==null?void 0:A.uiSchema)==null?void 0:p.title;n.title===v||n.title,n.readPretty||n.required;let b="editable";return l["x-disabled"]===!0&&(b="readonly"),l["x-read-pretty"]===!0&&(b="read-pretty"),i.jsxs(r.GeneralSchemaDesigner,{children:[i.jsx(r.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!r.isPatternDisabled(l)&&i.jsx(r.SchemaSettingsSelectItem,{title:a("Pattern"),options:[{label:a("Editable"),value:"editable"},{label:a("Readonly"),value:"readonly"},{label:a("Easy-reading"),value:"read-pretty"}],value:b,onChange:y=>{const d={"x-uid":l["x-uid"]};switch(y){case"readonly":{l["x-read-pretty"]=!1,l["x-disabled"]=!0,d["x-read-pretty"]=!1,d["x-disabled"]=!0,n.readPretty=!1,n.disabled=!0;break}case"read-pretty":{l["x-read-pretty"]=!0,l["x-disabled"]=!1,d["x-read-pretty"]=!0,d["x-disabled"]=!1,n.readPretty=!0;break}default:{l["x-read-pretty"]=!1,l["x-disabled"]=!1,d["x-read-pretty"]=!1,d["x-disabled"]=!1,n.readPretty=!1,n.disabled=!1;break}}c.emit("patch",{schema:d}),c.refresh()}},"pattern"),i.jsx(r.SchemaSettingsModalItem,{title:a("Set default zoom level"),schema:{type:"object",title:a("Set default zoom level"),properties:{zoom:{title:a("Zoom"),default:n.componentProps.zoom||13,description:a("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(me.set(l,"x-component-props.zoom",y),Object.assign(n.componentProps,l["x-component-props"]),c.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":n.componentProps}})),c.refresh()}},"map-zoom"),i.jsx(r.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:a("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},St={amap:ke,google:Fe},Oe=h.forwardRef((e,o)=>{const{t}=Y(),{mapType:n}=e,l=h.useMemo(()=>St[n],[n]);return l?i.jsx(l,O({ref:o},e)):i.jsx("div",{children:t(`The ${n} cannot found`)})});Oe.displayName="MapComponent";const xt=e=>{var A,v;const{value:o}=e,t=z.useFieldSchema(),l=r.useCollection().getField(t.name),a=e.mapType||((A=l==null?void 0:l.uiSchema["x-component-props"])==null?void 0:A.mapType),c=z.useForm(),g=z.useField();return r.useFieldTitle(),!c.readPretty||g.readPretty?i.jsx("div",{children:i.jsx(r.EllipsisWithTooltip,{ellipsis:!0,children:(v=o==null?void 0:o.map)==null?void 0:v.call(o,b=>Array.isArray(b)?`(${b.join(",")})`:b).join(",")})}):i.jsx(Oe,O({readonly:!0,mapType:a},e))},We=z.connect(e=>i.jsx("div",{className:r.css`
115
+ height: 100%;
116
+ border: 1px solid transparent;
117
+ .ant-formily-item-error & {
118
+ border: 1px solid #ff4d4f;
119
+ }
120
+ `,children:i.jsx(Oe,O({},e))}),z.mapReadPretty(xt));We.Designer=Ct;const wt={amap:at,google:At},Pt=e=>{const{t:o}=Y(),{mapType:t}=e,n=h.useMemo(()=>wt[t],[t]);return n?i.jsx(r.PopupContextProvider,{children:i.jsx(n,O({},e))}):i.jsx("div",{children:o(`The ${t} cannot found`)})},It=r.withDynamicSchemaProps(e=>{var g,A;const{context:o}=r.usePopupUtils();if(o.currentLevel&&!me.isNil((g=o.params)==null?void 0:g.filterbytk))return i.jsx(r.PopupContextProvider,{children:i.jsx(xe,{})});const{fieldNames:t}=r.useProps(e),{getCollectionJoinField:n}=r.useCollectionManager_deprecated(),{name:l}=r.useCollection_deprecated(),a=h.useMemo(()=>n([l,t==null?void 0:t.field].flat().join(".")),[l,t==null?void 0:t.field]),c=(A=a==null?void 0:a.uiSchema)==null?void 0:A["x-component-props"];return i.jsx(Pt,W(O(O({},c),e),{collectionField:a}))}),kt=()=>{const{name:e,title:o}=r.useCollection(),t=r.useSchemaTemplate();return i.jsx(r.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ft=e=>{const{collectionName:o,fieldNames:t,dataSource:n}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:n,action:"list",fieldNames:t,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{}},[tt.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}},Ye=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,n,l)=>{const a=t==null?void 0:t.find(c=>c.value===n);return l===e.length-1?a:a==null?void 0:a.children},o)),Ot=()=>{const e=r.useSchemaInitializerItem(),{insert:o}=r.useSchemaInitializer(),t=h.useContext(z.SchemaOptionsContext),{getCollectionFieldsOptions:n}=r.useCollectionManager_deprecated(),{t:l}=Y(),{theme:a}=r.useGlobalTheme();return i.jsx(r.DataBlockInitializer,O({componentType:"Map",icon:i.jsx(ee.TableOutlined,{}),onCreateBlockSchema:g=>Ce(this,[g],function*({item:c}){const A=n(c.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:c.dataSource}),v=n(c.name,"string",{dataSource:c.dataSource}),b=yield r.FormDialog(l("Create map block"),()=>{var p;return i.jsx(r.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:i.jsx(et.FormLayout,{layout:"vertical",children:i.jsx(r.SchemaComponent,{schema:{properties:{field:{title:l("Map field"),enum:A,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:A.length?[A[0].value,(p=A[0].children)==null?void 0:p[0].value].filter(y=>y!=null):[]},marker:{title:l("Marker field"),enum:v,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const d=y.form.values.field;if(!(d!=null&&d.length))return;const f=Ye(d,A);f&&(y.hidden=f.type!=="point")}}}}})})})},a).open({initialValues:{}});o(Ft({collectionName:c.name,dataSource:c.dataSource,fieldNames:O({},b)}))}),title:l("Map block")},e))},Ee=h.createContext({});Ee.displayName="MapBlockContext";const Et=e=>{var v;const{fieldNames:o}=e,t=z.useFieldSchema(),n=z.useField(),{resource:l,service:a}=r.useBlockRequestContext(),[c,g]=h.useState([]),{token:A}=x.theme.useToken();return i.jsx(r.FixedBlockWrapper,{children:i.jsx(r.SchemaComponentOptions,{scope:{selectedRecordKeys:c},children:i.jsxs(Ee.Provider,{value:{field:n,service:a,resource:l,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:c,setSelectedRecordKeys:g},children:[" ",i.jsx("div",{className:ot.css`
121
+ .nb-action-bar {
122
+ margin-bottom: ${A.margin}px;
123
+ }
124
+ `,children:e.children})]})})})},Lt=e=>{const{filter:o,parseVariableLoading:t}=r.useParsedFilter({filterOption:e==null?void 0:e.filter});return{params:W(O({},e),{filter:o}),parseVariableLoading:t}},Dt=e=>{const o=z.useField(),{fieldNames:t}=e,{params:n,parseVariableLoading:l}=Lt(e.params);if(l)return null;const a=n.appends||[],{field:c}=t||{};return Array.isArray(c)&&c.length>1&&a.push(c[0]),i.jsx(r.BlockProvider,W(O({name:"map"},e),{runWhenParamsChanged:!0,params:W(O({},n),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:i.jsx(Et,O({},e))}))},Ae=()=>h.useContext(Ee),He=()=>{var o,t,n,l,a,c;const e=Ae();return W(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((l=(n=e==null?void 0:e.field)==null?void 0:n.componentProps)==null?void 0:l.zoom)||13,lineSort:(c=(a=e==null?void 0:e.field)==null?void 0:a.componentProps)==null?void 0:c.lineSort})},Tt=e=>i.jsx(r.SchemaComponentOptions,{scope:{useMapBlockProps:He},components:{MapBlockInitializer:Ot,MapBlockDesigner:kt,MapBlockProvider:Dt,MapBlock:It},children:e.children}),Je={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>r.useActionAvailable("create")},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},Ze=new r.CompatibleSchemaInitializer(O({name:"MapActionInitializers"},Je)),zt=new r.CompatibleSchemaInitializer(O({name:"map:configureActions"},Je),Ze),Xe={name:"defaultZoomLevel",Component:r.SchemaSettingsModalItem,useComponentProps(){var a;const{t:e}=Y(),o=z.useFieldSchema(),t=z.useField(),{dn:n}=r.useDesignable(),l=((a=o==null?void 0:o["x-component-props"])==null?void 0:a.zoom)||13;return{title:e("The default zoom level of the map"),schema:{type:"object",title:e("Set default zoom level"),properties:{zoom:{title:e("Zoom"),default:l,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:c})=>{me.set(o,"x-component-props.zoom",c),t.componentProps.zoom=c,n.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),n.refresh()}}},useVisible(){const{fieldSchema:e}=r.useColumnSchema();return!e}},Bt=new r.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:r.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:r.SchemaSettingsBlockHeightItem},{name:"mapField",Component:r.SchemaSettingsCascaderItem,useComponentProps(){var v;const{getCollectionFieldsOptions:e}=r.useCollectionManager_deprecated(),{t:o}=Y(),t=z.useFieldSchema(),n=((v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fieldNames)||{},l=z.useField(),{dn:a}=r.useDesignable(),{service:c}=Ae(),{name:g}=r.useCollection(),A=e(g,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:n.field,options:A,allowClear:!1,onChange:b=>{const p=l.decoratorProps.fieldNames||{};p.field=b,l.decoratorProps.fieldNames=p,t["x-decorator-props"].fieldNames=p,c.refresh(),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":l.decoratorProps}}),a.refresh()}}}},{name:"markerField",Component:r.SchemaSettingsSelectItem,useComponentProps(){var v;const{t:e}=Y(),o=z.useFieldSchema(),t=((v=o==null?void 0:o["x-decorator-props"])==null?void 0:v.fieldNames)||{},{service:n}=Ae(),l=z.useField(),{dn:a}=r.useDesignable(),{getCollectionFieldsOptions:c}=r.useCollectionManager_deprecated(),{name:g}=r.useCollection(),A=c(g,"string");return{title:e("Marker field"),value:t.marker,options:A,onChange:b=>{const p=l.decoratorProps.fieldNames||{};p.marker=b,l.decoratorProps.fieldNames=p,o["x-decorator-props"].fieldNames=p,n.refresh(),a.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":l.decoratorProps}}),a.refresh()}}},useVisible(){var c,g;const e=z.useFieldSchema(),{getCollectionFieldsOptions:o}=r.useCollectionManager_deprecated(),{name:t}=r.useCollection(),n=((c=e==null?void 0:e["x-decorator-props"])==null?void 0:c.fieldNames)||{},l=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((g=Ye(n.field,l))==null?void 0:g.type)==="point"}},{name:"setDefaultSortingRules",Component:r.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=Y();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},r.setDataLoadingModeSettingsItem,Xe,{name:"dataScope",Component:r.SchemaSettingsDataScope,useComponentProps(){var c,g;const{name:e}=r.useCollection(),o=z.useFieldSchema(),{form:t}=r.useFormBlockContext(),n=z.useField(),{service:l}=Ae(),{dn:a}=r.useDesignable();return{collectionName:e,defaultFilter:((g=(c=o==null?void 0:o["x-decorator-props"])==null?void 0:c.params)==null?void 0:g.filter)||{},form:t,onSubmit:({filter:A})=>{var b,p;const v=n.decoratorProps.params||{};v.filter=A,n.decoratorProps.params=v,o["x-decorator-props"].params=v,(p=(b=l.params)==null?void 0:b[1])!=null&&p.filters,a.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:r.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=Y();return{type:r.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:r.SchemaSettingsTemplate,useComponentProps(){var l,a;const{name:e}=r.useCollection(),o=z.useFieldSchema(),{componentNamePrefix:t}=r.useBlockTemplateContext(),n=((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.resource)||((a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.association);return{componentName:`${t}Map`,collectionName:e,resourceName:n}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Ut}=r.interfacesProperties;Array.isArray(r.interfacesProperties.type.enum)&&r.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class ve extends r.CollectionFieldInterface{constructor(){super(...arguments);E(this,"properties",W(O({},Ut),{"uiSchema.x-component-props.mapType":{title:X("Map type"),type:"string",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1},"x-disabled":"{{ isOverride || !createOnly }}",default:"amap",enum:Te}}))}schemaInitialize(t,{block:n}){n==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Kt extends ve{constructor(){super(...arguments);E(this,"name","circle");E(this,"type","object");E(this,"group","map");E(this,"order",3);E(this,"title",X("Circle"));E(this,"availableTypes",["circle","json"]);E(this,"description",X("Circle"));E(this,"sortable",!0);E(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Nt extends ve{constructor(){super(...arguments);E(this,"name","lineString");E(this,"type","object");E(this,"group","map");E(this,"order",2);E(this,"title",X("Line"));E(this,"description",X("Line"));E(this,"availableTypes",["lineString","json"]);E(this,"sortable",!0);E(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Gt extends ve{constructor(){super(...arguments);E(this,"name","point");E(this,"type","object");E(this,"group","map");E(this,"order",1);E(this,"title",X("Point"));E(this,"description",X("Point"));E(this,"availableTypes",["point","json"]);E(this,"sortable",!0);E(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class jt extends ve{constructor(){super(...arguments);E(this,"name","polygon");E(this,"type","object");E(this,"group","map");E(this,"order",4);E(this,"title",X("Polygon"));E(this,"description",X("Polygon"));E(this,"availableTypes",["polygon","json"]);E(this,"sortable",!0);E(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const qt=[Gt,jt,Nt,Kt],_t=new r.SchemaSettings({name:"fieldSettings:component:Map",items:[Xe]}),Qe=h.memo(e=>i.jsx(r.SchemaComponentOptions,{components:{Map:We},children:i.jsx(Tt,{children:e.children})}));Qe.displayName="MapProvider";class $e extends r.Plugin{load(){return Ce(this,null,function*(){this.app.use(Qe),this.app.dataSourceManager.addFieldInterfaces(qt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:X("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(Ze),this.app.schemaInitializerManager.add(zt),this.schemaSettingsManager.add(Bt),this.schemaSettingsManager.add(_t);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobile:addBlock","dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(be,{title:`{{t("Map Manager", { ns: "${be}" })}}`,icon:"EnvironmentOutlined",Component:ut,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:He})})}}D.PluginMapClient=$e,D.default=$e,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -8,10 +8,10 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.5.0-alpha.4",
11
+ "@nocobase/client": "1.5.0-beta.1",
12
12
  "react": "18.2.0",
13
- "@nocobase/server": "1.5.0-alpha.4",
14
- "@nocobase/test": "1.5.0-alpha.4",
13
+ "@nocobase/server": "1.5.0-beta.1",
14
+ "@nocobase/test": "1.5.0-beta.1",
15
15
  "@formily/react": "2.3.0",
16
16
  "lodash": "4.17.21",
17
17
  "@ant-design/icons": "5.2.6",
@@ -22,6 +22,6 @@ module.exports = {
22
22
  "ahooks": "3.7.8",
23
23
  "@formily/core": "2.3.0",
24
24
  "react-i18next": "11.18.6",
25
- "@nocobase/actions": "1.5.0-alpha.4",
26
- "@nocobase/database": "1.5.0-alpha.4"
25
+ "@nocobase/actions": "1.5.0-beta.1",
26
+ "@nocobase/database": "1.5.0-beta.1"
27
27
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@nocobase/plugin-map",
3
3
  "displayName": "Block: Map",
4
4
  "displayName.zh-CN": "区块:地图",
5
- "version": "1.5.0-alpha.4",
5
+ "version": "1.5.0-beta.1",
6
6
  "description": "Map block, support Gaode map and Google map, you can also extend more map types.",
7
7
  "description.zh-CN": "地图区块,支持高德地图和 Google 地图,你也可以扩展更多地图类型。",
8
8
  "license": "AGPL-3.0",
@@ -36,7 +36,7 @@
36
36
  "@nocobase/test": "1.x",
37
37
  "@nocobase/utils": "1.x"
38
38
  },
39
- "gitHead": "22b9bce1c6c075afdc738766eb47853adaeb0876",
39
+ "gitHead": "10c6f1f3d90e91f3aabfa80449c7ef062e90f6af",
40
40
  "keywords": [
41
41
  "Blocks"
42
42
  ]