@nocobase/plugin-action-duplicate
Version:
Duplicate a record, you can either duplicate it into a form and edit it before saving it, or you can duplicate it directly to generate a new record.
10 lines (9 loc) • 76.4 kB
JavaScript
/**
* 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.
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/flow-engine"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-duplicate",["ahooks","react-i18next","@emotion/css","@nocobase/client-v2","@formily/core","react","antd","@nocobase/client","@formily/react","@nocobase/flow-engine","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-action-duplicate"]=t(require("ahooks"),require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/flow-engine"),require("lodash")):e["@nocobase/plugin-action-duplicate"]=t(e.ahooks,e["react-i18next"],e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/core"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@nocobase/flow-engine"],e.lodash)}(self,function(e,t,n,r,i,o,l,a,s,c,u){return function(){"use strict";var d={477:function(e){e.exports=n},452:function(e){e.exports=i},230:function(e){e.exports=s},342:function(e){e.exports=a},485:function(e){e.exports=r},694:function(e){e.exports=c},625:function(t){t.exports=e},59:function(e){e.exports=l},773:function(e){e.exports=u},155:function(e){e.exports=o},953:function(e){e.exports=t}},p={};function h(e){var t=p[e];if(void 0!==t)return t.exports;var n=p[e]={exports:{}};return d[e](n,n.exports,h),n.exports}h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},h.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.g.importScripts&&(f=h.g.location+"");var f,m=h.g.document;if(!f&&m&&(m.currentScript&&"SCRIPT"===m.currentScript.tagName.toUpperCase()&&(f=m.currentScript.src),!f)){var y=m.getElementsByTagName("script");if(y.length)for(var b=y.length-1;b>-1&&(!f||!/^http(s?):/.test(f));)f=y[b--].src}if(!f)throw Error("Automatic publicPath is not supported in this browser");h.p=f.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-action-duplicate/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-action-duplicate/dist/client/")}if(!e){var i=window.__nocobase_modern_client_prefix__||"v",o="/"+(i=String(i).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",a=l.indexOf(o);e=a>=0?l.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+i+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-duplicate/dist/client/"}h.p=e}(),!function(){h.r(v),h.d(v,{DuplicateActionModel:function(){return eA},PluginActionDuplicateClient:function(){return eT},default:function(){return eI},DuplicateAction:function(){return x},actionDesignerCss:function(){return w}});var e=h(342),t=h(477),n=h(230),r=h(59),i=h(773),o=h.n(i),l=h(155),a=h.n(l),s=h(953);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t,n,r,i,o,l){try{var a=e[o](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,i)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(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){d(e,t,n[t])})}return e}function f(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function m(e,t){if(null==e)return{};var n,r,i,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(i=0,n=Reflect.ownKeys(Object(e));i<n.length;i++)r=n[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,t){if(null==e)return{};var n,r,i={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)n=o[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,t),Object.getOwnPropertySymbols)for(i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r=n[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o=[],l=!0,a=!1;try{for(i=i.call(e);!(l=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==i.return||i.return()}finally{if(a)throw r}}return o}}(e,t)||g(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function g(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}function S(){var e=b(["\n position: relative;\n &:hover {\n .general-schema-designer {\n display: block;\n }\n }\n .general-schema-designer {\n position: absolute;\n z-index: 999;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n background: var(--colorBgSettingsHover);\n border: 0;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n pointer-events: none;\n '&.nb-in-template': {\n background: 'var(--colorTemplateBgSettingsHover)';\n }\n ,\n > .general-schema-designer-icons {\n position: absolute;\n right: 2px;\n top: 2px;\n line-height: 16px;\n pointer-events: all;\n .ant-space-item {\n background-color: var(--colorSettings);\n color: #fff;\n line-height: 16px;\n width: 16px;\n padding-left: 1px;\n align-self: stretch;\n }\n }\n }\n"]);return S=function(){return e},e}function O(){var e=b(["\n .general-schema-designer {\n top: -10px;\n bottom: -10px;\n left: -10px;\n right: -10px;\n }\n "]);return O=function(){return e},e}var w=(0,t.css)(S()),x=a().forwardRef(function(i,h){var b,v,S,x,k=i.onlyIcon,D=m(i,["onlyIcon"]),A=i.children,j=i.icon,E=i.title,P=m(i,["children","icon","title"]),_=r.App.useApp().message,C=(0,n.useField)(),F=(0,n.useFieldSchema)(),M=(0,e.useAPIClient)(),T=C.disabled||i.disabled,I=(0,e.useDesignable)().designable,R=y((0,l.useState)(!1),2),z=R[0],q=R[1],L=y((0,l.useState)(!1),2),K=L[0],$=L[1],B=y((0,l.useState)(!1),2),W=B[0],G=B[1],U=(0,e.useBlockRequestContext)(),N=U.service,V=U.__parent,H=U.block,J=U.resource,X=F["x-component-props"],Q=X.duplicateFields,Y=X.duplicateMode,Z=void 0===Y?"quickDulicate":Y,ee=X.duplicateCollection,et=(0,e.useRecord)(),en=(0,e.useCollectionParentRecordData)(),er=(0,e.useCollection)(),ei=et.id,eo=et.__collection,el=(0,e.useActionContext)(),ea=(0,e.useCollection_deprecated)().name,es=(0,e.useCollectionManager_deprecated)().getCollectionFields,ec=(0,s.useTranslation)().t,eu=es(eo||ea),ed=(0,e.useFormBlockContext)(),ep=(0,e.useACLActionParamsContext)(),eh=(0,e.useDataSourceKey)(),ef=(0,e.useDataSourceHeaders)(eh),em={key:"duplicate",dataId:Array.isArray(er.filterTargetKey)?(v=Object).assign.apply(v,[{}].concat(function(e){if(Array.isArray(e))return c(e)}(b=er.filterTargetKey.map(function(e){return d({},e,et[e])}))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(b)||g(b)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())):et[er.filterTargetKey]||ei,default:!0,fields:(null==Q?void 0:Q.filter(function(e){return eu.find(function(t){return e.includes(t.name)})}))||[],collection:eo||ea},ey="Action.Link"===F["x-component"],eb=function(){var t;return(t=function(){var t,n,r,i,o;return function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:s(0)}),a(l,"throw",{value:s(1)}),a(l,"return",{value:s(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function s(a){return function(s){var c=[a,s];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:$(!0),l.label=1;case 1:return l.trys.push([1,7,,8]),[4,(0,e.fetchTemplateData)(M,em,ef)];case 2:return t=l.sent(),[4,J.create({values:p({},t)})];case 3:if(l.sent(),_.success(ec("Saved successfully")),"form"!==H)return[3,4];return null==V||null==(r=V.service)||null==(n=r.refresh)||n.call(r),[3,6];case 4:return[4,null==N||null==(i=N.refresh)?void 0:i.call(N)];case 5:l.sent(),l.label=6;case 6:return $(!1),[3,8];case 7:return o=l.sent(),$(!1),console.error(o),[3,8];case 8:return[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function l(e){u(o,r,i,l,a,"next",e)}function a(e){u(o,r,i,l,a,"throw",e)}l(void 0)})})()},ev=function(){T||K||!ep||((null==Q?void 0:Q.length)>0?"quickDulicate"===Z?eb():q(!0):_.error(ec("Please configure the duplicate fields")))};return a().createElement("div",{ref:h,className:(0,t.cx)(w,d({},(0,t.css)(O()),ey))},a().createElement(e.FormBlockContext.Provider,{value:f(p({},ed),{duplicateData:{display:!1,enabled:!0,defaultTemplate:em}})},a().createElement("div",null,ey?a().createElement("a",{className:"nb-action-link",role:i.role,"aria-label":i["aria-label"],disabled:T,style:f(p({},P.style),{opacity:I&&(null==C||null==(S=C.data)?void 0:S.hidden)&&.1,cursor:K?"not-allowed":"pointer",position:"relative"}),onClick:ev},a().createElement(r.Tooltip,{title:E},a().createElement("span",{style:{marginRight:3}},j&&"string"==typeof j?a().createElement(e.Icon,{type:j}):j)),k?A[1]:K?ec("Duplicating"):A||ec("Duplicate")):a().createElement(r.Button,f(p({role:i.role,"aria-label":i["aria-label"],disabled:T,style:{opacity:I&&(null==C||null==(x=C.data)?void 0:x.hidden)&&.1}},D),{onClick:ev}),K?ec("Duplicating"):A||ec("Duplicate")),a().createElement(e.TabsContextProvider,null,a().createElement(e.CollectionProvider_deprecated,{name:ee||ea},a().createElement(e.RecordProvider,{record:f(p({},en),{__collection:ee||eo})},a().createElement(e.ActionContextProvider,{value:f(p({},el),{visible:z,setVisible:q,formValueChanged:W,setFormValueChanged:G})},a().createElement(e.PopupSettingsProvider,{enableURL:!1},a().createElement(e.RefreshComponentProvider,{refresh:o().noop},a().createElement(e.NocoBaseRecursionField,{schema:F,basePath:C.address,onlyRenderProperties:!0}))))))))))}),k=h(452);function D(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 A(e,t,n,r,i,o,l){try{var a=e[o](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,i)}function j(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function l(e){A(o,r,i,l,a,"next",e)}function a(e){A(o,r,i,l,a,"throw",e)}l(void 0)})}}function E(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(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){E(e,t,n[t])})}return e}function _(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function C(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:s(0)}),a(l,"throw",{value:s(1)}),a(l,"return",{value:s(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function s(a){return function(s){var c=[a,s];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var F=(0,n.connect)(r.Tree,(0,n.mapProps)(function(e,t){(0,l.useEffect)(function(){t.value=e.defaultCheckedKeys||[]},[]);var r,i=function(e){if(Array.isArray(e))return e}(r=(0,l.useState)(e.defaultCheckedKeys||[]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],o=!0,l=!1;try{for(r=r.call(e);!(o=(t=r.next()).done)&&(i.push(t.value),2!==i.length);o=!0);}catch(e){l=!0,n=e}finally{try{o||null==r.return||r.return()}finally{if(l)throw n}}return i}}(r)||function(e){if(e){if("string"==typeof e)return D(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return D(e,2)}}(r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=i[0],a=i[1],s=function(e){a(e),t.value=e};t.onCheck=s;var c=(0,n.useForm)();return _(P({},e),{checkedKeys:o,onCheck:s,treeData:null==e?void 0:e.treeData.map(function(e){if("quickDulicate"===c.values.duplicateMode){var t,n=null==e||null==(t=e.children)?void 0:t.map(function(e){return _(P({},e),{disabled:!1})});return _(P({},e),{disabled:!1,children:n})}return e})})})),M=function(e,t){for(var n=0;n<(null==e?void 0:e.length);n++){var r=e[n],i=r.children,o=function(e,t){if(null==e)return{};var n,r,i,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(i=0,n=Reflect.ownKeys(Object(e));i<n.length;i++)r=n[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,t){if(null==e)return{};var n,r,i={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)n=o[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,t),Object.getOwnPropertySymbols)for(i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r=n[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(r,["children"]);t.push(o.key),i&&M(i,t)}return t},T=function(e){return e.reduceProperties(function(e,t){return"FormBlockProvider"===t["x-decorator"]?t:T(t)},null)},I=[{name:"Customize",Component:function(e){return e.children},children:[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps:function(){return(0,e.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:e.SchemaSettingsLinkageRules,useComponentProps:function(){var t=(0,e.useCollection_deprecated)().name;return _(P({},(0,e.useSchemaToolbar)().linkageRulesProps),{collectionName:t})}},{name:"duplicationMode",Component:function(){var t,r,o,c,u=(0,e.useDesignable)().dn,d=(0,s.useTranslation)().t,p=(0,n.useField)(),h=(0,n.useFieldSchema)(),f=(0,e.useCollection_deprecated)().name,m=(0,e.useCollectionState)(f),y=m.collectionList,b=m.getEnableFieldTree,v=m.getOnLoadData,g=m.getOnCheck,S=(0,i.cloneDeep)((null==(t=h["x-component-props"])?void 0:t.duplicateFields)||[]),O=(0,e.useRecord)(),w=(0,l.useCallback)(function(e,t,n){n.query("duplicateFields").take(function(r){r.componentProps.treeData=e,r.componentProps.defaultCheckedKeys=t,r.setInitialValue(t),null==r||r.onCheck(t),n.setValues(_(P({},n.values),{treeData:e}))})},[]);return a().createElement(e.SchemaSettingsModalItem,{title:d("Duplicate mode"),components:{Tree:F},scope:{getEnableFieldTree:b,collectionName:(null==(r=h["x-component-props"])?void 0:r.duplicateCollection)||(null==O?void 0:O.__collection)||f,currentCollection:(null==O?void 0:O.__collection)||f,getOnLoadData:v,getOnCheck:g,treeData:null==(o=h["x-component-props"])?void 0:o.treeData,duplicateValues:S,onFieldInputValueChange:k.onFieldInputValueChange},schema:{type:"object",title:d("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:d("Duplicate mode"),default:(null==(c=h["x-component-props"])?void 0:c.duplicateMode)||"quickDulicate",enum:[{value:"quickDulicate",label:'{{t("Direct duplicate")}}'},{value:"continueduplicate",label:'{{t("Copy into the form and continue to fill in")}}'}]},collection:{type:"string",title:'{{ t("Target collection") }}',required:!0,description:d("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":y.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:y},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{disabled:'{{ $deps[0]==="quickDulicate" }}',value:'{{ $deps[0]==="quickDulicate"? currentCollection:collectionName }}'}}}]},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:function(){var t,n=(0,l.useMemo)(function(){return T(h)},[h]);return(0,e.useSyncFromForm)(n,(null==(t=h["x-component-props"])?void 0:t.duplicateCollection)||(null==O?void 0:O.__collection)||f,w)}},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]!=="quickDulicate" }}'}}}]},selectAll:{type:"void",title:'{{ t("Select all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]==="quickDulicate"}}'}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:function(){var e;return e=(0,n.useForm)(),{run:function(){return j(function(){return C(this,function(t){return e.query("duplicateFields").take(function(e){var t,n=M(e.componentProps.treeData,[]);e.componentProps.defaultCheckedKeys=n,e.setInitialValue(n),null==e||null==(t=e.onCheck)||t.call(e,n)}),[2]})})()}}}}},unselectAll:{type:"void",title:'{{ t("UnSelect all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode",".duplicateFields"],fulfill:{state:{visible:"{{ $deps[0]===\"quickDulicate\"&&$form.getValuesIn('duplicateFields').length>0 }}"}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200,marginRight:"10px"},useAction:function(){var e;return e=(0,n.useForm)(),{run:function(){return j(function(){return C(this,function(t){return e.query("duplicateFields").take(function(e){e.componentProps.defaultCheckedKeys=[],e.setInitialValue([]),null==e||e.onCheck([])}),[2]})})()}}}}},duplicateFields:{type:"array",title:'{{ t("Data fields") }}',required:!0,description:d("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":F,"x-component-props":{defaultCheckedKeys:S,treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection",".duplicateMode"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self,treeData) }}"}}}}]}}},onSubmit:function(e){var t,n,r=e.duplicateMode,i=e.collection,o=e.duplicateFields,l=e.treeData,a=Array.isArray(o)?o:o.checked||[];p.componentProps.duplicateMode=r,p.componentProps.duplicateFields=a,h["x-component-props"]=h["x-component-props"]||{},h["x-component-props"].duplicateMode=r,h["x-component-props"].duplicateFields=a,h["x-component-props"].duplicateCollection=i,h["x-component-props"].treeData=l||(null==(t=p.componentProps)?void 0:t.treeData),u.emit("patch",{schema:(E(n={},"x-uid",h["x-uid"]),E(n,"x-component-props",P({},h["x-component-props"])),n)}),u.refresh()}})},useVisible:function(){return"duplicate"===(0,n.useFieldSchema)()["x-action"]}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps:function(){var t=(0,e.useOpenModeContext)().hideOpenMode,n=(0,s.useTranslation)().t;return{openMode:!t,openSize:!t,modeOptions:(0,l.useMemo)(function(){return[{label:n("Drawer"),value:"drawer"},{label:n("Dialog"),value:"modal"}]},[n])}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps:function(){return(0,e.useSchemaToolbar)().removeButtonProps}}]}],R=new e.SchemaSettings({name:"ActionSettings:duplicate",items:I}),z=new e.SchemaSettings({name:"actionSettings:duplicate",items:I}),q=function(t){return a().createElement(e.ACLActionProvider,null,t.children)},L=function(t){var n,r,i={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"DuplicateActionDecorator","x-component-props":{openMode:(0,e.useOpenModeContext)().defaultOpenMode,component:"DuplicateAction"},properties:{drawer:{type:"void",title:'{{ t("Duplicate") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}}}};return a().createElement(e.ActionInitializerItem,(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t),r=r={schema:i},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))},K=function(t){return a().createElement(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:L,DuplicateAction:x}},t.children)},$=h(694),B=h(485),W=h(625),G="action-duplicate",U={hasSubscribers:!1},N="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,V=new Set,H="object"==typeof process&&process?process:{},J=(Symbol("type"),e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e)),X=e=>J(e)?e<=256?Uint8Array:e<=65536?Uint16Array:e<=0x100000000?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Q:null:null,Q=class extends Array{constructor(e){super(e),this.fill(0)}},Y=class e{heap;length;static #e=!1;static create(t){let n=X(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Z=class e{#e;#t;#n;#r;#i;#o;#l;#a;get perf(){return this.#a}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#c;#u;#d;#p;#h;#f;#m;#y;#b;#v;#g;#S;#O;#w;#x;#k;#D;#A;static unsafeExposeInternals(e){return{starts:e.#S,ttls:e.#O,autopurgeTimers:e.#w,sizes:e.#g,keyMap:e.#u,keyList:e.#d,valList:e.#p,next:e.#h,prev:e.#f,get head(){return e.#m},get tail(){return e.#y},free:e.#b,isBackgroundFetch:t=>e.#j(t),backgroundFetch:(t,n,r,i)=>e.#E(t,n,r,i),moveToTail:t=>e.#P(t),indexes:t=>e.#_(t),rindexes:t=>e.#C(t),isStale:t=>e.#F(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#c}get size(){return this.#s}get fetchMethod(){return this.#o}get memoMethod(){return this.#l}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:l,updateAgeOnHas:a,allowStale:s,dispose:c,onInsert:u,disposeAfter:d,noDisposeOnSet:p,noUpdateTTL:h,maxSize:f=0,maxEntrySize:m=0,sizeCalculation:y,fetchMethod:b,memoMethod:v,noDeleteOnFetchRejection:g,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:w,ignoreFetchAbort:x,perf:k}=t;if(void 0!==k&&"function"!=typeof k?.now)throw TypeError("perf option must have a now() method if specified");if(this.#a=k??N,0!==n&&!J(n))throw TypeError("max option must be a nonnegative integer");let D=n?X(n):Array;if(!D)throw Error("invalid max value: "+n);if(this.#e=n,this.#t=f,this.maxEntrySize=m||this.#t,this.sizeCalculation=y,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw TypeError("sizeCalculation set to non-function")}if(void 0!==v&&"function"!=typeof v)throw TypeError("memoMethod must be a function if defined");if(this.#l=v,void 0!==b&&"function"!=typeof b)throw TypeError("fetchMethod must be a function if specified");if(this.#o=b,this.#k=!!b,this.#u=new Map,this.#d=Array.from({length:n}).fill(void 0),this.#p=Array.from({length:n}).fill(void 0),this.#h=new D(n),this.#f=new D(n),this.#m=0,this.#y=0,this.#b=Y.create(n),this.#s=0,this.#c=0,"function"==typeof c&&(this.#n=c),"function"==typeof u&&(this.#r=u),"function"==typeof d?(this.#i=d,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#x=!!this.#n,this.#A=!!this.#r,this.#D=!!this.#i,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!g,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!x,0!==this.maxEntrySize){if(0!==this.#t&&!J(this.#t))throw TypeError("maxSize must be a positive integer if specified");if(!J(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#M()}if(this.allowStale=!!s,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!l,this.updateAgeOnHas=!!a,this.ttlResolution=J(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!J(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#T()}if(0===this.#e&&0===this.ttl&&0===this.#t)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t="LRU_CACHE_UNBOUNDED";(e=>!V.has(e))(t)&&(V.add(t),((e,t,n,r)=>{"function"==typeof H.emitWarning?H.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)})("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#T(){let e=new Q(this.#e),t=new Q(this.#e);this.#O=e,this.#S=t;let n=this.ttlAutopurge?Array.from({length:this.#e}):void 0;this.#w=n,this.#I=(n,i,o=this.#a.now())=>{t[n]=0!==i?o:0,e[n]=i,r(n,i)},this.#R=n=>{t[n]=0!==e[n]?this.#a.now():0,r(n,e[n])};let r=this.ttlAutopurge?(e,t)=>{if(n?.[e]&&(clearTimeout(n[e]),n[e]=void 0),t&&0!==t&&n){let r=setTimeout(()=>{this.#F(e)&&this.#z(this.#d[e],"expire")},t+1);r.unref&&r.unref(),n[e]=r}}:()=>{};this.#q=(n,r)=>{if(e[r]){let l=e[r],a=t[r];if(!l||!a)return;n.ttl=l,n.start=a,n.now=i||o();let s=n.now-a;n.remainingTTL=l-s}};let i=0,o=()=>{let e=this.#a.now();if(this.ttlResolution>0){i=e;let t=setTimeout(()=>i=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=n=>{let r=this.#u.get(n);if(void 0===r)return 0;let l=e[r],a=t[r];return l&&a?l-((i||o())-a):1/0},this.#F=n=>{let r=t[n],l=e[n];return!!l&&!!r&&(i||o())-r>l}}#R=()=>{};#q=()=>{};#I=()=>{};#F=()=>!1;#M(){let e=new Q(this.#e);this.#c=0,this.#g=e,this.#L=t=>{this.#c-=e[t],e[t]=0},this.#K=(e,t,n,r)=>{if(this.#j(t))return 0;if(!J(n))if(r){if("function"!=typeof r)throw TypeError("sizeCalculation must be a function");if(!J(n=r(t,e)))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.#$=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#c>n;)this.#B(!0)}this.#c+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#c)}}#L=e=>{};#$=(e,t,n)=>{};#K=(e,t,n,r)=>{if(n||r)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#_({allowStale:e=this.allowStale}={}){if(this.#s)for(let t=this.#y;this.#W(t)&&((e||!this.#F(t))&&(yield t),t!==this.#m);)t=this.#f[t]}*#C({allowStale:e=this.allowStale}={}){if(this.#s)for(let t=this.#m;this.#W(t)&&((e||!this.#F(t))&&(yield t),t!==this.#y);)t=this.#h[t]}#W(e){return void 0!==e&&this.#u.get(this.#d[e])===e}*entries(){for(let e of this.#_())void 0===this.#p[e]||void 0===this.#d[e]||this.#j(this.#p[e])||(yield[this.#d[e],this.#p[e]])}*rentries(){for(let e of this.#C())void 0===this.#p[e]||void 0===this.#d[e]||this.#j(this.#p[e])||(yield[this.#d[e],this.#p[e]])}*keys(){for(let e of this.#_()){let t=this.#d[e];void 0===t||this.#j(this.#p[e])||(yield t)}}*rkeys(){for(let e of this.#C()){let t=this.#d[e];void 0===t||this.#j(this.#p[e])||(yield t)}}*values(){for(let e of this.#_())void 0===this.#p[e]||this.#j(this.#p[e])||(yield this.#p[e])}*rvalues(){for(let e of this.#C())void 0===this.#p[e]||this.#j(this.#p[e])||(yield this.#p[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let n of this.#_()){let r=this.#p[n],i=this.#j(r)?r.__staleWhileFetching:r;if(void 0!==i&&e(i,this.#d[n],this))return this.#G(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#_()){let r=this.#p[n],i=this.#j(r)?r.__staleWhileFetching:r;void 0!==i&&e.call(t,i,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#C()){let r=this.#p[n],i=this.#j(r)?r.__staleWhileFetching:r;void 0!==i&&e.call(t,i,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#C({allowStale:!0}))this.#F(t)&&(this.#z(this.#d[t],"expire"),e=!0);return e}info(e){let t=this.#u.get(e);if(void 0===t)return;let n=this.#p[t],r=this.#j(n)?n.__staleWhileFetching:n;if(void 0===r)return;let i={value:r};if(this.#O&&this.#S){let e=this.#O[t],n=this.#S[t];e&&n&&(i.ttl=e-(this.#a.now()-n),i.start=Date.now())}return this.#g&&(i.size=this.#g[t]),i}dump(){let e=[];for(let t of this.#_({allowStale:!0})){let n=this.#d[t],r=this.#p[t],i=this.#j(r)?r.__staleWhileFetching:r;if(void 0===i||void 0===n)continue;let o={value:i};if(this.#O&&this.#S){o.ttl=this.#O[t];let e=this.#a.now()-this.#S[t];o.start=Math.floor(Date.now()-e)}this.#g&&(o.size=this.#g[t]),e.unshift([n,o])}return e}load(e){for(let[t,n]of(this.clear(),e)){if(n.start){let e=Date.now()-n.start;n.start=this.#a.now()-e}this.#U(t,n.value,n)}}set(e,t,n={}){let{status:r=U.hasSubscribers?{}:void 0}=n;n.status=r,r&&(r.op="set",r.key=e,void 0!==t&&(r.value=t));let i=this.#U(e,t,n);return r&&U.hasSubscribers&&U.publish(r),i}#U(e,t,n={}){let{ttl:r=this.ttl,start:i,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:a}=n;if(void 0===t)return a&&(a.set="deleted"),this.delete(e),this;let{noUpdateTTL:s=this.noUpdateTTL}=n;a&&!this.#j(t)&&(a.value=t);let c=this.#K(e,t,n.size||0,l,a);if(this.maxEntrySize&&c>this.maxEntrySize)return this.#z(e,"set"),a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this;let u=0===this.#s?void 0:this.#u.get(e);if(void 0===u)u=0===this.#s?this.#y:0!==this.#b.length?this.#b.pop():this.#s===this.#e?this.#B(!1):this.#s,this.#d[u]=e,this.#p[u]=t,this.#u.set(e,u),this.#h[this.#y]=u,this.#f[u]=this.#y,this.#y=u,this.#s++,this.#$(u,c,a),a&&(a.set="add"),s=!1,this.#A&&this.#r?.(t,e,"add");else{this.#P(u);let n=this.#p[u];if(t!==n){if(this.#k&&this.#j(n)){n.__abortController.abort(Error("replaced"));let{__staleWhileFetching:t}=n;void 0!==t&&!o&&(this.#x&&this.#n?.(t,e,"set"),this.#D&&this.#v?.push([t,e,"set"]))}else o||(this.#x&&this.#n?.(n,e,"set"),this.#D&&this.#v?.push([n,e,"set"]));if(this.#L(u),this.#$(u,c,a),this.#p[u]=t,a){a.set="replace";let e=n&&this.#j(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update");this.#A&&this.onInsert?.(t,e,t===n?"update":"replace")}if(0===r||this.#O||this.#T(),this.#O&&(s||this.#I(u,r,i),a&&this.#q(a,u)),!o&&this.#D&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return this}pop(){try{for(;this.#s;){let e=this.#p[this.#m];if(this.#B(!0),this.#j(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#D&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}}#B(e){let t=this.#m,n=this.#d[t],r=this.#p[t];return this.#k&&this.#j(r)?r.__abortController.abort(Error("evicted")):(this.#x||this.#D)&&(this.#x&&this.#n?.(r,n,"evict"),this.#D&&this.#v?.push([r,n,"evict"])),this.#L(t),this.#w?.[t]&&(clearTimeout(this.#w[t]),this.#w[t]=void 0),e&&(this.#d[t]=void 0,this.#p[t]=void 0,this.#b.push(t)),1===this.#s?(this.#m=this.#y=0,this.#b.length=0):this.#m=this.#h[t],this.#u.delete(n),this.#s--,t}has(e,t={}){let{status:n=U.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="has",n.key=e);let r=this.#N(e,t);return U.hasSubscribers&&U.publish(n),r}#N(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#u.get(e);if(void 0!==i){let e=this.#p[i];if(this.#j(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#F(i))return n&&this.#R(i),r&&(r.has="hit",this.#q(r,i)),!0;r&&(r.has="stale",this.#q(r,i))}else r&&(r.has="miss");return!1}peek(e,t={}){let{status:n=U.hasSubscribers||U.hasSubscribers?{}:void 0}=t;n&&(n.op="peek",n.key=e),t.status=n;let r=this.#V(e,t);return U.hasSubscribers&&U.publish(n),r}#V(e,t){let{status:n,allowStale:r=this.allowStale}=t,i=this.#u.get(e);if(void 0===i||!r&&this.#F(i)){n&&(n.peek=void 0===i?"miss":"stale");return}let o=this.#p[i],l=this.#j(o)?o.__staleWhileFetching:o;return n&&(void 0!==l?(n.peek="hit",n.value=l):n.peek="miss"),l}#E(e,t,n,r){let i=void 0===t?void 0:this.#p[t];if(this.#j(i))return i;let o=new AbortController,{signal:l}=n;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let a={signal:o.signal,options:n,context:r},s=(r,i=!1)=>{let{aborted:l}=o.signal,s=n.ignoreFetchAbort&&void 0!==r,u=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&void 0!==r);if(n.status&&(l&&!i?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,s&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),l&&!s&&!i)return c(o.signal.reason,u);let p=this.#p[t];return(p===d||void 0===p&&s&&i)&&(void 0===r?void 0!==d.__staleWhileFetching?this.#p[t]=d.__staleWhileFetching:this.#z(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.#U(e,r,a.options))),r},c=(r,i)=>{let{aborted:l}=o.signal,a=l&&n.allowStaleOnFetchAbort,s=a||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection;if(this.#p[t]===d&&(c&&(i||void 0!==d.__staleWhileFetching)?a||(this.#p[t]=d.__staleWhileFetching):this.#z(e,"fetch")),s)return n.status&&void 0!==d.__staleWhileFetching&&(n.status.returnedStale=!0),d.__staleWhileFetching;if(d.__returned===d)throw r},u=(t,r)=>{let l=this.#o?.(e,i,a);l&&l instanceof Promise&&l.then(e=>t(void 0===e?void 0:e),r),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>s(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let d=new Promise(u).then(s,e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),c(e,!1))),p=Object.assign(d,{__abortController:o,__staleWhileFetching:i,__returned:void 0});return void 0===t?(this.#U(e,p,{...a.options,status:void 0}),t=this.#u.get(e)):this.#p[t]=p,p}#j(e){return!!this.#k&&!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof AbortController}fetch(e,t={}){let n=U.hasSubscribers,{status:r=U.hasSubscribers||U.hasSubscribers?{}:void 0}=t;t.status=r,r&&t.context&&(r.context=t.context);let i=this.#H(e,t);return r&&(U.hasSubscribers||U.hasSubscribers)&&n&&(r.trace=!0,U.tracePromise(()=>i,r).catch(()=>{})),i}async #H(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:a=0,sizeCalculation:s=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:f,forceRefresh:m=!1,status:y,signal:b}=t;if(y&&(y.op="fetch",y.key=e,m&&(y.forceRefresh=!0)),!this.#k)return y&&(y.fetch="get"),this.#G(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:y});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:l,size:a,sizeCalculation:s,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:h,ignoreFetchAbort:p,status:y,signal:b},g=this.#u.get(e);if(void 0===g){y&&(y.fetch="miss");let t=this.#E(e,g,v,f);return t.__returned=t}{let t=this.#p[g];if(this.#j(t)){let e=n&&void 0!==t.__staleWhileFetching;return y&&(y.fetch="inflight",e&&(y.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#F(g);if(!m&&!i)return y&&(y.fetch="hit"),this.#P(g),r&&this.#R(g),y&&this.#q(y,g),t;let o=this.#E(e,g,v,f),l=void 0!==o.__staleWhileFetching&&n;return y&&(y.fetch=i?"stale":"refresh",l&&i&&(y.returnedStale=!0)),l?o.__staleWhileFetching:o.__returned=o}}forceFetch(e,t={}){let n=U.hasSubscribers,{status:r=U.hasSubscribers||U.hasSubscribers?{}:void 0}=t;t.status=r,r&&t.context&&(r.context=t.context);let i=this.#J(e,t);return r&&(U.hasSubscribers||U.hasSubscribers)&&n&&(r.trace=!0,U.tracePromise(()=>i,r).catch(()=>{})),i}async #J(e,t={}){let n=await this.#H(e,t);if(void 0===n)throw Error("fetch() returned undefined");return n}memo(e,t={}){let{status:n=U.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="memo",n.key=e,t.context&&(n.context=t.context));let r=this.#X(e,t);return n&&(n.value=r),U.hasSubscribers&&U.publish(n),r}#X(e,t={}){let n=this.#l;if(!n)throw Error("no memoMethod provided to constructor");let{context:r,status:i,forceRefresh:o,...l}=t;i&&o&&(i.forceRefresh=!0);let a=this.#G(e,l),s=o||void 0===a;if(i&&(i.memo=s?"miss":"hit",s||(i.value=a)),!s)return a;let c=n(e,a,{options:l,context:r});return i&&(i.value=c),this.#U(e,c,l),c}get(e,t={}){let{status:n=U.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="get",n.key=e);let r=this.#G(e,t);return n&&(void 0!==r&&(n.value=r),U.hasSubscribers&&U.publish(n)),r}#G(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=t,l=this.#u.get(e);if(void 0===l){o&&(o.get="miss");return}let a=this.#p[l],s=this.#j(a);return o&&this.#q(o,l),this.#F(l)?s?(o&&(o.get="stale-fetching"),n&&void 0!==a.__staleWhileFetching?(o&&(o.returnedStale=!0),a.__staleWhileFetching):void 0):(i||this.#z(e,"expire"),o&&(o.get="stale"),n?(o&&(o.returnedStale=!0),a):void 0):(o&&(o.get=s?"fetching":"hit"),this.#P(l),r&&this.#R(l),s?a.__staleWhileFetching:a)}#Q(e,t){this.#f[t]=e,this.#h[e]=t}#P(e){e!==this.#y&&(e===this.#m?this.#m=this.#h[e]:this.#Q(this.#f[e],this.#h[e]),this.#Q(this.#y,e),this.#y=e)}delete(e){return this.#z(e,"delete")}#z(e,t){U.hasSubscribers&&U.publish({op:"delete",delete:t,key:e});let n=!1;if(0!==this.#s){let r=this.#u.get(e);if(void 0!==r)if(this.#w?.[r]&&(clearTimeout(this.#w?.[r]),this.#w[r]=void 0),n=!0,1===this.#s)this.#Y(t);else{this.#L(r);let n=this.#p[r];if(this.#j(n)?n.__abortController.abort(Error("deleted")):(this.#x||this.#D)&&(this.#x&&this.#n?.(n,e,t),this.#D&&this.#v?.push([n,e,t])),this.#u.delete(e),this.#d[r]=void 0,this.#p[r]=void 0,r===this.#y)this.#y=this.#f[r];else if(r===this.#m)this.#m=this.#h[r];else{let e=this.#f[r];this.#h[e]=this.#h[r];let t=this.#h[r];this.#f[t]=this.#f[r]}this.#s--,this.#b.push(r)}}if(this.#D&&this.#v?.length){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return n}clear(){return this.#Y("delete")}#Y(e){for(let t of this.#C({allowStale:!0})){let n=this.#p[t];if(this.#j(n))n.__abortController.abort(Error("deleted"));else{let r=this.#d[t];this.#x&&this.#n?.(n,r,e),this.#D&&this.#v?.push([n,r,e])}}if(this.#u.clear(),this.#p.fill(void 0),this.#d.fill(void 0),this.#O&&this.#S){for(let e of(this.#O.fill(0),this.#S.fill(0),this.#w??[]))void 0!==e&&clearTimeout(e);this.#w?.fill(void 0)}if(this.#g&&this.#g.fill(0),this.#m=0,this.#y=0,this.#b.length=0,this.#c=0,this.#s=0,this.#D&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}};function ee(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 et(e,t,n,r,i,o,l){try{var a=e[o](l),s=a.value}catch(e){n(e);return}a.done?t(s):Promise.resolve(s).then(r,i)}function en(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function er(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function ei(e){return function(e){if(Array.isArray(e))return ee(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return ee(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ee(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eo=function(e){var t=e.tag,n=e.type,i=e.displayType;return a().createElement("div",null,a().createElement(r.Tag,{color:{reference:"blue",duplicate:"green",preloading:"cyan"}[n]},a().createElement("span",null,t)," ",void 0===i||i?"(".concat({reference:"Reference",duplicate:"Duplicate",preloading:"Preloading"}[n],")"):""))},el=["sort","createdById","createdBy","createdAt","updatedById","updatedBy","updatedAt","password","sequence"];function ea(e){var t=e.node,n=e.traverseAssociations,r=e.traverseFields,i=e.systemKeys,o=e.dataSource,l=e.setDataSource,a=function(e,t){for(var n=ei(e);n.length;){var r=n.shift();if(r.key===t.key)return r;r.children&&n.push.apply(n,ei(r.children))}}(o,t),s=[];return["belongsTo","belongsToMany"].includes(t.field.type)&&(null==t?void 0:t.type)==="reference"?s=n(t.field.target,{exclude:i,prefix:t.key,maxDepth:1}):(["hasOne","hasMany"].includes(t.field.type)||(null==t?void 0:t.type)==="duplicate")&&(s=r(t.field.target,{exclude:["id"].concat(ei(i.filter(function(e){return"sort"!==e}))),prefix:t.key,maxDepth:1})),s.length?a.children=s:a.isLeaf=!0,l(ei(o)),s}var es=function(e,t,n){arguments.length>3&&void 0!==arguments[3]&&arguments[3];var r=function(o,l){var s=l.exclude,c=void 0===s?[]:s,u=l.depth,d=void 0===u?0:u,p=l.maxDepth,h=l.prefix,f=void 0===h?"":h;return d>p?[]:ei(e.getCollection(n,o).fields.values()).map(function(e){if(!c.includes(e.name)&&e.interface&&!(0===d&&["sort","password","sequence"].includes(e.type))){var n,o={type:"duplicate",tag:t(null==(n=e.uiSchema)?void 0:n.title)||e.name},l=er(en({},o),{role:"button",title:a().createElement(eo,er(en({},o),{displayType:!0})),key:f?"".concat(f,".").concat(e.name):e.name,isLeaf:!0,field:e});return["belongsTo","belongsToMany"].includes(e.type)?(o.type="reference",l.type="reference",l.title=a().createElement(eo,er(en({},o),{type:"reference",displayType:!0})),l.isLeaf=!1,l.children=i(e.target,{depth:d+1,maxDepth:p,prefix:l.key,exclude:el})):["hasOne","hasMany"].includes(e.type)&&(l.isLeaf=!1,l.children=r(e.target,{depth:d+1,maxDepth:p,prefix:l.key,exclude:["id"].concat(ei(el.filter(function(e){return"sort"!==e})))})),l}}).filter(Boolean)},i=function(r,o){var l,s=o.prefix,c=o.maxDepth,u=o.depth,d=void 0===u?0:u,p=o.exclude,h=void 0===p?[]:p;return d>c||!e.getCollection(n,r)?[]:ei((null==(l=e.getCollection(n,r))?void 0:l.fields.values())||[]).map(function(e){if(e.target&&e.interface&&!h.includes(e.name)){var n,r={type:"preloading",tag:t(null==(n=e.uiSchema)?void 0:n.title)||e.name},o=s?"".concat(s,".").concat(e.name):e.name;return{role:"button",title:a().createElement(eo,er(en({},r),{displayType:!0})),key:o,isLeaf:!1,field:e,children:i(e.target,{prefix:o,depth:d+1,maxDepth:c,exclude:h})}}}).filter(Boolean)};return{getEnableFieldTree:function(e){try{return r(e,{exclude:["id"].concat(ei(el)),maxDepth:1})}catch(e){return console.error(e),[]}},getOnLoadData:function(e,t){return function(n){return new Promise(function(o){if(n.children.length)return n.children.forEach(function(n){ea({node:n,traverseAssociations:i,traverseFields:r,systemKeys:el,dataSource:e,setDataSource:t})}),o(void 0);ea({node:n,traverseAssociations:i,traverseFields:r,systemKeys:el,dataSource:e,setDataSource:t}),o(void 0)})}},getOnCheck:function(e){return function(t){e.value=t}}}},ec=function(e,t,n,r,i){var o,l=(o=new Z({max:50}),function(r,i,c){var u=i.exclude,d=void 0===u?[]:u,p=i.depth,h=void 0===p?0:p,f=i.maxDepth,m=i.prefix,y=void 0===m?"":m,b=i.disabled,v=void 0!==b&&b;if(h>f)return[];var g=Array.isArray(c)?c:[],S=(e.getCollection(n,r)?ei(e.getCollection(n,r).fields.values()):[]).map(function(e){if(!d.includes(e.name)&&e.interface&&!["sort","password","sequence"].includes(e.type)){var n,r={type:"duplicate",tag:t(null==(n=e.uiSchema)?void 0:n.title)||e.name},i=er(en({},r),{title:a().createElement(eo,r),key:y?"".concat(y,".").concat(e.name):e.name,isLeaf:!0,field:e,disabled:v}),o=g.find(function(e){return(null==e?void 0:e.name)===i.key});if(!["belongsTo","belongsToMany"].includes(e.type)||o&&(null==o?void 0:o.updateAssociation)){if(["hasOne","hasMany"].includes(e.type)||(null==o?void 0:o.updateAssociation)){var c=!1;!["has