@nocobase/plugin-map 0.20.0-alpha.9 → 0.21.0-alpha.2

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.
@@ -1,2 +1,8 @@
1
- import { SchemaInitializer } from '@nocobase/client';
2
- export declare const mapActionInitializers: SchemaInitializer;
1
+ import { CompatibleSchemaInitializer } from '@nocobase/client';
2
+ /**
3
+ * @deprecated
4
+ * use `mapActionInitializers` instead
5
+ * 表格操作配置
6
+ */
7
+ export declare const mapActionInitializers_deprecated: CompatibleSchemaInitializer;
8
+ export declare const mapActionInitializers: CompatibleSchemaInitializer;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const MapBlock: (props: any) => React.JSX.Element;
2
+ export declare const MapBlock: React.FunctionComponent<any>;
@@ -0,0 +1,6 @@
1
+ import { ISchema } from '@formily/react';
2
+ export declare const createMapBlockUISchema: (options: {
3
+ collectionName: string;
4
+ dataSource: string;
5
+ fieldNames: object;
6
+ }) => ISchema;
@@ -1,58 +1 @@
1
- export declare const createMapBlockSchema: (options: any) => import("@formily/react").Stringify<{
2
- [key: symbol]: any;
3
- [key: `x-${string}`]: any;
4
- [key: `x-${number}`]: any;
5
- version?: string;
6
- name?: import("@formily/react").SchemaKey;
7
- title?: any;
8
- description?: any;
9
- default?: any;
10
- readOnly?: boolean;
11
- writeOnly?: boolean;
12
- type?: import("@formily/react").SchemaTypes;
13
- enum?: import("@formily/react").SchemaEnum<any>;
14
- const?: any;
15
- multipleOf?: number;
16
- maximum?: number;
17
- exclusiveMaximum?: number;
18
- minimum?: number;
19
- exclusiveMinimum?: number;
20
- maxLength?: number;
21
- minLength?: number;
22
- pattern?: string | RegExp;
23
- maxItems?: number;
24
- minItems?: number;
25
- uniqueItems?: boolean;
26
- maxProperties?: number;
27
- minProperties?: number;
28
- required?: string | boolean | string[];
29
- format?: string;
30
- $ref?: string;
31
- $namespace?: string;
32
- definitions?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
33
- properties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
34
- items?: import("@formily/react").SchemaItems<any, any, any, any, any, any, any, any>;
35
- additionalItems?: import("@formily/react").Stringify<any>;
36
- patternProperties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
37
- additionalProperties?: import("@formily/react").Stringify<any>;
38
- "x-value"?: any;
39
- "x-index"?: number;
40
- "x-pattern"?: any;
41
- "x-display"?: any;
42
- "x-validator"?: any;
43
- "x-decorator"?: any;
44
- "x-decorator-props"?: any;
45
- "x-component"?: any;
46
- "x-component-props"?: any;
47
- "x-reactions"?: import("@formily/react").SchemaReactions<any>;
48
- "x-content"?: any;
49
- "x-data"?: any;
50
- "x-visible"?: boolean;
51
- "x-hidden"?: boolean;
52
- "x-disabled"?: boolean;
53
- "x-editable"?: boolean;
54
- "x-read-only"?: boolean;
55
- "x-read-pretty"?: boolean;
56
- "x-compile-omitted"?: string[];
57
- }>;
58
1
  export declare const findNestedOption: (value: string[] | string, options?: any[]) => any;
