bi-components-library 1.2.21 → 1.2.22
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/dist/index.es.js +3 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -33,7 +33,7 @@ ${(e||"").replace(/\r\n/g,`
|
|
|
33
33
|
`).split(`
|
|
34
34
|
`);let d=0;for(const y of c){const h=l.measureText(y||" ").width||0;d=Math.max(d,h)}const m=Number.parseFloat(n.letterSpacing||""),p=Number.isFinite(m)?m:0;if(p>0){const y=c.reduce((h,b)=>h.length>=b.length?h:b,"");d+=p*Math.max(0,y.length-1)}return Math.ceil(d)}function za(e,t){if(!e.current)return;e.current.querySelectorAll('[data-type="variable"]').forEach(l=>{if(l.dataset.variableRender==="antd-textarea")return;const r=l.innerText.replace(/\u200B/g,"").trim();if(r.length===0){const p=l.querySelector(".variable-info-icon");Array.from(l.childNodes).forEach(b=>{if(b.nodeType===Node.TEXT_NODE){l.removeChild(b);return}b.nodeType===Node.ELEMENT_NODE&&b.tagName==="BR"&&l.removeChild(b)});const y=document.createTextNode("");p&&p.parentNode===l?l.insertBefore(y,p):l.firstChild?l.insertBefore(y,l.firstChild):l.appendChild(y),l.classList.add("show-placeholder");const h=l.dataset.placeholder||"";if(h){const g=(()=>{try{const M=ec(h,l);if(!M||!Number.isFinite(M)){const S=qa(h);return Math.max(0,S-22)}return M}catch{const M=qa(h);return Math.max(0,M-22)}})(),E=(()=>{if(!l.classList.contains("rte-variable-with-icon"))return 0;const M=l.querySelector(".variable-info-icon:not(.hidden)");if(!M)return 24;try{const S=window.getComputedStyle(M),T=Math.ceil(M.getBoundingClientRect().width||0)||16,A=Math.ceil(Number.parseFloat(S.right||"0"))||4;return Math.max(16,Math.min(120,T+A+2))}catch{return 24}})();E>0?l.style.setProperty("--rte-icon-pad-right",`${E}px`):l.style.removeProperty("--rte-icon-pad-right");const _=2,w=E>0?E:8,C=Math.max(24,Math.min(600,Math.ceil(g+8+w+_)));l.style.minWidth=`${C}px`}else l.style.minWidth=""}else l.classList.remove("show-placeholder"),l.style.minWidth="",l.style.removeProperty("--rte-icon-pad-right");const i=l.innerText||"",u=!!l.querySelector("br")||i.includes(`
|
|
35
35
|
`),s=l.offsetHeight>32,o=r.length>0&&(u||s);l.classList.toggle("rte-variable-multiline",o),l.classList.toggle("rte-variable-force-block",o);const c=l.closest(".rte-inline-group");c&&c.classList.toggle("rte-inline-group-force-block",o);const d=l.closest(".required-upload-group, .required-multi-first");d&&d.classList.toggle("rte-required-group-force-block",o);const m=d?d.parentElement?.closest(".exclusion-wrapper"):l.closest(".exclusion-wrapper");m&&m!==d&&m.classList.toggle("rte-exclusion-force-block",o)})}function Ol(e,t,a,l){if(!e.current)return;const n=h=>{h.classList.contains("rte-richtext-host-expanded")&&(h.style.setProperty("display","flex","important"),h.style.setProperty("flex-direction","column","important"),h.style.setProperty("flex","1 1 auto","important"),h.style.setProperty("min-height","0","important"),h.style.setProperty("width","100%","important"),h.style.setProperty("align-self","stretch","important"))},r=h=>{if(!h.closest('[data-rte-force-hidden="1"]')){if(h.classList.contains("rte-richtext-host-expanded")){n(h);return}if(h.classList.contains("required-upload-group")){h.style.setProperty("display","inline-flex","important");return}if(h.classList.contains("exclusion-wrapper")){h.classList.contains("rte-exclusion-force-block")?h.style.setProperty("display","block","important"):h.style.setProperty("display","inline-block","important");return}h.style.setProperty("display","inline-block","important")}},i=h=>{h.closest('[data-rte-force-hidden="1"]')||(h.style.display="none",h.style.setProperty("display","none","important"))},u=t.some(h=>h.exclusionGroup==="separator");if(u){const h=[];let b=[];for(const T of t){if(T.exclusionGroup==="separator"){b.length&&h.push(b),b=[];continue}!T.exclusionGroup||T.exclusionGroup==="separator"||(T.type==="upload"&&T.key?b.push({type:"upload",key:T.key}):(T.type==="video-url"||T.type==="video-upload")&&T.key?b.push({type:T.type,key:T.key}):(T.type==="variable"||T.type==="multi-variable"||T.type==="markdown"||T.type==="markdown-name"||T.type==="markdown-module")&&T.key?b.push({type:T.type==="multi-variable"?"multi-variable":"variable",key:T.key}):b.push({type:"other",nodeType:T.type}))}b.length&&h.push(b);const v=T=>{const A=t.find(k=>k.type==="upload"&&k.key===T);return A?typeof A.maxCount=="number"&&A.maxCount>1?A.maxCount:1:0},g=h.map(T=>{for(const A of T)if(A.type!=="other"){if(A.type==="video-url"||A.type==="video-upload"){const k=l?.[A.key];if(k?.status==="success"&&k.videoUrl||k?.status==="loading")return!0;if(A.type==="video-url"){const D=e.current.querySelector(`[data-type="variable"][data-node-type="video-url"][data-key="${A.key}"]`);if(D&&!D.classList.contains("show-placeholder")&&D.innerText.replace(/[\u200B\n]/g,"").trim().length>0)return!0}continue}if(A.type==="upload"){if(a[A.key]!==null&&a[A.key]!==void 0)return!0;const k=v(A.key);for(let D=0;D<k;D++){const P=`${A.key}-${D}`;if(a[P]!==null&&a[P]!==void 0)return!0}continue}if(A.type==="multi-variable"){const k=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${A.key}"]`);for(const D of k){if(D.dataset.variableRender==="antd-textarea"){const P=D.dataset.value||"";let N=P;try{N=decodeURIComponent(P)}catch{N=P}if(N.trim().length>0)return!0;continue}if(!D.classList.contains("show-placeholder")&&D.innerText.replace(/[\u200B\n]/g,"").trim().length>0)return!0}continue}if(A.type==="variable"){if(e.current.querySelector(`[data-node-type="markdown-module"][data-key="${A.key}"]`))return!0;const D=e.current.querySelector(`[data-type="variable"][data-key="${A.key}"]`);if(!D)continue;if(D.dataset.variableRender==="antd-textarea"){const P=D.dataset.value||"";let N=P;try{N=decodeURIComponent(P)}catch{N=P}if(N.trim().length>0)return!0}else if(!D.classList.contains("show-placeholder")&&D.innerText.replace(/[\u200B\n]/g,"").trim().length>0)return!0;continue}}return!1}),E=g.some(Boolean),_=E?g.findIndex(Boolean):-1,w=T=>e.current.querySelector(`[data-type="video-url"][data-key="${T}"], [data-type="video-upload"][data-key="${T}"], [data-type="variable"][data-node-type="video-url"][data-key="${T}"]`),C=T=>{for(const A of h[T]||[])if(A.type!=="other"){if(A.type==="video-url"||A.type==="video-upload"){const k=w(A.key);k&&r(k.closest(".exclusion-wrapper")||k);continue}if(A.type==="upload"){e.current.querySelectorAll(`[data-type="upload"][data-key="${A.key}"], [data-type="upload"][data-key^="${A.key}-"]`).forEach(D=>r(D.closest(".exclusion-wrapper")||D));continue}if(A.type==="multi-variable"){e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${A.key}"]`).forEach(D=>{const P=D.closest(".exclusion-wrapper")||D;r(P)});continue}if(A.type==="variable"){const k=e.current.querySelector(`[data-type="variable"][data-key="${A.key}"]`);k&&r(k.closest(".exclusion-wrapper")||k),e.current.querySelectorAll(`[data-node-type="markdown-module"][data-key="${A.key}"]`).forEach(P=>{const N=P.closest(".exclusion-wrapper")||P.closest(".rte-markdown-module-container")||P;r(N)})}}},M=T=>{for(const A of h[T]||[])if(A.type!=="other"){if(A.type==="video-url"||A.type==="video-upload"){const k=w(A.key);k&&i(k.closest(".exclusion-wrapper")||k);continue}if(A.type==="upload"){e.current.querySelectorAll(`[data-type="upload"][data-key="${A.key}"], [data-type="upload"][data-key^="${A.key}-"]`).forEach(D=>i(D.closest(".exclusion-wrapper")||D));continue}if(A.type==="multi-variable"){e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${A.key}"]`).forEach(D=>i(D.closest(".exclusion-wrapper")||D));continue}if(A.type==="variable"){const k=e.current.querySelector(`[data-type="variable"][data-key="${A.key}"]`);k&&i(k.closest(".exclusion-wrapper")||k),e.current.querySelectorAll(`[data-node-type="markdown-module"][data-key="${A.key}"]`).forEach(P=>{const N=P.closest(".exclusion-wrapper")||P.closest(".rte-markdown-module-container")||P;i(N)})}}};for(let T=0;T<h.length;T++)!E||T===_?C(T):M(T);e.current.querySelectorAll('[data-group="separator"]').forEach(T=>{T.closest('[data-rte-force-hidden="1"]')||(E?i(T):T.style.setProperty("display","inline-flex","important"))});return}const s=new Set,o={};for(const h of t)h.exclusionGroup&&h.exclusionGroup!=="separator"&&(s.add(h.exclusionGroup),o[h.exclusionGroup]||(o[h.exclusionGroup]=[]),o[h.exclusionGroup].push({type:h.type,key:h.key,exclusionGroup:h.exclusionGroup}));const c={};for(const h of s){c[h]=!1;for(const b of o[h])if((b.type==="video-url"||b.type==="video-upload")&&b.key){const v=l?.[b.key];if(v?.status==="success"&&v.videoUrl||v?.status==="loading"){c[h]=!0;break}if(b.type==="video-url"){const g=e.current.querySelector(`[data-type="variable"][data-node-type="video-url"][data-key="${b.key}"]`);if(g&&!g.classList.contains("show-placeholder")&&g.innerText.replace(/[\u200B\n]/g,"").trim().length>0){c[h]=!0;break}}}else if(b.type==="upload"&&b.key){if(a[b.key]!==null&&a[b.key]!==void 0){c[h]=!0;break}const v=t.find(g=>g.type==="upload"&&g.key===b.key);if(v&&typeof v.maxCount=="number")for(let g=0;g<v.maxCount;g++){const E=`${b.key}-${g}`;if(a[E]!==null&&a[E]!==void 0){c[h]=!0;break}}if(c[h])break}else if((b.type==="variable"||b.type==="multi-variable"||b.type==="markdown"||b.type==="markdown-name")&&b.key){if(e.current.querySelector(`[data-node-type="markdown-module"][data-key="${b.key}"]`)){c[h]=!0;break}const g=b.type==="multi-variable"?e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${b.key}"]`):[e.current.querySelector(`[data-type="variable"][data-key="${b.key}"]`)].filter(Boolean);for(const E of g){if(E.dataset.variableRender==="antd-textarea"){const _=E.dataset.value||"";let w=_;try{w=decodeURIComponent(_)}catch{w=_}if(w.trim().length>0){c[h]=!0;break}continue}if(!E.classList.contains("show-placeholder")&&E.innerText.replace(/[\u200B\n]/g,"").trim().length>0){c[h]=!0;break}}if(c[h])break}}const m=Object.keys(c).filter(h=>c[h]).length>0;let p=null;if(m&&u){for(const h of t)if(h.exclusionGroup&&h.exclusionGroup!=="separator"&&c[h.exclusionGroup]){p=h.exclusionGroup;break}}for(const h of s){const b=e.current.querySelectorAll(`[data-group="${h}"]`);u&&m&&p?h===p?b.forEach(r):b.forEach(i):b.forEach(r)}e.current.querySelectorAll('[data-group="separator"]').forEach(h=>{h.closest('[data-rte-force-hidden="1"]')||(m?i(h):h.style.setProperty("display","inline-flex","important"))})}function Dl(e,t,a,l,n){if(!e.current){l(!1);return}const r=h=>{const b=h.getAttribute("data-node-type")||"";if(b!=="report-module"&&b!=="markdown-module")return(h.textContent||"").replace(/[\u200B]/g,"").trim();const v=(h.textContent||"").replace(/[\u200B]/g,"").trim(),g=Array.from(h.querySelectorAll(":scope > div"));if(g.length===0)return v;let E=-1;for(let C=0;C<g.length;C++)if((g[C].textContent||"").replace(/[\u200B]/g,"").trim().length>0){E=C;break}return g.filter((C,M)=>M!==E).map(C=>(C.textContent||"").replace(/[\u200B]/g,"").trim()).join(`
|
|
36
|
-
`).trim()||v},i=h=>h?!!h.closest('[data-rte-force-hidden="1"]'):!1,u=[];for(let h=0;h<t.length;h++){const b=t[h];if((b.type==="variable"||b.type==="report-url"||b.type==="markdown"||b.type==="markdown-name"||b.type==="upload"||b.type==="multi-variable"||b.type==="select"||b.type==="textarea"||b.type==="richtext"||b.type==="report-module"||b.type==="markdown-module"||b.type==="datepicker"||b.type==="number-input"||b.type==="video-url"||b.type==="video-upload")&&b.required&&b.key){u.push({exclusionGroup:b.exclusionGroup||"",key:b.key,type:b.type==="multi-variable"||b.type==="report-url"||b.type==="markdown"||b.type==="markdown-name"?"variable":b.type==="report-module"||b.type==="markdown-module"?"richtext":b.type==="video-url"?"video-url":b.type==="video-upload"?"video-upload":b.type,isMultiVariable:b.type==="multi-variable",minCount:b.type==="multi-variable"||b.type==="upload"&&typeof b.minCount=="number"?b.minCount:void 0,moduleIndex:b.type==="report-module"||b.type==="markdown-module"?b.moduleIndex:void 0,__index:h});continue}if(b.type==="text"&&b.className?.includes("rte-text-required"))if(b.exclusionGroup)for(let v=h+1;v<t.length;v++){const g=t[v];if(g.exclusionGroup===b.exclusionGroup&&(g.type==="variable"||g.type==="markdown"||g.type==="upload"||g.type==="select"||g.type==="textarea"||g.type==="richtext"||g.type==="datepicker"||g.type==="number-input")&&g.key){u.push({exclusionGroup:b.exclusionGroup,key:g.key,type:g.type==="markdown"?"variable":g.type,__index:v});break}}else for(let v=h+1;v<t.length;v++){const g=t[v];if((g.type==="variable"||g.type==="markdown"||g.type==="upload"||g.type==="select"||g.type==="textarea"||g.type==="richtext"||g.type==="datepicker"||g.type==="number-input")&&g.key){u.push({exclusionGroup:g.exclusionGroup||"",key:g.key,type:g.type==="markdown"?"variable":g.type,__index:v});break}}}const s=t.some(h=>h.exclusionGroup==="separator"),o=[];if(s&&u.length>1){const h=[];t.forEach((b,v)=>{b.exclusionGroup==="separator"&&h.push(v)});for(const b of h){const g=u.filter(w=>typeof w.__index=="number"&&w.__index<b).sort((w,C)=>(C.__index??0)-(w.__index??0))[0],_=u.filter(w=>typeof w.__index=="number"&&w.__index>b).sort((w,C)=>(w.__index??0)-(C.__index??0))[0];g&&_&&o.push([g,_])}}if(u.length===0){if(t.length===0){if(!e.current){l(!1);return}const h=e.current.textContent?.replace(/[\u200B\n]/g,"").trim()||"";l(h.length>0);return}l(!0);return}const c=u.filter(h=>{if(!e.current)return!1;if(h.exclusionGroup){const b=e.current.querySelectorAll(`[data-group="${h.exclusionGroup}"]`);if(b.length>0){const v=b[0];return i(v)?!0:v.style.display!=="none"}}if(h.type==="upload"&&h.key){const b=e.current.querySelector(`[data-type="upload"][data-key="${h.key}"]`)||e.current.querySelector(`[data-type="upload"][data-batch-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="variable"&&h.key)if(h.isMultiVariable){const b=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${h.key}"]`);if(b.length>0){const v=b[0],g=v.closest("[data-group]")||v.parentElement;return i(g)?!0:g?g.style.display!=="none":!0}}else{const b=e.current.querySelector(`[data-type="variable"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="select"&&h.key){const b=e.current.querySelector(`[data-type="select"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="textarea"&&h.key){const b=e.current.querySelector(`[data-type="textarea"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="richtext"&&h.key){const b=typeof h.moduleIndex=="number"?`[data-type="richtext"][data-node-type="report-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"], [data-type="richtext"][data-node-type="markdown-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"]`:`[data-type="richtext"][data-key="${h.key}"]`,v=e.current.querySelector(b);if(v){const g=v.closest("[data-group]")||v.parentElement;return i(g)?!0:g?g.style.display!=="none":!0}}else if(h.type==="datepicker"&&h.key){const b=e.current.querySelector(`[data-type="datepicker"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="number-input"&&h.key){const b=e.current.querySelector(`[data-type="number-input"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if((h.type==="video-url"||h.type==="video-upload")&&h.key){const b=e.current.querySelector(`[data-type="${h.type}"][data-key="${h.key}"], [data-type="variable"][data-key="${h.key}"][data-node-type="video-url"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}return!1});if(c.length===0){l(!0);return}const d=new Set;o.forEach(h=>{h.forEach(b=>{b.key&&d.add(b.key)})});const m=c.filter(h=>!h.key||!d.has(h.key));let p=(o.length===0,!0);for(const h of o){const b=h.filter(g=>{if(!e.current)return!1;if(g.exclusionGroup){const E=e.current.querySelectorAll(`[data-group="${g.exclusionGroup}"]`);if(E.length>0){const _=E[0];return i(_)?!0:_.style.display!=="none"}}return!0});if(b.length===0)continue;let v=!1;for(const g of b)if(g.type==="upload"&&g.key){if(g.minCount&&g.minCount>0){let E=0;const _=e.current.querySelectorAll(`[data-type="upload"][data-batch-key="${g.key}"]`);if(_.length===0)continue;for(let w=0;w<_.length;w++){const M=_[w].dataset.key;M&&a[M]!=null&&(E+=1)}if(E>=g.minCount){v=!0;break}}else if(a[g.key]!==null&&a[g.key]!==void 0){v=!0;break}}else if(g.type==="variable"&&g.key)if(g.isMultiVariable){const E=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${g.key}"]`);let _=0;for(const C of Array.from(E)){if(C.classList.contains("show-placeholder"))continue;C.innerText.replace(/[\u200B\n]/g,"").trim().length>0&&(_+=1)}const w=g.minCount&&g.minCount>0?g.minCount:1;if(_>=w){v=!0;break}}else{const E=e.current.querySelector(`[data-type="variable"][data-key="${g.key}"]`);if(E){if(E.classList.contains("show-placeholder"))continue;if(E.innerText.replace(/[\u200B\n]/g,"").trim().length>0){const w=E.dataset.nodeType;if((w==="markdown"||w==="markdown-name")&&!!!e.current.querySelector(`[data-node-type="markdown-module"][data-key="${g.key}"]`))continue;v=!0;break}}}else if(g.type==="select"&&g.key){const E=e.current.querySelector(`[data-type="select"][data-key="${g.key}"]`);if(E&&(E.getAttribute("data-value")||"").trim().length>0){v=!0;break}}else if(g.type==="textarea"&&g.key){const E=e.current.querySelector(`[data-type="textarea"][data-key="${g.key}"]`);if(E&&(E.value||"").trim().length>0){v=!0;break}}else if(g.type==="richtext"&&g.key){const E=typeof g.moduleIndex=="number"?`[data-type="richtext"][data-node-type="report-module"][data-key="${g.key}"][data-module-index="${g.moduleIndex}"], [data-type="richtext"][data-node-type="markdown-module"][data-key="${g.key}"][data-module-index="${g.moduleIndex}"]`:`[data-type="richtext"][data-key="${g.key}"]`,_=e.current.querySelector(E);if(_){if(_.getAttribute("data-is-placeholder")==="true")continue;if(r(_).length>0){v=!0;break}}}else if(g.type==="datepicker"&&g.key){const E=e.current.querySelector(`[data-type="datepicker"][data-key="${g.key}"]`);if(E&&(E.getAttribute("data-value")||"").trim().length>0){v=!0;break}}else if(g.type==="number-input"&&g.key){const E=e.current.querySelector(`[data-type="number-input"][data-key="${g.key}"]`);if(E&&(E.value||"").trim().length>0){v=!0;break}}else if((g.type==="video-url"||g.type==="video-upload")&&g.key&&n?.[g.key]?.status==="success"){v=!0;break}if(!v){p=!1;break}}let y=!0;for(const h of m)if(h.type==="upload"&&h.key){if(h.minCount&&h.minCount>0){let b=0;const v=e.current.querySelectorAll(`[data-type="upload"][data-batch-key="${h.key}"]`);if(v.length===0){y=!1;break}for(let g=0;g<v.length;g++){const _=v[g].dataset.key;_&&a[_]!=null&&(b+=1)}if(b<h.minCount){y=!1;break}}else if(a[h.key]===null||a[h.key]===void 0){y=!1;break}}else if(h.type==="variable"&&h.key)if(h.isMultiVariable){const b=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${h.key}"]`);let v=0;for(const E of Array.from(b)){if(E.classList.contains("show-placeholder"))continue;E.innerText.replace(/[\u200B\n]/g,"").trim().length>0&&(v+=1)}const g=h.minCount&&h.minCount>0?h.minCount:1;if(v<g){y=!1;break}}else{const b=e.current.querySelector(`[data-type="variable"][data-key="${h.key}"]`);if(!b){y=!1;break}if(b.classList.contains("show-placeholder")){y=!1;break}if(b.innerText.replace(/[\u200B\n]/g,"").trim().length===0){y=!1;break}const g=b.dataset.nodeType;if((g==="markdown"||g==="markdown-name")&&!!!e.current.querySelector(`[data-node-type="markdown-module"][data-key="${h.key}"]`)){y=!1;break}}else if(h.type==="select"&&h.key){const b=e.current.querySelector(`[data-type="select"][data-key="${h.key}"]`);if(!b||(b.getAttribute("data-value")||"").trim().length===0){y=!1;break}}else if(h.type==="textarea"&&h.key){const b=e.current.querySelector(`[data-type="textarea"][data-key="${h.key}"]`);if(!b||(b.value||"").trim().length===0){y=!1;break}}else if(h.type==="richtext"&&h.key){const b=typeof h.moduleIndex=="number"?`[data-type="richtext"][data-node-type="report-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"], [data-type="richtext"][data-node-type="markdown-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"]`:`[data-type="richtext"][data-key="${h.key}"]`,v=e.current.querySelector(b);if(v&&v.getAttribute("data-is-placeholder")==="true"){y=!1;break}if(!v||r(v).length===0){y=!1;break}}else if(h.type==="datepicker"&&h.key){const b=e.current.querySelector(`[data-type="datepicker"][data-key="${h.key}"]`);if(!b||(b.getAttribute("data-value")||"").trim().length===0){y=!1;break}}else if(h.type==="number-input"&&h.key){const b=e.current.querySelector(`[data-type="number-input"][data-key="${h.key}"]`);if(!b||(b.value||"").trim().length===0){y=!1;break}}else if((h.type==="video-url"||h.type==="video-upload")&&h.key&&n?.[h.key]?.status!=="success"){y=!1;break}l(p&&y)}const tc=({config:e,effectiveConfig:t,files:a,editorRef:l,setIsFormValid:n,multiVariableCounts:r,setMultiVariableCounts:i,videoState:u})=>{I.useLayoutEffect(()=>{const s=l.current;if(!s)return;const o=new Map,c=p=>{const y=p.target,h=p.relatedTarget;!y||!l.current||!l.current.contains(y)||h&&l.current.contains(h)||setTimeout(()=>{if(l.current){if(e.length===0){const b=l.current.textContent?.replace(/[\u200B\n]/g,"").trim()||"";n(b.length>0);return}za(l),Ol(l,t,a,u),Dl(l,t,a,n,u)}},0)};s.addEventListener("blur",c,!0);const d=()=>{if(!l.current)return;o.forEach((h,b)=>{b.removeEventListener("blur",h,!1)}),o.clear();const p=l.current.querySelectorAll('[data-type="variable"][data-multi-key]'),y=h=>{h.stopPropagation(),h.stopImmediatePropagation();const b=h.target;if(!b||!l.current||!l.current.contains(b))return;const v=b.closest('[data-type="variable"][data-multi-key]');if(!v||!l.current.contains(v))return;let g=!1;if(o.forEach((A,k)=>{(k===v||k.contains(b))&&(g=!0)}),!g)return;const E=v.dataset.multiKey,_=v.dataset.key,w=v.dataset.index;if(!E||!_||w===void 0)return;const C=h.relatedTarget;if(!(!C||!l.current.contains(C)))return;const S=v.innerText.replace(/[\u200B\n]/g,"").trim(),T=/[、,,\s]+/;if(T.test(S)){const D=S.split(T).map(P=>P.trim()).filter(P=>P.length>0).slice(0,9);if(D.length>1){const P=e.find(N=>N.type==="multi-variable"&&N.key===E);if(P){const N=r[E]||1,x=parseInt(w,10),F=P.maxCount||9,U=[];for(let V=0;V<N;V++){const R=`${E}_${V}`,K=l.current.querySelector(`[data-type="variable"][data-key="${R}"][data-multi-key="${E}"]`);if(K){const ne=K.innerText.replace(/[\u200B\n]/g,"").trim();U.push(ne)}}U.splice(x,1,...D);const $=U.slice(0,F);$.length>0&&$[$.length-1]!==""&&$.length<F&&$.push("");const G=Math.max($.length,1),L={};$.forEach((V,R)=>{V&&(L[`${E}_${R}`]=V)}),l.current.querySelectorAll('[data-type="variable"]').forEach(V=>{const R=V.dataset.key,K=V.dataset.multiKey;if(R&&K!==E){const ne=V.innerText.replace(/[\u200B\n]/g,"").trim();ne&&(L[R]=ne)}}),l.current.__tempVariableValues=L,i(V=>({...V,[E]:G}))}}}};p.forEach(h=>{h.addEventListener("blur",y,!1),o.set(h,y)})},m=setTimeout(()=>{d()},0);return()=>{clearTimeout(m),s.removeEventListener("blur",c,!0),o.forEach((p,y)=>{y.removeEventListener("blur",p,!1)}),o.clear()}},[e,t,l,a,r,n,i])},ac=({disabled:e,collapsed:t,onCollapsedChange:a,config:l,lockStructure:n,editorRef:r,containerRef:i,fileInputRef:u,onBeforeFilePickerOpen:s,files:o,setFiles:c,handleRemoveFile:d,setActiveBatchKey:m,setActiveBatchStartIndex:p,setActiveFileKey:y,isDraggingRef:h,richtextPrevScrollTopRef:b,videoState:v,setVideoState:g,videoFileInputRef:E,activeVideoKeyRef:_,onImagePreview:w})=>{const C=(...S)=>{},M=S=>{try{const T=window.getSelection();if(!T)return C(S,"no selection");const A=T.rangeCount>0?T.getRangeAt(0):null;C(S,{rangeCount:T.rangeCount,isCollapsed:T.isCollapsed,anchorNode:T.anchorNode?.nodeType===Node.TEXT_NODE?"TEXT":T.anchorNode?.nodeName,anchorOffset:T.anchorOffset,focusNode:T.focusNode?.nodeType===Node.TEXT_NODE?"TEXT":T.focusNode?.nodeName,focusOffset:T.focusOffset,range:A?{startContainer:A.startContainer.nodeType===Node.TEXT_NODE?"TEXT":A.startContainer.nodeName,startOffset:A.startOffset,endContainer:A.endContainer.nodeType===Node.TEXT_NODE?"TEXT":A.endContainer.nodeName,endOffset:A.endOffset}:null})}catch{}};return I.useCallback(S=>{if(e)return;t&&a?.(!1);const T=S.target;if(C("click",{tag:T.tagName,cls:T.className}),M("before click"),T.closest('[data-type="datepicker"]'))return;if(T.closest(".tag-close-btn")){S.preventDefault(),S.stopPropagation();return}if(l.length===0)return;const D=(W,V)=>{if(!r.current)return;Array.from(r.current.children).forEach(K=>{if(K!==W)if(V)K.dataset.prevDisplay===void 0&&(K.dataset.prevDisplay=K.style.display||""),K.dataset.rteForceHidden="1",K.style.setProperty("display","none","important");else{if(K.dataset.prevDisplay!==void 0){const ne=K.dataset.prevDisplay;ne?K.style.display=ne:K.style.removeProperty("display"),delete K.dataset.prevDisplay}else K.style.removeProperty("display");delete K.dataset.rteForceHidden}})},P=T.closest(".rte-textarea-toggle");if(P){S.preventDefault(),S.stopPropagation();const W=P.closest(".rte-textarea-wrapper"),V=W?.querySelector('[data-type="textarea"]'),K=!(P.getAttribute("data-expanded")==="true");P.setAttribute("data-expanded",String(K)),P.textContent=K?"收起":"展开",W&&W.classList.toggle("rte-textarea-expanded",K);const ne=W?.closest(".rte-textarea-required");if(ne?ne.classList.toggle("rte-textarea-overlay",K):W&&W.classList.toggle("rte-textarea-overlay",K),V)if(K)V.classList.add("rte-textarea-expanded"),V.style.maxHeight="none",V.style.height="100%";else{V.classList.remove("rte-textarea-expanded");const ae=V.dataset.maxHeight||"252";V.style.maxHeight=`${ae}px`,V.style.height="auto"}r.current&&(K?r.current.classList.add("rte-overlay-active"):r.current.classList.remove("rte-overlay-active"));return}const N=T.closest(".rte-richtext-toggle");if(N){S.preventDefault(),S.stopPropagation();const W=N.closest(".rte-richtext-wrapper"),V=W?.querySelector('[data-type="richtext"]'),K=!(N.getAttribute("data-expanded")==="true");((le,ie)=>{le.setAttribute("data-expanded",String(ie)),le.innerHTML=ie?'<i class="iconfont icon-shouqi1"></i><span class="rte-richtext-toggle-label">收起</span>':'<i class="iconfont icon-zhankai2"></i><span class="rte-richtext-toggle-label">展开</span>'})(N,K);const ae=W?.closest(".rte-richtext-required");ae?ae.classList.toggle("rte-richtext-expanded",K):W&&W.classList.toggle("rte-richtext-expanded",K);const X=W?.closest(".exclusion-wrapper")||W?.parentElement;if(V&&(K?(V.style.height="100%",V.style.overflow="auto"):(V.style.height="",V.style.overflow="")),X&&(X.classList.toggle("rte-richtext-host-expanded",K),D(X,K)),r.current){if(r.current.classList.toggle("rte-richtext-fullscreen-active",K),i.current?.classList.toggle("rte-richtext-container-expanded",K),i.current)if(K){const le=Math.ceil(i.current.getBoundingClientRect().height||0);le>0&&i.current.style.setProperty("--rte-richtext-fullscreen-height",`${le}px`)}else i.current.style.removeProperty("--rte-richtext-fullscreen-height");if(K)b.current=r.current.scrollTop||0,setTimeout(()=>{r.current&&(r.current.scrollTop=0,r.current.scrollLeft=0)},0);else{const le=b.current||0;setTimeout(()=>{r.current&&(r.current.scrollTop=le)},0)}}return}if(T.closest('[data-type="text"]')){S.preventDefault(),S.stopPropagation();const W=window.getSelection();W&&W.removeAllRanges();return}if(n&&T.closest(".tag-node")){S.preventDefault(),S.stopPropagation();const V=window.getSelection();V&&V.removeAllRanges();return}const F=T.closest('[data-type="variable"]');if(F){if(h.current)return;if(F.dataset.variableRender!=="antd-textarea"){const W=!!T.closest(".variable-info-icon"),V=F.classList.contains("show-placeholder")||(F.innerText||"").replace(/[\u200B\n]/g,"").trim().length===0;if(C("v1 variable click",{key:F.dataset.key,isPlaceholder:V,isOnIcon:W,classes:F.className,innerText:F.innerText}),V&&!W){S.preventDefault();const R=()=>{try{F.focus();const K=window.getSelection();if(!K)return;const ne=document.createTreeWalker(F,NodeFilter.SHOW_TEXT),ae=ne.nextNode()?ne.currentNode:null,X=document.createRange();ae?(X.setStart(ae,0),X.collapse(!0)):(X.selectNodeContents(F),X.collapse(!0)),K.removeAllRanges(),K.addRange(X),M("after placeCaretLeft()")}catch{}};setTimeout(()=>{window.requestAnimationFrame(R),window.requestAnimationFrame(()=>M("post-raf (click)"))},0)}}setTimeout(()=>{const W=window.getSelection();W&&!W.isCollapsed||za(r)},10);return}const U=T.closest(".video-remove-btn");if(U){S.preventDefault(),S.stopPropagation();const V=U.closest('[data-type="video-url"], [data-type="video-upload"]')?.dataset.key;V&&g&&g(R=>{const K={...R};return delete K[V],K});return}const $=T.closest('[data-type="video-upload"]');if($){S.preventDefault(),S.stopPropagation();const W=$.dataset.key;W&&E?.current&&_&&(_.current=W,E.current.value="",E.current.click());return}const G=T.closest(".file-remove-btn");if(G){S.preventDefault(),S.stopPropagation();const W=G.closest('[data-type="upload"]'),V=W?.dataset.key,R=W?.dataset.batchKey;if(V)if(R){const K=l.find(ne=>ne.type==="upload"&&ne.key===R);if(K&&typeof K.maxCount=="number"&&typeof K.minCount=="number"){const ne=K.maxCount;c(ae=>{const X={...ae},le=[];for(let ie=0;ie<ne;ie++){const he=`${R}-${ie}`,_e=X[he];_e!=null&&he!==V&&le.push(_e)}for(let ie=0;ie<ne;ie++)delete X[`${R}-${ie}`];return le.forEach((ie,he)=>{X[`${R}-${he}`]=ie}),X})}else d(V)}else d(V);return}const L=T.closest('[data-type="upload"]');if(L){const W=L.dataset.key,V=L.dataset.batchKey,R=L.dataset.batchIndex;if(W){const K=o[W];if(K&&w&&(typeof K=="string"?/\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(K):K.type?.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(K.name||""))){S.preventDefault(),S.stopPropagation();const le=typeof K=="string"?K:URL.createObjectURL(K);w(le);return}const ne=V||W,ae=l.find(X=>X.type==="upload"&&X.key===ne);if(u.current&&(ae?.accept?u.current.accept=ae.accept:ae?.acceptType==="image"?u.current.accept="image/*":ae?.acceptType==="file"?u.current.accept=".csv,.xlsx,.xls,.txt,.pdf,.doc,.docx,.json":u.current.accept=""),V){const X=l.find(le=>le.type==="upload"&&le.key===V);if(X&&typeof X.maxCount=="number"&&typeof X.minCount=="number"){const le=X.maxCount,ie=o[W]!=null,he=R!=null?Number.parseInt(R,10):NaN;if(ie){u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click();return}let _e=0;for(let Ge=0;Ge<le;Ge++)o[`${V}-${Ge}`]!=null&&(_e+=1);_e<le&&u.current?(u.current.multiple=!0,m(V),p(Number.isFinite(he)?he:null),y(null),s?.(),u.current.click()):(u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click())}else u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click()}else u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click()}return}},[t,l,i,e,r,u,s,o,d,h,n,a,b,m,p,y,c,g,E,_,w])},lc=({config:e,editorRef:t,setIsEmpty:a,setIsFormValid:l,setReportAnalyzeState:n,setMarkdownAnalyzeState:r,setMarkdownNameAnalyzeState:i,collapsed:u,measureExpandedContentHeight:s,effectiveConfig:o,files:c,multiVariableCounts:d,setMultiVariableCounts:m,savedCursorRef:p,videoState:y})=>I.useCallback(()=>{if(e.length===0){if(t.current){const v=!(t.current.textContent?.replace(/[\u200B\n]/g,"").trim()||"");a(v),l(!v)}return}if(za(t),t.current&&t.current.querySelectorAll('[data-type="variable"][data-node-type="report-url"]').forEach(v=>{const g=v.dataset.key;if(!g)return;v.innerText.replace(/[\u200B\n]/g,"").trim()||n(_=>{const w=_[g];return!w||w.status==="idle"&&(!w.modules||w.modules.length===0)?_:{..._,[g]:{status:"idle",modules:[],lastParsedUrl:void 0,error:void 0}}})}),t.current&&t.current.querySelectorAll('[data-type="variable"][data-node-type="markdown"]').forEach(v=>{const g=v.dataset.key;if(!g)return;v.innerText.replace(/[\u200B\n]/g,"").trim()||r(_=>{const w=_[g];return!w||w.status==="idle"&&(!w.modules||w.modules.length===0)?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}})}),t.current&&t.current.querySelectorAll('[data-type="variable"][data-node-type="markdown-name"]').forEach(v=>{const g=v.dataset.key;if(!g)return;v.innerText.replace(/[\u200B\n]/g,"").trim()||i(_=>{const w=_[g];return!w||w.status==="idle"&&(!w.modules||w.modules.length===0)?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}})}),t.current&&t.current.querySelectorAll('[data-type="richtext"][data-node-type="markdown-module"]').forEach(v=>{const g=v.dataset.key;if(!g)return;const E=v.innerText.replace(/[\u200B\n]/g,"").trim();v.getAttribute("data-is-placeholder")==="true"&&E&&!E.startsWith("请补充:")&&v.removeAttribute("data-is-placeholder"),E||(r(_=>{const w=_[g];return!w||w.status==="idle"?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}}),i(_=>{const w=_[g];return!w||w.status==="idle"?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}}))}),t.current&&t.current.querySelectorAll('[data-type="variable"]').forEach(v=>{if(v.dataset.variableRender==="antd-textarea")return;const g=v.innerText||"",E=!!v.querySelector("br")||g.includes(`
|
|
36
|
+
`).trim()||v},i=h=>h?!!h.closest('[data-rte-force-hidden="1"]'):!1,u=[];for(let h=0;h<t.length;h++){const b=t[h];if((b.type==="variable"||b.type==="report-url"||b.type==="markdown"||b.type==="markdown-name"||b.type==="upload"||b.type==="multi-variable"||b.type==="select"||b.type==="textarea"||b.type==="richtext"||b.type==="report-module"||b.type==="markdown-module"||b.type==="datepicker"||b.type==="number-input"||b.type==="video-url"||b.type==="video-upload")&&b.required&&b.key){u.push({exclusionGroup:b.exclusionGroup||"",key:b.key,type:b.type==="multi-variable"||b.type==="report-url"||b.type==="markdown"||b.type==="markdown-name"?"variable":b.type==="report-module"||b.type==="markdown-module"?"richtext":b.type==="video-url"?"video-url":b.type==="video-upload"?"video-upload":b.type,isMultiVariable:b.type==="multi-variable",minCount:b.type==="multi-variable"||b.type==="upload"&&typeof b.minCount=="number"?b.minCount:void 0,moduleIndex:b.type==="report-module"||b.type==="markdown-module"?b.moduleIndex:void 0,__index:h});continue}if(b.type==="text"&&b.className?.includes("rte-text-required"))if(b.exclusionGroup)for(let v=h+1;v<t.length;v++){const g=t[v];if(g.exclusionGroup===b.exclusionGroup&&(g.type==="variable"||g.type==="markdown"||g.type==="upload"||g.type==="select"||g.type==="textarea"||g.type==="richtext"||g.type==="datepicker"||g.type==="number-input")&&g.key){u.push({exclusionGroup:b.exclusionGroup,key:g.key,type:g.type==="markdown"?"variable":g.type,__index:v});break}}else for(let v=h+1;v<t.length;v++){const g=t[v];if((g.type==="variable"||g.type==="markdown"||g.type==="upload"||g.type==="select"||g.type==="textarea"||g.type==="richtext"||g.type==="datepicker"||g.type==="number-input")&&g.key){u.push({exclusionGroup:g.exclusionGroup||"",key:g.key,type:g.type==="markdown"?"variable":g.type,__index:v});break}}}const s=t.some(h=>h.exclusionGroup==="separator"),o=[];if(s&&u.length>1){const h=[];t.forEach((b,v)=>{b.exclusionGroup==="separator"&&h.push(v)});for(const b of h){const g=u.filter(w=>typeof w.__index=="number"&&w.__index<b).sort((w,C)=>(C.__index??0)-(w.__index??0))[0],_=u.filter(w=>typeof w.__index=="number"&&w.__index>b).sort((w,C)=>(w.__index??0)-(C.__index??0))[0];g&&_&&o.push([g,_])}}if(u.length===0){if(t.length===0){if(!e.current){l(!1);return}const h=e.current.textContent?.replace(/[\u200B\n]/g,"").trim()||"";l(h.length>0);return}l(!0);return}const c=u.filter(h=>{if(!e.current)return!1;if(h.exclusionGroup){const b=e.current.querySelectorAll(`[data-group="${h.exclusionGroup}"]`);if(b.length>0){const v=b[0];return i(v)?!0:v.style.display!=="none"}}if(h.type==="upload"&&h.key){const b=e.current.querySelector(`[data-type="upload"][data-key="${h.key}"]`)||e.current.querySelector(`[data-type="upload"][data-batch-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="variable"&&h.key)if(h.isMultiVariable){const b=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${h.key}"]`);if(b.length>0){const v=b[0],g=v.closest("[data-group]")||v.parentElement;return i(g)?!0:g?g.style.display!=="none":!0}}else{const b=e.current.querySelector(`[data-type="variable"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="select"&&h.key){const b=e.current.querySelector(`[data-type="select"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="textarea"&&h.key){const b=e.current.querySelector(`[data-type="textarea"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="richtext"&&h.key){const b=typeof h.moduleIndex=="number"?`[data-type="richtext"][data-node-type="report-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"], [data-type="richtext"][data-node-type="markdown-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"]`:`[data-type="richtext"][data-key="${h.key}"]`,v=e.current.querySelector(b);if(v){const g=v.closest("[data-group]")||v.parentElement;return i(g)?!0:g?g.style.display!=="none":!0}}else if(h.type==="datepicker"&&h.key){const b=e.current.querySelector(`[data-type="datepicker"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if(h.type==="number-input"&&h.key){const b=e.current.querySelector(`[data-type="number-input"][data-key="${h.key}"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}else if((h.type==="video-url"||h.type==="video-upload")&&h.key){const b=e.current.querySelector(`[data-type="${h.type}"][data-key="${h.key}"], [data-type="variable"][data-key="${h.key}"][data-node-type="video-url"]`);if(b){const v=b.closest("[data-group]")||b.parentElement;return i(v)?!0:v?v.style.display!=="none":!0}}return!1});if(c.length===0){l(!0);return}const d=new Set;o.forEach(h=>{h.forEach(b=>{b.key&&d.add(b.key)})});const m=c.filter(h=>!h.key||!d.has(h.key));let p=(o.length===0,!0);for(const h of o){const b=h.filter(g=>{if(!e.current)return!1;if(g.exclusionGroup){const E=e.current.querySelectorAll(`[data-group="${g.exclusionGroup}"]`);if(E.length>0){const _=E[0];return i(_)?!0:_.style.display!=="none"}}return!0});if(b.length===0)continue;let v=!1;for(const g of b)if(g.type==="upload"&&g.key){if(g.minCount&&g.minCount>0){let E=0;const _=e.current.querySelectorAll(`[data-type="upload"][data-batch-key="${g.key}"]`);if(_.length===0)continue;for(let w=0;w<_.length;w++){const M=_[w].dataset.key;M&&a[M]!=null&&(E+=1)}if(E>=g.minCount){v=!0;break}}else if(a[g.key]!==null&&a[g.key]!==void 0){v=!0;break}}else if(g.type==="variable"&&g.key)if(g.isMultiVariable){const E=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${g.key}"]`);let _=0;for(const C of Array.from(E)){if(C.classList.contains("show-placeholder"))continue;C.innerText.replace(/[\u200B\n]/g,"").trim().length>0&&(_+=1)}const w=g.minCount&&g.minCount>0?g.minCount:1;if(_>=w){v=!0;break}}else{const E=e.current.querySelector(`[data-type="variable"][data-key="${g.key}"]`);if(E){if(E.classList.contains("show-placeholder"))continue;if(E.innerText.replace(/[\u200B\n]/g,"").trim().length>0){const w=E.dataset.nodeType;if((w==="markdown"||w==="markdown-name")&&!!!e.current.querySelector(`[data-node-type="markdown-module"][data-key="${g.key}"]`))continue;v=!0;break}}}else if(g.type==="select"&&g.key){const E=e.current.querySelector(`[data-type="select"][data-key="${g.key}"]`);if(E&&(E.getAttribute("data-value")||"").trim().length>0){v=!0;break}}else if(g.type==="textarea"&&g.key){const E=e.current.querySelector(`[data-type="textarea"][data-key="${g.key}"]`);if(E&&(E.value||"").trim().length>0){v=!0;break}}else if(g.type==="richtext"&&g.key){const E=typeof g.moduleIndex=="number"?`[data-type="richtext"][data-node-type="report-module"][data-key="${g.key}"][data-module-index="${g.moduleIndex}"], [data-type="richtext"][data-node-type="markdown-module"][data-key="${g.key}"][data-module-index="${g.moduleIndex}"]`:`[data-type="richtext"][data-key="${g.key}"]`,_=e.current.querySelector(E);if(_){if(_.getAttribute("data-is-placeholder")==="true")continue;if(r(_).length>0){v=!0;break}}}else if(g.type==="datepicker"&&g.key){const E=e.current.querySelector(`[data-type="datepicker"][data-key="${g.key}"]`);if(E&&(E.getAttribute("data-value")||"").trim().length>0){v=!0;break}}else if(g.type==="number-input"&&g.key){const E=e.current.querySelector(`[data-type="number-input"][data-key="${g.key}"]`);if(E&&(E.value||"").trim().length>0){v=!0;break}}else if((g.type==="video-url"||g.type==="video-upload")&&g.key&&n?.[g.key]?.status==="success"){v=!0;break}if(!v){p=!1;break}}let y=!0;for(const h of m)if(h.type==="upload"&&h.key){if(h.minCount&&h.minCount>0){let b=0;const v=e.current.querySelectorAll(`[data-type="upload"][data-batch-key="${h.key}"]`);if(v.length===0){y=!1;break}for(let g=0;g<v.length;g++){const _=v[g].dataset.key;_&&a[_]!=null&&(b+=1)}if(b<h.minCount){y=!1;break}}else if(a[h.key]===null||a[h.key]===void 0){y=!1;break}}else if(h.type==="variable"&&h.key)if(h.isMultiVariable){const b=e.current.querySelectorAll(`[data-type="variable"][data-multi-key="${h.key}"]`);let v=0;for(const E of Array.from(b)){if(E.classList.contains("show-placeholder"))continue;E.innerText.replace(/[\u200B\n]/g,"").trim().length>0&&(v+=1)}const g=h.minCount&&h.minCount>0?h.minCount:1;if(v<g){y=!1;break}}else{const b=e.current.querySelector(`[data-type="variable"][data-key="${h.key}"]`);if(!b){y=!1;break}if(b.classList.contains("show-placeholder")){y=!1;break}if(b.innerText.replace(/[\u200B\n]/g,"").trim().length===0){y=!1;break}const g=b.dataset.nodeType;if((g==="markdown"||g==="markdown-name")&&!!!e.current.querySelector(`[data-node-type="markdown-module"][data-key="${h.key}"]`)){y=!1;break}}else if(h.type==="select"&&h.key){const b=e.current.querySelector(`[data-type="select"][data-key="${h.key}"]`);if(!b||(b.getAttribute("data-value")||"").trim().length===0){y=!1;break}}else if(h.type==="textarea"&&h.key){const b=e.current.querySelector(`[data-type="textarea"][data-key="${h.key}"]`);if(!b||(b.value||"").trim().length===0){y=!1;break}}else if(h.type==="richtext"&&h.key){const b=typeof h.moduleIndex=="number"?`[data-type="richtext"][data-node-type="report-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"], [data-type="richtext"][data-node-type="markdown-module"][data-key="${h.key}"][data-module-index="${h.moduleIndex}"]`:`[data-type="richtext"][data-key="${h.key}"]`,v=e.current.querySelector(b);if(v&&v.getAttribute("data-is-placeholder")==="true"){y=!1;break}if(!v||r(v).length===0){y=!1;break}}else if(h.type==="datepicker"&&h.key){const b=e.current.querySelector(`[data-type="datepicker"][data-key="${h.key}"]`);if(!b||(b.getAttribute("data-value")||"").trim().length===0){y=!1;break}}else if(h.type==="number-input"&&h.key){const b=e.current.querySelector(`[data-type="number-input"][data-key="${h.key}"]`);if(!b||(b.value||"").trim().length===0){y=!1;break}}else if((h.type==="video-url"||h.type==="video-upload")&&h.key&&n?.[h.key]?.status!=="success"){y=!1;break}l(p&&y)}const tc=({config:e,effectiveConfig:t,files:a,editorRef:l,setIsFormValid:n,multiVariableCounts:r,setMultiVariableCounts:i,videoState:u})=>{I.useLayoutEffect(()=>{const s=l.current;if(!s)return;const o=new Map,c=p=>{const y=p.target,h=p.relatedTarget;!y||!l.current||!l.current.contains(y)||h&&l.current.contains(h)||setTimeout(()=>{if(l.current){if(e.length===0){const b=l.current.textContent?.replace(/[\u200B\n]/g,"").trim()||"";n(b.length>0);return}za(l),Ol(l,t,a,u),Dl(l,t,a,n,u)}},0)};s.addEventListener("blur",c,!0);const d=()=>{if(!l.current)return;o.forEach((h,b)=>{b.removeEventListener("blur",h,!1)}),o.clear();const p=l.current.querySelectorAll('[data-type="variable"][data-multi-key]'),y=h=>{h.stopPropagation(),h.stopImmediatePropagation();const b=h.target;if(!b||!l.current||!l.current.contains(b))return;const v=b.closest('[data-type="variable"][data-multi-key]');if(!v||!l.current.contains(v))return;let g=!1;if(o.forEach((A,k)=>{(k===v||k.contains(b))&&(g=!0)}),!g)return;const E=v.dataset.multiKey,_=v.dataset.key,w=v.dataset.index;if(!E||!_||w===void 0)return;const C=h.relatedTarget;if(!(!C||!l.current.contains(C)))return;const S=v.innerText.replace(/[\u200B\n]/g,"").trim(),T=/[、,,\s]+/;if(T.test(S)){const D=S.split(T).map(P=>P.trim()).filter(P=>P.length>0).slice(0,9);if(D.length>1){const P=e.find(N=>N.type==="multi-variable"&&N.key===E);if(P){const N=r[E]||1,x=parseInt(w,10),F=P.maxCount||9,U=[];for(let V=0;V<N;V++){const R=`${E}_${V}`,K=l.current.querySelector(`[data-type="variable"][data-key="${R}"][data-multi-key="${E}"]`);if(K){const ne=K.innerText.replace(/[\u200B\n]/g,"").trim();U.push(ne)}}U.splice(x,1,...D);const $=U.slice(0,F);$.length>0&&$[$.length-1]!==""&&$.length<F&&$.push("");const G=Math.max($.length,1),L={};$.forEach((V,R)=>{V&&(L[`${E}_${R}`]=V)}),l.current.querySelectorAll('[data-type="variable"]').forEach(V=>{const R=V.dataset.key,K=V.dataset.multiKey;if(R&&K!==E){const ne=V.innerText.replace(/[\u200B\n]/g,"").trim();ne&&(L[R]=ne)}}),l.current.__tempVariableValues=L,i(V=>({...V,[E]:G}))}}}};p.forEach(h=>{h.addEventListener("blur",y,!1),o.set(h,y)})},m=setTimeout(()=>{d()},0);return()=>{clearTimeout(m),s.removeEventListener("blur",c,!0),o.forEach((p,y)=>{y.removeEventListener("blur",p,!1)}),o.clear()}},[e,t,l,a,r,n,i])},ac=({disabled:e,collapsed:t,onCollapsedChange:a,config:l,lockStructure:n,editorRef:r,containerRef:i,fileInputRef:u,onBeforeFilePickerOpen:s,files:o,setFiles:c,handleRemoveFile:d,setActiveBatchKey:m,setActiveBatchStartIndex:p,setActiveFileKey:y,isDraggingRef:h,richtextPrevScrollTopRef:b,videoState:v,setVideoState:g,videoFileInputRef:E,activeVideoKeyRef:_,onImagePreview:w})=>{const C=(...S)=>{},M=S=>{try{const T=window.getSelection();if(!T)return C(S,"no selection");const A=T.rangeCount>0?T.getRangeAt(0):null;C(S,{rangeCount:T.rangeCount,isCollapsed:T.isCollapsed,anchorNode:T.anchorNode?.nodeType===Node.TEXT_NODE?"TEXT":T.anchorNode?.nodeName,anchorOffset:T.anchorOffset,focusNode:T.focusNode?.nodeType===Node.TEXT_NODE?"TEXT":T.focusNode?.nodeName,focusOffset:T.focusOffset,range:A?{startContainer:A.startContainer.nodeType===Node.TEXT_NODE?"TEXT":A.startContainer.nodeName,startOffset:A.startOffset,endContainer:A.endContainer.nodeType===Node.TEXT_NODE?"TEXT":A.endContainer.nodeName,endOffset:A.endOffset}:null})}catch{}};return I.useCallback(S=>{if(e)return;t&&a?.(!1);const T=S.target;if(C("click",{tag:T.tagName,cls:T.className}),M("before click"),T.closest('[data-type="datepicker"]'))return;if(T.closest(".tag-close-btn")){S.preventDefault(),S.stopPropagation();return}if(l.length===0)return;const D=(W,V)=>{if(!r.current)return;Array.from(r.current.children).forEach(K=>{if(K!==W)if(V)K.dataset.prevDisplay===void 0&&(K.dataset.prevDisplay=K.style.display||""),K.dataset.rteForceHidden="1",K.style.setProperty("display","none","important");else{if(K.dataset.prevDisplay!==void 0){const ne=K.dataset.prevDisplay;ne?K.style.display=ne:K.style.removeProperty("display"),delete K.dataset.prevDisplay}else K.style.removeProperty("display");delete K.dataset.rteForceHidden}})},P=T.closest(".rte-textarea-toggle");if(P){S.preventDefault(),S.stopPropagation();const W=P.closest(".rte-textarea-wrapper"),V=W?.querySelector('[data-type="textarea"]'),K=!(P.getAttribute("data-expanded")==="true");P.setAttribute("data-expanded",String(K)),P.textContent=K?"收起":"展开",W&&W.classList.toggle("rte-textarea-expanded",K);const ne=W?.closest(".rte-textarea-required");if(ne?ne.classList.toggle("rte-textarea-overlay",K):W&&W.classList.toggle("rte-textarea-overlay",K),V)if(K)V.classList.add("rte-textarea-expanded"),V.style.maxHeight="none",V.style.height="100%";else{V.classList.remove("rte-textarea-expanded");const ae=V.dataset.maxHeight||"252";V.style.maxHeight=`${ae}px`,V.style.height="auto"}r.current&&(K?r.current.classList.add("rte-overlay-active"):r.current.classList.remove("rte-overlay-active"));return}const N=T.closest(".rte-richtext-toggle");if(N){S.preventDefault(),S.stopPropagation();const W=N.closest(".rte-richtext-wrapper"),V=W?.querySelector('[data-type="richtext"]'),K=!(N.getAttribute("data-expanded")==="true");((le,ie)=>{le.setAttribute("data-expanded",String(ie)),le.innerHTML=ie?'<i class="iconfont icon-shouqi1"></i><span class="rte-richtext-toggle-label">收起</span>':'<i class="iconfont icon-zhankai2"></i><span class="rte-richtext-toggle-label">展开</span>'})(N,K);const ae=W?.closest(".rte-richtext-required");ae?ae.classList.toggle("rte-richtext-expanded",K):W&&W.classList.toggle("rte-richtext-expanded",K);const X=W?.closest(".exclusion-wrapper")||W?.parentElement;if(V&&(K?(V.style.height="100%",V.style.overflow="auto"):(V.style.height="",V.style.overflow="")),X&&(X.classList.toggle("rte-richtext-host-expanded",K),D(X,K)),r.current){if(r.current.classList.toggle("rte-richtext-fullscreen-active",K),i.current?.classList.toggle("rte-richtext-container-expanded",K),i.current)if(K){const le=Math.ceil(i.current.getBoundingClientRect().height||0);le>0&&i.current.style.setProperty("--rte-richtext-fullscreen-height",`${le}px`)}else i.current.style.removeProperty("--rte-richtext-fullscreen-height");if(K)b.current=r.current.scrollTop||0,setTimeout(()=>{r.current&&(r.current.scrollTop=0,r.current.scrollLeft=0)},0);else{const le=b.current||0;setTimeout(()=>{r.current&&(r.current.scrollTop=le)},0)}}return}if(T.closest('[data-type="text"]')){S.preventDefault(),S.stopPropagation();const W=window.getSelection();W&&W.removeAllRanges();return}if(n&&T.closest(".tag-node")){S.preventDefault(),S.stopPropagation();const V=window.getSelection();V&&V.removeAllRanges();return}const F=T.closest('[data-type="variable"]');if(F){if(h.current)return;if(F.dataset.variableRender!=="antd-textarea"){const W=!!T.closest(".variable-info-icon"),V=F.classList.contains("show-placeholder")||(F.innerText||"").replace(/[\u200B\n]/g,"").trim().length===0;if(C("v1 variable click",{key:F.dataset.key,isPlaceholder:V,isOnIcon:W,classes:F.className,innerText:F.innerText}),V&&!W){S.preventDefault();const R=()=>{try{F.focus();const K=window.getSelection();if(!K)return;const ne=document.createTreeWalker(F,NodeFilter.SHOW_TEXT),ae=ne.nextNode()?ne.currentNode:null,X=document.createRange();ae?(X.setStart(ae,0),X.collapse(!0)):(X.selectNodeContents(F),X.collapse(!0)),K.removeAllRanges(),K.addRange(X),M("after placeCaretLeft()")}catch{}};setTimeout(()=>{window.requestAnimationFrame(R),window.requestAnimationFrame(()=>M("post-raf (click)"))},0)}}setTimeout(()=>{const W=window.getSelection();W&&!W.isCollapsed||za(r)},10);return}const U=T.closest(".video-remove-btn");if(U){S.preventDefault(),S.stopPropagation();const V=U.closest('[data-type="video-url"], [data-type="video-upload"]')?.dataset.key;V&&g&&g(R=>{const K={...R};return delete K[V],K});return}const $=T.closest('[data-type="video-upload"]');if($){S.preventDefault(),S.stopPropagation();const W=$.dataset.key;W&&E?.current&&_&&(_.current=W,E.current.value="",E.current.click());return}const G=T.closest(".file-remove-btn");if(G){S.preventDefault(),S.stopPropagation();const W=G.closest('[data-type="upload"]'),V=W?.dataset.key,R=W?.dataset.batchKey;if(V)if(R){const K=l.find(ne=>ne.type==="upload"&&ne.key===R);if(K&&typeof K.maxCount=="number"&&typeof K.minCount=="number"){const ne=K.maxCount;c(ae=>{const X={...ae},le=[];for(let ie=0;ie<ne;ie++){const he=`${R}-${ie}`,_e=X[he];_e!=null&&he!==V&&le.push(_e)}for(let ie=0;ie<ne;ie++)delete X[`${R}-${ie}`];return le.forEach((ie,he)=>{X[`${R}-${he}`]=ie}),X})}else d(V)}else d(V);return}const L=T.closest('[data-type="upload"]');if(L){const W=L.dataset.key,V=L.dataset.batchKey,R=L.dataset.batchIndex;if(W){const K=o[W];if(K&&w&&(typeof K=="string"?/\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(K):K.type?.startsWith("image/")||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(K.name||""))){S.preventDefault(),S.stopPropagation();const le=typeof K=="string"?K:URL.createObjectURL(K);w(le);return}const ne=V||W,ae=l.find(X=>X.type==="upload"&&X.key===ne);if(u.current&&(ae?.accept?u.current.accept=ae.accept:ae?.acceptType==="image"?u.current.accept="image/*":ae?.acceptType==="file"?u.current.accept=".csv,.xlsx,.xls,.txt,.pdf,.doc,.docx,.json":u.current.accept=""),V){const X=l.find(le=>le.type==="upload"&&le.key===V);if(X&&typeof X.maxCount=="number"&&typeof X.minCount=="number"){const le=X.maxCount,ie=o[W]!=null,he=R!=null?Number.parseInt(R,10):NaN;if(ie){u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click();return}let _e=0;for(let Ge=0;Ge<le;Ge++)o[`${V}-${Ge}`]!=null&&(_e+=1);_e<le&&u.current?(u.current.multiple=!0,m(V),p(Number.isFinite(he)?he:null),y(null),s?.(),u.current.click()):(u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click())}else u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click()}else u.current&&(u.current.multiple=!1),m(null),p(null),y(W),s?.(),u.current?.click()}return}},[t,l,i,e,r,u,s,o,d,h,n,a,b,m,p,y,c,g,E,_,w])},lc=({config:e,editorRef:t,setIsEmpty:a,setIsFormValid:l,setReportAnalyzeState:n,setMarkdownAnalyzeState:r,setMarkdownNameAnalyzeState:i,collapsed:u,measureExpandedContentHeight:s,effectiveConfig:o,files:c,multiVariableCounts:d,setMultiVariableCounts:m,savedCursorRef:p,videoState:y})=>I.useCallback(()=>{if(e.length===0){if(t.current){const v=!(t.current.textContent?.replace(/[\u200B\n]/g,"").trim()||"");a(v),l(!v)}u||window.requestAnimationFrame(()=>{s()});return}if(za(t),t.current&&t.current.querySelectorAll('[data-type="variable"][data-node-type="report-url"]').forEach(v=>{const g=v.dataset.key;if(!g)return;v.innerText.replace(/[\u200B\n]/g,"").trim()||n(_=>{const w=_[g];return!w||w.status==="idle"&&(!w.modules||w.modules.length===0)?_:{..._,[g]:{status:"idle",modules:[],lastParsedUrl:void 0,error:void 0}}})}),t.current&&t.current.querySelectorAll('[data-type="variable"][data-node-type="markdown"]').forEach(v=>{const g=v.dataset.key;if(!g)return;v.innerText.replace(/[\u200B\n]/g,"").trim()||r(_=>{const w=_[g];return!w||w.status==="idle"&&(!w.modules||w.modules.length===0)?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}})}),t.current&&t.current.querySelectorAll('[data-type="variable"][data-node-type="markdown-name"]').forEach(v=>{const g=v.dataset.key;if(!g)return;v.innerText.replace(/[\u200B\n]/g,"").trim()||i(_=>{const w=_[g];return!w||w.status==="idle"&&(!w.modules||w.modules.length===0)?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}})}),t.current&&t.current.querySelectorAll('[data-type="richtext"][data-node-type="markdown-module"]').forEach(v=>{const g=v.dataset.key;if(!g)return;const E=v.innerText.replace(/[\u200B\n]/g,"").trim();v.getAttribute("data-is-placeholder")==="true"&&E&&!E.startsWith("请补充:")&&v.removeAttribute("data-is-placeholder"),E||(r(_=>{const w=_[g];return!w||w.status==="idle"?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}}),i(_=>{const w=_[g];return!w||w.status==="idle"?_:{..._,[g]:{status:"idle",modules:[],lastParsedText:void 0,error:void 0}}}))}),t.current&&t.current.querySelectorAll('[data-type="variable"]').forEach(v=>{if(v.dataset.variableRender==="antd-textarea")return;const g=v.innerText||"",E=!!v.querySelector("br")||g.includes(`
|
|
37
37
|
`),_=v.offsetHeight>32,C=g.replace(/\u200B/g,"").trim().length>0&&(E||_);v.classList.toggle("rte-variable-multiline",C),v.classList.toggle("rte-variable-force-block",C);const M=v.closest(".rte-inline-group");M&&M.classList.toggle("rte-inline-group-force-block",C);const S=v.closest(".required-upload-group, .required-multi-first");S&&S.classList.toggle("rte-required-group-force-block",C);const T=v.querySelector(".variable-info-icon");if(T){let A=!1;const k=document.createTreeWalker(v,NodeFilter.SHOW_TEXT,{acceptNode:D=>T.contains(D)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});for(;k.nextNode();)if(k.currentNode.textContent?.replace(/[\u200B\n]/g,"").trim()){A=!0;break}A?T.classList.add("hidden"):T.classList.remove("hidden"),v.classList.toggle("rte-variable-with-icon",!T.classList.contains("hidden"))}}),u||window.requestAnimationFrame(()=>{s()}),Ol(t,o,c,y),Dl(t,o,c,l,y),!t.current)return;e.filter(b=>b.type==="multi-variable"&&b.key).forEach(b=>{if(!b.key)return;const v=b.maxCount||9,g=d[b.key]||1,E=[];for(let S=0;S<g;S++){const T=`${b.key}_${S}`,A=t.current.querySelector(`[data-type="variable"][data-key="${T}"][data-multi-key="${b.key}"]`);if(A){const k=(A.innerText||"").replace(/\u200B/g,"").replace(/\r\n/g,`
|
|
38
38
|
`).trim();E.push(k)}}const w=(E[E.length-1]||"")==="";let C=!1,M=-1;for(let S=0;S<E.length-1;S++)if(E[S]===""){C=!0,M=S;break}if(C&&M>=0){const S=window.getSelection();if(S&&S.rangeCount>0){const P=S.getRangeAt(0),N=P.startContainer,x=N.nodeType===Node.ELEMENT_NODE?N.closest('[data-type="variable"][data-multi-key]'):N.parentElement?.closest('[data-type="variable"][data-multi-key]');if(x){const F=x.dataset.key;if(F){const U=document.createRange();U.setStartBefore(x),U.setEnd(P.startContainer,P.startOffset);const $=U.toString().length;p.current={key:F,offset:$}}}}const T=[...E];for(let P=M;P<T.length-1;P++)T[P]=T[P+1];T.pop();const A={};T.forEach((P,N)=>{P&&(A[`${b.key}_${N}`]=P)});const k=Math.max(w?T.length:T.length+1,1);t.current.querySelectorAll('[data-type="variable"]').forEach(P=>{const N=P.dataset.key,x=P.dataset.multiKey;if(N&&x!==b.key){const F=(P.innerText||"").replace(/\u200B/g,"").replace(/\r\n/g,`
|
|
39
39
|
`).trim();F&&(A[N]=F)}}),t.current.__tempVariableValues=A,m(P=>({...P,[b.key]:k}));return}if(!w){const S=g-1,T=`${b.key}_${S}`,A=t.current.querySelector(`[data-type="variable"][data-key="${T}"][data-multi-key="${b.key}"]`);if(A&&(A.innerText||"").replace(/\u200B/g,"").replace(/\r\n/g,`
|