@nocobase/client 2.1.0-alpha.19 → 2.1.0-alpha.20
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.
- package/es/index.mjs +2 -2
- package/lib/index.js +3 -3
- package/package.json +6 -6
package/es/index.mjs
CHANGED
|
@@ -171,7 +171,7 @@ if (!rows.length) {
|
|
|
171
171
|
} else {
|
|
172
172
|
ctx.message.success('已选择 ' + rows.length + ' 条');
|
|
173
173
|
}
|
|
174
|
-
`}),async handler(e,t){let{code:l,version:o}=o4(e,t),n=(0,i.createSafeNavigator)();await e.runjs(l,{window:(0,i.createSafeWindow)({navigator:n}),document:(0,i.createSafeDocument)(),navigator:n},{version:o})}}}});let o9="__saveStepParamsWithSubModels";function o8(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error("[saveStepParamsWithSubModels] model is not an object");e[o9]=!0}async function o3(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error("[saveStepParamsWithSubModels] model is not an object");let l=e;if(!0!==l[o9])return await t();if("function"!=typeof l.save)throw Error("[saveStepParamsWithSubModels] model.save is not a function");try{return await l.save()}finally{delete l[o9]}}function ne(e,t){let l=(t,l,o)=>{var n,r,i;return!l||(null==e||null==(i=e.app)||null==(r=i.jsonLogic)||null==(n=r.apply)?void 0:n.call(r,{[l]:[t,o]}))};try{return(0,d.evaluateConditions)((0,d.removeInvalidFilterItems)(t),l)}catch{return!1}}function nt(e){let t=[],l=0,o=e.length,n=()=>{let n=l;for(;l<o&&"."!==e[l]&&"["!==e[l];)l++;let r=e.slice(n,l);r&&t.push(r)};for(;l<o;){let r=e[l];if("."===r){l++;continue}if("["===r){let n=++l;for(;l<o&&"]"!==e[l];)l++;let r=e.slice(n,l);l++,/^\d+$/.test(r)?t.push(Number(r)):r&&t.push({placeholder:r});continue}n()}return t}function nl(e){let t=Array.isArray(e)?e:[],l=[];for(let e of t){if("string"!=typeof e)continue;let[t,o]=e.split(":"),n=Number(o);!t||Number.isNaN(n)||l.push({name:t,index:n})}return l}function no(e,t){let l=Array.isArray(e)?[...e]:nt(e),o=nl(t),n=[],r=0;for(let e=0;e<l.length;e++){let t=l[e];if("object"==typeof t&&t&&"placeholder"in t){let e=n[n.length-1],t="string"==typeof e?e:void 0;if(!t)return null;for(;r<o.length&&o[r].name!==t;)r++;if(r>=o.length)return null;n.push(o[r].index),r++;continue}if(n.push(t),"string"==typeof t&&r<o.length&&o[r].name===t){let t=l[e+1];"number"==typeof t?r++:"object"==typeof t&&t&&"placeholder"in t||(n.push(o[r].index),r++)}}return n}function nn(e){let t="";for(let l of e){if("number"==typeof l){t+=`[${l}]`;continue}t?t+=`.${l}`:t=l}return t}function nr(e){return nt(e).filter(e=>"object"!=typeof e)}function ni(e){let t=[],l=[];for(let o of e)l.push(o),t.push(nn(l));return t}function na(e){return!!e&&"object"==typeof e&&(Array.isArray(e)||A.default.isPlainObject(e))}function ns(e,t){if(t)for(let l of ni(e))t.deps.add(`fv:${l}`)}function nd(e){let{valuesMirror:t,collector:l,basePath:o,getFormValuesSnapshot:n,getFormValueAtPath:r}=e,i=()=>o.length?A.default.get(t,o):t,a=i(),s=a&&("object"==typeof a||"function"==typeof a)?a:Array.isArray(a)?[]:{},d=e=>nd({valuesMirror:t,basePath:e,collector:l,getFormValuesSnapshot:n,getFormValueAtPath:r});return new Proxy(s,{get(e,a){if("toJSON"===a)return(l&&(l.wildcard=!0),0===o.length)?()=>n():()=>(0,t$.toJS)(i());if("symbol"==typeof a){l&&(l.wildcard=!0);let e=i();return null==e?void 0:e[a]}let s=i();if(null==s)return;if("__raw"===a)return s;if("__proto__"===a||"prototype"===a||"constructor"===a){l&&(l.wildcard=!0);return}let u=Array.isArray(s),c=u&&("number"==typeof a&&Number.isInteger(a)||"string"==typeof a&&/^\d+$/.test(a));if(u&&!c){l&&(l.wildcard=!0);let e=s[a];return"function"==typeof e?e.bind(s):e}let p=[...o,c?Number(a):a];ns(p,l);let m=s[a];if(void 0===m){let e=r(p);A.default.isEqual(e,m)||(A.default.set(t,p,e),m=e)}return null==m||"object"!=typeof m?m:na(m)?d(p):m},ownKeys(){l&&(l.wildcard=!0);let e=i();return e?Reflect.ownKeys(e):[]},getOwnPropertyDescriptor(e,t){let l=i();if(l)return Object.getOwnPropertyDescriptor(l,t)},has(e,t){let l=i();return!!l&&t in l}})}function nu(e,t){try{let l=(0,i.extractUsedVariablePaths)(e)||{};for(let[e,o]of Object.entries(l)){let l=Array.isArray(o)?o:[];for(let o of l.length?l:[""]){if("formValues"===e){if(!o){t.wildcard=!0;continue}let e=nt(String(o)).filter(e=>"object"!=typeof e);ns(e,t);continue}let l=o?`ctx:${e}:${String(o)}`:`ctx:${e}`;t.deps.add(l)}}}catch{}}function nc(e,t){if((0,i.isRunJSValue)(e))try{let l=(0,i.extractUsedVariablePathsFromRunJS)(e.code)||{};for(let[e,o]of Object.entries(l)){let l=Array.isArray(o)?o:[];for(let o of l.length?l:[""]){if("formValues"===e){if(!o){t.wildcard=!0;continue}let e=nt(String(o)).filter(e=>"object"!=typeof e);ns(e,t);continue}let l=o?`ctx:${e}:${String(o)}`:`ctx:${e}`;t.deps.add(l)}}}catch{}}function np(e){let t,l,o,n=()=>{let e=t;e&&(l&&(e.setFieldValue=l),o&&(e.setFieldsValue=o),t=void 0,l=void 0,o=void 0)};return{patch:r=>{if(t===r)return;n();let i="function"==typeof(null==r?void 0:r.setFieldValue)?r.setFieldValue.bind(r):void 0,a="function"==typeof(null==r?void 0:r.setFieldsValue)?r.setFieldsValue.bind(r):void 0;t=r,l=i,o=a,i&&(r.setFieldValue=(t,l)=>{e.isSuppressed()?i(t,l):e.setFormValues(e.getCallerContext(),[{path:t,value:l}],{source:"system"}).catch(()=>void 0)}),a&&(r.setFieldsValue=t=>{e.isSuppressed()?a(t):e.setFormValues(e.getCallerContext(),t,{source:"system"}).catch(()=>void 0)})},restore:n}}let nm=20;function nh(e){return null==e||("string"==typeof e||Array.isArray(e)?0===e.length:!!A.default.isPlainObject(e)&&0===Object.keys(e).length)}function nf(){return`${Date.now()}-${Math.random().toString(16).slice(2)}`}let nv=Symbol("SKIP_RULE_VALUE"),ng=Symbol("UNRESOLVED_ASSOCIATION_IDENTITY"),nx=1e3;class ny{getAssignRuleBlockId(e){return`form-assign:${e}:block`}removeAssignRuleBlockInstance(e){let t=this.getAssignRuleBlockId(e);this.rules.has(t)&&this.removeRule(t)}removeRowGridAssignRuleInstances(e){let t=`form-assign:${e}:`,l=this.getAssignRuleBlockId(e),o=[];for(let[e,i]of this.rules.entries()){var n,r;if(!e.startsWith(t)||e===l)continue;let a=null==i||null==(r=i.rule)||null==(n=r.getContext)?void 0:n.call(r),s=null==a?void 0:a.model;s&&this.isRowGridModel(s)&&o.push(e)}for(let e of o)this.removeRule(e)}hasAnyNonBlockAssignRuleInstance(e){let t=`form-assign:${e}:`,l=this.getAssignRuleBlockId(e);for(let e of this.rules.keys())if(e.startsWith(t)&&e!==l)return!0;return!1}ensureBlockAssignRuleInstancesForTargetPath(e){if(this.options.isDisposed()||!e||!this.shouldCreateBlockLevelAssignRule(e))return;let t=this.assignTemplatesByTargetPath.get(e)||[];if(t.length)for(let l of t){let t=(null==l?void 0:l.__key)?String(l.__key):"";if(!t||this.hasAnyNonBlockAssignRuleInstance(t))continue;let o="default"==((null==l?void 0:l.mode)==="default"?"default":"assign")?"default":"system",n=(null==l?void 0:l.enable)!==!1,r=this.getAssignRuleBlockId(t);if(this.rules.has(r))continue;let i={id:r,source:o,priority:10+(l.__order||0),debounceMs:0,getEnabled:()=>n&&!!e,getTarget:()=>e,getValue:()=>null==l?void 0:l.value,getCondition:()=>null==l?void 0:l.condition,getContext:()=>this.options.getBlockContext()};this.rules.set(r,{rule:i,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(r)}}getCollectionFromContext(e){var t,l;return(null==e?void 0:e.collection)??(null==e||null==(l=e.model)||null==(t=l.context)?void 0:t.collection)}getRootCollection(){let e=this.options.getBlockContext();return this.getCollectionFromContext(e)}shouldCreateBlockLevelAssignRule(e){let t=this.options.getBlockContext(),l=this.getCollectionFromContext(t);if(!(null==l?void 0:l.getField))return!0;let o=nt(e).filter(e=>"object"!=typeof e);if(o.length<=1)return!0;for(let e=0;e<o.length-1;e++){var n,r;let t=o[e];if("string"!=typeof t)continue;let i=null==l||null==(n=l.getField)?void 0:n.call(l,t);if(!(null==i||null==(r=i.isAssociationField)?void 0:r.call(i)))break;if(U(i)){if("number"!=typeof o[e+1])return!1;e+=1}if(!(null==(l=null==i?void 0:i.targetCollection)?void 0:l.getField))break}return!0}collectAssociationPrefixPaths(e,t){let l=[],o=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==o?void 0:o.getField))return l;let n=[];for(let e=0;e<t.length-1;e++){var r,i;let a=t[e];if("string"!=typeof a)break;let s=null==o||null==(r=o.getField)?void 0:r.call(o,a);if(!(null==s||null==(i=s.isAssociationField)?void 0:i.call(s)))break;if(n.push(a),U(s)){let l=t[e+1];if("number"!=typeof l)break;n.push(l),e+=1}if(l.push([...n]),!(null==(o=null==s?void 0:s.targetCollection)?void 0:o.getField))break}return l}shouldSkipToManyAssociationWriteWithoutIndex(e,t){let l=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==l?void 0:l.getField))return!1;for(let e=0;e<t.length-1;e++){var o,n;let r=t[e];if("string"!=typeof r)continue;let i=null==l||null==(o=l.getField)?void 0:o.call(l,r);if(!(null==i||null==(n=i.isAssociationField)?void 0:n.call(i)))break;if(U(i)){if("number"!=typeof t[e+1])return!0;e+=1}if(!(null==(l=null==i?void 0:i.targetCollection)?void 0:l.getField))break}return!1}shouldSkipAssociationNestedWrite(e,t){let l=this.collectAssociationPrefixPaths(e,t);if(!l.length)return!1;for(let o of l){let l=this.options.getFormValueAtPath(o);if(null==l){let l=o.filter(e=>"string"==typeof e).join(".");if(l&&this.getUpdateAssociationForTargetPath(l)||this.isAssociationTargetKeyWrite(e,t,o))continue;return!0}if("object"!=typeof l)return!0}return!1}getAssociationTargetKeyFields(e){var t,l;let o=(null==e?void 0:e.targetKey)??(null==e||null==(t=e.targetCollection)?void 0:t.filterTargetKey)??(null==e||null==(l=e.targetCollection)?void 0:l.filterByTk)??"id";return Array.isArray(o)?o.filter(e=>"string"==typeof e&&!!e):"string"==typeof o&&o?[o]:["id"]}resolveAssociationFieldByPrefixPath(e,t){let l=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==l?void 0:l.getField))return null;let o=null;for(let e of t){var n,r;if("number"==typeof e)continue;if("string"!=typeof e||!e)break;let t=null==l||null==(n=l.getField)?void 0:n.call(l,e);if(!(null==t||null==(r=t.isAssociationField)?void 0:r.call(t))||(o=t,!(null==(l=null==t?void 0:t.targetCollection)?void 0:l.getField)))break}return o}isAssociationTargetKeyWrite(e,t,l){var o;if(!Array.isArray(t)||!Array.isArray(l)||t.length!==l.length+1)return!1;let n=t[l.length];if("string"!=typeof n||!n)return!1;let r=this.resolveAssociationFieldByPrefixPath(e,l);return!(!(null==r||null==(o=r.isAssociationField)?void 0:o.call(r))||U(r))&&this.getAssociationTargetKeyFields(r).includes(n)}collectUpdateAssociationInitPatches(e,t){let l=this.collectAssociationPrefixPaths(e,t);if(!l.length)return[];let o=[];for(let n of l){let l=this.options.getFormValueAtPath(n);if(null==l){let l=n.filter(e=>"string"==typeof e).join(".");if(!l)return null;if(this.getUpdateAssociationForTargetPath(l)){o.push({path:[...n,"__is_new__"],value:!0});continue}if(this.isAssociationTargetKeyWrite(e,t,n)){o.push({path:[...n],value:{}});continue}return null}if("object"!=typeof l)return null}let n=new Map;for(let e of o){let t=nn(e.path);n.has(t)||n.set(t,e)}return Array.from(n.values())}dispose(){for(let{state:e}of this.rules.values())e.depDisposers.forEach(e=>e());for(let e of(this.rules.clear(),this.pendingRuleIds.clear(),this.assignTemplatesByTargetPath.clear(),this.defaultRuleMasterDisposers.values()))e();for(let e of(this.defaultRuleMasterDisposers.clear(),this.defaultRuleIdsByMasterUid.clear(),this.ruleDebounceTimersById.values()))clearTimeout(e);this.ruleDebounceTimersById.clear(),this.ruleDebounceUntilById.clear()}enable(){this.rulesEnabled=!0,this.pendingRuleIds.size&&!this.runningRules&&this.flushRules()}syncAssignRules(e){if(this.options.isDisposed())return;let t=(Array.isArray(e)?e:[]).map((e,t)=>({...e,key:(null==e?void 0:e.key)?String(e.key):`idx:${t}`})),l="form-assign:";for(let e of Array.from(this.rules.keys()))e.startsWith(l)&&this.removeRule(e);this.assignTemplatesByTargetPath.clear(),this.formItemTargetPaths.clear(),this.updateAssociationByTargetPath.clear();let o=0;for(let e of t){let t=(null==e?void 0:e.targetPath)?String(e.targetPath):"";if(!t)continue;let l=this.assignTemplatesByTargetPath.get(t)||[];o+=1,l.push({...e,__key:String(e.key),__order:o}),this.assignTemplatesByTargetPath.set(t,l)}let n=this.options.getEngine(),r=new Set;if(null==n?void 0:n.forEachModel){n.forEachModel(e=>{var t;if(!this.isModelInThisForm(e)||!(null==e||null==(t=e.subModels)?void 0:t.field))return;let l=this.getModelTargetPath(e);l&&this.formItemTargetPaths.add(l),this.cacheUpdateAssociationForModel(e)});let e=e=>{this.cacheUpdateAssociationForModel(e),this.tryRegisterAssignRuleInstancesForModel(e,r);let t=null==e?void 0:e.forks;t&&"function"==typeof t.forEach&&t.forEach(e=>{e&&(null==e||!e.disposed)&&this.tryRegisterAssignRuleInstancesForModel(e,r)})};n.forEachModel(t=>{e(t)})}for(let[e,t]of this.assignTemplatesByTargetPath.entries())if(!r.has(e)&&this.shouldCreateBlockLevelAssignRule(e))for(let o of t){let t="default"==((null==o?void 0:o.mode)==="default"?"default":"assign")?"default":"system",n=(null==o?void 0:o.enable)!==!1,r=`${l}${o.__key}:block`;this.rules.has(r)&&this.removeRule(r);let i={id:r,source:t,priority:10+(o.__order||0),debounceMs:0,getEnabled:()=>n&&!!e,getTarget:()=>e,getValue:()=>null==o?void 0:o.value,getCondition:()=>null==o?void 0:o.condition,getContext:()=>this.options.getBlockContext()};this.rules.set(r,{rule:i,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(r)}for(let e of Array.from(this.rules.keys()))e.startsWith("default:")&&this.scheduleRule(e)}onModelMounted(e){var t;if(this.isModelInThisForm(e)&&!(null==e?void 0:e.isFork)&&(null==e||null==(t=e.subModels)?void 0:t.field)){let t=this.getModelTargetPath(e);t&&this.formItemTargetPaths.add(t),this.cacheUpdateAssociationForModel(e)}this.tryRegisterDefaultRuleInstance(e),this.tryRegisterAssignRuleInstancesForModel(e)}onModelUnmounted(e){var t;if(this.tryUnregisterDefaultRuleInstance(e),this.tryUnregisterAssignRuleInstancesForModel(e),this.isModelInThisForm(e)&&(null==e||null==(t=e.subModels)?void 0:t.field)){let t=this.getModelTargetPath(e);if(t&&(this.ensureBlockAssignRuleInstancesForTargetPath(t),!(null==e?void 0:e.isFork))){this.updateAssociationByTargetPath.delete(t),this.formItemTargetPaths.delete(t);let e=`${t}.`;for(let t of this.assignTemplatesByTargetPath.keys())t.startsWith(e)&&this.ensureBlockAssignRuleInstancesForTargetPath(t);let l=this.options.getEngine();if(null==l?void 0:l.forEachModel){let e=e=>{this.tryRegisterAssignRuleInstancesForModel(e);let t=null==e?void 0:e.forks;t&&"function"==typeof t.forEach&&t.forEach(e=>{e&&(null==e||!e.disposed)&&this.tryRegisterAssignRuleInstancesForModel(e)})};l.forEachModel(t=>e(t))}}}}isModelInThisForm(e){var t;let l=null==e||null==(t=e.context)?void 0:t.blockModel;return!!l&&String(l.uid)===String(this.options.getBlockModelUid())}cacheUpdateAssociationForModel(e){var t,l;if(this.options.isDisposed()||!this.isModelInThisForm(e)||!e||"object"!=typeof e||(null==e?void 0:e.isFork)||!(null==e||null==(t=e.subModels)?void 0:t.field))return;let o=this.getModelTargetPath(e);if(!o)return;let n=null==e||null==(l=e.subModels)?void 0:l.field,r=!!(null==n?void 0:n.updateAssociation);!0!==this.updateAssociationByTargetPath.get(o)&&this.updateAssociationByTargetPath.set(o,r)}getUpdateAssociationForTargetPath(e){let t=String(e||"");if(!t)return!1;if(this.updateAssociationByTargetPath.has(t))return!!this.updateAssociationByTargetPath.get(t);let l=this.options.getEngine();return((null==l?void 0:l.forEachModel)&&l.forEachModel(e=>{this.cacheUpdateAssociationForModel(e)}),this.updateAssociationByTargetPath.has(t))?!!this.updateAssociationByTargetPath.get(t):(this.updateAssociationByTargetPath.set(t,!1),!1)}getDefaultRuleId(e){let t=(null==e?void 0:e.isFork)?String((null==e?void 0:e.forkId)??"fork"):"master",l=(null==e?void 0:e.uid)?String(e.uid):String(e);return`default:${l}:${t}`}getModelTargetNamePath(e){var t;let l=null==e||null==(t=e.context)?void 0:t.fieldPathArray;if(Array.isArray(l)&&l.length)return l;let o="function"==typeof(null==e?void 0:e.getProps)?e.getProps():null==e?void 0:e.props,n=null==o?void 0:o.name;return Array.isArray(n)?n:"string"==typeof n?n.includes(".")?n.split("."):[n]:null}getAssignTemplateTargetPathForModel(e){let t=this.getModelTargetPath(e);if(t)return t;let l=this.getModelTargetNamePath(e);if(!(null==l?void 0:l.length))return"";let o=l.filter(e=>"number"!=typeof e);return o.length?nn(o):""}hasAssignTemplateForTargetPath(e){let t=String(e||"");return!!t&&this.assignTemplatesByTargetPath.has(t)}tryRegisterDefaultRuleInstance(e){if(this.options.isDisposed()||!this.isModelInThisForm(e)||!e||"object"!=typeof e)return;let t="function"==typeof e.getProps?e.getProps():e.props;if(!t||"object"!=typeof t)return;let l=this.getModelTargetNamePath(e);if(!l)return;let o=this.getDefaultRuleId(e);if(this.rules.has(o))return;let n=e.master||e,r=this.getAssignTemplateTargetPathForModel(e);this.bindMasterInitialValue(n,o);let i=()=>{var e;let t=(null==n||null==(e=n.getProps)?void 0:e.call(n))??(null==n?void 0:n.props);return null==t?void 0:t.initialValue},a=i(),s=!1,d=()=>{let e=i();if(s||A.default.isEqual(e,a)||(s=!0),!this.hasAssignTemplateForTargetPath(r)||s||void 0===a)return e},u=()=>{if(!this.hasAssignTemplateForTargetPath(r))try{var e,t,l,o;let r=null==n||null==(t=n.getStepParams)||null==(e=t.call(n,"editItemSettings","initialValue"))?void 0:e.defaultValue;if(void 0!==r)return r;let i=null==n||null==(o=n.getStepParams)||null==(l=o.call(n,"formItemSettings","initialValue"))?void 0:l.defaultValue;if(void 0!==i)return i}catch{}},c={id:o,source:"default",priority:void 0!==d()?nx:0,debounceMs:0,getEnabled:()=>void 0!==d()||void 0!==u(),getTarget:()=>this.getModelTargetNamePath(e)||l,getValue:()=>{let e=d();return void 0!==e?e:u()},getContext:()=>null==e?void 0:e.context};this.rules.set(o,{rule:c,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(o)}getModelTargetPath(e){try{var t;let l=null==e||null==(t=e.getStepParams)?void 0:t.call(e,"fieldSettings","init"),o=null==l?void 0:l.fieldPath;if(o)return String(o)}catch{}let l=null==e?void 0:e.fieldPath;if(l)return String(l);let o=this.getModelTargetNamePath(e);return(null==o?void 0:o.length)&&o.filter(e=>"string"==typeof e).join(".")||null}getAssignRuleInstanceId(e,t){let l=(null==t?void 0:t.isFork)?String((null==t?void 0:t.forkId)??"fork"):"master",o=(null==t?void 0:t.uid)?String(t.uid):String(t);return`form-assign:${e}:${o}:${l}`}getDeepestFieldIndexKey(e){var t,l;let o=(null==e||null==(l=e.model)||null==(t=l.context)?void 0:t.fieldIndex)??(null==e?void 0:e.fieldIndex),n=Array.isArray(o)?o:[];if(!n.length)return null;let r=n[n.length-1];if("string"!=typeof r)return null;let[i,a]=r.split(":");return!i||Number.isNaN(Number(a))?null:i}getDeepestToManyAssociationKey(e){let t=this.getRootCollection();if(!(null==t?void 0:t.getField))return null;let l=nt(String(e||"")).filter(e=>"object"!=typeof e);if(l.length<2)return null;let o=t,n=null;for(let e=0;e<l.length-1;e++){var r,i;let t=l[e];if("string"!=typeof t)continue;let a=null==o||null==(r=o.getField)?void 0:r.call(o,t);if(!(null==a||null==(i=a.isAssociationField)?void 0:i.call(a)))break;let s=U(a);if(s&&(n=t),s&&"number"==typeof l[e+1]&&(e+=1),!(null==(o=null==a?void 0:a.targetCollection)?void 0:o.getField))break}return n}isRowGridModel(e){var t,l;if(!e||"object"!=typeof e||(null==e||null==(t=e.subModels)?void 0:t.field)||!(null==e||null==(l=e.subModels)?void 0:l.items))return!1;let o=null==e?void 0:e.context;return!!this.getDeepestFieldIndexKey(o)}tryRegisterAssignRuleInstancesForModel(e,t){var l,o,n,r;if(this.options.isDisposed()||!this.isModelInThisForm(e))return;let i=(l,o)=>{if(o&&0!==o.length)for(let r of(null==t||t.add(l),o)){var n;this.removeAssignRuleBlockInstance(r.__key),(null==e||null==(n=e.subModels)?void 0:n.field)&&this.removeRowGridAssignRuleInstances(r.__key);let t="default"==((null==r?void 0:r.mode)==="default"?"default":"assign")?"default":"system",o=(null==r?void 0:r.enable)!==!1,i=this.getAssignRuleInstanceId(r.__key,e);this.rules.has(i)&&this.removeRule(i);let a={id:i,source:t,priority:10+(r.__order||0),debounceMs:0,getEnabled:()=>o&&!!l,getTarget:()=>l,getValue:()=>null==r?void 0:r.value,getCondition:()=>null==r?void 0:r.condition,getContext:()=>null==e?void 0:e.context};this.rules.set(i,{rule:a,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(i)}};if(this.isRowGridModel(e)){let t=null==e?void 0:e.context,l=this.getDeepestFieldIndexKey(t);if(l)for(let[e,t]of this.assignTemplatesByTargetPath.entries()){if(this.formItemTargetPaths.has(e))continue;let o=this.getDeepestToManyAssociationKey(e);o&&o===l&&i(e,t)}return}if(!(null==e||null==(l=e.subModels)?void 0:l.field))return;let a=this.getModelTargetPath(e);if(!a)return;let s=this.assignTemplatesByTargetPath.get(a)||[];s.length&&i(a,s);let d=null==e||null==(o=e.subModels)?void 0:o.field,u=null==d||null==(n=d.context)?void 0:n.collectionField,c=!!(null==u||null==(r=u.isAssociationField)?void 0:r.call(u)),p=U(u);if(c&&!p){let e=`${a}.`;for(let[t,l]of this.assignTemplatesByTargetPath.entries())t&&"string"==typeof t&&t.startsWith(e)&&i(t,l)}}tryUnregisterAssignRuleInstancesForModel(e){var t,l,o,n;if(this.options.isDisposed()||!this.isModelInThisForm(e))return;let r=t=>{for(let l of t||[]){let t=this.getAssignRuleInstanceId(l.__key,e);this.rules.has(t)&&this.removeRule(t)}};if(this.isRowGridModel(e)){let t=null==e?void 0:e.context,l=this.getDeepestFieldIndexKey(t);if(!l)return;for(let[e,t]of this.assignTemplatesByTargetPath.entries()){if(this.formItemTargetPaths.has(e))continue;let o=this.getDeepestToManyAssociationKey(e);o&&o===l&&r(t)}return}if(!(null==e||null==(t=e.subModels)?void 0:t.field))return;let i=this.getModelTargetPath(e);if(!i)return;let a=this.assignTemplatesByTargetPath.get(i)||[];a.length&&r(a);let s=null==e||null==(l=e.subModels)?void 0:l.field,d=null==s||null==(o=s.context)?void 0:o.collectionField,u=!!(null==d||null==(n=d.isAssociationField)?void 0:n.call(d)),c=U(d);if(u&&!c){let e=`${i}.`;for(let[t,l]of this.assignTemplatesByTargetPath.entries())t&&"string"==typeof t&&t.startsWith(e)&&r(l)}}tryUnregisterDefaultRuleInstance(e){if(this.options.isDisposed()||!this.isModelInThisForm(e))return;let t=this.getDefaultRuleId(e);this.rules.has(t)&&this.removeRule(t)}bindMasterInitialValue(e,t){let l=(null==e?void 0:e.uid)?String(e.uid):t,o=this.defaultRuleIdsByMasterUid.get(l)||new Set;if(o.add(t),this.defaultRuleIdsByMasterUid.set(l,o),this.defaultRuleMasterDisposers.has(l))return;let n=(0,t$.reaction)(()=>{var t;let l=(null==e||null==(t=e.getProps)?void 0:t.call(e))??(null==e?void 0:e.props);return null==l?void 0:l.initialValue},(t,o)=>{var n;if(A.default.isEqual(t,o))return;let r=this.defaultRuleIdsByMasterUid.get(l);if(!r)return;let i=(null==e||null==(n=e.getProps)?void 0:n.call(e))??(null==e?void 0:e.props),a=void 0!==(null==i?void 0:i.initialValue)?nx:0;for(let e of r){let t=this.rules.get(e);t&&(t.rule.priority=a),this.scheduleRule(e)}});this.defaultRuleMasterDisposers.set(l,n)}removeRule(e){let t=this.rules.get(e);if(!t)return;try{let e=t.rule.getContext(),l=t.rule.getTarget(),o=this.options.tryResolveNamePath(e,l);if(o){let e=nn(o),l=this.options.observableBindings.get(e);l&&l.source===t.rule.source&&(l.dispose(),this.options.observableBindings.delete(e))}}catch{}t.state.depDisposers.forEach(e=>e()),this.rules.delete(e),this.pendingRuleIds.delete(e);let l=this.ruleDebounceTimersById.get(e);for(let[t,o]of(l&&clearTimeout(l),this.ruleDebounceTimersById.delete(e),this.ruleDebounceUntilById.delete(e),this.defaultRuleIdsByMasterUid.entries())){if(!o.has(e)||(o.delete(e),o.size>0))continue;this.defaultRuleIdsByMasterUid.delete(t);let l=this.defaultRuleMasterDisposers.get(t);l&&l(),this.defaultRuleMasterDisposers.delete(t)}}scheduleRule(e){if(this.options.isDisposed())return;let t=this.rules.get(e);if(!t)return;let{rule:l,state:o}=t;o.scheduledAtWriteSeq=this.options.getWriteSeq();let n=(null==l?void 0:l.debounceMs)??0;if(this.pendingRuleIds.add(e),n>0){let t=Date.now()+n;t>(this.ruleDebounceUntilById.get(e)||0)&&this.ruleDebounceUntilById.set(e,t);let l=this.ruleDebounceTimersById.get(e);l&&clearTimeout(l);let o=setTimeout(()=>{this.ruleDebounceTimersById.delete(e),!this.rulesEnabled||this.runningRules||this.pendingRuleIds.has(e)&&this.flushRules()},n);this.ruleDebounceTimersById.set(e,o)}else{let t=this.ruleDebounceTimersById.get(e);t&&clearTimeout(t),this.ruleDebounceTimersById.delete(e),this.ruleDebounceUntilById.delete(e)}!this.rulesEnabled||this.runningRules||this.flushRules()}async flushRules(){if(this.runningRules)return;this.runningRules=!0;let e=this.currentRuleTxId||nf();this.currentRuleTxId=e;try{for(;this.pendingRuleIds.size;){let e=Date.now(),t=[];for(let l of this.pendingRuleIds)(this.ruleDebounceUntilById.get(l)||0)>e||t.push(l);if(!t.length)break;for(let e of t)this.pendingRuleIds.delete(e),this.ruleDebounceUntilById.delete(e);for(let e of(t.sort((e,t)=>{var l,o;let n=null==(l=this.rules.get(e))?void 0:l.rule,r=null==(o=this.rules.get(t))?void 0:o.rule,i=(null==n?void 0:n.priority)??0,a=(null==r?void 0:r.priority)??0;return i!==a?i-a:e.localeCompare(t)}),t))await this.runRule(e)}}finally{this.runningRules=!1,this.currentRuleTxId=null,this.options.txWriteCounts.delete(e)}}async runRule(e){let t=this.rules.get(e);if(!t)return;let{rule:l,state:o}=t;o.runSeq+=1;let n=o.runSeq,r=o.scheduledAtWriteSeq,i=this.prepareRuleContext(l),{baseCtx:a,targetNamePath:s,targetKey:d,clearDeps:u,disposeBinding:c}=i;if(!this.shouldRunRule(l,s,d,a)||!s||!d){u(o),c();return}let p=s,m=d,{collector:h,evalCtx:f}=this.createRuleCollectorAndContext(l,i);if(l.getCondition&&!await this.evaluateRuleCondition(l,o,n,f,h))return;let v=await this.resolveRuleValue(l,o,n,f,h);if(v===nv||n!==o.runSeq)return;this.commitRuleDeps(l,o,h);let g=this.normalizeResolvedValueForTarget(a,v),x=this.normalizeResolvedValueForAssociationTarget(a,p,g);if("default"===l.source&&!this.checkDefaultRuleCanApply(x,p,m,u,c,o))return;if("default"===l.source){let e=this.lastRuleWriteByTargetKey.get(m);if((null==e?void 0:e.source)==="default"&&e.priority>l.priority&&e.writeSeq>=r)return void c()}if("system"===l.source){let e=this.options.lastWriteMetaByPathKey.get(m);if((null==e?void 0:e.source)==="linkage"&&e.writeSeq>=r)return void c()}if(this.shouldSkipAssociationNestedWrite(a,p)||this.shouldSkipToManyAssociationWriteWithoutIndex(a,p))return;let y=x;if(this.isAssociationTargetSemanticallyEqual(a,p,this.options.getFormValueAtPath(p),y))return;let b=this.collectUpdateAssociationInitPatches(a,p);if(null==b)return;if("system"===l.source||"default"===l.source){var _,S;let e=null==a?void 0:a.model,t=null==e||null==(_=e.subModels)?void 0:_.field;if(t){let l=this.getModelTargetNamePath(e);l&&nn(l)===m&&(e.setProps({value:x}),null==(S=t.setProps)||S.call(t,{value:x}))}}let k=this.options.getWriteSeq(),C=[...b,{path:p,value:x}];await this.options.setFormValues(f,C,{source:l.source,txId:this.currentRuleTxId||void 0});let w=this.options.getWriteSeq();w!==k&&this.lastRuleWriteByTargetKey.set(m,{source:l.source,priority:l.priority,writeSeq:w})}isTzAwareTargetInterface(e){return"string"==typeof e&&["datetime","createdAt","updatedAt","unixTimestamp"].includes(e)}normalizeDateOnlyToStartOfDayIso(e){let t=String(e||"").trim();if(!t||!/^\d{4}-\d{2}-\d{2}$/.test(t))return e;let l=(0,d.dayjs)(t,"YYYY-MM-DD",!0);return l.isValid()?l.startOf("day").toISOString():e}normalizeResolvedValueForTarget(e,t){var l,o,n;let r=null==e||null==(n=e.model)||null==(o=n.context)||null==(l=o.collectionField)?void 0:l.interface;return this.isTzAwareTargetInterface(r)?"string"==typeof t?this.normalizeDateOnlyToStartOfDayIso(t):Array.isArray(t)?t.map(e=>"string"==typeof e?this.normalizeDateOnlyToStartOfDayIso(e):e):t:t}isPrimitiveAssociationTargetValue(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e}extractAssociationIdentity(e,t){let l=this.getAssociationTargetKeyFields(e),o=1===l.length?l[0]:null,n=e=>{if(null==e)return e;if(this.isPrimitiveAssociationTargetValue(e))return o?e:ng;if(!e||"object"!=typeof e)return ng;if(o)return void 0===e[o]?ng:e[o];let t={};for(let o of l){if(void 0===e[o])return ng;t[o]=e[o]}return t};if(U(e)){let e=Array.isArray(t)?t:[t],l=[];for(let t of e){if(null==t)continue;let e=n(t);if(e===ng)return ng;l.push(e)}return l}let r=Array.isArray(t)?t.find(e=>null!=e):t;return null==r?r:n(r)}isAssociationTargetSemanticallyEqual(e,t,l,o){var n;let r=this.resolveCollectionFieldByNamePath(e,t);if(!(null==r||null==(n=r.isAssociationField)?void 0:n.call(r)))return A.default.isEqual(l,o);let i=this.extractAssociationIdentity(r,l),a=this.extractAssociationIdentity(r,o);return i===ng||a===ng?A.default.isEqual(l,o):A.default.isEqual(i,a)}resolveCollectionFieldByNamePath(e,t){if(!Array.isArray(t)||!t.length)return null;let l=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==l?void 0:l.getField))return null;for(let e=0;e<t.length;e++){var o,n;let r=t[e];if("string"!=typeof r||!r)break;let i=null==l||null==(o=l.getField)?void 0:o.call(l,r);if(!i)break;if(e===t.length-1)return i;if(!(null==i||null==(n=i.isAssociationField)?void 0:n.call(i))||!(null==i?void 0:i.targetCollection))break;if(U(i)){if("number"!=typeof t[e+1])return null;e+=1}if(!(null==(l=i.targetCollection)?void 0:l.getField))break}return null}normalizeResolvedValueForAssociationTarget(e,t,l){var o;let n=this.resolveCollectionFieldByNamePath(e,t);if(!(null==n||null==(o=n.isAssociationField)?void 0:o.call(n)))return l;let r=this.getAssociationTargetKeyFields(n),i=1===r.length?r[0]:null,a=e=>{if(null!=e)return i&&this.isPrimitiveAssociationTargetValue(e)?{[i]:e}:e};if(U(n))return(Array.isArray(l)?l:[l]).map(e=>a(e)).filter(e=>null!=e);let s=Array.isArray(l)?l.find(e=>null!=e):l;return null==s?s:a(s)}prepareRuleContext(e){let t=e.getContext(),l=e.getTarget(),o=this.options.tryResolveNamePath(t,l),n=o?nn(o):null,r=()=>{if(!n)return;let t=this.options.observableBindings.get(n);t&&t.source===e.source&&(t.dispose(),this.options.observableBindings.delete(n))};return{baseCtx:t,targetNamePath:o,targetKey:n,clearDeps:e=>{e.depDisposers.forEach(e=>e()),e.depDisposers=[],e.deps=new Set},disposeBinding:r}}shouldApplyDefaultRuleInCurrentState(e){var t,l;let o;if("update"!==(null==(t=(l=this.options).getActionName)?void 0:t.call(l)))return!0;try{o=null==e?void 0:e.item}catch{o=void 0}return!!o&&"object"==typeof o&&!0===o.__is_new__}shouldRunRule(e,t,l,o){return!(!e.getEnabled()||!t||!l||"default"===e.source&&(!this.shouldApplyDefaultRuleInCurrentState(o)||this.options.findExplicitHit(l)))&&!0}createRuleCollectorAndContext(e,t){let{baseCtx:l,targetNamePath:o}=t,n=e.getValue(),r=(0,i.isRunJSValue)(n),a={deps:new Set,wildcard:!1};if(e.getCondition&&nu(e.getCondition(),a),r?nc(n,a):nu(n,a),o)for(let e of(ns(o,a),this.collectAssociationPrefixPaths(l,o)))ns(e,a);let s=this.createRuleEvaluationContext(l,a,o);return{collector:a,evalCtx:s,rawValue:n,isRunJS:r}}async evaluateRuleCondition(e,t,l,o,n){let r=e.getCondition;if(!r)return!0;let i=r(),a=i;if(i)try{var s;a=await (null==o||null==(s=o.resolveJsonTemplate)?void 0:s.call(o,i))}catch{a=i}return l===t.runSeq&&(!i||!!ne(o,a)||(this.commitRuleDeps(e,t,n),!1))}async resolveRuleValue(e,t,l,o,n){let r=e.getValue();return(0,i.isRunJSValue)(r)?this.resolveRunJSValue(r,t,l,o,n,e):this.resolveTemplateValue(r,t,l,o,n,e)}async resolveRunJSValue(e,t,l,o,n,r){try{let{code:a,version:s}=(0,i.normalizeRunJSValue)(e),d=await (0,i.runjsWithSafeGlobals)(o,a,{version:s});if(!(null==d?void 0:d.success)){if(l!==t.runSeq)return nv;return this.commitRuleDeps(r,t,n),nv}return d.value}catch{if(l!==t.runSeq)return nv;return this.commitRuleDeps(r,t,n),nv}}async resolveTemplateValue(e,t,l,o,n,r){try{var i;return await (null==o||null==(i=o.resolveJsonTemplate)?void 0:i.call(o,e))}catch{if(l!==t.runSeq)return nv;return this.commitRuleDeps(r,t,n),nv}}commitRuleDeps(e,t,l){let o=new Set(l.deps);l.wildcard&&o.add("fv:*"),this.updateRuleDeps(e,t,o)}checkDefaultRuleCanApply(e,t,l,o,n,r){if(void 0===e)return!1;if(this.options.findExplicitHit(l))return o(r),n(),!1;let i=this.options.getFormValueAtPath(t),a=this.options.lastDefaultValueByPathKey.get(l),s=nh(i)||void 0!==a&&A.default.isEqual(i,a),d=(0,t$.isObservable)(e)?(0,t$.toJS)(e):e;return!s&&A.default.isEqual(i,d)?(this.options.lastDefaultValueByPathKey.set(l,d),!1):s}createRuleEvaluationContext(e,t,l){var o;let n,r=this.options.createTrackingFormValues(t),a=new i.FlowContext;try{a.delegate(e)}catch{}let s=null==e||null==(o=e.getPropertyOptions)?void 0:o.call(e,"formValues");s&&"object"==typeof s?a.defineProperty("formValues",{...s,get:()=>r,cache:!1}):a.defineProperty("formValues",{get:()=>r,cache:!1});let d=!1,u=()=>(d||(n=this.buildItemChainValue(e,r,l)??(null==e?void 0:e.item),d=!0),n);return a.defineProperty("item",{get:u,cache:!1}),a}buildItemChainValue(e,t,l){let o=this.getRootCollection()||this.getCollectionFromContext(e),n=(e,t,l,o)=>({index:t,length:l,__is_new__:null==e?void 0:e.__is_new__,__is_stored__:null==e?void 0:e.__is_stored__,value:e,parentItem:o}),r=n(t,void 0,void 0,void 0);if(!l||!Array.isArray(l)||!l.length||!(null==o?void 0:o.getField))return;let i=[],a=[],s=o;for(let e=0;e<l.length-1;e++){var d,u;let t=l[e];if("string"!=typeof t)break;let o=null==s||null==(d=s.getField)?void 0:d.call(s,t);if(!(null==o||null==(u=o.isAssociationField)?void 0:u.call(o)))break;let n=U(o);if(a.push(t),n){let t=l[e+1];if("number"!=typeof t)break;a.push(t),e+=1}let r=null==o?void 0:o.targetCollection;if(!r)break;i.push({path:[...a],toMany:n}),s=r}let c=e=>{if(e<0)return r;let l=i[e],o=A.default.get(t,l.path),a=l.path[l.path.length-1];return n(o,l.toMany&&"number"==typeof a?a:void 0,(()=>{if(!l.toMany)return;let e=l.path.slice(0,-1),o=A.default.get(t,e);return Array.isArray(o)?o.length:void 0})(),c(e-1))};return i.length?c(i.length-1):void 0}getFieldIndexSignature(e){var t,l;let o=(null==e||null==(l=e.model)||null==(t=l.context)?void 0:t.fieldIndex)??(null==e?void 0:e.fieldIndex);return(Array.isArray(o)?o:[]).filter(e=>"string"==typeof e).join("|")}updateRuleDeps(e,t,l){if(t.depDisposers.forEach(e=>e()),t.depDisposers=[],t.deps=l,l.has("fv:*")){let l=(0,t$.reaction)(()=>this.options.changeTick.value,()=>this.scheduleRule(e.id));t.depDisposers.push(l)}let o=(()=>{try{return e.getContext()}catch{return}})();for(let n of l){if("fv:*"===n)continue;if(!n.startsWith("fv:")&&!n.startsWith("ctx:")){let l=nr(n),o=(0,t$.reaction)(()=>A.default.get(this.options.valuesMirror,l),()=>this.scheduleRule(e.id));t.depDisposers.push(o);continue}if(n.startsWith("fv:")){let l=nr(n.slice(3)),o=(0,t$.reaction)(()=>A.default.get(this.options.valuesMirror,l),()=>this.scheduleRule(e.id));t.depDisposers.push(o);continue}let l=n.slice(4),r=l.indexOf(":"),i=r>=0?l.slice(0,r):l,a=r>=0?l.slice(r+1):"",s=a?nt(a).filter(e=>"object"!=typeof e):[];if("item"===i){let l=(0,t$.reaction)(()=>this.getFieldIndexSignature(o),()=>this.scheduleRule(e.id));if(t.depDisposers.push(l),s.length){let l=this.options.createTrackingFormValues({deps:new Set,wildcard:!1}),n=(0,t$.reaction)(()=>{var t;let n=null==(t=e.getTarget)?void 0:t.call(e),r=n?this.options.tryResolveNamePath(o,n):null,i=this.buildItemChainValue(o,l,r)??(null==o?void 0:o.item);return A.default.get(i,s)},()=>this.scheduleRule(e.id));t.depDisposers.push(n)}continue}let d=(0,t$.reaction)(()=>{let e=o?o[i]:void 0;return s.length?A.default.get(e,s):e},()=>this.scheduleRule(e.id));t.depDisposers.push(d)}}constructor(e){this.rules=new Map,this.lastRuleWriteByTargetKey=new Map,this.assignTemplatesByTargetPath=new Map,this.formItemTargetPaths=new Set,this.updateAssociationByTargetPath=new Map,this.pendingRuleIds=new Set,this.ruleDebounceUntilById=new Map,this.ruleDebounceTimersById=new Map,this.defaultRuleIdsByMasterUid=new Map,this.defaultRuleMasterDisposers=new Map,this.runningRules=!1,this.rulesEnabled=!1,this.currentRuleTxId=null,this.options=e}}class nb{syncAssignRules(e){this.ruleEngine.syncAssignRules(e)}get formValues(){return this.disposed||this.formPatcher.patch(this.getForm()),this.formValuesProxy}getFormValuesSnapshot(){if(!this.disposed){let e=this.getForm();this.formPatcher.patch(e)}return this.getForm().getFieldsValue(!0)}getFormValueAtPath(e){var t,l;let o=null==(t=(l=this).getForm)?void 0:t.call(l);if(o&&"function"==typeof o.getFieldValue)return o.getFieldValue(e);if(o&&"function"==typeof o.getFieldsValue){let t=o.getFieldsValue(!0);return A.default.get(t,e)}}mount(e){var t,l;if(this.disposed)return;this.formPatcher.patch(this.getForm());let o=null==(l=this.model)||null==(t=l.flowEngine)?void 0:t.emitter;if(o&&(this.mountedListener||this.unmountedListener||(this.mountedListener=e=>{let{model:t}=e;this.ruleEngine.onModelMounted(t)},this.unmountedListener=e=>{let{model:t}=e;this.ruleEngine.onModelUnmounted(t)},o.on("model:mounted",this.mountedListener),o.on("model:unmounted",this.unmountedListener)),null==e?void 0:e.sync)){let e=this.getFormValuesSnapshot();e&&"object"==typeof e&&(A.default.merge(this.valuesMirror,e),this.bumpChangeTick()),this.ruleEngine.enable()}}dispose(){var e,t;if(this.disposed)return;this.disposed=!0,this.formPatcher.restore();let l=null==(t=this.model)||null==(e=t.flowEngine)?void 0:e.emitter;for(let e of(l&&this.mountedListener&&this.unmountedListener&&(l.off("model:mounted",this.mountedListener),l.off("model:unmounted",this.unmountedListener)),this.ruleEngine.dispose(),this.observableBindings.values()))e.dispose();this.observableBindings.clear(),this.txWriteCounts.clear()}isSuppressed(){return this.suppressFormCallbackDepth>0}handleFormFieldsChange(e){if(this.disposed)return;let t=this.getForm();if(!t.getFieldValue)return;let l=[],o=new Set,n=!1;for(let r of e||[]){let e=null==r?void 0:r.name,i=Array.isArray(e)?e:"string"==typeof e||"number"==typeof e?[e]:null;if(!(null==i?void 0:i.length))continue;let a=t.getFieldValue(i),s=A.default.get(this.valuesMirror,i);A.default.isEqual(a,s)||(n||(this.writeSeq+=1,n=!0),A.default.set(this.valuesMirror,i,a),l.push(i),(null==r?void 0:r.touched)===!0&&o.add(nn(i)))}if(!l.length)return;let r=this.isSuppressed();if(!r&&o.size)for(let e of o)this.markExplicit(e);if(this.bumpChangeTick(),r)return;let i=e.some(e=>(null==e?void 0:e.touched)===!0)?"user":"system",a=this.writeSeq;for(let e of l)this.lastWriteMetaByPathKey.set(nn(e),{source:i,writeSeq:a});this.lastObservedChangedPaths=l,this.lastObservedSource=i;let s=++this.lastObservedToken;queueMicrotask(()=>{this.disposed||this.lastObservedToken===s&&(this.lastObservedChangedPaths=null,this.lastObservedSource=null)})}handleFormValuesChange(e,t){if(this.disposed||this.isSuppressed())return;let l=this.lastObservedChangedPaths&&this.lastObservedChangedPaths.length?this.lastObservedChangedPaths:Object.keys(e||{}).map(e=>[e]),o=this.lastObservedSource??"user";this.lastObservedChangedPaths=null,this.lastObservedSource=null;let n=t&&"object"==typeof t?t:this.getFormValuesSnapshot(),r=this.deriveExplicitPaths(l,n,this.valuesMirror),i=!1,a=!1,s=[];for(let e of l){if(!(null==e?void 0:e.length))continue;let t=A.default.get(n,e),l=A.default.get(this.valuesMirror,e);A.default.isEqual(l,t)||(a||(this.writeSeq+=1,a=!0),A.default.set(this.valuesMirror,e,t),i=!0,s.push(e))}for(let e of(i&&this.bumpChangeTick(),r))this.markExplicit(nn(e));if(i){let e=this.writeSeq;for(let t of s)(null==t?void 0:t.length)&&this.lastWriteMetaByPathKey.set(nn(t),{source:o,writeSeq:e})}let d=nf();this.emitFormValuesChange({source:o,txId:d,changedPaths:l,changedValues:e,allValues:n,allValuesSnapshot:n})}deriveExplicitPaths(e,t,l){let o=[],n=new Set;for(let r of e||[]){if(!(null==r?void 0:r.length))continue;let e=A.default.get(l,r),i=A.default.get(t,r);this.collectExplicitDiffPaths(e,i,r,o,n)}return o}collectExplicitDiffPaths(e,t,l,o,n){if(A.default.isEqual(e,t))return 0;let r=Array.isArray(e),i=Array.isArray(t);if(r||i){if(r&&i){let r=Math.min(e.length,t.length),i=0;for(let a=0;a<r;a++)i+=this.collectExplicitDiffPaths(e[a],t[a],[...l,a],o,n);return i}return+!!this.pushExplicitPath(l,o,n)}let a=this.isPlainObjectValue(e),s=this.isPlainObjectValue(t);if(a||s){if(a&&s){let r=new Set([...Object.keys(e),...Object.keys(t)]),i=0;for(let a of r)i+=this.collectExplicitDiffPaths(e[a],t[a],[...l,a],o,n);return 0===i&&this.isObjectCleared(e,t)?+!!this.pushExplicitPath(l,o,n):i}this.isObjectCleared(e,t)}return+!!this.pushExplicitPath(l,o,n)}pushExplicitPath(e,t,l){if(!(null==e?void 0:e.length))return!1;let o=nn(e);return!(!o||l.has(o))&&(l.add(o),t.push([...e]),!0)}isPlainObjectValue(e){return A.default.isPlainObject(e)}isObjectCleared(e,t){return!!this.isPlainObjectValue(e)&&!!(null==t||this.isPlainObjectValue(t)&&0===Object.keys(t).length)}async setFormValues(e,t,l){var o,n,r,i;if(this.disposed)return;let a=null==(o=(n=this).getForm)?void 0:o.call(n);if(!a)return;let s=(null==l?void 0:l.source)??"system",d=(null==l?void 0:l.triggerEvent)!==!1,u=(null==l?void 0:l.txId)??nf(),c=(null==l?void 0:l.markExplicit)??"default"!==s,p=void 0===(null==l?void 0:l.txId),m="linkage"===s&&Number.isFinite(Number(null==l?void 0:l.linkageScopeDepth))?Number(null==l?void 0:l.linkageScopeDepth):0,h="linkage"===s&&"string"==typeof(null==l?void 0:l.linkageTxId)&&l.linkageTxId?String(l.linkageTxId):void 0,f=e=>{if("linkage"!==s||!h)return!1;let t=this.lastWriteMetaByPathKey.get(e);return!!t&&"linkage"===t.source&&!!t.linkageTxId&&t.linkageTxId===h&&(Number.isFinite(Number(t.linkageScopeDepth))?Number(t.linkageScopeDepth):0)>m},v=e=>"linkage"===s?{source:s,writeSeq:e,linkageScopeDepth:m,linkageTxId:h}:{source:s,writeSeq:e},g=e=>"linkage"===s&&h?{...e,linkageTxId:h}:e;try{let l=[];if(!Array.isArray(t)){let e=Object.entries(t||{}).filter(e=>{let[t]=e;return!f(t)}),l=Object.fromEntries(e),o=e.map(e=>{let[t]=e;return t});if(!o.length)return;o.length&&(this.writeSeq+=1),this.suppressFormCallbackDepth++;try{null==(r=a.setFieldsValue)||r.call(a,l),A.default.merge(this.valuesMirror,l),this.bumpChangeTick()}finally{this.suppressFormCallbackDepth--}let n=this.writeSeq;for(let e of o)this.lastWriteMetaByPathKey.set(e,v(n));if(c)for(let e of o)this.markExplicit(e);if(d){let e=this.getFormValuesSnapshot();this.emitFormValuesChange(g({source:s,txId:u,changedPaths:o.map(e=>[e]),changedValues:l,allValues:e,allValuesSnapshot:e}))}return}let o=new Map,n=0;for(let l of t){let t=null==l?void 0:l.condition;if(t&&!ne(e,t))continue;let r=this.resolveNamePath(e,l.path),i=nn(r),a=l.value,s=(0,t$.isObservable)(a)?(0,t$.toJS)(a):a;if(f(i))continue;let d=this.getFormValueAtPath(r);A.default.isEqual(d,s)||(n+=1,o.set(i,{order:n,namePath:r,value:s,rawValue:a,pathKey:i}))}let p=Array.from(o.values()).sort((e,t)=>e.order-t.order).map(e=>({namePath:e.namePath,value:e.value,rawValue:e.rawValue,pathKey:e.pathKey}));if(!p.length)return;let x=this.txWriteCounts.get(u)||new Map;this.txWriteCounts.set(u,x);let y=[];for(let e of p){let t=(x.get(e.pathKey)||0)+1;x.set(e.pathKey,t),t>nm||y.push(e)}if(!y.length)return;this.writeSeq+=1;let b=this.writeSeq;for(let{pathKey:e,rawValue:t}of y)if(!(0,t$.isObservable)(t)){let t=this.observableBindings.get(e);t&&(t.dispose(),this.observableBindings.delete(e))}this.suppressFormCallbackDepth++;try{for(let{namePath:e,value:t}of y)null==(i=a.setFieldValue)||i.call(a,e,t),A.default.set(this.valuesMirror,e,t),l.push(e);this.bumpChangeTick()}finally{this.suppressFormCallbackDepth--}for(let{pathKey:e}of y)this.lastWriteMetaByPathKey.set(e,v(b));if(c)for(let{pathKey:e}of y)this.markExplicit(e);if("default"===s)for(let{namePath:e,pathKey:t}of y){let l=this.getFormValueAtPath(e);this.lastDefaultValueByPathKey.set(t,l)}for(let{namePath:t,rawValue:l,pathKey:o}of y){if(!(0,t$.isObservable)(l))continue;let n=l,r=(0,t$.observe)(n,()=>{this.applyBoundValue(e,t,o,(0,t$.toJS)(n),s,m,h)}),i=this.observableBindings.get(o);i&&i.dispose(),this.observableBindings.set(o,{source:s,dispose:r})}if(d){let e=this.getFormValuesSnapshot();this.emitFormValuesChange(g({source:s,txId:u,changedPaths:l,changedValues:{},allValues:e,allValuesSnapshot:e}))}}finally{p&&this.txWriteCounts.delete(u)}}applyBoundValue(e,t,l,o,n,r,i){var a,s,d;if(this.disposed)return;let u=null==(a=(s=this).getForm)?void 0:a.call(s);if(!u)return;let c=A.default.get(this.valuesMirror,t);if(A.default.isEqual(c,o))return;this.writeSeq+=1;let p=this.writeSeq;this.suppressFormCallbackDepth++;try{null==(d=u.setFieldValue)||d.call(u,t,o),A.default.set(this.valuesMirror,t,o),this.bumpChangeTick()}finally{this.suppressFormCallbackDepth--}let m="linkage"===n?{source:n,writeSeq:p,linkageScopeDepth:Number.isFinite(Number(r))?Number(r):0,linkageTxId:"string"==typeof i&&i?i:void 0}:{source:n,writeSeq:p};this.lastWriteMetaByPathKey.set(l,m);let h=nf(),f=this.getFormValuesSnapshot(),v={source:n,txId:h,changedPaths:[t],changedValues:{},allValues:f,allValuesSnapshot:f};if("linkage"===n&&i&&(v.linkageTxId=i),this.emitFormValuesChange(v),"default"===n&&this.isExplicit(l)){let e=this.observableBindings.get(l);e&&(e.dispose(),this.observableBindings.delete(l))}"default"===n&&this.lastDefaultValueByPathKey.set(l,this.getFormValueAtPath(t))}resolveNamePath(e,t){let l=this.tryResolveNamePath(e,t);if(!l)throw Error(`Failed to resolve path '${String(t)}'`);return l}tryResolveNamePath(e,t){var l,o;return no(t,(null==e||null==(o=e.model)||null==(l=o.context)?void 0:l.fieldIndex)??(null==e?void 0:e.fieldIndex))}bumpChangeTick(){this.changeTick.value+=1}emitFormValuesChange(e){var t,l,o,n;null==(t=(l=this.model).dispatchEvent)||t.call(l,"formValuesChange",e,{debounce:!0}),null==(n=this.model.emitter)||null==(o=n.emit)||o.call(n,"formValuesChange",e)}markExplicit(e){if(!this.explicitSet.has(e)){for(let t of(this.explicitSet.add(e),Array.from(this.lastDefaultValueByPathKey.keys())))(t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`))&&this.lastDefaultValueByPathKey.delete(t);for(let[e,t]of Array.from(this.observableBindings.entries()))"default"===t.source&&this.isExplicit(e)&&(t.dispose(),this.observableBindings.delete(e))}}isExplicit(e){return!!this.findExplicitHit(e)}findExplicitHit(e){if(this.explicitSet.has(e))return e;let t=nr(e),l=[];for(let e=0;e<t.length;e++){l.push(t[e]);let o=nn(l);if(this.explicitSet.has(o)&&"number"!=typeof t[e+1])return o}return null}constructor(e){this.valuesMirror=(0,t$.observable)({}),this.explicitSet=new Set,this.lastDefaultValueByPathKey=new Map,this.lastWriteMetaByPathKey=new Map,this.observableBindings=new Map,this.changeTick=t$.observable.ref(0),this.txWriteCounts=new Map,this.writeSeq=0,this.disposed=!1,this.suppressFormCallbackDepth=0,this.lastObservedChangedPaths=null,this.lastObservedSource=null,this.lastObservedToken=0,this.model=e.model,this.getForm=e.getForm,this.formPatcher=np({isSuppressed:()=>this.isSuppressed(),getCallerContext:()=>{var e;return null==(e=this.model)?void 0:e.context},setFormValues:this.setFormValues.bind(this)}),this.ruleEngine=new ny({getBlockModelUid:()=>{var e;return String(null==(e=this.model)?void 0:e.uid)},getActionName:()=>{var e,t,l,o;return(null==(t=this.model)||null==(e=t.getAclActionName)?void 0:e.call(t))??(null==(o=this.model)||null==(l=o.context)?void 0:l.actionName)},getBlockContext:()=>{var e;return null==(e=this.model)?void 0:e.context},getEngine:()=>{var e,t;return null==(t=this.model)||null==(e=t.context)?void 0:e.engine},getEngineModel:e=>{var t,l,o,n;return(null==(n=this.model)||null==(o=n.context)||null==(l=o.engine)||null==(t=l.getModel)?void 0:t.call(l,e))??null},isDisposed:()=>this.disposed,valuesMirror:this.valuesMirror,changeTick:this.changeTick,getWriteSeq:()=>this.writeSeq,txWriteCounts:this.txWriteCounts,createTrackingFormValues:e=>nd({valuesMirror:this.valuesMirror,basePath:[],collector:e,getFormValuesSnapshot:()=>this.getFormValuesSnapshot(),getFormValueAtPath:e=>this.getFormValueAtPath(e)}),tryResolveNamePath:(e,t)=>this.tryResolveNamePath(e,t),getFormValueAtPath:e=>this.getFormValueAtPath(e),setFormValues:(e,t,l)=>this.setFormValues(e,t,l),findExplicitHit:e=>this.findExplicitHit(e),lastDefaultValueByPathKey:this.lastDefaultValueByPathKey,lastWriteMetaByPathKey:this.lastWriteMetaByPathKey,observableBindings:this.observableBindings}),this.formValuesProxy=nd({valuesMirror:this.valuesMirror,basePath:[],getFormValuesSnapshot:()=>this.getFormValuesSnapshot(),getFormValueAtPath:e=>this.getFormValueAtPath(e)})}}function n_(e,t){let l=Array.isArray(e)?e:[],o=new Set,n=e=>{var l,o,n;if(!t||"function"!=typeof t.getField||"string"!=typeof e||!e.includes("."))return null;let r=e.split(".").filter(Boolean);if(r.length<2)return null;let i=t,a=[],s=null,d=null;for(let e=0;e<r.length-1;e++){let t=r[e],n=null==i||null==(l=i.getField)?void 0:l.call(i,t);if(!(null==n||null==(o=n.isAssociationField)?void 0:o.call(n))||!(null==n?void 0:n.targetCollection))break;a.push(t),s=a.join("."),d=n,i=n.targetCollection}if(s&&d){let e=r[r.length-1],t=(null==d?void 0:d.targetKey)??(null==d||null==(n=d.targetCollection)?void 0:n.filterTargetKey)??"id",l=Array.isArray(t)?t.filter(e=>"string"==typeof e&&!!e):"string"==typeof t&&t?[t]:["id"];if("string"==typeof e&&l.includes(e))return null}return s};for(let e of l){let t=(null==e?void 0:e.targetPath)?String(e.targetPath):"";if(!t)continue;let l=n(t);l&&o.add(l)}return Array.from(o)}function nS(){return{logic:"$and",items:[]}}function nk(e){if(!e)return;let t="function"==typeof e.getProps?e.getProps():e.props;if(t&&void 0!==t.initialValue)return t.initialValue}function nC(e,t){var l,o;if(e)return null==(o=e.getStepParams)||null==(l=o.call(e,t,"initialValue"))?void 0:l.defaultValue}function nw(e){return t=>{if(!t)return;let l=nk(t);if(void 0!==l)return l;for(let l of e){let e=nC(t,l);if(void 0!==e)return e}}}function nM(e,t,l){var o,n,r;if(!(null==e||null==(o=e.stepParams)?void 0:o[t]))return;let i=e.stepParams[t];!i||"object"!=typeof i||Object.prototype.hasOwnProperty.call(i,l)&&(delete i[l],A.default.isEmpty(i)&&delete e.stepParams[t],null==(r=e.emitter)||null==(n=r.emit)||n.call(r,"onStepParamsChanged"))}function nF(e){return t=>{var l;if(t)for(let o of(null==(l=t.setProps)||l.call(t,{initialValue:void 0}),t.props&&Object.prototype.hasOwnProperty.call(t.props,"initialValue")&&delete t.props.initialValue,e))nM(t,o,"initialValue")}}function nP(e,t){var l,o,n,r,i;let a=null==e||null==(n=e.subModels)||null==(o=n.grid)||null==(l=o.subModels)?void 0:l.items,s=Array.isArray(a)?a:[],d=[];for(let e of s){let l=(null==e||null==(i=e.getStepParams)||null==(r=i.call(e,"fieldSettings","init"))?void 0:r.fieldPath)||(null==e?void 0:e.fieldPath),o=l?String(l):"";if(!o)continue;let n=t(e);void 0!==n&&d.push({key:`legacy-default:${o}`,enable:!0,targetPath:o,mode:"default",condition:nS(),value:n})}return d}function nj(e,t){let l=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[];if(!o.length)return l;let n=new Set;for(let e of l){if(!e||"object"!=typeof e)continue;let t=e.targetPath?String(e.targetPath):"";if(t){if("default"===e.mode){n.add(t);continue}String(e.key??"").startsWith("legacy-default:")&&n.add(t)}}let r=new Set(l.map(e=>String(e.key??""))),i=[];for(let e of o){let t=e.targetPath?String(e.targetPath):"";if(!t||n.has(t))continue;let l={...e},o=String(l.key??"");o&&r.has(o)&&(l.key=`${o}:${t}`),i.push(l)}return i.length?[...l,...i]:l}function nA(e,t,l){var o,n,r;let i=null==e||null==(r=e.subModels)||null==(n=r.grid)||null==(o=n.subModels)?void 0:o.items,a=Array.isArray(i)?i:[],s=[];for(let e of a)void 0!==t(e)&&(l(e),s.push(e));return s}let nI=["editItemSettings","formItemSettings"],nT=nw(nI),nD=nF(nI);function nR(e){return nP(e,nT)}function nL(e){return nA(e,nT,nD)}let nE={formModelSettings:new Set(["layout","assignRules"]),eventSettings:new Set(["linkageRules"])},nN="nb-flow-keep-mobile-horizontal",nB=(0,m.css)`
|
|
174
|
+
`}),async handler(e,t){let{code:l,version:o}=o4(e,t),n=(0,i.createSafeNavigator)();await e.runjs(l,{window:(0,i.createSafeWindow)({navigator:n}),document:(0,i.createSafeDocument)(),navigator:n},{version:o})}}}});let o9="__saveStepParamsWithSubModels";function o8(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error("[saveStepParamsWithSubModels] model is not an object");e[o9]=!0}async function o3(e,t){if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error("[saveStepParamsWithSubModels] model is not an object");let l=e;if(!0!==l[o9])return await t();if("function"!=typeof l.save)throw Error("[saveStepParamsWithSubModels] model.save is not a function");try{return await l.save()}finally{delete l[o9]}}function ne(e,t){let l=(t,l,o)=>{var n,r,i;return!l||(null==e||null==(i=e.app)||null==(r=i.jsonLogic)||null==(n=r.apply)?void 0:n.call(r,{[l]:[t,o]}))};try{return(0,d.evaluateConditions)((0,d.removeInvalidFilterItems)(t),l)}catch{return!1}}function nt(e){let t=[],l=0,o=e.length,n=()=>{let n=l;for(;l<o&&"."!==e[l]&&"["!==e[l];)l++;let r=e.slice(n,l);r&&t.push(r)};for(;l<o;){let r=e[l];if("."===r){l++;continue}if("["===r){let n=++l;for(;l<o&&"]"!==e[l];)l++;let r=e.slice(n,l);l++,/^\d+$/.test(r)?t.push(Number(r)):r&&t.push({placeholder:r});continue}n()}return t}function nl(e){let t=Array.isArray(e)?e:[],l=[];for(let e of t){if("string"!=typeof e)continue;let[t,o]=e.split(":"),n=Number(o);!t||Number.isNaN(n)||l.push({name:t,index:n})}return l}function no(e,t){let l=Array.isArray(e)?[...e]:nt(e),o=nl(t),n=[],r=0;for(let e=0;e<l.length;e++){let t=l[e];if("object"==typeof t&&t&&"placeholder"in t){let e=n[n.length-1],t="string"==typeof e?e:void 0;if(!t)return null;for(;r<o.length&&o[r].name!==t;)r++;if(r>=o.length)return null;n.push(o[r].index),r++;continue}if(n.push(t),"string"==typeof t&&r<o.length&&o[r].name===t){let t=l[e+1];"number"==typeof t?r++:"object"==typeof t&&t&&"placeholder"in t||(n.push(o[r].index),r++)}}return n}function nn(e){let t="";for(let l of e){if("number"==typeof l){t+=`[${l}]`;continue}t?t+=`.${l}`:t=l}return t}function nr(e){return nt(e).filter(e=>"object"!=typeof e)}function ni(e){let t=[],l=[];for(let o of e)l.push(o),t.push(nn(l));return t}function na(e){return!!e&&"object"==typeof e&&(Array.isArray(e)||A.default.isPlainObject(e))}function ns(e,t){if(t)for(let l of ni(e))t.deps.add(`fv:${l}`)}function nd(e){let{valuesMirror:t,collector:l,basePath:o,getFormValuesSnapshot:n,getFormValueAtPath:r}=e,i=()=>o.length?A.default.get(t,o):t,a=i(),s=a&&("object"==typeof a||"function"==typeof a)?a:Array.isArray(a)?[]:{},d=e=>nd({valuesMirror:t,basePath:e,collector:l,getFormValuesSnapshot:n,getFormValueAtPath:r});return new Proxy(s,{get(e,a){if("toJSON"===a)return(l&&(l.wildcard=!0),0===o.length)?()=>n():()=>(0,t$.toJS)(i());if("symbol"==typeof a){l&&(l.wildcard=!0);let e=i();return null==e?void 0:e[a]}let s=i();if(null==s)return;if("__raw"===a)return s;if("__proto__"===a||"prototype"===a||"constructor"===a){l&&(l.wildcard=!0);return}let u=Array.isArray(s),c=u&&("number"==typeof a&&Number.isInteger(a)||"string"==typeof a&&/^\d+$/.test(a));if(u&&!c){l&&(l.wildcard=!0);let e=s[a];return"function"==typeof e?e.bind(s):e}let p=[...o,c?Number(a):a];ns(p,l);let m=s[a];if(void 0===m){let e=r(p);A.default.isEqual(e,m)||(A.default.set(t,p,e),m=e)}return null==m||"object"!=typeof m?m:na(m)?d(p):m},ownKeys(){l&&(l.wildcard=!0);let e=i();return e?Reflect.ownKeys(e):[]},getOwnPropertyDescriptor(e,t){let l=i();if(l)return Object.getOwnPropertyDescriptor(l,t)},has(e,t){let l=i();return!!l&&t in l}})}function nu(e,t){try{let l=(0,i.extractUsedVariablePaths)(e)||{};for(let[e,o]of Object.entries(l)){let l=Array.isArray(o)?o:[];for(let o of l.length?l:[""]){if("formValues"===e){if(!o){t.wildcard=!0;continue}let e=nt(String(o)).filter(e=>"object"!=typeof e);ns(e,t);continue}let l=o?`ctx:${e}:${String(o)}`:`ctx:${e}`;t.deps.add(l)}}}catch{}}function nc(e,t){if((0,i.isRunJSValue)(e))try{let l=(0,i.extractUsedVariablePathsFromRunJS)(e.code)||{};for(let[e,o]of Object.entries(l)){let l=Array.isArray(o)?o:[];for(let o of l.length?l:[""]){if("formValues"===e){if(!o){t.wildcard=!0;continue}let e=nt(String(o)).filter(e=>"object"!=typeof e);ns(e,t);continue}let l=o?`ctx:${e}:${String(o)}`:`ctx:${e}`;t.deps.add(l)}}}catch{}}function np(e){let t,l,o,n=()=>{let e=t;e&&(l&&(e.setFieldValue=l),o&&(e.setFieldsValue=o),t=void 0,l=void 0,o=void 0)};return{patch:r=>{if(t===r)return;n();let i="function"==typeof(null==r?void 0:r.setFieldValue)?r.setFieldValue.bind(r):void 0,a="function"==typeof(null==r?void 0:r.setFieldsValue)?r.setFieldsValue.bind(r):void 0;t=r,l=i,o=a,i&&(r.setFieldValue=(t,l)=>{e.isSuppressed()?i(t,l):e.setFormValues(e.getCallerContext(),[{path:t,value:l}],{source:"system"}).catch(()=>void 0)}),a&&(r.setFieldsValue=t=>{e.isSuppressed()?a(t):e.setFormValues(e.getCallerContext(),t,{source:"system"}).catch(()=>void 0)})},restore:n}}let nm=20;function nh(e){return null==e||("string"==typeof e||Array.isArray(e)?0===e.length:!!A.default.isPlainObject(e)&&0===Object.keys(e).length)}function nf(){return`${Date.now()}-${Math.random().toString(16).slice(2)}`}let nv=Symbol("SKIP_RULE_VALUE"),ng=Symbol("UNRESOLVED_ASSOCIATION_IDENTITY"),nx=1e3;class ny{getAssignRuleBlockId(e){return`form-assign:${e}:block`}removeAssignRuleBlockInstance(e){let t=this.getAssignRuleBlockId(e);this.rules.has(t)&&this.removeRule(t)}removeRowGridAssignRuleInstances(e){let t=`form-assign:${e}:`,l=this.getAssignRuleBlockId(e),o=[];for(let[e,i]of this.rules.entries()){var n,r;if(!e.startsWith(t)||e===l)continue;let a=null==i||null==(r=i.rule)||null==(n=r.getContext)?void 0:n.call(r),s=null==a?void 0:a.model;s&&this.isRowGridModel(s)&&o.push(e)}for(let e of o)this.removeRule(e)}hasAnyNonBlockAssignRuleInstance(e){let t=`form-assign:${e}:`,l=this.getAssignRuleBlockId(e);for(let e of this.rules.keys())if(e.startsWith(t)&&e!==l)return!0;return!1}ensureBlockAssignRuleInstancesForTargetPath(e){if(this.options.isDisposed()||!e||!this.shouldCreateBlockLevelAssignRule(e))return;let t=this.assignTemplatesByTargetPath.get(e)||[];if(t.length)for(let l of t){let t=(null==l?void 0:l.__key)?String(l.__key):"";if(!t||this.hasAnyNonBlockAssignRuleInstance(t))continue;let o="default"==((null==l?void 0:l.mode)==="default"?"default":"assign")?"default":"system",n=(null==l?void 0:l.enable)!==!1,r=this.getAssignRuleBlockId(t);if(this.rules.has(r))continue;let i={id:r,source:o,priority:10+(l.__order||0),debounceMs:0,getEnabled:()=>n&&!!e,getTarget:()=>e,getValue:()=>null==l?void 0:l.value,getCondition:()=>null==l?void 0:l.condition,getContext:()=>this.options.getBlockContext()};this.rules.set(r,{rule:i,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(r)}}getCollectionFromContext(e){var t,l;return(null==e?void 0:e.collection)??(null==e||null==(l=e.model)||null==(t=l.context)?void 0:t.collection)}getRootCollection(){let e=this.options.getBlockContext();return this.getCollectionFromContext(e)}shouldCreateBlockLevelAssignRule(e){let t=this.options.getBlockContext(),l=this.getCollectionFromContext(t);if(!(null==l?void 0:l.getField))return!0;let o=nt(e).filter(e=>"object"!=typeof e);if(o.length<=1)return!0;for(let e=0;e<o.length-1;e++){var n,r;let t=o[e];if("string"!=typeof t)continue;let i=null==l||null==(n=l.getField)?void 0:n.call(l,t);if(!(null==i||null==(r=i.isAssociationField)?void 0:r.call(i)))break;if(U(i)){if("number"!=typeof o[e+1])return!1;e+=1}if(!(null==(l=null==i?void 0:i.targetCollection)?void 0:l.getField))break}return!0}collectAssociationPrefixPaths(e,t){let l=[],o=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==o?void 0:o.getField))return l;let n=[];for(let e=0;e<t.length-1;e++){var r,i;let a=t[e];if("string"!=typeof a)break;let s=null==o||null==(r=o.getField)?void 0:r.call(o,a);if(!(null==s||null==(i=s.isAssociationField)?void 0:i.call(s)))break;if(n.push(a),U(s)){let l=t[e+1];if("number"!=typeof l)break;n.push(l),e+=1}if(l.push([...n]),!(null==(o=null==s?void 0:s.targetCollection)?void 0:o.getField))break}return l}shouldSkipToManyAssociationWriteWithoutIndex(e,t){let l=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==l?void 0:l.getField))return!1;for(let e=0;e<t.length-1;e++){var o,n;let r=t[e];if("string"!=typeof r)continue;let i=null==l||null==(o=l.getField)?void 0:o.call(l,r);if(!(null==i||null==(n=i.isAssociationField)?void 0:n.call(i)))break;if(U(i)){if("number"!=typeof t[e+1])return!0;e+=1}if(!(null==(l=null==i?void 0:i.targetCollection)?void 0:l.getField))break}return!1}shouldSkipAssociationNestedWrite(e,t){let l=this.collectAssociationPrefixPaths(e,t);if(!l.length)return!1;for(let o of l){let l=this.options.getFormValueAtPath(o);if(null==l){let l=o.filter(e=>"string"==typeof e).join(".");if(l&&this.getUpdateAssociationForTargetPath(l)||this.isAssociationTargetKeyWrite(e,t,o))continue;return!0}if("object"!=typeof l)return!0}return!1}getAssociationTargetKeyFields(e){var t,l;let o=(null==e?void 0:e.targetKey)??(null==e||null==(t=e.targetCollection)?void 0:t.filterTargetKey)??(null==e||null==(l=e.targetCollection)?void 0:l.filterByTk)??"id";return Array.isArray(o)?o.filter(e=>"string"==typeof e&&!!e):"string"==typeof o&&o?[o]:["id"]}resolveAssociationFieldByPrefixPath(e,t){let l=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==l?void 0:l.getField))return null;let o=null;for(let e of t){var n,r;if("number"==typeof e)continue;if("string"!=typeof e||!e)break;let t=null==l||null==(n=l.getField)?void 0:n.call(l,e);if(!(null==t||null==(r=t.isAssociationField)?void 0:r.call(t))||(o=t,!(null==(l=null==t?void 0:t.targetCollection)?void 0:l.getField)))break}return o}isAssociationTargetKeyWrite(e,t,l){var o;if(!Array.isArray(t)||!Array.isArray(l)||t.length!==l.length+1)return!1;let n=t[l.length];if("string"!=typeof n||!n)return!1;let r=this.resolveAssociationFieldByPrefixPath(e,l);return!(!(null==r||null==(o=r.isAssociationField)?void 0:o.call(r))||U(r))&&this.getAssociationTargetKeyFields(r).includes(n)}collectUpdateAssociationInitPatches(e,t){let l=this.collectAssociationPrefixPaths(e,t);if(!l.length)return[];let o=[];for(let n of l){let l=this.options.getFormValueAtPath(n);if(null==l){let l=n.filter(e=>"string"==typeof e).join(".");if(!l)return null;if(this.getUpdateAssociationForTargetPath(l)){o.push({path:[...n,"__is_new__"],value:!0});continue}if(this.isAssociationTargetKeyWrite(e,t,n)){o.push({path:[...n],value:{}});continue}return null}if("object"!=typeof l)return null}let n=new Map;for(let e of o){let t=nn(e.path);n.has(t)||n.set(t,e)}return Array.from(n.values())}dispose(){for(let{state:e}of this.rules.values())e.depDisposers.forEach(e=>e());for(let e of(this.rules.clear(),this.pendingRuleIds.clear(),this.assignTemplatesByTargetPath.clear(),this.defaultRuleMasterDisposers.values()))e();for(let e of(this.defaultRuleMasterDisposers.clear(),this.defaultRuleIdsByMasterUid.clear(),this.ruleDebounceTimersById.values()))clearTimeout(e);this.ruleDebounceTimersById.clear(),this.ruleDebounceUntilById.clear()}enable(){this.rulesEnabled=!0,this.pendingRuleIds.size&&!this.runningRules&&this.flushRules()}syncAssignRules(e){if(this.options.isDisposed())return;let t=(Array.isArray(e)?e:[]).map((e,t)=>({...e,key:(null==e?void 0:e.key)?String(e.key):`idx:${t}`})),l="form-assign:";for(let e of Array.from(this.rules.keys()))e.startsWith(l)&&this.removeRule(e);this.assignTemplatesByTargetPath.clear(),this.formItemTargetPaths.clear(),this.updateAssociationByTargetPath.clear();let o=0;for(let e of t){let t=(null==e?void 0:e.targetPath)?String(e.targetPath):"";if(!t)continue;let l=this.assignTemplatesByTargetPath.get(t)||[];o+=1,l.push({...e,__key:String(e.key),__order:o}),this.assignTemplatesByTargetPath.set(t,l)}let n=this.options.getEngine(),r=new Set;if(null==n?void 0:n.forEachModel){n.forEachModel(e=>{var t;if(!this.isModelInThisForm(e)||!(null==e||null==(t=e.subModels)?void 0:t.field))return;let l=this.getModelTargetPath(e);l&&this.formItemTargetPaths.add(l),this.cacheUpdateAssociationForModel(e)});let e=e=>{this.cacheUpdateAssociationForModel(e),this.tryRegisterAssignRuleInstancesForModel(e,r);let t=null==e?void 0:e.forks;t&&"function"==typeof t.forEach&&t.forEach(e=>{e&&(null==e||!e.disposed)&&this.tryRegisterAssignRuleInstancesForModel(e,r)})};n.forEachModel(t=>{e(t)})}for(let[e,t]of this.assignTemplatesByTargetPath.entries())if(!r.has(e)&&this.shouldCreateBlockLevelAssignRule(e))for(let o of t){let t="default"==((null==o?void 0:o.mode)==="default"?"default":"assign")?"default":"system",n=(null==o?void 0:o.enable)!==!1,r=`${l}${o.__key}:block`;this.rules.has(r)&&this.removeRule(r);let i={id:r,source:t,priority:10+(o.__order||0),debounceMs:0,getEnabled:()=>n&&!!e,getTarget:()=>e,getValue:()=>null==o?void 0:o.value,getCondition:()=>null==o?void 0:o.condition,getContext:()=>this.options.getBlockContext()};this.rules.set(r,{rule:i,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(r)}for(let e of Array.from(this.rules.keys()))e.startsWith("default:")&&this.scheduleRule(e)}onModelMounted(e){var t;if(this.isModelInThisForm(e)&&!(null==e?void 0:e.isFork)&&(null==e||null==(t=e.subModels)?void 0:t.field)){let t=this.getModelTargetPath(e);t&&this.formItemTargetPaths.add(t),this.cacheUpdateAssociationForModel(e)}this.tryRegisterDefaultRuleInstance(e),this.tryRegisterAssignRuleInstancesForModel(e)}onModelUnmounted(e){var t;if(this.tryUnregisterDefaultRuleInstance(e),this.tryUnregisterAssignRuleInstancesForModel(e),this.isModelInThisForm(e)&&(null==e||null==(t=e.subModels)?void 0:t.field)){let t=this.getModelTargetPath(e);if(t&&(this.ensureBlockAssignRuleInstancesForTargetPath(t),!(null==e?void 0:e.isFork))){this.updateAssociationByTargetPath.delete(t),this.formItemTargetPaths.delete(t);let e=`${t}.`;for(let t of this.assignTemplatesByTargetPath.keys())t.startsWith(e)&&this.ensureBlockAssignRuleInstancesForTargetPath(t);let l=this.options.getEngine();if(null==l?void 0:l.forEachModel){let e=e=>{this.tryRegisterAssignRuleInstancesForModel(e);let t=null==e?void 0:e.forks;t&&"function"==typeof t.forEach&&t.forEach(e=>{e&&(null==e||!e.disposed)&&this.tryRegisterAssignRuleInstancesForModel(e)})};l.forEachModel(t=>e(t))}}}}isModelInThisForm(e){var t;let l=null==e||null==(t=e.context)?void 0:t.blockModel;return!!l&&String(l.uid)===String(this.options.getBlockModelUid())}cacheUpdateAssociationForModel(e){var t,l;if(this.options.isDisposed()||!this.isModelInThisForm(e)||!e||"object"!=typeof e||(null==e?void 0:e.isFork)||!(null==e||null==(t=e.subModels)?void 0:t.field))return;let o=this.getModelTargetPath(e);if(!o)return;let n=null==e||null==(l=e.subModels)?void 0:l.field,r=!!(null==n?void 0:n.updateAssociation);!0!==this.updateAssociationByTargetPath.get(o)&&this.updateAssociationByTargetPath.set(o,r)}getUpdateAssociationForTargetPath(e){let t=String(e||"");if(!t)return!1;if(this.updateAssociationByTargetPath.has(t))return!!this.updateAssociationByTargetPath.get(t);let l=this.options.getEngine();return((null==l?void 0:l.forEachModel)&&l.forEachModel(e=>{this.cacheUpdateAssociationForModel(e)}),this.updateAssociationByTargetPath.has(t))?!!this.updateAssociationByTargetPath.get(t):(this.updateAssociationByTargetPath.set(t,!1),!1)}getDefaultRuleId(e){let t=(null==e?void 0:e.isFork)?String((null==e?void 0:e.forkId)??"fork"):"master",l=(null==e?void 0:e.uid)?String(e.uid):String(e);return`default:${l}:${t}`}getModelTargetNamePath(e){var t;let l=null==e||null==(t=e.context)?void 0:t.fieldPathArray;if(Array.isArray(l)&&l.length)return l;let o="function"==typeof(null==e?void 0:e.getProps)?e.getProps():null==e?void 0:e.props,n=null==o?void 0:o.name;return Array.isArray(n)?n:"string"==typeof n?n.includes(".")?n.split("."):[n]:null}getAssignTemplateTargetPathForModel(e){let t=this.getModelTargetPath(e);if(t)return t;let l=this.getModelTargetNamePath(e);if(!(null==l?void 0:l.length))return"";let o=l.filter(e=>"number"!=typeof e);return o.length?nn(o):""}hasAssignTemplateForTargetPath(e){let t=String(e||"");return!!t&&this.assignTemplatesByTargetPath.has(t)}tryRegisterDefaultRuleInstance(e){if(this.options.isDisposed()||!this.isModelInThisForm(e)||!e||"object"!=typeof e)return;let t="function"==typeof e.getProps?e.getProps():e.props;if(!t||"object"!=typeof t)return;let l=this.getModelTargetNamePath(e);if(!l)return;let o=this.getDefaultRuleId(e);if(this.rules.has(o))return;let n=e.master||e,r=this.getAssignTemplateTargetPathForModel(e);this.bindMasterInitialValue(n,o);let i=()=>{var e;let t=(null==n||null==(e=n.getProps)?void 0:e.call(n))??(null==n?void 0:n.props);return null==t?void 0:t.initialValue},a=i(),s=!1,d=()=>{let e=i();if(s||A.default.isEqual(e,a)||(s=!0),!this.hasAssignTemplateForTargetPath(r)||s||void 0===a)return e},u=()=>{if(!this.hasAssignTemplateForTargetPath(r))try{var e,t,l,o;let r=null==n||null==(t=n.getStepParams)||null==(e=t.call(n,"editItemSettings","initialValue"))?void 0:e.defaultValue;if(void 0!==r)return r;let i=null==n||null==(o=n.getStepParams)||null==(l=o.call(n,"formItemSettings","initialValue"))?void 0:l.defaultValue;if(void 0!==i)return i}catch{}},c={id:o,source:"default",priority:void 0!==d()?nx:0,debounceMs:0,getEnabled:()=>void 0!==d()||void 0!==u(),getTarget:()=>this.getModelTargetNamePath(e)||l,getValue:()=>{let e=d();return void 0!==e?e:u()},getContext:()=>null==e?void 0:e.context};this.rules.set(o,{rule:c,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(o)}getModelTargetPath(e){try{var t;let l=null==e||null==(t=e.getStepParams)?void 0:t.call(e,"fieldSettings","init"),o=null==l?void 0:l.fieldPath;if(o)return String(o)}catch{}let l=null==e?void 0:e.fieldPath;if(l)return String(l);let o=this.getModelTargetNamePath(e);return(null==o?void 0:o.length)&&o.filter(e=>"string"==typeof e).join(".")||null}getAssignRuleInstanceId(e,t){let l=(null==t?void 0:t.isFork)?String((null==t?void 0:t.forkId)??"fork"):"master",o=(null==t?void 0:t.uid)?String(t.uid):String(t);return`form-assign:${e}:${o}:${l}`}getDeepestFieldIndexKey(e){var t,l;let o=(null==e||null==(l=e.model)||null==(t=l.context)?void 0:t.fieldIndex)??(null==e?void 0:e.fieldIndex),n=Array.isArray(o)?o:[];if(!n.length)return null;let r=n[n.length-1];if("string"!=typeof r)return null;let[i,a]=r.split(":");return!i||Number.isNaN(Number(a))?null:i}getDeepestToManyAssociationKey(e){let t=this.getRootCollection();if(!(null==t?void 0:t.getField))return null;let l=nt(String(e||"")).filter(e=>"object"!=typeof e);if(l.length<2)return null;let o=t,n=null;for(let e=0;e<l.length-1;e++){var r,i;let t=l[e];if("string"!=typeof t)continue;let a=null==o||null==(r=o.getField)?void 0:r.call(o,t);if(!(null==a||null==(i=a.isAssociationField)?void 0:i.call(a)))break;let s=U(a);if(s&&(n=t),s&&"number"==typeof l[e+1]&&(e+=1),!(null==(o=null==a?void 0:a.targetCollection)?void 0:o.getField))break}return n}isRowGridModel(e){var t,l;if(!e||"object"!=typeof e||(null==e||null==(t=e.subModels)?void 0:t.field)||!(null==e||null==(l=e.subModels)?void 0:l.items))return!1;let o=null==e?void 0:e.context;return!!this.getDeepestFieldIndexKey(o)}tryRegisterAssignRuleInstancesForModel(e,t){var l,o,n,r;if(this.options.isDisposed()||!this.isModelInThisForm(e))return;let i=(l,o)=>{if(o&&0!==o.length)for(let r of(null==t||t.add(l),o)){var n;this.removeAssignRuleBlockInstance(r.__key),(null==e||null==(n=e.subModels)?void 0:n.field)&&this.removeRowGridAssignRuleInstances(r.__key);let t="default"==((null==r?void 0:r.mode)==="default"?"default":"assign")?"default":"system",o=(null==r?void 0:r.enable)!==!1,i=this.getAssignRuleInstanceId(r.__key,e);this.rules.has(i)&&this.removeRule(i);let a={id:i,source:t,priority:10+(r.__order||0),debounceMs:0,getEnabled:()=>o&&!!l,getTarget:()=>l,getValue:()=>null==r?void 0:r.value,getCondition:()=>null==r?void 0:r.condition,getContext:()=>null==e?void 0:e.context};this.rules.set(i,{rule:a,state:{deps:new Set,depDisposers:[],runSeq:0,scheduledAtWriteSeq:0}}),this.scheduleRule(i)}};if(this.isRowGridModel(e)){let t=null==e?void 0:e.context,l=this.getDeepestFieldIndexKey(t);if(l)for(let[e,t]of this.assignTemplatesByTargetPath.entries()){if(this.formItemTargetPaths.has(e))continue;let o=this.getDeepestToManyAssociationKey(e);o&&o===l&&i(e,t)}return}if(!(null==e||null==(l=e.subModels)?void 0:l.field))return;let a=this.getModelTargetPath(e);if(!a)return;let s=this.assignTemplatesByTargetPath.get(a)||[];s.length&&i(a,s);let d=null==e||null==(o=e.subModels)?void 0:o.field,u=null==d||null==(n=d.context)?void 0:n.collectionField,c=!!(null==u||null==(r=u.isAssociationField)?void 0:r.call(u)),p=U(u);if(c&&!p){let e=`${a}.`;for(let[t,l]of this.assignTemplatesByTargetPath.entries())t&&"string"==typeof t&&t.startsWith(e)&&i(t,l)}}tryUnregisterAssignRuleInstancesForModel(e){var t,l,o,n;if(this.options.isDisposed()||!this.isModelInThisForm(e))return;let r=t=>{for(let l of t||[]){let t=this.getAssignRuleInstanceId(l.__key,e);this.rules.has(t)&&this.removeRule(t)}};if(this.isRowGridModel(e)){let t=null==e?void 0:e.context,l=this.getDeepestFieldIndexKey(t);if(!l)return;for(let[e,t]of this.assignTemplatesByTargetPath.entries()){if(this.formItemTargetPaths.has(e))continue;let o=this.getDeepestToManyAssociationKey(e);o&&o===l&&r(t)}return}if(!(null==e||null==(t=e.subModels)?void 0:t.field))return;let i=this.getModelTargetPath(e);if(!i)return;let a=this.assignTemplatesByTargetPath.get(i)||[];a.length&&r(a);let s=null==e||null==(l=e.subModels)?void 0:l.field,d=null==s||null==(o=s.context)?void 0:o.collectionField,u=!!(null==d||null==(n=d.isAssociationField)?void 0:n.call(d)),c=U(d);if(u&&!c){let e=`${i}.`;for(let[t,l]of this.assignTemplatesByTargetPath.entries())t&&"string"==typeof t&&t.startsWith(e)&&r(l)}}tryUnregisterDefaultRuleInstance(e){if(this.options.isDisposed()||!this.isModelInThisForm(e))return;let t=this.getDefaultRuleId(e);this.rules.has(t)&&this.removeRule(t)}bindMasterInitialValue(e,t){let l=(null==e?void 0:e.uid)?String(e.uid):t,o=this.defaultRuleIdsByMasterUid.get(l)||new Set;if(o.add(t),this.defaultRuleIdsByMasterUid.set(l,o),this.defaultRuleMasterDisposers.has(l))return;let n=(0,t$.reaction)(()=>{var t;let l=(null==e||null==(t=e.getProps)?void 0:t.call(e))??(null==e?void 0:e.props);return null==l?void 0:l.initialValue},(t,o)=>{var n;if(A.default.isEqual(t,o))return;let r=this.defaultRuleIdsByMasterUid.get(l);if(!r)return;let i=(null==e||null==(n=e.getProps)?void 0:n.call(e))??(null==e?void 0:e.props),a=void 0!==(null==i?void 0:i.initialValue)?nx:0;for(let e of r){let t=this.rules.get(e);t&&(t.rule.priority=a),this.scheduleRule(e)}});this.defaultRuleMasterDisposers.set(l,n)}removeRule(e){let t=this.rules.get(e);if(!t)return;try{let e=t.rule.getContext(),l=t.rule.getTarget(),o=this.options.tryResolveNamePath(e,l);if(o){let e=nn(o),l=this.options.observableBindings.get(e);l&&l.source===t.rule.source&&(l.dispose(),this.options.observableBindings.delete(e))}}catch{}t.state.depDisposers.forEach(e=>e()),this.rules.delete(e),this.pendingRuleIds.delete(e);let l=this.ruleDebounceTimersById.get(e);for(let[t,o]of(l&&clearTimeout(l),this.ruleDebounceTimersById.delete(e),this.ruleDebounceUntilById.delete(e),this.defaultRuleIdsByMasterUid.entries())){if(!o.has(e)||(o.delete(e),o.size>0))continue;this.defaultRuleIdsByMasterUid.delete(t);let l=this.defaultRuleMasterDisposers.get(t);l&&l(),this.defaultRuleMasterDisposers.delete(t)}}scheduleRule(e){if(this.options.isDisposed())return;let t=this.rules.get(e);if(!t)return;let{rule:l,state:o}=t;o.scheduledAtWriteSeq=this.options.getWriteSeq();let n=(null==l?void 0:l.debounceMs)??0;if(this.pendingRuleIds.add(e),n>0){let t=Date.now()+n;t>(this.ruleDebounceUntilById.get(e)||0)&&this.ruleDebounceUntilById.set(e,t);let l=this.ruleDebounceTimersById.get(e);l&&clearTimeout(l);let o=setTimeout(()=>{this.ruleDebounceTimersById.delete(e),!this.rulesEnabled||this.runningRules||this.pendingRuleIds.has(e)&&this.flushRules()},n);this.ruleDebounceTimersById.set(e,o)}else{let t=this.ruleDebounceTimersById.get(e);t&&clearTimeout(t),this.ruleDebounceTimersById.delete(e),this.ruleDebounceUntilById.delete(e)}!this.rulesEnabled||this.runningRules||this.flushRules()}async flushRules(){if(this.runningRules)return;this.runningRules=!0;let e=this.currentRuleTxId||nf();this.currentRuleTxId=e;try{for(;this.pendingRuleIds.size;){let e=Date.now(),t=[];for(let l of this.pendingRuleIds)(this.ruleDebounceUntilById.get(l)||0)>e||t.push(l);if(!t.length)break;for(let e of t)this.pendingRuleIds.delete(e),this.ruleDebounceUntilById.delete(e);for(let e of(t.sort((e,t)=>{var l,o;let n=null==(l=this.rules.get(e))?void 0:l.rule,r=null==(o=this.rules.get(t))?void 0:o.rule,i=(null==n?void 0:n.priority)??0,a=(null==r?void 0:r.priority)??0;return i!==a?i-a:e.localeCompare(t)}),t))await this.runRule(e)}}finally{this.runningRules=!1,this.currentRuleTxId=null,this.options.txWriteCounts.delete(e)}}async runRule(e){let t=this.rules.get(e);if(!t)return;let{rule:l,state:o}=t;o.runSeq+=1;let n=o.runSeq,r=o.scheduledAtWriteSeq,i=this.prepareRuleContext(l),{baseCtx:a,targetNamePath:s,targetKey:d,clearDeps:u,disposeBinding:c}=i;if(!this.shouldRunRule(l,s,d,a)||!s||!d){u(o),c();return}let p=s,m=d,{collector:h,evalCtx:f}=this.createRuleCollectorAndContext(l,i);if(l.getCondition&&!await this.evaluateRuleCondition(l,o,n,f,h))return;let v=await this.resolveRuleValue(l,o,n,f,h);if(v===nv||n!==o.runSeq)return;this.commitRuleDeps(l,o,h);let g=this.normalizeResolvedValueForTarget(a,v),x=this.normalizeResolvedValueForAssociationTarget(a,p,g);if("default"===l.source&&!this.checkDefaultRuleCanApply(x,p,m,u,c,o))return;if("default"===l.source){let e=this.lastRuleWriteByTargetKey.get(m);if((null==e?void 0:e.source)==="default"&&e.priority>l.priority&&e.writeSeq>=r)return void c()}if("system"===l.source){let e=this.options.lastWriteMetaByPathKey.get(m);if((null==e?void 0:e.source)==="linkage"&&e.writeSeq>=r)return void c()}if(this.shouldSkipAssociationNestedWrite(a,p)||this.shouldSkipToManyAssociationWriteWithoutIndex(a,p))return;let y=x;if(this.isAssociationTargetSemanticallyEqual(a,p,this.options.getFormValueAtPath(p),y))return;let b=this.collectUpdateAssociationInitPatches(a,p);if(null==b)return;if("system"===l.source||"default"===l.source){var _,S;let e=null==a?void 0:a.model,t=null==e||null==(_=e.subModels)?void 0:_.field;if(t){let l=this.getModelTargetNamePath(e);l&&nn(l)===m&&(e.setProps({value:x}),null==(S=t.setProps)||S.call(t,{value:x}))}}let k=this.options.getWriteSeq(),C=[...b,{path:p,value:x}];await this.options.setFormValues(f,C,{source:l.source,txId:this.currentRuleTxId||void 0});let w=this.options.getWriteSeq();w!==k&&this.lastRuleWriteByTargetKey.set(m,{source:l.source,priority:l.priority,writeSeq:w})}isTzAwareTargetInterface(e){return"string"==typeof e&&["datetime","createdAt","updatedAt","unixTimestamp"].includes(e)}normalizeDateOnlyToStartOfDayIso(e){let t=String(e||"").trim();if(!t||!/^\d{4}-\d{2}-\d{2}$/.test(t))return e;let l=(0,d.dayjs)(t,"YYYY-MM-DD",!0);return l.isValid()?l.startOf("day").toISOString():e}normalizeResolvedValueForTarget(e,t){var l,o,n;let r=null==e||null==(n=e.model)||null==(o=n.context)||null==(l=o.collectionField)?void 0:l.interface;return this.isTzAwareTargetInterface(r)?"string"==typeof t?this.normalizeDateOnlyToStartOfDayIso(t):Array.isArray(t)?t.map(e=>"string"==typeof e?this.normalizeDateOnlyToStartOfDayIso(e):e):t:t}isPrimitiveAssociationTargetValue(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e}extractAssociationIdentity(e,t){let l=this.getAssociationTargetKeyFields(e),o=1===l.length?l[0]:null,n=e=>{if(null==e)return e;if(this.isPrimitiveAssociationTargetValue(e))return o?e:ng;if(!e||"object"!=typeof e)return ng;if(o)return void 0===e[o]?ng:e[o];let t={};for(let o of l){if(void 0===e[o])return ng;t[o]=e[o]}return t};if(U(e)){let e=Array.isArray(t)?t:[t],l=[];for(let t of e){if(null==t)continue;let e=n(t);if(e===ng)return ng;l.push(e)}return l}let r=Array.isArray(t)?t.find(e=>null!=e):t;return null==r?r:n(r)}isAssociationTargetSemanticallyEqual(e,t,l,o){var n;let r=this.resolveCollectionFieldByNamePath(e,t);if(!(null==r||null==(n=r.isAssociationField)?void 0:n.call(r)))return A.default.isEqual(l,o);let i=this.extractAssociationIdentity(r,l),a=this.extractAssociationIdentity(r,o);return i===ng||a===ng?A.default.isEqual(l,o):A.default.isEqual(i,a)}resolveCollectionFieldByNamePath(e,t){if(!Array.isArray(t)||!t.length)return null;let l=this.getRootCollection()||this.getCollectionFromContext(e);if(!(null==l?void 0:l.getField))return null;for(let e=0;e<t.length;e++){var o,n;let r=t[e];if("string"!=typeof r||!r)break;let i=null==l||null==(o=l.getField)?void 0:o.call(l,r);if(!i)break;if(e===t.length-1)return i;if(!(null==i||null==(n=i.isAssociationField)?void 0:n.call(i))||!(null==i?void 0:i.targetCollection))break;if(U(i)){if("number"!=typeof t[e+1])return null;e+=1}if(!(null==(l=i.targetCollection)?void 0:l.getField))break}return null}normalizeResolvedValueForAssociationTarget(e,t,l){var o;let n=this.resolveCollectionFieldByNamePath(e,t);if(!(null==n||null==(o=n.isAssociationField)?void 0:o.call(n)))return l;let r=this.getAssociationTargetKeyFields(n),i=1===r.length?r[0]:null,a=e=>{if(null!=e)return i&&this.isPrimitiveAssociationTargetValue(e)?{[i]:e}:e};if(U(n))return(Array.isArray(l)?l:[l]).map(e=>a(e)).filter(e=>null!=e);let s=Array.isArray(l)?l.find(e=>null!=e):l;return null==s?s:a(s)}prepareRuleContext(e){let t=e.getContext(),l=e.getTarget(),o=this.options.tryResolveNamePath(t,l),n=o?nn(o):null,r=()=>{if(!n)return;let t=this.options.observableBindings.get(n);t&&t.source===e.source&&(t.dispose(),this.options.observableBindings.delete(n))};return{baseCtx:t,targetNamePath:o,targetKey:n,clearDeps:e=>{e.depDisposers.forEach(e=>e()),e.depDisposers=[],e.deps=new Set},disposeBinding:r}}shouldApplyDefaultRuleInCurrentState(e){var t,l;let o;if("update"!==(null==(t=(l=this.options).getActionName)?void 0:t.call(l)))return!0;try{o=null==e?void 0:e.item}catch{o=void 0}return!!o&&"object"==typeof o&&!0===o.__is_new__}shouldRunRule(e,t,l,o){return!(!e.getEnabled()||!t||!l||"default"===e.source&&(!this.shouldApplyDefaultRuleInCurrentState(o)||this.options.findExplicitHit(l)))&&!0}createRuleCollectorAndContext(e,t){let{baseCtx:l,targetNamePath:o}=t,n=e.getValue(),r=(0,i.isRunJSValue)(n),a={deps:new Set,wildcard:!1};if(e.getCondition&&nu(e.getCondition(),a),r?nc(n,a):nu(n,a),o)for(let e of(ns(o,a),this.collectAssociationPrefixPaths(l,o)))ns(e,a);let s=this.createRuleEvaluationContext(l,a,o);return{collector:a,evalCtx:s,rawValue:n,isRunJS:r}}async evaluateRuleCondition(e,t,l,o,n){let r=e.getCondition;if(!r)return!0;let i=r(),a=i;if(i)try{var s;a=await (null==o||null==(s=o.resolveJsonTemplate)?void 0:s.call(o,i))}catch{a=i}return l===t.runSeq&&(!i||!!ne(o,a)||(this.commitRuleDeps(e,t,n),!1))}async resolveRuleValue(e,t,l,o,n){let r=e.getValue();return(0,i.isRunJSValue)(r)?this.resolveRunJSValue(r,t,l,o,n,e):this.resolveTemplateValue(r,t,l,o,n,e)}async resolveRunJSValue(e,t,l,o,n,r){try{let{code:a,version:s}=(0,i.normalizeRunJSValue)(e),d=await (0,i.runjsWithSafeGlobals)(o,a,{version:s});if(!(null==d?void 0:d.success)){if(l!==t.runSeq)return nv;return this.commitRuleDeps(r,t,n),nv}return d.value}catch{if(l!==t.runSeq)return nv;return this.commitRuleDeps(r,t,n),nv}}async resolveTemplateValue(e,t,l,o,n,r){try{var i;return await (null==o||null==(i=o.resolveJsonTemplate)?void 0:i.call(o,e))}catch{if(l!==t.runSeq)return nv;return this.commitRuleDeps(r,t,n),nv}}commitRuleDeps(e,t,l){let o=new Set(l.deps);l.wildcard&&o.add("fv:*"),this.updateRuleDeps(e,t,o)}checkDefaultRuleCanApply(e,t,l,o,n,r){if(void 0===e)return!1;if(this.options.findExplicitHit(l))return o(r),n(),!1;let i=this.options.getFormValueAtPath(t),a=this.options.lastDefaultValueByPathKey.get(l),s=nh(i)||void 0!==a&&A.default.isEqual(i,a),d=(0,t$.isObservable)(e)?(0,t$.toJS)(e):e;return!s&&A.default.isEqual(i,d)?(this.options.lastDefaultValueByPathKey.set(l,d),!1):s}createRuleEvaluationContext(e,t,l){var o;let n,r=this.options.createTrackingFormValues(t),a=new i.FlowContext;try{a.delegate(e)}catch{}let s=null==e||null==(o=e.getPropertyOptions)?void 0:o.call(e,"formValues");s&&"object"==typeof s?a.defineProperty("formValues",{...s,get:()=>r,cache:!1}):a.defineProperty("formValues",{get:()=>r,cache:!1});let d=!1,u=()=>(d||(n=this.buildItemChainValue(e,r,l)??(null==e?void 0:e.item),d=!0),n);return a.defineProperty("item",{get:u,cache:!1}),a}buildItemChainValue(e,t,l){let o=this.getRootCollection()||this.getCollectionFromContext(e),n=(e,t,l,o)=>({index:t,length:l,__is_new__:null==e?void 0:e.__is_new__,__is_stored__:null==e?void 0:e.__is_stored__,value:e,parentItem:o}),r=n(t,void 0,void 0,void 0);if(!l||!Array.isArray(l)||!l.length||!(null==o?void 0:o.getField))return;let i=[],a=[],s=o;for(let e=0;e<l.length-1;e++){var d,u;let t=l[e];if("string"!=typeof t)break;let o=null==s||null==(d=s.getField)?void 0:d.call(s,t);if(!(null==o||null==(u=o.isAssociationField)?void 0:u.call(o)))break;let n=U(o);if(a.push(t),n){let t=l[e+1];if("number"!=typeof t)break;a.push(t),e+=1}let r=null==o?void 0:o.targetCollection;if(!r)break;i.push({path:[...a],toMany:n}),s=r}let c=e=>{if(e<0)return r;let l=i[e],o=A.default.get(t,l.path),a=l.path[l.path.length-1];return n(o,l.toMany&&"number"==typeof a?a:void 0,(()=>{if(!l.toMany)return;let e=l.path.slice(0,-1),o=A.default.get(t,e);return Array.isArray(o)?o.length:void 0})(),c(e-1))};return i.length?c(i.length-1):void 0}getFieldIndexSignature(e){var t,l;let o=(null==e||null==(l=e.model)||null==(t=l.context)?void 0:t.fieldIndex)??(null==e?void 0:e.fieldIndex);return(Array.isArray(o)?o:[]).filter(e=>"string"==typeof e).join("|")}updateRuleDeps(e,t,l){if(t.depDisposers.forEach(e=>e()),t.depDisposers=[],t.deps=l,l.has("fv:*")){let l=(0,t$.reaction)(()=>this.options.changeTick.value,()=>this.scheduleRule(e.id));t.depDisposers.push(l)}let o=(()=>{try{return e.getContext()}catch{return}})();for(let n of l){if("fv:*"===n)continue;if(!n.startsWith("fv:")&&!n.startsWith("ctx:")){let l=nr(n),o=(0,t$.reaction)(()=>A.default.get(this.options.valuesMirror,l),()=>this.scheduleRule(e.id));t.depDisposers.push(o);continue}if(n.startsWith("fv:")){let l=nr(n.slice(3)),o=(0,t$.reaction)(()=>A.default.get(this.options.valuesMirror,l),()=>this.scheduleRule(e.id));t.depDisposers.push(o);continue}let l=n.slice(4),r=l.indexOf(":"),i=r>=0?l.slice(0,r):l,a=r>=0?l.slice(r+1):"",s=a?nt(a).filter(e=>"object"!=typeof e):[];if("item"===i){let l=(0,t$.reaction)(()=>this.getFieldIndexSignature(o),()=>this.scheduleRule(e.id));if(t.depDisposers.push(l),s.length){let l=this.options.createTrackingFormValues({deps:new Set,wildcard:!1}),n=(0,t$.reaction)(()=>{var t;let n=null==(t=e.getTarget)?void 0:t.call(e),r=n?this.options.tryResolveNamePath(o,n):null,i=this.buildItemChainValue(o,l,r)??(null==o?void 0:o.item);return A.default.get(i,s)},()=>this.scheduleRule(e.id));t.depDisposers.push(n)}continue}let d=(0,t$.reaction)(()=>{let e=o?o[i]:void 0;return s.length?A.default.get(e,s):e},()=>this.scheduleRule(e.id));t.depDisposers.push(d)}}constructor(e){this.rules=new Map,this.lastRuleWriteByTargetKey=new Map,this.assignTemplatesByTargetPath=new Map,this.formItemTargetPaths=new Set,this.updateAssociationByTargetPath=new Map,this.pendingRuleIds=new Set,this.ruleDebounceUntilById=new Map,this.ruleDebounceTimersById=new Map,this.defaultRuleIdsByMasterUid=new Map,this.defaultRuleMasterDisposers=new Map,this.runningRules=!1,this.rulesEnabled=!1,this.currentRuleTxId=null,this.options=e}}class nb{syncAssignRules(e){this.ruleEngine.syncAssignRules(e)}get formValues(){return this.disposed||this.formPatcher.patch(this.getForm()),this.formValuesProxy}getFormValuesSnapshot(){if(!this.disposed){let e=this.getForm();this.formPatcher.patch(e)}return this.getForm().getFieldsValue(!0)}getFormValueAtPath(e){var t,l;let o=null==(t=(l=this).getForm)?void 0:t.call(l);if(o&&"function"==typeof o.getFieldValue)return o.getFieldValue(e);if(o&&"function"==typeof o.getFieldsValue){let t=o.getFieldsValue(!0);return A.default.get(t,e)}}mount(e){var t,l;if(this.disposed)return;this.formPatcher.patch(this.getForm());let o=null==(l=this.model)||null==(t=l.flowEngine)?void 0:t.emitter;if(o&&(this.mountedListener||this.unmountedListener||(this.mountedListener=e=>{let{model:t}=e;this.ruleEngine.onModelMounted(t)},this.unmountedListener=e=>{let{model:t}=e;this.ruleEngine.onModelUnmounted(t)},o.on("model:mounted",this.mountedListener),o.on("model:unmounted",this.unmountedListener)),null==e?void 0:e.sync)){let e=this.getFormValuesSnapshot();e&&"object"==typeof e&&(A.default.merge(this.valuesMirror,e),this.bumpChangeTick()),this.ruleEngine.enable()}}dispose(){var e,t;if(this.disposed)return;this.disposed=!0,this.formPatcher.restore();let l=null==(t=this.model)||null==(e=t.flowEngine)?void 0:e.emitter;for(let e of(l&&this.mountedListener&&this.unmountedListener&&(l.off("model:mounted",this.mountedListener),l.off("model:unmounted",this.unmountedListener)),this.ruleEngine.dispose(),this.observableBindings.values()))e.dispose();this.observableBindings.clear(),this.txWriteCounts.clear()}isSuppressed(){return this.suppressFormCallbackDepth>0}handleFormFieldsChange(e){if(this.disposed)return;let t=this.getForm();if(!t.getFieldValue)return;let l=[],o=new Set,n=!1;for(let r of e||[]){let e=null==r?void 0:r.name,i=Array.isArray(e)?e:"string"==typeof e||"number"==typeof e?[e]:null;if(!(null==i?void 0:i.length))continue;let a=t.getFieldValue(i),s=A.default.get(this.valuesMirror,i);A.default.isEqual(a,s)||(n||(this.writeSeq+=1,n=!0),A.default.set(this.valuesMirror,i,a),l.push(i),(null==r?void 0:r.touched)===!0&&o.add(nn(i)))}if(!l.length)return;let r=this.isSuppressed();if(!r&&o.size)for(let e of o)this.markExplicit(e);if(this.bumpChangeTick(),r)return;let i=e.some(e=>(null==e?void 0:e.touched)===!0)?"user":"system",a=this.writeSeq;for(let e of l)this.lastWriteMetaByPathKey.set(nn(e),{source:i,writeSeq:a});this.lastObservedChangedPaths=l,this.lastObservedSource=i;let s=++this.lastObservedToken;queueMicrotask(()=>{this.disposed||this.lastObservedToken===s&&(this.lastObservedChangedPaths=null,this.lastObservedSource=null)})}handleFormValuesChange(e,t){if(this.disposed||this.isSuppressed())return;let l=this.lastObservedChangedPaths&&this.lastObservedChangedPaths.length?this.lastObservedChangedPaths:Object.keys(e||{}).map(e=>[e]),o=this.lastObservedSource??"user";this.lastObservedChangedPaths=null,this.lastObservedSource=null;let n=t&&"object"==typeof t?t:this.getFormValuesSnapshot(),r=this.deriveExplicitPaths(l,n,this.valuesMirror),i=!1,a=!1,s=[];for(let e of l){if(!(null==e?void 0:e.length))continue;let t=A.default.get(n,e),l=A.default.get(this.valuesMirror,e);A.default.isEqual(l,t)||(a||(this.writeSeq+=1,a=!0),A.default.set(this.valuesMirror,e,t),i=!0,s.push(e))}for(let e of(i&&this.bumpChangeTick(),r))this.markExplicit(nn(e));if(i){let e=this.writeSeq;for(let t of s)(null==t?void 0:t.length)&&this.lastWriteMetaByPathKey.set(nn(t),{source:o,writeSeq:e})}let d=nf();this.emitFormValuesChange({source:o,txId:d,changedPaths:l,changedValues:e,allValues:n,allValuesSnapshot:n})}deriveExplicitPaths(e,t,l){let o=[],n=new Set;for(let r of e||[]){if(!(null==r?void 0:r.length))continue;let e=A.default.get(l,r),i=A.default.get(t,r);this.collectExplicitDiffPaths(e,i,r,o,n)}return o}collectExplicitDiffPaths(e,t,l,o,n){if(A.default.isEqual(e,t))return 0;let r=Array.isArray(e),i=Array.isArray(t);if(r||i){if(r&&i){let r=Math.min(e.length,t.length),i=0;for(let a=0;a<r;a++)i+=this.collectExplicitDiffPaths(e[a],t[a],[...l,a],o,n);return i}return+!!this.pushExplicitPath(l,o,n)}let a=this.isPlainObjectValue(e),s=this.isPlainObjectValue(t);if(a||s){if(a&&s){let r=new Set([...Object.keys(e),...Object.keys(t)]),i=0;for(let a of r)i+=this.collectExplicitDiffPaths(e[a],t[a],[...l,a],o,n);return 0===i&&this.isObjectCleared(e,t)?+!!this.pushExplicitPath(l,o,n):i}this.isObjectCleared(e,t)}return+!!this.pushExplicitPath(l,o,n)}pushExplicitPath(e,t,l){if(!(null==e?void 0:e.length))return!1;let o=nn(e);return!(!o||l.has(o))&&(l.add(o),t.push([...e]),!0)}isPlainObjectValue(e){return A.default.isPlainObject(e)}isObjectCleared(e,t){return!!this.isPlainObjectValue(e)&&!!(null==t||this.isPlainObjectValue(t)&&0===Object.keys(t).length)}async setFormValues(e,t,l){var o,n,r,i;if(this.disposed)return;let a=null==(o=(n=this).getForm)?void 0:o.call(n);if(!a)return;let s=(null==l?void 0:l.source)??"system",d=(null==l?void 0:l.triggerEvent)!==!1,u=(null==l?void 0:l.txId)??nf(),c=(null==l?void 0:l.markExplicit)??"default"!==s,p=void 0===(null==l?void 0:l.txId),m="linkage"===s&&Number.isFinite(Number(null==l?void 0:l.linkageScopeDepth))?Number(null==l?void 0:l.linkageScopeDepth):0,h="linkage"===s&&"string"==typeof(null==l?void 0:l.linkageTxId)&&l.linkageTxId?String(l.linkageTxId):void 0,f=e=>{if("linkage"!==s||!h)return!1;let t=this.lastWriteMetaByPathKey.get(e);return!!t&&"linkage"===t.source&&!!t.linkageTxId&&t.linkageTxId===h&&(Number.isFinite(Number(t.linkageScopeDepth))?Number(t.linkageScopeDepth):0)>m},v=e=>"linkage"===s?{source:s,writeSeq:e,linkageScopeDepth:m,linkageTxId:h}:{source:s,writeSeq:e},g=e=>"linkage"===s&&h?{...e,linkageTxId:h}:e;try{let l=[];if(!Array.isArray(t)){let e=Object.entries(t||{}).filter(e=>{let[t]=e;return!f(t)}),l=Object.fromEntries(e),o=e.map(e=>{let[t]=e;return t});if(!o.length)return;o.length&&(this.writeSeq+=1),this.suppressFormCallbackDepth++;try{for(let[t,l]of e){let e=(0,t$.isObservable)(l)?(0,t$.toJS)(l):l;"function"==typeof a.setFieldValue?a.setFieldValue(t,e):"function"==typeof a.setFields?a.setFields([{name:t,value:e}]):null==(r=a.setFieldsValue)||r.call(a,{[t]:e}),A.default.set(this.valuesMirror,[t],e)}this.bumpChangeTick()}finally{this.suppressFormCallbackDepth--}let n=this.writeSeq;for(let e of o)this.lastWriteMetaByPathKey.set(e,v(n));if(c)for(let e of o)this.markExplicit(e);if(d){let e=this.getFormValuesSnapshot();this.emitFormValuesChange(g({source:s,txId:u,changedPaths:o.map(e=>[e]),changedValues:l,allValues:e,allValuesSnapshot:e}))}return}let o=new Map,n=0;for(let l of t){let t=null==l?void 0:l.condition;if(t&&!ne(e,t))continue;let r=this.resolveNamePath(e,l.path),i=nn(r),a=l.value,s=(0,t$.isObservable)(a)?(0,t$.toJS)(a):a;if(f(i))continue;let d=this.getFormValueAtPath(r);A.default.isEqual(d,s)||(n+=1,o.set(i,{order:n,namePath:r,value:s,rawValue:a,pathKey:i}))}let p=Array.from(o.values()).sort((e,t)=>e.order-t.order).map(e=>({namePath:e.namePath,value:e.value,rawValue:e.rawValue,pathKey:e.pathKey}));if(!p.length)return;let x=this.txWriteCounts.get(u)||new Map;this.txWriteCounts.set(u,x);let y=[];for(let e of p){let t=(x.get(e.pathKey)||0)+1;x.set(e.pathKey,t),t>nm||y.push(e)}if(!y.length)return;this.writeSeq+=1;let b=this.writeSeq;for(let{pathKey:e,rawValue:t}of y)if(!(0,t$.isObservable)(t)){let t=this.observableBindings.get(e);t&&(t.dispose(),this.observableBindings.delete(e))}this.suppressFormCallbackDepth++;try{for(let{namePath:e,value:t}of y)null==(i=a.setFieldValue)||i.call(a,e,t),A.default.set(this.valuesMirror,e,t),l.push(e);this.bumpChangeTick()}finally{this.suppressFormCallbackDepth--}for(let{pathKey:e}of y)this.lastWriteMetaByPathKey.set(e,v(b));if(c)for(let{pathKey:e}of y)this.markExplicit(e);if("default"===s)for(let{namePath:e,pathKey:t}of y){let l=this.getFormValueAtPath(e);this.lastDefaultValueByPathKey.set(t,l)}for(let{namePath:t,rawValue:l,pathKey:o}of y){if(!(0,t$.isObservable)(l))continue;let n=l,r=(0,t$.observe)(n,()=>{this.applyBoundValue(e,t,o,(0,t$.toJS)(n),s,m,h)}),i=this.observableBindings.get(o);i&&i.dispose(),this.observableBindings.set(o,{source:s,dispose:r})}if(d){let e=this.getFormValuesSnapshot();this.emitFormValuesChange(g({source:s,txId:u,changedPaths:l,changedValues:{},allValues:e,allValuesSnapshot:e}))}}finally{p&&this.txWriteCounts.delete(u)}}applyBoundValue(e,t,l,o,n,r,i){var a,s,d;if(this.disposed)return;let u=null==(a=(s=this).getForm)?void 0:a.call(s);if(!u)return;let c=A.default.get(this.valuesMirror,t);if(A.default.isEqual(c,o))return;this.writeSeq+=1;let p=this.writeSeq;this.suppressFormCallbackDepth++;try{null==(d=u.setFieldValue)||d.call(u,t,o),A.default.set(this.valuesMirror,t,o),this.bumpChangeTick()}finally{this.suppressFormCallbackDepth--}let m="linkage"===n?{source:n,writeSeq:p,linkageScopeDepth:Number.isFinite(Number(r))?Number(r):0,linkageTxId:"string"==typeof i&&i?i:void 0}:{source:n,writeSeq:p};this.lastWriteMetaByPathKey.set(l,m);let h=nf(),f=this.getFormValuesSnapshot(),v={source:n,txId:h,changedPaths:[t],changedValues:{},allValues:f,allValuesSnapshot:f};if("linkage"===n&&i&&(v.linkageTxId=i),this.emitFormValuesChange(v),"default"===n&&this.isExplicit(l)){let e=this.observableBindings.get(l);e&&(e.dispose(),this.observableBindings.delete(l))}"default"===n&&this.lastDefaultValueByPathKey.set(l,this.getFormValueAtPath(t))}resolveNamePath(e,t){let l=this.tryResolveNamePath(e,t);if(!l)throw Error(`Failed to resolve path '${String(t)}'`);return l}tryResolveNamePath(e,t){var l,o;return no(t,(null==e||null==(o=e.model)||null==(l=o.context)?void 0:l.fieldIndex)??(null==e?void 0:e.fieldIndex))}bumpChangeTick(){this.changeTick.value+=1}emitFormValuesChange(e){var t,l,o,n;null==(t=(l=this.model).dispatchEvent)||t.call(l,"formValuesChange",e,{debounce:!0}),null==(n=this.model.emitter)||null==(o=n.emit)||o.call(n,"formValuesChange",e)}markExplicit(e){if(!this.explicitSet.has(e)){for(let t of(this.explicitSet.add(e),Array.from(this.lastDefaultValueByPathKey.keys())))(t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`))&&this.lastDefaultValueByPathKey.delete(t);for(let[e,t]of Array.from(this.observableBindings.entries()))"default"===t.source&&this.isExplicit(e)&&(t.dispose(),this.observableBindings.delete(e))}}isExplicit(e){return!!this.findExplicitHit(e)}findExplicitHit(e){if(this.explicitSet.has(e))return e;let t=nr(e),l=[];for(let e=0;e<t.length;e++){l.push(t[e]);let o=nn(l);if(this.explicitSet.has(o)&&"number"!=typeof t[e+1])return o}return null}constructor(e){this.valuesMirror=(0,t$.observable)({}),this.explicitSet=new Set,this.lastDefaultValueByPathKey=new Map,this.lastWriteMetaByPathKey=new Map,this.observableBindings=new Map,this.changeTick=t$.observable.ref(0),this.txWriteCounts=new Map,this.writeSeq=0,this.disposed=!1,this.suppressFormCallbackDepth=0,this.lastObservedChangedPaths=null,this.lastObservedSource=null,this.lastObservedToken=0,this.model=e.model,this.getForm=e.getForm,this.formPatcher=np({isSuppressed:()=>this.isSuppressed(),getCallerContext:()=>{var e;return null==(e=this.model)?void 0:e.context},setFormValues:this.setFormValues.bind(this)}),this.ruleEngine=new ny({getBlockModelUid:()=>{var e;return String(null==(e=this.model)?void 0:e.uid)},getActionName:()=>{var e,t,l,o;return(null==(t=this.model)||null==(e=t.getAclActionName)?void 0:e.call(t))??(null==(o=this.model)||null==(l=o.context)?void 0:l.actionName)},getBlockContext:()=>{var e;return null==(e=this.model)?void 0:e.context},getEngine:()=>{var e,t;return null==(t=this.model)||null==(e=t.context)?void 0:e.engine},getEngineModel:e=>{var t,l,o,n;return(null==(n=this.model)||null==(o=n.context)||null==(l=o.engine)||null==(t=l.getModel)?void 0:t.call(l,e))??null},isDisposed:()=>this.disposed,valuesMirror:this.valuesMirror,changeTick:this.changeTick,getWriteSeq:()=>this.writeSeq,txWriteCounts:this.txWriteCounts,createTrackingFormValues:e=>nd({valuesMirror:this.valuesMirror,basePath:[],collector:e,getFormValuesSnapshot:()=>this.getFormValuesSnapshot(),getFormValueAtPath:e=>this.getFormValueAtPath(e)}),tryResolveNamePath:(e,t)=>this.tryResolveNamePath(e,t),getFormValueAtPath:e=>this.getFormValueAtPath(e),setFormValues:(e,t,l)=>this.setFormValues(e,t,l),findExplicitHit:e=>this.findExplicitHit(e),lastDefaultValueByPathKey:this.lastDefaultValueByPathKey,lastWriteMetaByPathKey:this.lastWriteMetaByPathKey,observableBindings:this.observableBindings}),this.formValuesProxy=nd({valuesMirror:this.valuesMirror,basePath:[],getFormValuesSnapshot:()=>this.getFormValuesSnapshot(),getFormValueAtPath:e=>this.getFormValueAtPath(e)})}}function n_(e,t){let l=Array.isArray(e)?e:[],o=new Set,n=e=>{var l,o,n;if(!t||"function"!=typeof t.getField||"string"!=typeof e||!e.includes("."))return null;let r=e.split(".").filter(Boolean);if(r.length<2)return null;let i=t,a=[],s=null,d=null;for(let e=0;e<r.length-1;e++){let t=r[e],n=null==i||null==(l=i.getField)?void 0:l.call(i,t);if(!(null==n||null==(o=n.isAssociationField)?void 0:o.call(n))||!(null==n?void 0:n.targetCollection))break;a.push(t),s=a.join("."),d=n,i=n.targetCollection}if(s&&d){let e=r[r.length-1],t=(null==d?void 0:d.targetKey)??(null==d||null==(n=d.targetCollection)?void 0:n.filterTargetKey)??"id",l=Array.isArray(t)?t.filter(e=>"string"==typeof e&&!!e):"string"==typeof t&&t?[t]:["id"];if("string"==typeof e&&l.includes(e))return null}return s};for(let e of l){let t=(null==e?void 0:e.targetPath)?String(e.targetPath):"";if(!t)continue;let l=n(t);l&&o.add(l)}return Array.from(o)}function nS(){return{logic:"$and",items:[]}}function nk(e){if(!e)return;let t="function"==typeof e.getProps?e.getProps():e.props;if(t&&void 0!==t.initialValue)return t.initialValue}function nC(e,t){var l,o;if(e)return null==(o=e.getStepParams)||null==(l=o.call(e,t,"initialValue"))?void 0:l.defaultValue}function nw(e){return t=>{if(!t)return;let l=nk(t);if(void 0!==l)return l;for(let l of e){let e=nC(t,l);if(void 0!==e)return e}}}function nM(e,t,l){var o,n,r;if(!(null==e||null==(o=e.stepParams)?void 0:o[t]))return;let i=e.stepParams[t];!i||"object"!=typeof i||Object.prototype.hasOwnProperty.call(i,l)&&(delete i[l],A.default.isEmpty(i)&&delete e.stepParams[t],null==(r=e.emitter)||null==(n=r.emit)||n.call(r,"onStepParamsChanged"))}function nF(e){return t=>{var l;if(t)for(let o of(null==(l=t.setProps)||l.call(t,{initialValue:void 0}),t.props&&Object.prototype.hasOwnProperty.call(t.props,"initialValue")&&delete t.props.initialValue,e))nM(t,o,"initialValue")}}function nP(e,t){var l,o,n,r,i;let a=null==e||null==(n=e.subModels)||null==(o=n.grid)||null==(l=o.subModels)?void 0:l.items,s=Array.isArray(a)?a:[],d=[];for(let e of s){let l=(null==e||null==(i=e.getStepParams)||null==(r=i.call(e,"fieldSettings","init"))?void 0:r.fieldPath)||(null==e?void 0:e.fieldPath),o=l?String(l):"";if(!o)continue;let n=t(e);void 0!==n&&d.push({key:`legacy-default:${o}`,enable:!0,targetPath:o,mode:"default",condition:nS(),value:n})}return d}function nj(e,t){let l=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[];if(!o.length)return l;let n=new Set;for(let e of l){if(!e||"object"!=typeof e)continue;let t=e.targetPath?String(e.targetPath):"";if(t){if("default"===e.mode){n.add(t);continue}String(e.key??"").startsWith("legacy-default:")&&n.add(t)}}let r=new Set(l.map(e=>String(e.key??""))),i=[];for(let e of o){let t=e.targetPath?String(e.targetPath):"";if(!t||n.has(t))continue;let l={...e},o=String(l.key??"");o&&r.has(o)&&(l.key=`${o}:${t}`),i.push(l)}return i.length?[...l,...i]:l}function nA(e,t,l){var o,n,r;let i=null==e||null==(r=e.subModels)||null==(n=r.grid)||null==(o=n.subModels)?void 0:o.items,a=Array.isArray(i)?i:[],s=[];for(let e of a)void 0!==t(e)&&(l(e),s.push(e));return s}let nI=["editItemSettings","formItemSettings"],nT=nw(nI),nD=nF(nI);function nR(e){return nP(e,nT)}function nL(e){return nA(e,nT,nD)}let nE={formModelSettings:new Set(["layout","assignRules"]),eventSettings:new Set(["linkageRules"])},nN="nb-flow-keep-mobile-horizontal",nB=(0,m.css)`
|
|
175
175
|
&.${nN} {
|
|
176
176
|
@media (max-width: 575px) {
|
|
177
177
|
.ant-form-item {
|
|
@@ -1439,7 +1439,7 @@ ${JSON.stringify(d,null,2)}`)},[S,_,b,f,h,Y,t,y,v,A,l,I,L,q,E,N,j]),$=(0,r.useCa
|
|
|
1439
1439
|
&:hover {
|
|
1440
1440
|
background-color: ${a.colorFillSecondary};
|
|
1441
1441
|
}
|
|
1442
|
-
`;return(0,r.jsxs)("div",{style:{maxHeight:300,overflowY:"auto"},children:[e.map(e=>(0,r.jsx)("div",{role:"option",onClick:()=>g(e.value),className:l,children:o(e.label)},e.value)),(0,r.jsx)(u.Divider,{style:{margin:"4px 0"}}),t.map(e=>(0,r.jsx)("div",{role:"option",className:l,onClick:()=>g(e.value),title:o(e.label),children:o(e.label)},e.value))]})};return(0,r.jsxs)(u.Space.Compact,{style:{...e.style,width:"100%"},children:[(0,r.jsx)(u.Select,{options:h,open:s,onDropdownVisibleChange:d,...e,allowClear:!1,style:{width:"100%",minWidth:100,maxWidth:["past","next","exact",void 0].includes(null==t?void 0:t.type)?100:null},value:(null==t?void 0:t.type)||"exact",onChange:g,dropdownRender:x}),["past","next"].includes(null==t?void 0:t.type)&&[(0,r.jsx)(u.InputNumber,{value:null==t?void 0:t.number,onChange:e=>{l({...t,number:e})}},"number"),(0,r.jsx)(u.Select,{value:null==t?void 0:t.unit,style:{minWidth:130,maxWidth:140},onChange:e=>{l({...t,unit:e})},options:[{value:"day",label:n("Day")},{value:"week",label:n("Calendar week")},{value:"month",label:n("Calendar Month")},{value:"year",label:n("Calendar Year")}],popupMatchSelectWidth:!0},"unit")],((null==t?void 0:t.type)==="exact"||!(null==t?void 0:t.type))&&(0,r.jsx)(v,{...e})]})}},39690(e,t,l){l.d(t,{gB:()=>m,X_:()=>p,L1:()=>v,Uq:()=>b,Pd:()=>h,L3:()=>_});var o=l(71178),n=l(72741),r=l(38533),i=l(10691),a=l(56920),s=l(77583),d=l(51649),u=l(54969),c=l(28260);let p=(0,d.createContext)(null);p.displayName="DraggableContext";let m=(0,d.createContext)(null);m.displayName="SortableContext";let h=e=>{let{id:t,data:l,children:n}=e,i=(0,r.useDraggable)({id:t,data:l}),a=(0,r.useDroppable)({id:t,data:l}),s=(0,d.useMemo)(()=>({draggable:i,droppable:a}),[i,a]);return(0,o.jsx)(m.Provider,{value:s,children:n})},f=e=>new n.TinyColor(e).setAlpha(.15).toHex8String(),v=e=>{var t,l;let{component:o,overStyle:n,style:r,children:s,openMode:c,...p}=e,{token:h}=(0,u.rd)(),{draggable:v,droppable:g}=(0,d.useContext)(m),{isOver:x,setNodeRef:y}=g,b={...r},_=(0,a.useFieldSchema)(),S=(null==_?void 0:_["x-component"])==="Action.Link"||"a"===o;return x&&(null==v||null==(t=v.active)?void 0:t.id)!==(null==g||null==(l=g.over)?void 0:l.id)&&(b[S?"color":"background"]=f(h.colorSettings),Object.assign(b,n)),d.default.createElement(o||"div",{role:"none",...p,className:(0,i.cx)("nb-sortable-designer",e.className),ref:y,style:b},s)},g=e=>{let t=x(e),l=(0,a.useFieldSchema)();return e.schema?{...e,id:t}:{...e,id:t,schema:l}},x=e=>{var t;let l=(0,a.useField)();return e.id?e.id:null==(t=l.address)?void 0:t.toString()},y=(0,a.observer)(e=>{let{schema:t,id:l,eid:n,removeParentsIfNoChildren:r,...i}=g(e),a=(0,d.useMemo)(()=>{var e,l,o;return{insertAdjacent:"afterEnd",schema:(null==(l=t.parent)||null==(e=l.parent)?void 0:e["x-component"])==="BlockTemplate"?null==(o=t.parent)?void 0:o.parent:t,removeParentsIfNoChildren:r??!0}},[t,r]);return(0,o.jsx)(h,{id:l,data:a,children:(0,o.jsx)(v,{id:n,...i,children:e.children})})},{displayName:"InternalSortableItem"}),b=d.default.memo(e=>{let{component:t,...l}=e,{designable:n}=(0,c.er)();return n?(0,o.jsx)(y,{...e}):d.default.createElement(t||"div",s.default.omit(l,["children","schema","overStyle","openMode","id","eid","removeParentsIfNoChildren"]),e.children)});b.displayName="SortableItem";let _=e=>{let{draggable:t}=(0,d.useContext)(m)||{};if(!t)return null;let{attributes:l,listeners:n,setNodeRef:r}=t;return(0,o.jsx)("div",{style:{display:"inline-block",width:14,height:14,lineHeight:"14px",textAlign:"left"},children:(0,o.jsx)("div",{ref:r,style:{position:"relative",zIndex:1,lineHeight:0,fontSize:0,display:"inline-block"},...n,...l,role:"none",children:(0,o.jsx)("span",{style:{cursor:"move",fontSize:14},children:e.children})})})}},59529(e,t,l){l.d(t,{KX:()=>p,_c:()=>f,a2:()=>S,bc:()=>c,rf:()=>u});var o=l(63526),n=l(77583),r=l(73761),i=l(839),a=l(59896),s=l(32665),d=l(64004);let u=(e,t)=>{var l;let o=/{{(.*?)}}/,r=null==e||null==(l=e.match)?void 0:l.call(e,o);if(!r)return e;{let e=n.default.get(t,r[1]);return n.default.isFunction(e)?e():e}};function c(e){if("object"!=typeof e||null===e)return null;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))if("[object Object]"===Object.prototype.toString.call(e[t])&&null!==e[t])return c(e[t]);else return{key:t,value:e[t]};return null}let p=e=>{let t=m(e),l=(0,n.findIndex)(t,(e,t,l)=>{if(e.includes("$")&&t>0)return!0});return t.slice(0,l)};function m(e){let t=[];function l(e){Object.keys(e).sort().forEach(function(o){t.push(o),e[o]&&"object"==typeof e[o]&&l(e[o])})}return l(e),t}let h=async(e,t,l)=>{let o=(0,a.DZ)(e)?[t.parseVariable(e,l).then(e=>{let{value:t}=e;return t})]:[e];try{let[e]=await Promise.all(o);return e}catch(e){throw console.error("Error in parseVariableValue:",e),e}},f=async(e,t)=>{let{ruleGroup:l,variables:o,localVariables:r,variableNameOfLeftCondition:i,conditionType:a}=e,s=Object.keys(l)[0]||"$and",d=l[s]||[],u=await Promise.all(d.filter(Boolean).map(e=>v(e,o,r,i,a,t)));return"$and"===s?(0,n.every)(u,e=>e):!u.length||(0,n.some)(u,e=>e)},v=async(e,t,l,o,n,r)=>"$and"in e||"$or"in e?await f({ruleGroup:e,variables:t,localVariables:l,conditionType:n},r):"advanced"===n?g(e,t,l,r):x(e,t,l,o,r),g=async(e,t,l,o)=>{let n=e.op,r=await h(e.rightVar,t,l),i=await h(e.leftVar,t,l);return!n||o.apply({[n]:[i,r]})},x=async(e,t,l,n,r)=>{let i=c(e),u=null==i?void 0:i.key;if(!u)return!0;let m=y(p(e),n),h=t.parseVariable(m,l,{doNotRequest:!0}).then(e=>{let{value:t}=e;return t}),f=(0,a.DZ)(null==i?void 0:i.value)?[t.parseVariable(null==i?void 0:i.value,l).then(e=>{let{value:t}=e;return t}),h]:[null==i?void 0:i.value,h];try{let[e,n]=await Promise.all(f),i=await t.getCollectionField(m,l),a=(0,s.A)(n,{targetCollectionField:i}),c=(0,s.A)(e,{targetCollectionField:i});if((null==i?void 0:i.type)&&["datetime","date","datetimeNoTz","dateOnly","unixTimestamp"].includes(i.type)&&a){let e=(0,d.Pn)(c),t=(0,o.getPickerFormat)(e);a=(0,o.dayjs)(a).format(t)}return r.apply({[u]:[a,c]})}catch(e){throw e}};function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$nForm";return`{{ ${t}.${e.join(".")} }}`}let b=e=>{let t={};return e.map(e=>{t[e.name]=e.ctx}),t};function _(e){return e.replace(/{{\s*}}/g,'{{"{{}}"}}')}async function S(e,t,l,n,a,s){if(t&&"handlebars"===e){o.Handlebars.registerHelper("t",function(e){if("string"==typeof e)return s(e,{ns:i.z})});try{var d,u;let e=_(t),r=o.Handlebars.compile(e),i=b(n),{$nDate:s}=(null==l||null==(d=l.ctxRef)?void 0:d.current)||{},c={};Object.keys(s||{}).map(e=>{c[e]=s[e]()});let p=r({...null==l||null==(u=l.ctxRef)?void 0:u.current,...i,$nDate:c});return console.log(p),await a(p)}catch(e){return/VariablesProvider: .* is not found/.test(e.message)||console.log(e),console.log(t),t}}try{let e=await (0,r.replaceVariableValue)(t,l,n);return await a(e)}catch(e){return/VariablesProvider: .* is not found/.test(e.message)||console.log(e),t}}},84951(e,t,l){l.d(t,{A:()=>g});var o=l(71178),n=l(56920),r=l(77583),i=l(51649),a=l(23610),s=l(44388),d=l(3012);let u={type:"void","x-component":"Action.Container","x-action":"view",title:'{{ t("View record") }}',"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("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}};var c=l(28227),p=l(30644),m=l(39888);let h=()=>{let e=(0,n.useFieldSchema)(),{insertAfterBegin:t}=(0,a.erX)();return(0,i.useCallback)(l=>{e.reduceProperties((e,t)=>"Action.Container"===t["x-component"]?t:e,null)||t((0,r.cloneDeep)(l))},[e,t])},f=e=>"Action.Container"===e["x-component"],v=e=>{let{WrappedComponent:t,...l}=e,a=(0,n.useFieldSchema)(),{openPopup:s}=(0,d.Hy)(),c=(0,i.useRef)(!1),p=h(),m=(0,i.useRef)(a);m.current=a;let f=(0,i.useRef)(p);f.current=p;let v=(0,i.useRef)(s);v.current=s;let g=(0,i.useCallback)(()=>m.current,[]),x=(0,i.useCallback)(()=>{m.current.properties||(f.current(u),c.current=!0),c.current?(setTimeout(()=>{v.current({customActionSchema:g()})}),c.current=!1):m.current.properties&&v.current()},[g]),y=(0,i.useMemo)(()=>(0,r.debounce)(x,600,{leading:!0,trailing:!1}),[x]);return(0,i.useEffect)(()=>()=>{y.cancel()},[y]),(0,o.jsx)("a",{onClick:y,children:(0,o.jsx)(t,{...l})})};function g(e){return t=>{let[l,r]=(0,i.useState)(!1),[u,h]=(0,i.useState)(!1),g=(0,c.Ge)(),x=(0,a.D50)(),y=(0,n.useField)(),b=(0,n.useFieldSchema)(),{enableLink:_,openMode:S,openSize:k}=(null==b?void 0:b["x-component-props"])||{},{visibleWithURL:C,setVisibleWithURL:w}=(0,d.Hy)(),M=(0,i.useCallback)(e=>{null==r||r(e),null==w||w(e)},[w]);(0,i.useRef)(b).current=b;let{setSubmitted:F}=x;return _?(0,o.jsx)(s.OC,{visible:!1,children:(0,o.jsxs)(a.z45,{button:(0,o.jsx)(e,{...t}),visible:l||C,setVisible:M,formValueChanged:u,setFormValueChanged:h,openMode:S,openSize:k,containerRefKey:"field-popup",fieldSchema:b,setSubmitted:F,children:[(0,o.jsx)(c.Yz,{name:g.name,children:(0,o.jsx)(a.t6u,{children:(0,o.jsx)(m.P3,{children:(0,o.jsx)(p.dw,{onlyRenderProperties:!0,basePath:null==y?void 0:y.address,schema:b,filterProperties:f})})})}),(0,o.jsx)(v,{...t,WrappedComponent:e})]})}):(0,o.jsx)(e,{...t})}}},63557(e,t,l){l.d(t,{u:()=>o});let o=(0,l(51649).createContext)({});o.displayName="SchemaComponentContext.Provider"},71915(e,t,l){l.d(t,{O:()=>u});var o=l(71178),n=l(44814),r=l(56920),i=l(51649),a=l(52570);let s=e=>{let{children:t,form:l,...n}=e,s=(0,i.useContext)(r.SchemaOptionsContext),d=(0,i.useContext)(r.SchemaExpressionScopeContext),u={...null==s?void 0:s.scope,...d},c={...null==s?void 0:s.components};return(0,o.jsx)(r.FormProvider,{...n,form:l,children:(0,o.jsx)(a.t,{components:c,scope:u,children:t})})},d=e=>{let{children:t,...l}=e,s=(0,i.useContext)(r.SchemaOptionsContext),d=(0,i.useContext)(r.SchemaExpressionScopeContext),u={...null==s?void 0:s.scope,...d},c={...null==s?void 0:s.components},p=(0,i.useMemo)(()=>(0,n.createForm)(),[]);return(0,o.jsx)(r.FormProvider,{...l,form:p,children:(0,o.jsx)(a.t,{components:c,scope:u,children:t})})},u=e=>e.form?(0,o.jsx)(s,{...e}):(0,o.jsx)(d,{...e})},86073(e,t,l){l.d(t,{D:()=>v});var o=l(71178),n=l(44814),r=l(56920),i=l(52793),a=l(51649),s=l(43353);l(67285);var d=l(28260),u=l(71915),c=l(93726),p=l(74737);let m=e=>{let{uid:t,type:l="getJsonSchema",onSuccess:o}=e,n={url:`/uiSchemas:${l}/${t}`},{data:r,loading:i}=(0,p.bP)(n,{refreshDeps:[t],onSuccess(e){o&&o(e)}});return{schema:null==r?void 0:r.data,loading:i}},h=e=>e,f=e=>{let{noForm:t,onlyRenderProperties:l,hidden:p,scope:f,uid:v,components:g,onSuccess:x,NotFoundPage:y,schemaTransform:b=h,onPageNotFind:_}=e,S=l?"getProperties":"getJsonSchema",k=(0,a.useMemo)(()=>(0,n.createForm)(),[v]),{schema:C,loading:w}=m({uid:v,type:S,onSuccess:e=>{x&&x(e)}}),M=(0,d.xZ)(y),F=(0,s.RH)(),P=(0,r.useFieldSchema)(),j=(0,a.useMemo)(()=>b(C||{}),[C,b]);return F||w||p?(0,o.jsx)(i.Spin,{style:{width:"100%",marginTop:20},delay:void 0}):C&&0!==Object.keys(C).length?t?(0,o.jsx)(c.H,{components:g,scope:f,schema:j,parentSchema:P}):(0,o.jsx)(u.O,{form:k,children:(0,o.jsx)(c.H,{components:g,scope:f,schema:j,parentSchema:P})}):(_&&_(),M?(0,o.jsx)(M,{}):null)},v=(0,a.memo)(e=>e.uid?(0,o.jsx)(f,{...e}):null);v.displayName="RemoteSchemaComponent"},93726(e,t,l){l.d(t,{D:()=>p,H:()=>f});var o=l(71178),n=l(56920),r=l(77583),i=l(51649),a=l(30644),s=l(63557),d=l(52570);function u(e){return n.Schema.isSchemaInstance(e)?e:new n.Schema((null==e?void 0:e.name)?{type:"object",properties:{[e.name]:e},name:`p_${e.name}`}:e)}let c=e=>(0,i.useMemo)(()=>u(e),[]),p=(0,i.createContext)({onChange:r.default.noop}),m=(0,i.memo)(e=>{let{components:t,scope:l,schema:n,distributed:c,onChange:m,parentSchema:h,...f}=e,v=(0,i.useContext)(s.u),g=(0,i.useMemo)(()=>u(n),[n]),x=(0,i.useMemo)(()=>({...v,distributed:!1!=v.distributed&&c,refresh:v.refresh||r.default.noop}),[v,c]),{onChange:y}=(0,i.useContext)(p),b=(0,i.useMemo)(()=>({onChange:()=>{null==m||m(g),null==y||y()}}),[m,y,g]);return(0,o.jsx)(p.Provider,{value:b,children:(0,o.jsx)(s.u.Provider,{value:x,children:(0,o.jsx)(d.t,{inherit:!0,components:t,scope:l,children:(0,o.jsx)(a.dw,{...f,schema:g,isUseFormilyField:!0,parentSchema:h})})})})});m.displayName="RecursionSchemaComponent";let h=(0,i.memo)(e=>{let{schema:t,parentSchema:l,...n}=e,r=c(t);return(0,o.jsx)(m,{...n,schema:r,parentSchema:l})});h.displayName="MemoizedSchemaComponent";let f=(0,i.memo)(e=>{let{memoized:t,...l}=e;return t?(0,o.jsx)(h,{...l}):(0,o.jsx)(m,{...l})});f.displayName="SchemaComponent"},52570(e,t,l){l.d(t,{M:()=>i,t:()=>a});var o=l(71178),n=l(56920),r=l(51649);let i=()=>(0,r.useContext)(n.SchemaOptionsContext)||{},a=(0,r.memo)(e=>{let{children:t}=e,l=i(),a=(0,r.useMemo)(()=>({...l.components,...e.components}),[l.components,e.components]),s=(0,r.useMemo)(()=>({...l.scope,...e.scope}),[l.scope,e.scope]),d=(0,r.useMemo)(()=>({scope:s,components:a}),[s,a]);return(0,o.jsx)(n.SchemaOptionsContext.Provider,{value:d,children:(0,o.jsx)(n.SchemaComponentsContext.Provider,{value:a,children:(0,o.jsx)(n.ExpressionScope,{value:s,children:t})})})});a.displayName="SchemaComponentOptions"},90995(e,t,l){l.d(t,{OA:()=>F,DY:()=>f.D,GD:()=>j,Do:()=>v.D,Mq:()=>g.M,t6:()=>g.t,Hv:()=>v.H,Op:()=>h.O,N3:()=>m});var o=l(71178),n=l(82113),r=l(52793),i=l(51649),a=l(77843),s=l(23610),d=l(49948),u=l(97812);let c={backgroundColor:"var(--colorSettings) !important"},p={backgroundColor:"transparent"},m=e=>{let{designable:t,setDesignable:l}=(0,s.erX)(),{t:i}=(0,a.useTranslation)(),{token:m}=(0,d.K)(),h=t?c:p,{isMobileLayout:f}=(0,u.mY)();return((0,__rspack_external_react_hotkeys_hook_f323ef84.useHotkeys)("Ctrl+Shift+U",()=>l(!t),[t]),f)?null:(0,o.jsx)(r.Tooltip,{title:i("UI Editor"),children:(0,o.jsx)(r.Button,{"data-testid":"ui-editor-button",icon:(0,o.jsx)(n.HighlightOutlined,{style:{color:m.colorTextHeaderMenu}}),title:i("UI Editor"),style:{...h,...e.style},onClick:()=>{l(!t)}})})};var h=l(71915),f=l(86073),v=l(93726),g=l(52570),x=l(44814),y=l(56920),b=l(27404),_=l(77583),S=l(63557),k=l(77850);let C=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return`${e}${(0,b.uid)()}`};y.Schema.silent(!0);let w={},M={silent:!0,compile(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=()=>{if(!M.silent)return Function("$root",`with($root) { return (${e}); }`)(t);try{return Function("$root",`with($root) { return (${e}); }`)(t)}catch{return`{{${e}}}`}};return w[e]?w[e]:e.trim().startsWith("t(")?(w[e]=l(),w[e]):l()}};y.Schema.registerCompiler(M.compile);let F=e=>{let{designable:t,onDesignableChange:l,components:n,children:r}=e,s=(0,i.useContext)(S.u),d=(0,g.M)(),[u,c]=(0,i.useState)(()=>(0,b.uid)()),p=(0,i.useMemo)(()=>e.form||(0,x.createForm)(),[u]),{t:m}=(0,a.useTranslation)(),h=(0,k.nm)(),f=(0,i.useMemo)(()=>({...e.scope,t:m,randomString:C}),[e.scope,m,null==d?void 0:d.scope]),[v,w]=(0,i.useState)(t),M=(0,i.useMemo)(()=>"boolean"==typeof t?t:v,[t,v,s.designable]),F=(0,i.useMemo)(()=>e=>{"boolean"!=typeof M&&w(e),null==l||l(e)},[M,l]);(0,i.useEffect)(()=>{let e=!1;return(async()=>{var t,l,o,n;if(!M)return await (null==(l=h.flowEngine)||null==(t=l.flowSettings)?void 0:t.disable());e||await (null==(n=h.flowEngine)||null==(o=n.flowSettings)?void 0:o.enable())})(),()=>{e=!0}},[h,M]);let P=(0,i.useCallback)(()=>{c((0,b.uid)())},[]),j=(0,i.useMemo)(()=>({scope:f,components:n,reset:P,refresh:_.default.noop,designable:M,setDesignable:F}),[n,M,P,f,F]);return(0,o.jsx)(S.u.Provider,{value:j,children:(0,o.jsx)(y.FormProvider,{form:p,children:(0,o.jsx)(g.t,{inherit:!0,scope:f,components:n,children:r})})})};F.displayName="SchemaComponentProvider";var P=l(83468);class j extends P.k{async load(){this.addComponents()}addComponents(){this.app.addComponents({DesignableSwitch:m})}}},28260(e,t,l){l.d(t,{Us:()=>y,TD:()=>n,F:()=>m,px:()=>d.px,QI:()=>d.QI,d1:()=>d.d1,xB:()=>v,YY:()=>b.Y,Lj:()=>_.Lj,er:()=>d.er,xZ:()=>s,OJ:()=>c,mh:()=>_.mh,lu:()=>r.l,kB:()=>d.kB,Hb:()=>u.H,a9:()=>_.a9,jE:()=>S});var o=l(51649);let n=e=>{let t=(0,o.useRef)(null);return(0,o.useEffect)(()=>(t.current&&e!==t.current&&t.current.onUnmount(),t.current=e,e.onMount(),()=>{e.onUnmount()}),[e]),e};var r=l(61013),i=l(56920),a=l(77583);let s=(e,t)=>{let{components:l}=(0,o.useContext)(i.SchemaOptionsContext);return e?"string"!=typeof e?e:(0,a.get)(l,e)||t:t};var d=l(95951),u=l(87463);let c=e=>{let t=(0,o.useContext)(i.SchemaOptionsContext),l=(0,o.useContext)(i.SchemaExpressionScopeContext),n=(0,o.useRef)();return n.current=l,e.toFieldProps({...t,get scope(){return{...t.scope,...n.current}}})};var p=l(63557);function m(){return(0,o.useContext)(p.u)}var h=l(77843),f=l(43288);let v=()=>{var e;let{getCollectionJoinField:t,getCollection:l}=(0,f.nj)(),n=(0,i.useFieldSchema)(),{getField:r}=(0,f.k7)(),a=r(n.name)||t(n["x-collection-field"]),{t:s}=(0,h.useTranslation)(),{label:d}=(null==(e=n["x-component-props"])?void 0:e.fieldNames)||{};return(0,o.useMemo)(()=>{if(!a||!(null==a?void 0:a.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(a.interface))return;let e=l(a.target);if((null==e?void 0:e.template)==="file")return[{label:s("Record picker"),value:"CollectionField"},{label:s("Select"),value:"AssociationSelect"}];switch(a.interface){case"o2m":return[{label:s("Record picker"),value:"CollectionField"},{label:s("Subtable"),value:"TableField"},{label:s("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:s("Record picker"),value:"CollectionField"},{label:s("Select"),value:"AssociationSelect"}];default:return[{label:s("Record picker"),value:"CollectionField"},{label:s("Subform"),value:"FormField"},{label:s("Select"),value:"AssociationSelect"}]}},[s,null==a?void 0:a.interface,d])};var g=l(26174),x=l(49621);let y=()=>{var e;let t=(0,i.useField)(),l=(0,i.useFieldSchema)(),n=(0,x.Ge)(),a=(0,g.r2)(),s=(null==n?void 0:n.getField(l.name))||(null==a?void 0:a.getCollectionField(l["x-collection-field"])),d=(0,r.l)();(0,o.useEffect)(()=>{if(!(null==t?void 0:t.title)){var e;t.title=d(null==s||null==(e=s.uiSchema)?void 0:e.title)}},[null==s||null==(e=s.uiSchema)?void 0:e.title])};var b=l(4922),_=l(62152);let S=e=>{var t;let{t:l}=(0,h.useTranslation)(),{getCollectionJoinField:n,getCollection:r}=(0,f.nj)(),a=(0,i.useFieldSchema)(),s=(null==e?void 0:e.fieldSchema)||a,d=(0,i.useField)(),u=(0,i.useForm)(),c=(null==s?void 0:s["x-read-pretty"])||d.readPretty||u.readPretty,p=null==e?void 0:e.fieldSchema,{getField:m}=(0,f.k7)(),v=(null==e?void 0:e.collectionField)||m(s.name)||n(s["x-collection-field"]),{label:g}=(null==(t=s["x-component-props"])?void 0:t.fieldNames)||{};return((0,o.useMemo)(()=>{if(!v||!(null==v?void 0:v.interface)||!["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(v.type))return;let e=r(v.target);if((null==e?void 0:e.template)==="file")return c?[{label:l("Title"),value:"Select"},{label:l("File manager"),value:"FileManager"},{label:l("Tag"),value:"Tag"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},{label:l("File manager"),value:"FileManager"}];if((null==e?void 0:e.template)==="tree"&&["m2m","o2m","m2o"].includes(v.interface))return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-details"),value:"Nester"},!p&&{label:l("Sub-table"),value:"SubTable"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&["m2m","o2m"].includes(v.interface)&&{label:l("Sub-table"),value:"SubTable"},!p&&{label:l("Cascader Select"),value:"CascadeSelect"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"}];switch(v.interface){case"o2m":return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-table"),value:"SubTable"},!p&&{label:l("Sub-details"),value:"Nester"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"},!p&&{label:l("Sub-table"),value:"SubTable"}];case"m2m":case"mbm":return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-details"),value:"Nester"},!p&&{label:l("Sub-table"),value:"SubTable"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&{label:l("Sub-table"),value:"SubTable"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"}];default:return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-details"),value:"Nester"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"}]}},[l,null==v?void 0:v.interface,g,c,p])||[]).filter(Boolean)}},62152(e,t,l){l.d(t,{Lj:()=>S,a9:()=>_,mh:()=>b});var o=l(56920),n=l(71883),r=l(52793),i=l(77583),a=l(51649),s=l(38356),d=l(23610),u=l(44374),c=l(73761),p=l(70892),m=l(38131);let h=(e,t,l,o,n)=>n.includes("/popups/")?2*o.paddingContentVertical+22+o.paddingPageVertical:e?o.paddingContentHorizontalLG:l?t?o.controlPaddingHorizontal+3*o.controlPaddingHorizontalSM+22+o.paddingContentHorizontalLG:o.paddingContentHorizontalLG+12:t?o.paddingSM+o.controlHeight+o.marginXS+2*o.controlPaddingHorizontalSM+22+o.paddingContentHorizontalLG:o.controlHeight+o.marginXS+(o.paddingContentVertical+2)*2+o.paddingContentHorizontalLG,f=e=>{let{token:t}=r.theme.useToken(),{designable:l}=(0,d.erX)(),{heightProps:o}=(0,c.useBlockHeightProps)(),n=(0,s.useLocation)(),{disablePageHeader:i,enablePageTabs:a,hidePageTitle:u}=e||o||{},p=t.sizeXXL-2,m=l?t.controlHeight+2*t.paddingContentHorizontalLG:+t.paddingContentHorizontalLG;return p+h(i,a,u,t,n.pathname)+m},v=()=>{let{token:e}=r.theme.useToken(),{designable:t}=(0,d.erX)();return e.paddingContentVerticalLG+e.margin+2*e.paddingContentVertical+24+(t?e.controlHeight+2*e.paddingContentHorizontalLG:+e.paddingContentHorizontalLG)},g=e=>{let t=k((0,o.useFieldSchema)()),l=f(e),n=v();return t?n:l},x=["workflowManualTasks","approvals","approvalRecords"],y=()=>{var e;let{token:t}=r.theme.useToken(),{heightProps:l}=(0,c.useBlockHeightProps)(),{heightProps:n}=(0,p.El)(),{designable:i}=(0,d.erX)(),a=(0,o.useFieldSchema)(),s=n||l,{titleHeight:h}=l,f=g(s),{name:v}=(0,u.useCollection)(),{heightMode:y,height:b,title:_}=s;if(!(null==s?void 0:s.heightMode)||y===m.D.DEFAULT)return;let S=Object.keys((null==(e=a.parent.properties.actions)?void 0:e.properties)||{}).length>0,k=t.controlHeight+t.padding+t.marginLG,C=S||i?t.controlHeight+2*t.marginLG:t.marginLG,w=(i&&!x.includes(v)?t.controlHeight:22)+2*t.padding+1,M=_?h:0;return y===m.D.FULL_HEIGHT?window.innerHeight-f-M-w-C-k:b-M-C-w-k},b=e=>{let{heightProps:t}=(0,c.useBlockHeightProps)(),l=g(),{heightMode:o,height:n,title:r,titleHeight:i}=t||{},a=r?i:0;if((null==t?void 0:t.heightMode)&&o!==m.D.DEFAULT){if(o===m.D.FULL_HEIGHT){let t=window.innerHeight-l;return(null==e?void 0:e.removeBlockHeaderHeight)&&(t-=a),(null==e?void 0:e.innerExtraHeight)&&(t-=e.innerExtraHeight),t}return n}},_=()=>{let e=(0,o.useFieldSchema)(),t=(0,a.useMemo)(()=>(0,c.getPageSchema)(e),[]),{disablePageHeader:l,enablePageTabs:n,hidePageTitle:r}=(null==t?void 0:t["x-component-props"])||{},i={...null==e?void 0:e["x-component-props"],disablePageHeader:l,enablePageTabs:n,hidePageTitle:r},s=g(i),{heightMode:d,height:u}=i||{};if((null==i?void 0:i.heightMode)&&d!==m.D.DEFAULT)return d===m.D.FULL_HEIGHT?window.innerHeight-s:u},S=()=>{let[e,t]=(0,a.useState)(),l=(0,a.useRef)(null),o=y(),r=(0,a.useCallback)((0,i.debounce)(()=>{var e;if(!l.current)return;let o=l.current.getBoundingClientRect();(null==(e=l.current.querySelector(".ant-table"))?void 0:e.getBoundingClientRect())&&t(o.width)},100),[o]),s=(0,a.useCallback)(e=>{l.current=e&&e.children?e.children[0]:null,r()},[r]);return(0,n.useEventListener)("resize",r),{height:o,width:e,tableSizeRefCallback:s}},k=e=>{if(!e)return null;if("Action.Container"===e["x-component"]){var t,l;return(null==e||null==(l=e.parent)||null==(t=l["x-component-props"])?void 0:t.openMode)!=="page"}return k(e.parent)}},61013(e,t,l){l.d(t,{l:()=>a});var o=l(56920),n=l(51649);let r={},i=e=>/{{.*?}}/g.test(e),a=function(){let{noCache:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{noCache:!1},t=(0,n.useContext)(o.SchemaOptionsContext),l=(0,n.useContext)(o.SchemaExpressionScopeContext);return(a,s)=>{let d,u=!1;if("string"==typeof a&&a.startsWith("{{")&&(u=!0,d=a),a&&"object"==typeof a&&!(0,n.isValidElement)(a)){try{d=JSON.stringify(a)}catch(e){return console.warn("Failed to stringify:",e),a}if(r[d])return r[d];u=i(d)}if(Array.isArray(a)){try{d=JSON.stringify(a)}catch(e){return console.warn("Failed to stringify:",e),a}if(r[d])return r[d];u=i(d)}if(u){let n={...null==t?void 0:t.scope,...l,...s};if(!d)return o.Schema.compile(a,n);try{if(e)return o.Schema.compile(a,n);return r[d]=r[d]||o.Schema.compile(a,n),r[d]}catch(e){return console.log("useCompile error",a,e),o.Schema.compile(a,n)}}return a}}},95951(e,t,l){l.d(t,{er:()=>P,px:()=>b,QI:()=>F,d1:()=>M,kB:()=>C});var o=l(71178),n=l(56920),r=l(27404),i=l(71883),a=l(52793),s=l(13791),d=l(93656),u=l(20148),c=l(51649),p=l(77843),m=l(74737),h=l(30644),f=l(88448),v=l(63557);function g(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(l=>{var o;g(null==(o=e.properties)?void 0:o[l],t)}),e}var x=JSON.parse('{"rE":"2.1.0-alpha.19"}'),y=l(97812);function b(e){return new M(e)}let _=e=>{e&&(e["x-uid"]||(e["x-uid"]=(0,r.uid)()),Object.keys(e.properties||{}).forEach(t=>{_(e.properties[t])}))},S=e=>e,k=(e,t)=>{if(e&&t){for(let l in t)if(Object.prototype.hasOwnProperty.call(t,l)&&t[l]!==(null==e?void 0:e[l]))return!1;return!0}},C=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];let l=e.toJSON(),o={...l,properties:{}},n=null,r=(e,l)=>{Object.keys(e||{}).forEach(o=>{let i=e[o];if(i["x-uid"]===t["x-uid"]){n=e[o];return}l.properties[o]={...i,properties:{}},r(null==i?void 0:i.properties,l.properties[o])})};return r(l.properties,o),[o,n]},w=e=>e;class M{get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){let{api:e,t=w}=this.options;if(!e)return;let l=e=>{if(!e)return[];let t=Object.values(e.properties).length,l=[];return(e.mapProperties(e=>{e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].width=100/t,e["x-uid"]&&l.push({"x-uid":e["x-uid"],"x-component-props":e["x-component-props"]})}),e["x-uid"]&&l.length)?l:[]};this.on("insertAdjacent",async o=>{var n;let{onSuccess:r,current:i,position:s,schema:d,wrap:u,wrapped:c,removed:p}=o,m=[];if((null==c?void 0:c["x-component"])==="Grid.Col"&&(m=m.concat(l(c.parent))),(null==p?void 0:p["x-component"])==="Grid.Col"&&(m=m.concat(l(p.parent))),this.refresh(),!i["x-uid"])return;let h=await e.request({url:`/uiSchemas:insertAdjacent/${i["x-uid"]}?position=${s}`,method:"post",data:{schema:g(d,this.appVersion),wrap:u}});m.length&&await e.request({url:"/uiSchemas:batchPatch",method:"post",data:m}),(null==p?void 0:p["x-uid"])&&await e.request({url:`/uiSchemas:remove/${p["x-uid"]}`,method:"post"}),null==r||r(null==h||null==(n=h.data)?void 0:n.data),a.message.success(t("Saved successfully"),.2)}),this.on("patch",async l=>{let{schema:o}=l;this.refresh(),(null==o?void 0:o["x-uid"])&&(await e.request({url:"/uiSchemas:patch",method:"post",data:{...o}}),a.message.success(t("Saved successfully"),.2))}),this.on("initializeActionContext",async t=>{let{schema:l}=t;(null==l?void 0:l["x-uid"])&&await e.request({url:"/uiSchemas:initializeActionContext",method:"post",data:{...l}})}),this.on("batchPatch",async l=>{let{schemas:o}=l;this.refresh(),await e.request({url:"/uiSchemas:batchPatch",method:"post",data:o}),a.message.success(t("Saved successfully"),.2)}),this.on("remove",async o=>{let{removed:n}=o,r=[];(null==n?void 0:n["x-component"])==="Grid.Col"&&(r=l(n.parent)),this.refresh(),(null==n?void 0:n["x-uid"])&&(await e.request({url:`/uiSchemas:remove/${n["x-uid"]}`,method:"post"}),r.length&&await e.request({url:"/uiSchemas:batchPatch",method:"post",data:r}),a.message.success(t("Saved successfully"),.2))})}prepareProperty(e){e.type||(e.type="void"),e.name||(e.name=(0,r.uid)()),this.current["x-uid"]&&_(e)}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}async emit(e){for(var t=arguments.length,l=Array(t>1?t-1:0),o=1;o<t;o++)l[o-1]=arguments[o];if(!this.events[e])return;let[n,...r]=l;return Promise.all(this.events[e].map(e=>e.bind(this)({current:this.current,...n},...r)))}parentsIn(e){if(!e||!n.Schema.isSchemaInstance(e))return!1;let t=this.current;for(;null==t?void 0:t.parent;){if(t.parent===e)return!0;t=t.parent}return!1}refresh(e){let{refresh:t}=this.options;return null==t?void 0:t(e)}deepMerge(e){let t={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly"},l={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(e).forEach(o=>{t[o]?(this.current[o]=e[o],this.updateModel(t[o],e[o])):l[o]?Object.keys(e[o]).forEach(t=>{(0,u.default)(this.current,[o,t],e[o][t]),this.updateModel([l[o],t],e[o][t])}):this.current[o]=e[o]}),this.emit("patch",{schema:e})}getSchemaAttribute(e,t){return(0,d.default)(this.current,e,t)}shallowMerge(e){let t={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly","x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(e).forEach(l=>{this.current[l]=e[l],t[l]&&this.updateModel(t[l],e[l])}),this.emit("patch",{schema:e})}updateModel(e,t){let l=l=>{(0,u.default)(l,e,t)};this.model&&l(this.model),this.query&&this.query.take(l)}insertAdjacent(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};switch(e){case"beforeBegin":return this.insertBeforeBegin(t,l);case"afterBegin":return this.insertAfterBegin(t,l);case"beforeEnd":return this.insertBeforeEnd(t,l);case"afterEnd":return this.insertAfterEnd(t,l)}}recursiveRemoveIfNoChildren(e,t){let l;if(!e)return;let o=e,n=null==t?void 0:t.breakRemoveOn;for(;o;){if("function"==typeof n){if(n(o))break}else if(k(o,n))break;if(Object.keys(o.properties||{}).length>0)break;o.parent&&(l=o.parent.removeProperty(o.name)),o=o.parent}return l}remove(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{breakRemoveOn:l,removeParentsIfNoChildren:o}=t,n=e||this.current,r=n.parent.removeProperty(n.name);if(o){let e=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:l});e&&(r=e)}return this.emit("remove",{removed:r})}removeWithoutEmit(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{breakRemoveOn:l,removeParentsIfNoChildren:o}=t,n=e||this.current,r=n.parent.removeProperty(n.name);if(o){let e=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:l});e&&(r=e)}return r}insertBeforeBeginOrAfterEnd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current)||!n.Schema.isSchemaInstance(e)||this.current.parent!==e.parent)return;let l=0,o=0;return this.current.parent.mapProperties((t,n,r)=>{this.current.name===n&&(o=r),e.name===n&&(l=r)}),l>o?this.insertBeforeBegin(e,t):this.insertAfterEnd(e,t)}insertBeforeBegin(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;let l={onSuccess:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t;if(n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i}))}else e&&(e=(0,s.default)(e));let d={},u=!1,c=0,p=0;this.current.parent.mapProperties((e,t)=>{t===this.current.name&&(p=c,u=!0,++c),e["x-index"]=c,++c,u&&(d[t]=e,this.current.parent.removeProperty(t))}),this.prepareProperty(e);let m=o(e),h=this.current.parent.addProperty(m.name||(0,r.uid)(),m);h["x-index"]=p,h.parent=this.current.parent,this.current.parent.setProperties(d);let[f,v]=C(h,e);this.emit("insertAdjacent",{position:"beforeBegin",schema:v,wrapped:m,wrap:f,...l})}insertAfterBegin(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;let l={onSuccess:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t;if(n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i}))}else e&&(e=(0,s.default)(e));let d={},u=1;this.current.mapProperties((e,t)=>{e["x-index"]=u,++u,d[t]=e}),this.current.properties={},this.prepareProperty(e);let c=o(e),p=this.current.addProperty(c.name||(0,r.uid)(),c);p["x-index"]=0,p.parent=this.current,this.current.setProperties(d);let[m,h]=C(p,e);this.emit("insertAdjacent",{position:"afterBegin",schema:h,wrap:m,wrapped:c,...l})}insertBeforeEnd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;delete e["x-index"];let l={onSuccess:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t;if(n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i}))}else e&&(e=(0,s.default)(e));this.prepareProperty(e);let d=o(e),u=this.current.addProperty(d.name||(0,r.uid)(),d);u.parent=this.current;let[c,p]=C(u,e);return this.emit("insertAdjacent",{position:"beforeEnd",schema:p,wrap:c,wrapped:d,...l})}insertAfterEnd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;let l={onSuccess:null==t?void 0:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t,d=0,u=0,c=!1,p={};if(this.current.parent.mapProperties((e,t)=>{e["x-index"]=d,t===this.current.name&&(u=++d,c=!0),++d,c&&t!==this.current.name&&(p[t]=e,this.current.parent.removeProperty(t))}),n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i})),e.parent=null}else e&&(e=(0,s.default)(e));this.prepareProperty(e);let m=o(e),h=this.current.parent.addProperty(m.name||(0,r.uid)(),m);h.parent=this.current.parent,h["x-index"]=u,this.current.parent.setProperties(p);let[f,v]=C(h,e);this.emit("insertAdjacent",{position:"afterEnd",schema:v,wrap:f,wrapped:m,...l})}constructor(e){this.events={},this.options=e,this.current=e.current,this.appVersion=e.appVersion}}function F(){let e=(0,c.useContext)(n.SchemaOptionsContext),t=(0,c.useMemo)(()=>(null==e?void 0:e.components)||{},[e]);return e=>{if(!e)return null;if("string"!=typeof e)return e;let l=(0,d.default)(t,e);return l||console.error(`[nocobase]: Component "${e}" not found`),l}}function P(){let{designable:e,setDesignable:t,refresh:l,reset:r}=(0,c.useContext)(v.u),a=(0,c.useContext)(n.SchemaOptionsContext),s=(0,c.useMemo)(()=>(null==a?void 0:a.components)||{},[a]),g=(0,c.useMemo)(()=>()=>(0,o.jsx)(o.Fragment,{}),[]),_=(0,i.useUpdate)(),S=(0,h.o8)(),k=(0,h.cQ)(),C=(0,c.useCallback)(e=>{null==l||l(),_(),null==S||S(e),null==k||k()},[l,_,S,k]),w=(0,n.useField)(),M=(0,n.useFieldSchema)(),F=(0,m.VB)(),{t:P}=(0,p.useTranslation)(),j=(0,c.useMemo)(()=>b({t:P,api:F,refresh:C,current:M,model:w,appVersion:x.rE}),[P,F,C,M,w]);(0,c.useEffect)(()=>{j.loadAPIClientEvents()},[j]);let{isMobileLayout:A}=(0,y.mY)();return{dn:j,designable:!A&&e,reset:r,refresh:C,setDesignable:t,DesignableBar:g,findComponent:(0,c.useCallback)(e=>{if(!e)return null;if("string"!=typeof e)return e;let t=(0,d.default)(s,e);return(null==t?void 0:t[f.PE])??t},[d.default]),on:j.on.bind(j),patch:(0,c.useCallback)((e,t)=>{let l=e=>{Object.keys(e).forEach(t=>{let l=e[t];"title"===t&&(w.title=l,M.title=l),"x-decorator-props"===t&&(w.decoratorProps||(w.decoratorProps={}),M["x-decorator-props"]||(M["x-decorator-props"]={}),Object.keys(l).forEach(e=>{w.decoratorProps[e]=l[e],M["x-decorator-props"][e]=l[e]})),"x-component-props"===t&&(w.componentProps||(w.componentProps={}),M["x-component-props"]||(M["x-component-props"]={}),Object.keys(l).forEach(e=>{w.componentProps[e]=l[e],M["x-component-props"][e]=l[e]}))})};if("string"==typeof e){let o={};return(0,u.default)(o,e,t),l(o)}l(e),C()},[j]),shallowMerge:(0,c.useCallback)(e=>{j.shallowMerge(e)},[j]),deepMerge:(0,c.useCallback)(e=>{j.deepMerge(e)},[j]),remove:(0,c.useCallback)((e,t)=>{j.remove(e,t)},[j]),insertAdjacent:(0,c.useCallback)((e,t,l)=>{j.insertAdjacent(e,t,l)},[j]),insertBeforeBegin:(0,c.useCallback)(e=>{j.insertBeforeBegin(e)},[j]),insertAfterBegin:(0,c.useCallback)(e=>{j.insertAfterBegin(e)},[j]),insertBeforeEnd:(0,c.useCallback)(e=>{j.insertBeforeEnd(e)},[j]),insertAfterEnd:(0,c.useCallback)(e=>{j.insertAfterEnd(e)},[j])}}},87463(e,t,l){l.d(t,{H:()=>s});var o=l(56920),n=l(28260),r=l(51649),i=l(29699);let a=()=>null;a.isNullComponent=!0;let s=()=>{let{designable:e}=(0,n.er)(),t=(0,o.useFieldSchema)(),l=(0,r.useMemo)(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?i.Bw:a,[t]),s=(0,n.xZ)(l);return e&&s||a}},4922(e,t,l){l.d(t,{Y:()=>n});let o=()=>({}),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{useProps:t=o,...l}=e,n=t;"function"!=typeof t&&(n=o);let r=n();return{...l,...r}}},23610(e,t,l){l.d(t,{iI7:()=>D.iI,a1G:()=>d.ShowFormData,yt2:()=>tX,flR:()=>r.fl,FVw:()=>r5.FV,FrL:()=>rn.Fr,CqQ:()=>E,$Eq:()=>T,ZB7:()=>r5.ZB,TrS:()=>tz,sIN:()=>a2.sI,a2g:()=>d.getRenderContent,t6u:()=>u.t6,qIn:()=>nE.qI,HPy:()=>r.HP,R_2:()=>nR.R_,doK:()=>D.do,bZ4:()=>r.bZ,pxY:()=>ep.px,pde:()=>nR.pd,CEt:()=>rn.CE,lum:()=>ep.lu,OpO:()=>u.Op,tO8:()=>r.tO,nxV:()=>rn.nx,TDj:()=>lS,xA9:()=>r5.xA,lNE:()=>i1.l,ud$:()=>e7,l46:()=>n3,X_:()=>d.DraggableContext,QD_:()=>rn.QD,ud1:()=>r.ud,Dgp:()=>D.Dg,tvd:()=>D.tv,QEB:()=>i0,X6x:()=>tS,jZb:()=>lp,tn0:()=>nE.tn,dF1:()=>l$.dF,kBD:()=>ep.kB,Gjn:()=>r.Gj,VFg:()=>tw,Pnr:()=>rn.Pn,zN:()=>r.zN,dKS:()=>iJ,LMh:()=>nR.LM,lTd:()=>eR,rlt:()=>eB,dWC:()=>t1.dW,cWk:()=>r.cW,Zy6:()=>tV,PB5:()=>i4.PB,UTu:()=>rn.UT,jeY:()=>D.je,TB2:()=>r.TB,D6h:()=>r1,d9b:()=>l$.d9,fM:()=>lv,X43:()=>l_.X,uc_:()=>rI,pEl:()=>i4.pE,T$Q:()=>l_.T,GD6:()=>u.GD,mJi:()=>nR.mJ,C5g:()=>lx.C5,OJX:()=>ep.OJ,Bmi:()=>aN,u4V:()=>sv.u,lrV:()=>rn.lr,fDF:()=>n.fD,N$k:()=>e4.N$,_sT:()=>l$._s,rNg:()=>lg.rN,RhU:()=>r.Rh,Bnf:()=>oF,UyB:()=>e6,xq$:()=>D.xq,RB3:()=>i4.RB,I5x:()=>eE,hqJ:()=>nR.hq,XIK:()=>aw,m2w:()=>nC,ccy:()=>sf,NVg:()=>lx.NV,kDr:()=>D.kD,J3t:()=>t1.J3,d09:()=>r.d0,AG:()=>aJ,Xjr:()=>oI,uwA:()=>e4.uw,KDQ:()=>ev,$mi:()=>oc.$,L1H:()=>d.Sortable,QoO:()=>rn.Qo,q7s:()=>D.q7,Mp5:()=>d.DndContext,xB5:()=>ep.xB,B4G:()=>D.B4,YIz:()=>iI,$xS:()=>i8,o8F:()=>oA,qKt:()=>i4.qK,_OO:()=>l$._O,qy$:()=>nQ,W1t:()=>tZ,Z0V:()=>nE.Z0,cGx:()=>ri,Q2z:()=>rn.Q2,YW0:()=>ll,HvB:()=>u.Hv,ic7:()=>r0,QpY:()=>D.Qp,tUM:()=>aH,oAT:()=>D.oA,zBI:()=>e8,gBz:()=>d.SortableProvider,eIh:()=>D.eI,i_r:()=>rO.i,DVX:()=>D.DV,b7u:()=>e4.b7,Mwt:()=>i4.Mw,Kql:()=>r.Kq,XOn:()=>D.XO,ozN:()=>iU.o,nu1:()=>tv.n,rTt:()=>a2.rT,eBw:()=>r2,xZI:()=>ep.xZ,MIq:()=>r.MI,JaO:()=>rU,htN:()=>eW,Eaz:()=>r.E,qy5:()=>n6,IX0:()=>lg.IX,lSn:()=>lx.lS,BsJ:()=>e4.Bs,_22:()=>iX._,sxL:()=>ot,xPi:()=>tv.x,b2W:()=>rG.b,sDQ:()=>i9,Xzy:()=>D.Xz,gt0:()=>i5,QIX:()=>e9,i_F:()=>nD,Ypd:()=>r.Yp,SOm:()=>e4.SO,VXI:()=>r.VX,nKd:()=>lc,N3p:()=>u.N3,dJT:()=>e4.dJ,vPC:()=>D.vP,a97:()=>ep.a9,TNL:()=>D.TN,Qgm:()=>tb.Q,RLS:()=>ig,OqW:()=>e4.Oq,j0_:()=>rC,zVE:()=>a1,yVm:()=>r.yV,B_g:()=>rr,Hbp:()=>ep.Hb,lhV:()=>D.lh,yGk:()=>e4.yG,QIi:()=>ep.QI,Q00:()=>iW,OAH:()=>u.OA,JQe:()=>D.JQ,xqq:()=>r.xq,zEg:()=>e3.z,wN6:()=>iU.w,fDM:()=>rn.fD,uUT:()=>lb,BCL:()=>aA.BC,D50:()=>r.D5,Fag:()=>ep.F,MoU:()=>r.Mo,wnJ:()=>e4.wn,ISS:()=>t_.I,m$h:()=>lA,c_d:()=>e4.c_,Hi5:()=>aq,x1p:()=>rn.x1,DYS:()=>u.DY,U6o:()=>r.U6,LjE:()=>ep.Lj,l2i:()=>r.l2,Um:()=>e4.Um,Y2j:()=>lo,O$4:()=>i4.O$,G2C:()=>lL.G2,wA7:()=>sl,$t1:()=>D.$t,_bM:()=>l$._b,b6K:()=>oc.b,vzL:()=>nX,lNX:()=>l$.lN,rcl:()=>r.rc,gZ:()=>i4.gZ,msY:()=>rn.ms,U8O:()=>r.U8,Sh8:()=>r.Sh,mhY:()=>ep.mh,tXY:()=>lx.tX,Sc0:()=>or,p9h:()=>aY,gBZ:()=>d.SortableContext,JDj:()=>aW,hbv:()=>ro,RD4:()=>rJ.R,bee:()=>i4.be,PSc:()=>r.PS,hsK:()=>e3.h,oVU:()=>n$,IJ7:()=>D.IJ,f2z:()=>oN.f,OZ6:()=>tk,pA3:()=>e4.pA,$5j:()=>r.$5,J1:()=>D.J1,dVP:()=>d.DateFilterDynamicComponent,E76:()=>r.E7,j9R:()=>nL,vjx:()=>rD,mz8:()=>r5.mz,Doh:()=>u.Do,vxQ:()=>nU,Us6:()=>ep.Us,UqM:()=>d.SortableItem,lVW:()=>A,f7I:()=>aZ,ARu:()=>lj,TDH:()=>ep.TD,l6P:()=>eP,g9w:()=>e4.g9,s23:()=>lu,GjU:()=>r.nY,GmQ:()=>i4.Gm,skP:()=>n2.s,C4D:()=>n1,arW:()=>ix.a,v93:()=>aE,Wis:()=>r.Wi,jE9:()=>ep.jE,dbD:()=>rq.d,Ff5:()=>D.Ff,gM2:()=>e4.gM,FZR:()=>nR.FZ,PnP:()=>a5.P,nlx:()=>eL,AQf:()=>nE.AQ,FoY:()=>i2,w2W:()=>i4.w2,z45:()=>r.z4,bkX:()=>lk,jgC:()=>aL,Ur4:()=>a3,lE3:()=>D.lE,U5u:()=>D.U5,LtX:()=>r.Lt,cl6:()=>iE,d1R:()=>ep.d1,rrz:()=>t1.rr,B8B:()=>iK,hY7:()=>oN.h,Ob5:()=>tH,erX:()=>ep.er,MqW:()=>u.Mq,S5r:()=>rG.S,YYe:()=>ep.YY,ami:()=>a2.am,LBS:()=>rW,L3t:()=>d.DragHandler,oMF:()=>ey});var o={};l.r(o),l.d(o,{Action:()=>r.rc,ActionBar:()=>r.E7,ActionBarProvider:()=>r.xq,ActionContext:()=>r.yV,ActionContextNoRerender:()=>r.Wi,ActionContextProvider:()=>r.z4,ActionDesigner:()=>r.U6,AfterSuccess:()=>r.Kq,AllDataBlocksContext:()=>t1.rr,AllDataBlocksProvider:()=>t1.J3,AntdSchemaComponentPlugin:()=>lk,AntdSchemaComponentProvider:()=>lS,AppendsTreeSelect:()=>lA,AssignedFieldValues:()=>r.TB,AssociationField:()=>nC,AssociationFieldMode:()=>oF,AssociationFieldModeProvider:()=>oA,AssociationSelect:()=>nD,AttachmentList:()=>l$._s,AutoComplete:()=>nL,BackButtonUsedInSubPage:()=>e3.h,Block:()=>r2,BlockItem:()=>nE.Z0,BlockItemCard:()=>nE.tn,BlockItemCardContext:()=>nE.AQ,BlocksSelector:()=>r.Gj,ButtonEditor:()=>r.Yp,CardItem:()=>n$,Cascader:()=>nU,Checkbox:()=>or,CollectionSelect:()=>nX,ColorPicker:()=>n2.s,ColorSelect:()=>n6,Cron:()=>n3,CronSet:()=>ro,DataSourceCollectionCascader:()=>n1,DataSourceSelect:()=>nQ,DateFormatCom:()=>rG.b,DatePicker:()=>rn.lr,DatePickerProvider:()=>rn.Qo,Details:()=>rr,DetailsDesigner:()=>E,Divider:()=>ri,EditComponent:()=>D.iI,EditDefaultValue:()=>D.tv,EditDescription:()=>D.JQ,EditOperator:()=>D.B4,EditPattern:()=>D.$t,EditRequired:()=>D.Qp,EditSortField:()=>aL,EditTable:()=>rC,EditTableAction:()=>rD,EditTableActionContext:()=>rI,EditTitle:()=>D.Xz,EditTitleField:()=>D.Ff,EditTooltip:()=>D.IJ,EditValidationRules:()=>D.vP,Editable:()=>i2,EllipsisWithTooltip:()=>nR.R_,ErrorFallback:()=>tv.x,Expand:()=>rU,ExpiresRadio:()=>rG.S,FieldsTreeSelect:()=>lj,Fieldset:()=>rW,Filter:()=>e4.dJ,FilterAction:()=>e4.Bs,FilterActionContext:()=>e4.SO,FilterContext:()=>e4.gM,FilterDynamicComponent:()=>e4.N$,FilterLogicContext:()=>e4.c_,Form:()=>A,FormDialog:()=>rJ.R,FormDrawer:()=>sl,FormField:()=>e8,FormItem:()=>D.eI,FormV2:()=>eW,G2Plot:()=>r1,G2PlotRenderer:()=>r0,Grid:()=>r5.xA,GridCard:()=>ig,GridRowContext:()=>r5.mz,HTMLEncode:()=>nR.mJ,ICON_POPUP_Z_INDEX:()=>oc.b,IconPicker:()=>ix.a,Input:()=>nR.pd,InputNumber:()=>iI,InputReadPretty:()=>nR.FZ,InputRecordPicker:()=>i4.qK,Json:()=>nR.LM,LinkageFilter:()=>sf,List:()=>iK,Markdown:()=>iU.o,MarkdownReadPretty:()=>iU.w,Menu:()=>tZ,NanoIDInput:()=>iW,Page:()=>ll,PagePopups:()=>lg.rN,PageTabs:()=>lo,Pagination:()=>iJ,ParentRouteContext:()=>tV,Password:()=>iX._,Percent:()=>i0,PopupSettingsProvider:()=>l_.T,Preview:()=>i1.l,QuickEdit:()=>i5,Radio:()=>ot,ReadPretty:()=>nR.hq,ReadPrettyRecordPicker:()=>i4.w2,RecordPicker:()=>i4.O$,RecordPickerContext:()=>i4.pE,RecordPickerProvider:()=>i4.be,RefreshDataBlockRequest:()=>r.ud,RemoteSelect:()=>eR,RemoveButton:()=>r.d0,RemoveConditionContext:()=>e4.b7,RequestSettings:()=>r.Rh,RichText:()=>i9,SecondConFirm:()=>r.VX,Select:()=>eP,SkipValidation:()=>r.zN,Space:()=>i8,StablePopover:()=>oc.$,Table:()=>aw,TableBlockDesigner:()=>aE,TableField:()=>aN,TableSelectorDesigner:()=>aY,TableV2:()=>aq,Tabs:()=>aH,TabsContextProvider:()=>oN.h,Templates:()=>eE,TestDesigner:()=>nE.qI,TextAreaWithGlobalScope:()=>a3,TimePicker:()=>aJ,TreeSelect:()=>aZ,UnixTimestamp:()=>a1,Upload:()=>l$._O,Uploader:()=>l$.d9,Variable:()=>a2.rT,VariableScopeProvider:()=>a2.sI,VariableSelect:()=>a5.P,actionSettings:()=>r.Sh,actionSettingsItems:()=>r.Mo,allowAddNew:()=>D.lE,attachmentFileTypes:()=>l$.lN,defaultFieldNames:()=>ev,fetchTemplateData:()=>eB,filterFormItemSettings:()=>D.Dg,findByUid:()=>tS,findKeysByUid:()=>tw,findMenuItem:()=>tk,formDetailsSettings:()=>e9,formItemSettings:()=>D.DV,formSettings:()=>e6,formV1Settings:()=>T,genStyleHook:()=>n.fD,getCurrentOptions:()=>ey,getDateExact:()=>rn.Q2,getDatePickerLabels:()=>i4.Mw,getDateRanges:()=>rn.fD,getLabelFormatValue:()=>i4.PB,getPopupPathFromParams:()=>lx.C5,getStoredPopupContext:()=>lx.lS,getTabSchema:()=>lp,getZIndex:()=>r.fl,handleDateChangeOnForm:()=>rn.QD,inferPickerType:()=>rn.Pn,isBulkEditAction:()=>r.PS,isFileCollection:()=>D.XO,isMobile:()=>rn.Fr,isShowFilePicker:()=>i4.Gm,isTabPage:()=>lc,isWriteEmailAction:()=>r.cW,mapDatePicker:()=>rn.x1,mapRangePicker:()=>rn.UT,mapTimeFormat:()=>aW,matchMimetype:()=>l$._b,moment2str:()=>rn.ms,navigateToTab:()=>lu,pageSettings:()=>lv,pageTabSettings:()=>lb,readPrettyFormSettings:()=>e7,removeNullCondition:()=>e4.pA,resolveFilterPickerFormat:()=>rn.CE,storePopupContext:()=>lx.NV,useActionBarContext:()=>r.MI,useActionContext:()=>r.D5,useAfterSuccessOptions:()=>r.bZ,useAllDataBlocks:()=>t1.dW,useAssociationFieldContext:()=>lL.G2,useAssociationFieldModeContext:()=>oI,useBackButton:()=>e3.z,useCloseAction:()=>r.nY,useColumnSchema:()=>aA.BC,useColumnSettings:()=>rq.d,useCurrentPopupContext:()=>lg.IX,useDatePickerContext:()=>rn.nx,useDownloadLogs:()=>tv.n,useEnsureOperatorsValid:()=>D.lh,useFieldMode:()=>D.J1,useFieldNames:()=>i4.gZ,useFilterActionProps:()=>e4.Um,useFilterFieldOptions:()=>e4.g9,useFilterFieldProps:()=>e4.yG,useFilterOptions:()=>e4.uw,useFormDataTemplates:()=>eL,useGetAriaLabelOfAction:()=>r.U8,useGetAriaLabelOfDrawer:()=>r.HP,useGetAriaLabelOfModal:()=>r.tO,useGetAriaLabelOfPopover:()=>r.l2,useGetFilterFieldOptions:()=>e4.Oq,useGetFilterOptions:()=>e4.wn,useGridContext:()=>r5.ZB,useGridRowContext:()=>r5.FV,useIsAddNewForm:()=>D.TN,useIsAssociationField:()=>D.xq,useIsFieldReadPretty:()=>D.U5,useIsFileField:()=>D.oA,useIsFormReadPretty:()=>D.q7,useIsSelectFieldMode:()=>D.je,useLabelUiSchema:()=>i4.RB,useLinkageAction:()=>r.Lt,useListBlockContext:()=>iE,useMenuDragEnd:()=>tX,useMenuTranslation:()=>tb.Q,useNocoBaseRoutes:()=>tH,useParentRoute:()=>tz,usePopupSettings:()=>l_.X,useStyles:()=>t_.I,useTableColumnIntegration:()=>rO.i,useTabsContext:()=>oN.f,useTitleFieldOptions:()=>D.kD,useUploadStyles:()=>l$.dF,useValidateSchema:()=>D.do,useVariableScope:()=>a2.am,useZIndexContext:()=>r.$5,withSearchParams:()=>lx.tX,zIndexContext:()=>r.E});var n=l(54969),r=l(6522),i=l(71178),a=l(51649),s=l(83468),d=l(91032),u=l(90995),c=l(72548);let p=e=>async function(){try{var t;let l=await this.api.request(e);return null==l||null==(t=l.data)?void 0:t.data}catch(e){return[]}};var m=l(56220),h=l(44814),f=l(56920),v=l(52793),g=l(74737),x=l(43288),y=l(30644),b=l(29699),_=l(25952),S=l(75830),k=l(24768);let C=e=>{let{form:t,children:l,...o}=e,n=(0,f.useField)(),r=(0,f.useFieldSchema)(),a=(0,ep.TD)(t.createVoidField({...n.props,basePath:""}));return(0,i.jsx)(f.FieldContext.Provider,{value:void 0,children:(0,i.jsx)(f.FormContext.Provider,{value:t,children:(0,i.jsx)(m.FormLayout,{layout:"vertical",...o,children:(0,i.jsx)(y.dw,{basePath:a.address,schema:r,onlyRenderProperties:!0})})})})},w=e=>e.children,M=e=>{let{form:t,children:l,disabled:o,...n}=e,r=(0,f.useField)(),s=(0,f.useFieldSchema)(),d=(0,ep.TD)(t.createVoidField({...r.props,basePath:""})),u=(0,ep.xZ)(s["x-component"],w);return(0,a.useEffect)(()=>{t.disabled=o||r.disabled},[o,r.disabled]),(0,i.jsx)(v.ConfigProvider,{componentDisabled:o,children:(0,i.jsx)(f.FieldContext.Provider,{value:void 0,children:(0,i.jsx)(f.FormContext.Provider,{value:t,children:(0,i.jsx)(m.FormLayout,{layout:"vertical",...n,children:(0,i.jsx)(f.FieldContext.Provider,{value:d,children:(0,i.jsx)(u,{...r.componentProps,children:(0,i.jsx)(y.dw,{basePath:d.address,schema:s,onlyRenderProperties:!0})})})})})})})},F=e=>{let{request:t,initialValue:l}=e;return t||(()=>Promise.resolve({data:l}))},P=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,g.bP)(F(t),e)},j=(0,a.createContext)(null);j.displayName="FormBlockContext";let A=(0,f.observer)(e=>{let{request:t,effects:l,initialValue:o,useValues:n=P,...r}=e,s=(0,f.useFieldSchema)(),d=(0,f.useField)(),u=(0,a.useMemo)(()=>(0,h.createForm)({effects:l}),[]),c=n({uid:s["x-uid"],async onSuccess(e){await u.reset(),u.setValues(null==e?void 0:e.data),u.setInitialValues(null==e?void 0:e.data)}},e),p=(0,a.useContext)(j);return(0,i.jsx)(j.Provider,{value:{parent:p,form:u,result:c,field:d,fieldSchema:s},children:(0,i.jsx)(v.Spin,{spinning:(null==c?void 0:c.loading)||!1,children:"Form"===s["x-decorator"]?(0,i.jsx)(M,{form:u,...r}):(0,i.jsx)(C,{form:u,...r})})})},{displayName:"Form"});A.Designer=function(){let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)(),{componentNamePrefix:o}=(0,k.kU)();return(0,i.jsxs)(b.xK,{template:l,title:t||e,children:[(0,i.jsx)(_.l,{componentName:`${o}Form`,collectionName:e}),(0,i.jsx)(b.kT,{}),(0,i.jsx)(b.d$,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};var I=l(31675);let T=new I.RT({name:"FormV1Settings",items:[{name:"template",Component:_.l,useComponentProps(){let{name:e}=(0,x.k7)(),{componentNamePrefix:t}=(0,k.kU)();return{componentName:`${t}Form`,collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});var D=l(60929);let R=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"FormSettings",template:l,title:t||e})},L=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"ReadPrettyFormSettings",template:l,title:t||e})},E=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"FormDetailsSettings",template:l,title:t||e})},N=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"blockSettings:filterForm",template:l,title:t||e})};var B=l(69412),Y=l(80461),q=l(99847),O=l(49948),$=l(10691),V=l(27404),z=l(77583),H=l(77850),K=l(18111),U=l(70136),G=l(28227),W=l(14187),J=l(92619),X=l(4627),Z=l(83006),Q=l(43923),ee=l(4922),et=l(95210),el=l(62152),eo=l(63526),en=l(77843),er=l(69575),ei=l(65457),ea=l(82113),es=l(91815),ed=l(23460),eu=l(29558),ec=l(58980),ep=l(28260),em=l(46638),eh=l(46724),ef=l(81607);let ev={label:"label",value:"value",color:"color",options:"children"};function eg(e,t){let l=[];if(!Array.isArray(e))return l;for(let o=0;o<e.length;o++){let n=e[o][t.options];Array.isArray(n)&&l.push(...eg(n,t)),l.push({...e[o]})}return l}function ex(e,t,l){if(!e)return[];let o=[];for(let n of l){let l=e.find(e=>e[t.value]==n)||{value:n,label:n?n.toString():n};o.push(l)}return o}function ey(e,t,l){let o=eg(t,l),n=(0,z.castArray)(e).map(e=>(0,eo.isPlainObject)(e)?e[l.value]:e);return ex(o,l,n)}var eb=l(84951),e_=l(60430);let eS=(0,f.observer)(e=>{let[t,l]=(0,a.useState)(!0),[o,n]=(0,a.useState)([]),r=(0,f.useField)(),s=(0,eh.E1)();return((0,a.useEffect)(()=>{var t;let o={...ev,...e.fieldNames},a=r.dataSource||e.options||(null==s?void 0:s.uiSchema.enum)||[],d=ey(r.value,a,o);!(0,V.isValid)(e.value)&&!d.length||(0,h.isArrayField)(r)&&(null==r||null==(t=r.value)?void 0:t.length)===0||(n(null!==r.value&&d.map((e,t)=>(0,i.jsx)(v.Tag,{color:e[o.color],icon:"string"==typeof e.icon?(0,i.jsx)(e_.In,{type:e.icon}):e.icon,children:e[o.label]},t))),l(!1))},[null==s?void 0:s.uiSchema.enum,r,r.dataSource,r.value,e.fieldNames,e.options,e.value]),t)?null:(0,i.jsx)(ef.R,{ellipsis:e.ellipsis,children:o})},{displayName:"SelectReadPretty"}),ek=(0,eb.A)(eS),eC=e=>!(0,V.isValid)(e)||"object"==typeof e&&0===Object.keys(e).length,ew=e=>{let{value:t,options:l,onChange:o,fieldNames:n,mode:r,loading:a,rawOptions:s,defaultValue:d,...u}=e,c=em.isDesktop?"":eF,p=em.isDesktop?void 0:"topLeft",m=t=>{var o;if(eC(t))return;let i=null==(o=ey((0,V.toArr)(t).filter(e=>e).map(e=>(0,eo.isPlainObject)(e)?e[n.value]:e),l,n))?void 0:o.map(e=>({label:e[n.label],value:e[n.value]}));return["tags","multiple"].includes(r)||e.multiple?i:i.shift()};return(0,i.jsx)(v.Select,{rootClassName:c,placement:p,role:"button","data-testid":`select-object-${r||"single"}`,value:m(t),defaultValue:m(d),allowClear:{clearIcon:(0,i.jsx)(ea.CloseCircleFilled,{role:"button","aria-label":"icon-close-select"})},labelInValue:!0,notFoundContent:a?(0,i.jsx)(v.Spin,{}):(0,i.jsx)(v.Empty,{image:v.Empty.PRESENTED_IMAGE_SIMPLE}),options:l,fieldNames:n,showSearch:!0,popupMatchSelectWidth:!1,filterOption:(e,t)=>((null==t?void 0:t[n.label||"label"])??"").includes(e),filterSort:(e,t)=>((null==e?void 0:e[n.label||"label"])??"").toLowerCase().localeCompare(((null==t?void 0:t[n.label||"label"])??"").toLowerCase()),onChange:t=>{let i=ey((0,V.toArr)(t).map(e=>e.value),s||l,n);["tags","multiple"].includes(r)||e.multiple?null==o||o(i):null==o||o(i.shift()||null)},mode:r,tagRender:e=>(0,i.jsx)(v.Tag,{role:"button","aria-label":e.label,closeIcon:(0,i.jsx)(ea.CloseOutlined,{role:"button","aria-label":"icon-close-tag"}),...e,children:e.label}),maxTagCount:"responsive",maxTagPlaceholder:e=>(0,i.jsxs)(v.Tooltip,{title:(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,maxWidth:"100%"},children:e.map(e=>(0,i.jsx)(v.Tag,{style:{margin:0,background:"#fafafa",border:"1px solid #d9d9d9",whiteSpace:"normal",wordBreak:"break-word",maxWidth:"100%"},children:e.label},e.value))}),overlayInnerStyle:{background:"#fff",color:"#000",padding:8,maxWidth:"100%"},color:"#fff",overlayStyle:{pointerEvents:"auto",maxWidth:300},children:["+",e.length,"..."]}),...u})},eM=(e,t)=>((null==t?void 0:t.label)??"").toLowerCase().includes((e||"").toLowerCase()),eF=(0,$.css)`
|
|
1442
|
+
`;return(0,r.jsxs)("div",{style:{maxHeight:300,overflowY:"auto"},children:[e.map(e=>(0,r.jsx)("div",{role:"option",onClick:()=>g(e.value),className:l,children:o(e.label)},e.value)),(0,r.jsx)(u.Divider,{style:{margin:"4px 0"}}),t.map(e=>(0,r.jsx)("div",{role:"option",className:l,onClick:()=>g(e.value),title:o(e.label),children:o(e.label)},e.value))]})};return(0,r.jsxs)(u.Space.Compact,{style:{...e.style,width:"100%"},children:[(0,r.jsx)(u.Select,{options:h,open:s,onDropdownVisibleChange:d,...e,allowClear:!1,style:{width:"100%",minWidth:100,maxWidth:["past","next","exact",void 0].includes(null==t?void 0:t.type)?100:null},value:(null==t?void 0:t.type)||"exact",onChange:g,dropdownRender:x}),["past","next"].includes(null==t?void 0:t.type)&&[(0,r.jsx)(u.InputNumber,{value:null==t?void 0:t.number,onChange:e=>{l({...t,number:e})}},"number"),(0,r.jsx)(u.Select,{value:null==t?void 0:t.unit,style:{minWidth:130,maxWidth:140},onChange:e=>{l({...t,unit:e})},options:[{value:"day",label:n("Day")},{value:"week",label:n("Calendar week")},{value:"month",label:n("Calendar Month")},{value:"year",label:n("Calendar Year")}],popupMatchSelectWidth:!0},"unit")],((null==t?void 0:t.type)==="exact"||!(null==t?void 0:t.type))&&(0,r.jsx)(v,{...e})]})}},39690(e,t,l){l.d(t,{gB:()=>m,X_:()=>p,L1:()=>v,Uq:()=>b,Pd:()=>h,L3:()=>_});var o=l(71178),n=l(72741),r=l(38533),i=l(10691),a=l(56920),s=l(77583),d=l(51649),u=l(54969),c=l(28260);let p=(0,d.createContext)(null);p.displayName="DraggableContext";let m=(0,d.createContext)(null);m.displayName="SortableContext";let h=e=>{let{id:t,data:l,children:n}=e,i=(0,r.useDraggable)({id:t,data:l}),a=(0,r.useDroppable)({id:t,data:l}),s=(0,d.useMemo)(()=>({draggable:i,droppable:a}),[i,a]);return(0,o.jsx)(m.Provider,{value:s,children:n})},f=e=>new n.TinyColor(e).setAlpha(.15).toHex8String(),v=e=>{var t,l;let{component:o,overStyle:n,style:r,children:s,openMode:c,...p}=e,{token:h}=(0,u.rd)(),{draggable:v,droppable:g}=(0,d.useContext)(m),{isOver:x,setNodeRef:y}=g,b={...r},_=(0,a.useFieldSchema)(),S=(null==_?void 0:_["x-component"])==="Action.Link"||"a"===o;return x&&(null==v||null==(t=v.active)?void 0:t.id)!==(null==g||null==(l=g.over)?void 0:l.id)&&(b[S?"color":"background"]=f(h.colorSettings),Object.assign(b,n)),d.default.createElement(o||"div",{role:"none",...p,className:(0,i.cx)("nb-sortable-designer",e.className),ref:y,style:b},s)},g=e=>{let t=x(e),l=(0,a.useFieldSchema)();return e.schema?{...e,id:t}:{...e,id:t,schema:l}},x=e=>{var t;let l=(0,a.useField)();return e.id?e.id:null==(t=l.address)?void 0:t.toString()},y=(0,a.observer)(e=>{let{schema:t,id:l,eid:n,removeParentsIfNoChildren:r,...i}=g(e),a=(0,d.useMemo)(()=>{var e,l,o;return{insertAdjacent:"afterEnd",schema:(null==(l=t.parent)||null==(e=l.parent)?void 0:e["x-component"])==="BlockTemplate"?null==(o=t.parent)?void 0:o.parent:t,removeParentsIfNoChildren:r??!0}},[t,r]);return(0,o.jsx)(h,{id:l,data:a,children:(0,o.jsx)(v,{id:n,...i,children:e.children})})},{displayName:"InternalSortableItem"}),b=d.default.memo(e=>{let{component:t,...l}=e,{designable:n}=(0,c.er)();return n?(0,o.jsx)(y,{...e}):d.default.createElement(t||"div",s.default.omit(l,["children","schema","overStyle","openMode","id","eid","removeParentsIfNoChildren"]),e.children)});b.displayName="SortableItem";let _=e=>{let{draggable:t}=(0,d.useContext)(m)||{};if(!t)return null;let{attributes:l,listeners:n,setNodeRef:r}=t;return(0,o.jsx)("div",{style:{display:"inline-block",width:14,height:14,lineHeight:"14px",textAlign:"left"},children:(0,o.jsx)("div",{ref:r,style:{position:"relative",zIndex:1,lineHeight:0,fontSize:0,display:"inline-block"},...n,...l,role:"none",children:(0,o.jsx)("span",{style:{cursor:"move",fontSize:14},children:e.children})})})}},59529(e,t,l){l.d(t,{KX:()=>p,_c:()=>f,a2:()=>S,bc:()=>c,rf:()=>u});var o=l(63526),n=l(77583),r=l(73761),i=l(839),a=l(59896),s=l(32665),d=l(64004);let u=(e,t)=>{var l;let o=/{{(.*?)}}/,r=null==e||null==(l=e.match)?void 0:l.call(e,o);if(!r)return e;{let e=n.default.get(t,r[1]);return n.default.isFunction(e)?e():e}};function c(e){if("object"!=typeof e||null===e)return null;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))if("[object Object]"===Object.prototype.toString.call(e[t])&&null!==e[t])return c(e[t]);else return{key:t,value:e[t]};return null}let p=e=>{let t=m(e),l=(0,n.findIndex)(t,(e,t,l)=>{if(e.includes("$")&&t>0)return!0});return t.slice(0,l)};function m(e){let t=[];function l(e){Object.keys(e).sort().forEach(function(o){t.push(o),e[o]&&"object"==typeof e[o]&&l(e[o])})}return l(e),t}let h=async(e,t,l)=>{let o=(0,a.DZ)(e)?[t.parseVariable(e,l).then(e=>{let{value:t}=e;return t})]:[e];try{let[e]=await Promise.all(o);return e}catch(e){throw console.error("Error in parseVariableValue:",e),e}},f=async(e,t)=>{let{ruleGroup:l,variables:o,localVariables:r,variableNameOfLeftCondition:i,conditionType:a}=e,s=Object.keys(l)[0]||"$and",d=l[s]||[],u=await Promise.all(d.filter(Boolean).map(e=>v(e,o,r,i,a,t)));return"$and"===s?(0,n.every)(u,e=>e):!u.length||(0,n.some)(u,e=>e)},v=async(e,t,l,o,n,r)=>"$and"in e||"$or"in e?await f({ruleGroup:e,variables:t,localVariables:l,conditionType:n},r):"advanced"===n?g(e,t,l,r):x(e,t,l,o,r),g=async(e,t,l,o)=>{let n=e.op,r=await h(e.rightVar,t,l),i=await h(e.leftVar,t,l);return!n||o.apply({[n]:[i,r]})},x=async(e,t,l,n,r)=>{let i=c(e),u=null==i?void 0:i.key;if(!u)return!0;let m=y(p(e),n),h=t.parseVariable(m,l,{doNotRequest:!0}).then(e=>{let{value:t}=e;return t}),f=(0,a.DZ)(null==i?void 0:i.value)?[t.parseVariable(null==i?void 0:i.value,l).then(e=>{let{value:t}=e;return t}),h]:[null==i?void 0:i.value,h];try{let[e,n]=await Promise.all(f),i=await t.getCollectionField(m,l),a=(0,s.A)(n,{targetCollectionField:i}),c=(0,s.A)(e,{targetCollectionField:i});if((null==i?void 0:i.type)&&["datetime","date","datetimeNoTz","dateOnly","unixTimestamp"].includes(i.type)&&a){let e=(0,d.Pn)(c),t=(0,o.getPickerFormat)(e);a=(0,o.dayjs)(a).format(t)}return r.apply({[u]:[a,c]})}catch(e){throw e}};function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$nForm";return`{{ ${t}.${e.join(".")} }}`}let b=e=>{let t={};return e.map(e=>{t[e.name]=e.ctx}),t};function _(e){return e.replace(/{{\s*}}/g,'{{"{{}}"}}')}async function S(e,t,l,n,a,s){if(t&&"handlebars"===e){o.Handlebars.registerHelper("t",function(e){if("string"==typeof e)return s(e,{ns:i.z})});try{var d,u;let e=_(t),r=o.Handlebars.compile(e),i=b(n),{$nDate:s}=(null==l||null==(d=l.ctxRef)?void 0:d.current)||{},c={};Object.keys(s||{}).map(e=>{c[e]=s[e]()});let p=r({...null==l||null==(u=l.ctxRef)?void 0:u.current,...i,$nDate:c});return console.log(p),await a(p)}catch(e){return/VariablesProvider: .* is not found/.test(e.message)||console.log(e),console.log(t),t}}try{let e=await (0,r.replaceVariableValue)(t,l,n);return await a(e)}catch(e){return/VariablesProvider: .* is not found/.test(e.message)||console.log(e),t}}},84951(e,t,l){l.d(t,{A:()=>g});var o=l(71178),n=l(56920),r=l(77583),i=l(51649),a=l(23610),s=l(44388),d=l(3012);let u={type:"void","x-component":"Action.Container","x-action":"view",title:'{{ t("View record") }}',"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("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}};var c=l(28227),p=l(30644),m=l(39888);let h=()=>{let e=(0,n.useFieldSchema)(),{insertAfterBegin:t}=(0,a.erX)();return(0,i.useCallback)(l=>{e.reduceProperties((e,t)=>"Action.Container"===t["x-component"]?t:e,null)||t((0,r.cloneDeep)(l))},[e,t])},f=e=>"Action.Container"===e["x-component"],v=e=>{let{WrappedComponent:t,...l}=e,a=(0,n.useFieldSchema)(),{openPopup:s}=(0,d.Hy)(),c=(0,i.useRef)(!1),p=h(),m=(0,i.useRef)(a);m.current=a;let f=(0,i.useRef)(p);f.current=p;let v=(0,i.useRef)(s);v.current=s;let g=(0,i.useCallback)(()=>m.current,[]),x=(0,i.useCallback)(()=>{m.current.properties||(f.current(u),c.current=!0),c.current?(setTimeout(()=>{v.current({customActionSchema:g()})}),c.current=!1):m.current.properties&&v.current()},[g]),y=(0,i.useMemo)(()=>(0,r.debounce)(x,600,{leading:!0,trailing:!1}),[x]);return(0,i.useEffect)(()=>()=>{y.cancel()},[y]),(0,o.jsx)("a",{onClick:y,children:(0,o.jsx)(t,{...l})})};function g(e){return t=>{let[l,r]=(0,i.useState)(!1),[u,h]=(0,i.useState)(!1),g=(0,c.Ge)(),x=(0,a.D50)(),y=(0,n.useField)(),b=(0,n.useFieldSchema)(),{enableLink:_,openMode:S,openSize:k}=(null==b?void 0:b["x-component-props"])||{},{visibleWithURL:C,setVisibleWithURL:w}=(0,d.Hy)(),M=(0,i.useCallback)(e=>{null==r||r(e),null==w||w(e)},[w]);(0,i.useRef)(b).current=b;let{setSubmitted:F}=x;return _?(0,o.jsx)(s.OC,{visible:!1,children:(0,o.jsxs)(a.z45,{button:(0,o.jsx)(e,{...t}),visible:l||C,setVisible:M,formValueChanged:u,setFormValueChanged:h,openMode:S,openSize:k,containerRefKey:"field-popup",fieldSchema:b,setSubmitted:F,children:[(0,o.jsx)(c.Yz,{name:g.name,children:(0,o.jsx)(a.t6u,{children:(0,o.jsx)(m.P3,{children:(0,o.jsx)(p.dw,{onlyRenderProperties:!0,basePath:null==y?void 0:y.address,schema:b,filterProperties:f})})})}),(0,o.jsx)(v,{...t,WrappedComponent:e})]})}):(0,o.jsx)(e,{...t})}}},63557(e,t,l){l.d(t,{u:()=>o});let o=(0,l(51649).createContext)({});o.displayName="SchemaComponentContext.Provider"},71915(e,t,l){l.d(t,{O:()=>u});var o=l(71178),n=l(44814),r=l(56920),i=l(51649),a=l(52570);let s=e=>{let{children:t,form:l,...n}=e,s=(0,i.useContext)(r.SchemaOptionsContext),d=(0,i.useContext)(r.SchemaExpressionScopeContext),u={...null==s?void 0:s.scope,...d},c={...null==s?void 0:s.components};return(0,o.jsx)(r.FormProvider,{...n,form:l,children:(0,o.jsx)(a.t,{components:c,scope:u,children:t})})},d=e=>{let{children:t,...l}=e,s=(0,i.useContext)(r.SchemaOptionsContext),d=(0,i.useContext)(r.SchemaExpressionScopeContext),u={...null==s?void 0:s.scope,...d},c={...null==s?void 0:s.components},p=(0,i.useMemo)(()=>(0,n.createForm)(),[]);return(0,o.jsx)(r.FormProvider,{...l,form:p,children:(0,o.jsx)(a.t,{components:c,scope:u,children:t})})},u=e=>e.form?(0,o.jsx)(s,{...e}):(0,o.jsx)(d,{...e})},86073(e,t,l){l.d(t,{D:()=>v});var o=l(71178),n=l(44814),r=l(56920),i=l(52793),a=l(51649),s=l(43353);l(67285);var d=l(28260),u=l(71915),c=l(93726),p=l(74737);let m=e=>{let{uid:t,type:l="getJsonSchema",onSuccess:o}=e,n={url:`/uiSchemas:${l}/${t}`},{data:r,loading:i}=(0,p.bP)(n,{refreshDeps:[t],onSuccess(e){o&&o(e)}});return{schema:null==r?void 0:r.data,loading:i}},h=e=>e,f=e=>{let{noForm:t,onlyRenderProperties:l,hidden:p,scope:f,uid:v,components:g,onSuccess:x,NotFoundPage:y,schemaTransform:b=h,onPageNotFind:_}=e,S=l?"getProperties":"getJsonSchema",k=(0,a.useMemo)(()=>(0,n.createForm)(),[v]),{schema:C,loading:w}=m({uid:v,type:S,onSuccess:e=>{x&&x(e)}}),M=(0,d.xZ)(y),F=(0,s.RH)(),P=(0,r.useFieldSchema)(),j=(0,a.useMemo)(()=>b(C||{}),[C,b]);return F||w||p?(0,o.jsx)(i.Spin,{style:{width:"100%",marginTop:20},delay:void 0}):C&&0!==Object.keys(C).length?t?(0,o.jsx)(c.H,{components:g,scope:f,schema:j,parentSchema:P}):(0,o.jsx)(u.O,{form:k,children:(0,o.jsx)(c.H,{components:g,scope:f,schema:j,parentSchema:P})}):(_&&_(),M?(0,o.jsx)(M,{}):null)},v=(0,a.memo)(e=>e.uid?(0,o.jsx)(f,{...e}):null);v.displayName="RemoteSchemaComponent"},93726(e,t,l){l.d(t,{D:()=>p,H:()=>f});var o=l(71178),n=l(56920),r=l(77583),i=l(51649),a=l(30644),s=l(63557),d=l(52570);function u(e){return n.Schema.isSchemaInstance(e)?e:new n.Schema((null==e?void 0:e.name)?{type:"object",properties:{[e.name]:e},name:`p_${e.name}`}:e)}let c=e=>(0,i.useMemo)(()=>u(e),[]),p=(0,i.createContext)({onChange:r.default.noop}),m=(0,i.memo)(e=>{let{components:t,scope:l,schema:n,distributed:c,onChange:m,parentSchema:h,...f}=e,v=(0,i.useContext)(s.u),g=(0,i.useMemo)(()=>u(n),[n]),x=(0,i.useMemo)(()=>({...v,distributed:!1!=v.distributed&&c,refresh:v.refresh||r.default.noop}),[v,c]),{onChange:y}=(0,i.useContext)(p),b=(0,i.useMemo)(()=>({onChange:()=>{null==m||m(g),null==y||y()}}),[m,y,g]);return(0,o.jsx)(p.Provider,{value:b,children:(0,o.jsx)(s.u.Provider,{value:x,children:(0,o.jsx)(d.t,{inherit:!0,components:t,scope:l,children:(0,o.jsx)(a.dw,{...f,schema:g,isUseFormilyField:!0,parentSchema:h})})})})});m.displayName="RecursionSchemaComponent";let h=(0,i.memo)(e=>{let{schema:t,parentSchema:l,...n}=e,r=c(t);return(0,o.jsx)(m,{...n,schema:r,parentSchema:l})});h.displayName="MemoizedSchemaComponent";let f=(0,i.memo)(e=>{let{memoized:t,...l}=e;return t?(0,o.jsx)(h,{...l}):(0,o.jsx)(m,{...l})});f.displayName="SchemaComponent"},52570(e,t,l){l.d(t,{M:()=>i,t:()=>a});var o=l(71178),n=l(56920),r=l(51649);let i=()=>(0,r.useContext)(n.SchemaOptionsContext)||{},a=(0,r.memo)(e=>{let{children:t}=e,l=i(),a=(0,r.useMemo)(()=>({...l.components,...e.components}),[l.components,e.components]),s=(0,r.useMemo)(()=>({...l.scope,...e.scope}),[l.scope,e.scope]),d=(0,r.useMemo)(()=>({scope:s,components:a}),[s,a]);return(0,o.jsx)(n.SchemaOptionsContext.Provider,{value:d,children:(0,o.jsx)(n.SchemaComponentsContext.Provider,{value:a,children:(0,o.jsx)(n.ExpressionScope,{value:s,children:t})})})});a.displayName="SchemaComponentOptions"},90995(e,t,l){l.d(t,{OA:()=>F,DY:()=>f.D,GD:()=>j,Do:()=>v.D,Mq:()=>g.M,t6:()=>g.t,Hv:()=>v.H,Op:()=>h.O,N3:()=>m});var o=l(71178),n=l(82113),r=l(52793),i=l(51649),a=l(77843),s=l(23610),d=l(49948),u=l(97812);let c={backgroundColor:"var(--colorSettings) !important"},p={backgroundColor:"transparent"},m=e=>{let{designable:t,setDesignable:l}=(0,s.erX)(),{t:i}=(0,a.useTranslation)(),{token:m}=(0,d.K)(),h=t?c:p,{isMobileLayout:f}=(0,u.mY)();return((0,__rspack_external_react_hotkeys_hook_f323ef84.useHotkeys)("Ctrl+Shift+U",()=>l(!t),[t]),f)?null:(0,o.jsx)(r.Tooltip,{title:i("UI Editor"),children:(0,o.jsx)(r.Button,{"data-testid":"ui-editor-button",icon:(0,o.jsx)(n.HighlightOutlined,{style:{color:m.colorTextHeaderMenu}}),title:i("UI Editor"),style:{...h,...e.style},onClick:()=>{l(!t)}})})};var h=l(71915),f=l(86073),v=l(93726),g=l(52570),x=l(44814),y=l(56920),b=l(27404),_=l(77583),S=l(63557),k=l(77850);let C=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return`${e}${(0,b.uid)()}`};y.Schema.silent(!0);let w={},M={silent:!0,compile(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=()=>{if(!M.silent)return Function("$root",`with($root) { return (${e}); }`)(t);try{return Function("$root",`with($root) { return (${e}); }`)(t)}catch{return`{{${e}}}`}};return w[e]?w[e]:e.trim().startsWith("t(")?(w[e]=l(),w[e]):l()}};y.Schema.registerCompiler(M.compile);let F=e=>{let{designable:t,onDesignableChange:l,components:n,children:r}=e,s=(0,i.useContext)(S.u),d=(0,g.M)(),[u,c]=(0,i.useState)(()=>(0,b.uid)()),p=(0,i.useMemo)(()=>e.form||(0,x.createForm)(),[u]),{t:m}=(0,a.useTranslation)(),h=(0,k.nm)(),f=(0,i.useMemo)(()=>({...e.scope,t:m,randomString:C}),[e.scope,m,null==d?void 0:d.scope]),[v,w]=(0,i.useState)(t),M=(0,i.useMemo)(()=>"boolean"==typeof t?t:v,[t,v,s.designable]),F=(0,i.useMemo)(()=>e=>{"boolean"!=typeof M&&w(e),null==l||l(e)},[M,l]);(0,i.useEffect)(()=>{let e=!1;return(async()=>{var t,l,o,n;if(!M)return await (null==(l=h.flowEngine)||null==(t=l.flowSettings)?void 0:t.disable());e||await (null==(n=h.flowEngine)||null==(o=n.flowSettings)?void 0:o.enable())})(),()=>{e=!0}},[h,M]);let P=(0,i.useCallback)(()=>{c((0,b.uid)())},[]),j=(0,i.useMemo)(()=>({scope:f,components:n,reset:P,refresh:_.default.noop,designable:M,setDesignable:F}),[n,M,P,f,F]);return(0,o.jsx)(S.u.Provider,{value:j,children:(0,o.jsx)(y.FormProvider,{form:p,children:(0,o.jsx)(g.t,{inherit:!0,scope:f,components:n,children:r})})})};F.displayName="SchemaComponentProvider";var P=l(83468);class j extends P.k{async load(){this.addComponents()}addComponents(){this.app.addComponents({DesignableSwitch:m})}}},28260(e,t,l){l.d(t,{Us:()=>y,TD:()=>n,F:()=>m,px:()=>d.px,QI:()=>d.QI,d1:()=>d.d1,xB:()=>v,YY:()=>b.Y,Lj:()=>_.Lj,er:()=>d.er,xZ:()=>s,OJ:()=>c,mh:()=>_.mh,lu:()=>r.l,kB:()=>d.kB,Hb:()=>u.H,a9:()=>_.a9,jE:()=>S});var o=l(51649);let n=e=>{let t=(0,o.useRef)(null);return(0,o.useEffect)(()=>(t.current&&e!==t.current&&t.current.onUnmount(),t.current=e,e.onMount(),()=>{e.onUnmount()}),[e]),e};var r=l(61013),i=l(56920),a=l(77583);let s=(e,t)=>{let{components:l}=(0,o.useContext)(i.SchemaOptionsContext);return e?"string"!=typeof e?e:(0,a.get)(l,e)||t:t};var d=l(95951),u=l(87463);let c=e=>{let t=(0,o.useContext)(i.SchemaOptionsContext),l=(0,o.useContext)(i.SchemaExpressionScopeContext),n=(0,o.useRef)();return n.current=l,e.toFieldProps({...t,get scope(){return{...t.scope,...n.current}}})};var p=l(63557);function m(){return(0,o.useContext)(p.u)}var h=l(77843),f=l(43288);let v=()=>{var e;let{getCollectionJoinField:t,getCollection:l}=(0,f.nj)(),n=(0,i.useFieldSchema)(),{getField:r}=(0,f.k7)(),a=r(n.name)||t(n["x-collection-field"]),{t:s}=(0,h.useTranslation)(),{label:d}=(null==(e=n["x-component-props"])?void 0:e.fieldNames)||{};return(0,o.useMemo)(()=>{if(!a||!(null==a?void 0:a.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(a.interface))return;let e=l(a.target);if((null==e?void 0:e.template)==="file")return[{label:s("Record picker"),value:"CollectionField"},{label:s("Select"),value:"AssociationSelect"}];switch(a.interface){case"o2m":return[{label:s("Record picker"),value:"CollectionField"},{label:s("Subtable"),value:"TableField"},{label:s("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:s("Record picker"),value:"CollectionField"},{label:s("Select"),value:"AssociationSelect"}];default:return[{label:s("Record picker"),value:"CollectionField"},{label:s("Subform"),value:"FormField"},{label:s("Select"),value:"AssociationSelect"}]}},[s,null==a?void 0:a.interface,d])};var g=l(26174),x=l(49621);let y=()=>{var e;let t=(0,i.useField)(),l=(0,i.useFieldSchema)(),n=(0,x.Ge)(),a=(0,g.r2)(),s=(null==n?void 0:n.getField(l.name))||(null==a?void 0:a.getCollectionField(l["x-collection-field"])),d=(0,r.l)();(0,o.useEffect)(()=>{if(!(null==t?void 0:t.title)){var e;t.title=d(null==s||null==(e=s.uiSchema)?void 0:e.title)}},[null==s||null==(e=s.uiSchema)?void 0:e.title])};var b=l(4922),_=l(62152);let S=e=>{var t;let{t:l}=(0,h.useTranslation)(),{getCollectionJoinField:n,getCollection:r}=(0,f.nj)(),a=(0,i.useFieldSchema)(),s=(null==e?void 0:e.fieldSchema)||a,d=(0,i.useField)(),u=(0,i.useForm)(),c=(null==s?void 0:s["x-read-pretty"])||d.readPretty||u.readPretty,p=null==e?void 0:e.fieldSchema,{getField:m}=(0,f.k7)(),v=(null==e?void 0:e.collectionField)||m(s.name)||n(s["x-collection-field"]),{label:g}=(null==(t=s["x-component-props"])?void 0:t.fieldNames)||{};return((0,o.useMemo)(()=>{if(!v||!(null==v?void 0:v.interface)||!["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(v.type))return;let e=r(v.target);if((null==e?void 0:e.template)==="file")return c?[{label:l("Title"),value:"Select"},{label:l("File manager"),value:"FileManager"},{label:l("Tag"),value:"Tag"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},{label:l("File manager"),value:"FileManager"}];if((null==e?void 0:e.template)==="tree"&&["m2m","o2m","m2o"].includes(v.interface))return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-details"),value:"Nester"},!p&&{label:l("Sub-table"),value:"SubTable"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&["m2m","o2m"].includes(v.interface)&&{label:l("Sub-table"),value:"SubTable"},!p&&{label:l("Cascader Select"),value:"CascadeSelect"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"}];switch(v.interface){case"o2m":return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-table"),value:"SubTable"},!p&&{label:l("Sub-details"),value:"Nester"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"},!p&&{label:l("Sub-table"),value:"SubTable"}];case"m2m":case"mbm":return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-details"),value:"Nester"},!p&&{label:l("Sub-table"),value:"SubTable"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&{label:l("Sub-table"),value:"SubTable"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"}];default:return c?[{label:l("Title"),value:"Select"},{label:l("Tag"),value:"Tag"},!p&&{label:l("Sub-details"),value:"Nester"}]:[{label:l("Select"),value:"Select"},{label:l("Record picker"),value:"Picker"},!p&&{label:l("Sub-form"),value:"Nester"},{label:l("Sub-form(Popover)"),value:"PopoverNester"}]}},[l,null==v?void 0:v.interface,g,c,p])||[]).filter(Boolean)}},62152(e,t,l){l.d(t,{Lj:()=>S,a9:()=>_,mh:()=>b});var o=l(56920),n=l(71883),r=l(52793),i=l(77583),a=l(51649),s=l(38356),d=l(23610),u=l(44374),c=l(73761),p=l(70892),m=l(38131);let h=(e,t,l,o,n)=>n.includes("/popups/")?2*o.paddingContentVertical+22+o.paddingPageVertical:e?o.paddingContentHorizontalLG:l?t?o.controlPaddingHorizontal+3*o.controlPaddingHorizontalSM+22+o.paddingContentHorizontalLG:o.paddingContentHorizontalLG+12:t?o.paddingSM+o.controlHeight+o.marginXS+2*o.controlPaddingHorizontalSM+22+o.paddingContentHorizontalLG:o.controlHeight+o.marginXS+(o.paddingContentVertical+2)*2+o.paddingContentHorizontalLG,f=e=>{let{token:t}=r.theme.useToken(),{designable:l}=(0,d.erX)(),{heightProps:o}=(0,c.useBlockHeightProps)(),n=(0,s.useLocation)(),{disablePageHeader:i,enablePageTabs:a,hidePageTitle:u}=e||o||{},p=t.sizeXXL-2,m=l?t.controlHeight+2*t.paddingContentHorizontalLG:+t.paddingContentHorizontalLG;return p+h(i,a,u,t,n.pathname)+m},v=()=>{let{token:e}=r.theme.useToken(),{designable:t}=(0,d.erX)();return e.paddingContentVerticalLG+e.margin+2*e.paddingContentVertical+24+(t?e.controlHeight+2*e.paddingContentHorizontalLG:+e.paddingContentHorizontalLG)},g=e=>{let t=k((0,o.useFieldSchema)()),l=f(e),n=v();return t?n:l},x=["workflowManualTasks","approvals","approvalRecords"],y=()=>{var e;let{token:t}=r.theme.useToken(),{heightProps:l}=(0,c.useBlockHeightProps)(),{heightProps:n}=(0,p.El)(),{designable:i}=(0,d.erX)(),a=(0,o.useFieldSchema)(),s=n||l,{titleHeight:h}=l,f=g(s),{name:v}=(0,u.useCollection)(),{heightMode:y,height:b,title:_}=s;if(!(null==s?void 0:s.heightMode)||y===m.D.DEFAULT)return;let S=Object.keys((null==(e=a.parent.properties.actions)?void 0:e.properties)||{}).length>0,k=t.controlHeight+t.padding+t.marginLG,C=S||i?t.controlHeight+2*t.marginLG:t.marginLG,w=(i&&!x.includes(v)?t.controlHeight:22)+2*t.padding+1,M=_?h:0;return y===m.D.FULL_HEIGHT?window.innerHeight-f-M-w-C-k:b-M-C-w-k},b=e=>{let{heightProps:t}=(0,c.useBlockHeightProps)(),l=g(),{heightMode:o,height:n,title:r,titleHeight:i}=t||{},a=r?i:0;if((null==t?void 0:t.heightMode)&&o!==m.D.DEFAULT){if(o===m.D.FULL_HEIGHT){let t=window.innerHeight-l;return(null==e?void 0:e.removeBlockHeaderHeight)&&(t-=a),(null==e?void 0:e.innerExtraHeight)&&(t-=e.innerExtraHeight),t}return n}},_=()=>{let e=(0,o.useFieldSchema)(),t=(0,a.useMemo)(()=>(0,c.getPageSchema)(e),[]),{disablePageHeader:l,enablePageTabs:n,hidePageTitle:r}=(null==t?void 0:t["x-component-props"])||{},i={...null==e?void 0:e["x-component-props"],disablePageHeader:l,enablePageTabs:n,hidePageTitle:r},s=g(i),{heightMode:d,height:u}=i||{};if((null==i?void 0:i.heightMode)&&d!==m.D.DEFAULT)return d===m.D.FULL_HEIGHT?window.innerHeight-s:u},S=()=>{let[e,t]=(0,a.useState)(),l=(0,a.useRef)(null),o=y(),r=(0,a.useCallback)((0,i.debounce)(()=>{var e;if(!l.current)return;let o=l.current.getBoundingClientRect();(null==(e=l.current.querySelector(".ant-table"))?void 0:e.getBoundingClientRect())&&t(o.width)},100),[o]),s=(0,a.useCallback)(e=>{l.current=e&&e.children?e.children[0]:null,r()},[r]);return(0,n.useEventListener)("resize",r),{height:o,width:e,tableSizeRefCallback:s}},k=e=>{if(!e)return null;if("Action.Container"===e["x-component"]){var t,l;return(null==e||null==(l=e.parent)||null==(t=l["x-component-props"])?void 0:t.openMode)!=="page"}return k(e.parent)}},61013(e,t,l){l.d(t,{l:()=>a});var o=l(56920),n=l(51649);let r={},i=e=>/{{.*?}}/g.test(e),a=function(){let{noCache:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{noCache:!1},t=(0,n.useContext)(o.SchemaOptionsContext),l=(0,n.useContext)(o.SchemaExpressionScopeContext);return(a,s)=>{let d,u=!1;if("string"==typeof a&&a.startsWith("{{")&&(u=!0,d=a),a&&"object"==typeof a&&!(0,n.isValidElement)(a)){try{d=JSON.stringify(a)}catch(e){return console.warn("Failed to stringify:",e),a}if(r[d])return r[d];u=i(d)}if(Array.isArray(a)){try{d=JSON.stringify(a)}catch(e){return console.warn("Failed to stringify:",e),a}if(r[d])return r[d];u=i(d)}if(u){let n={...null==t?void 0:t.scope,...l,...s};if(!d)return o.Schema.compile(a,n);try{if(e)return o.Schema.compile(a,n);return r[d]=r[d]||o.Schema.compile(a,n),r[d]}catch(e){return console.log("useCompile error",a,e),o.Schema.compile(a,n)}}return a}}},95951(e,t,l){l.d(t,{er:()=>P,px:()=>b,QI:()=>F,d1:()=>M,kB:()=>C});var o=l(71178),n=l(56920),r=l(27404),i=l(71883),a=l(52793),s=l(13791),d=l(93656),u=l(20148),c=l(51649),p=l(77843),m=l(74737),h=l(30644),f=l(88448),v=l(63557);function g(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(l=>{var o;g(null==(o=e.properties)?void 0:o[l],t)}),e}var x=JSON.parse('{"rE":"2.1.0-alpha.20"}'),y=l(97812);function b(e){return new M(e)}let _=e=>{e&&(e["x-uid"]||(e["x-uid"]=(0,r.uid)()),Object.keys(e.properties||{}).forEach(t=>{_(e.properties[t])}))},S=e=>e,k=(e,t)=>{if(e&&t){for(let l in t)if(Object.prototype.hasOwnProperty.call(t,l)&&t[l]!==(null==e?void 0:e[l]))return!1;return!0}},C=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];let l=e.toJSON(),o={...l,properties:{}},n=null,r=(e,l)=>{Object.keys(e||{}).forEach(o=>{let i=e[o];if(i["x-uid"]===t["x-uid"]){n=e[o];return}l.properties[o]={...i,properties:{}},r(null==i?void 0:i.properties,l.properties[o])})};return r(l.properties,o),[o,n]},w=e=>e;class M{get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){let{api:e,t=w}=this.options;if(!e)return;let l=e=>{if(!e)return[];let t=Object.values(e.properties).length,l=[];return(e.mapProperties(e=>{e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].width=100/t,e["x-uid"]&&l.push({"x-uid":e["x-uid"],"x-component-props":e["x-component-props"]})}),e["x-uid"]&&l.length)?l:[]};this.on("insertAdjacent",async o=>{var n;let{onSuccess:r,current:i,position:s,schema:d,wrap:u,wrapped:c,removed:p}=o,m=[];if((null==c?void 0:c["x-component"])==="Grid.Col"&&(m=m.concat(l(c.parent))),(null==p?void 0:p["x-component"])==="Grid.Col"&&(m=m.concat(l(p.parent))),this.refresh(),!i["x-uid"])return;let h=await e.request({url:`/uiSchemas:insertAdjacent/${i["x-uid"]}?position=${s}`,method:"post",data:{schema:g(d,this.appVersion),wrap:u}});m.length&&await e.request({url:"/uiSchemas:batchPatch",method:"post",data:m}),(null==p?void 0:p["x-uid"])&&await e.request({url:`/uiSchemas:remove/${p["x-uid"]}`,method:"post"}),null==r||r(null==h||null==(n=h.data)?void 0:n.data),a.message.success(t("Saved successfully"),.2)}),this.on("patch",async l=>{let{schema:o}=l;this.refresh(),(null==o?void 0:o["x-uid"])&&(await e.request({url:"/uiSchemas:patch",method:"post",data:{...o}}),a.message.success(t("Saved successfully"),.2))}),this.on("initializeActionContext",async t=>{let{schema:l}=t;(null==l?void 0:l["x-uid"])&&await e.request({url:"/uiSchemas:initializeActionContext",method:"post",data:{...l}})}),this.on("batchPatch",async l=>{let{schemas:o}=l;this.refresh(),await e.request({url:"/uiSchemas:batchPatch",method:"post",data:o}),a.message.success(t("Saved successfully"),.2)}),this.on("remove",async o=>{let{removed:n}=o,r=[];(null==n?void 0:n["x-component"])==="Grid.Col"&&(r=l(n.parent)),this.refresh(),(null==n?void 0:n["x-uid"])&&(await e.request({url:`/uiSchemas:remove/${n["x-uid"]}`,method:"post"}),r.length&&await e.request({url:"/uiSchemas:batchPatch",method:"post",data:r}),a.message.success(t("Saved successfully"),.2))})}prepareProperty(e){e.type||(e.type="void"),e.name||(e.name=(0,r.uid)()),this.current["x-uid"]&&_(e)}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}async emit(e){for(var t=arguments.length,l=Array(t>1?t-1:0),o=1;o<t;o++)l[o-1]=arguments[o];if(!this.events[e])return;let[n,...r]=l;return Promise.all(this.events[e].map(e=>e.bind(this)({current:this.current,...n},...r)))}parentsIn(e){if(!e||!n.Schema.isSchemaInstance(e))return!1;let t=this.current;for(;null==t?void 0:t.parent;){if(t.parent===e)return!0;t=t.parent}return!1}refresh(e){let{refresh:t}=this.options;return null==t?void 0:t(e)}deepMerge(e){let t={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly"},l={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(e).forEach(o=>{t[o]?(this.current[o]=e[o],this.updateModel(t[o],e[o])):l[o]?Object.keys(e[o]).forEach(t=>{(0,u.default)(this.current,[o,t],e[o][t]),this.updateModel([l[o],t],e[o][t])}):this.current[o]=e[o]}),this.emit("patch",{schema:e})}getSchemaAttribute(e,t){return(0,d.default)(this.current,e,t)}shallowMerge(e){let t={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly","x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(e).forEach(l=>{this.current[l]=e[l],t[l]&&this.updateModel(t[l],e[l])}),this.emit("patch",{schema:e})}updateModel(e,t){let l=l=>{(0,u.default)(l,e,t)};this.model&&l(this.model),this.query&&this.query.take(l)}insertAdjacent(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};switch(e){case"beforeBegin":return this.insertBeforeBegin(t,l);case"afterBegin":return this.insertAfterBegin(t,l);case"beforeEnd":return this.insertBeforeEnd(t,l);case"afterEnd":return this.insertAfterEnd(t,l)}}recursiveRemoveIfNoChildren(e,t){let l;if(!e)return;let o=e,n=null==t?void 0:t.breakRemoveOn;for(;o;){if("function"==typeof n){if(n(o))break}else if(k(o,n))break;if(Object.keys(o.properties||{}).length>0)break;o.parent&&(l=o.parent.removeProperty(o.name)),o=o.parent}return l}remove(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{breakRemoveOn:l,removeParentsIfNoChildren:o}=t,n=e||this.current,r=n.parent.removeProperty(n.name);if(o){let e=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:l});e&&(r=e)}return this.emit("remove",{removed:r})}removeWithoutEmit(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{breakRemoveOn:l,removeParentsIfNoChildren:o}=t,n=e||this.current,r=n.parent.removeProperty(n.name);if(o){let e=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:l});e&&(r=e)}return r}insertBeforeBeginOrAfterEnd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current)||!n.Schema.isSchemaInstance(e)||this.current.parent!==e.parent)return;let l=0,o=0;return this.current.parent.mapProperties((t,n,r)=>{this.current.name===n&&(o=r),e.name===n&&(l=r)}),l>o?this.insertBeforeBegin(e,t):this.insertAfterEnd(e,t)}insertBeforeBegin(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;let l={onSuccess:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t;if(n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i}))}else e&&(e=(0,s.default)(e));let d={},u=!1,c=0,p=0;this.current.parent.mapProperties((e,t)=>{t===this.current.name&&(p=c,u=!0,++c),e["x-index"]=c,++c,u&&(d[t]=e,this.current.parent.removeProperty(t))}),this.prepareProperty(e);let m=o(e),h=this.current.parent.addProperty(m.name||(0,r.uid)(),m);h["x-index"]=p,h.parent=this.current.parent,this.current.parent.setProperties(d);let[f,v]=C(h,e);this.emit("insertAdjacent",{position:"beforeBegin",schema:v,wrapped:m,wrap:f,...l})}insertAfterBegin(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;let l={onSuccess:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t;if(n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i}))}else e&&(e=(0,s.default)(e));let d={},u=1;this.current.mapProperties((e,t)=>{e["x-index"]=u,++u,d[t]=e}),this.current.properties={},this.prepareProperty(e);let c=o(e),p=this.current.addProperty(c.name||(0,r.uid)(),c);p["x-index"]=0,p.parent=this.current,this.current.setProperties(d);let[m,h]=C(p,e);this.emit("insertAdjacent",{position:"afterBegin",schema:h,wrap:m,wrapped:c,...l})}insertBeforeEnd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;delete e["x-index"];let l={onSuccess:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t;if(n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i}))}else e&&(e=(0,s.default)(e));this.prepareProperty(e);let d=o(e),u=this.current.addProperty(d.name||(0,r.uid)(),d);u.parent=this.current;let[c,p]=C(u,e);return this.emit("insertAdjacent",{position:"beforeEnd",schema:p,wrap:c,wrapped:d,...l})}insertAfterEnd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n.Schema.isSchemaInstance(this.current))return;let l={onSuccess:null==t?void 0:t.onSuccess},{wrap:o=S,breakRemoveOn:i,removeParentsIfNoChildren:a}=t,d=0,u=0,c=!1,p={};if(this.current.parent.mapProperties((e,t)=>{e["x-index"]=d,t===this.current.name&&(u=++d,c=!0),++d,c&&t!==this.current.name&&(p[t]=e,this.current.parent.removeProperty(t))}),n.Schema.isSchemaInstance(e)){if(this.parentsIn(e))return void this.emit("error",{code:"parent_is_not_allowed",schema:e});e.parent.removeProperty(e.name),a&&(l.removed=this.recursiveRemoveIfNoChildren(e.parent,{breakRemoveOn:i})),e.parent=null}else e&&(e=(0,s.default)(e));this.prepareProperty(e);let m=o(e),h=this.current.parent.addProperty(m.name||(0,r.uid)(),m);h.parent=this.current.parent,h["x-index"]=u,this.current.parent.setProperties(p);let[f,v]=C(h,e);this.emit("insertAdjacent",{position:"afterEnd",schema:v,wrap:f,wrapped:m,...l})}constructor(e){this.events={},this.options=e,this.current=e.current,this.appVersion=e.appVersion}}function F(){let e=(0,c.useContext)(n.SchemaOptionsContext),t=(0,c.useMemo)(()=>(null==e?void 0:e.components)||{},[e]);return e=>{if(!e)return null;if("string"!=typeof e)return e;let l=(0,d.default)(t,e);return l||console.error(`[nocobase]: Component "${e}" not found`),l}}function P(){let{designable:e,setDesignable:t,refresh:l,reset:r}=(0,c.useContext)(v.u),a=(0,c.useContext)(n.SchemaOptionsContext),s=(0,c.useMemo)(()=>(null==a?void 0:a.components)||{},[a]),g=(0,c.useMemo)(()=>()=>(0,o.jsx)(o.Fragment,{}),[]),_=(0,i.useUpdate)(),S=(0,h.o8)(),k=(0,h.cQ)(),C=(0,c.useCallback)(e=>{null==l||l(),_(),null==S||S(e),null==k||k()},[l,_,S,k]),w=(0,n.useField)(),M=(0,n.useFieldSchema)(),F=(0,m.VB)(),{t:P}=(0,p.useTranslation)(),j=(0,c.useMemo)(()=>b({t:P,api:F,refresh:C,current:M,model:w,appVersion:x.rE}),[P,F,C,M,w]);(0,c.useEffect)(()=>{j.loadAPIClientEvents()},[j]);let{isMobileLayout:A}=(0,y.mY)();return{dn:j,designable:!A&&e,reset:r,refresh:C,setDesignable:t,DesignableBar:g,findComponent:(0,c.useCallback)(e=>{if(!e)return null;if("string"!=typeof e)return e;let t=(0,d.default)(s,e);return(null==t?void 0:t[f.PE])??t},[d.default]),on:j.on.bind(j),patch:(0,c.useCallback)((e,t)=>{let l=e=>{Object.keys(e).forEach(t=>{let l=e[t];"title"===t&&(w.title=l,M.title=l),"x-decorator-props"===t&&(w.decoratorProps||(w.decoratorProps={}),M["x-decorator-props"]||(M["x-decorator-props"]={}),Object.keys(l).forEach(e=>{w.decoratorProps[e]=l[e],M["x-decorator-props"][e]=l[e]})),"x-component-props"===t&&(w.componentProps||(w.componentProps={}),M["x-component-props"]||(M["x-component-props"]={}),Object.keys(l).forEach(e=>{w.componentProps[e]=l[e],M["x-component-props"][e]=l[e]}))})};if("string"==typeof e){let o={};return(0,u.default)(o,e,t),l(o)}l(e),C()},[j]),shallowMerge:(0,c.useCallback)(e=>{j.shallowMerge(e)},[j]),deepMerge:(0,c.useCallback)(e=>{j.deepMerge(e)},[j]),remove:(0,c.useCallback)((e,t)=>{j.remove(e,t)},[j]),insertAdjacent:(0,c.useCallback)((e,t,l)=>{j.insertAdjacent(e,t,l)},[j]),insertBeforeBegin:(0,c.useCallback)(e=>{j.insertBeforeBegin(e)},[j]),insertAfterBegin:(0,c.useCallback)(e=>{j.insertAfterBegin(e)},[j]),insertBeforeEnd:(0,c.useCallback)(e=>{j.insertBeforeEnd(e)},[j]),insertAfterEnd:(0,c.useCallback)(e=>{j.insertAfterEnd(e)},[j])}}},87463(e,t,l){l.d(t,{H:()=>s});var o=l(56920),n=l(28260),r=l(51649),i=l(29699);let a=()=>null;a.isNullComponent=!0;let s=()=>{let{designable:e}=(0,n.er)(),t=(0,o.useFieldSchema)(),l=(0,r.useMemo)(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?i.Bw:a,[t]),s=(0,n.xZ)(l);return e&&s||a}},4922(e,t,l){l.d(t,{Y:()=>n});let o=()=>({}),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{useProps:t=o,...l}=e,n=t;"function"!=typeof t&&(n=o);let r=n();return{...l,...r}}},23610(e,t,l){l.d(t,{iI7:()=>D.iI,a1G:()=>d.ShowFormData,yt2:()=>tX,flR:()=>r.fl,FVw:()=>r5.FV,FrL:()=>rn.Fr,CqQ:()=>E,$Eq:()=>T,ZB7:()=>r5.ZB,TrS:()=>tz,sIN:()=>a2.sI,a2g:()=>d.getRenderContent,t6u:()=>u.t6,qIn:()=>nE.qI,HPy:()=>r.HP,R_2:()=>nR.R_,doK:()=>D.do,bZ4:()=>r.bZ,pxY:()=>ep.px,pde:()=>nR.pd,CEt:()=>rn.CE,lum:()=>ep.lu,OpO:()=>u.Op,tO8:()=>r.tO,nxV:()=>rn.nx,TDj:()=>lS,xA9:()=>r5.xA,lNE:()=>i1.l,ud$:()=>e7,l46:()=>n3,X_:()=>d.DraggableContext,QD_:()=>rn.QD,ud1:()=>r.ud,Dgp:()=>D.Dg,tvd:()=>D.tv,QEB:()=>i0,X6x:()=>tS,jZb:()=>lp,tn0:()=>nE.tn,dF1:()=>l$.dF,kBD:()=>ep.kB,Gjn:()=>r.Gj,VFg:()=>tw,Pnr:()=>rn.Pn,zN:()=>r.zN,dKS:()=>iJ,LMh:()=>nR.LM,lTd:()=>eR,rlt:()=>eB,dWC:()=>t1.dW,cWk:()=>r.cW,Zy6:()=>tV,PB5:()=>i4.PB,UTu:()=>rn.UT,jeY:()=>D.je,TB2:()=>r.TB,D6h:()=>r1,d9b:()=>l$.d9,fM:()=>lv,X43:()=>l_.X,uc_:()=>rI,pEl:()=>i4.pE,T$Q:()=>l_.T,GD6:()=>u.GD,mJi:()=>nR.mJ,C5g:()=>lx.C5,OJX:()=>ep.OJ,Bmi:()=>aN,u4V:()=>sv.u,lrV:()=>rn.lr,fDF:()=>n.fD,N$k:()=>e4.N$,_sT:()=>l$._s,rNg:()=>lg.rN,RhU:()=>r.Rh,Bnf:()=>oF,UyB:()=>e6,xq$:()=>D.xq,RB3:()=>i4.RB,I5x:()=>eE,hqJ:()=>nR.hq,XIK:()=>aw,m2w:()=>nC,ccy:()=>sf,NVg:()=>lx.NV,kDr:()=>D.kD,J3t:()=>t1.J3,d09:()=>r.d0,AG:()=>aJ,Xjr:()=>oI,uwA:()=>e4.uw,KDQ:()=>ev,$mi:()=>oc.$,L1H:()=>d.Sortable,QoO:()=>rn.Qo,q7s:()=>D.q7,Mp5:()=>d.DndContext,xB5:()=>ep.xB,B4G:()=>D.B4,YIz:()=>iI,$xS:()=>i8,o8F:()=>oA,qKt:()=>i4.qK,_OO:()=>l$._O,qy$:()=>nQ,W1t:()=>tZ,Z0V:()=>nE.Z0,cGx:()=>ri,Q2z:()=>rn.Q2,YW0:()=>ll,HvB:()=>u.Hv,ic7:()=>r0,QpY:()=>D.Qp,tUM:()=>aH,oAT:()=>D.oA,zBI:()=>e8,gBz:()=>d.SortableProvider,eIh:()=>D.eI,i_r:()=>rO.i,DVX:()=>D.DV,b7u:()=>e4.b7,Mwt:()=>i4.Mw,Kql:()=>r.Kq,XOn:()=>D.XO,ozN:()=>iU.o,nu1:()=>tv.n,rTt:()=>a2.rT,eBw:()=>r2,xZI:()=>ep.xZ,MIq:()=>r.MI,JaO:()=>rU,htN:()=>eW,Eaz:()=>r.E,qy5:()=>n6,IX0:()=>lg.IX,lSn:()=>lx.lS,BsJ:()=>e4.Bs,_22:()=>iX._,sxL:()=>ot,xPi:()=>tv.x,b2W:()=>rG.b,sDQ:()=>i9,Xzy:()=>D.Xz,gt0:()=>i5,QIX:()=>e9,i_F:()=>nD,Ypd:()=>r.Yp,SOm:()=>e4.SO,VXI:()=>r.VX,nKd:()=>lc,N3p:()=>u.N3,dJT:()=>e4.dJ,vPC:()=>D.vP,a97:()=>ep.a9,TNL:()=>D.TN,Qgm:()=>tb.Q,RLS:()=>ig,OqW:()=>e4.Oq,j0_:()=>rC,zVE:()=>a1,yVm:()=>r.yV,B_g:()=>rr,Hbp:()=>ep.Hb,lhV:()=>D.lh,yGk:()=>e4.yG,QIi:()=>ep.QI,Q00:()=>iW,OAH:()=>u.OA,JQe:()=>D.JQ,xqq:()=>r.xq,zEg:()=>e3.z,wN6:()=>iU.w,fDM:()=>rn.fD,uUT:()=>lb,BCL:()=>aA.BC,D50:()=>r.D5,Fag:()=>ep.F,MoU:()=>r.Mo,wnJ:()=>e4.wn,ISS:()=>t_.I,m$h:()=>lA,c_d:()=>e4.c_,Hi5:()=>aq,x1p:()=>rn.x1,DYS:()=>u.DY,U6o:()=>r.U6,LjE:()=>ep.Lj,l2i:()=>r.l2,Um:()=>e4.Um,Y2j:()=>lo,O$4:()=>i4.O$,G2C:()=>lL.G2,wA7:()=>sl,$t1:()=>D.$t,_bM:()=>l$._b,b6K:()=>oc.b,vzL:()=>nX,lNX:()=>l$.lN,rcl:()=>r.rc,gZ:()=>i4.gZ,msY:()=>rn.ms,U8O:()=>r.U8,Sh8:()=>r.Sh,mhY:()=>ep.mh,tXY:()=>lx.tX,Sc0:()=>or,p9h:()=>aY,gBZ:()=>d.SortableContext,JDj:()=>aW,hbv:()=>ro,RD4:()=>rJ.R,bee:()=>i4.be,PSc:()=>r.PS,hsK:()=>e3.h,oVU:()=>n$,IJ7:()=>D.IJ,f2z:()=>oN.f,OZ6:()=>tk,pA3:()=>e4.pA,$5j:()=>r.$5,J1:()=>D.J1,dVP:()=>d.DateFilterDynamicComponent,E76:()=>r.E7,j9R:()=>nL,vjx:()=>rD,mz8:()=>r5.mz,Doh:()=>u.Do,vxQ:()=>nU,Us6:()=>ep.Us,UqM:()=>d.SortableItem,lVW:()=>A,f7I:()=>aZ,ARu:()=>lj,TDH:()=>ep.TD,l6P:()=>eP,g9w:()=>e4.g9,s23:()=>lu,GjU:()=>r.nY,GmQ:()=>i4.Gm,skP:()=>n2.s,C4D:()=>n1,arW:()=>ix.a,v93:()=>aE,Wis:()=>r.Wi,jE9:()=>ep.jE,dbD:()=>rq.d,Ff5:()=>D.Ff,gM2:()=>e4.gM,FZR:()=>nR.FZ,PnP:()=>a5.P,nlx:()=>eL,AQf:()=>nE.AQ,FoY:()=>i2,w2W:()=>i4.w2,z45:()=>r.z4,bkX:()=>lk,jgC:()=>aL,Ur4:()=>a3,lE3:()=>D.lE,U5u:()=>D.U5,LtX:()=>r.Lt,cl6:()=>iE,d1R:()=>ep.d1,rrz:()=>t1.rr,B8B:()=>iK,hY7:()=>oN.h,Ob5:()=>tH,erX:()=>ep.er,MqW:()=>u.Mq,S5r:()=>rG.S,YYe:()=>ep.YY,ami:()=>a2.am,LBS:()=>rW,L3t:()=>d.DragHandler,oMF:()=>ey});var o={};l.r(o),l.d(o,{Action:()=>r.rc,ActionBar:()=>r.E7,ActionBarProvider:()=>r.xq,ActionContext:()=>r.yV,ActionContextNoRerender:()=>r.Wi,ActionContextProvider:()=>r.z4,ActionDesigner:()=>r.U6,AfterSuccess:()=>r.Kq,AllDataBlocksContext:()=>t1.rr,AllDataBlocksProvider:()=>t1.J3,AntdSchemaComponentPlugin:()=>lk,AntdSchemaComponentProvider:()=>lS,AppendsTreeSelect:()=>lA,AssignedFieldValues:()=>r.TB,AssociationField:()=>nC,AssociationFieldMode:()=>oF,AssociationFieldModeProvider:()=>oA,AssociationSelect:()=>nD,AttachmentList:()=>l$._s,AutoComplete:()=>nL,BackButtonUsedInSubPage:()=>e3.h,Block:()=>r2,BlockItem:()=>nE.Z0,BlockItemCard:()=>nE.tn,BlockItemCardContext:()=>nE.AQ,BlocksSelector:()=>r.Gj,ButtonEditor:()=>r.Yp,CardItem:()=>n$,Cascader:()=>nU,Checkbox:()=>or,CollectionSelect:()=>nX,ColorPicker:()=>n2.s,ColorSelect:()=>n6,Cron:()=>n3,CronSet:()=>ro,DataSourceCollectionCascader:()=>n1,DataSourceSelect:()=>nQ,DateFormatCom:()=>rG.b,DatePicker:()=>rn.lr,DatePickerProvider:()=>rn.Qo,Details:()=>rr,DetailsDesigner:()=>E,Divider:()=>ri,EditComponent:()=>D.iI,EditDefaultValue:()=>D.tv,EditDescription:()=>D.JQ,EditOperator:()=>D.B4,EditPattern:()=>D.$t,EditRequired:()=>D.Qp,EditSortField:()=>aL,EditTable:()=>rC,EditTableAction:()=>rD,EditTableActionContext:()=>rI,EditTitle:()=>D.Xz,EditTitleField:()=>D.Ff,EditTooltip:()=>D.IJ,EditValidationRules:()=>D.vP,Editable:()=>i2,EllipsisWithTooltip:()=>nR.R_,ErrorFallback:()=>tv.x,Expand:()=>rU,ExpiresRadio:()=>rG.S,FieldsTreeSelect:()=>lj,Fieldset:()=>rW,Filter:()=>e4.dJ,FilterAction:()=>e4.Bs,FilterActionContext:()=>e4.SO,FilterContext:()=>e4.gM,FilterDynamicComponent:()=>e4.N$,FilterLogicContext:()=>e4.c_,Form:()=>A,FormDialog:()=>rJ.R,FormDrawer:()=>sl,FormField:()=>e8,FormItem:()=>D.eI,FormV2:()=>eW,G2Plot:()=>r1,G2PlotRenderer:()=>r0,Grid:()=>r5.xA,GridCard:()=>ig,GridRowContext:()=>r5.mz,HTMLEncode:()=>nR.mJ,ICON_POPUP_Z_INDEX:()=>oc.b,IconPicker:()=>ix.a,Input:()=>nR.pd,InputNumber:()=>iI,InputReadPretty:()=>nR.FZ,InputRecordPicker:()=>i4.qK,Json:()=>nR.LM,LinkageFilter:()=>sf,List:()=>iK,Markdown:()=>iU.o,MarkdownReadPretty:()=>iU.w,Menu:()=>tZ,NanoIDInput:()=>iW,Page:()=>ll,PagePopups:()=>lg.rN,PageTabs:()=>lo,Pagination:()=>iJ,ParentRouteContext:()=>tV,Password:()=>iX._,Percent:()=>i0,PopupSettingsProvider:()=>l_.T,Preview:()=>i1.l,QuickEdit:()=>i5,Radio:()=>ot,ReadPretty:()=>nR.hq,ReadPrettyRecordPicker:()=>i4.w2,RecordPicker:()=>i4.O$,RecordPickerContext:()=>i4.pE,RecordPickerProvider:()=>i4.be,RefreshDataBlockRequest:()=>r.ud,RemoteSelect:()=>eR,RemoveButton:()=>r.d0,RemoveConditionContext:()=>e4.b7,RequestSettings:()=>r.Rh,RichText:()=>i9,SecondConFirm:()=>r.VX,Select:()=>eP,SkipValidation:()=>r.zN,Space:()=>i8,StablePopover:()=>oc.$,Table:()=>aw,TableBlockDesigner:()=>aE,TableField:()=>aN,TableSelectorDesigner:()=>aY,TableV2:()=>aq,Tabs:()=>aH,TabsContextProvider:()=>oN.h,Templates:()=>eE,TestDesigner:()=>nE.qI,TextAreaWithGlobalScope:()=>a3,TimePicker:()=>aJ,TreeSelect:()=>aZ,UnixTimestamp:()=>a1,Upload:()=>l$._O,Uploader:()=>l$.d9,Variable:()=>a2.rT,VariableScopeProvider:()=>a2.sI,VariableSelect:()=>a5.P,actionSettings:()=>r.Sh,actionSettingsItems:()=>r.Mo,allowAddNew:()=>D.lE,attachmentFileTypes:()=>l$.lN,defaultFieldNames:()=>ev,fetchTemplateData:()=>eB,filterFormItemSettings:()=>D.Dg,findByUid:()=>tS,findKeysByUid:()=>tw,findMenuItem:()=>tk,formDetailsSettings:()=>e9,formItemSettings:()=>D.DV,formSettings:()=>e6,formV1Settings:()=>T,genStyleHook:()=>n.fD,getCurrentOptions:()=>ey,getDateExact:()=>rn.Q2,getDatePickerLabels:()=>i4.Mw,getDateRanges:()=>rn.fD,getLabelFormatValue:()=>i4.PB,getPopupPathFromParams:()=>lx.C5,getStoredPopupContext:()=>lx.lS,getTabSchema:()=>lp,getZIndex:()=>r.fl,handleDateChangeOnForm:()=>rn.QD,inferPickerType:()=>rn.Pn,isBulkEditAction:()=>r.PS,isFileCollection:()=>D.XO,isMobile:()=>rn.Fr,isShowFilePicker:()=>i4.Gm,isTabPage:()=>lc,isWriteEmailAction:()=>r.cW,mapDatePicker:()=>rn.x1,mapRangePicker:()=>rn.UT,mapTimeFormat:()=>aW,matchMimetype:()=>l$._b,moment2str:()=>rn.ms,navigateToTab:()=>lu,pageSettings:()=>lv,pageTabSettings:()=>lb,readPrettyFormSettings:()=>e7,removeNullCondition:()=>e4.pA,resolveFilterPickerFormat:()=>rn.CE,storePopupContext:()=>lx.NV,useActionBarContext:()=>r.MI,useActionContext:()=>r.D5,useAfterSuccessOptions:()=>r.bZ,useAllDataBlocks:()=>t1.dW,useAssociationFieldContext:()=>lL.G2,useAssociationFieldModeContext:()=>oI,useBackButton:()=>e3.z,useCloseAction:()=>r.nY,useColumnSchema:()=>aA.BC,useColumnSettings:()=>rq.d,useCurrentPopupContext:()=>lg.IX,useDatePickerContext:()=>rn.nx,useDownloadLogs:()=>tv.n,useEnsureOperatorsValid:()=>D.lh,useFieldMode:()=>D.J1,useFieldNames:()=>i4.gZ,useFilterActionProps:()=>e4.Um,useFilterFieldOptions:()=>e4.g9,useFilterFieldProps:()=>e4.yG,useFilterOptions:()=>e4.uw,useFormDataTemplates:()=>eL,useGetAriaLabelOfAction:()=>r.U8,useGetAriaLabelOfDrawer:()=>r.HP,useGetAriaLabelOfModal:()=>r.tO,useGetAriaLabelOfPopover:()=>r.l2,useGetFilterFieldOptions:()=>e4.Oq,useGetFilterOptions:()=>e4.wn,useGridContext:()=>r5.ZB,useGridRowContext:()=>r5.FV,useIsAddNewForm:()=>D.TN,useIsAssociationField:()=>D.xq,useIsFieldReadPretty:()=>D.U5,useIsFileField:()=>D.oA,useIsFormReadPretty:()=>D.q7,useIsSelectFieldMode:()=>D.je,useLabelUiSchema:()=>i4.RB,useLinkageAction:()=>r.Lt,useListBlockContext:()=>iE,useMenuDragEnd:()=>tX,useMenuTranslation:()=>tb.Q,useNocoBaseRoutes:()=>tH,useParentRoute:()=>tz,usePopupSettings:()=>l_.X,useStyles:()=>t_.I,useTableColumnIntegration:()=>rO.i,useTabsContext:()=>oN.f,useTitleFieldOptions:()=>D.kD,useUploadStyles:()=>l$.dF,useValidateSchema:()=>D.do,useVariableScope:()=>a2.am,useZIndexContext:()=>r.$5,withSearchParams:()=>lx.tX,zIndexContext:()=>r.E});var n=l(54969),r=l(6522),i=l(71178),a=l(51649),s=l(83468),d=l(91032),u=l(90995),c=l(72548);let p=e=>async function(){try{var t;let l=await this.api.request(e);return null==l||null==(t=l.data)?void 0:t.data}catch(e){return[]}};var m=l(56220),h=l(44814),f=l(56920),v=l(52793),g=l(74737),x=l(43288),y=l(30644),b=l(29699),_=l(25952),S=l(75830),k=l(24768);let C=e=>{let{form:t,children:l,...o}=e,n=(0,f.useField)(),r=(0,f.useFieldSchema)(),a=(0,ep.TD)(t.createVoidField({...n.props,basePath:""}));return(0,i.jsx)(f.FieldContext.Provider,{value:void 0,children:(0,i.jsx)(f.FormContext.Provider,{value:t,children:(0,i.jsx)(m.FormLayout,{layout:"vertical",...o,children:(0,i.jsx)(y.dw,{basePath:a.address,schema:r,onlyRenderProperties:!0})})})})},w=e=>e.children,M=e=>{let{form:t,children:l,disabled:o,...n}=e,r=(0,f.useField)(),s=(0,f.useFieldSchema)(),d=(0,ep.TD)(t.createVoidField({...r.props,basePath:""})),u=(0,ep.xZ)(s["x-component"],w);return(0,a.useEffect)(()=>{t.disabled=o||r.disabled},[o,r.disabled]),(0,i.jsx)(v.ConfigProvider,{componentDisabled:o,children:(0,i.jsx)(f.FieldContext.Provider,{value:void 0,children:(0,i.jsx)(f.FormContext.Provider,{value:t,children:(0,i.jsx)(m.FormLayout,{layout:"vertical",...n,children:(0,i.jsx)(f.FieldContext.Provider,{value:d,children:(0,i.jsx)(u,{...r.componentProps,children:(0,i.jsx)(y.dw,{basePath:d.address,schema:s,onlyRenderProperties:!0})})})})})})})},F=e=>{let{request:t,initialValue:l}=e;return t||(()=>Promise.resolve({data:l}))},P=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,g.bP)(F(t),e)},j=(0,a.createContext)(null);j.displayName="FormBlockContext";let A=(0,f.observer)(e=>{let{request:t,effects:l,initialValue:o,useValues:n=P,...r}=e,s=(0,f.useFieldSchema)(),d=(0,f.useField)(),u=(0,a.useMemo)(()=>(0,h.createForm)({effects:l}),[]),c=n({uid:s["x-uid"],async onSuccess(e){await u.reset(),u.setValues(null==e?void 0:e.data),u.setInitialValues(null==e?void 0:e.data)}},e),p=(0,a.useContext)(j);return(0,i.jsx)(j.Provider,{value:{parent:p,form:u,result:c,field:d,fieldSchema:s},children:(0,i.jsx)(v.Spin,{spinning:(null==c?void 0:c.loading)||!1,children:"Form"===s["x-decorator"]?(0,i.jsx)(M,{form:u,...r}):(0,i.jsx)(C,{form:u,...r})})})},{displayName:"Form"});A.Designer=function(){let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)(),{componentNamePrefix:o}=(0,k.kU)();return(0,i.jsxs)(b.xK,{template:l,title:t||e,children:[(0,i.jsx)(_.l,{componentName:`${o}Form`,collectionName:e}),(0,i.jsx)(b.kT,{}),(0,i.jsx)(b.d$,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};var I=l(31675);let T=new I.RT({name:"FormV1Settings",items:[{name:"template",Component:_.l,useComponentProps(){let{name:e}=(0,x.k7)(),{componentNamePrefix:t}=(0,k.kU)();return{componentName:`${t}Form`,collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});var D=l(60929);let R=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"FormSettings",template:l,title:t||e})},L=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"ReadPrettyFormSettings",template:l,title:t||e})},E=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"FormDetailsSettings",template:l,title:t||e})},N=()=>{let{name:e,title:t}=(0,x.k7)(),l=(0,S.D$)();return(0,i.jsx)(b.xK,{schemaSettings:"blockSettings:filterForm",template:l,title:t||e})};var B=l(69412),Y=l(80461),q=l(99847),O=l(49948),$=l(10691),V=l(27404),z=l(77583),H=l(77850),K=l(18111),U=l(70136),G=l(28227),W=l(14187),J=l(92619),X=l(4627),Z=l(83006),Q=l(43923),ee=l(4922),et=l(95210),el=l(62152),eo=l(63526),en=l(77843),er=l(69575),ei=l(65457),ea=l(82113),es=l(91815),ed=l(23460),eu=l(29558),ec=l(58980),ep=l(28260),em=l(46638),eh=l(46724),ef=l(81607);let ev={label:"label",value:"value",color:"color",options:"children"};function eg(e,t){let l=[];if(!Array.isArray(e))return l;for(let o=0;o<e.length;o++){let n=e[o][t.options];Array.isArray(n)&&l.push(...eg(n,t)),l.push({...e[o]})}return l}function ex(e,t,l){if(!e)return[];let o=[];for(let n of l){let l=e.find(e=>e[t.value]==n)||{value:n,label:n?n.toString():n};o.push(l)}return o}function ey(e,t,l){let o=eg(t,l),n=(0,z.castArray)(e).map(e=>(0,eo.isPlainObject)(e)?e[l.value]:e);return ex(o,l,n)}var eb=l(84951),e_=l(60430);let eS=(0,f.observer)(e=>{let[t,l]=(0,a.useState)(!0),[o,n]=(0,a.useState)([]),r=(0,f.useField)(),s=(0,eh.E1)();return((0,a.useEffect)(()=>{var t;let o={...ev,...e.fieldNames},a=r.dataSource||e.options||(null==s?void 0:s.uiSchema.enum)||[],d=ey(r.value,a,o);!(0,V.isValid)(e.value)&&!d.length||(0,h.isArrayField)(r)&&(null==r||null==(t=r.value)?void 0:t.length)===0||(n(null!==r.value&&d.map((e,t)=>(0,i.jsx)(v.Tag,{color:e[o.color],icon:"string"==typeof e.icon?(0,i.jsx)(e_.In,{type:e.icon}):e.icon,children:e[o.label]},t))),l(!1))},[null==s?void 0:s.uiSchema.enum,r,r.dataSource,r.value,e.fieldNames,e.options,e.value]),t)?null:(0,i.jsx)(ef.R,{ellipsis:e.ellipsis,children:o})},{displayName:"SelectReadPretty"}),ek=(0,eb.A)(eS),eC=e=>!(0,V.isValid)(e)||"object"==typeof e&&0===Object.keys(e).length,ew=e=>{let{value:t,options:l,onChange:o,fieldNames:n,mode:r,loading:a,rawOptions:s,defaultValue:d,...u}=e,c=em.isDesktop?"":eF,p=em.isDesktop?void 0:"topLeft",m=t=>{var o;if(eC(t))return;let i=null==(o=ey((0,V.toArr)(t).filter(e=>e).map(e=>(0,eo.isPlainObject)(e)?e[n.value]:e),l,n))?void 0:o.map(e=>({label:e[n.label],value:e[n.value]}));return["tags","multiple"].includes(r)||e.multiple?i:i.shift()};return(0,i.jsx)(v.Select,{rootClassName:c,placement:p,role:"button","data-testid":`select-object-${r||"single"}`,value:m(t),defaultValue:m(d),allowClear:{clearIcon:(0,i.jsx)(ea.CloseCircleFilled,{role:"button","aria-label":"icon-close-select"})},labelInValue:!0,notFoundContent:a?(0,i.jsx)(v.Spin,{}):(0,i.jsx)(v.Empty,{image:v.Empty.PRESENTED_IMAGE_SIMPLE}),options:l,fieldNames:n,showSearch:!0,popupMatchSelectWidth:!1,filterOption:(e,t)=>((null==t?void 0:t[n.label||"label"])??"").includes(e),filterSort:(e,t)=>((null==e?void 0:e[n.label||"label"])??"").toLowerCase().localeCompare(((null==t?void 0:t[n.label||"label"])??"").toLowerCase()),onChange:t=>{let i=ey((0,V.toArr)(t).map(e=>e.value),s||l,n);["tags","multiple"].includes(r)||e.multiple?null==o||o(i):null==o||o(i.shift()||null)},mode:r,tagRender:e=>(0,i.jsx)(v.Tag,{role:"button","aria-label":e.label,closeIcon:(0,i.jsx)(ea.CloseOutlined,{role:"button","aria-label":"icon-close-tag"}),...e,children:e.label}),maxTagCount:"responsive",maxTagPlaceholder:e=>(0,i.jsxs)(v.Tooltip,{title:(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,maxWidth:"100%"},children:e.map(e=>(0,i.jsx)(v.Tag,{style:{margin:0,background:"#fafafa",border:"1px solid #d9d9d9",whiteSpace:"normal",wordBreak:"break-word",maxWidth:"100%"},children:e.label},e.value))}),overlayInnerStyle:{background:"#fff",color:"#000",padding:8,maxWidth:"100%"},color:"#fff",overlayStyle:{pointerEvents:"auto",maxWidth:300},children:["+",e.length,"..."]}),...u})},eM=(e,t)=>((null==t?void 0:t.label)??"").toLowerCase().includes((e||"").toLowerCase()),eF=(0,$.css)`
|
|
1443
1443
|
& .ant-select-selection-search-input {
|
|
1444
1444
|
opacity: 0.1 !important;
|
|
1445
1445
|
}
|