@@ -1,43 +1,43 @@
1
- (function(P,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/antd-v5"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/antd-v5","@formily/shared"],n):(P=typeof globalThis!="undefined"?globalThis:P||self,n(P["@nocobase/plugin-map"]={},P.jsxRuntime,P["@nocobase/client"],P.react,P["@ant-design/icons"],P["@formily/react"],P.ahooks,P.antd,P["react-i18next"],P["react-router-dom"],P.lodash,P["@formily/antd-v5"],P["@formily/shared"]))})(this,function(P,n,s,f,R,G,V,w,ne,le,Fe,Ye,Je){"use strict";var Kt=Object.defineProperty,Ut=Object.defineProperties;var Nt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable;var ke=(P,n,s)=>n in P?Kt(P,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):P[n]=s,O=(P,n)=>{for(var s in n||(n={}))_e.call(n,s)&&ke(P,s,n[s]);if(ye)for(var s of ye(n))Ve.call(n,s)&&ke(P,s,n[s]);return P},J=(P,n)=>Ut(P,Nt(n));var We=(P,n)=>{var s={};for(var f in P)_e.call(P,f)&&n.indexOf(f)<0&&(s[f]=P[f]);if(P!=null&&ye)for(var f of ye(P))n.indexOf(f)<0&&Ve.call(P,f)&&(s[f]=P[f]);return s};var E=(P,n,s)=>(ke(P,typeof n!="symbol"?n+"":n,s),s);var be=(P,n,s)=>new Promise((f,R)=>{var G=ne=>{try{w(s.next(ne))}catch(le){R(le)}},V=ne=>{try{w(s.throw(ne))}catch(le){R(le)}},w=ne=>ne.done?f(ne.value):Promise.resolve(ne.value).then(G,V);w((s=s.apply(P,n)).next())});const fe="map";function Q(e){return`{{t('${e}', { ns: '${fe}', nsMode: 'fallback' })}}`}function Z(){return ne.useTranslation(fe,{nsMode:"fallback"})}const Oe=[{label:Q("AMap"),value:"amap"},{label:Q("Google Maps"),value:"google"}],ve="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV2iEaCDnQ8F/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==",Ee=(e,o,t)=>{const r=o==null?void 0:o.reduce((a,i,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(g=>g[i]).filter(g=>g!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?r:[r]};var Ze=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Le={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(Ze,function(){function t(c){var y=[];return c.AMapUI&&y.push(r(c.AMapUI)),c.Loca&&y.push(a(c.Loca)),Promise.all(y)}function r(c){return new Promise(function(y,p){var d=[];if(c.plugins)for(var M=0;M<c.plugins.length;M+=1)l.AMapUI.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);if(g.AMapUI===i.failed)p("前次请求 AMapUI 失败");else if(g.AMapUI===i.notload){g.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,M=l.AMapUI.version;var T=document.body||document.head,K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/ui/"+M+"/main.js",K.onerror=function(I){g.AMapUI=i.failed,p("请求 AMapUI 失败")},K.onload=function(){if(g.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},T.appendChild(K)}else g.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}y()}):y():c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(I){I?p(I):d.length?window.AMapUI.loadUI(d,function(){for(var q=0,Y=d.length;q<Y;q++){var U=d[q].split("/").slice(-1)[0];window.AMapUI[U]=arguments[q]}y()}):y()})})}function a(c){return new Promise(function(y,p){if(g.Loca===i.failed)p("前次请求 Loca 失败");else if(g.Loca===i.notload){g.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,M=l.AMap.version.startsWith("2"),T=d.startsWith("2");if(M&&!T||!M&&T)p("JSAPI 与 Loca 版本不对应!!");else{M=l.key,T=document.body||document.head;var K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/loca?v="+d+"&key="+M,K.onerror=function(I){g.Loca=i.failed,p("请求 AMapUI 失败")},K.onload=function(){for(g.Loca=i.loaded,y();v.Loca.length;)v.Loca.splice(0,1)[0]()},T.appendChild(K)}}else g.Loca===i.loaded?c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):v.Loca.push(function(I){I?p(I):p()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},g={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]},x=[],A=function(c){typeof c=="function"&&(g.AMap===i.loaded?c(window.AMap):x.push(c))};return{load:function(c){return new Promise(function(y,p){if(g.AMap==i.failed)p("");else if(g.AMap==i.notload){var d=c.key,M=c.version,T=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=T||l.AMap.plugins,g.AMap=i.loading,M=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)g.AMap=i.failed,p(I);else for(g.AMap=i.loaded,t(c).then(function(){y(window.AMap)}).catch(p);x.length;)x.splice(0,1)[0]()},T=document.createElement("script"),T.type="text/javascript",T.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),T.onerror=function(I){g.AMap=i.failed,p(I)},M.appendChild(T)):p("请填写key")}else if(g.AMap==i.loaded)if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)}else if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 JSAPI 混用");else{var K=[];if(c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&K.push(c.plugins[M]);A(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},g={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(Le);var He=Le.exports;const Qe=Xe(He),ze="map-configuration",Ae=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Me=e=>{const o=f.useMemo(()=>{const r=sessionStorage.getItem(Ae(e));return r&&JSON.parse(r)},[e]),{data:t}=s.useRequest({resource:ze,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(Ae(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},$e=e=>{const{aMap:o,toCenter:t}=e,{t:r}=Z(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{a.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:g}=V.useDebounceFn(x=>{a.current&&a.current.search(x||" ",(A,c)=>{if(A==="complete")l(c.poiList.pois.map(y=>J(O({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(A==="no_data"){l([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=x=>{const A=i.find(c=>c.value===x);A!=null&&A.location&&t(A.location)};return n.jsx("div",{className:s.css`
1
+ (function(D,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/antd-v5"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/antd-v5","@formily/shared"],s):(D=typeof globalThis!="undefined"?globalThis:D||self,s(D["@nocobase/plugin-map"]={},D.jsxRuntime,D["@nocobase/client"],D.react,D["@ant-design/icons"],D["@formily/react"],D.ahooks,D.antd,D["react-i18next"],D["react-router-dom"],D.lodash,D["@formily/antd-v5"],D["@formily/shared"]))})(this,function(D,s,n,h,R,G,V,w,ne,le,ke,We,Ye){"use strict";var Tt=Object.defineProperty,Bt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ve=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable;var Pe=(D,s,n)=>s in D?Tt(D,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):D[s]=n,O=(D,s)=>{for(var n in s||(s={}))Ut.call(s,n)&&Pe(D,n,s[n]);if(Ve)for(var n of Ve(s))Nt.call(s,n)&&Pe(D,n,s[n]);return D},X=(D,s)=>Bt(D,Kt(s));var F=(D,s,n)=>(Pe(D,typeof s!="symbol"?s+"":s,n),n);var ye=(D,s,n)=>new Promise((h,R)=>{var G=ne=>{try{w(n.next(ne))}catch(le){R(le)}},V=ne=>{try{w(n.throw(ne))}catch(le){R(le)}},w=ne=>ne.done?h(ne.value):Promise.resolve(ne.value).then(G,V);w((n=n.apply(D,s)).next())});const fe="map";function Q(e){return`{{t('${e}', { ns: '${fe}', nsMode: 'fallback' })}}`}function J(){return ne.useTranslation(fe,{nsMode:"fallback"})}const Fe=[{label:Q("AMap"),value:"amap"},{label:Q("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV2iEaCDnQ8F/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==",Oe=(e,o,t)=>{const r=o==null?void 0:o.reduce((a,i,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(m=>m[i]).filter(m=>m!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?r:[r]};var Je=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ee={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(Je,function(){function t(c){var b=[];return c.AMapUI&&b.push(r(c.AMapUI)),c.Loca&&b.push(a(c.Loca)),Promise.all(b)}function r(c){return new Promise(function(b,u){var d=[];if(c.plugins)for(var M=0;M<c.plugins.length;M+=1)l.AMapUI.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);if(m.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,M=l.AMapUI.version;var L=document.body||document.head,K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/ui/"+M+"/main.js",K.onerror=function(I){m.AMapUI=i.failed,u("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(b();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()});else for(b();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()},L.appendChild(K)}else m.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}b()}):b():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):A.AMapUI.push(function(I){I?u(I):d.length?window.AMapUI.loadUI(d,function(){for(var q=0,Y=d.length;q<Y;q++){var U=d[q].split("/").slice(-1)[0];window.AMapUI[U]=arguments[q]}b()}):b()})})}function a(c){return new Promise(function(b,u){if(m.Loca===i.failed)u("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,M=l.AMap.version.startsWith("2"),L=d.startsWith("2");if(M&&!L||!M&&L)u("JSAPI 与 Loca 版本不对应!!");else{M=l.key,L=document.body||document.head;var K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/loca?v="+d+"&key="+M,K.onerror=function(I){m.Loca=i.failed,u("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=i.loaded,b();A.Loca.length;)A.Loca.splice(0,1)[0]()},L.appendChild(K)}}else m.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):A.Loca.push(function(I){I?u(I):u()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},A={AMap:[],AMapUI:[],Loca:[]},x=[],v=function(c){typeof c=="function"&&(m.AMap===i.loaded?c(window.AMap):x.push(c))};return{load:function(c){return new Promise(function(b,u){if(m.AMap==i.failed)u("");else if(m.AMap==i.notload){var d=c.key,M=c.version,L=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=L||l.AMap.plugins,m.AMap=i.loading,M=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)m.AMap=i.failed,u(I);else for(m.AMap=i.loaded,t(c).then(function(){b(window.AMap)}).catch(u);x.length;)x.splice(0,1)[0]()},L=document.createElement("script"),L.type="text/javascript",L.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),L.onerror=function(I){m.AMap=i.failed,u(I)},M.appendChild(L)):u("请填写key")}else if(m.AMap==i.loaded)if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(window.AMap)}).catch(u)}else if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{var K=[];if(c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&K.push(c.plugins[M]);v(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(window.AMap)}).catch(u)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},A={AMap:[],AMapUI:[],Loca:[]}}}})})(Ee);var Xe=Ee.exports;const He=Ze(Xe),ze="map-configuration",Ae=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,ve=e=>{const o=h.useMemo(()=>{const r=sessionStorage.getItem(Ae(e));return r&&JSON.parse(r)},[e]),{data:t}=n.useRequest({resource:ze,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(Ae(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Qe=e=>{const{aMap:o,toCenter:t}=e,{t:r}=J(),a=h.useRef(),[i,l]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{a.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=V.useDebounceFn(x=>{a.current&&a.current.search(x||" ",(v,c)=>{if(v==="complete")l(c.poiList.pois.map(b=>X(O({},b),{label:`${b.name}-${b.address}`,value:b.id})));else{if(v==="no_data"){l([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),A=x=>{const v=i.find(c=>c.value===x);v!=null&&v.location&&t(v.location)};return s.jsx("div",{className:n.css`
2
2
  position: absolute;
3
3
  top: 10px;
4
4
  left: 10px;
5
5
  z-index: 10;
6
6
  width: calc(100% - 20px);
7
- `,children:n.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:g,onSelect:v,options:i,popupMatchSelectWidth:!1})})},Ce={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"}},xe=f.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:r}=Me(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:g,disabled:v=l,zoom:x=13,overlayCommonOptions:A}=e,{t:c}=Z(),y=G.useFieldSchema(),p=f.useRef(),d=f.useRef(),M=f.useRef(),[T,K]=f.useState([]),[I,q]=f.useState(""),{getField:Y}=s.useCollection_deprecated(),U=f.useMemo(()=>{if(e.type)return e.type;const m=Y(y==null?void 0:y.name);return m==null?void 0:m.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),D=f.useRef(),B=f.useRef(null),ee=le.useNavigate(),H=f.useRef(`nocobase-map-${U||""}-${Date.now().toString(32)}`),{modal:te}=w.App.useApp(),[X]=f.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},A)),se=V.useMemoizedFn(()=>{D.current&&D.current.remove()}),oe=V.useMemoizedFn(()=>{(!v||l)&&U!=="point"&&B.current&&(B.current.setTarget(D.current),B.current.open())}),k=V.useMemoizedFn((m,u=!1)=>{let h=null;if(U==="point"){const{lat:C,lng:N}=m.getPosition();h=[N,C]}else if(U==="polygon"||U==="lineString"){if(h=m.getPath().map(C=>[C.lng,C.lat]),h.length<2)return}else if(U==="circle"){const C=m.getCenter(),N=m.getRadius();h=[C.lng,C.lat,N]}u||(se(),D.current=m,oe()),i==null||i(h)}),W=V.useMemoizedFn((m=U)=>{const u=Ce[m];if(u&&"editor"in u&&!B.current)return B.current=new p.current[u.editor](d.current,null,{createOptions:X,editOptions:X,controlPoint:J(O({},X),{strokeWeight:3}),midControlPoint:J(O({},X),{strokeWeight:2,fillColor:"#fff"})}),B.current.on("adjust",function({target:h}){k(h,!0)}),B.current.on("move",function({target:h}){k(h,!0)}),B.current}),L=V.useMemoizedFn((m=U)=>{var h;if(!M.current||(h=B.current)!=null&&h.getTarget())return;const u=Ce[m];u&&M.current[u.mouseTool](O({},X))}),$=V.useMemoizedFn((m=U)=>{M.current||(M.current=new p.current.MouseTool(d.current),M.current.on("draw",function({obj:u}){k(u)}),L(m))}),S=(m,u)=>{d.current&&d.current.setZoomAndCenter(18,m,u)},z=()=>{const m=()=>{se(),B.current&&(B.current.setTarget(),B.current.close()),i==null||i(null)};te.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(H.current),onOk(){m()}})},b=()=>{D.current&&d.current.setFitView([D.current])},F=f.useCallback((m=U,u=a,h)=>{const C=Ce[m];if(!C)return;const N=O(O({},X),h);return"transformOptions"in C?Object.assign(N,C.transformOptions(u)):"propertyKey"in C&&(N[C.propertyKey]=u),new p.current[C.overlay](N)},[X]),j=(m=U,u=a,h)=>{if(!p.current)return;const C=F(m,u,h);return C.setMap(d.current),C};f.useEffect(()=>{if(!p.current||!a||!g&&D.current)return;const m=j();d.current.setFitView([m]),D.current=m,v||(W(),oe())},[a,T,U,X,v,g]),f.useEffect(()=>{var m,u,h;M.current&&(v?((m=M.current)==null||m.close(),(u=B.current)==null||u.close()):(L(),(h=B.current)==null||h.open()))},[v]),f.useEffect(()=>{!p.current||!U||v||($(),W())},[v,T,U]),f.useEffect(()=>{var u,h;if(!a&&(M.current||B.current)&&(se(),B.current&&(B.current.setTarget(),B.current.close()),i==null||i(null)),!M.current||!B.current)return;B.current.getTarget()?(h=(u=M.current).close)==null||h.call(u):L()},[U,a]),f.useEffect(()=>{if(!t||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const m=window.define;return window.define=void 0,Qe.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(u=>(window.define=m,requestIdleCallback(()=>{d.current=new u.Map(H.current,{resizeEnable:!0,zoom:x}),p.current=u,q(""),K([])}))).catch(u=>{typeof u=="string"?u.includes("多个不一致的 key")?q(c("The AccessKey is incorrect, please check it")):q(u):(u==null?void 0:u.type)==="error"&&q("Something went wrong, please refresh the page and try again")}),()=>{var u;(u=d.current)==null||u.destroy(),p.current=null,d.current=null,M.current=null,B.current=null}},[t,U,r]),f.useImperativeHandle(o,()=>({setOverlay:j,getOverlay:F,createMouseTool:$,createEditor:W,executeMouseTool:L,aMap:p.current,map:d.current,overlay:D.current,mouseTool:()=>M.current,editor:()=>B.current,errMessage:I}));const _=s.useApp();return!t||I?n.jsx(w.Alert,{action:n.jsx(w.Button,{type:"primary",onClick:()=>ee(_.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):n.jsxs("div",{className:s.css`
7
+ `,children:s.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:A,options:i,popupMatchSelectWidth:!1})})},Me={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"}},Ce=h.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:r}=ve(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:m,disabled:A=l,zoom:x=13,overlayCommonOptions:v}=e,{t:c}=J(),b=G.useFieldSchema(),u=h.useRef(),d=h.useRef(),M=h.useRef(),[L,K]=h.useState([]),[I,q]=h.useState(""),{getField:Y}=n.useCollection_deprecated(),U=h.useMemo(()=>{if(e.type)return e.type;const f=Y(b==null?void 0:b.name);return f==null?void 0:f.interface},[e==null?void 0:e.type,b==null?void 0:b.name]),T=h.useRef(),B=h.useRef(null),ee=le.useNavigate(),H=h.useRef(`nocobase-map-${U||""}-${Date.now().toString(32)}`),{modal:te}=w.App.useApp(),[Z]=h.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},v)),se=V.useMemoizedFn(()=>{T.current&&T.current.remove()}),oe=V.useMemoizedFn(()=>{(!A||l)&&U!=="point"&&B.current&&(B.current.setTarget(T.current),B.current.open())}),P=V.useMemoizedFn((f,p=!1)=>{let g=null;if(U==="point"){const{lat:C,lng:N}=f.getPosition();g=[N,C]}else if(U==="polygon"||U==="lineString"){if(g=f.getPath().map(C=>[C.lng,C.lat]),g.length<2)return}else if(U==="circle"){const C=f.getCenter(),N=f.getRadius();g=[C.lng,C.lat,N]}p||(se(),T.current=f,oe()),i==null||i(g)}),W=V.useMemoizedFn((f=U)=>{const p=Me[f];if(p&&"editor"in p&&!B.current)return B.current=new u.current[p.editor](d.current,null,{createOptions:Z,editOptions:Z,controlPoint:X(O({},Z),{strokeWeight:3}),midControlPoint:X(O({},Z),{strokeWeight:2,fillColor:"#fff"})}),B.current.on("adjust",function({target:g}){P(g,!0)}),B.current.on("move",function({target:g}){P(g,!0)}),B.current}),E=V.useMemoizedFn((f=U)=>{var g;if(!M.current||(g=B.current)!=null&&g.getTarget())return;const p=Me[f];p&&M.current[p.mouseTool](O({},Z))}),$=V.useMemoizedFn((f=U)=>{M.current||(M.current=new u.current.MouseTool(d.current),M.current.on("draw",function({obj:p}){P(p)}),E(f))}),S=(f,p)=>{d.current&&d.current.setZoomAndCenter(18,f,p)},z=()=>{const f=()=>{se(),B.current&&(B.current.setTarget(),B.current.close()),i==null||i(null)};te.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(H.current),onOk(){f()}})},y=()=>{T.current&&d.current.setFitView([T.current])},k=h.useCallback((f=U,p=a,g)=>{const C=Me[f];if(!C)return;const N=O(O({},Z),g);return"transformOptions"in C?Object.assign(N,C.transformOptions(p)):"propertyKey"in C&&(N[C.propertyKey]=p),new u.current[C.overlay](N)},[Z]),_=(f=U,p=a,g)=>{if(!u.current)return;const C=k(f,p,g);return C.setMap(d.current),C};h.useEffect(()=>{if(!u.current||!a||!m&&T.current)return;const f=_();d.current.setFitView([f]),T.current=f,A||(W(),oe())},[a,L,U,Z,A,m]),h.useEffect(()=>{var f,p,g;M.current&&(A?((f=M.current)==null||f.close(),(p=B.current)==null||p.close()):(E(),(g=B.current)==null||g.open()))},[A]),h.useEffect(()=>{!u.current||!U||A||($(),W())},[A,L,U]),h.useEffect(()=>{var p,g;if(!a&&(M.current||B.current)&&(se(),B.current&&(B.current.setTarget(),B.current.close()),i==null||i(null)),!M.current||!B.current)return;B.current.getTarget()?(g=(p=M.current).close)==null||g.call(p):E()},[U,a]),h.useEffect(()=>{if(!t||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const f=window.define;return window.define=void 0,He.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(p=>(window.define=f,requestIdleCallback(()=>{d.current=new p.Map(H.current,{resizeEnable:!0,zoom:x}),u.current=p,q(""),K([])}))).catch(p=>{typeof p=="string"?p.includes("多个不一致的 key")?q(c("The AccessKey is incorrect, please check it")):q(p):(p==null?void 0:p.type)==="error"&&q("Something went wrong, please refresh the page and try again")}),()=>{var p;(p=d.current)==null||p.destroy(),u.current=null,d.current=null,M.current=null,B.current=null}},[t,U,r]),h.useImperativeHandle(o,()=>({setOverlay:_,getOverlay:k,createMouseTool:$,createEditor:W,executeMouseTool:E,aMap:u.current,map:d.current,overlay:T.current,mouseTool:()=>M.current,editor:()=>B.current,errMessage:I}));const j=n.useApp();return!t||I?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>ee(j.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):s.jsxs("div",{className:n.css`
8
8
  position: relative;
9
9
  height: 500px;
10
- `,id:H.current,style:e==null?void 0:e.style,children:[!p.current&&n.jsx("div",{className:s.css`
10
+ `,id:H.current,style:e==null?void 0:e.style,children:[!u.current&&s.jsx("div",{className:n.css`
11
11
  position: absolute;
12
12
  inset: 0;
13
13
  display: flex;
14
14
  align-items: center;
15
15
  justify-content: center;
16
- `,children:n.jsx(w.Spin,{})}),v?null:n.jsxs(n.Fragment,{children:[n.jsx($e,{toCenter:S,aMap:p.current}),n.jsx("div",{className:s.css`
16
+ `,children:s.jsx(w.Spin,{})}),A?null:s.jsxs(s.Fragment,{children:[s.jsx(Qe,{toCenter:S,aMap:u.current}),s.jsx("div",{className:n.css`
17
17
  position: absolute;
18
18
  bottom: 80px;
19
19
  right: 20px;
20
20
  z-index: 10;
21
- `,children:n.jsx(w.Button,{onClick:b,disabled:!D.current,type:"primary",shape:"round",size:"large",icon:n.jsx(R.SyncOutlined,{})})}),U!=="point"?n.jsx("div",{className:s.css`
21
+ `,children:s.jsx(w.Button,{onClick:y,disabled:!T.current,type:"primary",shape:"round",size:"large",icon:s.jsx(R.SyncOutlined,{})})}),U!=="point"?s.jsx("div",{className:n.css`
22
22
  position: absolute;
23
23
  bottom: 20px;
24
24
  left: 10px;
25
25
  z-index: 2;
26
26
  pointer-events: none;
27
- `,children:n.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:s.css`
27
+ `,children:s.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:n.css`
28
28
  position: absolute;
29
29
  bottom: 20px;
30
30
  right: 20px;
31
31
  z-index: 2;
32
- `,children:n.jsx(w.Button,{disabled:!a,style:{height:"40px"},onClick:z,type:"primary",danger:!0,children:c("Clear")})})]})]})});xe.displayName="AMapComponent";const Re=e=>{var k,W,L,$;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:g}=s.useProps(e),{name:v,getPrimaryKey:x}=s.useCollection_deprecated(),{getCollectionJoinField:A}=s.useCollectionManager_deprecated(),c=x(),[y,p]=f.useState(!1),d=f.useRef(),M=(W=(k=d.current)==null?void 0:k.aMap)==null?void 0:W.GeometryUtil,[T,K]=f.useState(),[I,q]=f.useState(""),{t:Y}=Z(),U=s.useCompile(),{isConnected:D,doFilter:B}=s.useFilterAPI(),[,ee]=f.useState(null),H=f.useRef(I);H.current=I;const te=(S,z)=>{const b=S.getExtData(),F=typeof z=="undefined"?b.selected:!z;b.selected=!F,"setIcon"in S&&S.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:F?ue:ve})),S.setOptions(O({extData:b},F?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},X=()=>{var S,z,b;d.current&&((S=d.current)==null||S.mouseTool().close(!0),(z=d.current)==null||z.editor().setTarget(null),(b=d.current)==null||b.editor().close())};f.useEffect(()=>{var S,z,b,F;if(I==="selection")return(S=d.current)!=null&&S.editor()?(F=d.current)==null||F.executeMouseTool("polygon"):((z=d.current)==null||z.createEditor("polygon"),(b=d.current)==null||b.createMouseTool("polygon")),()=>{X()}},[I]),f.useEffect(()=>{if(I)return()=>{var S;H.current||(S=d.current)==null||S.map.getAllOverlays().forEach(z=>{te(z,!1)})}},[I]);const se=V.useMemoizedFn(()=>{var j,_,m;const S=(j=d.current)==null?void 0:j.editor().getTarget(),z=(_=d.current)==null?void 0:_.map.getAllOverlays(),b=z==null?void 0:z.filter(u=>{if(!(u===S||u.getExtData().id===void 0))return"getPosition"in u?M.isPointInRing(u.getPosition(),S==null?void 0:S.getPath()):M.doesRingRingIntersect(u.getPath(),S==null?void 0:S.getPath())}),F=b==null?void 0:b.map(u=>(te(u,!0),u.getExtData().id));l(u=>F==null?void 0:F.concat(u)),S==null||S.remove(),(m=d.current)==null||m.editor().close()});f.useEffect(()=>{var j,_,m;if(!o||!d.current||!r)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,z=A([v,...S].flat().join(".")),b=r.map(u=>{var C;const h=(C=Ee(u,t==null?void 0:t.field,z==null?void 0:z.interface))==null?void 0:C.filter(Boolean);return h!=null&&h.length?h.map(N=>{var ie;return(ie=d.current)==null?void 0:ie.setOverlay(o.type,N,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?U(u[t.marker]):void 0},extData:{id:u[c]}})}):[]}).flat().filter(Boolean);(_=(j=d.current)==null?void 0:j.map)==null||_.setFitView(b);const F=b.map(u=>{const h=C=>{const N=C.target,re=N.getExtData();if(!re)return;if(H.current){H.current==="click"&&(l(ae=>re.selected?ae.filter(Pe=>Pe!==re.id):[...ae,re.id]),te(N));return}const ie=r.find(ae=>re.id===ae[c]);if(D){ee(ae=>(ae&&Te(ae),ae===u?(Te(u),B(null),null):(tt(u),B(ie[c],Pe=>Pe.field||c,"$eq"),u)));return}ie&&K(ie)};return u.on("click",h),()=>u.off("click",h)});if(o.type==="point"&&(g!=null&&g.length)&&(b==null?void 0:b.length)>1){const u=b.map(C=>C.getPosition());b[0].setzIndex(13),b[b.length-1].setzIndex(13);const h=(C=!0)=>{var N,re;if((N=d.current)!=null&&N.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:Y(C?"Start point":"End point")},position:u[C?0:u.length-1],map:(re=d.current)==null?void 0:re.map})};b.push(...[(m=d.current)==null?void 0:m.setOverlay("lineString",u,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),h(),h(!1)].filter(Boolean))}return()=>{b.forEach(u=>{u.remove()}),F.forEach(u=>u())}},[r,y,t,v,c,o.type,D,g]),f.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=S=>{d.current=S,p(!!(S!=null&&S.map)&&!S.errMessage)};return n.jsxs("div",{className:s.css`
32
+ `,children:s.jsx(w.Button,{disabled:!a,style:{height:"40px"},onClick:z,type:"primary",danger:!0,children:c("Clear")})})]})]})});Ce.displayName="AMapComponent";const $e=e=>{var P,W,E,$;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:m}=n.useProps(e),{name:A,getPrimaryKey:x}=n.useCollection_deprecated(),{getCollectionJoinField:v}=n.useCollectionManager_deprecated(),c=x(),[b,u]=h.useState(!1),d=h.useRef(),M=(W=(P=d.current)==null?void 0:P.aMap)==null?void 0:W.GeometryUtil,[L,K]=h.useState(),[I,q]=h.useState(""),{t:Y}=J(),U=n.useCompile(),{isConnected:T,doFilter:B}=n.useFilterAPI(),[,ee]=h.useState(null),H=h.useRef(I);H.current=I;const te=(S,z)=>{const y=S.getExtData(),k=typeof z=="undefined"?y.selected:!z;y.selected=!k,"setIcon"in S&&S.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:k?ue:be})),S.setOptions(O({extData:y},k?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},Z=()=>{var S,z,y;d.current&&((S=d.current)==null||S.mouseTool().close(!0),(z=d.current)==null||z.editor().setTarget(null),(y=d.current)==null||y.editor().close())};h.useEffect(()=>{var S,z,y,k;if(I==="selection")return(S=d.current)!=null&&S.editor()?(k=d.current)==null||k.executeMouseTool("polygon"):((z=d.current)==null||z.createEditor("polygon"),(y=d.current)==null||y.createMouseTool("polygon")),()=>{Z()}},[I]),h.useEffect(()=>{if(I)return()=>{var S;H.current||(S=d.current)==null||S.map.getAllOverlays().forEach(z=>{te(z,!1)})}},[I]);const se=V.useMemoizedFn(()=>{var _,j,f;const S=(_=d.current)==null?void 0:_.editor().getTarget(),z=(j=d.current)==null?void 0:j.map.getAllOverlays(),y=z==null?void 0:z.filter(p=>{if(!(p===S||p.getExtData().id===void 0))return"getPosition"in p?M.isPointInRing(p.getPosition(),S==null?void 0:S.getPath()):M.doesRingRingIntersect(p.getPath(),S==null?void 0:S.getPath())}),k=y==null?void 0:y.map(p=>(te(p,!0),p.getExtData().id));l(p=>k==null?void 0:k.concat(p)),S==null||S.remove(),(f=d.current)==null||f.editor().close()});h.useEffect(()=>{var _,j,f;if(!o||!d.current||!r)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,z=v([A,...S].flat().join(".")),y=r.map(p=>{var C;const g=(C=Oe(p,t==null?void 0:t.field,z==null?void 0:z.interface))==null?void 0:C.filter(Boolean);return g!=null&&g.length?g.map(N=>{var ie;return(ie=d.current)==null?void 0:ie.setOverlay(o.type,N,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?U(p[t.marker]):void 0},extData:{id:p[c]}})}):[]}).flat().filter(Boolean);(j=(_=d.current)==null?void 0:_.map)==null||j.setFitView(y);const k=y.map(p=>{const g=C=>{const N=C.target,re=N.getExtData();if(!re)return;if(H.current){H.current==="click"&&(l(ae=>re.selected?ae.filter(Ie=>Ie!==re.id):[...ae,re.id]),te(N));return}const ie=r.find(ae=>re.id===ae[c]);if(T){ee(ae=>(ae&&Le(ae),ae===p?(Le(p),B(null),null):(et(p),B(ie[c],Ie=>Ie.field||c,"$eq"),p)));return}ie&&K(ie)};return p.on("click",g),()=>p.off("click",g)});if(o.type==="point"&&(m!=null&&m.length)&&(y==null?void 0:y.length)>1){const p=y.map(C=>C.getPosition());y[0].setzIndex(13),y[y.length-1].setzIndex(13);const g=(C=!0)=>{var N,re;if((N=d.current)!=null&&N.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:Y(C?"Start point":"End point")},position:p[C?0:p.length-1],map:(re=d.current)==null?void 0:re.map})};y.push(...[(f=d.current)==null?void 0:f.setOverlay("lineString",p,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),g(),g(!1)].filter(Boolean))}return()=>{y.forEach(p=>{p.remove()}),k.forEach(p=>p())}},[r,b,t,A,c,o.type,T,m]),h.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=S=>{d.current=S,u(!!(S!=null&&S.map)&&!S.errMessage)};return s.jsxs("div",{className:n.css`
33
33
  position: relative;
34
34
  height: 100%;
35
- `,children:[n.jsx("div",{className:s.css`
35
+ `,children:[s.jsx("div",{className:n.css`
36
36
  position: absolute;
37
37
  left: 10px;
38
38
  top: 10px;
39
39
  z-index: 999;
40
- `,children:y&&!((L=d.current)!=null&&L.errMessage)?n.jsxs(w.Space,{direction:"vertical",children:[n.jsx(w.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),q("")},icon:n.jsx(R.EnvironmentOutlined,{})}),n.jsx(w.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),q("selection")},icon:n.jsx(R.ExpandOutlined,{})}),I==="selection"?n.jsx(w.Button,{type:"primary",icon:n.jsx(R.CheckOutlined,{}),title:Y("Confirm selection"),onClick:se}):null]}):null}),n.jsx(et,{record:T,setVisible:K}),n.jsx(xe,J(O({},($=o==null?void 0:o.uiSchema)==null?void 0:$["x-component-props"]),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},et=e=>{const{setVisible:o,record:t}=e,r=s.useCollectionParentRecordData(),a=G.useFieldSchema(),i=f.useMemo(()=>a.reduceProperties((l,g)=>g.name==="drawer"?g:l,null),[a]);return i&&n.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(s.RecordProvider,{record:t,parent:r,children:n.jsx(G.RecursionField,{schema:i,name:i.name})})})};function Te(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function tt(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 De=({type:e,children:o})=>{const{t}=Z(),[r,a]=V.useBoolean(!1),i=s.useAPIClient(),[l]=w.Form.useForm(),g=Me(e);f.useEffect(()=>{g&&(l.setFieldsValue(g),a.toggle())},[g]);const v=f.useMemo(()=>i.resource(ze),[i]),x=A=>{v.set(J(O({},A),{type:e})).then(c=>{sessionStorage.removeItem(Ae(e)),a.toggle(),w.message.success(t("Saved successfully"))}).catch(c=>{w.message.success(t("Saved failed"))})};return n.jsxs(w.Form,{disabled:r,form:l,layout:"vertical",onFinish:x,children:[o,r?n.jsx(w.Button,{disabled:!1,onClick:a.toggle,children:t("Edit")}):n.jsx(w.Form.Item,{children:n.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},ot={amap:()=>{const{t:e}=Z();return n.jsxs(De,{type:"amap",children:[n.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:n.jsx(w.Input,{})}),n.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:n.jsx(w.Input,{})})]})},google:()=>{const{t:e}=Z();return n.jsx(De,{type:"google",children:n.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:n.jsx(w.Input,{})})})}},rt=Oe.map(e=>J(O({},e),{component:ot[e.value]})),nt=()=>{const e=s.useCompile(),o=le.useLocation(),t=new URLSearchParams(o.search);return n.jsx(w.Card,{bordered:!0,children:n.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:rt.map(r=>n.jsx(w.Tabs.TabPane,{tab:e(r.label),children:n.jsx(r.component,{type:r.value})},r.value))})})};/*! *****************************************************************************
40
+ `,children:b&&!((E=d.current)!=null&&E.errMessage)?s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),q("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),q("selection")},icon:s.jsx(R.ExpandOutlined,{})}),I==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:Y("Confirm selection"),onClick:se}):null]}):null}),s.jsx(Re,{record:L,setVisible:K}),s.jsx(Ce,X(O({},($=o==null?void 0:o.uiSchema)==null?void 0:$["x-component-props"]),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},Re=e=>{const{setVisible:o,record:t}=e,r=n.useCollectionParentRecordData(),a=G.useFieldSchema(),i=h.useMemo(()=>a.reduceProperties((l,m)=>m.name==="drawer"?m:l,null),[a]);return i&&s.jsx(n.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:s.jsx(n.RecordProvider,{record:t,parent:r,children:s.jsx(G.RecursionField,{schema:i,name:i.name})})})};function Le(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function et(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 De=({type:e,children:o})=>{const{t}=J(),[r,a]=V.useBoolean(!1),i=n.useAPIClient(),[l]=w.Form.useForm(),m=ve(e);h.useEffect(()=>{m&&(l.setFieldsValue(m),a.toggle())},[m]);const A=h.useMemo(()=>i.resource(ze),[i]),x=v=>{A.set(X(O({},v),{type:e})).then(c=>{sessionStorage.removeItem(Ae(e)),a.toggle(),w.message.success(t("Saved successfully"))}).catch(c=>{w.message.success(t("Saved failed"))})};return s.jsxs(w.Form,{disabled:r,form:l,layout:"vertical",onFinish:x,children:[o,r?s.jsx(w.Button,{disabled:!1,onClick:a.toggle,children:t("Edit")}):s.jsx(w.Form.Item,{children:s.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},tt={amap:()=>{const{t:e}=J();return s.jsxs(De,{type:"amap",children:[s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:s.jsx(w.Input,{})}),s.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:s.jsx(w.Input,{})})]})},google:()=>{const{t:e}=J();return s.jsx(De,{type:"google",children:s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:s.jsx(w.Input,{})})})}},ot=Fe.map(e=>X(O({},e),{component:tt[e.value]})),rt=()=>{const e=n.useCompile(),o=le.useLocation(),t=new URLSearchParams(o.search);return s.jsx(w.Card,{bordered:!0,children:s.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:ot.map(r=>s.jsx(w.Tabs.TabPane,{tab:e(r.label),children:s.jsx(r.component,{type:r.value})},r.value))})})};/*! *****************************************************************************
41
41
  Copyright (c) Microsoft Corporation.
42
42
 
43
43
  Permission to use, copy, modify, and/or distribute this software for any
@@ -50,62 +50,62 @@
50
50
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
51
51
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52
52
  PERFORMANCE OF THIS SOFTWARE.
53
- ***************************************************************************** */function st(e,o,t,r){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function g(A){try{x(r.next(A))}catch(c){l(c)}}function v(A){try{x(r.throw(A))}catch(c){l(c)}}function x(A){A.done?i(A.value):a(A.value).then(g,v)}x((r=r.apply(e,o||[])).next())})}var it=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 r,a,i;if(Array.isArray(o)){if(r=o.length,r!=t.length)return!1;for(a=r;a--!==0;)if(!e(o[a],t[a]))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(i=Object.keys(o),r=i.length,r!==Object.keys(t).length)return!1;for(a=r;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[a]))return!1;for(a=r;a--!==0;){var l=i[a];if(!e(o[l],t[l]))return!1}return!0}return o!==o&&t!==t};const Be="__googleMapsScriptId";var de;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(de||(de={}));class ce{constructor({apiKey:o,authReferrerPolicy:t,channel:r,client:a,id:i=Be,language:l,libraries:g=[],mapIds:v,nonce:x,region:A,retries:c=3,url:y="https://maps.googleapis.com/maps/api/js",version:p}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=r,this.client=a,this.id=i||Be,this.language=l,this.libraries=g,this.mapIds=v,this.nonce=x,this.region=A,this.retries=c,this.url=y,this.version=p,ce.instance){if(!it(this.options,ce.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ce.instance.options)}`);return ce.instance}ce.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?de.FAILURE:this.done?de.SUCCESS:this.loading?de.LOADING:de.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(r=>{r?t(r.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 r={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(r).forEach(i=>!r[i]&&delete r[i]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(i=>{let l,g,v,x="The Google Maps JavaScript API",A="google",c="importLibrary",y="__ib__",p=document,d=window;d=d[A]||(d[A]={});const M=d.maps||(d.maps={}),T=new Set,K=new URLSearchParams,I=()=>l||(l=new Promise((q,Y)=>st(this,void 0,void 0,function*(){var U;yield g=p.createElement("script"),g.id=this.id,K.set("libraries",[...T]+"");for(v in i)K.set(v.replace(/[A-Z]/g,D=>"_"+D[0].toLowerCase()),i[v]);K.set("callback",A+".maps."+y),g.src=this.url+"?"+K,M[y]=q,g.onerror=()=>l=Y(Error(x+" could not load.")),g.nonce=this.nonce||((U=p.querySelector("script[nonce]"))===null||U===void 0?void 0:U.nonce)||"",p.head.append(g)})));M[c]?console.warn(x+" only loads once. Ignoring:",i):M[c]=(q,...Y)=>T.add(q)&&I().then(()=>M[c](q,...Y))})(r);const a=this.libraries.map(i=>this.importLibrary(i));a.length||a.push(this.importLibrary("core")),Promise.all(a).then(()=>this.callback(),i=>{const l=new ErrorEvent("error",{error:i});this.loadErrorCallback(l)})}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 at=e=>{const{toCenter:o,mapRef:t}=e,{t:r}=Z(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{google.maps.importLibrary("places").then(x=>{a.current=new x.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[t]);const{run:g}=V.useDebounceFn(x=>{a.current&&a.current.getPlacePredictions({input:x||" "},(A,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(A.map(y=>{const p=y.structured_formatting;return J(O({},y),{label:`${p.main_text}${p.secondary_text?" "+p.secondary_text:""}`,value:y.place_id})}));else{l([]);return}})},{wait:300}),v=x=>{const A=i.find(y=>y.value===x);new google.maps.places.PlacesService(t.current).getDetails({placeId:A.place_id,fields:["geometry"]},(y,p)=>{p===google.maps.places.PlacesServiceStatus.OK&&o(y.geometry.location)})};return n.jsx("div",{className:s.css`
53
+ ***************************************************************************** */function nt(e,o,t,r){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function m(v){try{x(r.next(v))}catch(c){l(c)}}function A(v){try{x(r.throw(v))}catch(c){l(c)}}function x(v){v.done?i(v.value):a(v.value).then(m,A)}x((r=r.apply(e,o||[])).next())})}var st=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 r,a,i;if(Array.isArray(o)){if(r=o.length,r!=t.length)return!1;for(a=r;a--!==0;)if(!e(o[a],t[a]))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(i=Object.keys(o),r=i.length,r!==Object.keys(t).length)return!1;for(a=r;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[a]))return!1;for(a=r;a--!==0;){var l=i[a];if(!e(o[l],t[l]))return!1}return!0}return o!==o&&t!==t};const Te="__googleMapsScriptId";var de;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(de||(de={}));class ce{constructor({apiKey:o,authReferrerPolicy:t,channel:r,client:a,id:i=Te,language:l,libraries:m=[],mapIds:A,nonce:x,region:v,retries:c=3,url:b="https://maps.googleapis.com/maps/api/js",version:u}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=r,this.client=a,this.id=i||Te,this.language=l,this.libraries=m,this.mapIds=A,this.nonce=x,this.region=v,this.retries=c,this.url=b,this.version=u,ce.instance){if(!st(this.options,ce.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ce.instance.options)}`);return ce.instance}ce.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?de.FAILURE:this.done?de.SUCCESS:this.loading?de.LOADING:de.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(r=>{r?t(r.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 r={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(r).forEach(i=>!r[i]&&delete r[i]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(i=>{let l,m,A,x="The Google Maps JavaScript API",v="google",c="importLibrary",b="__ib__",u=document,d=window;d=d[v]||(d[v]={});const M=d.maps||(d.maps={}),L=new Set,K=new URLSearchParams,I=()=>l||(l=new Promise((q,Y)=>nt(this,void 0,void 0,function*(){var U;yield m=u.createElement("script"),m.id=this.id,K.set("libraries",[...L]+"");for(A in i)K.set(A.replace(/[A-Z]/g,T=>"_"+T[0].toLowerCase()),i[A]);K.set("callback",v+".maps."+b),m.src=this.url+"?"+K,M[b]=q,m.onerror=()=>l=Y(Error(x+" could not load.")),m.nonce=this.nonce||((U=u.querySelector("script[nonce]"))===null||U===void 0?void 0:U.nonce)||"",u.head.append(m)})));M[c]?console.warn(x+" only loads once. Ignoring:",i):M[c]=(q,...Y)=>L.add(q)&&I().then(()=>M[c](q,...Y))})(r);const a=this.libraries.map(i=>this.importLibrary(i));a.length||a.push(this.importLibrary("core")),Promise.all(a).then(()=>this.callback(),i=>{const l=new ErrorEvent("error",{error:i});this.loadErrorCallback(l)})}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 it=e=>{const{toCenter:o,mapRef:t}=e,{t:r}=J(),a=h.useRef(),[i,l]=h.useState([]);h.useEffect(()=>{google.maps.importLibrary("places").then(x=>{a.current=new x.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[t]);const{run:m}=V.useDebounceFn(x=>{a.current&&a.current.getPlacePredictions({input:x||" "},(v,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(v.map(b=>{const u=b.structured_formatting;return X(O({},b),{label:`${u.main_text}${u.secondary_text?" "+u.secondary_text:""}`,value:b.place_id})}));else{l([]);return}})},{wait:300}),A=x=>{const v=i.find(b=>b.value===x);new google.maps.places.PlacesService(t.current).getDetails({placeId:v.place_id,fields:["geometry"]},(b,u)=>{u===google.maps.places.PlacesServiceStatus.OK&&o(b.geometry.location)})};return s.jsx("div",{className:n.css`
54
54
  position: absolute;
55
55
  top: 10px;
56
56
  left: 10px;
57
57
  z-index: 10;
58
58
  width: calc(100% - 20px);
59
- `,children:n.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:g,onSelect:v,options:i})})},pe=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),lt=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:a}=t.coords;e({lat:r,lng:a})},()=>{o()}):o()}),ct=e=>e==="point"?"marker":e==="lineString"?"polyline":e,pt={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"}},Se=f.forwardRef((e,o)=>{const{value:t,onChange:r,block:a=!1,readonly:i,disabled:l=a,zoom:g=13,overlayCommonOptions:v}=e,{accessKey:x}=Me(e.mapType)||{},{t:A}=Z(),{getField:c}=s.useCollection_deprecated(),y=G.useFieldSchema(),p=f.useRef(),d=f.useRef(),M=f.useRef(),[T,K]=f.useState([]),[I,q]=f.useState(""),Y=s.useAPIClient(),{modal:U}=w.App.useApp(),D=f.useMemo(()=>{if(e.type)return e.type;const m=c(y==null?void 0:y.name);return m==null?void 0:m.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),B=f.useRef(ct(D)),[ee]=f.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},v)),H=le.useNavigate(),te=f.useRef(),X=f.useRef(new Set),se=V.useMemoizedFn(m=>{if(X.current.forEach(u=>{X.current.delete(u)}),"getPath"in m){const u=m.getPath();["insert_at","remove_at","set_at"].forEach(h=>{X.current.add(u.addListener(h,()=>{S(m,!0)}).remove)})}else m instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(u=>{X.current.add(m.addListener(u,()=>{S(m,!0)}).remove)})}),oe=V.useMemoizedFn(()=>{var m;M.current&&(M.current.unbindAll(),M.current.setMap(null)),D!=="point"&&((m=p.current)==null||m.setDrawingMode(null))}),k=V.useMemoizedFn(m=>{d.current&&(d.current.setCenter(m),d.current.setZoom(g))}),W=V.useMemoizedFn(m=>{oe(),se(m),M.current=m}),L=V.useMemoizedFn(m=>{const u=new google.maps.LatLngBounds;m.forEach(h=>{if(h instanceof google.maps.Marker)u.extend(h.getPosition());else if(h instanceof google.maps.Polyline||h instanceof google.maps.Polygon){const C=h.getPath();for(let N=0;N<C.getLength();N++)u.extend(C.getAt(N))}else h instanceof google.maps.Circle&&u.union(h.getBounds())}),d.current.setCenter(u.getCenter())}),$=()=>{M.current&&L([M.current])},S=V.useMemoizedFn((m,u=!1)=>{let h=null;if(D==="point"){const{lat:C,lng:N}=m.getPosition();h=[N(),C()]}else if(D==="polygon"||D==="lineString"){if(h=m.getPath().getArray().map(C=>[C.lng(),C.lat()]),h.length<2)return}else if(D==="circle"){const C=m.getCenter(),N=m.getRadius();h=[C.lng(),C.lat(),N]}u||W(m),r==null||r(h)}),z=V.useMemoizedFn((m=!1,u)=>{const h=J(O(O({},ee),u),{map:d.current});return p.current=new google.maps.drawing.DrawingManager({drawingMode:B.current,drawingControl:!1,markerOptions:J(O({},h),{icon:pe(ue)}),polygonOptions:h,polylineOptions:h,circleOptions:h,map:d.current}),m||p.current.addListener("overlaycomplete",C=>{const N=C.overlay;S(N)}),p.current}),b=V.useMemoizedFn((m=D,u=t,h)=>{const C=pt[m];if(!C)return;const N=O(J(O({},ee),{icon:pe(ue)}),h);return"transformOptions"in C?Object.assign(N,C.transformOptions(u)):"propertyKey"in C&&(N[C.propertyKey]=Array.isArray(u[0])?u.map(ie=>new google.maps.LatLng(ie[1],ie[0])):new google.maps.LatLng(u[1],u[0])),new google.maps[C.overlay](N)}),F=V.useMemoizedFn((m=D,u=t,h)=>d.current?b(m,u,J(O({},h),{map:d.current})):void 0);f.useEffect(()=>{var u,h;if(!t&&d.current&&(oe(),(h=(u=p==null?void 0:p.current)==null?void 0:u.setDrawingMode)==null||h.call(u,B.current),r==null||r(null)),!d.current||!t||!i&&M.current)return;const m=F();W(m),L([m])},[t,T,D,l,i,F,L,W]),f.useEffect(()=>{if(!x||d.current||!te.current)return;let m;try{m=new ce({apiKey:x,version:"weekly",language:Y.auth.getLocale()})}catch(h){q(A("Load google maps failed, Please check the Api key and refresh the page"));return}const u=console.error;return console.error=(h,...C)=>{h!=null&&h.includes("InvalidKeyMapError")&&q(A("Load google maps failed, Please check the Api key and refresh the page")),u(h,...C)},Promise.all([m.importLibrary("drawing"),m.importLibrary("core"),m.importLibrary("geometry")]).then(h=>be(this,null,function*(){const C=yield lt();d.current=new google.maps.Map(te.current,{zoom:g,center:C,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),q(""),K([])})).catch(h=>{if(h instanceof Error){q(h.message);return}}),()=>{var h,C;(h=d.current)==null||h.unbindAll(),d.current=null,(C=p.current)==null||C.unbindAll()}},[x,Y.auth,D,g]),f.useEffect(()=>{!d.current||!D||l||p.current||z()},[z,l,T,D]),f.useImperativeHandle(o,()=>({setOverlay:F,getOverlay:b,setFitView:L,createDraw:z,map:d.current,overlay:M.current,drawingManager:p.current,errMessage:I}));const j=V.useMemoizedFn(()=>{const m=()=>{oe(),p.current.setDrawingMode(B.current),r==null||r(null)};U.confirm({title:A("Clear the canvas"),content:A("Are you sure to clear the canvas?"),okText:A("Confirm"),cancelText:A("Cancel"),getContainer:()=>te.current,onOk(){m()}})}),_=s.useApp();return!x||I?n.jsx(w.Alert,{action:n.jsx(w.Button,{type:"primary",onClick:()=>H(_.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:A("Go to the configuration page")}),message:I||A("Please configure the Api key first"),type:"error"}):n.jsxs("div",{className:s.css`
59
+ `,children:s.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:A,options:i})})},pe=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),at=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:a}=t.coords;e({lat:r,lng:a})},()=>{o()}):o()}),lt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ct={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"}},xe=h.forwardRef((e,o)=>{const{value:t,onChange:r,block:a=!1,readonly:i,disabled:l=a,zoom:m=13,overlayCommonOptions:A}=e,{accessKey:x}=ve(e.mapType)||{},{t:v}=J(),{getField:c}=n.useCollection_deprecated(),b=G.useFieldSchema(),u=h.useRef(),d=h.useRef(),M=h.useRef(),[L,K]=h.useState([]),[I,q]=h.useState(""),Y=n.useAPIClient(),{modal:U}=w.App.useApp(),T=h.useMemo(()=>{if(e.type)return e.type;const f=c(b==null?void 0:b.name);return f==null?void 0:f.interface},[e==null?void 0:e.type,b==null?void 0:b.name]),B=h.useRef(lt(T)),[ee]=h.useState(O({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},A)),H=le.useNavigate(),te=h.useRef(),Z=h.useRef(new Set),se=V.useMemoizedFn(f=>{if(Z.current.forEach(p=>{Z.current.delete(p)}),"getPath"in f){const p=f.getPath();["insert_at","remove_at","set_at"].forEach(g=>{Z.current.add(p.addListener(g,()=>{S(f,!0)}).remove)})}else f instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(p=>{Z.current.add(f.addListener(p,()=>{S(f,!0)}).remove)})}),oe=V.useMemoizedFn(()=>{var f;M.current&&(M.current.unbindAll(),M.current.setMap(null)),T!=="point"&&((f=u.current)==null||f.setDrawingMode(null))}),P=V.useMemoizedFn(f=>{d.current&&(d.current.setCenter(f),d.current.setZoom(m))}),W=V.useMemoizedFn(f=>{oe(),se(f),M.current=f}),E=V.useMemoizedFn(f=>{const p=new google.maps.LatLngBounds;f.forEach(g=>{if(g instanceof google.maps.Marker)p.extend(g.getPosition());else if(g instanceof google.maps.Polyline||g instanceof google.maps.Polygon){const C=g.getPath();for(let N=0;N<C.getLength();N++)p.extend(C.getAt(N))}else g instanceof google.maps.Circle&&p.union(g.getBounds())}),d.current.setCenter(p.getCenter())}),$=()=>{M.current&&E([M.current])},S=V.useMemoizedFn((f,p=!1)=>{let g=null;if(T==="point"){const{lat:C,lng:N}=f.getPosition();g=[N(),C()]}else if(T==="polygon"||T==="lineString"){if(g=f.getPath().getArray().map(C=>[C.lng(),C.lat()]),g.length<2)return}else if(T==="circle"){const C=f.getCenter(),N=f.getRadius();g=[C.lng(),C.lat(),N]}p||W(f),r==null||r(g)}),z=V.useMemoizedFn((f=!1,p)=>{const g=X(O(O({},ee),p),{map:d.current});return u.current=new google.maps.drawing.DrawingManager({drawingMode:B.current,drawingControl:!1,markerOptions:X(O({},g),{icon:pe(ue)}),polygonOptions:g,polylineOptions:g,circleOptions:g,map:d.current}),f||u.current.addListener("overlaycomplete",C=>{const N=C.overlay;S(N)}),u.current}),y=V.useMemoizedFn((f=T,p=t,g)=>{const C=ct[f];if(!C)return;const N=O(X(O({},ee),{icon:pe(ue)}),g);return"transformOptions"in C?Object.assign(N,C.transformOptions(p)):"propertyKey"in C&&(N[C.propertyKey]=Array.isArray(p[0])?p.map(ie=>new google.maps.LatLng(ie[1],ie[0])):new google.maps.LatLng(p[1],p[0])),new google.maps[C.overlay](N)}),k=V.useMemoizedFn((f=T,p=t,g)=>d.current?y(f,p,X(O({},g),{map:d.current})):void 0);h.useEffect(()=>{var p,g;if(!t&&d.current&&(oe(),(g=(p=u==null?void 0:u.current)==null?void 0:p.setDrawingMode)==null||g.call(p,B.current),r==null||r(null)),!d.current||!t||!i&&M.current)return;const f=k();W(f),E([f])},[t,L,T,l,i,k,E,W]),h.useEffect(()=>{if(!x||d.current||!te.current)return;let f;try{f=new ce({apiKey:x,version:"weekly",language:Y.auth.getLocale()})}catch(g){q(v("Load google maps failed, Please check the Api key and refresh the page"));return}const p=console.error;return console.error=(g,...C)=>{g!=null&&g.includes("InvalidKeyMapError")&&q(v("Load google maps failed, Please check the Api key and refresh the page")),p(g,...C)},Promise.all([f.importLibrary("drawing"),f.importLibrary("core"),f.importLibrary("geometry")]).then(g=>ye(this,null,function*(){const C=yield at();d.current=new google.maps.Map(te.current,{zoom:m,center:C,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),q(""),K([])})).catch(g=>{if(g instanceof Error){q(g.message);return}}),()=>{var g,C;(g=d.current)==null||g.unbindAll(),d.current=null,(C=u.current)==null||C.unbindAll()}},[x,Y.auth,T,m]),h.useEffect(()=>{!d.current||!T||l||u.current||z()},[z,l,L,T]),h.useImperativeHandle(o,()=>({setOverlay:k,getOverlay:y,setFitView:E,createDraw:z,map:d.current,overlay:M.current,drawingManager:u.current,errMessage:I}));const _=V.useMemoizedFn(()=>{const f=()=>{oe(),u.current.setDrawingMode(B.current),r==null||r(null)};U.confirm({title:v("Clear the canvas"),content:v("Are you sure to clear the canvas?"),okText:v("Confirm"),cancelText:v("Cancel"),getContainer:()=>te.current,onOk(){f()}})}),j=n.useApp();return!x||I?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>H(j.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:v("Go to the configuration page")}),message:I||v("Please configure the Api key first"),type:"error"}):s.jsxs("div",{className:n.css`
60
60
  position: relative;
61
61
  height: 500px;
62
- `,children:[!d.current&&n.jsx("div",{className:s.css`
62
+ `,children:[!d.current&&s.jsx("div",{className:n.css`
63
63
  position: absolute;
64
64
  inset: 0;
65
65
  display: flex;
66
66
  align-items: center;
67
67
  justify-content: center;
68
- `,children:n.jsx(w.Spin,{})}),l?null:n.jsxs(n.Fragment,{children:[d.current&&n.jsx(at,{toCenter:k,mapRef:d}),n.jsx("div",{className:s.css`
68
+ `,children:s.jsx(w.Spin,{})}),l?null:s.jsxs(s.Fragment,{children:[d.current&&s.jsx(it,{toCenter:P,mapRef:d}),s.jsx("div",{className:n.css`
69
69
  position: absolute;
70
70
  bottom: 80px;
71
71
  right: 20px;
72
72
  z-index: 10;
73
- `,children:n.jsx(w.Button,{onClick:$,disabled:!M.current,type:"primary",shape:"round",size:"large",icon:n.jsx(R.SyncOutlined,{})})}),D==="lineString"||D==="polygon"?n.jsx("div",{className:s.css`
73
+ `,children:s.jsx(w.Button,{onClick:$,disabled:!M.current,type:"primary",shape:"round",size:"large",icon:s.jsx(R.SyncOutlined,{})})}),T==="lineString"||T==="polygon"?s.jsx("div",{className:n.css`
74
74
  position: absolute;
75
75
  bottom: 20px;
76
76
  left: 10px;
77
77
  z-index: 2;
78
78
  pointer-events: none;
79
- `,children:n.jsx(w.Alert,{message:A("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:s.css`
79
+ `,children:s.jsx(w.Alert,{message:v("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:n.css`
80
80
  position: absolute;
81
81
  bottom: 20px;
82
82
  right: 20px;
83
83
  z-index: 2;
84
- `,children:n.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:j,type:"primary",danger:!0,children:A("Clear")})})]}),n.jsx("div",{ref:te,className:s.css`
84
+ `,children:s.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:_,type:"primary",danger:!0,children:v("Clear")})})]}),s.jsx("div",{ref:te,className:n.css`
85
85
  width: 100%;
86
86
  height: 100%;
87
- `,style:e==null?void 0:e.style})]})});Se.displayName="GoogleMapsComponent";const me="google-maps-overlay-id",Ke="google-maps-overlay-selected",ut=s.css`
87
+ `,style:e==null?void 0:e.style})]})});xe.displayName="GoogleMapsComponent";const me="google-maps-overlay-id",Be="google-maps-overlay-selected",pt=n.css`
88
88
  margin-top: 6px;
89
89
  padding: 2px 4px;
90
90
  background: #fff;
91
91
  border: 1px solid #0000f5;
92
- `,dt=s.css`
92
+ `,ut=n.css`
93
93
  margin-top: -64px;
94
94
  padding: 2px 4px;
95
95
  background: #fff;
96
96
  border: 1px solid #0000f5;
97
- `,ft=e=>{const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:g}=s.useProps(e),{getPrimaryKey:v}=s.useCollection_deprecated(),x=v(),{marker:A="id"}=t,[c,y]=f.useState(!1),p=f.useRef(),[d,M]=f.useState(),[T,K]=f.useState(""),{t:I}=Z(),q=s.useCompile(),{isConnected:Y,doFilter:U}=s.useFilterAPI(),[,D]=f.useState(null),B=f.useRef(T),ee=f.useRef(null),H=f.useRef([]);B.current=T;const{getCollectionJoinField:te}=s.useCollectionManager_deprecated(),X=(k,W)=>{const L=typeof W!="undefined"?!W:k.get(Ke);k.set(Ke,!L),k.setOptions(O({},L?{icon:pe(ue),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:pe(ve),strokeColor:"#F18b62",fillColor:"#F18b62"}))};f.useEffect(()=>{var W,L,$,S;if(T!=="selection")return;p.current&&!((W=p.current)!=null&&W.drawingManager)&&(p.current.drawingManager=(L=p.current)==null?void 0:L.createDraw(!0,{editable:!0,draggable:!0}));const k=new Set;return($=p.current)==null||$.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=p.current)==null||S.drawingManager.addListener("overlaycomplete",z=>{var j;const b=z.overlay;(j=p.current)==null||j.drawingManager.setDrawingMode(null),ee.current=b;const F=b.getPath();["insert_at","remove_at","set_at"].forEach(_=>{k.add(F.addListener(_,()=>{}).remove)})}),()=>{var z,b,F,j;k.forEach(_=>{_()}),p.current&&((z=ee.current)==null||z.unbindAll(),(b=ee.current)==null||b.setMap(null),ee.current=null,(F=p.current)==null||F.drawingManager.setDrawingMode(null),(j=p.current)==null||j.drawingManager.unbindAll())}},[T]),f.useEffect(()=>{if(T)return()=>{B.current||H.current.forEach(k=>{X(k,!1)})}},[T]);const se=V.useMemoizedFn(()=>{var z;const k=ee.current,W=H.current,L=google.maps.geometry.poly,S=W.filter(b=>{if(!(b===k||b.get(me)===void 0))return b instanceof google.maps.Marker?L.containsLocation(b.getPosition(),k):b instanceof google.maps.Circle?L.containsLocation(b.getCenter(),k):b.getPath().getArray().some(F=>L.containsLocation(F,k))}).map(b=>(X(b,!0),b.get(me)));l(b=>S.concat(b)),k==null||k.unbindAll(),k==null||k.setMap(null),(z=p.current)==null||z.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});f.useEffect(()=>{var S,z;if(!o||!(r!=null&&r.length)||!((S=p.current)!=null&&S.map))return;const k=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,W=te([name,...k].flat().join(".")),L=r.map(b=>{const F=Ee(b,t==null?void 0:t.field,W==null?void 0:W.interface);return F!=null&&F.length?F==null?void 0:F.filter(Boolean).map(j=>{var m;if(!F)return;const _=(m=p.current)==null?void 0:m.setOverlay(o.type,j,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:ut,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?q(b[A]):void 0}});return _==null||_.set(me,b[x]),_}):[]}).flat().filter(Boolean);H.current=L;const $=L.map(b=>{const F=j=>{const _=b,m=_.get(me);if(!m)return;const u=r==null?void 0:r.find(h=>m===h[x]);if(Y){D(h=>(h&&Ue(_),h===b?(Ue(_),U(null),null):(gt(_),U(u[x],C=>C.field||x,"$eq"),_)));return}u&&M(u)};return b.addListener("click",F),()=>b.unbindAll()});if(o.type==="point"&&(g!=null&&g.length)&&(L==null?void 0:L.length)>1){const b=L.map(j=>j.getPosition());L[0].setZIndex(138),L[L.length-1].setZIndex(138);const F=(j=!0)=>{var _;if((_=p.current)!=null&&_.map)return new google.maps.Marker({label:{className:dt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(j?"Start point":"End point")},icon:pe(ue),position:j?b[0]:b[b.length-1],map:p.current.map})};L.push(...[p.current.setOverlay("lineString",b.map(j=>[j.lng(),j.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),F(),F(!1)].filter(Boolean))}return(z=p.current)==null||z.setFitView(L),()=>{L.forEach(b=>{b.setMap(null),b.unbindAll()}),$.forEach(b=>b())}},[r,c,A,o.type,Y]),f.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=k=>{p.current=k,y(!!(k!=null&&k.map)&&!k.errMessage)};return n.jsxs("div",{className:s.css`
97
+ `,dt=e=>{const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:m}=n.useProps(e),{getPrimaryKey:A}=n.useCollection_deprecated(),x=A(),{marker:v="id"}=t,[c,b]=h.useState(!1),u=h.useRef(),[d,M]=h.useState(),[L,K]=h.useState(""),{t:I}=J(),q=n.useCompile(),{isConnected:Y,doFilter:U}=n.useFilterAPI(),[,T]=h.useState(null),B=h.useRef(L),ee=h.useRef(null),H=h.useRef([]);B.current=L;const{getCollectionJoinField:te}=n.useCollectionManager_deprecated(),Z=(P,W)=>{const E=typeof W!="undefined"?!W:P.get(Be);P.set(Be,!E),P.setOptions(O({},E?{icon:pe(ue),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:pe(be),strokeColor:"#F18b62",fillColor:"#F18b62"}))};h.useEffect(()=>{var W,E,$,S;if(L!=="selection")return;u.current&&!((W=u.current)!=null&&W.drawingManager)&&(u.current.drawingManager=(E=u.current)==null?void 0:E.createDraw(!0,{editable:!0,draggable:!0}));const P=new Set;return($=u.current)==null||$.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=u.current)==null||S.drawingManager.addListener("overlaycomplete",z=>{var _;const y=z.overlay;(_=u.current)==null||_.drawingManager.setDrawingMode(null),ee.current=y;const k=y.getPath();["insert_at","remove_at","set_at"].forEach(j=>{P.add(k.addListener(j,()=>{}).remove)})}),()=>{var z,y,k,_;P.forEach(j=>{j()}),u.current&&((z=ee.current)==null||z.unbindAll(),(y=ee.current)==null||y.setMap(null),ee.current=null,(k=u.current)==null||k.drawingManager.setDrawingMode(null),(_=u.current)==null||_.drawingManager.unbindAll())}},[L]),h.useEffect(()=>{if(L)return()=>{B.current||H.current.forEach(P=>{Z(P,!1)})}},[L]);const se=V.useMemoizedFn(()=>{var z;const P=ee.current,W=H.current,E=google.maps.geometry.poly,S=W.filter(y=>{if(!(y===P||y.get(me)===void 0))return y instanceof google.maps.Marker?E.containsLocation(y.getPosition(),P):y instanceof google.maps.Circle?E.containsLocation(y.getCenter(),P):y.getPath().getArray().some(k=>E.containsLocation(k,P))}).map(y=>(Z(y,!0),y.get(me)));l(y=>S.concat(y)),P==null||P.unbindAll(),P==null||P.setMap(null),(z=u.current)==null||z.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});h.useEffect(()=>{var S,z;if(!o||!(r!=null&&r.length)||!((S=u.current)!=null&&S.map))return;const P=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,W=te([name,...P].flat().join(".")),E=r.map(y=>{const k=Oe(y,t==null?void 0:t.field,W==null?void 0:W.interface);return k!=null&&k.length?k==null?void 0:k.filter(Boolean).map(_=>{var f;if(!k)return;const j=(f=u.current)==null?void 0:f.setOverlay(o.type,_,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:pt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?q(y[v]):void 0}});return j==null||j.set(me,y[x]),j}):[]}).flat().filter(Boolean);H.current=E;const $=E.map(y=>{const k=_=>{const j=y,f=j.get(me);if(!f)return;const p=r==null?void 0:r.find(g=>f===g[x]);if(Y){T(g=>(g&&Ke(j),g===y?(Ke(j),U(null),null):(mt(j),U(p[x],C=>C.field||x,"$eq"),j)));return}p&&M(p)};return y.addListener("click",k),()=>y.unbindAll()});if(o.type==="point"&&(m!=null&&m.length)&&(E==null?void 0:E.length)>1){const y=E.map(_=>_.getPosition());E[0].setZIndex(138),E[E.length-1].setZIndex(138);const k=(_=!0)=>{var j;if((j=u.current)!=null&&j.map)return new google.maps.Marker({label:{className:ut,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(_?"Start point":"End point")},icon:pe(ue),position:_?y[0]:y[y.length-1],map:u.current.map})};E.push(...[u.current.setOverlay("lineString",y.map(_=>[_.lng(),_.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),k(),k(!1)].filter(Boolean))}return(z=u.current)==null||z.setFitView(E),()=>{E.forEach(y=>{y.setMap(null),y.unbindAll()}),$.forEach(y=>y())}},[r,c,v,o.type,Y]),h.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=P=>{u.current=P,b(!!(P!=null&&P.map)&&!P.errMessage)};return s.jsxs("div",{className:n.css`
98
98
  position: relative;
99
99
  height: 100%;
100
- `,children:[c&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:s.css`
100
+ `,children:[c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:n.css`
101
101
  position: absolute;
102
102
  left: 10px;
103
103
  top: 10px;
104
104
  z-index: 999;
105
- `,children:n.jsxs(w.Space,{direction:"vertical",children:[n.jsx(w.Button,{style:{color:T?void 0:"#F18b62",borderColor:"currentcolor"},onClick:k=>{k.stopPropagation(),K("")},icon:n.jsx(R.EnvironmentOutlined,{})}),n.jsx(w.Button,{style:{color:T==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:k=>{k.stopPropagation(),K("selection")},icon:n.jsx(R.ExpandOutlined,{})}),T==="selection"?n.jsx(w.Button,{type:"primary",icon:n.jsx(R.CheckOutlined,{}),title:I("Confirm selection"),onClick:se}):null]})}),n.jsx(mt,{record:d,setVisible:M})]}),n.jsx(Se,J(O({},e),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},mt=e=>{const{setVisible:o,record:t}=e,r=s.useCollectionParentRecordData(),a=G.useFieldSchema(),i=f.useMemo(()=>a.reduceProperties((l,g)=>g.name==="drawer"?g:l,null),[a]);return i&&n.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(s.RecordProvider,{record:t,parent:r,children:n.jsx(G.RecursionField,{schema:i,name:i.name})})})};function Ue(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(ue));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function gt(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(ve));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const ht=()=>{var c;const{getCollectionJoinField:e}=s.useCollectionManager_deprecated(),{getField:o}=s.useCollection_deprecated(),{form:t}=s.useFormBlockContext(),r=G.useField(),a=G.useFieldSchema(),{t:i}=Z(),{dn:l,refresh:g}=s.useDesignable(),v=o(a.name)||e(a["x-collection-field"]),x=(c=v==null?void 0:v.uiSchema)==null?void 0:c.title;r.title===x||r.title,r.readPretty||r.required;let A="editable";return a["x-disabled"]===!0&&(A="readonly"),a["x-read-pretty"]===!0&&(A="read-pretty"),n.jsxs(s.GeneralSchemaDesigner,{children:[n.jsx(s.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!s.isPatternDisabled(a)&&n.jsx(s.SchemaSettingsSelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:A,onChange:y=>{const p={"x-uid":a["x-uid"]};switch(y){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,p["x-read-pretty"]=!1,p["x-disabled"]=!0,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,p["x-read-pretty"]=!0,p["x-disabled"]=!1,r.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,p["x-read-pretty"]=!1,p["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}l.emit("patch",{schema:p}),l.refresh()}},"pattern"),n.jsx(s.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:r.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(Fe.set(a,"x-component-props.zoom",y),Object.assign(r.componentProps,a["x-component-props"]),l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":r.componentProps}})),l.refresh()}},"map-zoom"),n.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},yt={amap:xe,google:Se},we=f.forwardRef((e,o)=>{const{t}=Z(),{mapType:r}=e,a=f.useMemo(()=>yt[r],[r]);return a?n.jsx(a,O({ref:o},e)):n.jsx("div",{children:t(`The ${r} cannot found`)})});we.displayName="MapComponent";const bt=e=>{var g,v;const{value:o}=e,t=G.useFieldSchema(),{getField:r}=s.useCollection_deprecated(),a=r(t.name),i=e.mapType||((g=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:g.mapType),l=G.useForm();return s.useFieldTitle(),l.readPretty?n.jsx(we,O({readonly:!0,mapType:i},e)):n.jsx("div",{children:n.jsx(s.EllipsisWithTooltip,{ellipsis:!0,children:(v=o==null?void 0:o.map)==null?void 0:v.call(o,x=>Array.isArray(x)?`(${x.join(",")})`:x).join(",")})})},Ne=G.connect(e=>n.jsx("div",{className:s.css`
105
+ `,children:s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:L?void 0:"#F18b62",borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),K("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:L==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),K("selection")},icon:s.jsx(R.ExpandOutlined,{})}),L==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:I("Confirm selection"),onClick:se}):null]})}),s.jsx(ft,{record:d,setVisible:M})]}),s.jsx(xe,X(O({},e),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},ft=e=>{const{setVisible:o,record:t}=e,r=n.useCollectionParentRecordData(),a=G.useFieldSchema(),i=h.useMemo(()=>a.reduceProperties((l,m)=>m.name==="drawer"?m:l,null),[a]);return i&&s.jsx(n.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:s.jsx(n.RecordProvider,{record:t,parent:r,children:s.jsx(G.RecursionField,{schema:i,name:i.name})})})};function Ke(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(ue));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function mt(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(be));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const gt=()=>{var c;const{getCollectionJoinField:e}=n.useCollectionManager_deprecated(),{getField:o}=n.useCollection_deprecated(),{form:t}=n.useFormBlockContext(),r=G.useField(),a=G.useFieldSchema(),{t:i}=J(),{dn:l,refresh:m}=n.useDesignable(),A=o(a.name)||e(a["x-collection-field"]),x=(c=A==null?void 0:A.uiSchema)==null?void 0:c.title;r.title===x||r.title,r.readPretty||r.required;let v="editable";return a["x-disabled"]===!0&&(v="readonly"),a["x-read-pretty"]===!0&&(v="read-pretty"),s.jsxs(n.GeneralSchemaDesigner,{children:[s.jsx(n.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!n.isPatternDisabled(a)&&s.jsx(n.SchemaSettingsSelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:v,onChange:b=>{const u={"x-uid":a["x-uid"]};switch(b){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,u["x-read-pretty"]=!1,u["x-disabled"]=!0,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,u["x-read-pretty"]=!0,u["x-disabled"]=!1,r.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,u["x-read-pretty"]=!1,u["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}l.emit("patch",{schema:u}),l.refresh()}},"pattern"),s.jsx(n.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:r.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:b})=>{b&&(ke.set(a,"x-component-props.zoom",b),Object.assign(r.componentProps,a["x-component-props"]),l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":r.componentProps}})),l.refresh()}},"map-zoom"),s.jsx(n.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},ht={amap:Ce,google:xe},Se=h.forwardRef((e,o)=>{const{t}=J(),{mapType:r}=e,a=h.useMemo(()=>ht[r],[r]);return a?s.jsx(a,O({ref:o},e)):s.jsx("div",{children:t(`The ${r} cannot found`)})});Se.displayName="MapComponent";const yt=e=>{var m,A;const{value:o}=e,t=G.useFieldSchema(),{getField:r}=n.useCollection_deprecated(),a=r(t.name),i=e.mapType||((m=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:m.mapType),l=G.useForm();return n.useFieldTitle(),l.readPretty?s.jsx(Se,O({readonly:!0,mapType:i},e)):s.jsx("div",{children:s.jsx(n.EllipsisWithTooltip,{ellipsis:!0,children:(A=o==null?void 0:o.map)==null?void 0:A.call(o,x=>Array.isArray(x)?`(${x.join(",")})`:x).join(",")})})},Ue=G.connect(e=>s.jsx("div",{className:n.css`
106
106
  height: 100%;
107
107
  border: 1px solid transparent;
108
108
  .ant-formily-item-error & {
109
109
  border: 1px solid #ff4d4f;
110
110
  }
111
- `,children:n.jsx(we,O({},e))}),G.mapReadPretty(bt));Ne.Designer=ht;const vt={amap:Re,google:ft},At=e=>{const{t:o}=Z(),{mapType:t}=e,r=f.useMemo(()=>vt[t],[t]);return r?n.jsx(r,O({},e)):n.jsx("div",{children:o(`The ${t} cannot found`)})},Mt=e=>{var l;const{fieldNames:o}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager_deprecated(),{name:r}=s.useCollection_deprecated(),a=f.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return n.jsx(At,J(O(O({},i),e),{collectionField:a}))},Ct=()=>{const{name:e,title:o}=s.useCollection(),t=s.useSchemaTemplate();return n.jsx(s.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},xt=e=>{const g=e,{collection:o,resource:t,fieldNames:r,settings:a}=g,i=We(g,["collection","resource","fieldNames","settings"]);return{type:"void","x-acl-action":`${t||o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":O({collection:o,resource:t||o,action:"list",fieldNames:r,params:{paginate:!1}},i),"x-toolbar":"BlockSchemaToolbar","x-settings":a,"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"MapActionInitializers","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},[Je.uid()]:{type:"void","x-component":"MapBlock","x-component-props":{useProps:"{{ useMapBlockProps }}"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",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":"RecordBlockInitializers",properties:{}}}}}}}}}}}}},Ge=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,a)=>{const i=t==null?void 0:t.find(l=>l.value===r);return a===e.length-1?i:i==null?void 0:i.children},o)),St=()=>{const e=s.useSchemaInitializerItem(),{insert:o}=s.useSchemaInitializer(),t=f.useContext(G.SchemaOptionsContext),{getCollectionFieldsOptions:r}=s.useCollectionManager_deprecated(),{t:a}=Z(),{theme:i}=s.useGlobalTheme();return n.jsx(s.DataBlockInitializer,O({componentType:"Map",icon:n.jsx(R.TableOutlined,{}),onCreateBlockSchema:g=>be(this,[g],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),x=r(l.name,"string",{dataSource:l.dataSource}),A=yield s.FormDialog(a("Create map block"),()=>{var c;return n.jsx(s.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:n.jsx(Ye.FormLayout,{layout:"vertical",children:n.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:v,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:v.length?[v[0].value,(c=v[0].children)==null?void 0:c[0].value].filter(y=>y!=null):[]},marker:{title:a("Marker field"),enum:x,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const p=y.form.values.field;if(!(p!=null&&p.length))return;const d=Ge(p,v);d&&(y.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(xt({collection:l.name,dataSource:l.dataSource,fieldNames:O({},A),settings:"blockSettings:map"}))}),title:a("Map block")},e))},Ie=f.createContext({});Ie.displayName="MapBlockContext";const wt=e=>{var v;const{fieldNames:o}=e,t=G.useFieldSchema(),r=G.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,g]=f.useState([]);return n.jsx(s.FixedBlockWrapper,{children:n.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:n.jsx(Ie.Provider,{value:{field:r,service:i,resource:a,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:g},children:e.children})})})},It=e=>{const o=G.useField(),{params:t,fieldNames:r}=e,a=t.appends||[],{field:i}=r||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),n.jsx(s.BlockProvider,J(O({name:"map"},e),{runWhenParamsChanged:!0,params:J(O({},t),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:n.jsx(wt,O({},e))}))},ge=()=>f.useContext(Ie),Pt=()=>{var o,t,r,a,i,l;const e=ge();return J(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((a=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:a.zoom)||13,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},kt=e=>n.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:Pt},components:{MapBlockInitializer:St,MapBlockDesigner:Ct,MapBlockProvider:It,MapBlock:Mt},children:e.children}),Ft=new s.SchemaInitializer({name:"MapActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){return s.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return s.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return s.useCollection_deprecated().template!=="sql"}}]}),{defaultProps:Ot}=s.interfacesProperties;Array.isArray(s.interfacesProperties.type.enum)&&s.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class he extends s.CollectionFieldInterface{constructor(){super(...arguments);E(this,"properties",J(O({},Ot),{"uiSchema.x-component-props.mapType":{title:Q("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:Oe}}))}schemaInitialize(t,{block:r}){r==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Et extends he{constructor(){super(...arguments);E(this,"name","circle");E(this,"type","object");E(this,"group","map");E(this,"order",3);E(this,"title",Q("Circle"));E(this,"availableTypes",["circle"]);E(this,"description",Q("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 Lt extends he{constructor(){super(...arguments);E(this,"name","lineString");E(this,"type","object");E(this,"group","map");E(this,"order",2);E(this,"title",Q("Line"));E(this,"description",Q("Line"));E(this,"availableTypes",["lineString"]);E(this,"sortable",!0);E(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class zt extends he{constructor(){super(...arguments);E(this,"name","point");E(this,"type","object");E(this,"group","map");E(this,"order",1);E(this,"title",Q("Point"));E(this,"description",Q("Point"));E(this,"availableTypes",["point"]);E(this,"sortable",!0);E(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Tt extends he{constructor(){super(...arguments);E(this,"name","polygon");E(this,"type","object");E(this,"group","map");E(this,"order",4);E(this,"title",Q("Polygon"));E(this,"description",Q("Polygon"));E(this,"availableTypes",["polygon"]);E(this,"sortable",!0);E(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const Dt=[zt,Tt,Lt,Et],Bt=new s.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:s.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:s.FixedBlockDesignerItem},{name:"mapField",Component:s.SchemaSettingsCascaderItem,useComponentProps(){var x;const{getCollectionFieldsOptions:e}=s.useCollectionManager_deprecated(),{t:o}=Z(),t=G.useFieldSchema(),r=((x=t==null?void 0:t["x-decorator-props"])==null?void 0:x.fieldNames)||{},a=G.useField(),{dn:i}=s.useDesignable(),{service:l}=ge(),{name:g}=s.useCollection(),v=e(g,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.field,options:v,allowClear:!1,onChange:A=>{const c=a.decoratorProps.fieldNames||{};c.field=A,a.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:s.SchemaSettingsSelectItem,useComponentProps(){var x;const{t:e}=Z(),o=G.useFieldSchema(),t=((x=o==null?void 0:o["x-decorator-props"])==null?void 0:x.fieldNames)||{},{service:r}=ge(),a=G.useField(),{dn:i}=s.useDesignable(),{getCollectionFieldsOptions:l}=s.useCollectionManager_deprecated(),{name:g}=s.useCollection(),v=l(g,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:A=>{const c=a.decoratorProps.fieldNames||{};c.marker=A,a.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}},useVisible(){var l,g;const e=G.useFieldSchema(),{getCollectionFieldsOptions:o}=s.useCollectionManager_deprecated(),{name:t}=s.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((g=Ge(r.field,a))==null?void 0:g.type)==="point"}},{name:"setDefaultSortingRules",Component:s.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=Z();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},{name:"defaultZoomLevel",Component:s.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=Z(),o=G.useFieldSchema(),t=G.useField(),{dn:r}=s.useDesignable(),a=((i=o==null?void 0:o["x-component-props"])==null?void 0:i.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:a,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{Fe.set(o,"x-component-props.zoom",l),Object.assign(t.componentProps,o["x-component-props"]),r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),r.refresh()}}}},{name:"dataScope",Component:s.SchemaSettingsDataScope,useComponentProps(){var l,g;const{name:e}=s.useCollection(),o=G.useFieldSchema(),{form:t}=s.useFormBlockContext(),r=G.useField(),{service:a}=ge(),{dn:i}=s.useDesignable();return{collectionName:e,defaultFilter:((g=(l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.params)==null?void 0:g.filter)||{},form:t,onSubmit:({filter:v})=>{var c,y,p;const x=r.decoratorProps.params||{};x.filter=v,r.decoratorProps.params=x,o["x-decorator-props"].params=x;const A=((y=(c=a.params)==null?void 0:c[1])==null?void 0:y.filters)||{};a.run(J(O({},(p=a.params)==null?void 0:p[0]),{filter:s.mergeFilter([...Object.values(A),v]),page:1}),{filters:A}),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:s.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=Z();return{type:s.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:s.SchemaSettingsTemplate,useComponentProps(){var r;const{name:e}=s.useCollection(),o=G.useFieldSchema(),t=(r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource;return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),qe=f.memo(e=>n.jsx(s.CurrentAppInfoProvider,{children:n.jsx(s.SchemaComponentOptions,{components:{Map:Ne},children:n.jsx(kt,{children:e.children})})}));qe.displayName="MapProvider";class je extends s.Plugin{load(){return be(this,null,function*(){this.app.use(qe),this.app.dataSourceManager.addFieldInterfaces(Dt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:Q("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(Ft),this.schemaSettingsManager.add(Bt);const o=this.app.schemaInitializerManager.get("BlockInitializers");o==null||o.add("dataBlocks.map",{title:Q("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(fe,{title:`{{t("Map Manager", { ns: "${fe}" })}}`,icon:"EnvironmentOutlined",Component:nt,aclSnippet:"pm.map.configuration"})})}}P.MapPlugin=je,P.default=je,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
111
+ `,children:s.jsx(Se,O({},e))}),G.mapReadPretty(yt));Ue.Designer=gt;const bt={amap:$e,google:dt},At=e=>{const{t:o}=J(),{mapType:t}=e,r=h.useMemo(()=>bt[t],[t]);return r?s.jsx(r,O({},e)):s.jsx("div",{children:o(`The ${t} cannot found`)})},vt=n.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=n.useProps(e),{getCollectionJoinField:t}=n.useCollectionManager_deprecated(),{name:r}=n.useCollection_deprecated(),a=h.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return s.jsx(At,X(O(O({},i),e),{collectionField:a}))}),Mt=()=>{const{name:e,title:o}=n.useCollection(),t=n.useSchemaTemplate();return s.jsx(n.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ne=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,a)=>{const i=t==null?void 0:t.find(l=>l.value===r);return a===e.length-1?i:i==null?void 0:i.children},o)),Ct=e=>{const{collectionName:o,fieldNames:t,dataSource:r}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:r,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":{style:{marginBottom:16}}},[Ye.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",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"}}}}}}}}}}}},xt=()=>{const e=n.useSchemaInitializerItem(),{insert:o}=n.useSchemaInitializer(),t=h.useContext(G.SchemaOptionsContext),{getCollectionFieldsOptions:r}=n.useCollectionManager_deprecated(),{t:a}=J(),{theme:i}=n.useGlobalTheme();return s.jsx(n.DataBlockInitializer,O({componentType:"Map",icon:s.jsx(R.TableOutlined,{}),onCreateBlockSchema:m=>ye(this,[m],function*({item:l}){const A=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),x=r(l.name,"string",{dataSource:l.dataSource}),v=yield n.FormDialog(a("Create map block"),()=>{var c;return s.jsx(n.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:s.jsx(We.FormLayout,{layout:"vertical",children:s.jsx(n.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:A,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:A.length?[A[0].value,(c=A[0].children)==null?void 0:c[0].value].filter(b=>b!=null):[]},marker:{title:a("Marker field"),enum:x,"x-component":"Select","x-decorator":"FormItem","x-reactions":b=>{const u=b.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,A);d&&(b.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(Ct({collectionName:l.name,dataSource:l.dataSource,fieldNames:O({},v)}))}),title:a("Map block")},e))},we=h.createContext({});we.displayName="MapBlockContext";const St=e=>{var A;const{fieldNames:o}=e,t=G.useFieldSchema(),r=G.useField(),{resource:a,service:i}=n.useBlockRequestContext(),[l,m]=h.useState([]);return s.jsx(n.FixedBlockWrapper,{children:s.jsx(n.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:s.jsx(we.Provider,{value:{field:r,service:i,resource:a,fieldNames:o,fixedBlock:(A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:m},children:e.children})})})},wt=e=>{const o=G.useField(),{params:t,fieldNames:r}=e,a=t.appends||[],{field:i}=r||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),s.jsx(n.BlockProvider,X(O({name:"map"},e),{runWhenParamsChanged:!0,params:X(O({},t),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:s.jsx(St,O({},e))}))},ge=()=>h.useContext(we),Ge=()=>{var o,t,r,a,i,l;const e=ge();return X(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((a=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:a.zoom)||13,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},It=e=>s.jsx(n.SchemaComponentOptions,{scope:{useMapBlockProps:Ge},components:{MapBlockInitializer:xt,MapBlockDesigner:Mt,MapBlockProvider:wt,MapBlock:vt},children:e.children}),qe=new n.CompatibleSchemaInitializer({name:"MapActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return n.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return n.useCollection_deprecated().template!=="sql"}}]}),Pt=new n.CompatibleSchemaInitializer({name:"map:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{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(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return n.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return n.useCollection_deprecated().template!=="sql"}}]},qe),kt=new n.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:n.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:n.FixedBlockDesignerItem},{name:"mapField",Component:n.SchemaSettingsCascaderItem,useComponentProps(){var x;const{getCollectionFieldsOptions:e}=n.useCollectionManager_deprecated(),{t:o}=J(),t=G.useFieldSchema(),r=((x=t==null?void 0:t["x-decorator-props"])==null?void 0:x.fieldNames)||{},a=G.useField(),{dn:i}=n.useDesignable(),{service:l}=ge(),{name:m}=n.useCollection(),A=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.field,options:A,allowClear:!1,onChange:v=>{const c=a.decoratorProps.fieldNames||{};c.field=v,a.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:n.SchemaSettingsSelectItem,useComponentProps(){var x;const{t:e}=J(),o=G.useFieldSchema(),t=((x=o==null?void 0:o["x-decorator-props"])==null?void 0:x.fieldNames)||{},{service:r}=ge(),a=G.useField(),{dn:i}=n.useDesignable(),{getCollectionFieldsOptions:l}=n.useCollectionManager_deprecated(),{name:m}=n.useCollection(),A=l(m,"string");return{title:e("Marker field"),value:t.marker,options:A,onChange:v=>{const c=a.decoratorProps.fieldNames||{};c.marker=v,a.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}},useVisible(){var l,m;const e=G.useFieldSchema(),{getCollectionFieldsOptions:o}=n.useCollectionManager_deprecated(),{name:t}=n.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ne(r.field,a))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:n.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=J();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},n.setDataLoadingModeSettingsItem,{name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=J(),o=G.useFieldSchema(),t=G.useField(),{dn:r}=n.useDesignable(),a=((i=o==null?void 0:o["x-component-props"])==null?void 0:i.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:a,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{ke.set(o,"x-component-props.zoom",l),Object.assign(t.componentProps,o["x-component-props"]),r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),r.refresh()}}}},{name:"dataScope",Component:n.SchemaSettingsDataScope,useComponentProps(){var l,m;const{name:e}=n.useCollection(),o=G.useFieldSchema(),{form:t}=n.useFormBlockContext(),r=G.useField(),{service:a}=ge(),{dn:i}=n.useDesignable();return{collectionName:e,defaultFilter:((m=(l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.params)==null?void 0:m.filter)||{},form:t,onSubmit:({filter:A})=>{var v,c;const x=r.decoratorProps.params||{};x.filter=A,r.decoratorProps.params=x,o["x-decorator-props"].params=x,(c=(v=a.params)==null?void 0:v[1])!=null&&c.filters,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:n.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=J();return{type:n.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:n.SchemaSettingsTemplate,useComponentProps(){var r,a;const{name:e}=n.useCollection(),o=G.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Ft}=n.interfacesProperties;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"});class he extends n.CollectionFieldInterface{constructor(){super(...arguments);F(this,"properties",X(O({},Ft),{"uiSchema.x-component-props.mapType":{title:Q("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:Fe}}))}schemaInitialize(t,{block:r}){r==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Ot extends he{constructor(){super(...arguments);F(this,"name","circle");F(this,"type","object");F(this,"group","map");F(this,"order",3);F(this,"title",Q("Circle"));F(this,"availableTypes",["circle"]);F(this,"description",Q("Circle"));F(this,"sortable",!0);F(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Et extends he{constructor(){super(...arguments);F(this,"name","lineString");F(this,"type","object");F(this,"group","map");F(this,"order",2);F(this,"title",Q("Line"));F(this,"description",Q("Line"));F(this,"availableTypes",["lineString"]);F(this,"sortable",!0);F(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class zt extends he{constructor(){super(...arguments);F(this,"name","point");F(this,"type","object");F(this,"group","map");F(this,"order",1);F(this,"title",Q("Point"));F(this,"description",Q("Point"));F(this,"availableTypes",["point"]);F(this,"sortable",!0);F(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Lt extends he{constructor(){super(...arguments);F(this,"name","polygon");F(this,"type","object");F(this,"group","map");F(this,"order",4);F(this,"title",Q("Polygon"));F(this,"description",Q("Polygon"));F(this,"availableTypes",["polygon"]);F(this,"sortable",!0);F(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const Dt=[zt,Lt,Et,Ot],_e=h.memo(e=>s.jsx(n.SchemaComponentOptions,{components:{Map:Ue},children:s.jsx(It,{children:e.children})}));_e.displayName="MapProvider";class je extends n.Plugin{load(){return ye(this,null,function*(){this.app.use(_e),this.app.dataSourceManager.addFieldInterfaces(Dt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:Q("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(qe),this.app.schemaInitializerManager.add(Pt),this.schemaSettingsManager.add(kt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:Q("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(fe,{title:`{{t("Map Manager", { ns: "${fe}" })}}`,icon:"EnvironmentOutlined",Component:rt,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ge})})}}D.MapPlugin=je,D.default=je,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.20.0-alpha.9",
2
+ "@nocobase/client": "0.21.0-alpha.2",
3
3
  "react": "18.2.0",
4
- "@nocobase/server": "0.20.0-alpha.9",
4
+ "@nocobase/server": "0.21.0-alpha.2",
5
5
  "@formily/react": "2.3.0",
6
6
  "lodash": "4.17.21",
7
7
  "@ant-design/icons": "5.2.6",
@@ -12,6 +12,6 @@ module.exports = {
12
12
  "react-router-dom": "6.21.0",
13
13
  "@formily/core": "2.3.0",
14
14
  "react-i18next": "11.18.6",
15
- "@nocobase/actions": "0.20.0-alpha.9",
16
- "@nocobase/database": "0.20.0-alpha.9"
15
+ "@nocobase/actions": "0.21.0-alpha.2",
16
+ "@nocobase/database": "0.21.0-alpha.2"
17
17
  };
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": "0.20.0-alpha.9",
5
+ "version": "0.21.0-alpha.2",
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": "0.x",
37
37
  "@nocobase/utils": "0.x"
38
38
  },
39
- "gitHead": "5473d9039cfdb649a8c8c625edefc9a3ac464be5",
39
+ "gitHead": "90628f2e2da846208fb2d7966ddb4e467d187ffb",
40
40
  "keywords": [
41
41
  "Blocks"
42
42
  ]