/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */

"use strict";(self.webpackChunk_nocobase_plugin_collection_fdw=self.webpackChunk_nocobase_plugin_collection_fdw||[]).push([["406"],{967:function(e,t,n){n.r(t),n.d(t,{PreviewTable:function(){return y}});var r=n(505),o=n(721),a=n(156),l=n.n(a),i=n(238),c=n(563),u=n(772);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var p=["lineString","point","circle","polygon"],y=function(e){var t=e.remoteServerName,n=e.remoteTableName,s=e.fields,y=m((0,a.useState)([]),2),d=y[0],b=y[1],v=m((0,a.useState)([]),2),g=v[0],O=v[1],h=(0,a.useContext)(r.SchemaOptionsContext),S=(0,u.useCompile)(),w=m((0,a.useState)(!1),2),j=w[0],E=w[1],P=(0,u.useCollectionManager_deprecated)().getInterface,k=(0,u.useAPIClient)(),T=(0,i.useTranslation)().t,_=(0,r.useForm)();(0,a.useEffect)(function(){t&&n?C():b([])},[n]),(0,a.useEffect)(function(){b([]);var e=x(s);setTimeout(function(){b(e)})},[_.values.fields]);var C=function(){var e={};_.values.fields.map(function(t){p.includes(t.type)&&(e[t.name]=t.type)}),E(!0),k.resource("databaseServers.tables",t).query({filterByTk:n,fieldTypes:e}).then(function(e){var t=e.data;t&&(E(!1),O((null==t?void 0:t.data)||[]))}).catch},x=function(e){var t;return null==(t=e.filter(function(e){return e.interface}))?void 0:t.map(function(e){var t,n,o,a=(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name,i=(null==(o=P(e.interface))||null==(n=o.default)?void 0:n.uiSchema)||{};return{title:S(a),dataIndex:e.name,key:e.name,width:200,render:function(t,n,o){var a,c,s=n[e.name],m={type:"object",properties:f({},"".concat(e.name,"_").concat(o),(a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){f(e,t,n[t])})}return e}({},i),c=c={"x-read-pretty":!0,default:"json"===e.interface?JSON.stringify(s):s},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(c)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(c)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(c,e))}),a))};return l().createElement(u.EllipsisWithTooltip,{ellipsis:!0},l().createElement(u.SchemaComponentOptions,{components:h.components},l().createElement(r.RecursionField,{schema:m,name:o,onlyRenderProperties:!0})))}}})},A=(0,a.useMemo)(function(){return(0,c.createForm)({readPretty:!0,readOnly:!0})},[d]);return l().createElement(o.Spin,{spinning:j,key:"preview"},l().createElement("div",{style:{marginBottom:22}},l().createElement("div",{className:"ant-formily-item-label",style:{marginTop:24,display:"flex",padding:"0 0 8px"},key:t},l().createElement("div",{className:"ant-formily-item-label-content"},l().createElement("span",null,l().createElement("label",null,T("Preview")))),l().createElement("span",{className:"ant-formily-item-colon"},":")),(null==d?void 0:d.length)>0&&l().createElement(r.FormProvider,{form:A},l().createElement(o.Table,{size:"middle",pagination:!1,bordered:!0,columns:d,dataSource:g,scroll:{x:1e3,y:300},key:"".concat(t,"-preview")}))))}}}]);