hxy-editor 0.4.20 → 0.4.21
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/pd-editor.js +19 -9
- package/dist/pd-editor.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/pd-editor.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`@keyframes univer-spin{to{transform:rotate(360deg)}}@media (width>=640px){.sm\\:\\!univer-flex-row{flex-direction:row!important}.sm\\:\\!univer-justify-end{justify-content:flex-end!important}.sm\\:\\!univer-space-x-2>:not([hidden])~:not([hidden]){--univer-tw-space-x-reverse:0!important;margin-right:0!important;margin-right:calc(.5rem * var(--univer-tw-space-x-reverse))!important;margin-left:calc(.5rem * (1 - var(--univer-tw-space-x-reverse)))!important;margin-left:.5rem!important;margin-left:calc(.5rem * calc(1 - var(--univer-tw-space-x-reverse)))!important}.sm\\:\\!univer-rounded-lg{border-radius:.5rem!important}.sm\\:\\!univer-text-left{text-align:left!important}}@media (width>=768px){.md\\:univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@keyframes popup-slide-up-in{0%{transform-origin:0 0;opacity:0;transform:scaleY(0)}to{transform-origin:0 0;opacity:1;transform:scaleY(1)}}@keyframes popup-slide-up-out{0%{transform-origin:0 0;opacity:1;transform:scaleY(1)}to{transform-origin:0 0;opacity:0;transform:scaleY(0)}}@keyframes enter{0%{opacity:1;opacity:var(--univer-tw-enter-opacity,1);transform:translateZ(0)scaleZ(1)rotate(0);transform:translate3d(var(--univer-tw-enter-translate-x,0),var(--univer-tw-enter-translate-y,0),0) scale3d(var(--univer-tw-enter-scale,1),var(--univer-tw-enter-scale,1),var(--univer-tw-enter-scale,1)) rotate(var(--univer-tw-enter-rotate,0))}}@keyframes exit{to{opacity:1;opacity:var(--univer-tw-exit-opacity,1);transform:translateZ(0)scaleZ(1)rotate(0);transform:translate3d(var(--univer-tw-exit-translate-x,0),var(--univer-tw-exit-translate-y,0),0) scale3d(var(--univer-tw-exit-scale,1),var(--univer-tw-exit-scale,1),var(--univer-tw-exit-scale,1)) rotate(var(--univer-tw-exit-rotate,0))}}.focus\\:univer-ring-2:focus,.focus-visible\\:univer-ring-2:focus-visible{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}@media (width>=640px){.sm\\:\\!univer-block{display:block!important}}.univer-w-\\[328px\\]{width:328px}.univer-flex-\\[0_0_auto\\]{flex:none}.doc-shell[data-v-ca38b9dd]{letter-spacing:normal;flex-direction:column;height:760px;font-size:14px;line-height:normal;display:flex}.doc-layout[data-v-ca38b9dd]{flex:1;min-height:0;display:flex}.doc-canvas[data-v-ca38b9dd]{background:#f7f8fa;flex:1;min-width:0;position:relative}.readonly-badge[data-v-ca38b9dd]{z-index:30;color:#8c8c8c;pointer-events:none;background:#ffffffeb;border:1px solid #e0e0e0;border-radius:999px;padding:3px 10px;font-size:12px;position:absolute;top:10px;right:14px;box-shadow:0 1px 4px #0000000f}.attachment-insert-btn[data-v-ca38b9dd]{z-index:30;color:#3370ff;cursor:pointer;background:#ffffffeb;border:1px solid #e0e0e0;border-radius:999px;height:30px;padding:0 12px;font-size:12px;transition:border-color .15s,background .15s;position:absolute;top:10px;right:14px;box-shadow:0 1px 4px #0000000f}.attachment-insert-btn[data-v-ca38b9dd]:hover:not(:disabled){background:#fff;border-color:#3370ff}.attachment-insert-btn[data-v-ca38b9dd]:disabled{color:#8c8c8c;cursor:not-allowed}.pagebreak-insert-btn[data-v-ca38b9dd]{z-index:30;color:#3370ff;cursor:pointer;background:#ffffffeb;border:1px solid #e0e0e0;border-radius:999px;height:30px;padding:0 12px;font-size:12px;transition:border-color .15s,background .15s;position:absolute;top:10px;right:118px;box-shadow:0 1px 4px #0000000f}.pagebreak-insert-btn[data-v-ca38b9dd]:hover{background:#fff;border-color:#3370ff}.attachment-file-input[data-v-ca38b9dd]{display:none}.attachment-error-tip[data-v-ca38b9dd]{z-index:30;color:#fff;pointer-events:none;background:#e5484df2;border-radius:6px;max-width:80%;padding:6px 14px;font-size:12px;position:absolute;bottom:16px;left:50%;transform:translate(-50%);box-shadow:0 4px 12px #0000002e}.doc-editor[data-v-ca38b9dd]{contain:layout style;letter-spacing:normal;font-size:14px;line-height:normal;position:absolute;inset:0;overflow:hidden}.link-dialog-mask[data-v-ca38b9dd]{z-index:30;background:#00000047;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.link-dialog[data-v-ca38b9dd]{background:#fff;border-radius:12px;width:400px;max-width:calc(100% - 48px);padding:22px 24px 18px;box-shadow:0 12px 40px #00000029}.link-dialog-title[data-v-ca38b9dd]{color:#1a1a1a;margin-bottom:18px;font-size:16px;font-weight:600}.link-dialog-field[data-v-ca38b9dd]{margin-bottom:14px}.field-label[data-v-ca38b9dd]{color:#595959;margin-bottom:6px;font-size:13px;font-weight:500;display:block}.field-input[data-v-ca38b9dd]{color:#333;background:#fafafa;border:1px solid #e0e0e0;border-radius:6px;outline:none;width:100%;height:34px;padding:0 10px;font-size:13px;transition:border-color .15s,box-shadow .15s}.field-input[data-v-ca38b9dd]:focus{background:#fff;border-color:#25b864;box-shadow:0 0 0 2px #25b8641f}.field-input.error[data-v-ca38b9dd]{border-color:#e5484d}.field-error[data-v-ca38b9dd]{color:#e5484d;margin-top:4px;font-size:12px}.link-dialog-tip[data-v-ca38b9dd]{color:#bfbfbf;margin-bottom:16px;font-size:12px}.link-dialog-actions[data-v-ca38b9dd]{justify-content:flex-end;gap:10px;display:flex}.dialog-btn[data-v-ca38b9dd]{cursor:pointer;border:none;border-radius:6px;height:32px;padding:0 18px;font-size:13px;transition:all .15s}.dialog-btn.cancel[data-v-ca38b9dd]{color:#595959;background:#f5f5f5}.dialog-btn.cancel[data-v-ca38b9dd]:hover{background:#ececec}.dialog-btn.confirm[data-v-ca38b9dd]{color:#fff;background:#25b864;font-weight:500}.dialog-btn.confirm[data-v-ca38b9dd]:hover:not(:disabled){background:#1fa257}.dialog-btn.confirm[data-v-ca38b9dd]:disabled{cursor:not-allowed;background:#bfe6d2}.doc-statusbar[data-v-ca38b9dd]{color:#8c8c8c;background:#fafbfc;border-top:1px solid #f0f0f0;align-items:center;gap:8px;padding:8px 20px;font-size:12px;display:flex}.status-count[data-v-ca38b9dd]{color:#595959;font-weight:500}.status-flex[data-v-ca38b9dd]{flex:1}.status-tip[data-v-ca38b9dd]{color:#bfbfbf}.link-hover-bar[data-v-ca38b9dd]{z-index:1080;white-space:nowrap;-webkit-user-select:none;user-select:none;background:#fff;border:1px solid #e8e8e8;border-radius:6px;align-items:center;gap:2px;padding:4px 8px;display:flex;position:fixed;transform:translate(-50%)translateY(-100%);box-shadow:0 4px 16px #0000001f}.hover-label[data-v-ca38b9dd]{color:#3370ff;cursor:pointer;padding:0 6px;font-size:13px;font-weight:500}.hover-label[data-v-ca38b9dd]:hover{text-decoration:underline}.hover-icon-btn[data-v-ca38b9dd]{color:#595959;cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;width:28px;height:28px;padding:0;transition:background .12s,color .12s;display:inline-flex;position:relative}.hover-icon-btn[data-v-ca38b9dd]:hover{color:#1d2129;background:#f2f3f5}.hover-icon-tip[data-v-ca38b9dd]{color:#3370ff;white-space:nowrap;pointer-events:none;font-size:10px;position:absolute;bottom:-18px;left:50%;transform:translate(-50%)}.hover-unlink-btn[data-v-ca38b9dd]:hover{color:#e5484d;background:#e5484d14}.hover-sep[data-v-ca38b9dd]{background:#ececec;flex-shrink:0;width:1px;height:16px;margin:0 4px}.hover-bar-arrow[data-v-ca38b9dd]{background:#fff;border-bottom:1px solid #e8e8e8;border-right:1px solid #e8e8e8;width:8px;height:8px;position:absolute;bottom:-5px;left:50%;transform:translate(-50%)rotate(45deg)}.hover-style[data-v-ca38b9dd]{position:relative}.hover-style-menu[data-v-ca38b9dd]{text-align:left;background:#fff;border:1px solid #e8e8e8;border-radius:6px;min-width:140px;padding:4px;position:absolute;top:calc(100% + 8px);left:50%;transform:translate(-50%);box-shadow:0 4px 16px #0000001f}.hover-style-item[data-v-ca38b9dd]{cursor:pointer;color:#595959;border-radius:4px;align-items:center;gap:6px;padding:6px 10px;font-size:13px;display:flex}.hover-style-item[data-v-ca38b9dd]:hover{background:#f7f8fa}.hover-style-item.active[data-v-ca38b9dd]{color:#3370ff}.style-check[data-v-ca38b9dd]{color:#3370ff;text-align:center;flex-shrink:0;width:16px;font-size:12px}.style-name[data-v-ca38b9dd]{font-size:13px}[data-u-comp=rect-popup]:has(.univer-max-w-80){visibility:hidden;pointer-events:none}*,:before,:after,::backdrop{--univer-tw-border-spacing-x:0;--univer-tw-border-spacing-y:0;--univer-tw-translate-x:0;--univer-tw-translate-y:0;--univer-tw-rotate:0;--univer-tw-skew-x:0;--univer-tw-skew-y:0;--univer-tw-scale-x:1;--univer-tw-scale-y:1;--univer-tw-pan-x: ;--univer-tw-pan-y: ;--univer-tw-pinch-zoom: ;--univer-tw-scroll-snap-strictness:proximity;--univer-tw-gradient-from-position: ;--univer-tw-gradient-via-position: ;--univer-tw-gradient-to-position: ;--univer-tw-ordinal: ;--univer-tw-slashed-zero: ;--univer-tw-numeric-figure: ;--univer-tw-numeric-spacing: ;--univer-tw-numeric-fraction: ;--univer-tw-ring-inset: ;--univer-tw-ring-offset-width:0px;--univer-tw-ring-offset-color:#fff;--univer-tw-ring-color:#93c5fd80;--univer-tw-ring-offset-shadow:0 0 #0000;--univer-tw-ring-shadow:0 0 #0000;--univer-tw-shadow:0 0 #0000;--univer-tw-shadow-colored:0 0 #0000;--univer-tw-blur: ;--univer-tw-brightness: ;--univer-tw-contrast: ;--univer-tw-grayscale: ;--univer-tw-hue-rotate: ;--univer-tw-invert: ;--univer-tw-saturate: ;--univer-tw-sepia: ;--univer-tw-drop-shadow: ;--univer-tw-backdrop-blur: ;--univer-tw-backdrop-brightness: ;--univer-tw-backdrop-contrast: ;--univer-tw-backdrop-grayscale: ;--univer-tw-backdrop-hue-rotate: ;--univer-tw-backdrop-invert: ;--univer-tw-backdrop-opacity: ;--univer-tw-backdrop-saturate: ;--univer-tw-backdrop-sepia: ;--univer-tw-contain-size: ;--univer-tw-contain-layout: ;--univer-tw-contain-paint: ;--univer-tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}.univer-sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.univer-inset-x-0{left:0;right:0}.univer-bottom-0\\.5{bottom:.125rem}.univer-bottom-6{bottom:1.5rem}.univer-left-0\\.5{left:.125rem}.univer-left-2{left:.5rem}.univer-left-\\[-16px\\]{left:-16px}.univer-right-4{right:1rem}.univer-right-px{right:1px}.univer-top-px{top:1px}.univer-z-0{z-index:0}.univer-z-\\[1081\\]{z-index:1081}.-univer-mx-1{margin-left:-.25rem;margin-right:-.25rem}.univer-ml-auto{margin-left:auto}.\\!univer-hidden{display:none!important}.univer-size-2{width:.5rem;height:.5rem}.univer-size-2\\.5{width:.625rem;height:.625rem}.univer-h-1\\/2{height:50%}.univer-h-12{height:3rem}.univer-h-2{height:.5rem}.univer-h-32{height:8rem}.univer-h-48{height:12rem}.univer-h-\\[150px\\]{height:150px}.univer-h-\\[calc\\(100\\%-2px\\)\\]{height:calc(100% - 2px)}.univer-max-h-0{max-height:0}.univer-max-h-80{max-height:20rem}.univer-max-h-\\[--radix-popper-available-height\\]{max-height:var(--radix-popper-available-height)}.univer-max-h-\\[1000px\\]{max-height:1000px}.univer-max-h-\\[40vh\\]{max-height:40vh}.univer-max-h-full{max-height:100%}.univer-max-h-screen{max-height:100vh}.univer-min-h-3\\.5{min-height:.875rem}.univer-min-h-\\[520px\\]{min-height:520px}.\\!univer-w-fit{width:fit-content!important}.univer-w-64{width:16rem}.univer-w-72{width:18rem}.univer-w-80{width:20rem}.univer-w-\\[calc\\(100\\%-16px\\)\\]{width:calc(100% - 16px)}.univer-min-w-36{min-width:9rem}.univer-min-w-\\[320px\\]{min-width:320px}.univer-max-w-2xl{max-width:42rem}.univer-max-w-\\[520px\\]{max-width:520px}.univer-max-w-\\[60vw\\]{max-width:60vw}.univer-max-w-sm{max-width:24rem}.univer-max-w-xs{max-width:20rem}.univer-shrink{flex-shrink:1}.univer-shrink-0{flex-shrink:0}.univer-origin-\\[--radix-hover-card-content-transform-origin\\]{transform-origin:var(--radix-hover-card-content-transform-origin)}.-univer-translate-y-1\\/2,.univer--translate-y-1\\/2{--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-translate-x-3{--univer-tw-translate-x:.75rem;transform:translate(.75rem,var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.-univer-rotate-90{--univer-tw-rotate:-90deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(-90deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-rotate-0{--univer-tw-rotate:0deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(0) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-rotate-45{--univer-tw-rotate:45deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(45deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-rotate-\\[-90deg\\]{--univer-tw-rotate:-90deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(-90deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.\\!univer-animate-none{animation:none!important}.univer-cursor-crosshair{cursor:crosshair}.univer-cursor-grabbing{cursor:grabbing}.univer-resize{resize:both}.univer-grid-flow-row{grid-auto-flow:row}.univer-grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.univer-flex-col-reverse{flex-direction:column-reverse}.univer-content-center{align-content:center}.univer-gap-5{gap:1.25rem}.univer-space-y-1\\.5>:not([hidden])~:not([hidden]){--univer-tw-space-y-reverse:0;margin-top:calc(.375rem * (1 - var(--univer-tw-space-y-reverse)));margin-top:.375rem;margin-top:calc(.375rem * calc(1 - var(--univer-tw-space-y-reverse)));margin-bottom:0;margin-bottom:calc(.375rem * var(--univer-tw-space-y-reverse))}.univer-divide-x>:not([hidden])~:not([hidden]){--univer-tw-divide-x-reverse:0;border-right-width:0;border-right-width:calc(1px * var(--univer-tw-divide-x-reverse));border-left-width:calc(1px * (1 - var(--univer-tw-divide-x-reverse)));border-left-width:1px;border-left-width:calc(1px * calc(1 - var(--univer-tw-divide-x-reverse)))}.univer-divide-y-0>:not([hidden])~:not([hidden]){--univer-tw-divide-y-reverse:0;border-top-width:calc(0px * (1 - var(--univer-tw-divide-y-reverse)));border-top-width:0;border-top-width:calc(0px * calc(1 - var(--univer-tw-divide-y-reverse)));border-bottom-width:0;border-bottom-width:calc(0px * var(--univer-tw-divide-y-reverse))}.univer-text-ellipsis{text-overflow:ellipsis}.univer-text-balance{text-wrap:balance}.\\!univer-rounded-b-none{border-bottom-right-radius:0!important;border-bottom-left-radius:0!important}.\\!univer-rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.\\!univer-rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.\\!univer-rounded-t-none{border-top-left-radius:0!important;border-top-right-radius:0!important}.univer-rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.\\!univer-border-l-0{border-left-width:0!important}.\\!univer-border-t-0{border-top-width:0!important}.univer-border-b-0{border-bottom-width:0}.univer-border-l{border-left-width:1px}.univer-border-l-0{border-left-width:0}.univer-border-r{border-right-width:1px}.univer-border-t-0{border-top-width:0}.univer-border-dashed{border-style:dashed}.\\!univer-border-gray-200{border-color:var(--univer-gray-200)!important}.univer-border-gray-300{border-color:var(--univer-gray-300)}.univer-border-primary-200{border-color:var(--univer-primary-200)}.univer-border-primary-300{border-color:var(--univer-primary-300)}.univer-border-red-300{border-color:var(--univer-red-300)}.univer-border-red-500{border-color:var(--univer-red-500)}.univer-border-white{border-color:var(--univer-white)}.\\!univer-bg-primary-600{background-color:var(--univer-primary-600)!important}.univer-bg-\\[rgba\\(0\\,0\\,0\\,0\\.8\\)\\]{background-color:#000c}.univer-bg-gray-800{background-color:var(--univer-gray-800)}.univer-bg-gray-900{background-color:var(--univer-gray-900)}.univer-bg-primary-500{background-color:var(--univer-primary-500)}.univer-bg-red-500{background-color:var(--univer-red-500)}.univer-bg-sky-100\\/70{background-color:#e0f2feb3}.univer-bg-slate-100\\/80{background-color:#f1f5f9cc}.univer-bg-slate-900\\/90{background-color:#0f172ae6}.univer-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--univer-tw-gradient-stops))}.univer-from-slate-100{--univer-tw-gradient-from:#f1f5f9 var(--univer-tw-gradient-from-position);--univer-tw-gradient-to:#f1f5f900 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)}.univer-via-cyan-50{--univer-tw-gradient-to:#ecfeff00 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), #ecfeff var(--univer-tw-gradient-via-position), var(--univer-tw-gradient-to)}.univer-to-blue-100{--univer-tw-gradient-to:var(--univer-blue-100) var(--univer-tw-gradient-to-position)}.univer-fill-current{fill:currentColor}.\\!univer-p-2\\.5{padding:.625rem!important}.univer-p-6{padding:1.5rem}.\\!univer-pl-4{padding-left:1rem!important}.univer-pb-2\\.5{padding-bottom:.625rem}.univer-pl-8{padding-left:2rem}.univer-pr-32{padding-right:8rem}.univer-pr-8{padding-right:2rem}.univer-pt-4{padding-top:1rem}.univer-align-middle{vertical-align:middle}.univer-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.univer-text-\\[13px\\]{font-size:13px}.univer-text-\\[8px\\]{font-size:8px}.univer-text-sm\\/8{font-size:.875rem;line-height:2rem}.univer-text-xs\\/6{font-size:.75rem;line-height:1.5rem}.univer-leading-9{line-height:2.25rem}.univer-leading-normal{line-height:1.5}.univer-tracking-wide{letter-spacing:.025em}.univer-tracking-widest{letter-spacing:.1em}.\\!univer-text-primary-500{color:var(--univer-primary-500)!important}.univer-text-amber-500{--univer-tw-text-opacity:1;color:rgba(245,158,11,var(--univer-tw-text-opacity,1))}.univer-text-cyan-700{--univer-tw-text-opacity:1;color:rgba(14,116,144,var(--univer-tw-text-opacity,1))}.univer-text-sky-500{--univer-tw-text-opacity:1;color:rgba(14,165,233,var(--univer-tw-text-opacity,1))}.univer-text-sky-700{--univer-tw-text-opacity:1;color:rgba(3,105,161,var(--univer-tw-text-opacity,1))}.univer-text-sky-900{--univer-tw-text-opacity:1;color:rgba(12,74,110,var(--univer-tw-text-opacity,1))}.univer-text-slate-500{--univer-tw-text-opacity:1;color:rgba(100,116,139,var(--univer-tw-text-opacity,1))}.univer-text-slate-600{--univer-tw-text-opacity:1;color:rgba(71,85,105,var(--univer-tw-text-opacity,1))}.univer-text-slate-700{--univer-tw-text-opacity:1;color:rgba(51,65,85,var(--univer-tw-text-opacity,1))}.univer-text-slate-800{--univer-tw-text-opacity:1;color:rgba(30,41,59,var(--univer-tw-text-opacity,1))}.univer-text-violet-500{--univer-tw-text-opacity:1;color:rgba(139,92,246,var(--univer-tw-text-opacity,1))}.univer-underline-offset-4{text-underline-offset:4px}.univer-opacity-100{opacity:1}.univer-opacity-50{opacity:.5}.univer-opacity-80{opacity:.8}.univer-shadow-\\[0_30px_60px_-35px_rgba\\(15\\,23\\,42\\,0\\.55\\)\\]{--univer-tw-shadow:0 30px 60px -35px #0f172a8c;--univer-tw-shadow-colored:0 30px 60px -35px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 30px 60px -35px #0f172a8c;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-shadow-inner{--univer-tw-shadow:inset 0 2px 4px 0 #0000000d;--univer-tw-shadow-colored:inset 0 2px 4px 0 var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,inset 0 2px 4px #0000000d;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-ring-2{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.\\!univer-ring-primary-900{--univer-tw-ring-color:var(--univer-primary-900)!important}.univer-ring-primary-50{--univer-tw-ring-color:var(--univer-primary-50)}.univer-ring-white{--univer-tw-ring-color:var(--univer-white)}.univer-ring-offset-2{--univer-tw-ring-offset-width:2px}.\\!univer-ring-offset-gray-600{--univer-tw-ring-offset-color:var(--univer-gray-600)!important}.univer-ring-offset-white{--univer-tw-ring-offset-color:var(--univer-white)}.univer-drop-shadow-sm{--univer-tw-drop-shadow:drop-shadow(0 1px 1px #0000000d);filter:var(--univer-tw-blur) var(--univer-tw-brightness) var(--univer-tw-contrast) var(--univer-tw-grayscale) var(--univer-tw-hue-rotate) var(--univer-tw-invert) var(--univer-tw-saturate) var(--univer-tw-sepia) var(--univer-tw-drop-shadow)}.univer-transition-\\[color\\,box-shadow\\]{transition-property:color,box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-\\[max-height\\,opacity\\]{transition-property:max-height,opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-opacity{transition-property:opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-duration-150{transition-duration:.15s}.univer-duration-500{transition-duration:.5s}.univer-duration-75{transition-duration:75ms}.univer-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.univer-will-change-transform{will-change:transform}.univer-scrollbar-thin::-webkit-scrollbar-track{background-color:var(--scrollbar-track);border-radius:var(--scrollbar-track-radius)}.univer-scrollbar-thin::-webkit-scrollbar-track:hover{background-color:var(--scrollbar-track-hover,var(--scrollbar-track))}.univer-scrollbar-thin::-webkit-scrollbar-track:active{background-color:var(--scrollbar-track-active,var(--scrollbar-track-hover,var(--scrollbar-track)))}.univer-scrollbar-thin::-webkit-scrollbar-thumb{background-color:var(--scrollbar-thumb);border-radius:var(--scrollbar-thumb-radius)}.univer-scrollbar-thin::-webkit-scrollbar-thumb:hover{background-color:var(--scrollbar-thumb-hover,var(--scrollbar-thumb))}.univer-scrollbar-thin::-webkit-scrollbar-thumb:active{background-color:var(--scrollbar-thumb-active,var(--scrollbar-thumb-hover,var(--scrollbar-thumb)))}.univer-scrollbar-thin::-webkit-scrollbar-corner{background-color:var(--scrollbar-corner);border-radius:var(--scrollbar-corner-radius)}.univer-scrollbar-thin::-webkit-scrollbar-corner:hover{background-color:var(--scrollbar-corner-hover,var(--scrollbar-corner))}.univer-scrollbar-thin::-webkit-scrollbar-corner:active{background-color:var(--scrollbar-corner-active,var(--scrollbar-corner-hover,var(--scrollbar-corner)))}.univer-scrollbar-thin{scrollbar-width:thin;scrollbar-color:initial initial;scrollbar-color:var(--scrollbar-thumb,initial) var(--scrollbar-track,initial)}.univer-scrollbar-thin::-webkit-scrollbar{width:8px;height:8px;display:block}.univer-scrollbar-track-gray-50{--scrollbar-track:var(--univer-gray-50)!important}.univer-scrollbar-thumb-gray-300{--scrollbar-thumb:var(--univer-gray-300)!important}.univer-animate-out{--univer-tw-exit-opacity:initial;--univer-tw-exit-scale:initial;--univer-tw-exit-rotate:initial;--univer-tw-exit-translate-x:initial;--univer-tw-exit-translate-y:initial;animation-name:exit;animation-duration:.15s}.univer-fade-in,.univer-fade-in-0{--univer-tw-enter-opacity:0}.univer-fade-out{--univer-tw-exit-opacity:0}.univer-zoom-in-95{--univer-tw-enter-scale:.95}.univer-duration-150{animation-duration:.15s}.univer-duration-200{animation-duration:.2s}.univer-duration-300{animation-duration:.3s}.univer-duration-500{animation-duration:.5s}.univer-duration-75{animation-duration:75ms}.univer-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.univer-ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.placeholder\\:univer-text-gray-200::placeholder{color:var(--univer-gray-200)}.placeholder\\:univer-text-gray-400::placeholder{color:var(--univer-gray-400)}.before\\:univer-absolute:before{content:var(--univer-tw-content);position:absolute}.before\\:univer-top-1\\/2:before{content:var(--univer-tw-content);top:50%}.before\\:univer-block:before{content:var(--univer-tw-content);display:block}.before\\:univer-h-px:before{content:var(--univer-tw-content);height:1px}.before\\:univer-w-full:before{content:var(--univer-tw-content);width:100%}.before\\:-univer-translate-y-1\\/2:before{content:var(--univer-tw-content);--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.before\\:univer-bg-gray-200:before{content:var(--univer-tw-content);background-color:var(--univer-gray-200)}.before\\:univer-content-\\[\\"\\"\\]:before{--univer-tw-content:"";content:"";content:var(--univer-tw-content)}.data-\\[disabled\\]\\:univer-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[orientation\\=horizontal\\]\\:univer-h-px[data-orientation=horizontal]{height:1px}.data-\\[orientation\\=vertical\\]\\:univer-h-full[data-orientation=vertical]{height:100%}.data-\\[orientation\\=horizontal\\]\\:univer-w-full[data-orientation=horizontal]{width:100%}.data-\\[orientation\\=vertical\\]\\:univer-w-px[data-orientation=vertical]{width:1px}.data-\\[state\\=open\\]\\:univer-bg-gray-100[data-state=open]{background-color:var(--univer-gray-100)}.data-\\[disabled\\]\\:univer-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=open\\]\\:univer-animate-in[data-state=open]{--univer-tw-enter-opacity:initial;--univer-tw-enter-scale:initial;--univer-tw-enter-rotate:initial;--univer-tw-enter-translate-x:initial;--univer-tw-enter-translate-y:initial;animation-name:enter;animation-duration:.15s}.data-\\[state\\=closed\\]\\:univer-animate-out[data-state=closed]{--univer-tw-exit-opacity:initial;--univer-tw-exit-scale:initial;--univer-tw-exit-rotate:initial;--univer-tw-exit-translate-x:initial;--univer-tw-exit-translate-y:initial;animation-name:exit;animation-duration:.15s}.data-\\[state\\=closed\\]\\:univer-fade-out-0[data-state=closed]{--univer-tw-exit-opacity:0}.data-\\[state\\=open\\]\\:univer-fade-in-0[data-state=open]{--univer-tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:univer-zoom-out-95[data-state=closed]{--univer-tw-exit-scale:.95}.data-\\[state\\=open\\]\\:univer-zoom-in-95[data-state=open]{--univer-tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:univer-slide-in-from-top-2[data-side=bottom]{--univer-tw-enter-translate-y:-.5rem}.data-\\[side\\=left\\]\\:univer-slide-in-from-right-2[data-side=left]{--univer-tw-enter-translate-x:.5rem}.data-\\[side\\=right\\]\\:univer-slide-in-from-left-2[data-side=right]{--univer-tw-enter-translate-x:-.5rem}.data-\\[side\\=top\\]\\:univer-slide-in-from-bottom-2[data-side=top]{--univer-tw-enter-translate-y:.5rem}.data-\\[state\\=closed\\]\\:univer-slide-out-to-left-1\\/2[data-state=closed]{--univer-tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:univer-slide-out-to-top-\\[48\\%\\][data-state=closed]{--univer-tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:univer-slide-in-from-left-1\\/2[data-state=open]{--univer-tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:univer-slide-in-from-top-\\[48\\%\\][data-state=open]{--univer-tw-enter-translate-y:-48%}.hover\\:univer-border-red-400:hover{border-color:var(--univer-red-400)}.hover\\:univer-border-transparent:hover{border-color:#0000}.hover\\:univer-bg-primary-500:hover{background-color:var(--univer-primary-500)}.hover\\:univer-bg-red-400:hover{background-color:var(--univer-red-400)}.hover\\:univer-text-gray-500:hover{color:var(--univer-gray-500)}.hover\\:univer-text-primary-500:hover{color:var(--univer-primary-500)}.hover\\:univer-text-white:hover{color:var(--univer-white)}.hover\\:univer-underline:hover{text-decoration-line:underline}.hover\\:univer-opacity-100:hover{opacity:1}.hover\\:univer-opacity-70:hover{opacity:.7}.hover\\:univer-opacity-80:hover{opacity:.8}.focus\\:univer-border-primary-600:focus{border-color:var(--univer-primary-600)}.focus\\:univer-bg-gray-100:focus{background-color:var(--univer-gray-100)}.focus\\:univer-ring-primary-50:focus{--univer-tw-ring-color:var(--univer-primary-50)}.active\\:univer-border-red-600:active{border-color:var(--univer-red-600)}.active\\:univer-bg-primary-700:active{background-color:var(--univer-primary-700)}.active\\:univer-bg-red-600:active{background-color:var(--univer-red-600)}.active\\:univer-text-primary-700:active{color:var(--univer-primary-700)}.disabled\\:univer-pointer-events-none:disabled{pointer-events:none}.disabled\\:univer-opacity-50:disabled{opacity:.5}@media (width>=640px){.sm\\:\\!univer-flex-row{flex-direction:row!important}.sm\\:\\!univer-justify-end{justify-content:flex-end!important}.sm\\:\\!univer-space-x-2>:not([hidden])~:not([hidden]){--univer-tw-space-x-reverse:0!important;margin-right:0!important;margin-right:calc(.5rem * var(--univer-tw-space-x-reverse))!important;margin-left:calc(.5rem * (1 - var(--univer-tw-space-x-reverse)))!important;margin-left:.5rem!important;margin-left:calc(.5rem * calc(1 - var(--univer-tw-space-x-reverse)))!important}.sm\\:\\!univer-rounded-lg{border-radius:.5rem!important}.sm\\:\\!univer-text-left{text-align:left!important}}@media (width>=768px){.md\\:univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.rtl\\:univer-left-px:where([dir=rtl],[dir=rtl] *){left:1px}.rtl\\:univer-right-auto:where([dir=rtl],[dir=rtl] *){right:auto}.rtl\\:univer-rounded-l-md:where([dir=rtl],[dir=rtl] *){border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rtl\\:univer-rounded-r-none:where([dir=rtl],[dir=rtl] *){border-top-right-radius:0;border-bottom-right-radius:0}.rtl\\:univer-border-l-0:where([dir=rtl],[dir=rtl] *){border-left-width:0}.rtl\\:univer-border-r:where([dir=rtl],[dir=rtl] *){border-right-width:1px}.dark\\:\\!univer-border-gray-500:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-500)!important}.dark\\:\\!univer-border-primary-700:where(.univer-dark,.univer-dark *){border-color:var(--univer-primary-700)!important}.dark\\:\\!univer-bg-gray-100:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-100)!important}.dark\\:\\!univer-bg-primary-600:where(.univer-dark,.univer-dark *){background-color:var(--univer-primary-600)!important}.dark\\:\\!univer-text-gray-900:where(.univer-dark,.univer-dark *){color:var(--univer-gray-900)!important}.dark\\:\\!univer-text-primary-500:where(.univer-dark,.univer-dark *){color:var(--univer-primary-500)!important}.dark\\:\\!univer-text-sky-400:where(.univer-dark,.univer-dark *){--univer-tw-text-opacity:1!important;color:rgba(56,189,248,var(--univer-tw-text-opacity,1))!important}.dark\\:\\!univer-ring-primary-600:where(.univer-dark,.univer-dark *){--univer-tw-ring-color:var(--univer-primary-600)!important}.dark\\:\\!univer-ring-primary-900:where(.univer-dark,.univer-dark *){--univer-tw-ring-color:var(--univer-primary-900)!important}.dark\\:\\!univer-ring-offset-gray-600:where(.univer-dark,.univer-dark *){--univer-tw-ring-offset-color:var(--univer-gray-600)!important}.dark\\:\\!univer-scrollbar-track-gray-900:where(.univer-dark,.univer-dark *){--scrollbar-track:var(--univer-gray-900)!important}.dark\\:\\!univer-scrollbar-thumb-gray-700:where(.univer-dark,.univer-dark *){--scrollbar-thumb:var(--univer-gray-700)!important}.dark\\:before\\:\\!univer-bg-gray-600:where(.univer-dark,.univer-dark *):before{content:var(--univer-tw-content);background-color:var(--univer-gray-600)!important}.dark\\:data-\\[state\\=open\\]\\:\\!univer-bg-gray-600[data-state=open]:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:hover\\:\\!univer-text-white:hover:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\\:focus\\:\\!univer-border-primary-500:focus:where(.univer-dark,.univer-dark *){border-color:var(--univer-primary-500)!important}.dark\\:focus\\:\\!univer-bg-gray-600:focus:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:focus\\:\\!univer-ring-primary-900:focus:where(.univer-dark,.univer-dark *){--univer-tw-ring-color:var(--univer-primary-900)!important}.dark\\:focus-visible\\:\\!univer-border-gray-600:focus-visible:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\\:active\\:\\!univer-bg-gray-700:active:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.\\[\\&\\:\\:-webkit-calendar-picker-indicator\\]\\:univer-hidden::-webkit-calendar-picker-indicator{display:none}.\\[\\&\\:\\:-webkit-calendar-picker-indicator\\]\\:univer-appearance-none::-webkit-calendar-picker-indicator{appearance:none}.\\[\\&\\>input\\]\\:univer-w-11>input{width:2.75rem}.\\[\\&\\>input\\]\\:univer-border-gray-200>input{border-color:var(--univer-gray-200)}.\\[\\&\\>input\\]\\:focus\\:univer-border-primary-500:focus>input{border-color:var(--univer-primary-500)}.dark\\:\\[\\&\\>input\\]\\:\\!univer-border-gray-600>input:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\\:\\[\\&\\>input\\]\\:\\!univer-text-white>input:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.\\[\\&\\>svg\\]\\:univer-block>svg{display:block}.\\[\\&\\>svg\\]\\:univer-size-4>svg{width:1rem;height:1rem}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-0>ul:not(:last-child){border-width:0}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-r>ul:not(:last-child){border-right-width:1px}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-solid>ul:not(:last-child){border-style:solid}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-r-gray-200>ul:not(:last-child){border-right-color:var(--univer-gray-200)}.\\[\\&_\\[data-description\\]\\]\\:univer-text-sm [data-description]{font-size:.875rem;line-height:1.25rem}.\\[\\&_\\[data-description\\]\\]\\:univer-text-gray-200 [data-description]{color:var(--univer-gray-200)}.\\[\\&_\\[data-description\\]\\]\\:univer-text-gray-600 [data-description]{color:var(--univer-gray-600)}.\\[\\&_\\[data-icon\\]\\>svg\\]\\:univer-relative [data-icon]>svg{position:relative}.\\[\\&_\\[data-icon\\]\\>svg\\]\\:univer-top-1 [data-icon]>svg{top:.25rem}.\\[\\&_\\[data-icon\\]\\]\\:univer-self-baseline [data-icon]{align-self:baseline}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-amber-500 [data-icon]{--univer-tw-text-opacity:1;color:rgba(245,158,11,var(--univer-tw-text-opacity,1))}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-green-500 [data-icon]{color:var(--univer-green-500)}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-primary-600 [data-icon]{color:var(--univer-primary-600)}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-red-500 [data-icon]{color:var(--univer-red-500)}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-sky-500 [data-icon]{--univer-tw-text-opacity:1;color:rgba(14,165,233,var(--univer-tw-text-opacity,1))}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-violet-500 [data-icon]{--univer-tw-text-opacity:1;color:rgba(139,92,246,var(--univer-tw-text-opacity,1))}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-yellow-500 [data-icon]{color:var(--univer-yellow-500)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-rounded-2xl [data-sonner-toast]{border-radius:1rem}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-border [data-sonner-toast]{border-width:1px}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-border-solid [data-sonner-toast]{border-style:solid}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-border-gray-200 [data-sonner-toast]{border-color:var(--univer-gray-200)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-shadow-\\[0_16px_40px_-20px_rgba\\(15\\,23\\,42\\,0\\.55\\)\\] [data-sonner-toast]{--univer-tw-shadow:0 16px 40px -20px #0f172a8c;--univer-tw-shadow-colored:0 16px 40px -20px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 16px 40px -20px #0f172a8c;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-shadow-md [data-sonner-toast]{--univer-tw-shadow:0px 1px 6px -2px #1e284d14, 0px 2px 6px -1px #1e284d1a;--univer-tw-shadow-colored:0px 1px 6px -2px var(--univer-tw-shadow-color), 0px 2px 6px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-backdrop-blur-sm [data-sonner-toast]{--univer-tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.dark\\:\\[\\&_\\[data-sonner-toast\\]\\]\\:\\!univer-border-gray-600 [data-sonner-toast]:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.\\[\\&_\\[data-title\\]\\]\\:univer-text-sm [data-title]{font-size:.875rem;line-height:1.25rem}.\\[\\&_\\[data-title\\]\\]\\:univer-text-gray-900 [data-title]{color:var(--univer-gray-900)}.\\[\\&_\\[data-u-comp\\=form-layout\\]\\]\\:univer-max-w-\\[calc\\(50\\%-8px\\)\\] [data-u-comp=form-layout]{max-width:calc(50% - 8px)}.\\[\\&_\\[data-u-comp\\=form-layout\\]\\]\\:univer-shrink [data-u-comp=form-layout]{flex-shrink:1}.\\[\\&_\\[data-u-comp\\=form-layout\\]\\]\\:univer-grow [data-u-comp=form-layout]{flex-grow:1}.\\[\\&_\\[data-u-comp\\=input\\]\\]\\:univer-w-full [data-u-comp=input]{width:100%}.\\[\\&_\\[data-u-comp\\=input\\]\\]\\:univer-border-red-500 [data-u-comp=input]{border-color:var(--univer-red-500)}.\\[\\&_\\[data-u-comp\\=pager-left-arrow\\]\\:hover\\]\\:\\!univer-bg-gray-600 [data-u-comp=pager-left-arrow]:hover,.\\[\\&_\\[data-u-comp\\=pager-right-arrow\\]\\:hover\\]\\:\\!univer-bg-gray-600 [data-u-comp=pager-right-arrow]:hover{background-color:var(--univer-gray-600)!important}.\\[\\&_\\[data-u-comp\\=select\\]\\]\\:univer-w-full [data-u-comp=select]{width:100%}.\\[\\&_\\[data-u-comp\\=select\\]\\]\\:univer-border-red-500 [data-u-comp=select]{border-color:var(--univer-red-500)}.\\[\\&_input\\]\\:univer-box-border input{box-sizing:border-box}.\\[\\&_input\\]\\:univer-flex input{display:flex}.\\[\\&_input\\]\\:univer-h-7 input{height:1.75rem}.\\[\\&_input\\]\\:univer-items-center input{align-items:center}.\\[\\&_input\\]\\:univer-rounded input{border-radius:.25rem}.\\[\\&_input\\]\\:univer-border input{border-width:1px}.\\[\\&_input\\]\\:univer-border-solid input{border-style:solid}.\\[\\&_input\\]\\:univer-border-gray-200 input{border-color:var(--univer-gray-200)}.\\[\\&_input\\]\\:univer-border-gray-600 input{border-color:var(--univer-gray-600)}.\\[\\&_input\\]\\:univer-bg-transparent input{background-color:#0000}.\\[\\&_input\\]\\:univer-px-1\\.5 input{padding-left:.375rem;padding-right:.375rem}.\\[\\&_input\\]\\:univer-text-gray-700 input{color:var(--univer-gray-700)}.\\[\\&_input\\]\\:univer-text-white input{color:var(--univer-white)}.\\[\\&_input\\]\\:univer-outline-none input{outline-offset:2px;outline:2px solid #0000}.\\[\\&_svg\\]\\:univer-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:univer-size-4 svg{width:1rem;height:1rem}.\\[\\&_svg\\]\\:univer-shrink-0 svg{flex-shrink:0}.univer-popup{z-index:1070;--univer-tw-shadow:0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;--univer-tw-shadow-colored:0 1px 3px 0 var(--univer-tw-shadow-color), 0 1px 2px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow);border-radius:6px;position:fixed;top:-9999px;left:-9999px;overflow:hidden}.univer-popup-enter{transform-origin:0 0;opacity:0;animation-duration:.15s;animation-timing-function:cubic-bezier(.08,.82,.17,1);animation-play-state:paused;animation-fill-mode:both}.univer-popup-enter-active{animation-name:popup-slide-up-in;animation-play-state:running}.univer-popup-exit{transform-origin:0 0;opacity:1;animation-name:popup-slide-up-out;animation-duration:.15s;animation-timing-function:cubic-bezier(.6,.04,.98,.34);animation-play-state:running;animation-fill-mode:both}.univer-popup-exit-active{display:none}.univer-popup-mask{z-index:1060;position:fixed;inset:0}.univer-pointer-events-auto{pointer-events:auto}.univer-invisible{visibility:hidden}.univer-sticky{position:sticky}.-univer-left-\\[99999\\]{left:-99999px}.-univer-top-\\[99999\\]{top:-99999px}.univer-left-1\\/2{left:50%}.univer-left-\\[-9999px\\]{left:-9999px}.univer-right-2{right:.5rem}.univer-top-\\[-9999px\\]{top:-9999px}.univer-top-\\[calc\\(50\\%-6px\\)\\]{top:calc(50% - 6px)}.univer-z-20{z-index:20}.univer-z-\\[-1\\]{z-index:-1}.univer-z-\\[1020\\]{z-index:1020}.univer-z-\\[1080\\]{z-index:1080}.univer-z-\\[1\\]{z-index:1}.univer-mx-2{margin-left:.5rem;margin-right:.5rem}.univer-mx-auto{margin-left:auto;margin-right:auto}.univer-line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.\\!univer-size-3\\.5{width:.875rem!important;height:.875rem!important}.univer-size-12{width:3rem;height:3rem}.univer-size-3\\.5{width:.875rem;height:.875rem}.univer-size-7{width:1.75rem;height:1.75rem}.univer-size-9{width:2.25rem;height:2.25rem}.univer-h-0{height:0}.univer-h-1\\.5{height:.375rem}.univer-max-h-\\[80vh\\]{max-height:80vh}.univer-max-h-\\[min\\(72vh\\,560px\\)\\]{max-height:min(72vh,560px)}.univer-min-h-\\[560px\\]{min-height:560px}.univer-min-h-\\[56px\\]{min-height:56px}.univer-min-h-full{min-height:100%}.univer-w-0{width:0}.univer-w-1{width:.25rem}.univer-w-10{width:2.5rem}.univer-w-40{width:10rem}.univer-w-7{width:1.75rem}.univer-w-8{width:2rem}.univer-w-96{width:24rem}.univer-w-max{width:max-content}.univer-w-screen{width:100vw}.univer-min-w-52{min-width:13rem}.univer-min-w-6{min-width:1.5rem}.univer-min-w-min{min-width:min-content}.univer-max-w-3xl{max-width:48rem}.univer-max-w-5xl{max-width:64rem}.univer-max-w-96{max-width:24rem}.univer-max-w-\\[--radix-popper-available-width\\]{max-width:var(--radix-popper-available-width)}.univer-max-w-\\[32\\%\\]{max-width:32%}.univer-max-w-\\[560px\\]{max-width:560px}.univer-max-w-\\[calc\\(100vw-16px\\)\\]{max-width:calc(100vw - 16px)}.univer-max-w-full{max-width:100%}.univer-origin-center{transform-origin:50%}.-univer-translate-x-1\\/2{--univer-tw-translate-x:-50%;transform:translate(-50%,var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-translate-x-0{--univer-tw-translate-x:0px;transform:translateY(var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-translate-x-full{--univer-tw-translate-x:100%;transform:translate(100%,var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-cursor-col-resize{cursor:col-resize}.univer-grid-cols-\\[1fr\\]{grid-template-columns:1fr}.univer-grid-cols-\\[22px_minmax\\(0\\,1fr\\)_22px\\]{grid-template-columns:22px minmax(0,1fr) 22px}.univer-grid-cols-\\[28px_minmax\\(0\\,1fr\\)_auto\\]{grid-template-columns:28px minmax(0,1fr) auto}.univer-grid-cols-\\[32px_minmax\\(0\\,1fr\\)_32px\\]{grid-template-columns:32px minmax(0,1fr) 32px}.univer-grid-cols-\\[auto\\,1fr\\]{grid-template-columns:auto 1fr}.univer-grid-cols-\\[auto_1fr_auto\\]{grid-template-columns:auto 1fr auto}.univer-grid-rows-\\[100\\%\\]{grid-template-rows:100%}.univer-grid-rows-\\[auto_1fr\\]{grid-template-rows:auto 1fr}.univer-grid-rows-\\[auto_1fr_auto\\]{grid-template-rows:auto 1fr auto}.univer-flex-wrap{flex-wrap:wrap}.univer-items-end{align-items:flex-end}.univer-gap-0\\.5{gap:.125rem}.univer-overscroll-contain{overscroll-behavior:contain}.univer-scroll-smooth{scroll-behavior:smooth}.\\!univer-rounded-full{border-radius:9999px!important}.\\!univer-rounded-xl{border-radius:.75rem!important}.univer-rounded-2xl{border-radius:1rem}.univer-rounded-3xl{border-radius:1.5rem}.univer-rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.univer-rounded-t-\\[28px\\]{border-top-left-radius:28px;border-top-right-radius:28px}.univer-border-0{border-width:0}.\\!univer-bg-gray-200{background-color:var(--univer-gray-200)!important}.\\!univer-bg-gray-500{background-color:var(--univer-gray-500)!important}.univer-bg-\\[rgba\\(15\\,23\\,42\\,0\\.32\\)\\]{background-color:#0f172a52}.univer-bg-gray-50{background-color:var(--univer-gray-50)}.univer-bg-gray-700{background-color:var(--univer-gray-700)}.univer-bg-gradient-to-tr{background-image:linear-gradient(to top right,var(--univer-tw-gradient-stops))}.univer-from-slate-950{--univer-tw-gradient-from:#020617 var(--univer-tw-gradient-from-position);--univer-tw-gradient-to:#02061700 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)}.univer-via-blue-950{--univer-tw-gradient-to:#17255400 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), #172554 var(--univer-tw-gradient-via-position), var(--univer-tw-gradient-to)}.univer-to-cyan-900{--univer-tw-gradient-to:#164e63 var(--univer-tw-gradient-to-position)}.univer-p-8{padding:2rem}.univer-px-0{padding-left:0;padding-right:0}.univer-px-0\\.5{padding-left:.125rem;padding-right:.125rem}.univer-px-3{padding-left:.75rem;padding-right:.75rem}.univer-pb-2{padding-bottom:.5rem}.univer-pl-2{padding-left:.5rem}.univer-pl-4{padding-left:1rem}.univer-pr-1\\.5{padding-right:.375rem}.univer-text-right{text-align:right}.univer-font-sans{font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.univer-text-2xl{font-size:1.5rem;line-height:2rem}.univer-uppercase{text-transform:uppercase}.univer-leading-4{line-height:1rem}.univer-leading-none{line-height:1}.univer-tracking-\\[0\\.08em\\]{letter-spacing:.08em}.univer-tracking-tight{letter-spacing:-.025em}.\\!univer-text-gray-600{color:var(--univer-gray-600)!important}.univer-text-current{color:currentColor}.univer-text-slate-200{--univer-tw-text-opacity:1;color:rgba(226,232,240,var(--univer-tw-text-opacity,1))}.univer-underline{text-decoration-line:underline}.univer-opacity-0{opacity:0}.univer-opacity-30{opacity:.3}.univer-opacity-40{opacity:.4}.univer-opacity-60{opacity:.6}.univer-shadow-\\[0_-16px_48px_rgba\\(15\\,23\\,42\\,0\\.18\\)\\]{--univer-tw-shadow:0 -16px 48px #0f172a2e;--univer-tw-shadow-colored:0 -16px 48px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 -16px 48px #0f172a2e;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-ring-0{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(0px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.univer-ring-primary-600{--univer-tw-ring-color:var(--univer-primary-600)}.univer-backdrop-blur-\\[2px\\]{--univer-tw-backdrop-blur:blur(2px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-backdrop-blur-xl{--univer-tw-backdrop-blur:blur(24px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-transition-\\[width\\]{transition-property:width;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-animate-in{--univer-tw-enter-opacity:initial;--univer-tw-enter-scale:initial;--univer-tw-enter-rotate:initial;--univer-tw-enter-translate-x:initial;--univer-tw-enter-translate-y:initial;animation-name:enter;animation-duration:.15s}.univer-fade-in{--univer-tw-enter-opacity:0}.univer-fade-in-70{--univer-tw-enter-opacity:.7}.last\\:univer-border-b-0:last-child{border-bottom-width:0}.empty\\:univer-hidden:empty{display:none}.hover\\:univer-opacity-50:hover{opacity:.5}.focus\\:univer-bg-white:focus{background-color:var(--univer-white)}.focus\\:univer-ring-2:focus{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.focus-visible\\:univer-ring-primary-600:focus-visible{--univer-tw-ring-color:var(--univer-primary-600)}.focus-visible\\:univer-ring-offset-0:focus-visible{--univer-tw-ring-offset-width:0px}.active\\:univer-bg-gray-200:active{background-color:var(--univer-gray-200)}.enabled\\:hover\\:univer-bg-gray-50:hover:enabled{background-color:var(--univer-gray-50)}.enabled\\:active\\:univer-bg-gray-100:active:enabled{background-color:var(--univer-gray-100)}.disabled\\:univer-text-gray-300:disabled{color:var(--univer-gray-300)}.disabled\\:hover\\:univer-bg-transparent:hover:disabled{background-color:#0000}@media (width>=640px){.sm\\:\\!univer-block{display:block!important}}.rtl\\:univer-pl-1\\.5:where([dir=rtl],[dir=rtl] *){padding-left:.375rem}.rtl\\:univer-pr-0:where([dir=rtl],[dir=rtl] *){padding-right:0}.rtl\\:univer-pr-2:where([dir=rtl],[dir=rtl] *){padding-right:.5rem}.dark\\:\\!univer-bg-gray-200:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-200)!important}.dark\\:\\!univer-bg-primary-400:where(.univer-dark,.univer-dark *){background-color:var(--univer-primary-400)!important}.dark\\:\\!univer-text-gray-600:where(.univer-dark,.univer-dark *){color:var(--univer-gray-600)!important}.dark\\:\\!univer-text-gray-800:where(.univer-dark,.univer-dark *){color:var(--univer-gray-800)!important}.dark\\:\\!univer-text-primary-100:where(.univer-dark,.univer-dark *){color:var(--univer-primary-100)!important}.dark\\:\\!univer-text-primary-400:where(.univer-dark,.univer-dark *){color:var(--univer-primary-400)!important}.dark\\:hover\\:\\!univer-bg-transparent:hover:where(.univer-dark,.univer-dark *){background-color:#0000!important}.dark\\:active\\:\\!univer-bg-gray-600:active:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:disabled\\:\\!univer-text-gray-600:disabled:where(.univer-dark,.univer-dark *){color:var(--univer-gray-600)!important}.\\[\\&\\:\\:-webkit-scrollbar\\]\\:univer-hidden::-webkit-scrollbar{display:none}.\\[\\&\\>\\*\\]\\:univer-m-0>*{margin:0}.\\[\\&\\>\\*\\]\\:univer-inline-flex>*{display:inline-flex}.\\[\\&\\>\\*\\]\\:univer-h-6>*{height:1.5rem}.\\[\\&\\>\\*\\]\\:univer-min-h-7>*{min-height:1.75rem}.\\[\\&\\>\\*\\]\\:univer-min-w-7>*{min-width:1.75rem}.\\[\\&\\>\\*\\]\\:univer-appearance-none>*{appearance:none}.\\[\\&\\>\\*\\]\\:univer-items-center>*{align-items:center}.\\[\\&\\>\\*\\]\\:univer-justify-center>*{justify-content:center}.\\[\\&\\>\\*\\]\\:univer-rounded>*{border-radius:.25rem}.\\[\\&\\>\\*\\]\\:univer-rounded-md>*{border-radius:.375rem}.\\[\\&\\>\\*\\]\\:univer-border-0>*{border-width:0}.\\[\\&\\>\\*\\]\\:univer-px-1>*{padding-left:.25rem;padding-right:.25rem}.\\[\\&\\>\\*\\]\\:univer-px-1\\.5>*{padding-left:.375rem;padding-right:.375rem}.\\[\\&\\>\\*\\]\\:univer-leading-none>*{line-height:1}.\\[\\&\\>\\*\\]\\:univer-outline-none>*{outline-offset:2px;outline:2px solid #0000}.\\[\\&\\>\\*\\]\\:univer-transition-colors>*{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:\\[\\&\\>\\*\\]\\:univer-bg-gray-100>:hover{background-color:var(--univer-gray-100)}.\\[\\&\\>span\\]\\:univer-truncate>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.\\[\\&\\>span\\]\\:univer-text-sm>span{font-size:.875rem;line-height:1.25rem}.\\[\\&\\>span\\]\\:univer-font-medium>span{font-weight:500}.\\[\\&\\>svg\\]\\:univer-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:univer-text-lg>svg{font-size:1.125rem;line-height:1.75rem}.\\[\\&\\>svg\\]\\:univer-text-gray-700>svg{color:var(--univer-gray-700)}.\\[\\&_\\*\\]\\:univer-box-border *{box-sizing:border-box}.\\[\\&_\\.univer-custom-label\\]\\:univer-text-sm .univer-custom-label{font-size:.875rem;line-height:1.25rem}.\\[\\&_\\.univer-custom-label\\]\\:univer-leading-none .univer-custom-label{line-height:1}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-h-8 .univer-toolbar-button-selector-main{height:2rem!important}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-rounded-none .univer-toolbar-button-selector-main{border-radius:0!important}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-rounded-l-md .univer-toolbar-button-selector-main{border-top-left-radius:.375rem!important;border-bottom-left-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-px-1\\.5 .univer-toolbar-button-selector-main{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:\\!univer-h-8 .univer-toolbar-button-selector-root{height:2rem!important}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:univer-overflow-hidden .univer-toolbar-button-selector-root{overflow:hidden}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:\\!univer-rounded-md .univer-toolbar-button-selector-root{border-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:\\!univer-pr-0 .univer-toolbar-button-selector-root{padding-right:0!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-static .univer-toolbar-button-selector-trigger{position:static!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-h-8 .univer-toolbar-button-selector-trigger{height:2rem!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-w-6 .univer-toolbar-button-selector-trigger{width:1.5rem!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-rounded-none .univer-toolbar-button-selector-trigger{border-radius:0!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-rounded-r-md .univer-toolbar-button-selector-trigger{border-top-right-radius:.375rem!important;border-bottom-right-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-h-8 .univer-toolbar-selector-root{height:2rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-gap-1 .univer-toolbar-selector-root{gap:.25rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-rounded-md .univer-toolbar-selector-root{border-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-px-1\\.5 .univer-toolbar-selector-root{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_\\.univer-toolbar-selector-trigger\\]\\:\\!univer-pl-0\\.5 .univer-toolbar-selector-trigger{padding-left:.125rem!important}.\\[\\&_\\.univer-tooltip\\]\\:univer-inline-flex .univer-tooltip{display:inline-flex}.\\[\\&_\\.univer-tooltip\\]\\:univer-h-full .univer-tooltip{height:100%}.\\[\\&_\\.univer-tooltip\\]\\:univer-items-center .univer-tooltip{align-items:center}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-h-8 [data-u-command]{height:2rem!important}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-min-h-8 [data-u-command]{min-height:2rem!important}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-rounded-md [data-u-command]{border-radius:.375rem!important}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-px-1\\.5 [data-u-command]{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_button\\]\\:\\!univer-m-0 button{margin:0!important}.\\[\\&_button\\]\\:\\!univer-h-8 button{height:2rem!important}.\\[\\&_button\\]\\:\\!univer-min-w-8 button{min-width:2rem!important}.\\[\\&_button\\]\\:\\!univer-appearance-none button{appearance:none!important}.\\[\\&_button\\]\\:\\!univer-rounded-md button{border-radius:.375rem!important}.\\[\\&_button\\]\\:\\!univer-border-0 button{border-width:0!important}.\\[\\&_button\\]\\:\\!univer-bg-transparent button{background-color:#0000!important}.\\[\\&_button\\]\\:\\!univer-p-0 button{padding:0!important}.\\[\\&_button\\]\\:\\!univer-px-1\\.5 button{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_button\\]\\:\\!univer-leading-none button{line-height:1!important}.\\[\\&_button\\]\\:\\!univer-outline-none button{outline-offset:2px!important;outline:2px solid #0000!important}.\\[\\&_input\\:focus\\]\\:\\!univer-ring-0 input:focus{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color)!important;--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(0px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color)!important;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000!important;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)!important}.\\[\\&_input\\]\\:\\!univer-m-0 input{margin:0!important}.\\[\\&_input\\]\\:univer-h-6 input{height:1.5rem}.\\[\\&_input\\]\\:univer-w-7 input{width:1.75rem}.\\[\\&_input\\]\\:\\!univer-appearance-none input{appearance:none!important}.\\[\\&_input\\]\\:\\!univer-border-0 input{border-width:0!important}.\\[\\&_input\\]\\:univer-border-none input{border-style:none}.\\[\\&_input\\]\\:\\!univer-bg-transparent input{background-color:#0000!important}.\\[\\&_input\\]\\:\\!univer-p-0 input{padding:0!important}.\\[\\&_input\\]\\:univer-p-0 input{padding:0}.\\[\\&_input\\]\\:univer-text-sm input{font-size:.875rem;line-height:1.25rem}.\\[\\&_input\\]\\:\\!univer-leading-none input{line-height:1!important}.\\[\\&_input\\]\\:\\!univer-outline-none input{outline-offset:2px!important;outline:2px solid #0000!important}.univer-fixed{position:fixed}.univer-bottom-0{bottom:0}.univer-left-5{left:1.25rem}.univer-left-\\[5px\\]{left:5px}.univer-top-4{top:1rem}.univer-top-\\[5px\\]{top:5px}.univer-z-\\[10000\\]{z-index:10000}.univer-mr-1{margin-right:.25rem}.univer-mt-1\\.5{margin-top:.375rem}.univer-mt-12{margin-top:3rem}.univer-size-0\\.5{width:.125rem;height:.125rem}.univer-size-8{width:2rem;height:2rem}.univer-h-16{height:4rem}.univer-h-3\\.5{height:.875rem}.univer-h-\\[24px\\]{height:24px}.univer-min-h-8{min-height:2rem}.univer-w-2{width:.5rem}.univer-w-2\\.5{width:.625rem}.univer-w-28{width:7rem}.univer-w-4\\/5{width:80%}.univer-w-\\[0px\\]{width:0}.univer-w-\\[212px\\]{width:212px}.univer-w-\\[72px\\]{width:72px}.univer-min-w-\\[180px\\]{min-width:180px}.univer-cursor-grab{cursor:grab}.univer-grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.univer-place-items-center{place-items:center}.univer-items-stretch{align-items:stretch}.univer-gap-2\\.5{gap:.625rem}.univer-gap-3{gap:.75rem}.univer-gap-x-0\\.5{-moz-column-gap:.125rem;column-gap:.125rem}.univer-gap-y-px{row-gap:1px}.univer-rounded-r-2xl{border-top-right-radius:1rem;border-bottom-right-radius:1rem}.\\!univer-border-primary-500{border-color:var(--univer-primary-500)!important}.univer-border-primary-500{border-color:var(--univer-primary-500)}.\\!univer-bg-primary-50{background-color:var(--univer-primary-50)!important}.\\!univer-bg-primary-900{background-color:var(--univer-primary-900)!important}.univer-bg-gray-400{background-color:var(--univer-gray-400)}.univer-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.univer-pb-0\\.5{padding-bottom:.125rem}.univer-pb-4{padding-bottom:1rem}.univer-pr-1{padding-right:.25rem}.univer-pt-1\\.5{padding-top:.375rem}.univer-pt-14{padding-top:3.5rem}.univer-text-lg{font-size:1.125rem;line-height:1.75rem}.univer-font-\\[500\\],.univer-font-medium{font-weight:500}.univer-font-normal{font-weight:400}.univer-leading-\\[24px\\]{line-height:24px}.\\!univer-text-gray-200{color:var(--univer-gray-200)!important}.\\!univer-text-gray-400{color:var(--univer-gray-400)!important}.\\!univer-text-primary-600{color:var(--univer-primary-600)!important}.univer-text-gray-800{color:var(--univer-gray-800)}.univer-backdrop-blur-\\[10px\\]{--univer-tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-duration-300{transition-duration:.3s}.univer-group:hover .group-hover\\:univer-bg-gray-500{background-color:var(--univer-gray-500)}.hover\\:univer-border-primary-500:hover{border-color:var(--univer-primary-500)}.hover\\:univer-bg-white:hover{background-color:var(--univer-white)}.hover\\:univer-text-gray-900:hover{color:var(--univer-gray-900)}.hover\\:univer-text-primary-600:hover{color:var(--univer-primary-600)}.hover\\:univer-shadow-md:hover{--univer-tw-shadow:0px 1px 6px -2px #1e284d14, 0px 2px 6px -1px #1e284d1a;--univer-tw-shadow-colored:0px 1px 6px -2px var(--univer-tw-shadow-color), 0px 2px 6px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.active\\:univer-cursor-grabbing:active{cursor:grabbing}.dark\\:\\!univer-bg-gray-500:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-500)!important}.dark\\:\\!univer-bg-primary-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-primary-900)!important}.univer-group:hover .dark\\:group-hover\\:\\!univer-bg-gray-300:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-300)!important}.univer-pointer-events-none{pointer-events:none}.univer-inset-0{inset:0}.-univer-left-0\\.5{left:-.125rem}.-univer-top-0\\.5{top:-.125rem}.univer-left-0{left:0}.univer-left-1{left:.25rem}.univer-left-3{left:.75rem}.univer-right-0{right:0}.univer-right-5{right:1.25rem}.univer-top-0{top:0}.univer-top-0\\.5{top:.125rem}.univer-z-10{z-index:10}.univer-z-\\[1001\\]{z-index:1001}.univer-z-\\[100\\]{z-index:100}.univer-mx-1\\.5{margin-left:.375rem;margin-right:.375rem}.univer-mb-1\\.5{margin-bottom:.375rem}.univer-mb-4{margin-bottom:1rem}.univer-ml-6{margin-left:1.5rem}.univer-ml-px{margin-left:1px}.univer-mr-1\\.5{margin-right:.375rem}.univer-mr-5{margin-right:1.25rem}.univer-mt-auto{margin-top:auto}.univer-size-0{width:0;height:0}.univer-size-10{width:2.5rem;height:2.5rem}.univer-h-0\\.5{height:.125rem}.univer-h-1{height:.25rem}.univer-h-10{height:2.5rem}.univer-h-20{height:5rem}.univer-h-60{height:15rem}.univer-h-9{height:2.25rem}.univer-h-\\[270px\\]{height:270px}.univer-h-\\[30px\\]{height:30px}.univer-h-\\[calc\\(100\\%-16px\\)\\]{height:calc(100% - 16px)}.univer-h-\\[calc\\(100\\%-8px\\)\\]{height:calc(100% - 8px)}.univer-h-px{height:1px}.univer-max-h-52{max-height:13rem}.univer-max-h-\\[100px\\]{max-height:100px}.univer-max-h-\\[360px\\]{max-height:360px}.univer-min-h-0{min-height:0}.univer-min-h-\\[30px\\]{min-height:30px}.\\!univer-w-\\[90px\\]{width:90px!important}.univer-w-16{width:4rem}.univer-w-20{width:5rem}.univer-w-24{width:6rem}.univer-w-5{width:1.25rem}.univer-w-60{width:15rem}.univer-w-\\[100px\\]{width:100px}.univer-w-\\[130px\\]{width:130px}.univer-w-\\[156px\\]{width:156px}.univer-w-\\[300px\\]{width:300px}.univer-w-\\[50\\%\\]{width:50%}.univer-w-fit{width:fit-content}.univer-min-w-0{min-width:0}.univer-min-w-72{min-width:18rem}.univer-max-w-32{max-width:8rem}.univer-max-w-36{max-width:9rem}.univer-max-w-64{max-width:16rem}.univer-max-w-\\[190px\\]{max-width:190px}.univer-max-w-\\[200px\\]{max-width:200px}.univer-max-w-\\[calc\\(100\\%-112px\\)\\]{max-width:calc(100% - 112px)}.univer-max-w-fit{max-width:fit-content}.univer-max-w-lg{max-width:32rem}.univer-flex-shrink-0,.univer-shrink-0{flex-shrink:0}.univer-rotate-180{--univer-tw-rotate:180deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(180deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-animate-spin{animation:1s linear infinite univer-spin}.univer-cursor-not-allowed{cursor:not-allowed}.univer-appearance-none{appearance:none}.univer-grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.univer-grid-cols-\\[1fr\\,auto\\,auto\\,auto\\]{grid-template-columns:1fr auto auto auto}.univer-flex-row-reverse{flex-direction:row-reverse}.univer-gap-7{gap:1.75rem}.univer-gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.univer-space-y-2>:not([hidden])~:not([hidden]){--univer-tw-space-y-reverse:0;margin-top:calc(.5rem * (1 - var(--univer-tw-space-y-reverse)));margin-top:.5rem;margin-top:calc(.5rem * calc(1 - var(--univer-tw-space-y-reverse)));margin-bottom:0;margin-bottom:calc(.5rem * var(--univer-tw-space-y-reverse))}.univer-divide-x-0>:not([hidden])~:not([hidden]){--univer-tw-divide-x-reverse:0;border-right-width:0;border-right-width:calc(0px * var(--univer-tw-divide-x-reverse));border-left-width:calc(0px * (1 - var(--univer-tw-divide-x-reverse)));border-left-width:0;border-left-width:calc(0px * calc(1 - var(--univer-tw-divide-x-reverse)))}.univer-divide-y>:not([hidden])~:not([hidden]){--univer-tw-divide-y-reverse:0;border-top-width:calc(1px * (1 - var(--univer-tw-divide-y-reverse)));border-top-width:1px;border-top-width:calc(1px * calc(1 - var(--univer-tw-divide-y-reverse)));border-bottom-width:0;border-bottom-width:calc(1px * var(--univer-tw-divide-y-reverse))}.univer-divide-solid>:not([hidden])~:not([hidden]){border-style:solid}.univer-divide-gray-200>:not([hidden])~:not([hidden]){border-color:var(--univer-gray-200)}.univer-justify-self-center{justify-self:center}.univer-overflow-x-auto{overflow-x:auto}.univer-overflow-y-hidden{overflow-y:hidden}.univer-rounded-sm{border-radius:.125rem}.univer-border-2{border-width:2px}.univer-border-4{border-width:4px}.univer-border-b{border-bottom-width:1px}.univer-border-\\[rgba\\(13\\,13\\,13\\,0\\.12\\)\\]{border-color:#0d0d0d1f}.univer-border-gray-100{border-color:var(--univer-gray-100)}.univer-border-r-gray-200{border-right-color:var(--univer-gray-200)}.univer-border-t-primary-500{border-top-color:var(--univer-primary-500)}.\\!univer-bg-gray-700{background-color:var(--univer-gray-700)!important}.univer-bg-blue-500{background-color:var(--univer-blue-500)}.univer-bg-blue-600{background-color:var(--univer-blue-600)}.univer-bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--univer-tw-gradient-stops))}.univer-from-gray-50{--univer-tw-gradient-from:var(--univer-gray-50) var(--univer-tw-gradient-from-position);--univer-tw-gradient-to:#fff0 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)}.univer-to-gray-100{--univer-tw-gradient-to:var(--univer-gray-100) var(--univer-tw-gradient-to-position)}.univer-fill-gray-900{fill:var(--univer-gray-900)}.univer-px-3\\.5{padding-left:.875rem;padding-right:.875rem}.univer-px-5{padding-left:1.25rem;padding-right:1.25rem}.univer-py-5{padding-top:1.25rem;padding-bottom:1.25rem}.univer-pb-1{padding-bottom:.25rem}.univer-pl-1\\.5{padding-left:.375rem}.univer-pl-3{padding-left:.75rem}.univer-pl-6{padding-left:1.5rem}.univer-pr-5{padding-right:1.25rem}.univer-pt-1{padding-top:.25rem}.univer-font-semibold{font-weight:600}.univer-leading-6{line-height:1.5rem}.univer-leading-7{line-height:1.75rem}.\\!univer-text-blue-400{color:var(--univer-blue-400)!important}.\\!univer-text-gray-700{color:var(--univer-gray-700)!important}.\\!univer-text-white{color:var(--univer-white)!important}.univer-text-blue-500{color:var(--univer-blue-500)}.univer-text-blue-600{color:var(--univer-blue-600)}.univer-text-gray-200{color:var(--univer-gray-200)}.univer-text-gray-300{color:var(--univer-gray-300)}.univer-text-green-600{color:var(--univer-green-600)}.univer-text-primary-700{color:var(--univer-primary-700)}.univer-text-red-600{color:var(--univer-red-600)}.univer-text-rose-600{--univer-tw-text-opacity:1;color:rgba(225,29,72,var(--univer-tw-text-opacity,1))}.univer-text-yellow-500{color:var(--univer-yellow-500)}.univer-shadow{--univer-tw-shadow:0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;--univer-tw-shadow-colored:0 1px 3px 0 var(--univer-tw-shadow-color), 0 1px 2px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-blur-sm{--univer-tw-blur:blur(4px);filter:var(--univer-tw-blur) var(--univer-tw-brightness) var(--univer-tw-contrast) var(--univer-tw-grayscale) var(--univer-tw-hue-rotate) var(--univer-tw-invert) var(--univer-tw-saturate) var(--univer-tw-sepia) var(--univer-tw-drop-shadow)}.univer-backdrop-blur{--univer-tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-transition-\\[colors\\,box-shadow\\]{transition-property:colors,box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-\\[height\\]{transition-property:height;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-duration-200{transition-duration:.2s}.univer-ease-linear{transition-timing-function:linear}.after\\:univer-absolute:after{content:var(--univer-tw-content);position:absolute}.after\\:univer-right-0:after{content:var(--univer-tw-content);right:0}.after\\:univer-top-1\\/2:after{content:var(--univer-tw-content);top:50%}.after\\:univer-block:after{content:var(--univer-tw-content);display:block}.after\\:univer-h-4:after{content:var(--univer-tw-content);height:1rem}.after\\:univer-w-px:after{content:var(--univer-tw-content);width:1px}.after\\:-univer-translate-y-1\\/2:after{content:var(--univer-tw-content);--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.after\\:univer-bg-gray-200:after{content:var(--univer-tw-content);background-color:var(--univer-gray-200)}.after\\:univer-content-\\[\\"\\"\\]:after{--univer-tw-content:"";content:"";content:var(--univer-tw-content)}.last\\:univer-mb-0:last-child{margin-bottom:0}.univer-group:hover .group-hover\\:univer-flex{display:flex}.hover\\:univer-border-primary-600:hover{border-color:var(--univer-primary-600)}.hover\\:univer-bg-transparent:hover{background-color:#0000}.focus\\:univer-border-primary-500:focus{border-color:var(--univer-primary-500)}.focus\\:univer-outline-none:focus{outline-offset:2px;outline:2px solid #0000}.focus-visible\\:univer-ring-2:focus-visible{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.focus-visible\\:univer-ring-primary-500:focus-visible{--univer-tw-ring-color:var(--univer-primary-500)}.active\\:univer-bg-gray-100:active{background-color:var(--univer-gray-100)}.dark\\:\\!univer-divide-gray-600:where(.univer-dark,.univer-dark *)>:not([hidden])~:not([hidden]){border-color:var(--univer-gray-600)!important}.dark\\:\\!univer-border-r-gray-700:where(.univer-dark,.univer-dark *){border-right-color:var(--univer-gray-700)!important}.dark\\:\\!univer-bg-black:where(.univer-dark,.univer-dark *){background-color:var(--univer-black)!important}.dark\\:\\!univer-bg-blue-400:where(.univer-dark,.univer-dark *){background-color:var(--univer-blue-400)!important}.dark\\:\\!univer-from-gray-800:where(.univer-dark,.univer-dark *){--univer-tw-gradient-from:var(--univer-gray-800) var(--univer-tw-gradient-from-position)!important;--univer-tw-gradient-to:#fff0 var(--univer-tw-gradient-to-position)!important;--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)!important}.dark\\:\\!univer-to-gray-900:where(.univer-dark,.univer-dark *){--univer-tw-gradient-to:var(--univer-gray-900) var(--univer-tw-gradient-to-position)!important}.dark\\:\\!univer-fill-white:where(.univer-dark,.univer-dark *){fill:var(--univer-white)!important}.dark\\:\\!univer-text-blue-400:where(.univer-dark,.univer-dark *){color:var(--univer-blue-400)!important}.dark\\:\\!univer-text-gray-700:where(.univer-dark,.univer-dark *){color:var(--univer-gray-700)!important}.dark\\:\\!univer-text-green-400:where(.univer-dark,.univer-dark *){color:var(--univer-green-400)!important}.dark\\:\\!univer-text-red-400:where(.univer-dark,.univer-dark *){color:var(--univer-red-400)!important}.\\[\\&\\>div\\:first-child\\]\\:univer-px-2\\.5>div:first-child{padding-left:.625rem;padding-right:.625rem}.\\[\\&\\>div\\]\\:univer-h-5>div{height:1.25rem}.\\[\\&\\>div\\]\\:univer-ring-transparent>div{--univer-tw-ring-color:transparent}.\\[\\&_canvas\\]\\:univer-absolute canvas,.univer-absolute{position:absolute}.univer-left-1\\.5{left:.375rem}.univer-top-1\\/2{top:50%}.univer-z-\\[15\\]{z-index:15}.univer-m-0{margin:0}.-univer-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.univer-mx-0{margin-left:0;margin-right:0}.univer-my-1{margin-top:.25rem;margin-bottom:.25rem}.univer-my-2{margin-top:.5rem;margin-bottom:.5rem}.univer-mb-0{margin-bottom:0}.univer-ml-4{margin-left:1rem}.univer-mr-0{margin-right:0}.univer-mt-0{margin-top:0}.univer-mt-1{margin-top:.25rem}.univer-h-\\[18px\\]{height:18px}.univer-h-\\[364px\\]{height:364px}.univer-max-h-60{max-height:15rem}.univer-max-h-72{max-height:18rem}.univer-max-h-\\[350px\\]{max-height:350px}.univer-w-\\[250px\\]{width:250px}.-univer-translate-y-1\\/2{--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-justify-around{justify-content:space-around}.univer-overflow-visible{overflow:visible}.univer-whitespace-pre-wrap{white-space:pre-wrap}.univer-break-words{word-wrap:break-word}.univer-break-all{word-break:break-all}.univer-rounded-none{border-radius:0}.univer-rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.univer-border-r-0{border-right-width:0}.univer-border-gray-600{border-color:var(--univer-gray-600)}.univer-border-primary-600{border-color:var(--univer-primary-600)}.\\!univer-bg-gray-600{background-color:var(--univer-gray-600)!important}.univer-bg-primary-600{background-color:var(--univer-primary-600)}.univer-px-4{padding-left:1rem;padding-right:1rem}.univer-px-6{padding-left:1.5rem;padding-right:1.5rem}.univer-px-7{padding-left:1.75rem;padding-right:1.75rem}.univer-py-3{padding-top:.75rem;padding-bottom:.75rem}.univer-pb-3{padding-bottom:.75rem}.univer-pt-0{padding-top:0}.univer-font-medium{font-weight:500}.univer-leading-\\[13px\\]{line-height:13px}.univer-text-white{color:var(--univer-white)}.univer-outline-none{outline-offset:2px;outline:2px solid #0000}.univer-ring-1{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(1px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.univer-ring-primary-500{--univer-tw-ring-color:var(--univer-primary-500)}.univer-ring-red-500{--univer-tw-ring-color:var(--univer-red-500)}.hover\\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.hover\\:univer-bg-gray-300:hover{background-color:var(--univer-gray-300)}.dark\\:\\!univer-bg-gray-600:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:\\!univer-text-gray-300:where(.univer-dark,.univer-dark *){color:var(--univer-gray-300)!important}.dark\\:hover\\:\\!univer-bg-gray-600:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.univer-mb-5{margin-bottom:1.25rem}.univer-mr-3{margin-right:.75rem}.univer-mt-3{margin-top:.75rem}.univer-mt-3\\.5{margin-top:.875rem}.univer-max-h-\\[400px\\]{max-height:400px}.univer-w-32{width:8rem}.univer-w-36{width:9rem}.univer-w-4{width:1rem}.univer-w-\\[340px\\]{width:340px}.univer-cursor-default{cursor:default}.univer-gap-1\\.5{gap:.375rem}.univer-gap-6{gap:1.5rem}.univer-p-1\\.5{padding:.375rem}.univer-pb-5{padding-bottom:1.25rem}.univer-text-sm,.univer-text-sm\\/5{font-size:.875rem;line-height:1.25rem}.dark\\:\\!univer-text-gray-400:where(.univer-dark,.univer-dark *){color:var(--univer-gray-400)!important}.univer-absolute{position:absolute}.-univer-bottom-0\\.5{bottom:-.125rem}.-univer-right-0\\.5{right:-.125rem}.univer-mx-1{margin-left:.25rem;margin-right:.25rem}.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-block{display:block}.univer-inline-block{display:inline-block}.univer-size-3{width:.75rem;height:.75rem}.univer-size-full{width:100%;height:100%}.univer-h-4{height:1rem}.univer-h-\\[300px\\]{height:300px}.univer-max-h-\\[500px\\]{max-height:500px}.univer-min-h-\\[300px\\]{min-height:300px}.univer-w-\\[400px\\]{width:400px}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow{flex-grow:1}.univer-flex-grow-0{flex-grow:0}.univer-grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.univer-flex-nowrap{flex-wrap:nowrap}.univer-justify-start{justify-content:flex-start}.univer-gap-4{gap:1rem}.univer-overflow-auto{overflow:auto}.univer-whitespace-nowrap{white-space:nowrap}.univer-rounded-full{border-radius:9999px}.univer-border-\\[rgba\\(13\\,13\\,13\\,0\\.06\\)\\]{border-color:#0d0d0d0f}.univer-border-transparent{border-color:#0000}.univer-bg-gray-300{background-color:var(--univer-gray-300)}.univer-p-0\\.5{padding:.125rem}.univer-p-2{padding:.5rem}.univer-py-0{padding-top:0;padding-bottom:0}.univer-py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.univer-py-2\\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pl-5{padding-left:1.25rem}.univer-pr-0\\.5{padding-right:.125rem}.univer-pr-2{padding-right:.5rem}.univer-pt-2{padding-top:.5rem}.univer-font-bold{font-weight:700}.univer-text-\\[\\#418F1F\\]{--univer-tw-text-opacity:1;color:rgba(65,143,31,var(--univer-tw-text-opacity,1))}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-transition-shadow{transition-property:box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.hover\\:univer-ring-2:hover{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.hover\\:univer-ring-offset-2:hover{--univer-tw-ring-offset-width:2px}.hover\\:univer-ring-offset-white:hover{--univer-tw-ring-offset-color:var(--univer-white)}.dark\\:\\!univer-border-\\[rgba\\(255\\,255\\,255\\,0\\.06\\)\\]:where(.univer-dark,.univer-dark *){border-color:#ffffff0f!important}.dark\\:\\!univer-border-gray-600:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\\:\\!univer-text-gray-500:where(.univer-dark,.univer-dark *){color:var(--univer-gray-500)!important}.dark\\:hover\\:\\!univer-bg-gray-900:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.\\[\\&\\:hover_a\\]\\:univer-inline-block:hover a{display:inline-block}.univer-my-0{margin-top:0;margin-bottom:0}.univer-mb-2{margin-bottom:.5rem}.univer-mb-3{margin-bottom:.75rem}.univer-ml-1\\.5{margin-left:.375rem}.univer-ml-3{margin-left:.75rem}.univer-mt-5{margin-top:1.25rem}.univer-max-h-\\[310px\\]{max-height:310px}.univer-w-\\[--radix-popper-anchor-width\\]{width:var(--radix-popper-anchor-width)}.univer-max-w-\\[220px\\]{max-width:220px}.univer-select-none{-webkit-user-select:none;user-select:none}.univer-list-none{list-style-type:none}.univer-grid-flow-col{grid-auto-flow:column}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.univer-transition-all{transition-property:all;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:univer-text-red-500:hover{color:var(--univer-red-500)}.disabled\\:univer-divide-opacity-30:disabled>:not([hidden])~:not([hidden]){--univer-tw-divide-opacity:.3}.disabled\\:univer-text-gray-800:disabled{color:var(--univer-gray-800)}.univer-mt-4{margin-top:1rem}.univer-mt-6{margin-top:1.5rem}.univer-inline-flex{display:inline-flex}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-relative{position:relative}.univer-mt-2\\.5{margin-top:.625rem}.univer-size-4{width:1rem;height:1rem}.univer-h-5{height:1.25rem}.univer-h-7{height:1.75rem}.univer-h-8{height:2rem}.univer-h-full{height:100%}.univer-w-6{width:1.5rem}.univer-w-px{width:1px}.univer-min-w-32{min-width:8rem}.univer-min-w-9{min-width:2.25rem}.univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.univer-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.univer-gap-1{gap:.25rem}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-none{border-style:none}.\\!univer-bg-gray-800{background-color:var(--univer-gray-800)!important}.\\!univer-bg-gray-900{background-color:var(--univer-gray-900)!important}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-gray-200{background-color:var(--univer-gray-200)}.univer-bg-primary-50{background-color:var(--univer-primary-50)}.univer-bg-transparent{background-color:#0000}.univer-fill-primary-600{fill:var(--univer-primary-600)}.univer-p-0{padding:0}.univer-p-1{padding:.25rem}.univer-px-1{padding-left:.25rem;padding-right:.25rem}.univer-px-1\\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-1{padding-top:.25rem;padding-bottom:.25rem}.univer-text-left{text-align:left}.univer-text-center{text-align:center}.\\!univer-text-primary-300{color:var(--univer-primary-300)!important}.univer-text-gray-700{color:var(--univer-gray-700)}.univer-shadow-lg{--univer-tw-shadow:0px 4px 6px 0px #1e284d0d, 0px 10px 15px -3px #1e284d1a;--univer-tw-shadow-colored:0px 4px 6px 0px var(--univer-tw-shadow-color), 0px 10px 15px -3px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-shadow-sm{--univer-tw-shadow:0px 1px 2px 0px #1e284d14;--univer-tw-shadow-colored:0px 1px 2px 0px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 2px #1e284d14;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.disabled\\:univer-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:univer-opacity-40:disabled{opacity:.4}.dark\\:\\!univer-border-gray-700:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-700)!important}.dark\\:\\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\\:\\!univer-bg-gray-800:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.dark\\:\\!univer-text-gray-100:where(.univer-dark,.univer-dark *){color:var(--univer-gray-100)!important}.dark\\:\\!univer-text-primary-300:where(.univer-dark,.univer-dark *){color:var(--univer-primary-300)!important}.dark\\:hover\\:\\!univer-bg-gray-800:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.\\[\\&\\>div\\]\\:univer-grid>div{display:grid}.\\[\\&\\>div\\]\\:univer-gap-2>div{gap:.5rem}.univer-grid{display:grid}.univer-hidden{display:none}.univer-flex-col{flex-direction:column}.univer-border-t{border-top-width:1px}.univer-border-gray-200{border-color:var(--univer-gray-200)}.univer-py-2{padding-top:.5rem;padding-bottom:.5rem}.univer-pt-3{padding-top:.75rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-600{color:var(--univer-gray-600)}.dark\\:\\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.univer-mb-1{margin-bottom:.25rem}.univer-ml-2{margin-left:.5rem}.univer-mr-2{margin-right:.5rem}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-size-5{width:1.25rem;height:1.25rem}.univer-size-6{width:1.5rem;height:1.5rem}.univer-h-6{height:1.5rem}.univer-w-\\[296px\\]{width:296px}.univer-w-full{width:100%}.univer-max-w-80{max-width:20rem}.univer-flex-1{flex:1}.univer-flex-none{flex:none}.univer-cursor-pointer{cursor:pointer}.univer-flex-row{flex-direction:row}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:.5rem}.univer-overflow-hidden{overflow:hidden}.univer-truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.univer-rounded{border-radius:.25rem}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-xl{border-radius:.75rem}.univer-bg-white{background-color:var(--univer-white)}.univer-p-3{padding:.75rem}.univer-p-4{padding:1rem}.univer-text-base{font-size:1rem;line-height:1.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-leading-5{line-height:1.25rem}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-green-500{color:var(--univer-green-500)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-text-red-500{color:var(--univer-red-500)}.univer-shadow-md{--univer-tw-shadow:0px 1px 6px -2px #1e284d14, 0px 2px 6px -1px #1e284d1a;--univer-tw-shadow-colored:0px 1px 6px -2px var(--univer-tw-shadow-color), 0px 2px 6px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000), var(--univer-tw-ring-shadow,0 0 #0000), var(--univer-tw-shadow)}.hover\\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.dark\\:\\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\\:\\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\\:hover\\:\\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.sheet-shell[data-v-490e6eac]{letter-spacing:normal;flex-direction:column;height:760px;font-size:14px;line-height:normal;display:flex}.sheet-canvas[data-v-490e6eac]{flex:1;min-height:0;position:relative}.sheet-editor[data-v-490e6eac]{contain:layout style;letter-spacing:normal;width:100%;height:100%;font-size:14px;line-height:normal;position:absolute;inset:0;overflow:hidden}.sheet-attachments[data-v-490e6eac]{border-bottom:1px solid #eee;align-items:center;gap:8px;padding:6px 12px;font-size:12px;display:flex}.sheet-attachments button[data-v-490e6eac]{cursor:pointer;color:#3370ff;background:#fff;border:1px solid #dce3ed;border-radius:4px;padding:4px 8px}.sheet-attachments button[data-v-490e6eac]:disabled{cursor:wait;opacity:.5}.attachment-name[data-v-490e6eac]{text-overflow:ellipsis;white-space:nowrap;max-width:240px;overflow:hidden}.attachment-error[data-v-490e6eac]{color:#c62828}.tag-current-row[data-v-490e6eac]{z-index:100;background:#fafbfc;border:1px solid #eee;border-radius:6px;align-items:center;gap:4px;padding:0 8px;font-size:12px;display:inline-flex;position:absolute;box-shadow:0 1px 4px #0000000f}.tag-current-label[data-v-490e6eac]{color:#999;white-space:nowrap;font-size:11px}.tag-dropdown[data-v-490e6eac]{z-index:100;background:#fff;border:1px solid #e0e0e0;border-radius:6px;flex-direction:column;gap:4px;min-width:220px;max-width:320px;padding:8px;display:flex;position:absolute;box-shadow:0 4px 12px #0000001f}.tag-search[data-v-490e6eac]{box-sizing:border-box;border:1px solid #d9d9d9;border-radius:4px;outline:none;width:100%;padding:5px 8px;font-size:12px}.tag-search[data-v-490e6eac]:focus{border-color:#3370ff}.tag-option-list[data-v-490e6eac]{flex-wrap:wrap;gap:6px;max-height:180px;padding:4px;display:flex;overflow-y:auto}.tag-option[data-v-490e6eac]{cursor:pointer;white-space:nowrap;border:1px solid #0000;border-radius:4px;padding:3px 10px;font-size:12px;font-weight:600;position:relative}.tag-option[data-v-490e6eac]:hover{opacity:.85;border-color:currentColor}.tag-option-name[data-v-490e6eac]{pointer-events:none}.tag-option-delete[data-v-490e6eac]{cursor:pointer;color:#fff;background:#ff4d4f;border:1px solid #fff;border-radius:50%;justify-content:center;align-items:center;width:14px;height:14px;font-size:10px;line-height:1;display:none;position:absolute;top:-6px;right:-6px;box-shadow:0 1px 2px #00000026}.tag-option:hover .tag-option-delete[data-v-490e6eac]{display:inline-flex}.tag-option-delete[data-v-490e6eac]:hover{background:#cf1322}.tag-empty[data-v-490e6eac]{color:#999;text-align:center;width:100%;padding:8px 0;font-size:12px}.tag-add-new[data-v-490e6eac]{color:#666;cursor:pointer;text-align:center;background:0 0;border:1px dashed #d9d9d9;border-radius:4px;width:100%;padding:4px 8px;font-size:12px}.tag-add-new[data-v-490e6eac]:hover{color:#3370ff;border-color:#3370ff}.cell-tag-chip[data-v-490e6eac]{border-radius:4px;align-items:center;gap:2px;padding:2px 6px;font-size:12px;font-weight:600;display:inline-flex}.cell-tag-remove[data-v-490e6eac]{cursor:pointer;color:inherit;opacity:.6;background:0 0;border:none;padding:0 1px;font-size:14px;line-height:1}.cell-tag-remove[data-v-490e6eac]:hover{opacity:1}.tag-config-overlay[data-v-490e6eac]{z-index:1000;background:#0006;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.tag-config-dialog[data-v-490e6eac]{background:#fff;border-radius:8px;min-width:320px;padding:20px;box-shadow:0 8px 24px #00000026}.tag-config-dialog h4[data-v-490e6eac]{margin:0 0 16px;font-size:15px;font-weight:600}.tag-config-label[data-v-490e6eac]{color:#666;flex-direction:column;gap:4px;margin-bottom:12px;font-size:12px;display:flex}.tag-config-label input[data-v-490e6eac]{border:1px solid #d9d9d9;border-radius:4px;padding:6px 8px;font-size:13px}.tag-config-label input[data-v-490e6eac]:focus{border-color:#3370ff;outline:none}.tag-config-colors[data-v-490e6eac]{margin-bottom:12px}.tag-config-colors>span[data-v-490e6eac]{color:#666;margin-bottom:6px;font-size:12px;display:block}.tag-sv-panel[data-v-490e6eac]{cursor:crosshair;touch-action:none;border-radius:6px;width:100%;height:110px;margin-bottom:10px;position:relative}.tag-hue-bar[data-v-490e6eac]{cursor:pointer;touch-action:none;background:linear-gradient(90deg,red,#ff0,#0f0,#0ff,#00f,#f0f,red);border-radius:7px;width:100%;height:14px;position:relative}.tag-color-dot[data-v-490e6eac]{pointer-events:none;border:2px solid #fff;border-radius:50%;width:14px;height:14px;position:absolute;transform:translate(-50%,-50%);box-shadow:0 0 2px #0006}.tag-config-preview[data-v-490e6eac]{margin-bottom:16px}.tag-config-actions[data-v-490e6eac]{justify-content:flex-end;gap:8px;display:flex}.tag-config-cancel[data-v-490e6eac]{cursor:pointer;background:#fff;border:1px solid #d9d9d9;border-radius:4px;padding:5px 14px;font-size:13px}.tag-config-save[data-v-490e6eac]{color:#fff;cursor:pointer;background:#3370ff;border:none;border-radius:4px;padding:5px 14px;font-size:13px}.tag-config-save[data-v-490e6eac]:hover{background:#245bdb}.sheet-statusbar[data-v-490e6eac]{color:#8c8c8c;white-space:nowrap;background:#fafbfc;border-top:1px solid #f0f0f0;align-items:center;gap:8px;padding:8px 16px;font-size:12px;display:flex;overflow:hidden}.status-cell[data-v-490e6eac]{color:#25b864;font-family:ui-monospace,Consolas,monospace;font-weight:600}.status-sep[data-v-490e6eac]{color:#d9d9d9}.sheet-statusbar b[data-v-490e6eac]{color:#595959;font-weight:600}.status-flex[data-v-490e6eac]{flex:1}.status-hint[data-v-490e6eac]{color:#bfbfbf}.status-readonly[data-v-490e6eac]{color:#faad14}.status-tip[data-v-490e6eac]{color:#bfbfbf}.tag-toast[data-v-490e6eac]{z-index:200;color:#fff;pointer-events:none;white-space:nowrap;background:#000000bf;border-radius:6px;padding:8px 18px;font-size:13px;line-height:1.4;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:0 4px 12px #00000026}.tag-toast-enter-active[data-v-490e6eac],.tag-toast-leave-active[data-v-490e6eac]{transition:opacity .25s}.tag-toast-enter-from[data-v-490e6eac],.tag-toast-leave-to[data-v-490e6eac]{opacity:0}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`@keyframes univer-spin{to{transform:rotate(360deg)}}@media (width>=640px){.sm\\:\\!univer-flex-row{flex-direction:row!important}.sm\\:\\!univer-justify-end{justify-content:flex-end!important}.sm\\:\\!univer-space-x-2>:not([hidden])~:not([hidden]){--univer-tw-space-x-reverse:0!important;margin-right:0!important;margin-right:calc(.5rem * var(--univer-tw-space-x-reverse))!important;margin-left:calc(.5rem * (1 - var(--univer-tw-space-x-reverse)))!important;margin-left:.5rem!important;margin-left:calc(.5rem * calc(1 - var(--univer-tw-space-x-reverse)))!important}.sm\\:\\!univer-rounded-lg{border-radius:.5rem!important}.sm\\:\\!univer-text-left{text-align:left!important}}@media (width>=768px){.md\\:univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@keyframes popup-slide-up-in{0%{transform-origin:0 0;opacity:0;transform:scaleY(0)}to{transform-origin:0 0;opacity:1;transform:scaleY(1)}}@keyframes popup-slide-up-out{0%{transform-origin:0 0;opacity:1;transform:scaleY(1)}to{transform-origin:0 0;opacity:0;transform:scaleY(0)}}@keyframes enter{0%{opacity:1;opacity:var(--univer-tw-enter-opacity,1);transform:translateZ(0)scaleZ(1)rotate(0);transform:translate3d(var(--univer-tw-enter-translate-x,0),var(--univer-tw-enter-translate-y,0),0) scale3d(var(--univer-tw-enter-scale,1),var(--univer-tw-enter-scale,1),var(--univer-tw-enter-scale,1)) rotate(var(--univer-tw-enter-rotate,0))}}@keyframes exit{to{opacity:1;opacity:var(--univer-tw-exit-opacity,1);transform:translateZ(0)scaleZ(1)rotate(0);transform:translate3d(var(--univer-tw-exit-translate-x,0),var(--univer-tw-exit-translate-y,0),0) scale3d(var(--univer-tw-exit-scale,1),var(--univer-tw-exit-scale,1),var(--univer-tw-exit-scale,1)) rotate(var(--univer-tw-exit-rotate,0))}}.focus\\:univer-ring-2:focus,.focus-visible\\:univer-ring-2:focus-visible{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}@media (width>=640px){.sm\\:\\!univer-block{display:block!important}}.univer-w-\\[328px\\]{width:328px}.univer-flex-\\[0_0_auto\\]{flex:none}.doc-shell[data-v-f0db620e]{letter-spacing:normal;flex-direction:column;height:760px;font-size:14px;line-height:normal;display:flex}.doc-layout[data-v-f0db620e]{flex:1;min-height:0;display:flex}.doc-canvas[data-v-f0db620e]{background:#f7f8fa;flex:1;min-width:0;position:relative}.readonly-badge[data-v-f0db620e]{z-index:30;color:#8c8c8c;pointer-events:none;background:#ffffffeb;border:1px solid #e0e0e0;border-radius:999px;padding:3px 10px;font-size:12px;position:absolute;top:10px;right:14px;box-shadow:0 1px 4px #0000000f}.attachment-insert-btn[data-v-f0db620e]{z-index:30;color:#3370ff;cursor:pointer;background:#ffffffeb;border:1px solid #e0e0e0;border-radius:999px;height:30px;padding:0 12px;font-size:12px;transition:border-color .15s,background .15s;position:absolute;top:10px;right:14px;box-shadow:0 1px 4px #0000000f}.attachment-insert-btn[data-v-f0db620e]:hover:not(:disabled){background:#fff;border-color:#3370ff}.attachment-insert-btn[data-v-f0db620e]:disabled{color:#8c8c8c;cursor:not-allowed}.pagebreak-insert-btn[data-v-f0db620e]{z-index:30;color:#3370ff;cursor:pointer;background:#ffffffeb;border:1px solid #e0e0e0;border-radius:999px;height:30px;padding:0 12px;font-size:12px;transition:border-color .15s,background .15s;position:absolute;top:10px;right:118px;box-shadow:0 1px 4px #0000000f}.pagebreak-insert-btn[data-v-f0db620e]:hover{background:#fff;border-color:#3370ff}.attachment-file-input[data-v-f0db620e]{display:none}.attachment-error-tip[data-v-f0db620e]{z-index:30;color:#fff;pointer-events:none;background:#e5484df2;border-radius:6px;max-width:80%;padding:6px 14px;font-size:12px;position:absolute;bottom:16px;left:50%;transform:translate(-50%);box-shadow:0 4px 12px #0000002e}.doc-editor[data-v-f0db620e]{contain:layout style;letter-spacing:normal;font-size:14px;line-height:normal;position:absolute;inset:0;overflow:hidden}.link-dialog-mask[data-v-f0db620e]{z-index:30;background:#00000047;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.link-dialog[data-v-f0db620e]{background:#fff;border-radius:12px;width:400px;max-width:calc(100% - 48px);padding:22px 24px 18px;box-shadow:0 12px 40px #00000029}.link-dialog-title[data-v-f0db620e]{color:#1a1a1a;margin-bottom:18px;font-size:16px;font-weight:600}.link-dialog-field[data-v-f0db620e]{margin-bottom:14px}.field-label[data-v-f0db620e]{color:#595959;margin-bottom:6px;font-size:13px;font-weight:500;display:block}.field-input[data-v-f0db620e]{color:#333;background:#fafafa;border:1px solid #e0e0e0;border-radius:6px;outline:none;width:100%;height:34px;padding:0 10px;font-size:13px;transition:border-color .15s,box-shadow .15s}.field-input[data-v-f0db620e]:focus{background:#fff;border-color:#25b864;box-shadow:0 0 0 2px #25b8641f}.field-input.error[data-v-f0db620e]{border-color:#e5484d}.field-error[data-v-f0db620e]{color:#e5484d;margin-top:4px;font-size:12px}.link-dialog-tip[data-v-f0db620e]{color:#bfbfbf;margin-bottom:16px;font-size:12px}.link-dialog-actions[data-v-f0db620e]{justify-content:flex-end;gap:10px;display:flex}.dialog-btn[data-v-f0db620e]{cursor:pointer;border:none;border-radius:6px;height:32px;padding:0 18px;font-size:13px;transition:all .15s}.dialog-btn.cancel[data-v-f0db620e]{color:#595959;background:#f5f5f5}.dialog-btn.cancel[data-v-f0db620e]:hover{background:#ececec}.dialog-btn.confirm[data-v-f0db620e]{color:#fff;background:#25b864;font-weight:500}.dialog-btn.confirm[data-v-f0db620e]:hover:not(:disabled){background:#1fa257}.dialog-btn.confirm[data-v-f0db620e]:disabled{cursor:not-allowed;background:#bfe6d2}.doc-statusbar[data-v-f0db620e]{color:#8c8c8c;background:#fafbfc;border-top:1px solid #f0f0f0;align-items:center;gap:8px;padding:8px 20px;font-size:12px;display:flex}.status-count[data-v-f0db620e]{color:#595959;font-weight:500}.status-flex[data-v-f0db620e]{flex:1}.status-tip[data-v-f0db620e]{color:#bfbfbf}.link-hover-bar[data-v-f0db620e]{z-index:1080;white-space:nowrap;-webkit-user-select:none;user-select:none;background:#fff;border:1px solid #e8e8e8;border-radius:6px;align-items:center;gap:2px;padding:4px 8px;display:flex;position:fixed;transform:translate(-50%)translateY(-100%);box-shadow:0 4px 16px #0000001f}.hover-label[data-v-f0db620e]{color:#3370ff;cursor:pointer;padding:0 6px;font-size:13px;font-weight:500}.hover-label[data-v-f0db620e]:hover{text-decoration:underline}.hover-icon-btn[data-v-f0db620e]{color:#595959;cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;width:28px;height:28px;padding:0;transition:background .12s,color .12s;display:inline-flex;position:relative}.hover-icon-btn[data-v-f0db620e]:hover{color:#1d2129;background:#f2f3f5}.hover-icon-tip[data-v-f0db620e]{color:#3370ff;white-space:nowrap;pointer-events:none;font-size:10px;position:absolute;bottom:-18px;left:50%;transform:translate(-50%)}.hover-unlink-btn[data-v-f0db620e]:hover{color:#e5484d;background:#e5484d14}.hover-sep[data-v-f0db620e]{background:#ececec;flex-shrink:0;width:1px;height:16px;margin:0 4px}.hover-bar-arrow[data-v-f0db620e]{background:#fff;border-bottom:1px solid #e8e8e8;border-right:1px solid #e8e8e8;width:8px;height:8px;position:absolute;bottom:-5px;left:50%;transform:translate(-50%)rotate(45deg)}.hover-style[data-v-f0db620e]{position:relative}.hover-style-menu[data-v-f0db620e]{text-align:left;background:#fff;border:1px solid #e8e8e8;border-radius:6px;min-width:140px;padding:4px;position:absolute;top:calc(100% + 8px);left:50%;transform:translate(-50%);box-shadow:0 4px 16px #0000001f}.hover-style-item[data-v-f0db620e]{cursor:pointer;color:#595959;border-radius:4px;align-items:center;gap:6px;padding:6px 10px;font-size:13px;display:flex}.hover-style-item[data-v-f0db620e]:hover{background:#f7f8fa}.hover-style-item.active[data-v-f0db620e]{color:#3370ff}.style-check[data-v-f0db620e]{color:#3370ff;text-align:center;flex-shrink:0;width:16px;font-size:12px}.style-name[data-v-f0db620e]{font-size:13px}[data-u-comp=rect-popup]:has(.univer-max-w-80){visibility:hidden;pointer-events:none}*,:before,:after,::backdrop{--univer-tw-border-spacing-x:0;--univer-tw-border-spacing-y:0;--univer-tw-translate-x:0;--univer-tw-translate-y:0;--univer-tw-rotate:0;--univer-tw-skew-x:0;--univer-tw-skew-y:0;--univer-tw-scale-x:1;--univer-tw-scale-y:1;--univer-tw-pan-x: ;--univer-tw-pan-y: ;--univer-tw-pinch-zoom: ;--univer-tw-scroll-snap-strictness:proximity;--univer-tw-gradient-from-position: ;--univer-tw-gradient-via-position: ;--univer-tw-gradient-to-position: ;--univer-tw-ordinal: ;--univer-tw-slashed-zero: ;--univer-tw-numeric-figure: ;--univer-tw-numeric-spacing: ;--univer-tw-numeric-fraction: ;--univer-tw-ring-inset: ;--univer-tw-ring-offset-width:0px;--univer-tw-ring-offset-color:#fff;--univer-tw-ring-color:#93c5fd80;--univer-tw-ring-offset-shadow:0 0 #0000;--univer-tw-ring-shadow:0 0 #0000;--univer-tw-shadow:0 0 #0000;--univer-tw-shadow-colored:0 0 #0000;--univer-tw-blur: ;--univer-tw-brightness: ;--univer-tw-contrast: ;--univer-tw-grayscale: ;--univer-tw-hue-rotate: ;--univer-tw-invert: ;--univer-tw-saturate: ;--univer-tw-sepia: ;--univer-tw-drop-shadow: ;--univer-tw-backdrop-blur: ;--univer-tw-backdrop-brightness: ;--univer-tw-backdrop-contrast: ;--univer-tw-backdrop-grayscale: ;--univer-tw-backdrop-hue-rotate: ;--univer-tw-backdrop-invert: ;--univer-tw-backdrop-opacity: ;--univer-tw-backdrop-saturate: ;--univer-tw-backdrop-sepia: ;--univer-tw-contain-size: ;--univer-tw-contain-layout: ;--univer-tw-contain-paint: ;--univer-tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}.univer-sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.univer-inset-x-0{left:0;right:0}.univer-bottom-0\\.5{bottom:.125rem}.univer-bottom-6{bottom:1.5rem}.univer-left-0\\.5{left:.125rem}.univer-left-2{left:.5rem}.univer-left-\\[-16px\\]{left:-16px}.univer-right-4{right:1rem}.univer-right-px{right:1px}.univer-top-px{top:1px}.univer-z-0{z-index:0}.univer-z-\\[1081\\]{z-index:1081}.-univer-mx-1{margin-left:-.25rem;margin-right:-.25rem}.univer-ml-auto{margin-left:auto}.\\!univer-hidden{display:none!important}.univer-size-2{width:.5rem;height:.5rem}.univer-size-2\\.5{width:.625rem;height:.625rem}.univer-h-1\\/2{height:50%}.univer-h-12{height:3rem}.univer-h-2{height:.5rem}.univer-h-32{height:8rem}.univer-h-48{height:12rem}.univer-h-\\[150px\\]{height:150px}.univer-h-\\[calc\\(100\\%-2px\\)\\]{height:calc(100% - 2px)}.univer-max-h-0{max-height:0}.univer-max-h-80{max-height:20rem}.univer-max-h-\\[--radix-popper-available-height\\]{max-height:var(--radix-popper-available-height)}.univer-max-h-\\[1000px\\]{max-height:1000px}.univer-max-h-\\[40vh\\]{max-height:40vh}.univer-max-h-full{max-height:100%}.univer-max-h-screen{max-height:100vh}.univer-min-h-3\\.5{min-height:.875rem}.univer-min-h-\\[520px\\]{min-height:520px}.\\!univer-w-fit{width:fit-content!important}.univer-w-64{width:16rem}.univer-w-72{width:18rem}.univer-w-80{width:20rem}.univer-w-\\[calc\\(100\\%-16px\\)\\]{width:calc(100% - 16px)}.univer-min-w-36{min-width:9rem}.univer-min-w-\\[320px\\]{min-width:320px}.univer-max-w-2xl{max-width:42rem}.univer-max-w-\\[520px\\]{max-width:520px}.univer-max-w-\\[60vw\\]{max-width:60vw}.univer-max-w-sm{max-width:24rem}.univer-max-w-xs{max-width:20rem}.univer-shrink{flex-shrink:1}.univer-shrink-0{flex-shrink:0}.univer-origin-\\[--radix-hover-card-content-transform-origin\\]{transform-origin:var(--radix-hover-card-content-transform-origin)}.-univer-translate-y-1\\/2,.univer--translate-y-1\\/2{--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-translate-x-3{--univer-tw-translate-x:.75rem;transform:translate(.75rem,var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.-univer-rotate-90{--univer-tw-rotate:-90deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(-90deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-rotate-0{--univer-tw-rotate:0deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(0) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-rotate-45{--univer-tw-rotate:45deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(45deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-rotate-\\[-90deg\\]{--univer-tw-rotate:-90deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(-90deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.\\!univer-animate-none{animation:none!important}.univer-cursor-crosshair{cursor:crosshair}.univer-cursor-grabbing{cursor:grabbing}.univer-resize{resize:both}.univer-grid-flow-row{grid-auto-flow:row}.univer-grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.univer-flex-col-reverse{flex-direction:column-reverse}.univer-content-center{align-content:center}.univer-gap-5{gap:1.25rem}.univer-space-y-1\\.5>:not([hidden])~:not([hidden]){--univer-tw-space-y-reverse:0;margin-top:calc(.375rem * (1 - var(--univer-tw-space-y-reverse)));margin-top:.375rem;margin-top:calc(.375rem * calc(1 - var(--univer-tw-space-y-reverse)));margin-bottom:0;margin-bottom:calc(.375rem * var(--univer-tw-space-y-reverse))}.univer-divide-x>:not([hidden])~:not([hidden]){--univer-tw-divide-x-reverse:0;border-right-width:0;border-right-width:calc(1px * var(--univer-tw-divide-x-reverse));border-left-width:calc(1px * (1 - var(--univer-tw-divide-x-reverse)));border-left-width:1px;border-left-width:calc(1px * calc(1 - var(--univer-tw-divide-x-reverse)))}.univer-divide-y-0>:not([hidden])~:not([hidden]){--univer-tw-divide-y-reverse:0;border-top-width:calc(0px * (1 - var(--univer-tw-divide-y-reverse)));border-top-width:0;border-top-width:calc(0px * calc(1 - var(--univer-tw-divide-y-reverse)));border-bottom-width:0;border-bottom-width:calc(0px * var(--univer-tw-divide-y-reverse))}.univer-text-ellipsis{text-overflow:ellipsis}.univer-text-balance{text-wrap:balance}.\\!univer-rounded-b-none{border-bottom-right-radius:0!important;border-bottom-left-radius:0!important}.\\!univer-rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.\\!univer-rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.\\!univer-rounded-t-none{border-top-left-radius:0!important;border-top-right-radius:0!important}.univer-rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.\\!univer-border-l-0{border-left-width:0!important}.\\!univer-border-t-0{border-top-width:0!important}.univer-border-b-0{border-bottom-width:0}.univer-border-l{border-left-width:1px}.univer-border-l-0{border-left-width:0}.univer-border-r{border-right-width:1px}.univer-border-t-0{border-top-width:0}.univer-border-dashed{border-style:dashed}.\\!univer-border-gray-200{border-color:var(--univer-gray-200)!important}.univer-border-gray-300{border-color:var(--univer-gray-300)}.univer-border-primary-200{border-color:var(--univer-primary-200)}.univer-border-primary-300{border-color:var(--univer-primary-300)}.univer-border-red-300{border-color:var(--univer-red-300)}.univer-border-red-500{border-color:var(--univer-red-500)}.univer-border-white{border-color:var(--univer-white)}.\\!univer-bg-primary-600{background-color:var(--univer-primary-600)!important}.univer-bg-\\[rgba\\(0\\,0\\,0\\,0\\.8\\)\\]{background-color:#000c}.univer-bg-gray-800{background-color:var(--univer-gray-800)}.univer-bg-gray-900{background-color:var(--univer-gray-900)}.univer-bg-primary-500{background-color:var(--univer-primary-500)}.univer-bg-red-500{background-color:var(--univer-red-500)}.univer-bg-sky-100\\/70{background-color:#e0f2feb3}.univer-bg-slate-100\\/80{background-color:#f1f5f9cc}.univer-bg-slate-900\\/90{background-color:#0f172ae6}.univer-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--univer-tw-gradient-stops))}.univer-from-slate-100{--univer-tw-gradient-from:#f1f5f9 var(--univer-tw-gradient-from-position);--univer-tw-gradient-to:#f1f5f900 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)}.univer-via-cyan-50{--univer-tw-gradient-to:#ecfeff00 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), #ecfeff var(--univer-tw-gradient-via-position), var(--univer-tw-gradient-to)}.univer-to-blue-100{--univer-tw-gradient-to:var(--univer-blue-100) var(--univer-tw-gradient-to-position)}.univer-fill-current{fill:currentColor}.\\!univer-p-2\\.5{padding:.625rem!important}.univer-p-6{padding:1.5rem}.\\!univer-pl-4{padding-left:1rem!important}.univer-pb-2\\.5{padding-bottom:.625rem}.univer-pl-8{padding-left:2rem}.univer-pr-32{padding-right:8rem}.univer-pr-8{padding-right:2rem}.univer-pt-4{padding-top:1rem}.univer-align-middle{vertical-align:middle}.univer-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.univer-text-\\[13px\\]{font-size:13px}.univer-text-\\[8px\\]{font-size:8px}.univer-text-sm\\/8{font-size:.875rem;line-height:2rem}.univer-text-xs\\/6{font-size:.75rem;line-height:1.5rem}.univer-leading-9{line-height:2.25rem}.univer-leading-normal{line-height:1.5}.univer-tracking-wide{letter-spacing:.025em}.univer-tracking-widest{letter-spacing:.1em}.\\!univer-text-primary-500{color:var(--univer-primary-500)!important}.univer-text-amber-500{--univer-tw-text-opacity:1;color:rgba(245,158,11,var(--univer-tw-text-opacity,1))}.univer-text-cyan-700{--univer-tw-text-opacity:1;color:rgba(14,116,144,var(--univer-tw-text-opacity,1))}.univer-text-sky-500{--univer-tw-text-opacity:1;color:rgba(14,165,233,var(--univer-tw-text-opacity,1))}.univer-text-sky-700{--univer-tw-text-opacity:1;color:rgba(3,105,161,var(--univer-tw-text-opacity,1))}.univer-text-sky-900{--univer-tw-text-opacity:1;color:rgba(12,74,110,var(--univer-tw-text-opacity,1))}.univer-text-slate-500{--univer-tw-text-opacity:1;color:rgba(100,116,139,var(--univer-tw-text-opacity,1))}.univer-text-slate-600{--univer-tw-text-opacity:1;color:rgba(71,85,105,var(--univer-tw-text-opacity,1))}.univer-text-slate-700{--univer-tw-text-opacity:1;color:rgba(51,65,85,var(--univer-tw-text-opacity,1))}.univer-text-slate-800{--univer-tw-text-opacity:1;color:rgba(30,41,59,var(--univer-tw-text-opacity,1))}.univer-text-violet-500{--univer-tw-text-opacity:1;color:rgba(139,92,246,var(--univer-tw-text-opacity,1))}.univer-underline-offset-4{text-underline-offset:4px}.univer-opacity-100{opacity:1}.univer-opacity-50{opacity:.5}.univer-opacity-80{opacity:.8}.univer-shadow-\\[0_30px_60px_-35px_rgba\\(15\\,23\\,42\\,0\\.55\\)\\]{--univer-tw-shadow:0 30px 60px -35px #0f172a8c;--univer-tw-shadow-colored:0 30px 60px -35px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 30px 60px -35px #0f172a8c;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-shadow-inner{--univer-tw-shadow:inset 0 2px 4px 0 #0000000d;--univer-tw-shadow-colored:inset 0 2px 4px 0 var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,inset 0 2px 4px #0000000d;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-ring-2{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.\\!univer-ring-primary-900{--univer-tw-ring-color:var(--univer-primary-900)!important}.univer-ring-primary-50{--univer-tw-ring-color:var(--univer-primary-50)}.univer-ring-white{--univer-tw-ring-color:var(--univer-white)}.univer-ring-offset-2{--univer-tw-ring-offset-width:2px}.\\!univer-ring-offset-gray-600{--univer-tw-ring-offset-color:var(--univer-gray-600)!important}.univer-ring-offset-white{--univer-tw-ring-offset-color:var(--univer-white)}.univer-drop-shadow-sm{--univer-tw-drop-shadow:drop-shadow(0 1px 1px #0000000d);filter:var(--univer-tw-blur) var(--univer-tw-brightness) var(--univer-tw-contrast) var(--univer-tw-grayscale) var(--univer-tw-hue-rotate) var(--univer-tw-invert) var(--univer-tw-saturate) var(--univer-tw-sepia) var(--univer-tw-drop-shadow)}.univer-transition-\\[color\\,box-shadow\\]{transition-property:color,box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-\\[max-height\\,opacity\\]{transition-property:max-height,opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-opacity{transition-property:opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-duration-150{transition-duration:.15s}.univer-duration-500{transition-duration:.5s}.univer-duration-75{transition-duration:75ms}.univer-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.univer-will-change-transform{will-change:transform}.univer-scrollbar-thin::-webkit-scrollbar-track{background-color:var(--scrollbar-track);border-radius:var(--scrollbar-track-radius)}.univer-scrollbar-thin::-webkit-scrollbar-track:hover{background-color:var(--scrollbar-track-hover,var(--scrollbar-track))}.univer-scrollbar-thin::-webkit-scrollbar-track:active{background-color:var(--scrollbar-track-active,var(--scrollbar-track-hover,var(--scrollbar-track)))}.univer-scrollbar-thin::-webkit-scrollbar-thumb{background-color:var(--scrollbar-thumb);border-radius:var(--scrollbar-thumb-radius)}.univer-scrollbar-thin::-webkit-scrollbar-thumb:hover{background-color:var(--scrollbar-thumb-hover,var(--scrollbar-thumb))}.univer-scrollbar-thin::-webkit-scrollbar-thumb:active{background-color:var(--scrollbar-thumb-active,var(--scrollbar-thumb-hover,var(--scrollbar-thumb)))}.univer-scrollbar-thin::-webkit-scrollbar-corner{background-color:var(--scrollbar-corner);border-radius:var(--scrollbar-corner-radius)}.univer-scrollbar-thin::-webkit-scrollbar-corner:hover{background-color:var(--scrollbar-corner-hover,var(--scrollbar-corner))}.univer-scrollbar-thin::-webkit-scrollbar-corner:active{background-color:var(--scrollbar-corner-active,var(--scrollbar-corner-hover,var(--scrollbar-corner)))}.univer-scrollbar-thin{scrollbar-width:thin;scrollbar-color:initial initial;scrollbar-color:var(--scrollbar-thumb,initial) var(--scrollbar-track,initial)}.univer-scrollbar-thin::-webkit-scrollbar{width:8px;height:8px;display:block}.univer-scrollbar-track-gray-50{--scrollbar-track:var(--univer-gray-50)!important}.univer-scrollbar-thumb-gray-300{--scrollbar-thumb:var(--univer-gray-300)!important}.univer-animate-out{--univer-tw-exit-opacity:initial;--univer-tw-exit-scale:initial;--univer-tw-exit-rotate:initial;--univer-tw-exit-translate-x:initial;--univer-tw-exit-translate-y:initial;animation-name:exit;animation-duration:.15s}.univer-fade-in,.univer-fade-in-0{--univer-tw-enter-opacity:0}.univer-fade-out{--univer-tw-exit-opacity:0}.univer-zoom-in-95{--univer-tw-enter-scale:.95}.univer-duration-150{animation-duration:.15s}.univer-duration-200{animation-duration:.2s}.univer-duration-300{animation-duration:.3s}.univer-duration-500{animation-duration:.5s}.univer-duration-75{animation-duration:75ms}.univer-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.univer-ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.placeholder\\:univer-text-gray-200::placeholder{color:var(--univer-gray-200)}.placeholder\\:univer-text-gray-400::placeholder{color:var(--univer-gray-400)}.before\\:univer-absolute:before{content:var(--univer-tw-content);position:absolute}.before\\:univer-top-1\\/2:before{content:var(--univer-tw-content);top:50%}.before\\:univer-block:before{content:var(--univer-tw-content);display:block}.before\\:univer-h-px:before{content:var(--univer-tw-content);height:1px}.before\\:univer-w-full:before{content:var(--univer-tw-content);width:100%}.before\\:-univer-translate-y-1\\/2:before{content:var(--univer-tw-content);--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.before\\:univer-bg-gray-200:before{content:var(--univer-tw-content);background-color:var(--univer-gray-200)}.before\\:univer-content-\\[\\"\\"\\]:before{--univer-tw-content:"";content:"";content:var(--univer-tw-content)}.data-\\[disabled\\]\\:univer-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[orientation\\=horizontal\\]\\:univer-h-px[data-orientation=horizontal]{height:1px}.data-\\[orientation\\=vertical\\]\\:univer-h-full[data-orientation=vertical]{height:100%}.data-\\[orientation\\=horizontal\\]\\:univer-w-full[data-orientation=horizontal]{width:100%}.data-\\[orientation\\=vertical\\]\\:univer-w-px[data-orientation=vertical]{width:1px}.data-\\[state\\=open\\]\\:univer-bg-gray-100[data-state=open]{background-color:var(--univer-gray-100)}.data-\\[disabled\\]\\:univer-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=open\\]\\:univer-animate-in[data-state=open]{--univer-tw-enter-opacity:initial;--univer-tw-enter-scale:initial;--univer-tw-enter-rotate:initial;--univer-tw-enter-translate-x:initial;--univer-tw-enter-translate-y:initial;animation-name:enter;animation-duration:.15s}.data-\\[state\\=closed\\]\\:univer-animate-out[data-state=closed]{--univer-tw-exit-opacity:initial;--univer-tw-exit-scale:initial;--univer-tw-exit-rotate:initial;--univer-tw-exit-translate-x:initial;--univer-tw-exit-translate-y:initial;animation-name:exit;animation-duration:.15s}.data-\\[state\\=closed\\]\\:univer-fade-out-0[data-state=closed]{--univer-tw-exit-opacity:0}.data-\\[state\\=open\\]\\:univer-fade-in-0[data-state=open]{--univer-tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:univer-zoom-out-95[data-state=closed]{--univer-tw-exit-scale:.95}.data-\\[state\\=open\\]\\:univer-zoom-in-95[data-state=open]{--univer-tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:univer-slide-in-from-top-2[data-side=bottom]{--univer-tw-enter-translate-y:-.5rem}.data-\\[side\\=left\\]\\:univer-slide-in-from-right-2[data-side=left]{--univer-tw-enter-translate-x:.5rem}.data-\\[side\\=right\\]\\:univer-slide-in-from-left-2[data-side=right]{--univer-tw-enter-translate-x:-.5rem}.data-\\[side\\=top\\]\\:univer-slide-in-from-bottom-2[data-side=top]{--univer-tw-enter-translate-y:.5rem}.data-\\[state\\=closed\\]\\:univer-slide-out-to-left-1\\/2[data-state=closed]{--univer-tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:univer-slide-out-to-top-\\[48\\%\\][data-state=closed]{--univer-tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:univer-slide-in-from-left-1\\/2[data-state=open]{--univer-tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:univer-slide-in-from-top-\\[48\\%\\][data-state=open]{--univer-tw-enter-translate-y:-48%}.hover\\:univer-border-red-400:hover{border-color:var(--univer-red-400)}.hover\\:univer-border-transparent:hover{border-color:#0000}.hover\\:univer-bg-primary-500:hover{background-color:var(--univer-primary-500)}.hover\\:univer-bg-red-400:hover{background-color:var(--univer-red-400)}.hover\\:univer-text-gray-500:hover{color:var(--univer-gray-500)}.hover\\:univer-text-primary-500:hover{color:var(--univer-primary-500)}.hover\\:univer-text-white:hover{color:var(--univer-white)}.hover\\:univer-underline:hover{text-decoration-line:underline}.hover\\:univer-opacity-100:hover{opacity:1}.hover\\:univer-opacity-70:hover{opacity:.7}.hover\\:univer-opacity-80:hover{opacity:.8}.focus\\:univer-border-primary-600:focus{border-color:var(--univer-primary-600)}.focus\\:univer-bg-gray-100:focus{background-color:var(--univer-gray-100)}.focus\\:univer-ring-primary-50:focus{--univer-tw-ring-color:var(--univer-primary-50)}.active\\:univer-border-red-600:active{border-color:var(--univer-red-600)}.active\\:univer-bg-primary-700:active{background-color:var(--univer-primary-700)}.active\\:univer-bg-red-600:active{background-color:var(--univer-red-600)}.active\\:univer-text-primary-700:active{color:var(--univer-primary-700)}.disabled\\:univer-pointer-events-none:disabled{pointer-events:none}.disabled\\:univer-opacity-50:disabled{opacity:.5}@media (width>=640px){.sm\\:\\!univer-flex-row{flex-direction:row!important}.sm\\:\\!univer-justify-end{justify-content:flex-end!important}.sm\\:\\!univer-space-x-2>:not([hidden])~:not([hidden]){--univer-tw-space-x-reverse:0!important;margin-right:0!important;margin-right:calc(.5rem * var(--univer-tw-space-x-reverse))!important;margin-left:calc(.5rem * (1 - var(--univer-tw-space-x-reverse)))!important;margin-left:.5rem!important;margin-left:calc(.5rem * calc(1 - var(--univer-tw-space-x-reverse)))!important}.sm\\:\\!univer-rounded-lg{border-radius:.5rem!important}.sm\\:\\!univer-text-left{text-align:left!important}}@media (width>=768px){.md\\:univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.rtl\\:univer-left-px:where([dir=rtl],[dir=rtl] *){left:1px}.rtl\\:univer-right-auto:where([dir=rtl],[dir=rtl] *){right:auto}.rtl\\:univer-rounded-l-md:where([dir=rtl],[dir=rtl] *){border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rtl\\:univer-rounded-r-none:where([dir=rtl],[dir=rtl] *){border-top-right-radius:0;border-bottom-right-radius:0}.rtl\\:univer-border-l-0:where([dir=rtl],[dir=rtl] *){border-left-width:0}.rtl\\:univer-border-r:where([dir=rtl],[dir=rtl] *){border-right-width:1px}.dark\\:\\!univer-border-gray-500:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-500)!important}.dark\\:\\!univer-border-primary-700:where(.univer-dark,.univer-dark *){border-color:var(--univer-primary-700)!important}.dark\\:\\!univer-bg-gray-100:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-100)!important}.dark\\:\\!univer-bg-primary-600:where(.univer-dark,.univer-dark *){background-color:var(--univer-primary-600)!important}.dark\\:\\!univer-text-gray-900:where(.univer-dark,.univer-dark *){color:var(--univer-gray-900)!important}.dark\\:\\!univer-text-primary-500:where(.univer-dark,.univer-dark *){color:var(--univer-primary-500)!important}.dark\\:\\!univer-text-sky-400:where(.univer-dark,.univer-dark *){--univer-tw-text-opacity:1!important;color:rgba(56,189,248,var(--univer-tw-text-opacity,1))!important}.dark\\:\\!univer-ring-primary-600:where(.univer-dark,.univer-dark *){--univer-tw-ring-color:var(--univer-primary-600)!important}.dark\\:\\!univer-ring-primary-900:where(.univer-dark,.univer-dark *){--univer-tw-ring-color:var(--univer-primary-900)!important}.dark\\:\\!univer-ring-offset-gray-600:where(.univer-dark,.univer-dark *){--univer-tw-ring-offset-color:var(--univer-gray-600)!important}.dark\\:\\!univer-scrollbar-track-gray-900:where(.univer-dark,.univer-dark *){--scrollbar-track:var(--univer-gray-900)!important}.dark\\:\\!univer-scrollbar-thumb-gray-700:where(.univer-dark,.univer-dark *){--scrollbar-thumb:var(--univer-gray-700)!important}.dark\\:before\\:\\!univer-bg-gray-600:where(.univer-dark,.univer-dark *):before{content:var(--univer-tw-content);background-color:var(--univer-gray-600)!important}.dark\\:data-\\[state\\=open\\]\\:\\!univer-bg-gray-600[data-state=open]:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:hover\\:\\!univer-text-white:hover:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\\:focus\\:\\!univer-border-primary-500:focus:where(.univer-dark,.univer-dark *){border-color:var(--univer-primary-500)!important}.dark\\:focus\\:\\!univer-bg-gray-600:focus:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:focus\\:\\!univer-ring-primary-900:focus:where(.univer-dark,.univer-dark *){--univer-tw-ring-color:var(--univer-primary-900)!important}.dark\\:focus-visible\\:\\!univer-border-gray-600:focus-visible:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\\:active\\:\\!univer-bg-gray-700:active:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.\\[\\&\\:\\:-webkit-calendar-picker-indicator\\]\\:univer-hidden::-webkit-calendar-picker-indicator{display:none}.\\[\\&\\:\\:-webkit-calendar-picker-indicator\\]\\:univer-appearance-none::-webkit-calendar-picker-indicator{appearance:none}.\\[\\&\\>input\\]\\:univer-w-11>input{width:2.75rem}.\\[\\&\\>input\\]\\:univer-border-gray-200>input{border-color:var(--univer-gray-200)}.\\[\\&\\>input\\]\\:focus\\:univer-border-primary-500:focus>input{border-color:var(--univer-primary-500)}.dark\\:\\[\\&\\>input\\]\\:\\!univer-border-gray-600>input:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\\:\\[\\&\\>input\\]\\:\\!univer-text-white>input:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.\\[\\&\\>svg\\]\\:univer-block>svg{display:block}.\\[\\&\\>svg\\]\\:univer-size-4>svg{width:1rem;height:1rem}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-0>ul:not(:last-child){border-width:0}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-r>ul:not(:last-child){border-right-width:1px}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-solid>ul:not(:last-child){border-style:solid}.\\[\\&\\>ul\\:not\\(\\:last-child\\)\\]\\:univer-border-r-gray-200>ul:not(:last-child){border-right-color:var(--univer-gray-200)}.\\[\\&_\\[data-description\\]\\]\\:univer-text-sm [data-description]{font-size:.875rem;line-height:1.25rem}.\\[\\&_\\[data-description\\]\\]\\:univer-text-gray-200 [data-description]{color:var(--univer-gray-200)}.\\[\\&_\\[data-description\\]\\]\\:univer-text-gray-600 [data-description]{color:var(--univer-gray-600)}.\\[\\&_\\[data-icon\\]\\>svg\\]\\:univer-relative [data-icon]>svg{position:relative}.\\[\\&_\\[data-icon\\]\\>svg\\]\\:univer-top-1 [data-icon]>svg{top:.25rem}.\\[\\&_\\[data-icon\\]\\]\\:univer-self-baseline [data-icon]{align-self:baseline}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-amber-500 [data-icon]{--univer-tw-text-opacity:1;color:rgba(245,158,11,var(--univer-tw-text-opacity,1))}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-green-500 [data-icon]{color:var(--univer-green-500)}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-primary-600 [data-icon]{color:var(--univer-primary-600)}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-red-500 [data-icon]{color:var(--univer-red-500)}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-sky-500 [data-icon]{--univer-tw-text-opacity:1;color:rgba(14,165,233,var(--univer-tw-text-opacity,1))}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-violet-500 [data-icon]{--univer-tw-text-opacity:1;color:rgba(139,92,246,var(--univer-tw-text-opacity,1))}.\\[\\&_\\[data-icon\\]\\]\\:univer-text-yellow-500 [data-icon]{color:var(--univer-yellow-500)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-rounded-2xl [data-sonner-toast]{border-radius:1rem}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-border [data-sonner-toast]{border-width:1px}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-border-solid [data-sonner-toast]{border-style:solid}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-border-gray-200 [data-sonner-toast]{border-color:var(--univer-gray-200)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-shadow-\\[0_16px_40px_-20px_rgba\\(15\\,23\\,42\\,0\\.55\\)\\] [data-sonner-toast]{--univer-tw-shadow:0 16px 40px -20px #0f172a8c;--univer-tw-shadow-colored:0 16px 40px -20px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 16px 40px -20px #0f172a8c;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-shadow-md [data-sonner-toast]{--univer-tw-shadow:0px 1px 6px -2px #1e284d14, 0px 2px 6px -1px #1e284d1a;--univer-tw-shadow-colored:0px 1px 6px -2px var(--univer-tw-shadow-color), 0px 2px 6px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.\\[\\&_\\[data-sonner-toast\\]\\]\\:univer-backdrop-blur-sm [data-sonner-toast]{--univer-tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.dark\\:\\[\\&_\\[data-sonner-toast\\]\\]\\:\\!univer-border-gray-600 [data-sonner-toast]:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.\\[\\&_\\[data-title\\]\\]\\:univer-text-sm [data-title]{font-size:.875rem;line-height:1.25rem}.\\[\\&_\\[data-title\\]\\]\\:univer-text-gray-900 [data-title]{color:var(--univer-gray-900)}.\\[\\&_\\[data-u-comp\\=form-layout\\]\\]\\:univer-max-w-\\[calc\\(50\\%-8px\\)\\] [data-u-comp=form-layout]{max-width:calc(50% - 8px)}.\\[\\&_\\[data-u-comp\\=form-layout\\]\\]\\:univer-shrink [data-u-comp=form-layout]{flex-shrink:1}.\\[\\&_\\[data-u-comp\\=form-layout\\]\\]\\:univer-grow [data-u-comp=form-layout]{flex-grow:1}.\\[\\&_\\[data-u-comp\\=input\\]\\]\\:univer-w-full [data-u-comp=input]{width:100%}.\\[\\&_\\[data-u-comp\\=input\\]\\]\\:univer-border-red-500 [data-u-comp=input]{border-color:var(--univer-red-500)}.\\[\\&_\\[data-u-comp\\=pager-left-arrow\\]\\:hover\\]\\:\\!univer-bg-gray-600 [data-u-comp=pager-left-arrow]:hover,.\\[\\&_\\[data-u-comp\\=pager-right-arrow\\]\\:hover\\]\\:\\!univer-bg-gray-600 [data-u-comp=pager-right-arrow]:hover{background-color:var(--univer-gray-600)!important}.\\[\\&_\\[data-u-comp\\=select\\]\\]\\:univer-w-full [data-u-comp=select]{width:100%}.\\[\\&_\\[data-u-comp\\=select\\]\\]\\:univer-border-red-500 [data-u-comp=select]{border-color:var(--univer-red-500)}.\\[\\&_input\\]\\:univer-box-border input{box-sizing:border-box}.\\[\\&_input\\]\\:univer-flex input{display:flex}.\\[\\&_input\\]\\:univer-h-7 input{height:1.75rem}.\\[\\&_input\\]\\:univer-items-center input{align-items:center}.\\[\\&_input\\]\\:univer-rounded input{border-radius:.25rem}.\\[\\&_input\\]\\:univer-border input{border-width:1px}.\\[\\&_input\\]\\:univer-border-solid input{border-style:solid}.\\[\\&_input\\]\\:univer-border-gray-200 input{border-color:var(--univer-gray-200)}.\\[\\&_input\\]\\:univer-border-gray-600 input{border-color:var(--univer-gray-600)}.\\[\\&_input\\]\\:univer-bg-transparent input{background-color:#0000}.\\[\\&_input\\]\\:univer-px-1\\.5 input{padding-left:.375rem;padding-right:.375rem}.\\[\\&_input\\]\\:univer-text-gray-700 input{color:var(--univer-gray-700)}.\\[\\&_input\\]\\:univer-text-white input{color:var(--univer-white)}.\\[\\&_input\\]\\:univer-outline-none input{outline-offset:2px;outline:2px solid #0000}.\\[\\&_svg\\]\\:univer-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:univer-size-4 svg{width:1rem;height:1rem}.\\[\\&_svg\\]\\:univer-shrink-0 svg{flex-shrink:0}.univer-popup{z-index:1070;--univer-tw-shadow:0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;--univer-tw-shadow-colored:0 1px 3px 0 var(--univer-tw-shadow-color), 0 1px 2px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow);border-radius:6px;position:fixed;top:-9999px;left:-9999px;overflow:hidden}.univer-popup-enter{transform-origin:0 0;opacity:0;animation-duration:.15s;animation-timing-function:cubic-bezier(.08,.82,.17,1);animation-play-state:paused;animation-fill-mode:both}.univer-popup-enter-active{animation-name:popup-slide-up-in;animation-play-state:running}.univer-popup-exit{transform-origin:0 0;opacity:1;animation-name:popup-slide-up-out;animation-duration:.15s;animation-timing-function:cubic-bezier(.6,.04,.98,.34);animation-play-state:running;animation-fill-mode:both}.univer-popup-exit-active{display:none}.univer-popup-mask{z-index:1060;position:fixed;inset:0}.univer-pointer-events-auto{pointer-events:auto}.univer-invisible{visibility:hidden}.univer-sticky{position:sticky}.-univer-left-\\[99999\\]{left:-99999px}.-univer-top-\\[99999\\]{top:-99999px}.univer-left-1\\/2{left:50%}.univer-left-\\[-9999px\\]{left:-9999px}.univer-right-2{right:.5rem}.univer-top-\\[-9999px\\]{top:-9999px}.univer-top-\\[calc\\(50\\%-6px\\)\\]{top:calc(50% - 6px)}.univer-z-20{z-index:20}.univer-z-\\[-1\\]{z-index:-1}.univer-z-\\[1020\\]{z-index:1020}.univer-z-\\[1080\\]{z-index:1080}.univer-z-\\[1\\]{z-index:1}.univer-mx-2{margin-left:.5rem;margin-right:.5rem}.univer-mx-auto{margin-left:auto;margin-right:auto}.univer-line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.\\!univer-size-3\\.5{width:.875rem!important;height:.875rem!important}.univer-size-12{width:3rem;height:3rem}.univer-size-3\\.5{width:.875rem;height:.875rem}.univer-size-7{width:1.75rem;height:1.75rem}.univer-size-9{width:2.25rem;height:2.25rem}.univer-h-0{height:0}.univer-h-1\\.5{height:.375rem}.univer-max-h-\\[80vh\\]{max-height:80vh}.univer-max-h-\\[min\\(72vh\\,560px\\)\\]{max-height:min(72vh,560px)}.univer-min-h-\\[560px\\]{min-height:560px}.univer-min-h-\\[56px\\]{min-height:56px}.univer-min-h-full{min-height:100%}.univer-w-0{width:0}.univer-w-1{width:.25rem}.univer-w-10{width:2.5rem}.univer-w-40{width:10rem}.univer-w-7{width:1.75rem}.univer-w-8{width:2rem}.univer-w-96{width:24rem}.univer-w-max{width:max-content}.univer-w-screen{width:100vw}.univer-min-w-52{min-width:13rem}.univer-min-w-6{min-width:1.5rem}.univer-min-w-min{min-width:min-content}.univer-max-w-3xl{max-width:48rem}.univer-max-w-5xl{max-width:64rem}.univer-max-w-96{max-width:24rem}.univer-max-w-\\[--radix-popper-available-width\\]{max-width:var(--radix-popper-available-width)}.univer-max-w-\\[32\\%\\]{max-width:32%}.univer-max-w-\\[560px\\]{max-width:560px}.univer-max-w-\\[calc\\(100vw-16px\\)\\]{max-width:calc(100vw - 16px)}.univer-max-w-full{max-width:100%}.univer-origin-center{transform-origin:50%}.-univer-translate-x-1\\/2{--univer-tw-translate-x:-50%;transform:translate(-50%,var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-translate-x-0{--univer-tw-translate-x:0px;transform:translateY(var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-translate-x-full{--univer-tw-translate-x:100%;transform:translate(100%,var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-cursor-col-resize{cursor:col-resize}.univer-grid-cols-\\[1fr\\]{grid-template-columns:1fr}.univer-grid-cols-\\[22px_minmax\\(0\\,1fr\\)_22px\\]{grid-template-columns:22px minmax(0,1fr) 22px}.univer-grid-cols-\\[28px_minmax\\(0\\,1fr\\)_auto\\]{grid-template-columns:28px minmax(0,1fr) auto}.univer-grid-cols-\\[32px_minmax\\(0\\,1fr\\)_32px\\]{grid-template-columns:32px minmax(0,1fr) 32px}.univer-grid-cols-\\[auto\\,1fr\\]{grid-template-columns:auto 1fr}.univer-grid-cols-\\[auto_1fr_auto\\]{grid-template-columns:auto 1fr auto}.univer-grid-rows-\\[100\\%\\]{grid-template-rows:100%}.univer-grid-rows-\\[auto_1fr\\]{grid-template-rows:auto 1fr}.univer-grid-rows-\\[auto_1fr_auto\\]{grid-template-rows:auto 1fr auto}.univer-flex-wrap{flex-wrap:wrap}.univer-items-end{align-items:flex-end}.univer-gap-0\\.5{gap:.125rem}.univer-overscroll-contain{overscroll-behavior:contain}.univer-scroll-smooth{scroll-behavior:smooth}.\\!univer-rounded-full{border-radius:9999px!important}.\\!univer-rounded-xl{border-radius:.75rem!important}.univer-rounded-2xl{border-radius:1rem}.univer-rounded-3xl{border-radius:1.5rem}.univer-rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.univer-rounded-t-\\[28px\\]{border-top-left-radius:28px;border-top-right-radius:28px}.univer-border-0{border-width:0}.\\!univer-bg-gray-200{background-color:var(--univer-gray-200)!important}.\\!univer-bg-gray-500{background-color:var(--univer-gray-500)!important}.univer-bg-\\[rgba\\(15\\,23\\,42\\,0\\.32\\)\\]{background-color:#0f172a52}.univer-bg-gray-50{background-color:var(--univer-gray-50)}.univer-bg-gray-700{background-color:var(--univer-gray-700)}.univer-bg-gradient-to-tr{background-image:linear-gradient(to top right,var(--univer-tw-gradient-stops))}.univer-from-slate-950{--univer-tw-gradient-from:#020617 var(--univer-tw-gradient-from-position);--univer-tw-gradient-to:#02061700 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)}.univer-via-blue-950{--univer-tw-gradient-to:#17255400 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), #172554 var(--univer-tw-gradient-via-position), var(--univer-tw-gradient-to)}.univer-to-cyan-900{--univer-tw-gradient-to:#164e63 var(--univer-tw-gradient-to-position)}.univer-p-8{padding:2rem}.univer-px-0{padding-left:0;padding-right:0}.univer-px-0\\.5{padding-left:.125rem;padding-right:.125rem}.univer-px-3{padding-left:.75rem;padding-right:.75rem}.univer-pb-2{padding-bottom:.5rem}.univer-pl-2{padding-left:.5rem}.univer-pl-4{padding-left:1rem}.univer-pr-1\\.5{padding-right:.375rem}.univer-text-right{text-align:right}.univer-font-sans{font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.univer-text-2xl{font-size:1.5rem;line-height:2rem}.univer-uppercase{text-transform:uppercase}.univer-leading-4{line-height:1rem}.univer-leading-none{line-height:1}.univer-tracking-\\[0\\.08em\\]{letter-spacing:.08em}.univer-tracking-tight{letter-spacing:-.025em}.\\!univer-text-gray-600{color:var(--univer-gray-600)!important}.univer-text-current{color:currentColor}.univer-text-slate-200{--univer-tw-text-opacity:1;color:rgba(226,232,240,var(--univer-tw-text-opacity,1))}.univer-underline{text-decoration-line:underline}.univer-opacity-0{opacity:0}.univer-opacity-30{opacity:.3}.univer-opacity-40{opacity:.4}.univer-opacity-60{opacity:.6}.univer-shadow-\\[0_-16px_48px_rgba\\(15\\,23\\,42\\,0\\.18\\)\\]{--univer-tw-shadow:0 -16px 48px #0f172a2e;--univer-tw-shadow-colored:0 -16px 48px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 -16px 48px #0f172a2e;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-ring-0{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(0px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.univer-ring-primary-600{--univer-tw-ring-color:var(--univer-primary-600)}.univer-backdrop-blur-\\[2px\\]{--univer-tw-backdrop-blur:blur(2px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-backdrop-blur-xl{--univer-tw-backdrop-blur:blur(24px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-transition-\\[width\\]{transition-property:width;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-animate-in{--univer-tw-enter-opacity:initial;--univer-tw-enter-scale:initial;--univer-tw-enter-rotate:initial;--univer-tw-enter-translate-x:initial;--univer-tw-enter-translate-y:initial;animation-name:enter;animation-duration:.15s}.univer-fade-in{--univer-tw-enter-opacity:0}.univer-fade-in-70{--univer-tw-enter-opacity:.7}.last\\:univer-border-b-0:last-child{border-bottom-width:0}.empty\\:univer-hidden:empty{display:none}.hover\\:univer-opacity-50:hover{opacity:.5}.focus\\:univer-bg-white:focus{background-color:var(--univer-white)}.focus\\:univer-ring-2:focus{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.focus-visible\\:univer-ring-primary-600:focus-visible{--univer-tw-ring-color:var(--univer-primary-600)}.focus-visible\\:univer-ring-offset-0:focus-visible{--univer-tw-ring-offset-width:0px}.active\\:univer-bg-gray-200:active{background-color:var(--univer-gray-200)}.enabled\\:hover\\:univer-bg-gray-50:hover:enabled{background-color:var(--univer-gray-50)}.enabled\\:active\\:univer-bg-gray-100:active:enabled{background-color:var(--univer-gray-100)}.disabled\\:univer-text-gray-300:disabled{color:var(--univer-gray-300)}.disabled\\:hover\\:univer-bg-transparent:hover:disabled{background-color:#0000}@media (width>=640px){.sm\\:\\!univer-block{display:block!important}}.rtl\\:univer-pl-1\\.5:where([dir=rtl],[dir=rtl] *){padding-left:.375rem}.rtl\\:univer-pr-0:where([dir=rtl],[dir=rtl] *){padding-right:0}.rtl\\:univer-pr-2:where([dir=rtl],[dir=rtl] *){padding-right:.5rem}.dark\\:\\!univer-bg-gray-200:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-200)!important}.dark\\:\\!univer-bg-primary-400:where(.univer-dark,.univer-dark *){background-color:var(--univer-primary-400)!important}.dark\\:\\!univer-text-gray-600:where(.univer-dark,.univer-dark *){color:var(--univer-gray-600)!important}.dark\\:\\!univer-text-gray-800:where(.univer-dark,.univer-dark *){color:var(--univer-gray-800)!important}.dark\\:\\!univer-text-primary-100:where(.univer-dark,.univer-dark *){color:var(--univer-primary-100)!important}.dark\\:\\!univer-text-primary-400:where(.univer-dark,.univer-dark *){color:var(--univer-primary-400)!important}.dark\\:hover\\:\\!univer-bg-transparent:hover:where(.univer-dark,.univer-dark *){background-color:#0000!important}.dark\\:active\\:\\!univer-bg-gray-600:active:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:disabled\\:\\!univer-text-gray-600:disabled:where(.univer-dark,.univer-dark *){color:var(--univer-gray-600)!important}.\\[\\&\\:\\:-webkit-scrollbar\\]\\:univer-hidden::-webkit-scrollbar{display:none}.\\[\\&\\>\\*\\]\\:univer-m-0>*{margin:0}.\\[\\&\\>\\*\\]\\:univer-inline-flex>*{display:inline-flex}.\\[\\&\\>\\*\\]\\:univer-h-6>*{height:1.5rem}.\\[\\&\\>\\*\\]\\:univer-min-h-7>*{min-height:1.75rem}.\\[\\&\\>\\*\\]\\:univer-min-w-7>*{min-width:1.75rem}.\\[\\&\\>\\*\\]\\:univer-appearance-none>*{appearance:none}.\\[\\&\\>\\*\\]\\:univer-items-center>*{align-items:center}.\\[\\&\\>\\*\\]\\:univer-justify-center>*{justify-content:center}.\\[\\&\\>\\*\\]\\:univer-rounded>*{border-radius:.25rem}.\\[\\&\\>\\*\\]\\:univer-rounded-md>*{border-radius:.375rem}.\\[\\&\\>\\*\\]\\:univer-border-0>*{border-width:0}.\\[\\&\\>\\*\\]\\:univer-px-1>*{padding-left:.25rem;padding-right:.25rem}.\\[\\&\\>\\*\\]\\:univer-px-1\\.5>*{padding-left:.375rem;padding-right:.375rem}.\\[\\&\\>\\*\\]\\:univer-leading-none>*{line-height:1}.\\[\\&\\>\\*\\]\\:univer-outline-none>*{outline-offset:2px;outline:2px solid #0000}.\\[\\&\\>\\*\\]\\:univer-transition-colors>*{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:\\[\\&\\>\\*\\]\\:univer-bg-gray-100>:hover{background-color:var(--univer-gray-100)}.\\[\\&\\>span\\]\\:univer-truncate>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.\\[\\&\\>span\\]\\:univer-text-sm>span{font-size:.875rem;line-height:1.25rem}.\\[\\&\\>span\\]\\:univer-font-medium>span{font-weight:500}.\\[\\&\\>svg\\]\\:univer-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:univer-text-lg>svg{font-size:1.125rem;line-height:1.75rem}.\\[\\&\\>svg\\]\\:univer-text-gray-700>svg{color:var(--univer-gray-700)}.\\[\\&_\\*\\]\\:univer-box-border *{box-sizing:border-box}.\\[\\&_\\.univer-custom-label\\]\\:univer-text-sm .univer-custom-label{font-size:.875rem;line-height:1.25rem}.\\[\\&_\\.univer-custom-label\\]\\:univer-leading-none .univer-custom-label{line-height:1}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-h-8 .univer-toolbar-button-selector-main{height:2rem!important}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-rounded-none .univer-toolbar-button-selector-main{border-radius:0!important}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-rounded-l-md .univer-toolbar-button-selector-main{border-top-left-radius:.375rem!important;border-bottom-left-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-button-selector-main\\]\\:\\!univer-px-1\\.5 .univer-toolbar-button-selector-main{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:\\!univer-h-8 .univer-toolbar-button-selector-root{height:2rem!important}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:univer-overflow-hidden .univer-toolbar-button-selector-root{overflow:hidden}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:\\!univer-rounded-md .univer-toolbar-button-selector-root{border-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-button-selector-root\\]\\:\\!univer-pr-0 .univer-toolbar-button-selector-root{padding-right:0!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-static .univer-toolbar-button-selector-trigger{position:static!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-h-8 .univer-toolbar-button-selector-trigger{height:2rem!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-w-6 .univer-toolbar-button-selector-trigger{width:1.5rem!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-rounded-none .univer-toolbar-button-selector-trigger{border-radius:0!important}.\\[\\&_\\.univer-toolbar-button-selector-trigger\\]\\:\\!univer-rounded-r-md .univer-toolbar-button-selector-trigger{border-top-right-radius:.375rem!important;border-bottom-right-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-h-8 .univer-toolbar-selector-root{height:2rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-gap-1 .univer-toolbar-selector-root{gap:.25rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-rounded-md .univer-toolbar-selector-root{border-radius:.375rem!important}.\\[\\&_\\.univer-toolbar-selector-root\\]\\:\\!univer-px-1\\.5 .univer-toolbar-selector-root{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_\\.univer-toolbar-selector-trigger\\]\\:\\!univer-pl-0\\.5 .univer-toolbar-selector-trigger{padding-left:.125rem!important}.\\[\\&_\\.univer-tooltip\\]\\:univer-inline-flex .univer-tooltip{display:inline-flex}.\\[\\&_\\.univer-tooltip\\]\\:univer-h-full .univer-tooltip{height:100%}.\\[\\&_\\.univer-tooltip\\]\\:univer-items-center .univer-tooltip{align-items:center}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-h-8 [data-u-command]{height:2rem!important}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-min-h-8 [data-u-command]{min-height:2rem!important}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-rounded-md [data-u-command]{border-radius:.375rem!important}.\\[\\&_\\[data-u-command\\]\\]\\:\\!univer-px-1\\.5 [data-u-command]{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_button\\]\\:\\!univer-m-0 button{margin:0!important}.\\[\\&_button\\]\\:\\!univer-h-8 button{height:2rem!important}.\\[\\&_button\\]\\:\\!univer-min-w-8 button{min-width:2rem!important}.\\[\\&_button\\]\\:\\!univer-appearance-none button{appearance:none!important}.\\[\\&_button\\]\\:\\!univer-rounded-md button{border-radius:.375rem!important}.\\[\\&_button\\]\\:\\!univer-border-0 button{border-width:0!important}.\\[\\&_button\\]\\:\\!univer-bg-transparent button{background-color:#0000!important}.\\[\\&_button\\]\\:\\!univer-p-0 button{padding:0!important}.\\[\\&_button\\]\\:\\!univer-px-1\\.5 button{padding-left:.375rem!important;padding-right:.375rem!important}.\\[\\&_button\\]\\:\\!univer-leading-none button{line-height:1!important}.\\[\\&_button\\]\\:\\!univer-outline-none button{outline-offset:2px!important;outline:2px solid #0000!important}.\\[\\&_input\\:focus\\]\\:\\!univer-ring-0 input:focus{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color)!important;--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(0px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color)!important;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000!important;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)!important}.\\[\\&_input\\]\\:\\!univer-m-0 input{margin:0!important}.\\[\\&_input\\]\\:univer-h-6 input{height:1.5rem}.\\[\\&_input\\]\\:univer-w-7 input{width:1.75rem}.\\[\\&_input\\]\\:\\!univer-appearance-none input{appearance:none!important}.\\[\\&_input\\]\\:\\!univer-border-0 input{border-width:0!important}.\\[\\&_input\\]\\:univer-border-none input{border-style:none}.\\[\\&_input\\]\\:\\!univer-bg-transparent input{background-color:#0000!important}.\\[\\&_input\\]\\:\\!univer-p-0 input{padding:0!important}.\\[\\&_input\\]\\:univer-p-0 input{padding:0}.\\[\\&_input\\]\\:univer-text-sm input{font-size:.875rem;line-height:1.25rem}.\\[\\&_input\\]\\:\\!univer-leading-none input{line-height:1!important}.\\[\\&_input\\]\\:\\!univer-outline-none input{outline-offset:2px!important;outline:2px solid #0000!important}.univer-fixed{position:fixed}.univer-bottom-0{bottom:0}.univer-left-5{left:1.25rem}.univer-left-\\[5px\\]{left:5px}.univer-top-4{top:1rem}.univer-top-\\[5px\\]{top:5px}.univer-z-\\[10000\\]{z-index:10000}.univer-mr-1{margin-right:.25rem}.univer-mt-1\\.5{margin-top:.375rem}.univer-mt-12{margin-top:3rem}.univer-size-0\\.5{width:.125rem;height:.125rem}.univer-size-8{width:2rem;height:2rem}.univer-h-16{height:4rem}.univer-h-3\\.5{height:.875rem}.univer-h-\\[24px\\]{height:24px}.univer-min-h-8{min-height:2rem}.univer-w-2{width:.5rem}.univer-w-2\\.5{width:.625rem}.univer-w-28{width:7rem}.univer-w-4\\/5{width:80%}.univer-w-\\[0px\\]{width:0}.univer-w-\\[212px\\]{width:212px}.univer-w-\\[72px\\]{width:72px}.univer-min-w-\\[180px\\]{min-width:180px}.univer-cursor-grab{cursor:grab}.univer-grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.univer-place-items-center{place-items:center}.univer-items-stretch{align-items:stretch}.univer-gap-2\\.5{gap:.625rem}.univer-gap-3{gap:.75rem}.univer-gap-x-0\\.5{-moz-column-gap:.125rem;column-gap:.125rem}.univer-gap-y-px{row-gap:1px}.univer-rounded-r-2xl{border-top-right-radius:1rem;border-bottom-right-radius:1rem}.\\!univer-border-primary-500{border-color:var(--univer-primary-500)!important}.univer-border-primary-500{border-color:var(--univer-primary-500)}.\\!univer-bg-primary-50{background-color:var(--univer-primary-50)!important}.\\!univer-bg-primary-900{background-color:var(--univer-primary-900)!important}.univer-bg-gray-400{background-color:var(--univer-gray-400)}.univer-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.univer-pb-0\\.5{padding-bottom:.125rem}.univer-pb-4{padding-bottom:1rem}.univer-pr-1{padding-right:.25rem}.univer-pt-1\\.5{padding-top:.375rem}.univer-pt-14{padding-top:3.5rem}.univer-text-lg{font-size:1.125rem;line-height:1.75rem}.univer-font-\\[500\\],.univer-font-medium{font-weight:500}.univer-font-normal{font-weight:400}.univer-leading-\\[24px\\]{line-height:24px}.\\!univer-text-gray-200{color:var(--univer-gray-200)!important}.\\!univer-text-gray-400{color:var(--univer-gray-400)!important}.\\!univer-text-primary-600{color:var(--univer-primary-600)!important}.univer-text-gray-800{color:var(--univer-gray-800)}.univer-backdrop-blur-\\[10px\\]{--univer-tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-duration-300{transition-duration:.3s}.univer-group:hover .group-hover\\:univer-bg-gray-500{background-color:var(--univer-gray-500)}.hover\\:univer-border-primary-500:hover{border-color:var(--univer-primary-500)}.hover\\:univer-bg-white:hover{background-color:var(--univer-white)}.hover\\:univer-text-gray-900:hover{color:var(--univer-gray-900)}.hover\\:univer-text-primary-600:hover{color:var(--univer-primary-600)}.hover\\:univer-shadow-md:hover{--univer-tw-shadow:0px 1px 6px -2px #1e284d14, 0px 2px 6px -1px #1e284d1a;--univer-tw-shadow-colored:0px 1px 6px -2px var(--univer-tw-shadow-color), 0px 2px 6px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.active\\:univer-cursor-grabbing:active{cursor:grabbing}.dark\\:\\!univer-bg-gray-500:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-500)!important}.dark\\:\\!univer-bg-primary-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-primary-900)!important}.univer-group:hover .dark\\:group-hover\\:\\!univer-bg-gray-300:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-300)!important}.univer-pointer-events-none{pointer-events:none}.univer-inset-0{inset:0}.-univer-left-0\\.5{left:-.125rem}.-univer-top-0\\.5{top:-.125rem}.univer-left-0{left:0}.univer-left-1{left:.25rem}.univer-left-3{left:.75rem}.univer-right-0{right:0}.univer-right-5{right:1.25rem}.univer-top-0{top:0}.univer-top-0\\.5{top:.125rem}.univer-z-10{z-index:10}.univer-z-\\[1001\\]{z-index:1001}.univer-z-\\[100\\]{z-index:100}.univer-mx-1\\.5{margin-left:.375rem;margin-right:.375rem}.univer-mb-1\\.5{margin-bottom:.375rem}.univer-mb-4{margin-bottom:1rem}.univer-ml-6{margin-left:1.5rem}.univer-ml-px{margin-left:1px}.univer-mr-1\\.5{margin-right:.375rem}.univer-mr-5{margin-right:1.25rem}.univer-mt-auto{margin-top:auto}.univer-size-0{width:0;height:0}.univer-size-10{width:2.5rem;height:2.5rem}.univer-h-0\\.5{height:.125rem}.univer-h-1{height:.25rem}.univer-h-10{height:2.5rem}.univer-h-20{height:5rem}.univer-h-60{height:15rem}.univer-h-9{height:2.25rem}.univer-h-\\[270px\\]{height:270px}.univer-h-\\[30px\\]{height:30px}.univer-h-\\[calc\\(100\\%-16px\\)\\]{height:calc(100% - 16px)}.univer-h-\\[calc\\(100\\%-8px\\)\\]{height:calc(100% - 8px)}.univer-h-px{height:1px}.univer-max-h-52{max-height:13rem}.univer-max-h-\\[100px\\]{max-height:100px}.univer-max-h-\\[360px\\]{max-height:360px}.univer-min-h-0{min-height:0}.univer-min-h-\\[30px\\]{min-height:30px}.\\!univer-w-\\[90px\\]{width:90px!important}.univer-w-16{width:4rem}.univer-w-20{width:5rem}.univer-w-24{width:6rem}.univer-w-5{width:1.25rem}.univer-w-60{width:15rem}.univer-w-\\[100px\\]{width:100px}.univer-w-\\[130px\\]{width:130px}.univer-w-\\[156px\\]{width:156px}.univer-w-\\[300px\\]{width:300px}.univer-w-\\[50\\%\\]{width:50%}.univer-w-fit{width:fit-content}.univer-min-w-0{min-width:0}.univer-min-w-72{min-width:18rem}.univer-max-w-32{max-width:8rem}.univer-max-w-36{max-width:9rem}.univer-max-w-64{max-width:16rem}.univer-max-w-\\[190px\\]{max-width:190px}.univer-max-w-\\[200px\\]{max-width:200px}.univer-max-w-\\[calc\\(100\\%-112px\\)\\]{max-width:calc(100% - 112px)}.univer-max-w-fit{max-width:fit-content}.univer-max-w-lg{max-width:32rem}.univer-flex-shrink-0,.univer-shrink-0{flex-shrink:0}.univer-rotate-180{--univer-tw-rotate:180deg;transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(180deg) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-animate-spin{animation:1s linear infinite univer-spin}.univer-cursor-not-allowed{cursor:not-allowed}.univer-appearance-none{appearance:none}.univer-grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.univer-grid-cols-\\[1fr\\,auto\\,auto\\,auto\\]{grid-template-columns:1fr auto auto auto}.univer-flex-row-reverse{flex-direction:row-reverse}.univer-gap-7{gap:1.75rem}.univer-gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.univer-space-y-2>:not([hidden])~:not([hidden]){--univer-tw-space-y-reverse:0;margin-top:calc(.5rem * (1 - var(--univer-tw-space-y-reverse)));margin-top:.5rem;margin-top:calc(.5rem * calc(1 - var(--univer-tw-space-y-reverse)));margin-bottom:0;margin-bottom:calc(.5rem * var(--univer-tw-space-y-reverse))}.univer-divide-x-0>:not([hidden])~:not([hidden]){--univer-tw-divide-x-reverse:0;border-right-width:0;border-right-width:calc(0px * var(--univer-tw-divide-x-reverse));border-left-width:calc(0px * (1 - var(--univer-tw-divide-x-reverse)));border-left-width:0;border-left-width:calc(0px * calc(1 - var(--univer-tw-divide-x-reverse)))}.univer-divide-y>:not([hidden])~:not([hidden]){--univer-tw-divide-y-reverse:0;border-top-width:calc(1px * (1 - var(--univer-tw-divide-y-reverse)));border-top-width:1px;border-top-width:calc(1px * calc(1 - var(--univer-tw-divide-y-reverse)));border-bottom-width:0;border-bottom-width:calc(1px * var(--univer-tw-divide-y-reverse))}.univer-divide-solid>:not([hidden])~:not([hidden]){border-style:solid}.univer-divide-gray-200>:not([hidden])~:not([hidden]){border-color:var(--univer-gray-200)}.univer-justify-self-center{justify-self:center}.univer-overflow-x-auto{overflow-x:auto}.univer-overflow-y-hidden{overflow-y:hidden}.univer-rounded-sm{border-radius:.125rem}.univer-border-2{border-width:2px}.univer-border-4{border-width:4px}.univer-border-b{border-bottom-width:1px}.univer-border-\\[rgba\\(13\\,13\\,13\\,0\\.12\\)\\]{border-color:#0d0d0d1f}.univer-border-gray-100{border-color:var(--univer-gray-100)}.univer-border-r-gray-200{border-right-color:var(--univer-gray-200)}.univer-border-t-primary-500{border-top-color:var(--univer-primary-500)}.\\!univer-bg-gray-700{background-color:var(--univer-gray-700)!important}.univer-bg-blue-500{background-color:var(--univer-blue-500)}.univer-bg-blue-600{background-color:var(--univer-blue-600)}.univer-bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--univer-tw-gradient-stops))}.univer-from-gray-50{--univer-tw-gradient-from:var(--univer-gray-50) var(--univer-tw-gradient-from-position);--univer-tw-gradient-to:#fff0 var(--univer-tw-gradient-to-position);--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)}.univer-to-gray-100{--univer-tw-gradient-to:var(--univer-gray-100) var(--univer-tw-gradient-to-position)}.univer-fill-gray-900{fill:var(--univer-gray-900)}.univer-px-3\\.5{padding-left:.875rem;padding-right:.875rem}.univer-px-5{padding-left:1.25rem;padding-right:1.25rem}.univer-py-5{padding-top:1.25rem;padding-bottom:1.25rem}.univer-pb-1{padding-bottom:.25rem}.univer-pl-1\\.5{padding-left:.375rem}.univer-pl-3{padding-left:.75rem}.univer-pl-6{padding-left:1.5rem}.univer-pr-5{padding-right:1.25rem}.univer-pt-1{padding-top:.25rem}.univer-font-semibold{font-weight:600}.univer-leading-6{line-height:1.5rem}.univer-leading-7{line-height:1.75rem}.\\!univer-text-blue-400{color:var(--univer-blue-400)!important}.\\!univer-text-gray-700{color:var(--univer-gray-700)!important}.\\!univer-text-white{color:var(--univer-white)!important}.univer-text-blue-500{color:var(--univer-blue-500)}.univer-text-blue-600{color:var(--univer-blue-600)}.univer-text-gray-200{color:var(--univer-gray-200)}.univer-text-gray-300{color:var(--univer-gray-300)}.univer-text-green-600{color:var(--univer-green-600)}.univer-text-primary-700{color:var(--univer-primary-700)}.univer-text-red-600{color:var(--univer-red-600)}.univer-text-rose-600{--univer-tw-text-opacity:1;color:rgba(225,29,72,var(--univer-tw-text-opacity,1))}.univer-text-yellow-500{color:var(--univer-yellow-500)}.univer-shadow{--univer-tw-shadow:0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;--univer-tw-shadow-colored:0 1px 3px 0 var(--univer-tw-shadow-color), 0 1px 2px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-blur-sm{--univer-tw-blur:blur(4px);filter:var(--univer-tw-blur) var(--univer-tw-brightness) var(--univer-tw-contrast) var(--univer-tw-grayscale) var(--univer-tw-hue-rotate) var(--univer-tw-invert) var(--univer-tw-saturate) var(--univer-tw-sepia) var(--univer-tw-drop-shadow)}.univer-backdrop-blur{--univer-tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia);backdrop-filter:var(--univer-tw-backdrop-blur) var(--univer-tw-backdrop-brightness) var(--univer-tw-backdrop-contrast) var(--univer-tw-backdrop-grayscale) var(--univer-tw-backdrop-hue-rotate) var(--univer-tw-backdrop-invert) var(--univer-tw-backdrop-opacity) var(--univer-tw-backdrop-saturate) var(--univer-tw-backdrop-sepia)}.univer-transition-\\[colors\\,box-shadow\\]{transition-property:colors,box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-transition-\\[height\\]{transition-property:height;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.univer-duration-200{transition-duration:.2s}.univer-ease-linear{transition-timing-function:linear}.after\\:univer-absolute:after{content:var(--univer-tw-content);position:absolute}.after\\:univer-right-0:after{content:var(--univer-tw-content);right:0}.after\\:univer-top-1\\/2:after{content:var(--univer-tw-content);top:50%}.after\\:univer-block:after{content:var(--univer-tw-content);display:block}.after\\:univer-h-4:after{content:var(--univer-tw-content);height:1rem}.after\\:univer-w-px:after{content:var(--univer-tw-content);width:1px}.after\\:-univer-translate-y-1\\/2:after{content:var(--univer-tw-content);--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.after\\:univer-bg-gray-200:after{content:var(--univer-tw-content);background-color:var(--univer-gray-200)}.after\\:univer-content-\\[\\"\\"\\]:after{--univer-tw-content:"";content:"";content:var(--univer-tw-content)}.last\\:univer-mb-0:last-child{margin-bottom:0}.univer-group:hover .group-hover\\:univer-flex{display:flex}.hover\\:univer-border-primary-600:hover{border-color:var(--univer-primary-600)}.hover\\:univer-bg-transparent:hover{background-color:#0000}.focus\\:univer-border-primary-500:focus{border-color:var(--univer-primary-500)}.focus\\:univer-outline-none:focus{outline-offset:2px;outline:2px solid #0000}.focus-visible\\:univer-ring-2:focus-visible{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.focus-visible\\:univer-ring-primary-500:focus-visible{--univer-tw-ring-color:var(--univer-primary-500)}.active\\:univer-bg-gray-100:active{background-color:var(--univer-gray-100)}.dark\\:\\!univer-divide-gray-600:where(.univer-dark,.univer-dark *)>:not([hidden])~:not([hidden]){border-color:var(--univer-gray-600)!important}.dark\\:\\!univer-border-r-gray-700:where(.univer-dark,.univer-dark *){border-right-color:var(--univer-gray-700)!important}.dark\\:\\!univer-bg-black:where(.univer-dark,.univer-dark *){background-color:var(--univer-black)!important}.dark\\:\\!univer-bg-blue-400:where(.univer-dark,.univer-dark *){background-color:var(--univer-blue-400)!important}.dark\\:\\!univer-from-gray-800:where(.univer-dark,.univer-dark *){--univer-tw-gradient-from:var(--univer-gray-800) var(--univer-tw-gradient-from-position)!important;--univer-tw-gradient-to:#fff0 var(--univer-tw-gradient-to-position)!important;--univer-tw-gradient-stops:var(--univer-tw-gradient-from), var(--univer-tw-gradient-to)!important}.dark\\:\\!univer-to-gray-900:where(.univer-dark,.univer-dark *){--univer-tw-gradient-to:var(--univer-gray-900) var(--univer-tw-gradient-to-position)!important}.dark\\:\\!univer-fill-white:where(.univer-dark,.univer-dark *){fill:var(--univer-white)!important}.dark\\:\\!univer-text-blue-400:where(.univer-dark,.univer-dark *){color:var(--univer-blue-400)!important}.dark\\:\\!univer-text-gray-700:where(.univer-dark,.univer-dark *){color:var(--univer-gray-700)!important}.dark\\:\\!univer-text-green-400:where(.univer-dark,.univer-dark *){color:var(--univer-green-400)!important}.dark\\:\\!univer-text-red-400:where(.univer-dark,.univer-dark *){color:var(--univer-red-400)!important}.\\[\\&\\>div\\:first-child\\]\\:univer-px-2\\.5>div:first-child{padding-left:.625rem;padding-right:.625rem}.\\[\\&\\>div\\]\\:univer-h-5>div{height:1.25rem}.\\[\\&\\>div\\]\\:univer-ring-transparent>div{--univer-tw-ring-color:transparent}.\\[\\&_canvas\\]\\:univer-absolute canvas,.univer-absolute{position:absolute}.univer-left-1\\.5{left:.375rem}.univer-top-1\\/2{top:50%}.univer-z-\\[15\\]{z-index:15}.univer-m-0{margin:0}.-univer-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.univer-mx-0{margin-left:0;margin-right:0}.univer-my-1{margin-top:.25rem;margin-bottom:.25rem}.univer-my-2{margin-top:.5rem;margin-bottom:.5rem}.univer-mb-0{margin-bottom:0}.univer-ml-4{margin-left:1rem}.univer-mr-0{margin-right:0}.univer-mt-0{margin-top:0}.univer-mt-1{margin-top:.25rem}.univer-h-\\[18px\\]{height:18px}.univer-h-\\[364px\\]{height:364px}.univer-max-h-60{max-height:15rem}.univer-max-h-72{max-height:18rem}.univer-max-h-\\[350px\\]{max-height:350px}.univer-w-\\[250px\\]{width:250px}.-univer-translate-y-1\\/2{--univer-tw-translate-y:-50%;transform:translate(var(--univer-tw-translate-x),-50%) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));transform:translate(var(--univer-tw-translate-x),var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skew(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y))}.univer-justify-around{justify-content:space-around}.univer-overflow-visible{overflow:visible}.univer-whitespace-pre-wrap{white-space:pre-wrap}.univer-break-words{word-wrap:break-word}.univer-break-all{word-break:break-all}.univer-rounded-none{border-radius:0}.univer-rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.univer-border-r-0{border-right-width:0}.univer-border-gray-600{border-color:var(--univer-gray-600)}.univer-border-primary-600{border-color:var(--univer-primary-600)}.\\!univer-bg-gray-600{background-color:var(--univer-gray-600)!important}.univer-bg-primary-600{background-color:var(--univer-primary-600)}.univer-px-4{padding-left:1rem;padding-right:1rem}.univer-px-6{padding-left:1.5rem;padding-right:1.5rem}.univer-px-7{padding-left:1.75rem;padding-right:1.75rem}.univer-py-3{padding-top:.75rem;padding-bottom:.75rem}.univer-pb-3{padding-bottom:.75rem}.univer-pt-0{padding-top:0}.univer-font-medium{font-weight:500}.univer-leading-\\[13px\\]{line-height:13px}.univer-text-white{color:var(--univer-white)}.univer-outline-none{outline-offset:2px;outline:2px solid #0000}.univer-ring-1{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(1px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.univer-ring-primary-500{--univer-tw-ring-color:var(--univer-primary-500)}.univer-ring-red-500{--univer-tw-ring-color:var(--univer-red-500)}.hover\\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.hover\\:univer-bg-gray-300:hover{background-color:var(--univer-gray-300)}.dark\\:\\!univer-bg-gray-600:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.dark\\:\\!univer-text-gray-300:where(.univer-dark,.univer-dark *){color:var(--univer-gray-300)!important}.dark\\:hover\\:\\!univer-bg-gray-600:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-600)!important}.univer-mb-5{margin-bottom:1.25rem}.univer-mr-3{margin-right:.75rem}.univer-mt-3{margin-top:.75rem}.univer-mt-3\\.5{margin-top:.875rem}.univer-max-h-\\[400px\\]{max-height:400px}.univer-w-32{width:8rem}.univer-w-36{width:9rem}.univer-w-4{width:1rem}.univer-w-\\[340px\\]{width:340px}.univer-cursor-default{cursor:default}.univer-gap-1\\.5{gap:.375rem}.univer-gap-6{gap:1.5rem}.univer-p-1\\.5{padding:.375rem}.univer-pb-5{padding-bottom:1.25rem}.univer-text-sm,.univer-text-sm\\/5{font-size:.875rem;line-height:1.25rem}.dark\\:\\!univer-text-gray-400:where(.univer-dark,.univer-dark *){color:var(--univer-gray-400)!important}.univer-absolute{position:absolute}.-univer-bottom-0\\.5{bottom:-.125rem}.-univer-right-0\\.5{right:-.125rem}.univer-mx-1{margin-left:.25rem;margin-right:.25rem}.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-block{display:block}.univer-inline-block{display:inline-block}.univer-size-3{width:.75rem;height:.75rem}.univer-size-full{width:100%;height:100%}.univer-h-4{height:1rem}.univer-h-\\[300px\\]{height:300px}.univer-max-h-\\[500px\\]{max-height:500px}.univer-min-h-\\[300px\\]{min-height:300px}.univer-w-\\[400px\\]{width:400px}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow{flex-grow:1}.univer-flex-grow-0{flex-grow:0}.univer-grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.univer-flex-nowrap{flex-wrap:nowrap}.univer-justify-start{justify-content:flex-start}.univer-gap-4{gap:1rem}.univer-overflow-auto{overflow:auto}.univer-whitespace-nowrap{white-space:nowrap}.univer-rounded-full{border-radius:9999px}.univer-border-\\[rgba\\(13\\,13\\,13\\,0\\.06\\)\\]{border-color:#0d0d0d0f}.univer-border-transparent{border-color:#0000}.univer-bg-gray-300{background-color:var(--univer-gray-300)}.univer-p-0\\.5{padding:.125rem}.univer-p-2{padding:.5rem}.univer-py-0{padding-top:0;padding-bottom:0}.univer-py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.univer-py-2\\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pl-5{padding-left:1.25rem}.univer-pr-0\\.5{padding-right:.125rem}.univer-pr-2{padding-right:.5rem}.univer-pt-2{padding-top:.5rem}.univer-font-bold{font-weight:700}.univer-text-\\[\\#418F1F\\]{--univer-tw-text-opacity:1;color:rgba(65,143,31,var(--univer-tw-text-opacity,1))}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-transition-shadow{transition-property:box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.hover\\:univer-ring-2:hover{--univer-tw-ring-offset-shadow:var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow:var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow,0 0 #0000)}.hover\\:univer-ring-offset-2:hover{--univer-tw-ring-offset-width:2px}.hover\\:univer-ring-offset-white:hover{--univer-tw-ring-offset-color:var(--univer-white)}.dark\\:\\!univer-border-\\[rgba\\(255\\,255\\,255\\,0\\.06\\)\\]:where(.univer-dark,.univer-dark *){border-color:#ffffff0f!important}.dark\\:\\!univer-border-gray-600:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\\:\\!univer-text-gray-500:where(.univer-dark,.univer-dark *){color:var(--univer-gray-500)!important}.dark\\:hover\\:\\!univer-bg-gray-900:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.\\[\\&\\:hover_a\\]\\:univer-inline-block:hover a{display:inline-block}.univer-my-0{margin-top:0;margin-bottom:0}.univer-mb-2{margin-bottom:.5rem}.univer-mb-3{margin-bottom:.75rem}.univer-ml-1\\.5{margin-left:.375rem}.univer-ml-3{margin-left:.75rem}.univer-mt-5{margin-top:1.25rem}.univer-max-h-\\[310px\\]{max-height:310px}.univer-w-\\[--radix-popper-anchor-width\\]{width:var(--radix-popper-anchor-width)}.univer-max-w-\\[220px\\]{max-width:220px}.univer-select-none{-webkit-user-select:none;user-select:none}.univer-list-none{list-style-type:none}.univer-grid-flow-col{grid-auto-flow:column}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.univer-transition-all{transition-property:all;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:univer-text-red-500:hover{color:var(--univer-red-500)}.disabled\\:univer-divide-opacity-30:disabled>:not([hidden])~:not([hidden]){--univer-tw-divide-opacity:.3}.disabled\\:univer-text-gray-800:disabled{color:var(--univer-gray-800)}.univer-mt-4{margin-top:1rem}.univer-mt-6{margin-top:1.5rem}.univer-inline-flex{display:inline-flex}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-relative{position:relative}.univer-mt-2\\.5{margin-top:.625rem}.univer-size-4{width:1rem;height:1rem}.univer-h-5{height:1.25rem}.univer-h-7{height:1.75rem}.univer-h-8{height:2rem}.univer-h-full{height:100%}.univer-w-6{width:1.5rem}.univer-w-px{width:1px}.univer-min-w-32{min-width:8rem}.univer-min-w-9{min-width:2.25rem}.univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.univer-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.univer-gap-1{gap:.25rem}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-none{border-style:none}.\\!univer-bg-gray-800{background-color:var(--univer-gray-800)!important}.\\!univer-bg-gray-900{background-color:var(--univer-gray-900)!important}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-gray-200{background-color:var(--univer-gray-200)}.univer-bg-primary-50{background-color:var(--univer-primary-50)}.univer-bg-transparent{background-color:#0000}.univer-fill-primary-600{fill:var(--univer-primary-600)}.univer-p-0{padding:0}.univer-p-1{padding:.25rem}.univer-px-1{padding-left:.25rem;padding-right:.25rem}.univer-px-1\\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-1{padding-top:.25rem;padding-bottom:.25rem}.univer-text-left{text-align:left}.univer-text-center{text-align:center}.\\!univer-text-primary-300{color:var(--univer-primary-300)!important}.univer-text-gray-700{color:var(--univer-gray-700)}.univer-shadow-lg{--univer-tw-shadow:0px 4px 6px 0px #1e284d0d, 0px 10px 15px -3px #1e284d1a;--univer-tw-shadow-colored:0px 4px 6px 0px var(--univer-tw-shadow-color), 0px 10px 15px -3px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-shadow-sm{--univer-tw-shadow:0px 1px 2px 0px #1e284d14;--univer-tw-shadow-colored:0px 1px 2px 0px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 2px #1e284d14;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000),var(--univer-tw-ring-shadow,0 0 #0000),var(--univer-tw-shadow)}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.disabled\\:univer-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:univer-opacity-40:disabled{opacity:.4}.dark\\:\\!univer-border-gray-700:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-700)!important}.dark\\:\\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\\:\\!univer-bg-gray-800:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.dark\\:\\!univer-text-gray-100:where(.univer-dark,.univer-dark *){color:var(--univer-gray-100)!important}.dark\\:\\!univer-text-primary-300:where(.univer-dark,.univer-dark *){color:var(--univer-primary-300)!important}.dark\\:hover\\:\\!univer-bg-gray-800:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.\\[\\&\\>div\\]\\:univer-grid>div{display:grid}.\\[\\&\\>div\\]\\:univer-gap-2>div{gap:.5rem}.univer-grid{display:grid}.univer-hidden{display:none}.univer-flex-col{flex-direction:column}.univer-border-t{border-top-width:1px}.univer-border-gray-200{border-color:var(--univer-gray-200)}.univer-py-2{padding-top:.5rem;padding-bottom:.5rem}.univer-pt-3{padding-top:.75rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-600{color:var(--univer-gray-600)}.dark\\:\\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.univer-mb-1{margin-bottom:.25rem}.univer-ml-2{margin-left:.5rem}.univer-mr-2{margin-right:.5rem}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-size-5{width:1.25rem;height:1.25rem}.univer-size-6{width:1.5rem;height:1.5rem}.univer-h-6{height:1.5rem}.univer-w-\\[296px\\]{width:296px}.univer-w-full{width:100%}.univer-max-w-80{max-width:20rem}.univer-flex-1{flex:1}.univer-flex-none{flex:none}.univer-cursor-pointer{cursor:pointer}.univer-flex-row{flex-direction:row}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:.5rem}.univer-overflow-hidden{overflow:hidden}.univer-truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.univer-rounded{border-radius:.25rem}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-xl{border-radius:.75rem}.univer-bg-white{background-color:var(--univer-white)}.univer-p-3{padding:.75rem}.univer-p-4{padding:1rem}.univer-text-base{font-size:1rem;line-height:1.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-leading-5{line-height:1.25rem}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-green-500{color:var(--univer-green-500)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-text-red-500{color:var(--univer-red-500)}.univer-shadow-md{--univer-tw-shadow:0px 1px 6px -2px #1e284d14, 0px 2px 6px -1px #1e284d1a;--univer-tw-shadow-colored:0px 1px 6px -2px var(--univer-tw-shadow-color), 0px 2px 6px -1px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow,0 0 #0000), var(--univer-tw-ring-shadow,0 0 #0000), var(--univer-tw-shadow)}.hover\\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.dark\\:\\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\\:\\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\\:hover\\:\\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.sheet-shell[data-v-490e6eac]{letter-spacing:normal;flex-direction:column;height:760px;font-size:14px;line-height:normal;display:flex}.sheet-canvas[data-v-490e6eac]{flex:1;min-height:0;position:relative}.sheet-editor[data-v-490e6eac]{contain:layout style;letter-spacing:normal;width:100%;height:100%;font-size:14px;line-height:normal;position:absolute;inset:0;overflow:hidden}.sheet-attachments[data-v-490e6eac]{border-bottom:1px solid #eee;align-items:center;gap:8px;padding:6px 12px;font-size:12px;display:flex}.sheet-attachments button[data-v-490e6eac]{cursor:pointer;color:#3370ff;background:#fff;border:1px solid #dce3ed;border-radius:4px;padding:4px 8px}.sheet-attachments button[data-v-490e6eac]:disabled{cursor:wait;opacity:.5}.attachment-name[data-v-490e6eac]{text-overflow:ellipsis;white-space:nowrap;max-width:240px;overflow:hidden}.attachment-error[data-v-490e6eac]{color:#c62828}.tag-current-row[data-v-490e6eac]{z-index:100;background:#fafbfc;border:1px solid #eee;border-radius:6px;align-items:center;gap:4px;padding:0 8px;font-size:12px;display:inline-flex;position:absolute;box-shadow:0 1px 4px #0000000f}.tag-current-label[data-v-490e6eac]{color:#999;white-space:nowrap;font-size:11px}.tag-dropdown[data-v-490e6eac]{z-index:100;background:#fff;border:1px solid #e0e0e0;border-radius:6px;flex-direction:column;gap:4px;min-width:220px;max-width:320px;padding:8px;display:flex;position:absolute;box-shadow:0 4px 12px #0000001f}.tag-search[data-v-490e6eac]{box-sizing:border-box;border:1px solid #d9d9d9;border-radius:4px;outline:none;width:100%;padding:5px 8px;font-size:12px}.tag-search[data-v-490e6eac]:focus{border-color:#3370ff}.tag-option-list[data-v-490e6eac]{flex-wrap:wrap;gap:6px;max-height:180px;padding:4px;display:flex;overflow-y:auto}.tag-option[data-v-490e6eac]{cursor:pointer;white-space:nowrap;border:1px solid #0000;border-radius:4px;padding:3px 10px;font-size:12px;font-weight:600;position:relative}.tag-option[data-v-490e6eac]:hover{opacity:.85;border-color:currentColor}.tag-option-name[data-v-490e6eac]{pointer-events:none}.tag-option-delete[data-v-490e6eac]{cursor:pointer;color:#fff;background:#ff4d4f;border:1px solid #fff;border-radius:50%;justify-content:center;align-items:center;width:14px;height:14px;font-size:10px;line-height:1;display:none;position:absolute;top:-6px;right:-6px;box-shadow:0 1px 2px #00000026}.tag-option:hover .tag-option-delete[data-v-490e6eac]{display:inline-flex}.tag-option-delete[data-v-490e6eac]:hover{background:#cf1322}.tag-empty[data-v-490e6eac]{color:#999;text-align:center;width:100%;padding:8px 0;font-size:12px}.tag-add-new[data-v-490e6eac]{color:#666;cursor:pointer;text-align:center;background:0 0;border:1px dashed #d9d9d9;border-radius:4px;width:100%;padding:4px 8px;font-size:12px}.tag-add-new[data-v-490e6eac]:hover{color:#3370ff;border-color:#3370ff}.cell-tag-chip[data-v-490e6eac]{border-radius:4px;align-items:center;gap:2px;padding:2px 6px;font-size:12px;font-weight:600;display:inline-flex}.cell-tag-remove[data-v-490e6eac]{cursor:pointer;color:inherit;opacity:.6;background:0 0;border:none;padding:0 1px;font-size:14px;line-height:1}.cell-tag-remove[data-v-490e6eac]:hover{opacity:1}.tag-config-overlay[data-v-490e6eac]{z-index:1000;background:#0006;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.tag-config-dialog[data-v-490e6eac]{background:#fff;border-radius:8px;min-width:320px;padding:20px;box-shadow:0 8px 24px #00000026}.tag-config-dialog h4[data-v-490e6eac]{margin:0 0 16px;font-size:15px;font-weight:600}.tag-config-label[data-v-490e6eac]{color:#666;flex-direction:column;gap:4px;margin-bottom:12px;font-size:12px;display:flex}.tag-config-label input[data-v-490e6eac]{border:1px solid #d9d9d9;border-radius:4px;padding:6px 8px;font-size:13px}.tag-config-label input[data-v-490e6eac]:focus{border-color:#3370ff;outline:none}.tag-config-colors[data-v-490e6eac]{margin-bottom:12px}.tag-config-colors>span[data-v-490e6eac]{color:#666;margin-bottom:6px;font-size:12px;display:block}.tag-sv-panel[data-v-490e6eac]{cursor:crosshair;touch-action:none;border-radius:6px;width:100%;height:110px;margin-bottom:10px;position:relative}.tag-hue-bar[data-v-490e6eac]{cursor:pointer;touch-action:none;background:linear-gradient(90deg,red,#ff0,#0f0,#0ff,#00f,#f0f,red);border-radius:7px;width:100%;height:14px;position:relative}.tag-color-dot[data-v-490e6eac]{pointer-events:none;border:2px solid #fff;border-radius:50%;width:14px;height:14px;position:absolute;transform:translate(-50%,-50%);box-shadow:0 0 2px #0006}.tag-config-preview[data-v-490e6eac]{margin-bottom:16px}.tag-config-actions[data-v-490e6eac]{justify-content:flex-end;gap:8px;display:flex}.tag-config-cancel[data-v-490e6eac]{cursor:pointer;background:#fff;border:1px solid #d9d9d9;border-radius:4px;padding:5px 14px;font-size:13px}.tag-config-save[data-v-490e6eac]{color:#fff;cursor:pointer;background:#3370ff;border:none;border-radius:4px;padding:5px 14px;font-size:13px}.tag-config-save[data-v-490e6eac]:hover{background:#245bdb}.sheet-statusbar[data-v-490e6eac]{color:#8c8c8c;white-space:nowrap;background:#fafbfc;border-top:1px solid #f0f0f0;align-items:center;gap:8px;padding:8px 16px;font-size:12px;display:flex;overflow:hidden}.status-cell[data-v-490e6eac]{color:#25b864;font-family:ui-monospace,Consolas,monospace;font-weight:600}.status-sep[data-v-490e6eac]{color:#d9d9d9}.sheet-statusbar b[data-v-490e6eac]{color:#595959;font-weight:600}.status-flex[data-v-490e6eac]{flex:1}.status-hint[data-v-490e6eac]{color:#bfbfbf}.status-readonly[data-v-490e6eac]{color:#faad14}.status-tip[data-v-490e6eac]{color:#bfbfbf}.tag-toast[data-v-490e6eac]{z-index:200;color:#fff;pointer-events:none;white-space:nowrap;background:#000000bf;border-radius:6px;padding:8px 18px;font-size:13px;line-height:1.4;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:0 4px 12px #00000026}.tag-toast-enter-active[data-v-490e6eac],.tag-toast-leave-active[data-v-490e6eac]{transition:opacity .25s}.tag-toast-enter-from[data-v-490e6eac],.tag-toast-leave-to[data-v-490e6eac]{opacity:0}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|
|
2
2
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue")):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.PdEditor={},e.Vue))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},l=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),u=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:`Module`}),n},d=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},f=(e,t,i)=>(i=e==null?{}:n(o(e)),d(t||!e||!e.__esModule||!s.call(e,`default`)?r(i,`default`,{value:e,enumerable:!0}):i,e)),p=l(((e,t)=>{var n=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>`u`||process.domain===void 0)throw Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||n.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,this.maxPending=e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(e,t,n,r){if(Array.isArray(e))return this._acquireBatch(e,t,n,r);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var i=null,a=null,o=null;typeof n!=`function`&&(r=n,n=null,o=new this.Promise(function(e,t){i=e,a=t})),r||={};var s=!1,c=null,l=null,u=null,d=this,f=function(t,r,c){l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null),t&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),s||=(o?r?a(r):i(c):typeof n==`function`&&n(r,c),!0),t&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},p=function(n){if(s)return f(n);c&&=(clearTimeout(c),null),d.domainReentrant&&n&&(d.domains[e]=process.domain);var i=r.maxExecutionTime||d.maxExecutionTime;if(i&&(u=setTimeout(function(){d.queues[e]&&f(n,Error(`Maximum execution time is exceeded `+e))},i)),t.length===1){var a=!1;try{t(function(e,t){a||(a=!0,f(n,e,t))})}catch(e){a||(a=!0,f(n,e))}}else d._promiseTry(function(){return t()}).then(function(e){f(n,void 0,e)},function(e){f(n,e)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=r.maxPending||d.maxPending;if(!d.queues[e])d.queues[e]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[e])p(!1);else if(d.queues[e].length>=m)f(!1,Error(`Too many pending tasks in queue `+e));else{var h=function(){p(!0)};r.skipQueue?d.queues[e].unshift(h):d.queues[e].push(h);var g=r.timeout||d.timeout;g&&(c=setTimeout(function(){c=null,f(!1,Error(`async-lock timed out in queue `+e))},g))}var _=r.maxOccupationTime||d.maxOccupationTime;if(_&&(l=setTimeout(function(){d.queues[e]&&f(!1,Error(`Maximum occupation time is exceeded in queue `+e))},_)),o)return o},n.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},n.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},t.exports=n})),m=f(l(((e,t)=>{t.exports=p()}))()),h=Symbol(`$$IDENTIFIER_DECORATOR`);function g(e){return e&&e[h]===!0}function _(e){return typeof e==`function`}function v(e){return!!(e&&e.useClass!==void 0)}function y(e){return!!(e&&e.useFactory!==void 0)}function b(e){return!!(e&&e.useValue!==void 0)}function x(e){return!!(e&&e.useExisting!==void 0)}function S(e){return!!(e&&e.useAsync!==void 0)}var C=Symbol(`AsyncHook`);function w(e){return!!(e&&e.__symbol===C)}function T(e){return _(e)&&!e[h]?e.name:e.toString()}var E=class extends Error{constructor(e){super(`[redi]: ${e}`)}},D=function(e){return e.MANY=`many`,e.OPTIONAL=`optional`,e.REQUIRED=`required`,e}({}),O=function(e){return e.SELF=`self`,e.SKIP_SELF=`skipSelf`,e}({}),k=Symbol(`$$TARGET`),A=Symbol(`$$DEPENDENCIES`),ee=class extends E{constructor(e,t){let n=`Could not find dependency registered on the ${e} (indexed) parameter of the constructor of "${T(t)}".`;super(n)}},te=class extends E{constructor(e,t){let n=`It seems that you forgot to provide a parameter to @Required() on the ${t}th parameter of "${T(e)}"`;super(n)}},ne=class extends E{constructor(e,t){let n=`It seems that you register "undefined" as dependency on the ${t}th parameter of "${T(e)}". Please make sure that there is not cyclic dependency among your TypeScript files, or consider using "forwardRef". For more info please visit our website https://redi.wendell.fun/docs/faq#could-not-find-dependency-registered-on`;super(n)}};function re(e){return e[A]||[]}function ie(e,t){let n=re(e).find(e=>e.paramIndex===t);if(!n)throw new ee(t,e);return n}function ae(e,t,n,r=D.REQUIRED,i){let a={paramIndex:n,identifier:t,quantity:r,lookUp:i,withNew:!1};if(t===void 0)throw new ne(e,n);let o=e;o[k]===o?o[A].push(a):(o[A]=[a],o[k]=o)}var oe=new Set,se=new Map;function ce(e){if(oe.has(e))return console.error(`Identifier "${e}" already exists. Returning the cached identifier decorator.`),se.get(e);let t=function(e,n,r){ae(e,t,r)};return t.decoratorName=e,t.toString=()=>t.decoratorName,t[h]=!0,oe.add(e),se.set(e,t),t}function le(e,t,n){let r=ie(e,t);r.lookUp=n}function ue(e){return function t(){return this instanceof t?this:function(t,n,r){le(t,r,e)}}}var de=ue(O.SKIP_SELF),fe=ue(O.SELF);function pe(e){return e===D.OPTIONAL?`0 or 1`:`1`}var me=class extends E{constructor(e,t,n){let r=`Expect ${pe(t)} dependency item(s) for id "${T(e)}" but get ${n}.`;n===0&&(r+=` Did you forget to register it?`),n>1&&(r+=` You register it more than once.`),super(r),this.quantity=t,this.actual=n}};function he(e,t,n){if(t===D.OPTIONAL&&n>1||t===D.REQUIRED&&n!==1)throw new me(e,t,n)}function ge(e,t){return e===D.MANY?t:t[0]}function _e(e,t,n){let r=ie(e,t);r.quantity=n}function ve(e){return function t(n){return this instanceof t?this:function(t,r,i){if(n)ae(t,n,i,e);else{if(e===D.REQUIRED)throw new te(t,i);_e(t,i,e)}}}}var ye=ve(D.MANY),be=ve(D.OPTIONAL),j=ve(D.REQUIRED);function xe(e,t=0){return e?e.map((e,n)=>{if(n+=t,!Array.isArray(e))return{paramIndex:n,identifier:e,quantity:D.REQUIRED,withNew:!1};let r=e.slice(0,e.length-1),i=e[e.length-1],a,o=D.REQUIRED,s=!1;return r.forEach(e=>{e instanceof fe?a=O.SELF:e instanceof de?a=O.SKIP_SELF:e instanceof be?o=D.OPTIONAL:e instanceof ye?o=D.MANY:s=!0}),{paramIndex:n,identifier:i,quantity:o,lookUp:a,withNew:s}}):[]}function Se(e){return!!e&&typeof e.unwrap==`function`}function Ce(e){return Se(e)?e.unwrap():e}function we(e){return!!e&&typeof e.dispose==`function`}function Te(e){return e.length===1}var Ee=[];function De(e){Ee.push(e)}function Oe(){Ee.pop()}function ke(){Ee.length=0}var Ae=class extends E{constructor(e,t,n){let r=`Cannot find "${T(t)}" registered by any injector. It is the ${n}th param of "${g(e)?T(e):e.name}".`;super(r)}},je=class extends E{constructor(e){let t=`Cannot find "${T(e)}" registered by any injector. The stack of dependencies is: "${Ee.map(e=>T(e)).join(` -> `)}".`;super(t),ke()}},Me=class{dependencyMap=new Map;constructor(e){this.normalizeDependencies(e).map(e=>this.add(e[0],e[1]))}add(e,t){t===void 0&&(t={useClass:e,lazy:!1});let n=this.dependencyMap.get(e);n===void 0&&(n=[],this.dependencyMap.set(e,n)),n.push(t)}delete(e){this.dependencyMap.delete(e)}get(e,t){let n=this.dependencyMap.get(e);return he(e,t,n.length),ge(t,n)}has(e){return this.dependencyMap.has(e)}dispose(){this.dependencyMap.clear()}normalizeDependencies(e){return e.map(e=>{let t=e[0],n;return n=Te(e)?{useClass:e[0],lazy:!1}:e[1],[t,n]})}},Ne=class{resolvedDependencies=new Map;add(e,t){let n=this.resolvedDependencies.get(e);n===void 0&&(n=[],this.resolvedDependencies.set(e,n)),n.push(t)}has(e){return this.resolvedDependencies.has(e)}get(e,t){let n=this.resolvedDependencies.get(e);if(!n)throw new je(e);return he(e,t,n.length),t===D.MANY?n:n[0]}dispose(){Array.from(this.resolvedDependencies.values()).forEach(e=>{e.forEach(e=>we(e)?e.dispose():void 0)}),this.resolvedDependencies.clear()}},Pe;(function(){if(typeof requestIdleCallback<`u`&&typeof cancelIdleCallback<`u`)Pe=(e,t)=>{let n=requestIdleCallback(e,typeof t==`number`?{timeout:t}:void 0),r=!1;return()=>{r||(r=!0,cancelIdleCallback(n))}};else{let e=Object.freeze({didTimeout:!0,timeRemaining(){return 15}});Pe=t=>{let n=setTimeout(()=>t(e)),r=!1;return()=>{r||(r=!0,clearTimeout(n))}}}})();var Fe=class{executor;disposeIdleCallback;didRun=!1;value;error;constructor(e){this.executor=()=>{try{this.value=e()}catch(e){this.error=e}finally{this.didRun=!0}},this.disposeIdleCallback=Pe(()=>this.executor())}hasRun(){return this.didRun}dispose(){this.disposeIdleCallback()}getValue(){if(this.didRun||(this.disposeIdleCallback(),this.executor()),this.error)throw this.error;return this.value}},Ie=300,Le=Symbol(`$$NOT_INSTANTIATED_SYMBOL`),Re=class extends E{constructor(e){super(`Detecting cyclic dependency. The last identifier is "${T(e)}".`)}},ze=class extends E{constructor(){super(`Injector cannot be accessed after it was disposed.`)}},Be=class extends E{constructor(e){super(`Async item "${T(e)}" returns another async item.`)}},Ve=class extends E{constructor(e){super(`Cannot get async item "${T(e)}" from sync api.`)}},He=class extends E{constructor(e){super(`Cannot add dependency "${T(e)}" after it is already resolved.`)}},Ue=class extends E{constructor(e){super(`Cannot delete dependency "${T(e)}" when it is already resolved.`)}},We=class e{dependencyCollection;resolvedDependencyCollection;children=[];resolutionOngoing=0;disposingCallbacks=new Set;disposed=!1;constructor(e,t=null){this.parent=t,this.dependencyCollection=new Me(e||[]),this.resolvedDependencyCollection=new Ne,t&&t.children.push(this)}onDispose(e){return this.disposingCallbacks.add(e),{dispose:()=>this.disposingCallbacks.delete(e)}}createChild(t){return this._ensureInjectorNotDisposed(),new e(t,this)}dispose(){this.children.forEach(e=>e.dispose()),this.children.length=0,this.dependencyCollection.dispose(),this.resolvedDependencyCollection.dispose(),this.deleteSelfFromParent(),this.disposed=!0,this.disposingCallbacks.forEach(e=>e()),this.disposingCallbacks.clear()}deleteSelfFromParent(){if(this.parent){let e=this.parent.children.indexOf(this);this.parent.children.splice(e,1)}}add(e){this._ensureInjectorNotDisposed();let t=e[0],n=e[1];if(this.resolvedDependencyCollection.has(t))throw new He(t);n===void 0?this.dependencyCollection.add(t):S(n)||v(n)||b(n)||y(n)?this.dependencyCollection.add(t,n):this.resolvedDependencyCollection.add(t,n)}replace(e){this._ensureInjectorNotDisposed();let t=e[0];if(this.resolvedDependencyCollection.has(t))throw new He(t);this.dependencyCollection.delete(t),this.dependencyCollection.add(t,e[1])}delete(e){if(this._ensureInjectorNotDisposed(),this.resolvedDependencyCollection.has(e))throw new Ue(e);this.dependencyCollection.delete(e)}invoke(e,...t){return this._ensureInjectorNotDisposed(),e({get:(e,t,n)=>this._get(e,t,n),has:e=>this.has(e)},...t)}has(e){return this.dependencyCollection.has(e)||this.parent?.has(e)||!1}get(e,t,n){this._ensureInjectorNotDisposed();let r=this._get(e,t,n);if(Array.isArray(r)&&r.some(e=>w(e))||w(r))throw new Ve(e);return r}_get(e,t,n,r){let i=D.REQUIRED;if(t===D.REQUIRED||t===D.OPTIONAL||t===D.MANY?i=t:n=t,!r){let t=this.getValue(e,i,n);if(t!==Le)return t}let a=!r;return this.createDependency(e,i,n,a)}getAsync(e){this._ensureInjectorNotDisposed();let t=this.getValue(e,D.REQUIRED);if(t!==Le)return Promise.resolve(t);let n=this.createDependency(e,D.REQUIRED);return w(n)?n.whenReady():Promise.resolve(n)}createInstance(e,...t){return this._ensureInjectorNotDisposed(),this._resolveClassImpl({useClass:e},...t)}_resolveDependency(e,t,n=!0){let r;De(e);try{r=b(t)?this._resolveValueDependency(e,t):y(t)?this._resolveFactory(e,t,n):v(t)?this._resolveClass(e,t,n):x(t)?this._resolveExisting(e,t):this._resolveAsync(e,t),Oe()}catch(e){throw Oe(),e}return r}_resolveExisting(e,t){let n=this.get(t.useExisting);return this.resolvedDependencyCollection.add(e,n),n}_resolveValueDependency(e,t){let n=t.useValue;return this.resolvedDependencyCollection.add(e,n),n}_resolveClass(e,t,n){let r;if(t.lazy){let e=new Fe(()=>(this._ensureInjectorNotDisposed(),this._resolveClassImpl(t)));r=new Proxy(Object.create(null),{get(t,n){if(n in t)return t[n];let r=e.getValue(),i=r[n];return typeof i==`function`?(i=i.bind(r),t[n]=i,i):i},set(t,n,r){return e.getValue()[n]=r,!0}})}else r=this._resolveClassImpl(t);return e&&n&&this.resolvedDependencyCollection.add(e,r),r}_resolveClassImpl(e,...t){let n=e.useClass;this.markNewResolution(n);let r=re(n).sort((e,t)=>e.paramIndex-t.paramIndex).map(e=>({...e,identifier:Ce(e.identifier)})),i=[];for(let e of r)try{let t=this._get(e.identifier,e.quantity,e.lookUp,e.withNew);i.push(t)}catch(t){throw t instanceof je||t instanceof me&&t.actual===0?new Ae(n,e.identifier,e.paramIndex):t}let a=[...t],o=r.length>0?r[0].paramIndex:a.length;if(a.length!==o){console.warn(`[redi]: Expect ${o} custom parameter(s) of ${T(n)} but get ${a.length}.`);let e=o-a.length;a=e>0?[...a,...Array.from({length:e}).fill(void 0)]:a.slice(0,o)}let s=new n(...a,...i);return e?.onInstantiation?.(s),this.markResolutionCompleted(),s}_resolveFactory(e,t,n){this.markNewResolution(e);let r=xe(t.deps),i=[];for(let t of r)try{let e=this._get(t.identifier,t.quantity,t.lookUp,t.withNew);i.push(e)}catch(n){throw n instanceof je||n instanceof me&&n.actual===0?new Ae(e,t.identifier,t.paramIndex):n}let a=t.useFactory.apply(null,i);return n&&this.resolvedDependencyCollection.add(e,a),this.markResolutionCompleted(),t?.onInstantiation?.(a),a}_resolveAsync(e,t){return{__symbol:C,whenReady:()=>this._resolveAsyncImpl(e,t)}}_resolveAsyncImpl(e,t){return t.useAsync().then(n=>{let r=this.getValue(e);if(r!==Le)return r;let i;if(Array.isArray(n)){let t=n[1];if(S(t))throw new Be(e);i=this._resolveDependency(e,t)}else i=_(n)?this._resolveClassImpl({useClass:n,onInstantiation:t.onInstantiation}):n;return this.resolvedDependencyCollection.add(e,i),i})}getValue(t,n=D.REQUIRED,r){let i=()=>this.dependencyCollection.has(t)&&!this.resolvedDependencyCollection.has(t)?Le:this.resolvedDependencyCollection.get(t,n),a=()=>{if(this.parent)return this.parent.getValue(t,n);if(n===D.OPTIONAL)return null;if(n===D.MANY)return[];throw new me(t,D.REQUIRED,0)};return r===O.SKIP_SELF?a():t===e?this:r===O.SELF||this.resolvedDependencyCollection.has(t)||this.dependencyCollection.has(t)?i():a()}createDependency(e,t,n,r=!0){let i=()=>{let n=this.dependencyCollection.get(e,t),i=null;return i=Array.isArray(n)?n.map(t=>this._resolveDependency(e,t,r)):this._resolveDependency(e,n,r),i},a=()=>{if(this.parent)return this.parent.createDependency(e,t,void 0,r);if(t===D.OPTIONAL)return null;if(t===D.MANY)return[];throw De(e),new je(e)};return n===O.SKIP_SELF?a():this.dependencyCollection.has(e)?i():a()}markNewResolution(e){if(this.resolutionOngoing+=1,this.resolutionOngoing>=Ie)throw new Re(e)}markResolutionCompleted(){--this.resolutionOngoing}_ensureInjectorNotDisposed(){if(this.disposed)throw new ze}},Ge=typeof globalThis<`u`&&globalThis||typeof window<`u`&&window||typeof global<`u`&&global,Ke=`REDI_GLOBAL_LOCK`,qe=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;Ge[Ke]?qe||console.error(`[redi]: You are loading scripts of redi more than once! This may cause undesired behavior in your application.
|
|
3
3
|
Maybe your dependencies added redi as its dependency and bundled redi to its dist files. Or you import different versions of redi.
|
|
4
4
|
For more info please visit our website: https://redi.wendell.fun/en-US/docs/faq#import-scripts-of-redi-more-than-once`):Ge[Ke]=!0;var Je=typeof global==`object`&&global&&global.Object===Object&&global,Ye=typeof self==`object`&&self&&self.Object===Object&&self,Xe=Je||Ye||Function(`return this`)(),Ze=Xe.Symbol,Qe=Object.prototype,$e=Qe.hasOwnProperty,et=Qe.toString,tt=Ze?Ze.toStringTag:void 0;function nt(e){var t=$e.call(e,tt),n=e[tt];try{e[tt]=void 0;var r=!0}catch{}var i=et.call(e);return r&&(t?e[tt]=n:delete e[tt]),i}var rt=Object.prototype.toString;function it(e){return rt.call(e)}var at=`[object Null]`,ot=`[object Undefined]`,st=Ze?Ze.toStringTag:void 0;function ct(e){return e==null?e===void 0?ot:at:st&&st in Object(e)?nt(e):it(e)}function lt(e){return typeof e==`object`&&!!e}var ut=`[object Symbol]`;function dt(e){return typeof e==`symbol`||lt(e)&&ct(e)==ut}function ft(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var pt=Array.isArray,mt=1/0,ht=Ze?Ze.prototype:void 0,gt=ht?ht.toString:void 0;function _t(e){if(typeof e==`string`)return e;if(pt(e))return ft(e,_t)+``;if(dt(e))return gt?gt.call(e):``;var t=e+``;return t==`0`&&1/e==-mt?`-0`:t}var vt=/\s/;function yt(e){for(var t=e.length;t--&&vt.test(e.charAt(t)););return t}var bt=/^\s+/;function xt(e){return e&&e.slice(0,yt(e)+1).replace(bt,``)}function St(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Ct=NaN,wt=/^[-+]0x[0-9a-f]+$/i,Tt=/^0b[01]+$/i,Et=/^0o[0-7]+$/i,Dt=parseInt;function Ot(e){if(typeof e==`number`)return e;if(dt(e))return Ct;if(St(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=St(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=xt(e);var n=Tt.test(e);return n||Et.test(e)?Dt(e.slice(2),n?2:8):wt.test(e)?Ct:+e}function kt(e){return e}var At=`[object AsyncFunction]`,jt=`[object Function]`,Mt=`[object GeneratorFunction]`,Nt=`[object Proxy]`;function Pt(e){if(!St(e))return!1;var t=ct(e);return t==jt||t==Mt||t==At||t==Nt}var Ft=Xe[`__core-js_shared__`],It=function(){var e=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Lt(e){return!!It&&It in e}var Rt=Function.prototype.toString;function zt(e){if(e!=null){try{return Rt.call(e)}catch{}try{return e+``}catch{}}return``}var Bt=/[\\^$.*+?()[\]{}|]/g,Vt=/^\[object .+?Constructor\]$/,Ht=Function.prototype,Ut=Object.prototype,Wt=Ht.toString,Gt=Ut.hasOwnProperty,Kt=RegExp(`^`+Wt.call(Gt).replace(Bt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function qt(e){return!St(e)||Lt(e)?!1:(Pt(e)?Kt:Vt).test(zt(e))}function Jt(e,t){return e?.[t]}function Yt(e,t){var n=Jt(e,t);return qt(n)?n:void 0}var Xt=Object.create,Zt=function(){function e(){}return function(t){if(!St(t))return{};if(Xt)return Xt(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Qt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function $t(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var en=800,tn=16,nn=Date.now;function rn(e){var t=0,n=0;return function(){var r=nn(),i=tn-(r-n);if(n=r,i>0){if(++t>=en)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function an(e){return function(){return e}}var on=function(){try{var e=Yt(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),sn=rn(on?function(e,t){return on(e,`toString`,{configurable:!0,enumerable:!1,value:an(t),writable:!0})}:kt),cn=9007199254740991,ln=/^(?:0|[1-9]\d*)$/;function un(e,t){var n=typeof e;return t??=cn,!!t&&(n==`number`||n!=`symbol`&&ln.test(e))&&e>-1&&e%1==0&&e<t}function dn(e,t,n){t==`__proto__`&&on?on(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function fn(e,t){return e===t||e!==e&&t!==t}var pn=Object.prototype.hasOwnProperty;function mn(e,t,n){var r=e[t];(!(pn.call(e,t)&&fn(r,n))||n===void 0&&!(t in e))&&dn(e,t,n)}function hn(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?dn(n,s,c):mn(n,s,c)}return n}var gn=Math.max;function _n(e,t,n){return t=gn(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=gn(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),Qt(e,this,s)}}function vn(e,t){return sn(_n(e,t,kt),e+``)}var yn=9007199254740991;function bn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=yn}function xn(e){return e!=null&&bn(e.length)&&!Pt(e)}function Sn(e,t,n){if(!St(n))return!1;var r=typeof t;return(r==`number`?xn(n)&&un(t,n.length):r==`string`&&t in n)?fn(n[t],e):!1}function Cn(e){return vn(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Sn(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var wn=Object.prototype;function Tn(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||wn)}function En(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Dn=`[object Arguments]`;function On(e){return lt(e)&&ct(e)==Dn}var kn=Object.prototype,An=kn.hasOwnProperty,jn=kn.propertyIsEnumerable,Mn=On(function(){return arguments}())?On:function(e){return lt(e)&&An.call(e,`callee`)&&!jn.call(e,`callee`)};function Nn(){return!1}var Pn=typeof e==`object`&&e&&!e.nodeType&&e,Fn=Pn&&typeof module==`object`&&module&&!module.nodeType&&module,In=Fn&&Fn.exports===Pn?Xe.Buffer:void 0,Ln=(In?In.isBuffer:void 0)||Nn,Rn=`[object Arguments]`,zn=`[object Array]`,Bn=`[object Boolean]`,Vn=`[object Date]`,Hn=`[object Error]`,Un=`[object Function]`,Wn=`[object Map]`,Gn=`[object Number]`,Kn=`[object Object]`,qn=`[object RegExp]`,Jn=`[object Set]`,Yn=`[object String]`,Xn=`[object WeakMap]`,Zn=`[object ArrayBuffer]`,Qn=`[object DataView]`,$n=`[object Float32Array]`,er=`[object Float64Array]`,tr=`[object Int8Array]`,nr=`[object Int16Array]`,rr=`[object Int32Array]`,ir=`[object Uint8Array]`,ar=`[object Uint8ClampedArray]`,or=`[object Uint16Array]`,sr=`[object Uint32Array]`,cr={};cr[$n]=cr[er]=cr[tr]=cr[nr]=cr[rr]=cr[ir]=cr[ar]=cr[or]=cr[sr]=!0,cr[Rn]=cr[zn]=cr[Zn]=cr[Bn]=cr[Qn]=cr[Vn]=cr[Hn]=cr[Un]=cr[Wn]=cr[Gn]=cr[Kn]=cr[qn]=cr[Jn]=cr[Yn]=cr[Xn]=!1;function lr(e){return lt(e)&&bn(e.length)&&!!cr[ct(e)]}function ur(e){return function(t){return e(t)}}var dr=typeof e==`object`&&e&&!e.nodeType&&e,fr=dr&&typeof module==`object`&&module&&!module.nodeType&&module,pr=fr&&fr.exports===dr&&Je.process,mr=function(){try{return fr&&fr.require&&fr.require(`util`).types||pr&&pr.binding&&pr.binding(`util`)}catch{}}(),hr=mr&&mr.isTypedArray,gr=hr?ur(hr):lr,_r=Object.prototype.hasOwnProperty;function vr(e,t){var n=pt(e),r=!n&&Mn(e),i=!n&&!r&&Ln(e),a=!n&&!r&&!i&&gr(e),o=n||r||i||a,s=o?En(e.length,String):[],c=s.length;for(var l in e)(t||_r.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||un(l,c)))&&s.push(l);return s}function yr(e,t){return function(n){return e(t(n))}}function br(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var xr=Object.prototype.hasOwnProperty;function Sr(e){if(!St(e))return br(e);var t=Tn(e),n=[];for(var r in e)(r!=`constructor`||!t&&xr.call(e,r))&&n.push(r);return n}function Cr(e){return xn(e)?vr(e,!0):Sr(e)}var wr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Tr=/^\w*$/;function Er(e,t){if(pt(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||dt(e)?!0:Tr.test(e)||!wr.test(e)||t!=null&&e in Object(t)}var Dr=Yt(Object,`create`);function Or(){this.__data__=Dr?Dr(null):{},this.size=0}function kr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Ar=`__lodash_hash_undefined__`,jr=Object.prototype.hasOwnProperty;function Mr(e){var t=this.__data__;if(Dr){var n=t[e];return n===Ar?void 0:n}return jr.call(t,e)?t[e]:void 0}var Nr=Object.prototype.hasOwnProperty;function Pr(e){var t=this.__data__;return Dr?t[e]!==void 0:Nr.call(t,e)}var Fr=`__lodash_hash_undefined__`;function Ir(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=Dr&&t===void 0?Fr:t,this}function Lr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Lr.prototype.clear=Or,Lr.prototype.delete=kr,Lr.prototype.get=Mr,Lr.prototype.has=Pr,Lr.prototype.set=Ir;function Rr(){this.__data__=[],this.size=0}function zr(e,t){for(var n=e.length;n--;)if(fn(e[n][0],t))return n;return-1}var Br=Array.prototype.splice;function Vr(e){var t=this.__data__,n=zr(t,e);return n<0?!1:(n==t.length-1?t.pop():Br.call(t,n,1),--this.size,!0)}function Hr(e){var t=this.__data__,n=zr(t,e);return n<0?void 0:t[n][1]}function Ur(e){return zr(this.__data__,e)>-1}function Wr(e,t){var n=this.__data__,r=zr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Gr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Gr.prototype.clear=Rr,Gr.prototype.delete=Vr,Gr.prototype.get=Hr,Gr.prototype.has=Ur,Gr.prototype.set=Wr;var Kr=Yt(Xe,`Map`);function qr(){this.size=0,this.__data__={hash:new Lr,map:new(Kr||Gr),string:new Lr}}function Jr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Yr(e,t){var n=e.__data__;return Jr(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Xr(e){var t=Yr(this,e).delete(e);return this.size-=+!!t,t}function Zr(e){return Yr(this,e).get(e)}function Qr(e){return Yr(this,e).has(e)}function $r(e,t){var n=Yr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ei(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ei.prototype.clear=qr,ei.prototype.delete=Xr,ei.prototype.get=Zr,ei.prototype.has=Qr,ei.prototype.set=$r;var ti=`Expected a function`;function ni(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(ti);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(ni.Cache||ei),n}ni.Cache=ei;var ri=500;function ii(e){var t=ni(e,function(e){return n.size===ri&&n.clear(),e}),n=t.cache;return t}var ai=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,oi=/\\(\\)?/g,si=ii(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(ai,function(e,n,r,i){t.push(r?i.replace(oi,`$1`):n||e)}),t});function ci(e){return e==null?``:_t(e)}function li(e,t){return pt(e)?e:Er(e,t)?[e]:si(ci(e))}var ui=1/0;function di(e){if(typeof e==`string`||dt(e))return e;var t=e+``;return t==`0`&&1/e==-ui?`-0`:t}function fi(e,t){t=li(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[di(t[n++])];return n&&n==r?e:void 0}function pi(e,t,n){var r=e==null?void 0:fi(e,t);return r===void 0?n:r}var mi=yr(Object.getPrototypeOf,Object),hi=`[object Object]`,gi=Function.prototype,_i=Object.prototype,vi=gi.toString,yi=_i.hasOwnProperty,bi=vi.call(Object);function xi(e){if(!lt(e)||ct(e)!=hi)return!1;var t=mi(e);if(t===null)return!0;var n=yi.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&vi.call(n)==bi}function Si(){this.__data__=new Gr,this.size=0}function Ci(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function wi(e){return this.__data__.get(e)}function Ti(e){return this.__data__.has(e)}var Ei=200;function Di(e,t){var n=this.__data__;if(n instanceof Gr){var r=n.__data__;if(!Kr||r.length<Ei-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ei(r)}return n.set(e,t),this.size=n.size,this}function Oi(e){var t=this.__data__=new Gr(e);this.size=t.size}Oi.prototype.clear=Si,Oi.prototype.delete=Ci,Oi.prototype.get=wi,Oi.prototype.has=Ti,Oi.prototype.set=Di;var ki=typeof e==`object`&&e&&!e.nodeType&&e,Ai=ki&&typeof module==`object`&&module&&!module.nodeType&&module,ji=Ai&&Ai.exports===ki?Xe.Buffer:void 0,Mi=ji?ji.allocUnsafe:void 0;function Ni(e,t){if(t)return e.slice();var n=e.length,r=Mi?Mi(n):new e.constructor(n);return e.copy(r),r}var Pi=Xe.Uint8Array;function Fi(e){var t=new e.constructor(e.byteLength);return new Pi(t).set(new Pi(e)),t}function Ii(e,t){var n=t?Fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Li(e){return typeof e.constructor==`function`&&!Tn(e)?Zt(mi(e)):{}}function Ri(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var zi=Ri(),Bi=function(){return Xe.Date.now()},Vi=`Expected a function`,Hi=Math.max,Ui=Math.min;function Wi(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Vi);t=Ot(t)||0,St(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Hi(Ot(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?Ui(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Bi();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Bi())}function x(){var e=Bi(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function Gi(e,t,n){(n!==void 0&&!fn(e[t],n)||n===void 0&&!(t in e))&&dn(e,t,n)}function Ki(e){return lt(e)&&xn(e)}function qi(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}function Ji(e){return hn(e,Cr(e))}function Yi(e,t,n,r,i,a,o){var s=qi(e,n),c=qi(t,n),l=o.get(c);if(l){Gi(e,n,l);return}var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=pt(c),p=!f&&Ln(c),m=!f&&!p&&gr(c);u=c,f||p||m?pt(s)?u=s:Ki(s)?u=$t(s):p?(d=!1,u=Ni(c,!0)):m?(d=!1,u=Ii(c,!0)):u=[]:xi(c)||Mn(c)?(u=s,Mn(s)?u=Ji(s):(!St(s)||Pt(s))&&(u=Li(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Gi(e,n,u)}function Xi(e,t,n,r,i){e!==t&&zi(t,function(a,o){if(i||=new Oi,St(a))Yi(e,t,o,n,Xi,r,i);else{var s=r?r(qi(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Gi(e,o,s)}},Cr)}var Zi=Cn(function(e,t,n,r){Xi(e,t,n,r)}),Qi=Cn(function(e,t,n){Xi(e,t,n)});function $i(e,t,n,r){if(!St(e))return e;t=li(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=di(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=St(u)?u:un(t[i+1])?[]:{})}mn(s,c,l),s=s[c]}return e}function ea(e,t,n){return e==null?e:$i(e,t,n)}var M=function(e){return e[e.UNIVER_UNKNOWN=0]=`UNIVER_UNKNOWN`,e[e.UNIVER_DOC=1]=`UNIVER_DOC`,e[e.UNIVER_SHEET=2]=`UNIVER_SHEET`,e[e.UNIVER_SLIDE=3]=`UNIVER_SLIDE`,e[e.UNIVER_PROJECT=4]=`UNIVER_PROJECT`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({}),ta=function(e){return e[e.View=0]=`View`,e[e.Edit=1]=`Edit`,e[e.ManageCollaborator=2]=`ManageCollaborator`,e[e.Print=3]=`Print`,e[e.Duplicate=4]=`Duplicate`,e[e.Comment=5]=`Comment`,e[e.Copy=6]=`Copy`,e[e.Share=7]=`Share`,e[e.Export=8]=`Export`,e[e.MoveWorksheet=9]=`MoveWorksheet`,e[e.DeleteWorksheet=10]=`DeleteWorksheet`,e[e.HideWorksheet=11]=`HideWorksheet`,e[e.RenameWorksheet=12]=`RenameWorksheet`,e[e.CreateWorksheet=13]=`CreateWorksheet`,e[e.SetWorksheetStyle=14]=`SetWorksheetStyle`,e[e.EditWorksheetCell=15]=`EditWorksheetCell`,e[e.InsertHyperlink=16]=`InsertHyperlink`,e[e.Sort=17]=`Sort`,e[e.Filter=18]=`Filter`,e[e.PivotTable=19]=`PivotTable`,e[e.FloatImg=20]=`FloatImg`,e[e.IHistory=21]=`IHistory`,e[e.RwHgtClWdt=22]=`RwHgtClWdt`,e[e.ViemRwHgtClWdt=23]=`ViemRwHgtClWdt`,e[e.ViewFilter=24]=`ViewFilter`,e[e.MoveSheet=25]=`MoveSheet`,e[e.DeleteSheet=26]=`DeleteSheet`,e[e.HideSheet=27]=`HideSheet`,e[e.CopySheet=28]=`CopySheet`,e[e.RenameSheet=29]=`RenameSheet`,e[e.CreateSheet=30]=`CreateSheet`,e[e.SelectProtectedCells=31]=`SelectProtectedCells`,e[e.SelectUnProtectedCells=32]=`SelectUnProtectedCells`,e[e.SetCellStyle=33]=`SetCellStyle`,e[e.SetCellValue=34]=`SetCellValue`,e[e.SetRowStyle=35]=`SetRowStyle`,e[e.SetColumnStyle=36]=`SetColumnStyle`,e[e.InsertRow=37]=`InsertRow`,e[e.InsertColumn=38]=`InsertColumn`,e[e.DeleteRow=39]=`DeleteRow`,e[e.DeleteColumn=40]=`DeleteColumn`,e[e.EditExtraObject=41]=`EditExtraObject`,e[e.Delete=42]=`Delete`,e[e.RecoverHistory=43]=`RecoverHistory`,e[e.ViewHistory=44]=`ViewHistory`,e[e.CreatePermissionObject=45]=`CreatePermissionObject`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({}),na=function(e){return e[e.Reader=0]=`Reader`,e[e.Editor=1]=`Editor`,e[e.Owner=2]=`Owner`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({}),ra=function(e){return e[e.Unkonwn=0]=`Unkonwn`,e[e.Workbook=1]=`Workbook`,e[e.Worksheet=2]=`Worksheet`,e[e.SelectRange=3]=`SelectRange`,e[e.Document=4]=`Document`,e[e.Slide=5]=`Slide`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({}),ia=function(e){return e[e.SomeCollaborator=0]=`SomeCollaborator`,e[e.AllCollaborator=1]=`AllCollaborator`,e[e.OneSelf=2]=`OneSelf`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({}),aa=function(e,t){return aa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},aa(e,t)};function oa(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);aa(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var sa=function(){return sa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},sa.apply(this,arguments)};function ca(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function la(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function ua(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function da(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function fa(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function pa(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function ma(e){return this instanceof ma?(this.v=e,this):new ma(e)}function ha(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof ma?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ga(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof da==`function`?da(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function _a(e){return typeof e==`function`}function va(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ya=va(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
@@ -590,8 +590,8 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
|
|
|
590
590
|
`)}\r\n`;return this.insertText(n,{...t,cursorOffset:t.cursorOffset??n.length})}setSelection(e,t){let n=this._renderManagerService.getRenderById(this.getId())?.with(XF);n?.removeAllRanges(),n?.addDocRanges([{startOffset:e,endOffset:t,rangeType:xh.TEXT}],!0)}};OU=oat([DU(1,j(We)),DU(2,z),DU(3,R),DU(4,By),DU(5,KE)],OU);var sat=class extends pS{createUniverDoc(e){let t=this._univerInstanceService.createUnit(M.UNIVER_DOC,e);return this._injector.createInstance(OU,t)}getActiveDocument(){let e=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_DOC);return e?this._injector.createInstance(OU,e):null}getUniverDoc(e){let t=this._univerInstanceService.getUniverDocInstance(e);return t?this._injector.createInstance(OU,t):null}};pS.extend(sat);function cat(e={}){let{container:t=`app`,header:n,footer:r,toolbar:i,ribbonType:a,menu:o,contextMenu:s,disableAutoFocus:c}=e;return{plugins:[wU,sD,YE,[_N,{container:t,header:n,footer:r,toolbar:i,ribbonType:a,menu:o,contextMenu:s,disableAutoFocus:c}],wL,pU]}}var lat={design:{Confirm:{cancel:`取消`,confirm:`确定`},CascaderList:{empty:`无`},Calendar:{year:`年`,weekDays:[`日`,`一`,`二`,`三`,`四`,`五`,`六`],months:[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`]},Select:{empty:`无`},ColorPicker:{more:`更多颜色`,cancel:`取消`,confirm:`确定`},GradientColorPicker:{linear:`线性`,radial:`径向`,angular:`角向`,diamond:`菱形`,offset:`偏移`,angle:`角度`,flip:`翻转`,delete:`删除`}}},uat={"docs-ui":{toolbar:{undo:`撤销`,redo:`重做`,font:`字体`,fontSize:`字号`,bold:`粗体`,italic:`斜体`,strikethrough:`删除线`,subscript:`下标`,superscript:`上标`,underline:`下划线`,textColor:{main:`文本颜色`},fillColor:{main:`文本背景色`},table:{main:`表格`,insert:`插入表格`,colCount:`列数`,rowCount:`行数`},resetColor:`重置颜色`,order:`有序列表`,unorder:`无序列表`,checklist:`任务列表`,documentFlavor:`现代模式`,alignLeft:`左对齐`,alignCenter:`居中对齐`,alignRight:`右对齐`,alignJustify:`两端对齐`,horizontalLine:`水平分割线`,headerFooter:`页眉页脚`,pageSetup:`页面设置`},table:{insert:`插入`,insertRowAbove:`上方插入行`,insertRowBelow:`下方插入行`,insertColumnLeft:`左方插入列`,insertColumnRight:`右方插入列`,delete:`表格删除`,deleteRows:`删除行`,deleteColumns:`删除列`,deleteTable:`删除表格`},headerFooter:{header:`页眉`,footer:`页脚`,panel:`页眉页脚设置`,firstPageCheckBox:`首页不同`,oddEvenCheckBox:`奇偶页不同`,headerTopMargin:`页眉顶端距离`,footerBottomMargin:`页脚底端距离`,closeHeaderFooter:`关闭页眉页脚`,disableText:`页眉页脚设置不可用`},doc:{menu:{paragraphSetting:`段落设置`},slider:{paragraphSetting:`段落设置`},paragraphSetting:{alignment:`对齐方式`,indentation:`缩进`,left:`左边距`,right:`右边距`,firstLine:`首行`,hanging:`悬挂`,spacing:`间距`,before:`段落前`,after:`段落后`,lineSpace:`行距`,multiSpace:`多倍行距`,fixedValue:`固定值(px)`}},rightClick:{copy:`复制`,cut:`剪切`,paste:`粘贴`,delete:`删除`,bulletList:`无序列表`,orderList:`有序列表`,checkList:`任务列表`,insertBellow:`在下方插入`},"page-settings":{"document-setting":`文档设置`,mode:`模式`,"modern-mode":`现代模式`,"classic-mode":`经典模式`,"modern-width":`内容宽度`,"modern-width-narrow":`窄`,"modern-width-medium":`适中`,"modern-width-wide":`宽`,"page-size":{main:`纸张大小`,a4:`A4`,a3:`A3`,a5:`A5`,b4:`B4`,b5:`B5`,letter:`美式信纸`,legal:`美式法律用纸`,tabloid:`小报尺寸`,statement:`声明用纸`,executive:`行政用纸`,folio:`对开纸`},"paper-size":`纸张大小`,orientation:`方向`,portrait:`纵向`,landscape:`横向`,"custom-paper-size":`自定义纸张大小`,top:`上`,bottom:`下`,left:`左`,right:`右`,cancel:`取消`,confirm:`确认`}}},dat={ui:{toolbar:{heading:{normal:`正文`,title:`标题`,subTitle:`副标题`,1:`标题1`,2:`标题2`,3:`标题3`,4:`标题4`,5:`标题5`,6:`标题6`,tooltip:`设置标题`}},ribbon:{start:`开始`,startDesc:`初始化工作表并设置基本参数。`,insert:`插入`,insertDesc:`插入行、列、图表和各种其他元素。`,formulas:`公式`,formulasDesc:`使用函数和公式进行数据计算。`,data:`数据`,dataDesc:`管理数据,包括导入、排序和筛选。`,view:`视图`,viewDesc:`切换视图模式并调整显示效果。`,others:`其他`,othersDesc:`其他功能和设置。`,more:`更多`},fontFamily:{"not-supported":`系统中未找到该字体,使用默认字体。`,arial:`Arial`,"times-new-roman":`Times New Roman`,tahoma:`Tahoma`,verdana:`Verdana`,"microsoft-yahei":`微软雅黑`,simsun:`宋体`,simhei:`黑体`,kaiti:`楷体`,fangsong:`仿宋`,nsimsun:`新宋体`,stxinwei:`华文新魏`,stxingkai:`华文行楷`,stliti:`华文隶书`},"shortcut-panel":{title:`快捷键面板`},shortcut:{undo:`撤销`,redo:`重做`,cut:`剪切`,copy:`复制`,paste:`粘贴`,"shortcut-panel":`打开收起快捷键面板`},"common-edit":`常用编辑`,"toggle-shortcut-panel":`打开收起快捷键面板`,clipboard:{authentication:{title:`无法访问剪贴板`,content:`请允许 Univer 访问您的剪贴板。`}},textEditor:{formulaError:`请输入合法的公式,例如=SUM(A1)`,rangeError:`请输入合法的范围,例如 A1:B10`},rangeSelector:{title:`选择一个数据范围`,addAnotherRange:`添加范围`,buttonTooltip:`选择数据范围`,placeHolder:`框选范围或输入`,confirm:`确认`,cancel:`取消`},"global-shortcut":`全局快捷键`,"zoom-slider":{resetTo:`恢复至`},row:`行`,column:`列`}},fat=Rg(lat,uat,dat),pat=class extends TN{},kU=ce(`univer.doc.plugin.doc-drawing.service`);function AU(e,t){return function(n,r){t(n,r,e)}}function mat(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var hat=`DOC_DRAWING_PLUGIN`,jU=class extends P{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,M.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder;return JSON.stringify({data:e??{},order:n??[]})}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:hat,businesses:[M.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{this._setDrawingDataForUnit(e,{data:t.data??{},order:t.order??[]})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,M.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};jU=mat([AU(0,kU),AU(1,xN),AU(2,By),AU(3,z)],jU);var gat=`@univerjs/docs-drawing`,_at=`0.25.1`,vat=`docs-drawing.config`,yat={};function MU(e){"@babel/helpers - typeof";return MU=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},MU(e)}function bat(e,t){if(MU(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(MU(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function xat(e){var t=bat(e,`string`);return MU(t)==`symbol`?t:t+``}function NU(e,t,n){return(t=xat(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var PU=class extends dx{constructor(e=yat,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=Qi({},yat,this._config);this._configService.setConfig(vat,r)}onStarting(){[[jU],[pat],[kU,{useClass:pat}]].forEach(e=>this._injector.add(e)),ff(this._injector,[[jU]])}};NU(PU,`pluginName`,hat),NU(PU,`packageName`,gat),NU(PU,`version`,_at),NU(PU,`type`,M.UNIVER_DOC),PU=mat([AU(1,j(We)),AU(2,Nm)],PU);var FU={id:`sheet.operation.set-image-align`,type:L.OPERATION,handler:(e,t)=>!0},IU={id:`sheet.operation.set-drawing-align-left`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`1`})},LU={id:`sheet.operation.set-drawing-align-center`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`2`})},RU={id:`sheet.operation.set-drawing-align-right`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`3`})},zU={id:`sheet.operation.set-drawing-align-top`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`4`})},BU={id:`sheet.operation.set-drawing-align-middle`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`5`})},VU={id:`sheet.operation.set-drawing-align-bottom`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`6`})},HU={id:`sheet.operation.set-drawing-align-horizon`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`7`})},UU={id:`sheet.operation.set-drawing-align-vertical`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(FU.id,{alignType:`8`})},WU={id:`drawing.operation.set-drawing-arrange`,type:L.OPERATION,handler:(e,t)=>{let n=e.get(xN),{arrangeType:r}=t,i=t.drawings||n.getFocusDrawings(),{unitId:a,subUnitId:o}=i[0],s=i.map(e=>e.drawingId);return n.featurePluginOrderUpdateNotification({unitId:a,subUnitId:o,drawingIds:s,arrangeType:r}),!0}},GU={id:`drawing.operation.set-drawing-arrange-front`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(WU.id,{arrangeType:lm.front})},KU={id:`drawing.operation.set-drawing-arrange-forward`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(WU.id,{arrangeType:lm.forward})},qU={id:`drawing.operation.set-drawing-arrange-back`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(WU.id,{arrangeType:lm.back})},JU={id:`drawing.operation.set-drawing-arrange-backward`,type:L.OPERATION,handler:e=>e.get(R).syncExecuteCommand(WU.id,{arrangeType:lm.backward})},YU=[um.DRAWING_IMAGE,um.DRAWING_SHAPE,um.DRAWING_GROUP],XU={id:`drawing.operation.set-drawing-group`,type:L.OPERATION,handler:(e,t)=>{let n=e.get(xN),r=t.drawings||n.getFocusDrawings();if(r.length<2||!r.every(e=>YU.includes(e.drawingType)))return!1;let{unitId:i,subUnitId:a}=r[0],o=ip(10),s=Uw(0,0,r.map(e=>e.transform||{})),c={unitId:i,subUnitId:a,drawingId:o,drawingType:um.DRAWING_GROUP,transform:s,groupBaseBound:{left:s.left,top:s.top,width:s.width,height:s.height}},l=r.map(e=>{let t=e.transform||{left:0,top:0},{unitId:n,subUnitId:r,drawingId:i}=e;return{unitId:n,subUnitId:r,drawingId:i,transform:{...t},groupId:o}});return n.featurePluginGroupUpdateNotification([{parent:c,children:l}]),!0}},ZU={id:`drawing.operation.cancel-drawing-group`,type:L.OPERATION,handler:(e,t)=>{let n=e.get(xN),r=(t.drawings||n.getFocusDrawings()).map(e=>{if(e.drawingType!==um.DRAWING_GROUP)return null;let{unitId:t,subUnitId:r,drawingId:i,transform:a={width:0,height:0},groupBaseBound:o}=e;if(a===null)return null;let s=n.getDrawingsByGroup({unitId:t,subUnitId:r,drawingId:i});return s.length===0?null:{parent:e,children:s.map(e=>{let{transform:t}=e,{unitId:n,subUnitId:r,drawingId:i}=e,s=Ww(t||{},a,a.width||0,a.height||0,o);return{unitId:n,subUnitId:r,drawingId:i,transform:{...t,...s},groupId:void 0}})}}).filter(e=>e!==null);return r.length!==0&&(n.featurePluginUngroupUpdateNotification(r),!0)}},QU={id:`sheet.operation.open-image-crop`,type:L.OPERATION,handler:(e,t)=>!0},$U={id:`sheet.operation.close-image-crop`,type:L.OPERATION,handler:(e,t)=>!0},eW={id:`sheet.operation.Auto-image-crop`,type:L.OPERATION,handler:(e,t)=>!0},tW={id:`sheet.operation.image-reset-size`,type:L.OPERATION,handler:(e,t)=>!0};function nW(e,t,n,r){let i=r.getDrawingByParam(e);if(i==null)return;let a=ON(e),o=n.getObjectIncludeInGroup(a);if(o&&!(o instanceof IE))return;if(o!=null){let e=o.getObjects();for(let n of e)if(n.oKey===t.oKey)return;o.addObject(t);return}let s=new Dke(a);n.addObject(s,4).attachTransformerTo(s),s.addObject(t);let{transform:c,groupBaseBound:l}=i;l&&s.setBaseBound(l),i.groupId&&(s.isInGroup=!0,nW({drawingId:i.groupId,unitId:e.unitId,subUnitId:e.subUnitId},s,n,r)),c&&s.transformByState({left:c.left,top:c.top,angle:c.angle,width:c.width,height:c.height})}function Sat(e,t){let n=t?e.getUnit(t):e.getFocusedUnit();if(n==null)return;let r=n.getUnitId(),i;return n.type===M.UNIVER_SHEET?i=n.getActiveSheet()?.getSheetId():(n.type===M.UNIVER_DOC||n.type===M.UNIVER_SLIDE)&&(i=r),{unitId:r,subUnitId:i,current:n}}var Cat=`@univerjs/drawing-ui`,wat=`0.25.1`,Tat=`drawing-ui.config`,Eat={},Dat=e=>{let t=e.get(xN);return new Ya(e=>{let n=t=>{if(!t||t.length===0||t.length<2)return e.next(!0);e.next(!1)},r=t.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);n(t)});return n(t.getFocusDrawings()),()=>r.unsubscribe()})},Oat=`contextMenu.drawing-align`;function kat(e){return{id:Oat,type:bM.SUBITEMS,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.title`,hidden$:Dat(e)}}function Aat(){return{id:IU.id,type:bM.BUTTON,icon:`LeftJustifyingIcon`,title:`drawing-ui.image-panel.align.left`}}function jat(){return{id:LU.id,type:bM.BUTTON,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.center`}}function Mat(){return{id:RU.id,type:bM.BUTTON,icon:`RightJustifyingIcon`,title:`drawing-ui.image-panel.align.right`}}function Nat(){return{id:zU.id,type:bM.BUTTON,icon:`AlignTopIcon`,title:`drawing-ui.image-panel.align.top`}}function Pat(){return{id:BU.id,type:bM.BUTTON,icon:`VerticalCenterIcon`,title:`drawing-ui.image-panel.align.middle`}}function Fat(){return{id:VU.id,type:bM.BUTTON,icon:`AlignBottomIcon`,title:`drawing-ui.image-panel.align.bottom`}}function Iat(){return{id:HU.id,type:bM.BUTTON,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.horizon`}}function Lat(){return{id:UU.id,type:bM.BUTTON,icon:`VerticalCenterIcon`,title:`drawing-ui.image-panel.align.vertical`}}var Rat=`contextMenu.drawing-arrange`;function zat(){return{id:Rat,type:bM.SUBITEMS,icon:`TopmostIcon`,title:`drawing-ui.image-panel.arrange.title`}}function Bat(){return{id:GU.id,type:bM.BUTTON,icon:`TopmostIcon`,title:`drawing-ui.image-panel.arrange.front`}}function Vat(){return{id:KU.id,type:bM.BUTTON,icon:`MoveUpIcon`,title:`drawing-ui.image-panel.arrange.forward`}}function Hat(){return{id:qU.id,type:bM.BUTTON,icon:`BottomIcon`,title:`drawing-ui.image-panel.arrange.back`}}function Uat(){return{id:JU.id,type:bM.BUTTON,icon:`MoveDownIcon`,title:`drawing-ui.image-panel.arrange.backward`}}var rW=(e,t)=>{let n=e.get(xN);return new Ya(e=>{let r=n=>{if(!n||n.length===0)return e.next(!0);if(t===`group`){if(n.length<2||!n.every(e=>YU.includes(e.drawingType)))return e.next(!0)}else if(t===`unGroup`){if(n.filter(e=>e.drawingType===um.DRAWING_GROUP).length===0)return e.next(!0)}else if(!n.every(e=>YU.includes(e.drawingType)))return e.next(!0);e.next(!1)},i=n.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);r(t)});return r(n.getFocusDrawings()),()=>i.unsubscribe()})},Wat=`contextMenu.drawing-group`;function Gat(e){return{id:Wat,type:bM.SUBITEMS,icon:`GroupIcon`,title:`drawing-ui.image-panel.group.title`,hidden$:rW(e)}}function Kat(e){return{id:XU.id,type:bM.BUTTON,icon:`GroupIcon`,title:`drawing-ui.image-panel.group.group`,disabled$:rW(e,`group`)}}function qat(e){return{id:ZU.id,type:bM.BUTTON,icon:`UngroupIcon`,title:`drawing-ui.image-panel.group.unGroup`,disabled$:rW(e,`unGroup`)}}var Jat={[hM.DRAWING]:{[gM.OTHERS]:{[Wat]:{order:1,menuItemFactory:Gat,[XU.id]:{order:0,menuItemFactory:Kat},[ZU.id]:{order:1,menuItemFactory:qat}},[Rat]:{order:2,menuItemFactory:zat,[GU.id]:{order:0,menuItemFactory:Bat},[KU.id]:{order:1,menuItemFactory:Vat},[qU.id]:{order:2,menuItemFactory:Hat},[JU.id]:{order:3,menuItemFactory:Uat}},[Oat]:{order:3,menuItemFactory:kat,[IU.id]:{order:0,menuItemFactory:Aat},[LU.id]:{order:1,menuItemFactory:jat},[RU.id]:{order:2,menuItemFactory:Mat},[zU.id]:{order:3,menuItemFactory:Nat},[BU.id]:{order:4,menuItemFactory:Pat},[VU.id]:{order:5,menuItemFactory:Fat},[HU.id]:{order:6,menuItemFactory:Iat},[UU.id]:{order:7,menuItemFactory:Lat}}}}},iW=`COMPONENT_IMAGE_POPUP_MENU`;function Yat(e){var t;let{popup:n}=e,r=n==null||(t=n.extraProps)==null?void 0:t.menuItems;if(!r)return null;if(n.extraProps?.variant===`doc-floating-toolbar`&&n.extraProps.unitId&&n.extraProps.subUnitId&&n.extraProps.drawingId)return(0,H.jsx)(tot,{menuItems:r,unitId:n.extraProps.unitId,subUnitId:n.extraProps.subUnitId,drawingId:n.extraProps.drawingId});let i=U(R),a=U(nx),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),u=()=>{l(!0)},d=()=>{l(!1)},f=e=>{s(e)},p=e=>{i.executeCommand(e.commandId,e.commandParams),s(!1)},m=o||c;return(0,H.jsx)(`div`,{onMouseEnter:u,onMouseLeave:d,children:(0,H.jsx)(sj,{align:`start`,items:r.map(e=>({type:`item`,children:a.t(e.label),disabled:e.disable,onSelect:()=>p(e)})),open:o,onOpenChange:f,children:(0,H.jsxs)(`div`,{className:W(`univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800`,qA,{"univer-bg-gray-100 dark:!univer-bg-gray-800":o,"univer-bg-white dark:!univer-bg-gray-900":!o}),children:[(0,H.jsx)(qD,{className:`univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white`}),m&&(0,H.jsx)(ID,{className:`dark:!univer-text-white`})]})})})}var Xat=`doc.command.update-doc-drawing-wrapping-style`;function Zat(e,t){var n;let r=e==null||(n=e.getSnapshot().drawings)==null?void 0:n[t];return r?r.layoutType===Kp.WRAP_NONE?r.behindDoc===Np.TRUE?`behindText`:`inFrontOfText`:r.layoutType===Kp.WRAP_SQUARE?`wrapSquare`:r.layoutType===Kp.WRAP_TOP_AND_BOTTOM?`wrapTopAndBottom`:`inline`:`inline`}function Qat(){return(0,H.jsx)(`span`,{className:`
|
|
591
591
|
univer-h-5 univer-w-px univer-bg-gray-200
|
|
592
592
|
dark:!univer-bg-gray-700
|
|
593
|
-
`})}function aW(e){return(0,H.jsx)(`div`,{className:`univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1`,children:e.children})}function oW(e){return(0,H.jsx)(fj,{title:e.title,placement:`bottom`,children:(0,H.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:W(`univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":e.active}),children:e.children})})}function sW(){return(0,H.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`1em`,height:`1em`,fill:`none`,"aria-hidden":`true`,children:[(0,H.jsx)(`path`,{d:`M2.5 4.5H8.2`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M11.8 4.5H17.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M2.5 10H5.7`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M14.3 10H17.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M2.5 15.5H8.2`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M11.8 15.5H17.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`rect`,{x:`6.8`,y:`7`,width:`6.4`,height:`6`,rx:`1`,stroke:`currentColor`,strokeWidth:`1.4`})]})}function $at(){return(0,H.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`1em`,height:`1em`,fill:`none`,"aria-hidden":`true`,children:[(0,H.jsx)(`path`,{d:`M5 2.8V12.5C5 13.9 6.1 15 7.5 15H17.2`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M2.8 5H12.5C13.9 5 15 6.1 15 7.5V17.2`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M8.3 8.3H11.7V11.7H8.3V8.3Z`,stroke:`currentColor`,strokeWidth:`1.2`})]})}function eot(e){let[t,n]=(0,V.useState)(!1),r=e.options.find(t=>t.value===e.value)??e.options[0];return(0,H.jsx)(oj,{open:t,onOpenChange:n,overlay:(0,H.jsx)(`div`,{className:`univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,children:e.options.map(t=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{e.onChange(t.value),n(!1)},className:W(`univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800`,{"univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300":t.value===e.value}),children:[(0,H.jsx)(`span`,{className:`univer-flex univer-size-4 univer-items-center univer-justify-center`,children:t.icon}),(0,H.jsx)(`span`,{className:`univer-flex-1`,children:t.label})]},t.value))}),children:(0,H.jsx)(`span`,{children:(0,H.jsx)(fj,{title:e.title,placement:`bottom`,children:(0,H.jsxs)(`button`,{type:`button`,className:W(`univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":t}),children:[r.icon,(0,H.jsx)(ID,{className:`univer-text-xs`})]})})})})}function tot(e){let t=U(R),n=U(nx),r=U(z).getUnit(e.unitId,M.UNIVER_DOC)??void 0,[i,a]=(0,V.useState)(()=>Zat(r,e.drawingId)),[o,s]=(0,V.useState)(!1),c=t=>e.menuItems.find(e=>e.label===t),l=c(`drawing-ui.image-popup.edit`),u=c(`drawing-ui.image-popup.crop`),d=c(`drawing-ui.image-popup.delete`),f=[{label:n.t(`drawing-ui.image-text-wrap.inline`),value:`inline`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.square`),value:`wrapSquare`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.topAndBottom`),value:`wrapTopAndBottom`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.behindText`),value:`behindText`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.inFrontText`),value:`inFrontOfText`,icon:(0,H.jsx)(sW,{})}],p=e=>{e&&!e.disable&&t.executeCommand(e.commandId,e.commandParams)};return o?null:(0,H.jsxs)(`div`,{"data-u-comp":`doc-image-floating-toolbar`,onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},className:W(`univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,qA),children:[(0,H.jsx)(aW,{children:(0,H.jsx)(eot,{title:f.find(e=>e.value===i)?.label??n.t(`drawing-ui.image-text-wrap.inline`),value:i,options:f,onChange:n=>{a(n),t.executeCommand(Xat,{unitId:e.unitId,subUnitId:e.subUnitId,drawings:[{unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}],wrappingStyle:n})}})}),(0,H.jsx)(Qat,{}),(0,H.jsxs)(aW,{children:[(0,H.jsx)(oW,{title:l?n.t(l.label):n.t(`drawing-ui.image-popup.edit`),disabled:!l||l.disable,onClick:()=>{s(!0),p(l)},children:(0,H.jsx)(xD,{})}),(0,H.jsx)(oW,{title:u?n.t(u.label):n.t(`drawing-ui.image-popup.crop`),disabled:!u||u.disable,onClick:()=>p(u),children:(0,H.jsx)($at,{})})]}),(0,H.jsx)(Qat,{}),(0,H.jsx)(aW,{children:(0,H.jsx)(oW,{title:d?n.t(d.label):n.t(`drawing-ui.image-popup.delete`),disabled:!d||d.disable,onClick:()=>p(d),children:(0,H.jsx)(yD,{})})})]})}function cW(e,t){return function(n,r){t(n,r,e)}}function lW(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var uW=class extends P{constructor(e,t,n){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._init()}_init(){this._initMenus(),this._initCommands(),this._initComponents()}_initMenus(){this._menuManagerService.mergeMenu(Jat)}_initCommands(){[QU,$U,tW,FU,IU,LU,RU,zU,BU,VU,HU,UU,eW,XU,ZU,WU,GU,KU,qU,JU].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initComponents(){[[iW,Yat],[`BottomIcon`,WAe],[`GroupIcon`,dMe],[`MoveDownIcon`,rNe],[`MoveUpIcon`,aNe],[`TopmostIcon`,iPe],[`UngroupIcon`,fPe]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};uW=lW([cW(0,j(Nj)),cW(1,R),cW(2,_M)],uW);function dW(e,t){let n=[];return e.forEach(e=>{let{oKey:r,left:i,top:a,height:o,width:s,angle:c}=e,l=t.getDrawingOKey(r);if(l==null)return n.push(null),!0;let{unitId:u,subUnitId:d,drawingId:f,drawingType:p}=l,m={unitId:u,subUnitId:d,drawingId:f,drawingType:p,transform:{left:i,top:a,height:o,width:s,angle:c}};p===um.DRAWING_IMAGE&&(m.srcRect=e.srcRect),n.push(m)}),n}function fW(e){"@babel/helpers - typeof";return fW=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},fW(e)}function not(e,t){if(fW(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(fW(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function rot(e){var t=not(e,`string`);return fW(t)==`symbol`?t:t+``}function pW(e,t,n){return(t=rot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mW=class extends P{constructor(e,t,n,r){super(),this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._drawingManagerService=r,pW(this,`_sceneListenerOnDrawingMap`,new WeakSet),this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){let e=this._drawingManagerService.drawingManagerData,t=Sat(this._currentUniverService);if(t==null)return;let{unitId:n,subUnitId:r}=t;Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(i=>{let a=e[t][i].data;a!=null&&t===n&&i===r&&Object.keys(a).forEach(e=>{a[e]&&this._insertDrawing([{unitId:t,subUnitId:i,drawingId:e}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===FU.id){let t=e.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(e=>{this._groupDrawings(e)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(e=>{this._ungroupDrawings(e)}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e)?.scene;return t==null?null:{scene:t,transformer:t.getTransformerByCreate()}}_groupDrawings(e){e.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;let{scene:s,transformer:c}=o;this._commandService.syncExecuteCommand($U.id);let l=[];if(n.forEach(e=>{let t=ON(e),n=s.getObjectIncludeInGroup(t);if(n==null||l.includes(n))return;l.push(n);let{transform:r}=e;r!=null&&(n.classType===yw.GROUP?n.transformByState({left:r.left,top:r.top}):n.transformByState(r))}),l.length===0)return;let u=new Dke(ON({unitId:r,subUnitId:i,drawingId:a}));s.addObject(u,4).attachTransformerTo(u),u.addObjects(...l),t.groupBaseBound&&u.setBaseBound(t.groupBaseBound),t.groupId&&(u.isInGroup=!0,nW({drawingId:t.groupId,unitId:r,subUnitId:i},u,s,this._drawingManagerService)),t.transform&&u.transformByState({left:t.transform.left,top:t.transform.top,width:t.transform.width,height:t.transform.height,angle:t.transform.angle}),c.clearSelectedObjects(),c.setSelectedControl(u)}_ungroupDrawings(e){e.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(e){let{parent:t,children:n}=e,r=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(r==null)return;let{scene:i,transformer:a}=r;n.forEach(e=>{let t=ON(e),n=i.getObjectIncludeInGroup(t);if(n==null)return!0;if(n==null)return;let{transform:r}=e;r!=null&&(n.classType===yw.GROUP?n.transformByState({left:r.left,top:r.top}):n.transformByState(r))});let o=ON(t),s=i.getObject(o),{width:c,height:l}=s;s.getObjects().forEach(e=>{s.removeSelfObjectAndTransform(e.oKey,c,l)}),s.dispose(),a.clearSelectedObjects()}_drawingAlign(e){let{alignType:t}=e,n=e.drawings||this._drawingManagerService.getFocusDrawings();if(t===`0`)return;let r=[],i=1/0,a=1/0,o=-1/0,s=-1/0,c=0;n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:l,drawingType:u}=e,d=this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:l});if(d==null||d.transform==null)return;r.push({unitId:t,subUnitId:n,drawingId:l,drawingType:u,transform:d.transform});let{left:f=0,top:p=0,width:m=0,height:h=0}=d.transform;i=Math.min(i,f),a=Math.min(a,p),o=Math.max(o,f+m),s=Math.max(s,p+h),c++}),c!==0&&(this._sortDrawingTransform(r,t),this._applyAlignType(r,t,i,a,o,s,c))}_applyAlignType(e,t,n,r,i,a,o){let s=Math.round((i-n)/o*10)/10,c=Math.round((a-r)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(e[0].unitId);if(u==null)return;let{scene:d,transformer:f}=u;e.forEach((e,o)=>{let{unitId:u,subUnitId:d,drawingId:f,transform:p,drawingType:m}=e,{left:h=0,top:g=0,width:_=0,height:v=0}=p,y=h,b=g;switch(t){case`1`:y=n;break;case`2`:y=n+(i-n)/2-_/2;break;case`3`:y=i-_;break;case`4`:b=r;break;case`5`:b=r+(a-r)/2-v/2;break;case`6`:b=a-v;break;case`7`:y=n+s*o;break;case`8`:b=r+c*o}(y!==h||b!==g)&&l.push({unitId:u,subUnitId:d,drawingId:f,drawingType:m,transform:{left:y,top:b}})}),this._drawingManagerService.featurePluginUpdateNotification(l),f.refreshControls().changeNotification()}_sortDrawingTransform(e,t){e.sort((e,n)=>{let r=e.transform,i=n.transform,{left:a=0,top:o=0,width:s=0,height:c=0}=r,{left:l=0,top:u=0,width:d=0,height:f=0}=i;switch(t){case`1`:return a-l;case`2`:return a+s/2-(l+d/2);case`3`:return a+s-(l+d);case`4`:return o-u;case`5`:return o+c/2-(u+f/2);case`6`:return o+c-(u+f);case`7`:return a+s/2-(l+d/2);case`8`:return o+c/2-(u+f/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(e=>{this._drawingArrange(e)}))}_drawingArrange(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let{scene:a}=i;r.forEach(e=>{let r=ON({unitId:t,subUnitId:n,drawingId:e}),i=a.fuzzyMathObjects(r,!0);if(i==null||i.length===0)return;let o=this._drawingManagerService.getDrawingOrder(t,n).indexOf(e);for(let e of i)e.setProps({zIndex:o}),e.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertDrawing(e)}))}_insertDrawing(e){let t=[];e.forEach(e=>{let{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;let r=this._getSceneAndTransformerByDrawingSearch(n);if(r==null)return;let{scene:i}=r;t.includes(i)||t.push(i)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let{scene:a}=i,o=ON({unitId:t,subUnitId:n,drawingId:r}),s=a.fuzzyMathObjects(o,!0);if(s.length>0){var c;for(let e of s)e.dispose();(c=a.getTransformer())==null||c.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var t;let{unitId:n,subUnitId:r,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o,drawingType:s}=a,c=this._getSceneAndTransformerByDrawingSearch(n);if(c==null)return;let{scene:l,transformer:u}=c;if(o==null)return!0;let{left:d=0,top:f=0,width:p=0,height:m=0,angle:h=0,flipX:g=!1,flipY:_=!1,skewX:v=0,skewY:y=0}=o,b=ON({unitId:n,subUnitId:r,drawingId:i}),x=l.getObject(b);if(x==null)return!0;x.transformByState({left:d,top:f,width:p,height:m,angle:h,flipX:g,flipY:_,skewX:v,skewY:y}),(t=l.getTransformer())==null||t.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o}=a,{scene:s}=i,c=ON({unitId:t,subUnitId:n,drawingId:r}),l=s.getObject(c);if(l==null||o==null)return!0;let{left:u=0,top:d=0,width:f=0,height:p=0,angle:m=0,flipX:h=!1,flipY:g=!1,skewX:_=0,skewY:v=0}=o;l.transformByState({left:u,top:d,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r,visible:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;let{scene:o}=a,s=ON({unitId:t,subUnitId:n,drawingId:r}),c=o.getObject(s);if(c==null)return!0;i?c.show():c.hide()})}))}_filterUpdateParams(e,t){return e.filter((e,n)=>{if(e==null)return!1;let{transform:r}=e;return th(r,t?.[n])})}_addListenerOnDrawing(e){let t=e.getTransformerByCreate(),n=null;this.disposeWithMe(Wf(t.changeStart$.subscribe(e=>{let{objects:t}=e,r=Array.from(t.values()),i=[];n=r.map(e=>{let{left:t,top:n,height:r,width:a,angle:o,oKey:s,isInGroup:c}=e,l=this._drawingManagerService.getDrawingOKey(s);if(c||e instanceof IE){let t=e.ancestorGroup;if(t==null&&e instanceof IE&&(t=e),t==null)return null;let n=this._drawingManagerService.getDrawingOKey(t.oKey);if(n){let{unitId:e,subUnitId:r,drawingId:a}=n;i.push({unitId:e,subUnitId:r,drawingId:a});let{left:o,top:s,height:c,width:l,angle:u}=t;return{left:o,top:s,height:c,width:l,angle:u}}}else if(l!=null){let{unitId:e,subUnitId:s,drawingId:c}=l;return i.push({unitId:e,subUnitId:s,drawingId:c}),{left:t,top:n,height:r,width:a,angle:o}}return null}).filter(e=>e!=null),i.length>0?this._commandService.syncExecuteCommand(SN.id,i):this._commandService.syncExecuteCommand(SN.id,[])}))),this.disposeWithMe(Wf(t.changeEnd$.subscribe(e=>{let{objects:t}=e,r=this._filterUpdateParams(dW(t,this._drawingManagerService),n);r.length>0&&this._drawingManagerService.featurePluginUpdateNotification(r)})))}};mW=lW([cW(0,z),cW(1,R),cW(2,KE),cW(3,xN)],mW);var hW=class extends wT{constructor(e,t){t??={},t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:`rgb(0, 0, 0)`,anchorStroke:`rgb(255, 255, 255)`,anchorSize:24},super(e,t),pW(this,`_srcRect`,void 0),pW(this,`_prstGeom`,void 0),pW(this,`_applyTransform`,void 0),pW(this,`_dragPadding`,8),pW(this,`_cacheCanvas`,void 0),t?.srcRect&&(this._srcRect=t.srcRect),t?.prstGeom&&(this._prstGeom=t.prstGeom),t?.applyTransform&&(this._applyTransform=t.applyTransform),t?.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){let t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){let t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var t;let{width:n,height:r}=this.getScene().getEngine();this._initialCacheCanvas(),(t=this._cacheCanvas)==null||t.clear();let i=this._cacheCanvas?.getContext();i!=null&&(i.save(),OE.drawWith(i,{left:0,top:0,width:n,height:r,fill:`rgba(0, 0, 0, 0.5)`}),i.setTransform(e.getTransform()),this._clipForApplyObject(i),this._applyCache(e),i.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation=`destination-out`,e.beginPath(),t===0){let t=this.transform.getMatrix();e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,r=0,{left:i=0,top:a=0,width:o=0,height:s=0,angle:c}=this._applyTransform;if(this._srcRect!=null){let{left:i=0,top:a=0,right:o=0,bottom:s=0}=this._srcRect;e=i,t=a,n=o,r=s}let l=i+e,u=a+t;this.transformByState({left:l,top:u,width:i+o-n-l,height:a+s-r-u,angle:c})}_applyCache(e){if(!e||this._cacheCanvas==null)return;let t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;let e=this.getScene();if(e==null)return;this._cacheCanvas=new rT;let t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var e;(e=this._cacheCanvas)==null||e.setSize(t.width,t.height),this.makeDirty(!0)})}},gW=class extends P{constructor(e,t,n,r,i,a){super(),this._commandService=e,this._drawingManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._messageService=i,this._localeService=a,pW(this,`_sceneListenerOnImageMap`,new WeakSet),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==eW.id)return;let t=e.params;if(t==null)return;let{cropType:n}=t,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;let{unitId:i,subUnitId:a,drawingId:o}=r[0],s=this._renderManagerService.getRenderById(i)?.scene;if(s==null)return!0;this._searchCropObject(s)!=null&&this._commandService.syncExecuteCommand($U.id,{isAuto:!0});let c=ON({unitId:i,subUnitId:a,drawingId:o}),l=s.getObject(c);if(!(l instanceof kE)){this._messageService.show({type:pj.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}l!=null&&(this._updateCropperObject(n,l),this._commandService.executeCommand(QU.id,{unitId:i,subUnitId:a,drawingId:o}))}))}_calculateSrcRectByRatio(e,t,n,r,i,a){let o=n/r,s=i/a,c=n,l=r;o>s?c=r*s:l=n/s;let u=(n-c)/2,d=(r-l)/2;return{left:Tw(u,1),top:Tw(d,1),right:Tw(n-(u+c),1),bottom:Tw(r-(d+l),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case`1`:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case`2`:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case`3`:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case`4`:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case`5`:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case`6`:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case`7`:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case`8`:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case`9`:o=this._calculateSrcRectByRatio(n,r,i,a,2,3)}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==QU.id)return;let t=e.params;if(t==null)return;let{unitId:n,subUnitId:r,drawingId:i}=t,a=this._renderManagerService.getRenderById(n)?.scene;if(a==null)return!0;if(this._sceneListenerOnImageMap.has(a)||(this._addListenerOnImage(a),this._sceneListenerOnImageMap.add(a)),this._drawingManagerService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:i})==null)return;let o=ON({unitId:n,subUnitId:r,drawingId:i}),s=a.getObject(o);if(s==null)return;if(!(s instanceof kE)){this._messageService.show({type:pj.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}let c=a.getTransformer();c?.clearControls();let l=new hW(`${o}-crop`,{srcRect:s.srcRect,prstGeom:s.prstGeom,applyTransform:s.calculateTransformWithSrcRect()});a.addObject(l,s.getLayerIndex()+1).attachTransformerTo(l),c?.createControlForCopper(l),this._addHoverForImageCopper(l),s.openRenderByCropper(),c?.refreshControls(),l.makeDirty(!0),this._commandService.syncExecuteCommand(SN.id,[{unitId:n,subUnitId:r,drawingId:i}])}))}_searchCropObject(e){let t=e.getAllObjectsByOrder();for(let e of t)if(e instanceof hW)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==$U.id)return;let t=this._univerInstanceService.getFocusedUnit();if(t==null)return;let n=t.getUnitId(),r=this._renderManagerService.getRenderById(n)?.scene;if(r==null)return!0;let i=this._searchCropObject(r);if(i==null)return;let a=this._getApplyObjectByCropObject(i);if(a==null)return;let o=r.getTransformerByCreate();o.detachFrom(i),o.clearCopperControl();let s=this._getSrcRectByTransformState(a,i),c=this._drawingManagerService.getDrawingOKey(a.oKey);if(c!=null){let{left:e,top:t,height:n,width:r}=i;this._drawingManagerService.featurePluginUpdateNotification([{...c,transform:{...c.transform,left:e,top:t,height:n,width:r},srcRect:s.srcRectAngle}])}a.setSrcRect({...s.srcRectAngle}),a.closeRenderByCropper(),a.makeDirty(!0),i?.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_SHEET).pipe(sc(e=>e?e.activeSheet$:ts(null)));this.disposeWithMe(e.subscribe(()=>{this._commandService.syncExecuteCommand($U.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey,n=t.slice(0,t.length-5),r=e.getScene();return r?r.getObject(n)??null:null}_addListenerOnImage(e){let t=e.getTransformerByCreate(),n=null;this.disposeWithMe(t.changeStart$.subscribe(e=>{let{objects:r}=e,i=r.values().next().value;if(i==null||!(i instanceof hW))return;let{left:a,top:o,height:s,width:c,angle:l}=i;n={left:a,top:o,height:s,width:c,angle:l},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(e=>{let{objects:r}=e,i=r.values().next().value;if(i==null||!(i instanceof hW))return;let{left:a,top:o,height:s,width:c,angle:l}=i;if(!th({left:a,top:o,height:s,width:c,angle:l},n))return;let u=this._getApplyObjectByCropObject(i);if(u==null)return;let d=this._getSrcRectByTransformState(u,i);i.refreshSrcRect(d.srcRect,u.getState()),t.createControlForCopper(i)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=_w.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=_w.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand($U.id)}))}_getSrcRectByTransformState(e,t){let{left:n,top:r,height:i,width:a,strokeWidth:o,angle:s}=t,{left:c,top:l,width:u,height:d,angle:f,strokeWidth:p}=e,m=n-c,h=r-l,g={left:m,top:h,right:u-m-a,bottom:d-h-i},_={...g};if(f!==0){let e=new zw(n+a/2,r+i/2),t=new zw(u/2+c,d/2+l),o=new zw(c,l);o.rotateByPoint(ww(f),t);let s=o.clone();s.rotateByPoint(ww(-f),e);let p=n-s.x,m=r-s.y;_.left=p,_.top=m,_.right=u-p-a,_.bottom=d-m-i}return{srcRect:g,srcRectAngle:_}}};gW=lW([cW(0,R),cW(1,xN),cW(2,KE),cW(3,z),cW(4,eM),cW(5,j(nx))],gW);var _W=class extends P{constructor(){super(),pW(this,`_clipDelegate`,null),pW(this,`_canUseShapeClip$`,new so(!1)),pW(this,`canUseShapeClip$`,this._canUseShapeClip$.asObservable())}setCanUseShapeClip(e){this._canUseShapeClip$.next(e)}registerClipDelegate(e){return this._clipDelegate=e,Wf(()=>{this._clipDelegate===e&&(this._clipDelegate=null)})}applyShapeClip(e,t,n,r,i){return this._clipDelegate?this._clipDelegate(e,t,n,r,i):!1}dispose(){this._clipDelegate=null,this._canUseShapeClip$.complete(),super.dispose()}},vW=class{constructor(e,t,n,r,i,a){this._drawingManagerService=e,this._imageIoService=t,this._galleryService=n,this._urlImageService=r,this._univerInstanceService=i,this._drawingImageClipService=a}async renderImages(e,t){let{transform:n,drawingType:r,source:i,imageSourceType:a,srcRect:o,prstGeom:s,groupId:c,unitId:l,subUnitId:u,drawingId:d,isMultiTransform:f,transforms:p,adjustValues:m,hidden:h}=e;if(r!==um.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||this._univerInstanceService.getUnitType(l)===M.UNIVER_SHEET&&u!==this._getActiveSheetId()||n==null)return;let g=f&&p?p:[n],_=[];for(let e of g){let{left:n,top:r,width:p,height:v,angle:y,flipX:b,flipY:x,skewX:S,skewY:C}=e,w=g.indexOf(e),T=ON({unitId:l,subUnitId:u,drawingId:d},f?w:void 0),E=t.getObject(T);if(E!=null){E.transformByState({left:n,top:r,width:p,height:v,angle:y,flipX:b,flipY:x,skewX:S,skewY:C});continue}let D=this._drawingManagerService.getDrawingOrder(l,u),O=D.indexOf(d),k={...e,zIndex:O===-1?D.length-1:O},A=this._imageIoService.getImageSourceCache(i,a),ee=!1;if(A!=null)k.image=A;else if(a===cb.UUID)try{k.url=await this._imageIoService.getImage(i)}catch(e){console.error(e);continue}else if(a===cb.URL){try{k.url=await this._urlImageService.getImage(i)}catch(e){console.error(e),k.url=i}ee=!0}else k.url=i,ee=!0;if(h&&(k.visible=!1),t.getObject(T))continue;k.printable=!0;let te=new kE(T,k);te.setClipService(this._drawingImageClipService),ee&&this._imageIoService.addImageSourceCache(i,a,te.getNative()),t.addObject(te,4),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(te),c&&nW({drawingId:c,unitId:l,subUnitId:u},te,t,this._drawingManagerService),s!=null&&te.setPrstGeom(s),m!=null&&te.setPrstGeomAdjValues(m),o!=null&&te.setSrcRect(o),_.push(te)}return _}_getActiveSheetId(){var e;return(e=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET))==null||(e=e.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(e,t){let{transform:n,drawingType:r,groupId:i,unitId:a,subUnitId:o,drawingId:s,isMultiTransform:c,transforms:l}=e;if(r!==um.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||n==null)return;let u=c&&l?l:[n],d=[];for(let n of u){let{left:r,top:l,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v}=n,y=u.indexOf(n),b=ON({unitId:a,subUnitId:o,drawingId:s},c?y:void 0),x=t.getObject(b);if(x!=null){x.transformByState({left:r,top:l,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v});continue}let S=this._drawingManagerService.getDrawingOrder(a,o),C=S.indexOf(s),w={...n,zIndex:C===-1?S.length-1:C};if(t.getObject(b))continue;w.printable=!1;let T=new OE(b,w);this._drawingManagerService.getDrawingVisible()&&(t.addObject(T,4),this._drawingManagerService.getDrawingEditable()&&e.allowTransform!==!1&&t.attachTransformerTo(T),i&&nW({drawingId:i,unitId:a,subUnitId:o},T,t,this._drawingManagerService),d.push(T))}return d}renderDrawing(e,t){let n=this._drawingManagerService.getDrawingByParam(e);if(n!=null)switch(n.drawingType){case um.DRAWING_IMAGE:return this.renderImages(n,t)}}previewImage(e,t,n,r){this._galleryService.open({images:[t],onOpenChange:e=>{e||this._galleryService.close()}})}_adjustImageSize(e,t,n,r){if(e<=n&&t<=r)return{width:e,height:t};let i=n/e,a=r/t,o=Math.min(i,a);return{width:Math.floor(e*o),height:Math.floor(t*o)}}};vW=lW([cW(0,xN),cW(1,ub),cW(2,lN),cW(3,db),cW(4,z),cW(5,j(_W))],vW);var yW=class extends P{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=r,this._imageIoService=i,this._currentUniverService=a,this._drawingRenderService=o,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===tW.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e)?.scene;return t==null?null:{scene:t,transformer:t.getTransformerByCreate()}}_resetImageSize(e){let t=[],n=[];e.forEach(e=>{let{unitId:r,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;let{scene:s}=o,c=ON({unitId:r,subUnitId:i,drawingId:a}),l=s.getObject(c);if(l==null)return!0;let u=this._drawingManagerService.getDrawingByParam(e);if(u==null)return!0;if(u.drawingType!==um.DRAWING_IMAGE)return;l.resetSize();let{width:d,height:f}=l.getNativeSize();n.includes(s)===!1&&n.push(s),t.push({...u,transform:{...u.transform,height:f,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(SN.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe(Bs(33),Ls(e=>e.length>0),os(e=>e.flat()),os(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),Ls(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{let{unitId:t,subUnitId:n}=e,r=this._getSceneAndTransformerByDrawingSearch(t),i=Sat(this._currentUniverService,t)?.subUnitId;if(r==null||i!==n)return;let a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let o=await this._drawingRenderService.renderImages(a,r.scene);if(this._drawingManagerService.refreshTransform([a]),o!=null&&o.length!==0)for(let e of o)this._addHoverForImage(e),this._addDialogForImage(e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._drawingManagerService.getDrawingByParam(e);if(i==null)return;let{transform:a,drawingType:o,srcRect:s,prstGeom:c,source:l,imageSourceType:u}=i;if(o!==um.DRAWING_IMAGE)return;let d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;let{scene:f,transformer:p}=d;if(a==null)return!0;let m=ON({unitId:t,subUnitId:n,drawingId:r}),h=f.getObject(m);if(h==null)return!0;h.setSrcRect(s),h.setPrstGeom(c),l!=null&&l.length>0&&(u===cb.BASE64||u===cb.URL)&&h.changeSource(l)})}))}_addHoverForImage(e){this.disposeWithMe(Wf(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=_w.GRAB}))),this.disposeWithMe(Wf(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=_w.DEFAULT})))}_addDialogForImage(e){this.disposeWithMe(Wf(e.onDblclick$.subscribeEvent(()=>{let t=`${e.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,e.getNative().src,e.getNativeSize().width,e.getNativeSize().height)})))}};yW=lW([cW(0,R),cW(1,KE),cW(2,xN),cW(3,sN),cW(4,ub),cW(5,z),cW(6,j(vW))],yW);var bW=class extends dx{constructor(e=Eat,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=Qi({},Eat,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(Tat,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(mW),this._injector.get(uW),this._injector.get(gW),this._injector.get(yW)}_initDependencies(){[[_W],[vW],[mW],[uW],[gW],[yW]].forEach(e=>this._injector.add(e))}};pW(bW,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),pW(bW,`packageName`,Cat),pW(bW,`version`,wat),bW=lW([cW(1,j(We)),cW(2,Nm)],bW);var iot=e=>{let t=U(R),n=U(nx),{drawings:r,alignShow:i}=e,[a,o]=(0,V.useState)(`0`),s=[{label:n.t(`drawing-ui.image-panel.align.default`),value:`0`},{options:[{label:n.t(`drawing-ui.image-panel.align.left`),value:`1`},{label:n.t(`drawing-ui.image-panel.align.center`),value:`2`},{label:n.t(`drawing-ui.image-panel.align.right`),value:`3`}]},{options:[{label:n.t(`drawing-ui.image-panel.align.top`),value:`4`},{label:n.t(`drawing-ui.image-panel.align.middle`),value:`5`},{label:n.t(`drawing-ui.image-panel.align.bottom`),value:`6`}]},{options:[{label:n.t(`drawing-ui.image-panel.align.horizon`),value:`7`},{label:n.t(`drawing-ui.image-panel.align.vertical`),value:`8`}]}];function c(e){o(e),t.executeCommand(FU.id,{alignType:e,drawings:r})}return(0,H.jsxs)(`div`,{className:W(`univer-relative univer-w-full`,{"univer-hidden":!i}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`drawing-ui.image-panel.align.title`)})}),(0,H.jsx)(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:(0,H.jsx)(`div`,{className:`univer-w-full univer-text-gray-900 dark:!univer-text-white`,children:(0,H.jsx)(bj,{value:a,options:s,onChange:c})})})]})},aot=e=>{let{arrangeShow:t,drawings:n}=e,r=U(nx),i=U(xN),a=U(R),o=U(Nj),s=o.get(`MoveUpIcon`),c=o.get(`MoveDownIcon`),l=o.get(`TopmostIcon`),u=o.get(`BottomIcon`),[d,f]=(0,V.useState)(n);(0,V.useEffect)(()=>{let e=i.focus$.subscribe(e=>{f(e)});return()=>{e.unsubscribe()}},[]);let p=e=>{a.syncExecuteCommand(WU.id,{arrangeType:e,drawings:d})};return(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!t}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.arrange.title`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[(0,H.jsxs)(HA,{onClick:()=>{p(lm.forward)},children:[(0,H.jsx)(s,{}),r.t(`drawing-ui.image-panel.arrange.forward`)]}),(0,H.jsxs)(HA,{onClick:()=>{p(lm.backward)},children:[(0,H.jsx)(c,{}),r.t(`drawing-ui.image-panel.arrange.backward`)]}),(0,H.jsxs)(HA,{onClick:()=>{p(lm.front)},children:[(0,H.jsx)(l,{}),r.t(`drawing-ui.image-panel.arrange.front`)]}),(0,H.jsxs)(HA,{onClick:()=>{p(lm.back)},children:[(0,H.jsx)(u,{}),r.t(`drawing-ui.image-panel.arrange.back`)]})]})]})},oot=e=>{let t=U(nx),n=U(KE),r=U(xN),i=U(R),a=U(Nj),{hasGroup:o,drawings:s}=e,c=a.get(`GroupIcon`),l=a.get(`UngroupIcon`),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(!0);return(0,V.useEffect)(()=>{let e=s[0];if(e==null)return;let{unitId:t}=e,i=n.getRenderById(t)?.scene;if(i==null)return;let a=i.getTransformerByCreate(),o=a.clearControl$.subscribe(e=>{e===!0&&d(!1)}),c=a.changeStart$.subscribe(e=>{let{objects:t}=e,n=dW(t,r),i=n.filter(e=>e?.drawingType===um.DRAWING_GROUP),a=!1,o=!1;n.length>1&&(a=!0),i.length>0&&(o=!0),d(a||o),p(a),h(o)});return()=>{c.unsubscribe(),o.unsubscribe()}},[]),(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":o===!0&&u===!1||o===!1}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:t.t(`drawing-ui.image-panel.group.title`)})}),(0,H.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,H.jsxs)(HA,{className:W({"univer-hidden":!f}),onClick:()=>{i.syncExecuteCommand(XU.id,{drawings:s})},children:[(0,H.jsx)(c,{}),t.t(`drawing-ui.image-panel.group.group`)]}),(0,H.jsxs)(HA,{className:W({"univer-hidden":!m}),onClick:()=>{i.syncExecuteCommand(ZU.id,{drawings:s})},children:[(0,H.jsx)(l,{}),t.t(`drawing-ui.image-panel.group.unGroup`)]})]})]})},sot=[-360,360],xW=300,cot=e=>{let t=U(nx),n=U(xN),r=U(KE),{drawings:i,transformShow:a}=e,o=i[0];if(o==null)return;let s=o.transform;if(s==null)return;let{unitId:c,subUnitId:l,drawingId:u,drawingType:d}=o,f=r.getRenderById(c)?.scene;if(f==null)return;let p=f.getEngine()?.activeScene;if(p==null)return;let m=f.getTransformerByCreate(),{width:h=0,height:g=0,left:_=0,top:v=0,angle:y=0}=s,[b,x]=(0,V.useState)(h),[S,C]=(0,V.useState)(g),[w,T]=(0,V.useState)(_),[E,D]=(0,V.useState)(v),[O,k]=(0,V.useState)(y),[A,ee]=(0,V.useState)(m.keepRatio),te=(e,t,n,r)=>{let{width:i,height:a}=p,{ancestorLeft:o,ancestorTop:s}=f,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=i-c-o,u<20&&(u=20),d=a-l-s,d<20&&(d=20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ne=e=>{let{objects:t}=e,r=dW(t,n);if(r.length!==1)return;let i=r[0];if(i==null)return;let{transform:a}=i;if(a==null)return;let{width:o,height:s,left:c,top:l,angle:u}=a;o!=null&&x(o),s!=null&&C(s),c!=null&&T(c),l!=null&&D(l),u!=null&&k(u)};(0,V.useEffect)(()=>{let e=[m.changeStart$.subscribe(e=>{ne(e)}),m.changing$.subscribe(e=>{ne(e)}),m.changeEnd$.subscribe(e=>{ne(e)}),n.focus$.subscribe(e=>{if(e.length!==1)return;let t=n.getDrawingByParam(e[0]);if(t==null)return;let r=t.transform;if(r==null)return;let{width:i,height:a,left:o,top:s,angle:c}=r;i!=null&&x(i),a!=null&&C(a),o!=null&&T(o),s!=null&&D(s),c!=null&&k(c)})];return()=>{e.forEach(e=>e.unsubscribe())}},[]);let re=Wi(e=>{if(e==null)return;let{limitWidth:t,limitHeight:r}=te(w,E,e,S);e=Math.min(e,t);let i={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{width:e}};if(A){let t=e/b*S;if(t=Math.max(t,20),t>r)return;C(t),i.transform.height=t}x(e),n.featurePluginUpdateNotification([i]),m.refreshControls().changeNotification()},xW),ie=Wi(e=>{if(e==null)return;let{limitHeight:t,limitWidth:r}=te(w,E,b,e);e=Math.min(e,t);let i={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{height:e}};if(A){let t=e/S*b;if(t=Math.max(t,20),t>r)return;x(t),i.transform.width=t}C(e),n.featurePluginUpdateNotification([i]),m.refreshControls().changeNotification()},xW),ae=Wi(e=>{if(e==null)return;let{limitLeft:t}=te(e,E,b,S);e=t;let r={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{left:e}};T(e),n.featurePluginUpdateNotification([r]),m.refreshControls().changeNotification()},xW),oe=Wi(e=>{if(e==null)return;let{limitTop:t}=te(w,e,b,S);e=t;let r={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{top:e}};D(e),n.featurePluginUpdateNotification([r]),m.refreshControls().changeNotification()},xW);return(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!a}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:t.t(`drawing-ui.image-panel.transform.title`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.width`)}),(0,H.jsx)(dj,{precision:1,value:b,min:20,onChange:e=>{re(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.height`)}),(0,H.jsx)(dj,{precision:1,value:S,min:20,onChange:e=>{ie(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.lock`)}),(0,H.jsx)(`div`,{className:`univer-text-center`,children:(0,H.jsx)($A,{checked:A,onChange:e=>{ee(e),m.keepRatio=e}})})]})]}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.x`)}),(0,H.jsx)(dj,{precision:1,value:w,onChange:e=>{ae(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.y`)}),(0,H.jsx)(dj,{precision:1,value:E,onChange:e=>{oe(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.rotate`)}),(0,H.jsx)(dj,{precision:1,value:O,min:sot[0],max:sot[1],onChange:e=>{if(e==null)return;let t={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{angle:e}};k(e),n.featurePluginUpdateNotification([t]),m.refreshControls().changeNotification()}})]})]})]})},lot=e=>{let t=U(R),n=U(nx),r=U(_W),i=U(Nj),a=QD(r.canUseShapeClip$,!1),{drawings:o,cropperShow:s}=e;if(o[0]==null)return;let[c,l]=(0,V.useState)(`0`),u=(0,V.useRef)(!1),d=[{label:n.t(`drawing-ui.image-panel.crop.mode`),value:`0`},{label:`1:1`,value:`1`},{label:`16:9`,value:`2`},{label:`9:16`,value:`3`},{label:`5:4`,value:`4`},{label:`4:5`,value:`5`},{label:`4:3`,value:`6`},{label:`3:4`,value:`7`},{label:`3:2`,value:`8`},{label:`2:3`,value:`9`}];(0,V.useEffect)(()=>{let e=t.onCommandExecuted(e=>{e.id===$U.id&&(e.params?.isAuto||(u.current=!1))});return()=>{e?.dispose()}},[]);function f(e){l(e),u.current&&t.executeCommand(eW.id,{cropType:e})}let p=e=>{t.executeCommand(eW.id,{cropType:e}),u.current=!0};return(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!s}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`drawing-ui.image-panel.crop.title`)})}),(0,H.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,H.jsxs)(HA,{onClick:()=>{p(c)},children:[(0,H.jsx)(dje,{}),n.t(`drawing-ui.image-panel.crop.start`)]}),(0,H.jsx)(bj,{value:c,options:d,onChange:f})]}),a&&(()=>{let e=i.get(`sheet.image-clip.shape.picker.component`);return e?(0,H.jsx)(e,{}):null})()]})},uot=e=>{let t=U(xN),n=U(KE),r=U(nx),{drawings:i,hasArrange:a=!0,hasTransform:o=!0,hasAlign:s=!0,hasCropper:c=!0,hasGroup:l=!0}=e,u=i[0];if(u==null)return;let{unitId:d}=u,f=n.getRenderById(d)?.scene;if(f==null)return;let p=f.getTransformerByCreate(),[m,h]=(0,V.useState)(!0),[g,_]=(0,V.useState)(!0),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(!0),[S,C]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let e=p.clearControl$.subscribe(e=>{e===!0&&(h(!1),_(!1),y(!1),x(!1),C(!0))}),n=p.changeStart$.subscribe(e=>{let{objects:n}=e,r=dW(n,t);r.length===0?(h(!1),_(!1),y(!1),x(!1),C(!0)):r.length===1?(h(!0),_(!0),y(!1),x(!0),C(!1)):(h(!0),_(!1),y(!0),x(!1),C(!1))}),r=t.focus$.subscribe(e=>{e.length===0?(h(!1),_(!1),y(!1),x(!1),C(!0)):e.length===1?(h(!0),_(!0),y(!1),x(!0),C(!1)):(h(!0),_(!1),y(!0),x(!1),C(!1))});return()=>{n.unsubscribe(),e.unsubscribe(),r.unsubscribe()}},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:W(`univer-h-full`,{"univer-hidden":!S}),children:(0,H.jsx)(`div`,{className:`univer-flex univer-h-full univer-items-center univer-justify-center`,children:(0,H.jsx)(`span`,{children:r.t(`drawing-ui.image-panel.null`)})})}),(0,H.jsx)(aot,{arrangeShow:a===!0&&m,drawings:i}),(0,H.jsx)(cot,{transformShow:o===!0&&g,drawings:i}),(0,H.jsx)(iot,{alignShow:s===!0&&v,drawings:i}),(0,H.jsx)(lot,{cropperShow:c===!0&&b,drawings:i}),(0,H.jsx)(oot,{hasGroup:l,drawings:i})]})},SW={id:`doc.command.remove-doc-image`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(z),i=e.get(KE),a=r.getCurrentUniverDocInstance();if(t==null||a==null)return!1;let o=i.getRenderById(t.unitId).with(XF),{drawings:s}=t,c=o.getSegment()??``,l=new Bv,u=Vv.getInstance(),d=a.getSelfOrHeaderFooterModel(c).getBody()?.customBlocks??[],f=s.map(e=>d.find(t=>t.blockId===e.drawingId)).filter(e=>!!e).sort((e,t)=>e.startIndex>t.startIndex?1:-1),p=s[0].unitId,m=new Pf;m.reset();let h=f[0].startIndex,g=[{startOffset:h,endOffset:h}],_={id:aD.id,params:{unitId:p,actions:[],textRanges:g}},v=[];for(let e of f){let{startIndex:t}=e;t>m.cursor&&l.push({t:Mm.RETAIN,len:t-m.cursor}),l.push({t:Mm.DELETE,len:1}),m.moveCursorTo(t+1)}let y=qN(a,c);v.push(u.editOp(l.serialize(),y));for(let e of f){let{blockId:t}=e,n=(a.getDrawings()??{})[t],r=a.getDrawingsOrder().indexOf(t),i=u.removeOp([`drawings`,t],n),o=u.removeOp([`drawingsOrder`,r],t);v.push(i),v.push(o)}return _.params.actions=v.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(_.id,_.params)}},dot={id:`doc.command.delete-drawing`,type:L.COMMAND,handler:e=>{let t=e.get(R),n=e.get(kU).getFocusDrawings();if(n.length===0)return!1;let{unitId:r}=n[0],i=n.map(e=>{let{unitId:t,subUnitId:n,drawingId:r,drawingType:i}=e;return{unitId:t,subUnitId:n,drawingId:r,drawingType:i}});return t.executeCommand(SW.id,{unitId:r,drawings:i})}},fot={id:`doc.command.group-doc-image`,type:L.COMMAND,handler:(e,t)=>!1},CW={id:`doc.command.insert-doc-image`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(nD),i=e.get(z),a=r.getActiveTextRange(),o=i.getCurrentUniverDocInstance();if(o==null)return!1;let s=o.getUnitId(),c=pot(e,s),l=c?{...a,startOffset:c.startOffset,endOffset:c.endOffset,collapsed:c.startOffset===c.endOffset,segmentId:c.segmentId??a?.segmentId??``}:a;if(l==null)return!1;let{drawings:u}=t,{collapsed:d,startOffset:f,segmentId:p=``}=l,m=o.getSelfOrHeaderFooterModel(p).getBody();if(m==null)return!1;let h=new Bv,g=Vv.getInstance(),_=[],v=o.getSnapshot().drawingsOrder?.length??0,y=0;if(d)f>0&&h.push({t:Mm.RETAIN,len:f});else{let e=Ey.selection.delete([l],m,0,null,!1);h.push(...e);let t=RYe(m,[l]),n=o.getDrawings()??{},r=o.getDrawingsOrder()??[],i=t.sort((e,t)=>r.indexOf(e)>r.indexOf(t)?-1:+(r.indexOf(e)<r.indexOf(t)));if(i.length>0)for(let e of i){let t=n[e],i=r.indexOf(e);if(t==null||i<0)continue;let a=g.removeOp([`drawings`,e],t),o=g.removeOp([`drawingsOrder`,i],e);_.push(a),_.push(o),y++}}h.push({t:Mm.INSERT,body:{dataStream:`\b`.repeat(u.length),customBlocks:u.map((e,t)=>({startIndex:t,blockId:e.drawingId}))},len:u.length});let b=qN(o,p),x=g.editOp(h.serialize(),b);_.push(x);for(let e of u){let{drawingId:t}=e,n=g.insertOp([`drawings`,t],e),r=g.insertOp([`drawingsOrder`,v-y],t);_.push(n),_.push(r)}let S={id:aD.id,params:{unitId:s,actions:[],textRanges:[]}};return S.params.actions=_.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(S.id,S.params)}};function pot(e,t){try{let n=e.get(zP).consumeInsertRange(t);return n==null?null:{startOffset:n.startOffset,endOffset:n.endOffset,collapsed:n.startOffset===n.endOffset,segmentId:n.segmentId}}catch{return null}}var mot={id:`doc.command.set-drawing-arrange`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(kU);if(t==null)return!1;let{unitId:i,subUnitId:a,drawingIds:o,arrangeType:s}=t,c={unitId:i,subUnitId:a,drawingIds:o},l;if(s===lm.forward?l=r.getForwardDrawingsOp(c):s===lm.backward?l=r.getBackwardDrawingOp(c):s===lm.front?l=r.getFrontDrawingsOp(c):s===lm.back&&(l=r.getBackDrawingsOp(c)),l==null)return!1;let{redo:u}=l;if(u==null)return!1;let d=[],f=F.deepClone(u);f=f.slice(3),f.unshift(`drawingsOrder`),d.push(f);let p={id:aD.id,params:{unitId:i,actions:[],textRanges:null}};return p.params.actions=d.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(p.id,p.params)}},hot={id:`doc.command.ungroup-doc-image`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(kU);if(!t)return!1;let r=[];t.forEach(({parent:e,children:t})=>{r.push(e.unitId),t.forEach(e=>{r.push(e.unitId)})});let{unitId:i,subUnitId:a,undo:o,redo:s,objects:c}=n.getUngroupDrawingOp(t);return!1}};function wW(e){"@babel/helpers - typeof";return wW=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},wW(e)}function got(e,t){if(wW(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(wW(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _ot(e){var t=got(e,`string`);return wW(t)==`symbol`?t:t+``}function TW(e,t,n){return(t=_ot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var EW=class{constructor(){TW(this,`_refreshDrawings$`,new so(null)),TW(this,`refreshDrawings$`,this._refreshDrawings$.asObservable())}refreshDrawings(e){this._refreshDrawings$.next(e)}};function DW(e,t){return function(n,r){t(n,r,e)}}function OW(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var kW=class extends P{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){super(),this._context=e,this._commandService=t,this._docSelectionManagerService=n,this._renderManagerSrv=r,this._imageIoService=i,this._docDrawingService=a,this._drawingManagerService=o,this._contextService=s,this._messageService=c,this._localeService=l,this._docSelectionRenderService=u,this._docRefreshDrawingsService=d,this._fileOpenerService=f,this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._transformDrawingListener(),this._editAreaChangeListener()}dispose(){super.dispose(),delete this._context}async insertDocImage(){let e=this._getCurrentImageInsertPosition(),t=await this._fileOpenerService.openFile({multiple:!0,accept:bN.map(e=>`.${e.replace(`image/`,``)}`).join(`,`)}),n=t.length;return n>10?(this._messageService.show({type:pj.Error,content:this._localeService.t(`docs-drawing-ui.update-status.exceedMaxCount`,`10`)}),!1):n!==0&&(await this._insertFloatImages(t,e),!0)}async _insertFloatImages(e,t){let n=[];try{n=await Promise.all(e.map(e=>this._imageIoService.saveImage(e)))}catch(e){let t=e.message,n=``;switch(t){case lb.ERROR_EXCEED_SIZE:n=this._localeService.t(`docs-drawing-ui.update-status.exceedMaxSize`,String(yN()/1048576));break;case lb.ERROR_IMAGE_TYPE:n=this._localeService.t(`docs-drawing-ui.update-status.invalidImageType`);break;case lb.ERROR_IMAGE:n=this._localeService.t(`docs-drawing-ui.update-status.invalidImage`)}this._messageService.show({type:pj.Error,content:n})}if(n.length===0)return;let{unitId:r}=this._context,i=[];for(let e of n){if(e==null)continue;let{imageId:n,imageSourceType:a,source:o,base64Cache:s}=e,{width:c,height:l,image:u}=await kN(s||``);this._imageIoService.addImageSourceCache(n,a,u);let d=1;if(c>500||l>500){let e=500/c,t=500/l;d=Math.min(e,t)}let f=t??this._getCurrentImageInsertPosition(),p=this._getImagePosition(c*d,l*d,f);if(p==null)return;let m=FN(p);m!=null&&f!=null&&(m.top=f.top);let h={unitId:r,subUnitId:r,drawingId:n,drawingType:um.DRAWING_IMAGE,imageSourceType:a,source:o,transform:m,docTransform:p,behindDoc:Np.FALSE,title:``,description:``,layoutType:Kp.INLINE,wrapText:Gp.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0};this._isInsertInHeaderFooter()&&(h.isMultiTransform=Np.TRUE,h.transforms=h.transform?[h.transform]:null),i.push(h)}this._commandService.executeCommand(CW.id,{unitId:r,drawings:i})}_isInsertInHeaderFooter(){let{unitId:e}=this._context,t=(this._renderManagerSrv.getRenderById(e)?.with(rD).getViewModel())?.getEditArea();return t===OT.HEADER||t===OT.FOOTER}_getImagePosition(e,t,n){let r=n??this._getCurrentImageInsertPosition()??{left:0,top:0};return{size:{width:e,height:t},positionH:{relativeFrom:nm.PAGE,posOffset:r.left},positionV:{relativeFrom:rm.PARAGRAPH,posOffset:0},angle:0}}_getCurrentImageInsertPosition(){let e=this._docSelectionRenderService.getActiveTextRange()?.getAbsolutePosition();return e==null?null:{left:e.left,top:e.top}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n,drawingIds:r,arrangeType:i}=e;this._commandService.executeCommand(mot.id,{unitId:t,subUnitId:n,drawingIds:r,arrangeType:i})}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(fot.id,e)})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(hot.id,e)}))}_getCurrentSceneAndTransformer(){let{scene:e,mainComponent:t}=this._context;if(e==null||t==null)return;let n=e.getTransformerByCreate(),{docsLeft:r,docsTop:i}=t.getOffsetConfig();return{scene:e,transformer:n,docsLeft:r,docsTop:i}}_transformDrawingListener(){let e=this._getCurrentSceneAndTransformer();if(e&&e.transformer)this.disposeWithMe(e.transformer.changeEnd$.pipe(Ks(30)).subscribe(e=>{this._docSelectionManagerService.refreshSelection()}));else throw Error(`transformer is not init`)}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{let{transformer:t,docsLeft:n,docsTop:r}=this._getCurrentSceneAndTransformer()??{};if(e==null||e.length===0)this._contextService.setContextValue(ab,!1),this._docDrawingService.focusDrawing([]),t&&t.resetProps({zeroTop:0,zeroLeft:0});else{this._contextService.setContextValue(ab,!0),this._docDrawingService.focusDrawing(e),this._setDrawingSelections(e);let i=this._docSelectionRenderService.getSegment(),a=this._findSegmentIdByDrawingId(e[0].drawingId);i!==a&&this._docSelectionRenderService.setSegment(a),t&&t.resetProps({zeroTop:r,zeroLeft:n})}}))}_findSegmentIdByDrawingId(e){let{unit:t}=this._context,{body:n,headers:r={},footers:i={}}=t.getSnapshot();if((n?.customBlocks??[]).some(t=>t.blockId===e))return``;for(let t of Object.keys(r))if(r[t].body.customBlocks?.some(t=>t.blockId===e))return t;for(let t of Object.keys(i))if(i[t].body.customBlocks?.some(t=>t.blockId===e))return t;return``}_updateDrawingsEditStatus(){if(!this._context)return;let{unit:e,scene:t,unitId:n}=this._context,r=this._renderManagerSrv.getRenderById(n)?.with(rD).getViewModel();if(r==null||e==null)return;let{drawings:i={}}=e.getSnapshot(),a=r.getEditArea()===OT.BODY;for(let e of Object.keys(i)){let r=i[e],o=ON({unitId:n,drawingId:r.drawingId,subUnitId:n}),s=t.fuzzyMathObjects(o,!0);if(s.length)for(let e of s){t.detachTransformerFrom(e);try{e.setOpacity(.5)}catch{}if(a&&r.isMultiTransform!==Np.TRUE||!a&&r.isMultiTransform===Np.TRUE){r.allowTransform!==!1&&t.attachTransformerTo(e);try{e.setOpacity(1)}catch{}}}}}_editAreaChangeListener(){let{unitId:e}=this._context,t=this._renderManagerSrv.getRenderById(e)?.with(rD).getViewModel();t!=null&&(this._updateDrawingsEditStatus(),this.disposeWithMe(t.editAreaChange$.subscribe(()=>{this._updateDrawingsEditStatus()})),this.disposeWithMe(this._docRefreshDrawingsService.refreshDrawings$.subscribe(e=>{e!=null&&queueMicrotask(()=>{this._updateDrawingsEditStatus()})})),this.disposeWithMe(this._commandService.onCommandExecuted(async e=>{e.id===aD.id&&queueMicrotask(()=>{this._updateDrawingsEditStatus()})})))}_setDrawingSelections(e){let{unit:t}=this._context,n=t.getSnapshot().body?.customBlocks??[],r=e.map(e=>{let t=e.drawingId,r=n.find(e=>e.blockId===t);return r?r.startIndex:null}).filter(e=>e!==null).map(e=>({startOffset:e,endOffset:e+1}));this._docSelectionManagerService.replaceDocRanges(r)}};kW=OW([DW(1,R),DW(2,j(nD)),DW(3,KE),DW(4,ub),DW(5,kU),DW(6,xN),DW(7,Fm),DW(8,eM),DW(9,j(nx)),DW(10,j(XF)),DW(11,j(EW)),DW(12,dN)],kW);var vot={id:`doc.command.insert-float-image`,type:L.COMMAND,handler:e=>{let t=e.get(z),n=e.get(KE);return qE(M.UNIVER_DOC,t,n)?.with(kW).insertDocImage()??!1}},yot={inline:Kp.INLINE,wrapSquare:Kp.WRAP_SQUARE,wrapTopAndBottom:Kp.WRAP_TOP_AND_BOTTOM,inFrontOfText:Kp.WRAP_NONE,behindText:Kp.WRAP_NONE};function AW(e,t,n,r){let i=e.skeDrawings.get(t);if(i)return{skeDrawing:i,pageMarginTop:n,pageMarginLeft:r};for(let n of e.skeTables.values())for(let e of n.rows)for(let n of e.cells){let e=AW(n,t,n.marginTop,n.marginLeft);if(e)return e}return null}function bot(e,t,n,r,i,a,o){var s;let c=new Bv,l=Vv.getInstance(),u=[],d=a.getSelfOrHeaderFooterModel(t).getBody(),f=a.getSelfOrHeaderFooterModel(e).getBody();if(d==null||f==null)return;let p=(s=d.customBlocks)==null||(s=s.find(e=>e.blockId===i))==null?void 0:s.startIndex;if(p!=null){if(r=Math.min(f.dataStream.length-2,r),e===t){if(r<p?(r>0&&c.push({t:Mm.RETAIN,len:r}),c.push({t:Mm.INSERT,body:{dataStream:`\b`,customBlocks:[{startIndex:0,blockId:i}]},len:1}),c.push({t:Mm.RETAIN,len:p-r}),c.push({t:Mm.DELETE,len:1})):(p>0&&c.push({t:Mm.RETAIN,len:p}),c.push({t:Mm.DELETE,len:1}),r-p-1>0&&c.push({t:Mm.RETAIN,len:r-p-1}),c.push({t:Mm.INSERT,body:{dataStream:`\b`,customBlocks:[{startIndex:0,blockId:i}]},len:1})),r!==p){let e=qN(a,t),n=l.editOp(c.serialize(),e);u.push(n)}}else{p>0&&c.push({t:Mm.RETAIN,len:p}),c.push({t:Mm.DELETE,len:1});let s=qN(a,t),d=l.editOp(c.serialize(),s);u.push(d),c.empty(),r>0&&c.push({t:Mm.RETAIN,len:r}),c.push({t:Mm.INSERT,body:{dataStream:`\b`,customBlocks:[{startIndex:0,blockId:i}]},len:1}),s=qN(a,e),d=l.editOp(c.serialize(),s),u.push(d),o.setSegment(e),o.setSegmentPage(n)}return u}}var xot={id:`doc.command.update-doc-drawing-wrapping-style`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let{drawings:n,wrappingStyle:r,unitId:i}=t,a=e.get(R),o=e.get(z),s=e.get(KE).getRenderById(i),c=s?.with(rD).getSkeleton().getSkeletonData(),l=s?.with(rD).getViewModel(),u=s?.scene,d=o.getCurrentUniverDocInstance();if(d==null||c==null||u==null||l==null)return!1;let f=l.getEditArea(),p=u.getTransformerByCreate(),{pages:m,skeHeaders:h,skeFooters:g}=c,_=Vv.getInstance(),v=[],{drawings:y={}}=d.getSnapshot();for(let e of n){let{drawingId:t}=e,n=y[t].layoutType,i=yot[r];if(n!==i){let e=_.replaceOp([`drawings`,t,`layoutType`],n,i);v.push(e)}if(r===`behindText`||r===`inFrontOfText`){let e=y[t].behindDoc,n=r===`behindText`?Np.TRUE:Np.FALSE;if(e!==n){let r=_.replaceOp([`drawings`,t,`behindDoc`],e,n);v.push(r)}}if(r===`inline`)continue;let a=null;for(let e of m){let{headerId:n,footerId:r,marginTop:i,marginLeft:o,marginBottom:s,pageWidth:c,pageHeight:l}=e;switch(f){case OT.HEADER:{let e=h.get(n)?.get(c);e!=null&&(a=AW(e,t,e.marginTop,o));break}case OT.FOOTER:{let e=g.get(r)?.get(c);e!=null&&(a=AW(e,t,l-s+e.marginTop,o));break}case OT.BODY:a=AW(e,t,i,o)}if(a!=null)break}if(a!=null){let{skeDrawing:e,pageMarginTop:n,pageMarginLeft:r}=a,{aTop:i,aLeft:o}=e,s=y[t].docTransform.positionH,c=o;s.relativeFrom===nm.MARGIN?c-=r:s.relativeFrom===nm.COLUMN&&(c-=e.columnLeft);let l={relativeFrom:s.relativeFrom,posOffset:c};if(s.posOffset!==l.posOffset){let e=_.replaceOp([`drawings`,t,`docTransform`,`positionH`],s,l);v.push(e)}let u=y[t].docTransform.positionV,d=i;u.relativeFrom===rm.PAGE?d+=n:u.relativeFrom===rm.LINE?d-=e.lineTop:u.relativeFrom===rm.PARAGRAPH&&(d-=e.blockAnchorTop);let f={relativeFrom:u.relativeFrom,posOffset:d};if(u.posOffset!==f.posOffset){let e=_.replaceOp([`drawings`,t,`docTransform`,`positionV`],u,f);v.push(e)}}}let b={id:aD.id,params:{unitId:i,actions:[],textRanges:null}};b.params.actions=v.reduce((e,t)=>Vv.compose(e,t),null);let x=a.syncExecuteCommand(b.id,b.params);return p.refreshControls(),!!x}},Sot={id:`doc.command.update-doc-drawing-distance`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(z).getCurrentUniverDocInstance();if(r==null)return!1;let{drawings:i,dist:a,unitId:o}=t,s=Vv.getInstance(),c=[],{drawings:l={}}=r.getSnapshot();for(let e of i){let{drawingId:t}=e;for(let[e,n]of Object.entries(a)){let r=l[t][e];if(r!==n){let i=s.replaceOp([`drawings`,t,e],r,n);c.push(i)}}}let u={id:aD.id,params:{unitId:o,actions:[],textRanges:null}};return u.params.actions=c.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(u.id,u.params)}},Cot={id:`doc.command.update-doc-drawing-wrap-text`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(z).getCurrentUniverDocInstance();if(r==null)return!1;let{drawings:i,wrapText:a,unitId:o}=t,s=Vv.getInstance(),c=[],{drawings:l={}}=r.getSnapshot();for(let e of i){let{drawingId:t}=e,n=l[t].wrapText;if(n!==a){let e=s.replaceOp([`drawings`,t,`wrapText`],n,a);c.push(e)}}let u={id:aD.id,params:{unitId:o,actions:[],textRanges:null}};return u.params.actions=c.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(u.id,u.params)}},jW={id:`doc.command.update-drawing-doc-transform`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(z),i=e.get(KE).getRenderById(t.unitId)?.scene;if(i==null)return!1;let a=i.getTransformerByCreate(),o=r.getCurrentUniverDocInstance();if(o==null)return!1;let{drawings:s,unitId:c}=t,l=Vv.getInstance(),u=[],{drawings:d={}}=o.getSnapshot();for(let e of s){let{drawingId:t,key:n,value:r}=e,i=d[t].docTransform[n];if(!F.diffValue(i,r)){let e=l.replaceOp([`drawings`,t,`docTransform`,n],i,r);u.push(e)}}let f={id:aD.id,params:{unitId:c,actions:[],textRanges:null,debounce:!0}};f.params.actions=u.reduce((e,t)=>Vv.compose(e,t),null);let p=n.syncExecuteCommand(f.id,f.params);return a.refreshControls(),!!p}},wot={id:`doc.command.move-inline-drawing`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(KE),r=n.getRenderById(t.unitId)?.with(XF),i=e.get(EW),a=n.getRenderById(t.unitId),o=a?.scene,s=a?.with(rD).getSkeleton();if(o==null||r==null)return!1;let c=o.getTransformerByCreate(),l=e.get(R),u=e.get(z).getCurrentUniverDocInstance();if(u==null)return!1;let{drawing:d,unitId:f,offset:p,segmentId:m,segmentPage:h,needRefreshDrawings:g}=t;if(g)return i.refreshDrawings(s),c.refreshControls(),!0;let _=[],{drawingId:v}=d,y=bot(m,r.getSegment()??``,h,p,v,u,r);if(y==null||y.length===0)return i.refreshDrawings(s),c.refreshControls(),!1;_.push(...y);let b={id:aD.id,params:{unitId:f,actions:[],textRanges:null}};b.params.actions=_.reduce((e,t)=>Vv.compose(e,t),null);let x=l.syncExecuteCommand(b.id,b.params);return c.refreshControls(),!!x}},Tot={id:`doc.command.transform-non-inline-drawing`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(KE),r=n.getRenderById(t.unitId)?.with(XF),i=n.getRenderById(t.unitId)?.scene;if(i==null||r==null)return!1;let a=i.getTransformerByCreate(),o=e.get(R),s=e.get(z).getCurrentUniverDocInstance();if(s==null)return!1;let{drawing:c,unitId:l,offset:u,docTransform:d,segmentId:f,segmentPage:p}=t,m=[],{drawingId:h}=c,g=bot(f,r.getSegment()??``,p,u,h,s,r);if(g==null)return!1;g.length>0&&m.push(...g);let _=Vv.getInstance(),{drawings:v={}}=s.getSnapshot(),{positionH:y,positionV:b,size:x,angle:S}=v[h].docTransform;if(!F.diffValue(y,d.positionH)){let e=_.replaceOp([`drawings`,h,`docTransform`,`positionH`],y,d.positionH);m.push(e)}if(!F.diffValue(b,d.positionV)){let e=_.replaceOp([`drawings`,h,`docTransform`,`positionV`],b,d.positionV);m.push(e)}if(!F.diffValue(x,d.size)){let e=_.replaceOp([`drawings`,h,`docTransform`,`size`],x,d.size);m.push(e)}if(!F.diffValue(S,d.angle)){let e=_.replaceOp([`drawings`,h,`docTransform`,`angle`],S,d.angle);m.push(e)}let C={id:aD.id,params:{unitId:l,actions:[],textRanges:null,debounce:!0}};C.params.actions=m.reduce((e,t)=>Vv.compose(e,t),null);let w=o.syncExecuteCommand(C.id,C.params);return a.refreshControls(),!!w}},MW={id:`doc.command.move-drawing`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(kU),i=e.get(z),a=e.get(KE),{direction:o}=t,s=r.getFocusDrawings();if(s.length===0)return!1;let c=s[0].unitId,l=a.getRenderById(c)?.scene;if(l==null)return!1;let u=l.getTransformerByCreate(),d=i.getUniverDocInstance(c),f=s.map(e=>{var t;let{drawingId:n}=e,r=d==null||(t=d.getSnapshot().drawings)==null?void 0:t[n];if(r==null||r.layoutType===Kp.INLINE)return null;let{positionH:i,positionV:a}=r.docTransform,s={...i},c={...a};return o===I.UP?c.posOffset=(c.posOffset??0)-2:o===I.DOWN?c.posOffset=(c.posOffset??0)+2:o===I.LEFT?s.posOffset=(s.posOffset??0)-2:o===I.RIGHT&&(s.posOffset=(s.posOffset??0)+2),{drawingId:n,key:o===I.UP||o===I.DOWN?`positionV`:`positionH`,value:o===I.UP||o===I.DOWN?c:s}}).filter(e=>e!=null);if(f.length===0)return!1;let p=n.syncExecuteCommand(jW.id,{unitId:c,subUnitId:c,drawings:f});return u.refreshControls(),!!p}},Eot={id:`doc.operation.clear-drawing-transformer`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(KE);return t.forEach(e=>{var t;(t=n.getRenderById(e))==null||(t=t.scene.getTransformer())==null||t.debounceRefreshControls()}),!0}},Dot=`COMPONENT_DOC_DRAWING_PANEL`,NW={id:`sidebar.operation.doc-image`,type:L.COMMAND,handler:async(e,t)=>{let n=e.get(Aj),r=e.get(nx),i=e.get(xN);switch(t.value){case`open`:n.open({header:{title:r.t(`docs-drawing-ui.panel.title`)},children:{label:Dot},onClose:()=>{i.focusDrawing(null)},width:360});break;default:n.close()}return!0}},PW={id:`doc.operation.edit-doc-image`,type:L.OPERATION,handler:(e,t)=>{let n=e.get(xN),r=e.get(R);return t!=null&&(n.focusDrawing([t]),r.executeCommand(NW.id,{value:`open`}),!0)}};function Oot(e,t,n=1,r=0){let{top:i,left:a,bottom:o,right:s}=e,c=s-a,l=o-i,{viewportScrollX:u,viewportScrollY:d}=t.getViewport(AN.VIEW_MAIN),{scaleX:f,scaleY:p}=t.getAncestorScale();return{startX:(a-u)*f,startY:(i-d)*p,endX:(a+c-u)*f,endY:(i+l-d)*p,width:c*f,height:l*p,rotate:r,absolute:{left:!1,top:!1},opacity:n??1}}function FW(e,t){let{top:n,left:r,width:i,height:a,angle:o,opacity:s}=e;return Oot({top:n,left:r,bottom:n+a,right:r+i},t.scene,s,o)}var IW=class extends P{constructor(e,t,n,r,i,a){super(),this._renderManagerService=e,this._drawingManagerService=t,this._drawingRenderService=n,this._canvasFloatDomService=r,this._univerInstanceService=i,this._commandService=a,TW(this,`_domLayerInfoMap`,new Map),this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddRemoveListener(),this._initScrollAndZoomEvent()}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e);if(t==null)return null;let n=t.scene;return{scene:n,transformer:n.getTransformerByCreate(),renderUnit:t,canvas:t.engine.getCanvasElement()}}_drawingAddRemoveListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertRects(e)})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{this._removeDom(e.drawingId)})}))}_insertRects(e){e.forEach(async e=>{let{unitId:t}=e;if(!this._univerInstanceService.getUnit(t,M.UNIVER_DOC))return;let n=this._getSceneAndTransformerByDrawingSearch(t);if(n==null)return;let r=this._drawingManagerService.getDrawingByParam(e);if(r==null)return;let i=await this._drawingRenderService.renderFloatDom(r,n.scene);if(i!=null&&i.length!==0)for(let e of i){this._addHoverForRect(e);let i=new Gf,a=new so(FW(e,n.renderUnit)),o=n.canvas,s=r.data,c={dispose:i,rect:e,position$:a,unitId:t};this._canvasFloatDomService.addFloatDom({position$:a,id:r.drawingId,componentKey:r.componentKey,onPointerDown:e=>{o.dispatchEvent(new PointerEvent(e.type,e))},onPointerMove:e=>{o.dispatchEvent(new PointerEvent(e.type,e))},onPointerUp:e=>{o.dispatchEvent(new PointerEvent(e.type,e))},onWheel:e=>{o.dispatchEvent(new WheelEvent(e.type,e))},data:s,unitId:t});let l=e.onTransformChange$.subscribeEvent(()=>{let t=FW(e,n.renderUnit);a.next(t)});i.add(()=>{this._canvasFloatDomService.removeFloatDom(r.drawingId)}),l&&i.add(l),this._domLayerInfoMap.set(r.drawingId,c)}})}_addHoverForRect(e){this.disposeWithMe(Wf(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=_w.GRAB}))),this.disposeWithMe(Wf(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=_w.DEFAULT})))}_removeDom(e){let t=this._domLayerInfoMap.get(e);if(!t)return;let{unitId:n}=t;this._domLayerInfoMap.delete(e),t.dispose.dispose();let r=this._getSceneAndTransformerByDrawingSearch(n);r&&r.scene.removeObject(t.rect)}_initScrollAndZoomEvent(){let e=e=>{let t=this._getSceneAndTransformerByDrawingSearch(e);t&&this._domLayerInfoMap.forEach(n=>{if(n.unitId!==e)return;let r=FW(n.rect,t.renderUnit);n.position$.next(r)})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_DOC).pipe(os(e=>{if(!e)return null;let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);return n?{render:n,unitId:t}:null}),sc(e=>e?zy(e.render.scene.getViewport(AN.VIEW_MAIN).onScrollAfter$).pipe(os(()=>({unitId:e.unitId}))):ts(null))).subscribe(t=>{if(!t)return;let{unitId:n}=t;e(n)})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===SF.id){let{unitId:n}=t.params;e(n)}}))}insertFloatDom(e,t){let n=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_DOC);if(!n)return!1;let r=this._getSceneAndTransformerByDrawingSearch(n.getUnitId());if(!r)return!1;let i=r.renderUnit.with(rD).getSkeleton().getSkeletonData()?.pages[0];if(!i)return!1;let{pageWidth:a,marginLeft:o,marginRight:s}=i,c=a-o-s,l={size:{width:t.width??c,height:t.height},positionH:{relativeFrom:nm.PAGE,posOffset:0},positionV:{relativeFrom:rm.PAGE,posOffset:0},angle:0},u=t.drawingId??ip(),d={unitId:n.getUnitId(),drawings:[{drawingId:u,drawingType:um.DRAWING_DOM,subUnitId:n.getUnitId(),unitId:n.getUnitId(),...e,title:``,description:``,docTransform:l,layoutType:Kp.INLINE,transform:FN(l)}]};return this._commandService.syncExecuteCommand(CW.id,d),u}};IW=OW([DW(0,KE),DW(1,xN),DW(2,j(vW)),DW(3,j(CM)),DW(4,z),DW(5,R)],IW);var kot=`doc.menu.image`,LW=vot.id,Aot=e=>{let t=e.get(nD),n=e.get(z);return new Ya(e=>{let r=t.textSelection$.subscribe(()=>{let r=t.getActiveTextRange();if(r){var i;let{segmentId:t,startOffset:a,endOffset:o}=r,s=n.getCurrentUniverDocInstance(),c=s==null||(i=s.getSelfOrHeaderFooterModel(t).getBody())==null?void 0:i.tables;if(c&&c.length&&c.some(e=>{let{startIndex:t,endIndex:n}=e;return a>=t&&a<n||o>=t&&o<n})){e.next(!0);return}}else{e.next(!0);return}e.next(!1)});return()=>r.unsubscribe()})};function jot(e){return{id:kot,type:bM.SUBITEMS,icon:`AddImageIcon`,tooltip:`docs-drawing-ui.title`,disabled$:Aot(e),hidden$:Pj(e,M.UNIVER_DOC,void 0,rf)}}function RW(e){return{id:LW,title:`docs-drawing-ui.upload.float`,type:bM.BUTTON,icon:`AddImageIcon`,hidden$:Pj(e,M.UNIVER_DOC,void 0,rf)}}var Mot=`@univerjs/docs-drawing-ui`,Not=`0.25.1`,Pot=`docs-drawing-ui.config`,Fot={};function Iot(e){if(Vv.isNoop(e)||!Array.isArray(e))return null;let t=e.find(e=>Array.isArray(e)&&e?.[0]===`drawings`);if(t==null||!Array.isArray(t)||t.length<3||typeof t[1]==`string`&&typeof t[2]!=`object`||Array.isArray(t[1])&&typeof t[1][1]!=`object`)return null;let n=[];if(Array.isArray(t?.[1])){for(let e of t)if(Array.isArray(e)){var r,i;n.push({type:e!=null&&(r=e[1])!=null&&r.i?`add`:`remove`,drawingId:e?.[0],drawing:e==null||(i=e[1])==null?void 0:i.i})}}else n.push({type:t[2]?.i?`add`:`remove`,drawingId:t[1],drawing:t[2]?.i});return n}function Lot(e){if(!Array.isArray(e)||e.length<3||e[0]!==`drawingsOrder`)return[];let t=[];for(let n=1;n<e.length;n++){let r=e[n];if(Array.isArray(r)&&typeof r[0]==`number`&&typeof r[1]==`object`)t.push(r[0]);else{t.length=0;break}}return t}var zW=class extends P{constructor(e,t,n,r,i){super(),this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=n,this._docDrawingService=r,this._renderManagerService=i,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id!==aD.id)return;let{unitId:t,actions:n,isSync:r,syncer:i}=e.params,a=Iot(n);if(a!=null)for(let{type:e,drawingId:n,drawing:o}of a)r&&o?.unitId===i||(e===`add`?this._addDrawings(t,[o]):this._removeDrawings(t,[n]))})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==aD.id)return;let{unitId:t,actions:n}=e.params;Lot(n).length>0&&this._updateDrawingsOrder(t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Cx.id&&e.id!==wx.id)return;let t=this._univerInstanceService.getCurrentUniverDocInstance()?.getUnitId(),n=this._drawingManagerService.getFocusDrawings();if(t==null||n.length===0)return;let r=this._renderManagerService.getRenderById(t)?.scene;if(r==null)return!1;r.getTransformerByCreate().refreshControls()}))}_addDrawings(e,t){let n=this._drawingManagerService,r=this._docDrawingService,{subUnitId:i,redo:a,objects:o}=this._docDrawingService.getBatchAddOp(t);n.applyJson1(e,i,a),r.applyJson1(e,i,a),n.addNotification(o),r.addNotification(o)}_removeDrawings(e,t){let n=this._drawingManagerService,r=this._docDrawingService,{subUnitId:i,redo:a,objects:o}=this._docDrawingService.getBatchRemoveOp(t.map(t=>({unitId:e,subUnitId:e,drawingId:t})));n.applyJson1(e,i,a),r.applyJson1(e,i,a),n.removeNotification(o),r.removeNotification(o)}_updateDrawingsOrder(e){let t=this._univerInstanceService.getUniverDocInstance(e);if(t==null)return;let n=t.getSnapshot().drawingsOrder;if(n==null)return;let r=this._drawingManagerService,i=this._docDrawingService;r.setDrawingOrder(e,e,n),i.setDrawingOrder(e,e,n);let a={unitId:e,subUnitId:e,drawingIds:n};r.orderNotification(a),i.orderNotification(a)}};zW=OW([DW(0,z),DW(1,R),DW(2,xN),DW(3,kU),DW(4,KE)],zW);var Rot=e=>{let{floatDomInfos:t,scene:n,offset:r,bound:i}=e,a=i.right-i.left,o=i.bottom-i.top;return(0,H.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-top-0`,children:(0,V.useMemo)(()=>t.map(e=>{let{width:t=0,height:r=0,left:i=0,top:a=0}=e.transform,o=Oot({left:i,right:i+t,top:a,bottom:a+r},n),s={position$:new so(o),position:o,id:e.drawingId,componentKey:e.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:e.unitId,data:e.data};return[e.drawingId,s]}).filter(([e,t])=>!(t.position.endX<0||t.position.endY<0||t.position.startX>a||t.position.startY>o)),[t,n,r,a,o]).map(([e,t])=>(0,H.jsx)(sYe,{layer:t,id:e,position:t.position},e))})},BW=class extends P{constructor(e,t,n,r,i){super(),this._docPrintInterceptorService=e,this._drawingRenderService=t,this._drawingManagerService=n,this._componetManager=r,this._injector=i,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._docPrintInterceptorService.interceptor.intercept(this._docPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(e,t,n)=>{let{unitId:r,scene:i}=t,a=this._drawingManagerService.getDrawingDataForUnit(r)?.[r];return a&&a.order.forEach(e=>{let t=a.data[e];t.drawingType!==um.DRAWING_CHART&&t.drawingType!==um.DRAWING_DOM&&this._drawingRenderService.renderDrawing(t,i)}),n()}}))}_initPrintingDom(){this.disposeWithMe(this._docPrintInterceptorService.interceptor.intercept(this._docPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(e,t,n)=>{let{unitId:r}=t,i=this._drawingManagerService.getDrawingDataForUnit(r)?.[r];if(i){let a=i.order.map(e=>{let t=i.data[e];if(t.drawingType===um.DRAWING_CHART)return{...t,componentKey:this._componetManager.get(Tm)};if(t.drawingType===um.DRAWING_DOM){let e=this._docPrintInterceptorService.getPrintComponent(t.componentKey);return{...t,componentKey:this._componetManager.get(e||t.componentKey)}}return null}).filter(Boolean);return Sj((0,H.jsx)(ZD(Rot,this._injector),{unitId:r,floatDomInfos:a,scene:t.scene,skeleton:t.skeleton,offset:t.offset,bound:t.bound}),t.root),e?.add(()=>{Cj(t.root)}),n(e)}}}))}};BW=OW([DW(0,j(Q2e)),DW(1,j(vW)),DW(2,xN),DW(3,j(Nj)),DW(4,j(We))],BW);function zot(e,t,n,r){let i=qT(t.tableId).tableId,a=ET(e,i),o=a&&a.contentWidth>a.viewportWidth?a.scrollLeft:0;return{left:t.left+r.left-o+r.marginLeft,top:t.top+n.top+r.marginTop}}var VW=class extends P{constructor(e,t,n,r,i,a,o,s){super(),this._context=e,this._docSkeletonManagerService=t,this._commandService=n,this._editorService=r,this._drawingManagerService=i,this._docRefreshDrawingsService=a,this._univerInstanceService=o,this._lifecycleService=s,TW(this,`_liquid`,new TT),this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._drawingInitializeListener(),this._initResize()}_initialRenderRefresh(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{e!=null&&this._refreshDrawing(e)})),this.disposeWithMe(this._docRefreshDrawingsService.refreshDrawings$.subscribe(e=>{e!=null&&this._refreshDrawing(e)}))}_commandExecutedListener(){let e=[aD.id,SF.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){let{unitId:e}=t.params,{unitId:n,mainComponent:r}=this._context;if(e!==n)return;let i=this._docSkeletonManagerService.getSkeleton();if(i==null)return;if(this._editorService.isEditor(n)&&n!==rf){r?.makeDirty();return}this._refreshDrawing(i)}}))}_initResize(){this.disposeWithMe(zy(this._context.engine.onTransformChange$).pipe(Ls(e=>e.type===qw.resize),Ks(16)).subscribe(()=>{var e;let t=this._docSkeletonManagerService.getSkeleton(),{scene:n}=this._context;(e=n.getTransformer())==null||e.refreshControls(),this._refreshDrawing(t)}))}_refreshDrawing(e){let t=e?.getSkeletonData(),{mainComponent:n,unitId:r}=this._context,i=n;if(!t)return;let{left:a,top:o,pageLayoutType:s,pageMarginLeft:c,pageMarginTop:l}=i,{pages:u,skeHeaders:d,skeFooters:f}=t,p={};this._liquid.reset();for(let e=0,t=u.length;e<t;e++){let t=u[e],{headerId:n,footerId:i,pageWidth:m}=t;if(n){let e=d.get(n)?.get(m);e&&(this._calculateDrawingPosition(r,e,a,o,p,e.marginTop,t.marginLeft),this._calculateTableCellDrawingPositions(r,e,a,o,p,e.marginTop,t.marginLeft))}if(i){let e=f.get(i)?.get(m);if(e){let n=t.pageHeight-t.marginBottom+e.marginTop;this._calculateDrawingPosition(r,e,a,o,p,n,t.marginLeft),this._calculateTableCellDrawingPositions(r,e,a,o,p,n,t.marginLeft)}}this._calculateDrawingPosition(r,t,a,o,p,t.marginTop,t.marginLeft),this._calculateTableCellDrawingPositions(r,t,a,o,p,t.marginTop,t.marginLeft),this._liquid.translatePage(t,s,c,l)}let m=Object.values(p),h=m.filter(e=>!e.isMultiTransform),g=m.filter(e=>e.isMultiTransform);h.length>0&&this._drawingManagerService.refreshTransform(h),this._handleMultiDrawingsTransform(g)}_handleMultiDrawingsTransform(e){let{scene:t,unitId:n}=this._context,r=t.getTransformerByCreate();e.forEach(e=>{let t=this._drawingManagerService.getDrawingByParam(e);t!=null&&(t.transform=e.transform,t.transforms=e.transforms,t.isMultiTransform=e.isMultiTransform)});let i=[...r.getSelectedObjectMap().keys()],a=Object.values(this._drawingManagerService.getDrawingData(n,n)).filter(e=>e.isMultiTransform===Np.TRUE);this._drawingManagerService.removeNotification(a),e.length>0&&this._drawingManagerService.addNotification(e);for(let e of i){let n=t.getObject(e);n&&r.setSelectedControl(n)}}_calculateDrawingPosition(e,t,n,r,i,a,o){let{skeDrawings:s}=t;this._liquid.translatePagePadding({marginTop:a,marginLeft:o}),s.forEach(t=>{let{aLeft:a,aTop:o,height:s,width:c,angle:l,drawingId:u,drawingOrigin:d}=t,f=d.layoutType===Kp.WRAP_NONE&&d.behindDoc===Np.TRUE,{isMultiTransform:p=Np.FALSE}=d,m={left:a+n+this._liquid.x,top:o+r+this._liquid.y,width:c,height:s,angle:l};i[u]==null?i[u]={unitId:e,subUnitId:e,drawingId:u,behindText:f,transform:m,transforms:[m],isMultiTransform:p}:p===Np.TRUE&&i[u].transforms.push(m)}),this._liquid.restorePagePadding({marginTop:a,marginLeft:o})}_calculateTableCellDrawingPositions(e,t,n,r,i,a,o){var s;(s=t.skeTables)==null||s.forEach(t=>{t.rows.forEach(s=>{s.cells.forEach(c=>{let l=zot(e,t,s,c),u=a+l.top,d=o+l.left;this._calculateDrawingPosition(e,c,n,r,i,u,d),this._calculateTableCellDrawingPositions(e,c,n,r,i,u,d)})})})}_drawingInitializeListener(){let e=()=>{let e=this._docSkeletonManagerService.getSkeleton();e!=null&&(this._refreshDrawing(e),this._drawingManagerService.initializeNotification(this._context.unitId))};this._lifecycleService.stage>=Xb.Rendered?this._docSkeletonManagerService.getSkeleton()?e():setTimeout(e,500):this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(Ls(e=>e===Xb.Rendered)).subscribe(e))}};VW=OW([DW(1,j(rD)),DW(2,R),DW(3,pI),DW(4,xN),DW(5,j(EW)),DW(6,z),DW(7,j($b))],VW);var Bot=`__InlineDrawingAnchor__`;function Vot(e,t){let n=t.parent,r=n?.parent,i=r?.parent;return!n||!r||!i||!n.cells?.includes(t)?null:{cell:t,hostPage:i,offset:zot(e,r,n,t),row:n,table:r}}var HW=class extends P{constructor(e,t,n,r){super(),this._commandService=e,this._univerInstanceService=t,this._drawingManagerService=n,this._renderManagerService=r,TW(this,`_liquid`,new TT),TW(this,`_listenerOnImageMap`,new Set),TW(this,`_transformerCache`,new Map),TW(this,`_anchorShape`,void 0),this._init()}_init(){this._listenDrawingFocus()}_listenDrawingFocus(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{if(e.length!==0)for(let t of e){let{unitId:e}=t;this._listenerOnImageMap.has(e)||(this._listenTransformerChange(e),this._listenerOnImageMap.add(e))}}))}_listenTransformerChange(e){let t=this._getSceneAndTransformerByDrawingSearch(e)?.transformer;if(t==null)return;this.disposeWithMe(Wf(t.changeStart$.subscribe(e=>{this._transformerCache.clear();let{objects:t}=e;for(let e of t.values()){var n;let{oKey:t,width:r,height:i,left:a,top:o,angle:s}=e,c=this._drawingManagerService.getDrawingOKey(t);if(c==null)continue;let l=this._univerInstanceService.getUniverDocInstance(c.unitId),u=l==null||(n=l.getSnapshot().drawings)==null?void 0:n[c.drawingId];if(u?.layoutType===Kp.INLINE)try{e.setOpacity(.2)}catch{}u!=null&&this._transformerCache.set(c.drawingId,{drawing:u,top:o,left:a,width:r,height:i,angle:s})}})));let n=_f(this._updateMultipleDrawingDocTransform.bind(this),50);this._nonInlineDrawingTransform.bind(this),this.disposeWithMe(Wf(t.changing$.subscribe(e=>{let{objects:t,offsetX:r,offsetY:i}=e;if(t.size>1)n(t);else if(t.size===1){let e=this._transformerCache.values().next().value,{width:n,height:a,top:o,left:s,angle:c}=t.values().next().value;if(e&&n===e.width&&a===e.height&&o===e.top&&s===e.left&&c===e.angle)return;e&&(e.drawing.layoutType,Kp.INLINE),e&&e.drawing.layoutType===Kp.INLINE&&r!=null&&i!=null&&this._updateInlineDrawingAnchor(e.drawing,r,i)}}))),this.disposeWithMe(Wf(t.changeEnd$.subscribe(e=>{let{objects:t,offsetX:n,offsetY:r}=e;for(let e of t.values()){let t=this._drawingManagerService.getDrawingOKey(e.oKey);if(t!=null&&this._transformerCache.get(t?.drawingId)?.drawing.layoutType===Kp.INLINE)try{e.setOpacity(1)}catch{}}if(this._anchorShape&&this._anchorShape.hide(),t.size>1)this._updateMultipleDrawingDocTransform(t);else if(t.size===1){let e=this._transformerCache.values().next().value,i=t.values().next().value,{width:a,height:o,top:s,left:c,angle:l}=i;if(e&&a===e.width&&o===e.height&&s===e.top&&c===e.left&&l===e.angle)return;e&&e.drawing.layoutType===Kp.INLINE?a!==e.width||o!==e.height||l!==e.angle?this._updateDrawingSize(e,i):n!=null&&r!=null&&this._moveInlineDrawing(e.drawing,n,r):e&&this._nonInlineDrawingTransform(e.drawing,i)}this._transformerCache.clear()})))}_updateMultipleDrawingDocTransform(e){if(e.size<1)return;let t=[],n,r;for(let i of e.values()){let{oKey:e,left:a,top:o,angle:s}=i,{width:c,height:l}=i,u=this._drawingManagerService.getDrawingOKey(e);if(u==null)continue;n??=u.unitId,r??=u.subUnitId;let d=this._transformerCache.get(u.drawingId);if(d==null)continue;let{drawing:f,top:p,left:m,width:h,height:g,angle:_}=d,{width:v,height:y}=this._getPageContentSize(f);if(c=Math.min(c,v),l=Math.min(l,y),(h!==c||g!==l)&&t.push({drawingId:u.drawingId,key:`size`,value:{width:c,height:l}}),_!==s&&t.push({drawingId:u.drawingId,key:`angle`,value:s}),p!==o||m!==a){let e=o-p,n=a-m;e!==0&&t.push({drawingId:u.drawingId,key:`positionV`,value:{relativeFrom:f.docTransform.positionV.relativeFrom,posOffset:f.docTransform.positionV.posOffset+e}}),n!==0&&t.push({drawingId:u.drawingId,key:`positionH`,value:{relativeFrom:f.docTransform.positionH.relativeFrom,posOffset:f.docTransform.positionH.posOffset+n}})}}t.length>0&&n&&r&&this._commandService.executeCommand(jW.id,{unitId:n,subUnitId:r,drawings:t})}_updateDrawingAnchor(e){if(this._transformerCache.size!==1)return;let t=this._transformerCache.values().next().value,n=e.values().next().value;this._getDrawingAnchor(t.drawing,n)}_updateInlineDrawingAnchor(e,t,n){if(this._transformerCache.size!==1)return;let{contentBoxPointGroup:r}=this._getInlineDrawingAnchor(e,t,n)??{};r!=null&&this._createOrUpdateInlineAnchor(e.unitId,r)}_getInlineDrawingAnchor(e,t,n){let r=this._renderManagerService.getRenderById(e.unitId),i=r?.with(rD).getSkeleton();if(r==null)return;let{mainComponent:a,scene:o}=r,s=a,c=o.getViewports()[0],{pageLayoutType:l=Rw.VERTICAL,pageMarginLeft:u,pageMarginTop:d}=s.getOffsetConfig(),f=null,p=!1,m=-1,h=``,g=this._getTransformCoordForDocumentOffset(s,c,t,n);if(g==null)return;let _=this._renderManagerService.getRenderById(e.unitId)?.with(XF);if(_==null)return;let v=i?.findNodeByCoord(g,l,u,d,{strict:!1,segmentId:_.getSegment(),segmentPage:_.getSegmentPage()});if(v){let{node:e,ratioX:t,segmentPage:n,segmentId:r}=v;p=t<.5,f=e,m=n,h=r}if(f==null)return;let y=i?.findPositionByGlyph(f,m),b=this._getDocObject();if(y==null||i==null||b==null)return;let x={...y,isBack:p},{cursorList:S,contentBoxPointGroup:C}=new BF(b.document.getOffsetConfig(),i).getRangePointData(x,x),{startOffset:w}=RF(S)??{};if(w!=null)return{offset:w,contentBoxPointGroup:C,segmentId:h,segmentPage:m}}_getDrawingAnchor(e,t){var n;let r=this._renderManagerService.getRenderById(e.unitId),i=r?.with(rD).getSkeleton(),a=i?.getSkeletonData();if(a==null||r==null)return;let{pages:o,skeHeaders:s,skeFooters:c}=a,{mainComponent:l,scene:u}=r,d=l,f=u.getViewports()[0],{pageLayoutType:p=Rw.VERTICAL,pageMarginLeft:m,pageMarginTop:h,docsLeft:g,docsTop:_}=d.getOffsetConfig(),{left:v,top:y,angle:b}=t,{width:x,height:S}=t,{positionV:C,positionH:w}=e.docTransform,{width:T,height:E}=this._getPageContentSize(e);x=Math.min(x,T),S=Math.min(S,E);let D=null,O=``,k=-1,A={...e.docTransform,size:{width:x,height:S},angle:b},{x:ee,y:te}=u.getViewportScrollXY(f),ne=this._getTransformCoordForDocumentOffset(d,f,v-ee,y-te);if(ne==null)return;let re=this._renderManagerService.getRenderById(e.unitId)?.with(XF);if(re==null)return;let ie=i?.findNodeByCoord(ne,p,m,h,{strict:!1,segmentId:re.getSegment(),segmentPage:re.getSegmentPage()});if(ie){let{node:e,segmentPage:t,segmentId:n}=ie;D=e,k=t,O=n}if(D==null)return;let ae=D.parent?.parent,oe=ae?.parent,se=oe?.lines.find(e=>e.paragraphIndex===ae?.paragraphIndex&&e.paragraphStart)??oe?.lines[0],ce=oe==null||(n=oe.parent)==null?void 0:n.parent;if(ae==null||oe==null||se==null||ce==null)return;this._liquid.reset();let le=ce.type===Iw.CELL?Vot(e.unitId,ce):null,ue=le?.hostPage??ce,de=ue.type;for(let e of o){let{headerId:t,footerId:n,pageHeight:r,pageWidth:i,marginLeft:a,marginBottom:l}=e,u=o.indexOf(e);if(k>-1&&u===k){switch(de){case Iw.HEADER:{let e=s.get(t)?.get(i);if(e)this._liquid.translatePagePadding({marginTop:e.marginTop,marginLeft:a});else throw Error(`header skeleton not found`);break}case Iw.FOOTER:{let e=c.get(n)?.get(i);if(e)this._liquid.translatePagePadding({marginTop:r-l+e.marginTop,marginLeft:a});else throw Error(`footer skeleton not found`);break}default:this._liquid.translatePagePadding(e)}break}if(this._liquid.translatePagePadding(e),e===ue)break;this._liquid.restorePagePadding(e),this._liquid.translatePage(e,p,m,h)}if(le&&this._liquid.translate(le.offset.left,le.offset.top),C.relativeFrom===rm.LINE)D=ae.divides[0].glyphGroup[0];else{var fe;D=((fe=se.divides)==null||(fe=fe[0])==null||(fe=fe.glyphGroup)==null?void 0:fe[0])??D}switch(A.positionH={relativeFrom:w.relativeFrom,posOffset:v-this._liquid.x-g},w.relativeFrom){case nm.MARGIN:A.positionH.posOffset=v-this._liquid.x-g-ce.marginLeft;break;case nm.COLUMN:A.positionH.posOffset=v-this._liquid.x-g-oe.left}switch(A.positionV={relativeFrom:C.relativeFrom,posOffset:y-this._liquid.y-_},C.relativeFrom){case rm.PAGE:A.positionV.posOffset=y-this._liquid.y-_-ce.marginTop;break;case rm.LINE:A.positionV.posOffset=y-this._liquid.y-_-ae.top;break;case rm.PARAGRAPH:A.positionV.posOffset=y-this._liquid.y-_-se.top}if(D==null)return;let pe=i?.findPositionByGlyph(D,k),me=this._getDocObject();if(pe==null||i==null||me==null)return;let he={...pe,isBack:!1},{cursorList:ge}=new BF(me.document.getOffsetConfig(),i).getRangePointData(he,he),{startOffset:_e}=RF(ge)??{};if(_e!=null)return{offset:_e,docTransform:A,segmentId:O,segmentPage:k}}_updateDrawingSize(e,t){let n=[],{drawing:r,width:i,height:a,angle:o}=e,{unitId:s,subUnitId:c}=r,{width:l,height:u,angle:d}=t,{width:f,height:p}=this._getPageContentSize(r);l=Math.min(f,l),u=Math.min(p,u),(l!==i||u!==a)&&n.push({drawingId:r.drawingId,key:`size`,value:{width:l,height:u}}),d!==o&&n.push({drawingId:r.drawingId,key:`angle`,value:d}),n.length>0&&s&&c&&this._commandService.executeCommand(jW.id,{unitId:s,subUnitId:c,drawings:n})}_moveInlineDrawing(e,t,n){let{offset:r,segmentId:i,segmentPage:a}=this._getInlineDrawingAnchor(e,t,n)??{};return this._commandService.executeCommand(wot.id,{unitId:e.unitId,subUnitId:e.unitId,drawing:e,offset:r,segmentId:i,segmentPage:a,needRefreshDrawings:r==null})}_limitDrawingInPage(e,t){let n=this._renderManagerService.getRenderById(e.unitId),{left:r,top:i,width:a,height:o,angle:s}=t,c=(n?.with(rD).getSkeleton())?.getSkeletonData(),{pages:l}=c??{};if(c==null||n==null||l==null)return{left:r,top:i,width:a,height:o,angle:s};let{mainComponent:u}=n,{top:d,pageLayoutType:f,pageMarginLeft:p,pageMarginTop:m}=u,h=i;this._liquid.reset();for(let e of l){let{marginBottom:t,pageHeight:n}=e,r=l[l.indexOf(e)+1];r!=null&&(F.hasIntersectionBetweenTwoRanges(i,i+o,this._liquid.y+d+n-t,this._liquid.y+d+n+m+r.marginTop)&&(h=i+o/2<this._liquid.y+d+n+m/2?Math.min(i,this._liquid.y+d+n-t-o):Math.max(i,this._liquid.y+d+n+m+r.marginTop)),this._liquid.translatePage(e,f,p,m))}return{left:r,top:h,width:a,height:o,angle:s}}_nonInlineDrawingTransform(e,t,n=!1){let r=e.isMultiTransform===Np.TRUE?t:this._limitDrawingInPage(e,t);if(n&&r.top!==t.top)return;let{offset:i,docTransform:a,segmentId:o,segmentPage:s}=this._getDrawingAnchor(e,r)??{};return i==null||a==null?this._updateMultipleDrawingDocTransform(new Map([[e.drawingId,t]])):this._commandService.executeCommand(Tot.id,{unitId:e.unitId,subUnitId:e.unitId,drawing:e,offset:i,docTransform:a,segmentId:o,segmentPage:s})}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e)?.scene;if(t!=null)return{scene:t,transformer:t.getTransformerByCreate()}}_getTransformCoordForDocumentOffset(e,t,n,r){let{documentTransform:i}=e.getOffsetConfig(),a=t.transformVector2SceneCoord(zw.FromArray([n,r]));if(a)return i.clone().invert().applyPoint(a)}_createOrUpdateInlineAnchor(e,t){let n=this._renderManagerService.getRenderById(e);if(n==null)return;let{mainComponent:r,scene:i}=n,{docsLeft:a,docsTop:o}=r.getOffsetConfig(),{left:s,top:c,height:l}=UF(t),u=s+a,d=c+o;if(this._anchorShape){this._anchorShape.transformByState({left:u,top:d,height:l}),this._anchorShape.show();return}let f=new OE(Bot+ip(6),{left:u,top:d,height:l,strokeWidth:2,stroke:xw(nh.darkgray,1),evented:!1});this._anchorShape=f,i.addObject(f,3)}_getDocObject(){return xYe(this._univerInstanceService,this._renderManagerService)}_getPageContentSize(e){let t=this._renderManagerService.getRenderById(e.unitId),n=(t?.with(rD).getSkeleton())?.getSkeletonData();if(n==null||t==null)return{width:500,height:500};let{pages:r}=n,i=null;for(let t of r){let{skeDrawings:n}=t;if(n.has(e.drawingId)){i=t;break}}if(i){let{pageWidth:e,pageHeight:t,marginLeft:n,marginBottom:r,marginRight:a,marginTop:o}=i;return{width:Math.max(500,e-n-a),height:Math.max(500,t-o-r)}}return{width:500,height:500}}};HW=OW([DW(0,R),DW(1,z),DW(2,xN),DW(3,KE)],HW);var Hot={[pM.MEDIA]:{[kot]:{order:0,menuItemFactory:jot,[LW]:{order:0,menuItemFactory:RW}}},[hM.PARAGRAPH]:{[gM.LAYOUT]:{[GI]:{[LW]:{order:5,menuItemFactory:RW}}},[BI]:{[gM.LAYOUT]:{[LW]:{order:5,menuItemFactory:RW}}},[I1e]:{[gM.LAYOUT]:{[LW]:{order:5,menuItemFactory:RW}}}}},Uot=-1e3,Wot=1e3,Got=e=>{let t=U(R),n=U(nx),r=U(xN),i=U(KE),a=U(z),{drawings:o}=e,s=o[0];if(s==null)return;let{unitId:c}=s,l=a.getUniverDocInstance(c),u=l?.getSnapshot().documentStyle.documentFlavor,d=i.getRenderById(c)?.scene;if(d==null)return;let f=d.getTransformerByCreate(),p=[{label:n.t(`docs-drawing-ui.image-position.column`),value:String(nm.COLUMN)},{label:n.t(`docs-drawing-ui.image-position.page`),value:String(nm.PAGE)},{label:n.t(`docs-drawing-ui.image-position.margin`),value:String(nm.MARGIN)}],m=[{label:n.t(`docs-drawing-ui.image-position.line`),value:String(rm.LINE),disabled:u===Vp.MODERN},{label:n.t(`docs-drawing-ui.image-position.page`),value:String(rm.PAGE),disabled:u===Vp.MODERN},{label:n.t(`docs-drawing-ui.image-position.margin`),value:String(rm.MARGIN),disabled:u===Vp.MODERN},{label:n.t(`docs-drawing-ui.image-position.paragraph`),value:String(rm.PARAGRAPH)}],[h,g]=(0,V.useState)(!0),[_,v]=(0,V.useState)({relativeFrom:nm.PAGE,posOffset:0}),[y,b]=(0,V.useState)({relativeFrom:rm.PAGE,posOffset:0}),[x,S]=(0,V.useState)(!0),[C,w]=(0,V.useState)(!0);function T(e,n){e===`positionH`?v(n):b(n);let a=r.getFocusDrawings();if(a.length===0)return;let o=a.map(e=>({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}));t.executeCommand(jW.id,{unitId:a[0].unitId,subUnitId:a[0].unitId,drawings:o.map(t=>({drawingId:t.drawingId,key:e,value:n}))});let s=i.getRenderById(c)?.with(XF);s&&s.blur(),f.refreshControls()}function E(e){let t=_.relativeFrom,n=_.posOffset,a=Number(e);if(t===a)return;let o=r.getFocusDrawings();if(o.length===0)return;let s=o[0].drawingId,c=o[0].unitId,l=null,u=0,d=(i.getRenderById(c)?.with(rD).getSkeleton())?.getSkeletonData();if(d==null)return;let{pages:f,skeHeaders:p,skeFooters:m}=d;for(let e of f){let{marginLeft:t,skeDrawings:n,headerId:r,footerId:i,pageWidth:a}=e;if(n.has(s)){l=n.get(s),u=t;break}let o=p.get(r)?.get(a);if(o?.skeDrawings.has(s)){l=o?.skeDrawings.get(s),u=t;break}let c=m.get(i)?.get(a);if(c?.skeDrawings.has(s)){l=c?.skeDrawings.get(s),u=t;break}}if(l==null)return;let h=0;t===nm.COLUMN?h-=l.columnLeft:t===nm.MARGIN&&(h-=u),a===nm.COLUMN?h+=l.columnLeft:a===nm.MARGIN?h+=u:nm.PAGE,T(`positionH`,{relativeFrom:a,posOffset:(n??0)-h})}function D(e){var t,n,o;let s=y.relativeFrom,c=y.posOffset,l=Number(e);if(s===l)return;let u=r.getFocusDrawings();if(u.length===0)return;let{drawingId:d,unitId:f}=u[0],p=a.getUniverDocInstance(f),m=i.getRenderById(f)?.with(rD).getSkeleton(),h=i.getRenderById(f)?.with(XF),g=h?.getSegment(),_=h?.getSegmentPage(),v=p==null||(t=p.getSelfOrHeaderFooterModel(g).getBody())==null||(t=t.customBlocks)==null?void 0:t.find(e=>e.blockId===d);if(v==null||m==null||h==null)return;let{startIndex:b}=v,x=m.findNodeByCharIndex(b,g,_),S=x==null||(n=x.parent)==null?void 0:n.parent,C=S?.parent,w=C?.lines.find(e=>e.paragraphIndex===S?.paragraphIndex&&e.paragraphStart),E=C==null||(o=C.parent)==null?void 0:o.parent;if(x==null||S==null||w==null||C==null||E==null)return;let D=0;s===rm.PARAGRAPH?D-=w.top:s===rm.LINE?D-=S.top:s===rm.PAGE&&(D+=E.marginTop),l===rm.PARAGRAPH?D+=w.top:l===rm.LINE?D+=S.top:l===rm.PAGE&&(D-=E.marginTop),T(`positionV`,{relativeFrom:l,posOffset:(c??0)-D})}function O(e){var t;let n=l?.getSnapshot(),r=n==null||(t=n.drawings)==null?void 0:t[e.drawingId];if(r==null)return;let{layoutType:i}=r,{positionH:a,positionV:o}=r.docTransform;v(a),b(o),g(i===Kp.INLINE),S(o.relativeFrom===rm.PARAGRAPH||o.relativeFrom===rm.LINE)}function k(){let e=r.getFocusDrawings();e.length!==0&&O(e[0])}function A(e){S(e),D(String(e?rm.PARAGRAPH:rm.PAGE))}return(0,V.useEffect)(()=>{k();let e=r.focus$.subscribe(e=>{if(e.length===0){w(!1);return}w(!0),O(e[0])}),n=t.onCommandExecuted(async e=>{e.id===aD.id&&k()});return()=>{e.unsubscribe(),n.dispose()}},[]),(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!C}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.title`)})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.horizontal`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.absolutePosition`)}),(0,H.jsx)(dj,{min:Uot,max:Wot,precision:1,disabled:h,value:_.posOffset,onChange:e=>{T(`positionH`,{relativeFrom:_.relativeFrom,posOffset:e})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.toTheRightOf`)}),(0,H.jsx)(bj,{value:String(_.relativeFrom),disabled:h,options:p,onChange:E})]})]}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.vertical`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.absolutePosition`)}),(0,H.jsx)(dj,{min:Uot,max:Wot,precision:1,disabled:h,value:y.posOffset,onChange:e=>{T(`positionV`,{relativeFrom:y.relativeFrom,posOffset:e})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.bellow`)}),(0,H.jsx)(bj,{disabled:h,value:String(y.relativeFrom),options:m,onChange:D})]})]}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.options`)})}),(0,H.jsx)(`div`,{children:(0,H.jsx)($A,{disabled:h,checked:x,onChange:A,children:n.t(`docs-drawing-ui.image-position.moveObjectWithText`)})})]})},UW=0,WW=100,Kot=e=>{let t=U(R),n=U(nx),r=U(xN),i=U(KE),a=U(z),{drawings:o}=e,s=o[0];if(s==null)return null;let{unitId:c}=s,l=a.getUniverDocInstance(c);if(i.getRenderById(c)?.scene==null)return null;let[u,d]=(0,V.useState)(!0),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(!0),[g,_]=(0,V.useState)(`inline`),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)({distT:0,distL:0,distB:0,distR:0}),[S,C]=(0,V.useState)(!0);function w(e){_(e);let n=r.getFocusDrawings();if(n.length===0)return;let{unitId:i,subUnitId:a}=n[0],o=n.map(({unitId:e,subUnitId:t,drawingId:n})=>({unitId:e,subUnitId:t,drawingId:n}));t.executeCommand(xot.id,{unitId:i,subUnitId:a,drawings:o,wrappingStyle:e})}function T(e){y(e);let n=r.getFocusDrawings();if(n.length===0)return;let i=n.map(e=>({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}));t.executeCommand(Cot.id,{unitId:n[0].unitId,subUnitId:n[0].unitId,drawings:i,wrapText:e})}function E(e,n){if(e==null)return;x({...b,[n]:e});let i=r.getFocusDrawings();if(i.length===0)return;let a=i.map(e=>({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}));t.executeCommand(Sot.id,{unitId:i[0].unitId,subUnitId:i[0].unitId,drawings:a,dist:{[n]:e}})}function D(){let e=r.getFocusDrawings();e.length!==0&&O(e[0])}function O(e){var t;let n=l==null||(t=l.getSnapshot())==null||(t=t.drawings)==null?void 0:t[e.drawingId];if(n==null)return;let{distT:r=0,distL:i=0,distB:a=0,distR:o=0,layoutType:s=Kp.INLINE,behindDoc:c=Np.FALSE,wrapText:u=Gp.BOTH_SIDES}=n;if(x({distT:r,distL:i,distB:a,distR:o}),y(u),d(s!==Kp.WRAP_SQUARE),s===Kp.WRAP_NONE||s===Kp.INLINE?p(!0):p(!1),s===Kp.WRAP_NONE||s===Kp.INLINE||s===Kp.WRAP_TOP_AND_BOTTOM?h(!0):h(!1),s===Kp.WRAP_NONE)c===Np.TRUE?_(`behindText`):_(`inFrontOfText`);else switch(s){case Kp.INLINE:_(`inline`);break;case Kp.WRAP_SQUARE:_(`wrapSquare`);break;case Kp.WRAP_TOP_AND_BOTTOM:_(`wrapTopAndBottom`);break;default:throw Error(`Unsupported layout type: ${s}`)}}return(0,V.useEffect)(()=>{D();let e=r.focus$.subscribe(e=>{if(e.length===0){C(!1);return}C(!0),O(e[0])}),n=t.onCommandExecuted(async e=>{e.id===aD.id&&D()});return()=>{e.unsubscribe(),n.dispose()}},[]),(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!S}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.title`)})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.wrappingStyle`)})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(vj,{value:g,onChange:w,direction:`vertical`,children:[(0,H.jsx)(yj,{value:`inline`,children:n.t(`docs-drawing-ui.image-text-wrap.inline`)}),(0,H.jsx)(yj,{value:`wrapSquare`,children:n.t(`docs-drawing-ui.image-text-wrap.square`)}),(0,H.jsx)(yj,{value:`wrapTopAndBottom`,children:n.t(`docs-drawing-ui.image-text-wrap.topAndBottom`)}),(0,H.jsx)(yj,{value:`behindText`,children:n.t(`docs-drawing-ui.image-text-wrap.behindText`)}),(0,H.jsx)(yj,{value:`inFrontOfText`,children:n.t(`docs-drawing-ui.image-text-wrap.inFrontText`)})]})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.wrapText`)})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(vj,{disabled:u,value:v,onChange:T,direction:`horizontal`,children:[(0,H.jsx)(yj,{value:Gp.BOTH_SIDES,children:n.t(`docs-drawing-ui.image-text-wrap.bothSide`)}),(0,H.jsx)(yj,{value:Gp.LEFT,children:n.t(`docs-drawing-ui.image-text-wrap.leftOnly`)}),(0,H.jsx)(yj,{value:Gp.RIGHT,children:n.t(`docs-drawing-ui.image-text-wrap.rightOnly`)})]})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.distanceFromText`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.top`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:f,precision:1,value:b.distT,onChange:e=>{E(e,`distT`)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.left`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:m,precision:1,value:b.distL,onChange:e=>{E(e,`distL`)}})]})]}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.bottom`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:f,precision:1,value:b.distB,onChange:e=>{E(e,`distB`)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.right`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:m,precision:1,value:b.distR,onChange:e=>{E(e,`distR`)}})]})]})]})},qot=()=>{let e=U(xN),[t,n]=(0,V.useState)(e.getFocusDrawings());return(0,V.useEffect)(()=>{let t=e.focus$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[]),!!t?.length&&(0,H.jsxs)(`div`,{className:`univer-text-sm`,children:[(0,H.jsx)(uot,{drawings:t,hasAlign:!1,hasCropper:!0,hasGroup:!1,hasTransform:!1}),(0,H.jsx)(Kot,{drawings:t}),(0,H.jsx)(Got,{drawings:t})]})};function GW(e){return e.getContextValue(`FOCUSING_DOC`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&e.getContextValue(`FOCUSING_COMMON_DRAWINGS`)}var Jot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-down`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_DOWN,priority:100,preconditions:GW,staticParameters:{direction:I.DOWN}},Yot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-up`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_UP,priority:100,preconditions:GW,staticParameters:{direction:I.UP}},Xot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-left`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_LEFT,priority:100,preconditions:GW,staticParameters:{direction:I.LEFT}},Zot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-right`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_RIGHT,priority:100,preconditions:GW,staticParameters:{direction:I.RIGHT}},Qot={id:dot.id,description:`docs-drawing-ui.shortcut.drawing-delete`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,preconditions:GW,binding:aM.DELETE,mac:aM.BACKSPACE},KW=class extends P{constructor(e,t,n,r){super(),this._componentManager=e,this._menuManagerService=t,this._commandService=n,this._shortcutService=r,this._init()}_initCustomComponents(){let e=this._componentManager;this.disposeWithMe(e.register(Dot,qot))}_initMenus(){this._menuManagerService.mergeMenu(Hot)}_initCommands(){[vot,CW,xot,Sot,Cot,jW,wot,Tot,SW,NW,Eot,PW,fot,hot,MW,dot,mot].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initShortcuts(){[Jot,Yot,Xot,Zot,Qot].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};KW=OW([DW(0,j(Nj)),DW(1,_M),DW(2,R),DW(3,cM)],KW);var qW=class extends Kf{constructor(e,t,n,r,i,a){super(),this._drawingManagerService=e,this._canvasPopManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._contextService=i,this._commandService=a,TW(this,`_initImagePopupMenu`,new Set),TW(this,`_disposePopups`,[]),TW(this,`_isDrawingPanelOpen`,!1),this._init()}_init(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===PW.id&&(this._isDrawingPanelOpen=!0,this._clearPopups()),e.id===NW.id){let t=e.params;this._isDrawingPanelOpen=t?.value===`open`,this._isDrawingPanelOpen&&this._clearPopups()}})),this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e.length===0&&(this._isDrawingPanelOpen=!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_DOC).pipe(cc(this.dispose$)).subscribe(e=>this._create(e))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_DOC).pipe(cc(this.dispose$)).subscribe(e=>this._dispose(e))),this._univerInstanceService.getAllUnitsForType(M.UNIVER_DOC).forEach(e=>this._create(e))}_dispose(e){let t=e.getUnitId();this._clearPopups(),this._renderManagerService.removeRender(t)}_clearPopups(){this._disposePopups.forEach(e=>e.dispose()),this._disposePopups.length=0}_create(e){if(!e)return;let t=e.getUnitId();lf(t)||this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(e){let t=e.getAllObjects();for(let e of t)if(e instanceof hW)return!0;return!1}_popupMenuListener(e){let t=this._renderManagerService.getRenderById(e)?.scene;if(!t)return;let n=t.getTransformerByCreate();if(!n)return;let r=this._disposePopups;this.disposeWithMe(n.createControl$.subscribe(()=>{if(this._hasCropObject(t))return;let e=n.getSelectedObjectMap();if(r.forEach(e=>e.dispose()),r.length=0,this._isDrawingPanelOpen||e.size>1)return;let i=e.values().next().value;if(!i)return;let a=i.oKey,o=this._drawingManagerService.getDrawingOKey(a);if(!o||o.drawingType===um.DRAWING_DOM||o.drawingType===um.DRAWING_SHAPE)return;let{unitId:s,subUnitId:c,drawingId:l,drawingType:u}=o,d=u===um.DRAWING_IMAGE,f=this._canvasPopManagerService.attachPopupToObject(i,{componentKey:iW,direction:d?`top-center`:`horizontal`,offset:d?[0,8]:[2,0],extraProps:{menuItems:this._getImageMenuItems(s,c,l,u),variant:d?`doc-floating-toolbar`:void 0,unitId:s,subUnitId:c,drawingId:l}},s);r.push(this.disposeWithMe(f)),!this._drawingManagerService.getFocusDrawings().find(e=>e.unitId===s&&e.subUnitId===c&&e.drawingId===l)&&this._drawingManagerService.focusDrawing([{unitId:s,subUnitId:c,drawingId:l}])})),this.disposeWithMe(n.clearControl$.subscribe(()=>{r.forEach(e=>e.dispose()),r.length=0,this._contextService.setContextValue(ab,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(n.changing$.subscribe(()=>{r.forEach(e=>e.dispose()),r.length=0})),this.disposeWithMe(n.changeStart$.subscribe(()=>{r.forEach(e=>e.dispose()),r.length=0}))}_getImageMenuItems(e,t,n,r){return[{label:`docs-drawing-ui.image-popup.edit`,index:0,commandId:PW.id,commandParams:{unitId:e,subUnitId:t,drawingId:n},disable:r===um.DRAWING_DOM},{label:`docs-drawing-ui.image-popup.delete`,index:1,commandId:SW.id,commandParams:{unitId:e,drawings:[{unitId:e,subUnitId:t,drawingId:n}]},disable:!1},{label:`docs-drawing-ui.image-popup.crop`,index:2,commandId:QU.id,commandParams:{unitId:e,subUnitId:t,drawingId:n},disable:r===um.DRAWING_DOM},{label:`docs-drawing-ui.image-popup.reset`,index:3,commandId:tW.id,commandParams:[{unitId:e,subUnitId:t,drawingId:n}],disable:!0}]}};qW=OW([DW(0,xN),DW(1,j(YI)),DW(2,KE),DW(3,z),DW(4,Fm),DW(5,R)],qW);var JW=class extends dx{constructor(e=Fot,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=r;let{...i}=Qi({},Fot,this._config);this._configService.setConfig(Pot,i)}onStarting(){[[KW],[qW],[HW],[zW],[EW],[IW],[BW]].forEach(e=>this._injector.add(e))}onReady(){[[kW],[VW]].forEach(e=>this._renderManagerSrv.registerRenderModule(M.UNIVER_DOC,e)),this._injector.get(zW),this._injector.get(KW),this._injector.get(HW),this._injector.get(BW)}onRendered(){this._injector.get(qW),this._injector.get(IW)}};TW(JW,`type`,M.UNIVER_DOC),TW(JW,`pluginName`,`DOC_DRAWING_UI_PLUGIN`),TW(JW,`packageName`,Mot),TW(JW,`version`,Not),JW=OW([px(bW,DN,PU,_N),DW(1,j(We)),DW(2,KE),DW(3,Nm)],JW);function $ot(e={}){let{collaboration:t=!1}=e;return{plugins:[[DN,{override:t?[[ub,null]]:[]}],bW,PU,JW].filter(e=>!!e)}}var est={"docs-drawing-ui":{title:`图片`,upload:{float:`插入图片`},panel:{title:`编辑图片`},"image-popup":{replace:`替换`,delete:`删除`,edit:`编辑`,crop:`裁剪`,reset:`重置大小`},"image-text-wrap":{title:`文字环绕`,wrappingStyle:`环绕方式`,square:`四周型`,topAndBottom:`上下型`,inline:`嵌入型`,behindText:`衬于文字下方`,inFrontText:`浮于文字上方`,wrapText:`自动换行`,bothSide:`两侧`,leftOnly:`左侧`,rightOnly:`右侧`,distanceFromText:`距正文`,top:`上(px)`,left:`左(px)`,bottom:`下(px)`,right:`右(px)`},"image-position":{title:`位置`,horizontal:`水平`,vertical:`垂直`,absolutePosition:`绝对位置(px)`,relativePosition:`相对位置`,toTheRightOf:`右侧`,relativeTo:`相对于`,bellow:`下方`,options:`选项`,moveObjectWithText:`对象随文字移动`,column:`栏`,margin:`页边距`,page:`页面`,line:`行`,paragraph:`段落`},"update-status":{exceedMaxSize:`图片大小超过限制, 限制为{0}M`,invalidImageType:`图片类型错误`,exceedMaxCount:`图片只能一次上传{0}张`,invalidImage:`无效图片`},shortcut:{"drawing-view":`绘图视图`,"drawing-move-down":`下移绘图`,"drawing-move-up":`上移绘图`,"drawing-move-left":`左移绘图`,"drawing-move-right":`右移绘图`,"drawing-delete":`删除绘图`}}},tst={"drawing-ui":{"image-cropper":{error:`无法裁剪非图片元素`},"image-panel":{arrange:{title:`排列`,forward:`上移一层`,backward:`下移一层`,front:`置于顶层`,back:`置于底层`},transform:{title:`变换`,rotate:`旋转 (°)`,x:`X (px)`,y:`Y (px)`,width:`宽度 (px)`,height:`高度 (px)`,lock:`锁定比例 (%)`},crop:{title:`裁剪`,start:`开始裁剪`,mode:`自由比例裁剪`},group:{title:`组合`,group:`组合`,unGroup:`取消组合`},align:{title:`对齐方式`,default:`选择对齐方式`,left:`左对齐`,center:`水平居中`,right:`右对齐`,top:`顶部对齐`,middle:`垂直居中`,bottom:`底部对齐`,horizon:`水平分布`,vertical:`垂直分布`},null:`未选中任何对象`},"image-text-wrap":{title:`文字环绕`,wrappingStyle:`环绕方式`,square:`四周型`,topAndBottom:`上下型`,inline:`嵌入型`,behindText:`衬于文字下方`,inFrontText:`浮于文字上方`,wrapText:`自动换行`,bothSide:`两侧`,leftOnly:`左侧`,rightOnly:`右侧`,distanceFromText:`距正文`,top:`上(px)`,left:`左(px)`,bottom:`下(px)`,right:`右(px)`},"image-popup":{replace:`替换`,delete:`删除`,edit:`编辑`,crop:`裁剪`,reset:`重置大小`}}},nst=Rg(est,tst),rst=`@univerjs/docs-hyper-link`,ist=`0.25.1`,ast={id:`docs.mutation.add-hyper-link`,type:L.MUTATION,handler:()=>!0},ost={id:`docs.mutation.update-hyper-link`,type:L.MUTATION,handler:()=>!0},sst={id:`docs.mutation.delete-hyper-link`,type:L.MUTATION,handler:()=>!0},cst=`docs-hyper-link.config`,lst={};function YW(e,t){return function(n,r){t(n,r,e)}}function ust(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var dst=`DOC_HYPER_LINK_PLUGIN`,XW=class extends P{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:dst,businesses:[M.UNIVER_DOC],onLoad:(e,t)=>{let n=this._univerInstanceService.getUnit(e,M.UNIVER_DOC);if(!n)return;let r=new Map,i=e=>{var t;return(t=e.getBody())==null||(t=t.customRanges)==null||t.forEach(e=>{e.rangeType===Rp.HYPERLINK&&r.set(e.rangeId,e)}),r};n.headerModelMap.forEach(e=>{i(e)}),n.footerModelMap.forEach(e=>{i(e)}),i(n),t.links.forEach(e=>{let t=r.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:e=>{let t=this._univerInstanceService.getUnit(e,M.UNIVER_DOC),n=[];if(t){let e=e=>{var t;(t=e.getBody())==null||(t=t.customRanges)==null||t.forEach(e=>{e.rangeType===Rp.HYPERLINK&&n.push({id:e.rangeId,payload:e.properties?.url||``})})};t.headerModelMap.forEach(t=>{e(t)}),t.footerModelMap.forEach(t=>{e(t)}),e(t)}return JSON.stringify({links:n})},parseJson(e){return JSON.parse(e)}})}};XW=ust([YW(0,j(By)),YW(1,z)],XW);function ZW(e){"@babel/helpers - typeof";return ZW=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ZW(e)}function fst(e,t){if(ZW(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ZW(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function pst(e){var t=fst(e,`string`);return ZW(t)==`symbol`?t:t+``}function QW(e,t,n){return(t=pst(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var $W=class extends dx{constructor(e=lst,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._commandService=r;let{...i}=Qi({},lst,this._config);this._configService.setConfig(cst,i)}onStarting(){[[XW]].forEach(e=>this._injector.add(e)),[ast,sst,ost].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(XW)}};QW($W,`pluginName`,dst),QW($W,`packageName`,rst),QW($W,`version`,ist),QW($W,`type`,M.UNIVER_DOC),$W=ust([YW(1,j(We)),YW(2,Nm),YW(3,R)],$W);var mst=`@univerjs/docs-hyper-link-ui`,hst=`0.25.1`,gst=`docs-hyper-link-ui.config`,_st={},vst={type:L.COMMAND,id:`docs.command.add-hyper-link`,async handler(e,t){if(!t)return!1;let{payload:n,unitId:r,selections:i}=t,a=e.get(R),o=uAe(e,{rangeId:ip(),rangeType:Rp.HYPERLINK,properties:{url:n},unitId:r,selections:i});return o?a.syncExecuteCommand(o.id,o.params):!1}},yst={id:`docs.command.update-hyper-link`,type:L.COMMAND,handler(e,t){if(!t)return!1;let{unitId:n,payload:r,segmentId:i,linkId:a}=t,o=e.get(R),s=e.get(z),c=e.get(nD).getActiveTextRange(),l=s.getUnit(n,M.UNIVER_DOC);if(!c||!l)return!1;let u=yv(l.getSelfOrHeaderFooterModel(i).getBody(),c.startOffset,c.endOffset).textRuns?.[0];u&&(u.ed=t.label.length+1);let d=uD(e,{unitId:n,body:{dataStream:`${t.label}`,customRanges:[{rangeId:a,rangeType:Rp.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:r}}],textRuns:u?[u]:void 0},selection:{startOffset:c.startOffset,endOffset:c.endOffset,collapsed:!1,segmentId:i}});return d?o.syncExecuteCommand(d.id,d.params):!1}};function eG(e){return e.trim().length===0}function bst(e){return/^[a-zA-Z]+:\/\//.test(e)}function xst(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Sst(e){return bst(e)?e:xst(e)?`mailto://${e}`:`https://${e}`}var tG=()=>{let e=U(lG),t=U(nx),n=QD(e.editingLink$),r=U(R),i=U(z),a=U(nD),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),f=F.isLegalUrl(o),p=n?i.getUnit(n.unitId,M.UNIVER_DOC):i.getCurrentUnitOfType(M.UNIVER_DOC);(0,V.useEffect)(()=>{var e;let t=a.getActiveTextRange();if(!t)return;if(n){var r,i;let e=p==null||(r=p.getSelfOrHeaderFooterModel(n.segmentId))==null?void 0:r.getBody(),t=e==null||(i=e.customRanges)==null?void 0:i.find(e=>n?.linkId===e.rangeId&&e.startIndex===n.startIndex&&e.endIndex===n.endIndex);p&&t&&(s(t.properties?.url??``),l(Ey.transform.getPlainText(yv(e,t.startIndex,t.endIndex+1).dataStream)));return}let o=p==null||(e=p.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:e.getBody(),c=o?t:null,u=c&&Ey.customRange.getCustomRangesInterestsWithSelection(c,o?.customRanges??[])?.[0];if(p&&u){var d;s((u==null||(d=u.properties)==null?void 0:d.url)??``)}},[p,n,a,i]);let m=()=>{e.hideEditPopup()},h=()=>{if(d(!0),!f||!p)return;let t=Sst(o);if(!n)r.executeCommand(vst.id,{unitId:p.getUnitId(),payload:t});else{if(eG(c))return;r.executeCommand(yst.id,{unitId:p.getUnitId(),payload:t,linkId:n.linkId,label:c,segmentId:n.segmentId})}e.hideEditPopup()};if(p)return(0,H.jsxs)(`div`,{className:W(`univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900`,qA),children:[(0,H.jsxs)(`div`,{children:[n?(0,H.jsx)(cj,{label:t.t(`docs-hyper-link-ui.edit.label`),error:u&&eG(c)?t.t(`docs-hyper-link-ui.edit.labelError`):``,children:(0,H.jsx)(uj,{value:c,onChange:l,autoFocus:!0,onKeyDown:e=>{e.keyCode===aM.ENTER&&h()}})}):null,(0,H.jsx)(cj,{label:t.t(`docs-hyper-link-ui.edit.address`),error:u&&!f?t.t(`docs-hyper-link-ui.edit.addressError`):``,children:(0,H.jsx)(uj,{value:o,onChange:s,autoFocus:!0,onKeyDown:e=>{e.keyCode===aM.ENTER&&h()}})})]}),(0,H.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[(0,H.jsx)(HA,{onClick:m,children:t.t(`docs-hyper-link-ui.edit.cancel`)}),(0,H.jsx)(HA,{variant:`primary`,disabled:eG(o),onClick:h,children:t.t(`docs-hyper-link-ui.edit.confirm`)})]})]})};tG.componentKey=`docs-hyper-link-edit`;var Cst={type:L.COMMAND,id:`docs.command.delete-hyper-link`,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:r,segmentId:i}=t,a=e.get(R),o=dAe(e,{unitId:n,rangeId:r,segmentId:i});return o?await a.syncExecuteCommand(o.id,o.params):!1}},wst=e=>{let t=e.get(nD),n=e.get(z),r=t.getTextRanges();if(!r?.length)return!0;let i=r[0];return!(n.getCurrentUnitOfType(M.UNIVER_DOC)&&i&&!i.collapsed)},nG={type:L.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){let n=t?.link,r=e.get(z);if(wst(e)&&!n)return!1;let i=e.get(lG),a=n?.unitId||r.getCurrentUnitOfType(M.UNIVER_DOC)?.getUnitId();return a?(i.showEditPopup(a,n),!0):!1}},rG={type:L.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(lG);return t?(n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},Tst={type:L.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,t){var n;if(!t)return!1;let{unitId:r,linkId:i,segmentId:a}=t,o=e.get(z).getUnit(r,M.UNIVER_DOC)?.getSelfOrHeaderFooterModel(a).getBody(),s=o==null||(n=o.customRanges)==null||(n=n.find(e=>e.rangeId===i&&e.rangeType===Rp.HYPERLINK))==null||(n=n.properties)==null?void 0:n.url;return ep(s)?(window.open(s,`_blank`,`noopener noreferrer`),!0):!1}},iG=()=>{var e;let t=U(lG),n=U(R),r=U(eM),i=U(nx),a=QD(t.showingLink$),o=U(z);if(!a)return null;let{unitId:s,linkId:c,segmentId:l,startIndex:u,endIndex:d}=a,f=o.getUnit(s,M.UNIVER_DOC)?.getSelfOrHeaderFooterModel(l).getBody(),p=f==null||(e=f.customRanges)==null?void 0:e.find(e=>e.rangeId===c&&e.rangeType===Rp.HYPERLINK&&e.startIndex===u&&e.endIndex===d);if(!p)return null;let m=p.properties?.url;return(0,H.jsxs)(`div`,{className:W(`univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow dark:!univer-bg-gray-900`,qA),onClick:()=>{t.hideInfoPopup()},children:[(0,H.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500`,onClick:()=>window.open(m,void 0,`noopener noreferrer`),children:[(0,H.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white`,children:(0,H.jsx)(PD,{})}),(0,H.jsx)(fj,{showIfEllipsis:!0,title:m,children:(0,H.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:m})})]}),(0,H.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[(0,H.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{navigator.clipboard.writeText(m),r.show({content:i.t(`docs-hyper-link-ui.info.coped`),type:pj.Info})},children:(0,H.jsx)(fj,{placement:`bottom`,title:i.t(`docs-hyper-link-ui.info.copy`),children:(0,H.jsx)(vD,{})})}),(0,H.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{n.executeCommand(nG.id,{link:a})},children:(0,H.jsx)(fj,{placement:`bottom`,title:i.t(`docs-hyper-link-ui.info.edit`),children:(0,H.jsx)(KD,{})})}),(0,H.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{n.executeCommand(Cst.id,{unitId:s,linkId:p.rangeId,segmentId:l})},children:(0,H.jsx)(fj,{placement:`bottom`,title:i.t(`docs-hyper-link-ui.info.cancel`),children:(0,H.jsx)(WD,{})})})]})]})};iG.componentKey=`univer.doc.link-info-popup`;function aG(e){"@babel/helpers - typeof";return aG=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},aG(e)}function Est(e,t){if(aG(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(aG(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Dst(e){var t=Est(e,`string`);return aG(t)==`symbol`?t:t+``}function oG(e,t,n){return(t=Dst(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sG(e,t){return function(n,r){t(n,r,e)}}function cG(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var lG=class extends P{constructor(e,t,n){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,oG(this,`_editingLink$`,new so(null)),oG(this,`_showingLink$`,new so(null)),oG(this,`editingLink$`,this._editingLink$.asObservable()),oG(this,`showingLink$`,this._showingLink$.asObservable()),oG(this,`_editPopup`,null),oG(this,`_infoPopup`,null),this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);let n=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),r=n?.[n.length-1];if(t){let{segmentId:e,segmentPage:n,startIndex:i,endIndex:a}=t;r={collapsed:!1,startOffset:i,endOffset:a+1,segmentId:e,segmentPage:n},this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:a+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:tG.componentKey,direction:`bottom`},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){let{linkId:t,unitId:n,segmentId:r,segmentPage:i,startIndex:a,endIndex:o}=e;if((this.showing?.linkId!==t||this.showing?.unitId!==n||this.showing?.segmentId!==r||this.showing?.segmentPage!==i||this.showing?.startIndex!==a||this.showing?.endIndex!==o)&&(this._infoPopup&&this._infoPopup.dispose(),this._univerInstanceService.getUnit(n,M.UNIVER_DOC)))return this._showingLink$.next({unitId:n,linkId:t,segmentId:r,segmentPage:i,startIndex:a,endIndex:o}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:a,endOffset:o+1,segmentId:r,segmentPage:i},{componentKey:iG.componentKey,direction:`top-center`,multipleDirection:`top`,onClickOutside:()=>{this.hideInfoPopup()}},n),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};lG=cG([sG(0,j(YI)),sG(1,j(nD)),sG(2,z)],lG);var uG=class extends P{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===ZE.id){let{unitId:n,ranges:r,segmentId:i}=e.params,a=this._univerInstanceService.getUnit(n,M.UNIVER_DOC),o=r[0];if(o&&a){var t;let{startOffset:e,endOffset:r,collapsed:s,segmentPage:c}=o,l=(t=a.getSelfOrHeaderFooterModel(i))==null||(t=t.getBody())==null?void 0:t.customRanges;if(s){let t=l?.findIndex(t=>t.startIndex<e&&t.endIndex>r-1)??-1;if(t>-1){let e=l[t];this._docHyperLinkService.showInfoPopup({unitId:n,linkId:e.rangeId,segmentId:i,segmentPage:c,startIndex:e.startIndex,endIndex:e.endIndex});return}}else if(l?.find(t=>t.startIndex<=e&&t.endIndex>=r-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};uG=cG([sG(0,R),sG(1,z),sG(2,j(lG))],uG);var dG=class extends P{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,r,i,a){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=r,this._docSkeletonManagerService=i,this._docSelectionManagerService=a,this._context.unitId!==rf&&this._context.unitId!==tf&&(this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(rG.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===Rp.HYPERLINK),r=this._docSelectionManagerService.getTextRanges(),i=r==null||(t=r[0])==null?void 0:t.segmentId;if((n?.segmentId??``)!==i){this._hideInfoPopup();return}n?this._commandService.executeCommand(rG.id,{unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,rangeId:n.range.rangeId,startIndex:n.range.startIndex,endIndex:n.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t&&this._commandService.executeCommand(Tst.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}))}};dG=cG([sG(1,j(ZI)),sG(2,R),sG(3,j(lG)),sG(4,j(rD)),sG(5,j(nD))],dG);var fG=class extends P{constructor(e,t,n,r){super(),this._context=e,this._docInterceptorService=t,this._hyperLinkService=n,this._docRenderController=r,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(cD.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(Ys((e,t)=>e?.linkId===t?.linkId&&e?.unitId===t?.unitId&&e?.startIndex===t?.startIndex),ec()).subscribe(([e,t])=>{t?t.unitId===this._context.unitId&&this._docRenderController.reRender(t.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)}))}};fG=cG([sG(1,j(lD)),sG(2,j(lG)),sG(3,j(uL))],fG);var Ost=`doc-hyper-link-icon`;function pG(e){return{id:nG.id,type:bM.BUTTON,icon:Ost,title:`docs-hyper-link-ui.menu.tooltip`,tooltip:`docs-hyper-link-ui.menu.tooltip`,hidden$:Pj(e,M.UNIVER_DOC),disabled$:new Ya(function(t){let n=e.get(nD).textSelection$.pipe(Ks(16)).subscribe(()=>{t.next(wst(e))});return()=>{n.unsubscribe()}})}}var kst={id:nG.id,binding:oM.CTRL_COMMAND|aM.K,description:`docs-hyper-link-ui.menu.tooltip`,preconditions:iL},Ast={[pM.MEDIA]:{[nG.id]:{order:1,menuItemFactory:pG}},[hM.MAIN_AREA]:{[gM.DATA]:{[nG.id]:{order:0,menuItemFactory:pG}}},[hM.PARAGRAPH]:{[gM.LAYOUT]:{[GI]:{[nG.id]:{order:6,menuItemFactory:pG}}},[BI]:{[gM.LAYOUT]:{[nG.id]:{order:6,menuItemFactory:pG}}}}},mG=class extends P{constructor(e,t,n,r){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[tG.componentKey,tG],[iG.componentKey,iG],[Ost,PD]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initCommands(){[vst,yst,Cst,nG,rG,Tst].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[kst].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.mergeMenu(Ast)}};mG=cG([sG(0,j(Nj)),sG(1,R),sG(2,_M),sG(3,cM)],mG);var jst=`DOC_HYPER_LINK_UI_PLUGIN`,hG=class extends dx{constructor(e=_st,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=r;let{menu:i,...a}=Qi({},_st,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(gst,a)}onStarting(){[[lG],[mG],[uG]].forEach(e=>{this._injector.add(e)}),this._injector.get(mG)}onReady(){this._injector.get(uG)}onRendered(){this._initRenderModule()}_initRenderModule(){[[fG],[dG]].forEach(e=>{this._renderManagerSrv.registerRenderModule(M.UNIVER_DOC,e)})}};oG(hG,`pluginName`,jst),oG(hG,`packageName`,mst),oG(hG,`version`,hst),oG(hG,`type`,M.UNIVER_DOC),hG=cG([px($W),sG(1,j(We)),sG(2,KE),sG(3,Nm)],hG);function Mst(){return{plugins:[$W,hG].filter(e=>!!e)}}var Nst=Rg({"docs-hyper-link-ui":{edit:{confirm:`确认`,cancel:`取消`,title:`链接`,address:`链接`,label:`文本`,labelError:`请输入链接文本`,placeholder:`请输入合法的链接`,addressError:`请输入合法的链接`},info:{copy:`复制`,edit:`编辑`,cancel:`取消链接`,coped:`链接已被复制到剪贴板`},menu:{tooltip:`添加链接`}}}),Pst=new Set([`line-height`,`margin-top`,`margin-bottom`,`font-size`,`mso-line-height-rule`]),Fst=/<style[^>]*>([\s\S]*?)<\/style>/gi,Ist=/([^{}]+)\{([^{}]*)\}/g;function Lst(e){let t=new Map;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&i&&t.set(r,i)}return t}function Rst(e){let t=``;for(let[n,r]of e)t+=`${n}:${r};`;return t}function zst(e){let t=new Map;for(let n of e.matchAll(Fst)){let e=n[1];for(let n of e.matchAll(Ist)){let e=n[1].split(`,`).map(e=>e.trim()).filter(Boolean),r=new Map;for(let e of n[2].split(`;`)){let t=e.indexOf(`:`);if(t<=0)continue;let n=e.slice(0,t).trim().toLowerCase(),i=e.slice(t+1).trim();n&&i&&Pst.has(n)&&r.set(n,i)}if(r.size)for(let n of e){let e=n.match(/\.([A-Za-z0-9_-]+)/);if(!e)continue;let i=t.get(e[1])||{};for(let[e,t]of r)i[e]=t;t.set(e[1],i)}}}return t}function Bst(e,t){let n=e.trim().toLowerCase().match(/^([0-9]*\.?[0-9]+)(pt|px)$/);if(n){if(!t)return e;let r=parseFloat(n[1]),i=parseFloat(t);return!Number.isFinite(r)||!Number.isFinite(i)||i<=0?e:`${Math.round(r/i*100)}%`}return e}function Vst(e){if(typeof e!=`string`||!e||!/<style[^>]*>/i.test(e)||!/line-height/i.test(e))return e;let t=zst(e);return t.size?e.replace(/<(p|li|h[1-6])\b[^>]*>/gi,e=>{let n=e.match(/\bclass\s*=\s*"([^"]*)"/i);if(!n)return e;let r=n[1].trim().split(/\s+/).filter(Boolean),i=new Map;for(let e of r){let n=t.get(e);if(n)for(let[e,t]of Object.entries(n))i.set(e,t)}if(!i.size)return e;let a=e.match(/\bstyle\s*=\s*"([^"]*)"/i),o=a?Lst(a[1]):new Map,s=!1;for(let[e,t]of i)o.has(e)||(o.set(e,t),s=!0);if(!s&&!o.has(`line-height`))return e;let c=o.get(`line-height`),l=o.get(`mso-line-height-rule`);if(c&&/pt|px/i.test(c.trim())&&!l){let e=o.get(`font-size`);o.set(`line-height`,Bst(c,e?e.trim():null))}let u=Rst(o);return a?e.replace(/\bstyle\s*=\s*"[^"]*"/i,`style="${u}"`):e.replace(/>\s*$/,` style="${u}">`)}):e}var Hst=/(?:^|[;\s"'])(?:page-)?break-before\s*:\s*(?:always|page)\b(?![-\w])/i,Ust=/(?:^|[;\s"'])(?:page-)?break-after\s*:\s*(?:always|page)\b(?![-\w])/i,Wst=/break-(?:before|after)/i;function Gst(e){return e.replace(/<[^>]*>/g,``).replace(/ | | /gi,` `).trim().length>0}function Kst(e,t){let n=typeof e==`string`?e:``;if(Hst.test(n))return`before`;if(Ust.test(n))return`after`;let r=typeof t==`string`?t:``;if(!r||!Wst.test(r))return null;let i=/<[a-z][^>]*>/gi,a;for(;a=i.exec(r);){let e=a[0];if(!Wst.test(e))continue;let t=Hst.test(e),n=Ust.test(e);if(!t&&!n)continue;let i=t?a.index:a.index+e.length;return Gst(r.slice(0,i))?`after`:`before`}return null}function qst(e,t){let n=e&&e.tables;if(!Array.isArray(n))return!1;for(let e of n){if(!e||typeof e.startIndex!=`number`)continue;let n=typeof e.endIndex==`number`?e.endIndex:e.startIndex;if(t>=e.startIndex&&t<n)return!0}return!1}function gG(e,t,n=!1){if(Array.isArray(e))for(let r of e)r&&typeof r==`object`&&(typeof r.startIndex==`number`&&t<=r.startIndex&&(r.startIndex+=1),typeof r.st==`number`&&t<=r.st&&(r.st+=1),typeof r.endIndex==`number`&&(n?t<r.endIndex:t<=r.endIndex)&&(r.endIndex+=1),typeof r.ed==`number`&&t<r.ed&&(r.ed+=1))}function Jst(e,t){gG(e.paragraphs,t),gG(e.textRuns,t),gG(e.sectionBreaks,t),gG(e.customBlocks,t),gG(e.customRanges,t),gG(e.blockRanges,t),gG(e.tables,t,!0)}function Yst(e,t){if(!e||typeof e.dataStream!=`string`)return!1;let n=e.dataStream;return!Number.isInteger(t)||t<0||t>=n.length||t>0&&n[t-1]===`\f`||qst(e,t)?!1:(e.dataStream=n.slice(0,t)+`\f`+n.slice(t),Jst(e,t),!0)}function Xst(e,t){try{let n=e&&e.body;if(!n||typeof n.dataStream!=`string`||!t||typeof t.closest==`function`&&t.closest(`table`))return!1;let r=Kst(typeof t.getAttribute==`function`?t.getAttribute(`style`):``,t.innerHTML);if(!r)return!1;let i=n.dataStream;if(r===`after`)return i[i.length-1]===`\r`&&Yst(n,i.length-1);let a=i.lastIndexOf(`\r`,i.length-2);return a<=0?!1:Yst(n,a)}catch{return!1}}function Zst(e){let t=[],n=e&&typeof e.getChildren==`function`&&e.getChildren()||[];for(let e of n){let n=e&&e.children;if(Array.isArray(n))for(let e=0;e<n.length-1;e++){let r=n[e];if(!r||typeof r.content!=`string`||!/\f\r?$/.test(r.content))continue;let i=n[e+1];i&&typeof i.endIndex==`number`&&t.push(i.endIndex)}}return t}function Qst(e){let t=e&&e.prototype,n=t&&t._prepareLayoutContext;if(typeof n!=`function`||n.__pageBreakLayoutFixed)return!1;let r=function(...e){let t=n.apply(this,e);try{let e=Zst(typeof this.getViewModel==`function`?this.getViewModel():null);if(e.length&&t&&t.paragraphsOpenNewPage instanceof Set)for(let n of e)t.paragraphsOpenNewPage.add(n)}catch{}return t};return r.__pageBreakLayoutFixed=!0,t._prepareLayoutContext=r,!0}var $st=12e4,ect=65536,tct=5e3,nct=8192,rct=1500,ict=4e3,act=16384,oct=100,sct=512e3,cct=150,lct=class{docKey;docType;snapshotInterval;mutationFlushSize;cloudSync;incrementalMode;editorRef=null;revision=0;lastSnapshotRevision=0;lastPersistedRevision=0;pendingMutations=[];pendingBytes=0;snapshotTimer=null;disposed=!1;saving=!1;writeQueue=null;saveError=null;autoSaving=!1;onAutoSaveError=null;retryTimer=null;restoring=!1;restoreError=null;restorePromise=null;restored=!1;needsInitialSnapshot=!1;debounceTimer=null;lastFlushTime=0;mutationsSinceSnapshot=0;bytesSinceSnapshot=0;lastSnapshotTime=0;commandEventDisposable=null;pagehideHandler=null;constructor(e){this.docKey=e.docKey,this.docType=e.docType,this.snapshotInterval=e.snapshotInterval??$st,this.mutationFlushSize=e.mutationFlushSize??ect,this.cloudSync=e.cloudSync,this.incrementalMode=e.enableIncremental??!0}async attach(e){if(this.disposed)return;this.editorRef=e;let t=Date.now()+3e3;for(;Date.now()<t&&!(typeof e.ready==`function`?e.ready():e.getData()!=null);)await new Promise(e=>setTimeout(e,100));this.disposed||(this.revision=e.getVersion(),typeof e.onMutation==`function`&&(this.commandEventDisposable=e.onMutation(e=>{this.handleCommandEvent(e)}),console.log(`[EditorPersistence] 已接入 onMutation 增量事件`)),this.lastSnapshotTime=Date.now(),this.snapshotTimer=setInterval(()=>{this.takeSnapshotIfNeeded().catch(()=>void 0)},Math.min(this.snapshotInterval,3e4)),this.pagehideHandler=()=>{this.takeSnapshotSync()},window.addEventListener(`pagehide`,this.pagehideHandler),await this.restore())}dispose(){this.disposed||(this.disposed=!0,this.snapshotTimer&&=(clearInterval(this.snapshotTimer),null),this.debounceTimer&&=(clearTimeout(this.debounceTimer),null),this.retryTimer&&=(clearTimeout(this.retryTimer),null),this.commandEventDisposable?.(),this.commandEventDisposable=null,this.pagehideHandler&&=(window.removeEventListener(`pagehide`,this.pagehideHandler),null),this.editorRef=null)}handleCommandEvent(e){if(!e||!e.id||this.restoring||this.restoreError||this.disposed||this.editorRef?.canPersist?.()===!1)return;let t={commandId:e.id,params:dct(e.params??{}),timestamp:e.timestamp??Date.now()};if(this.revision++,!this.incrementalMode)return;this.pendingMutations.push(t),this.autoSaving=!0;let n=256;try{n=JSON.stringify(t.params).length*2}catch{}if(t._bytes=n,this.pendingBytes+=n,this.mutationsSinceSnapshot++,this.bytesSinceSnapshot+=n,n>=act){this.flushMutations().catch(()=>void 0);return}if(this.pendingBytes>=this.mutationFlushSize){this.flushMutations().catch(()=>void 0);return}this.resetDebounceTimer()}resetDebounceTimer(){this.debounceTimer&&clearTimeout(this.debounceTimer);let e=Date.now()-this.lastFlushTime;if(e>=ict){this.flushMutations().catch(()=>void 0);return}let t=Math.min(rct,ict-e);this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.flushMutations().catch(()=>void 0)},t)}enqueueWrite(e){let t=this.writeQueue?this.writeQueue.then(e):e(),n=t.catch(()=>void 0).finally(()=>{this.writeQueue===n&&(this.writeQueue=null)});return this.writeQueue=n,t}flushPendingMutations(){return this.flushMutations()}flushMutations(){return this.enqueueWrite(()=>this.flushMutationsNow())}async flushMutationsNow(){if(this.restoreError)throw this.restoreError;if(!this.pendingMutations.length||this.saving||this.restoring||this.restoreError||this.disposed||this.editorRef?.canPersist?.()===!1)return;if(!this.cloudSync){this.pendingMutations.length=0,this.pendingBytes=0;return}if(this.pendingMutations.length>cct)try{await this.saveSnapshotNow(),this.mutationsSinceSnapshot=0,this.bytesSinceSnapshot=0;return}catch{}let e=this.pendingMutations.splice(0);this.pendingBytes=0,this.saving=!0,this.lastFlushTime=Date.now();let t=this.compactMutations(e),n=this.revision;try{if(this.needsInitialSnapshot){let e=this.editorRef.getData();if(!e)throw Error(`无法读取初始工作簿`);await this.cloudSync.saveSnapshot({docKey:this.docKey,docType:this.docType,revision:n,data:e}),this.needsInitialSnapshot=!1,this.lastSnapshotRevision=n}else await this.cloudSync.saveMutations({docKey:this.docKey,mutations:t.map(e=>({revision:e._rev??this.revision,commandId:e.commandId,params:e.params,timestamp:e.timestamp}))});this.lastPersistedRevision=n,this.saveError=null,this.autoSaving=!1}catch(t){if(t&&typeof t==`object`&&`needsSnapshot`in t&&t.needsSnapshot===!0)try{await this.saveSnapshotNow();return}catch(e){t=e}this.pendingMutations.unshift(...e),this.pendingBytes+=e.reduce((e,t)=>e+(t._bytes??256),0),this.saveError=t instanceof Error?t:Error(`增量保存失败`),console.warn(`[EditorPersistence] 增量云端同步失败,将在下次重试`,t),this.scheduleRetry();try{this.onAutoSaveError?.(this.saveError)}catch{}throw this.autoSaving=!1,this.saveError}finally{this.saving=!1}}compactMutations(e){let t=this.revision-e.length;return e.map((e,n)=>({...e,_rev:t+n+1}))}scheduleRetry(){this.retryTimer||this.disposed||(this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.pendingMutations.length&&!this.disposed&&this.flushMutations().catch(()=>void 0)},tct))}async takeSnapshotIfNeeded(){if(!this.editorRef||this.saving||this.restoring||this.restoreError||this.disposed||this.editorRef.canPersist?.()===!1||!this.editorRef.isDirty()&&this.revision===this.lastSnapshotRevision)return;let e=Date.now()-this.lastSnapshotTime,t=this.mutationsSinceSnapshot>=oct,n=this.bytesSinceSnapshot>=sct,r=e>=this.snapshotInterval;(t||n||r)&&(await this.takeSnapshot(),this.mutationsSinceSnapshot=0,this.bytesSinceSnapshot=0,this.lastSnapshotTime=Date.now())}takeSnapshot(){return this.enqueueWrite(async()=>{if(this.restoreError)throw this.restoreError;if(!this.editorRef||this.restoring||this.disposed)throw Error(`编辑器尚未就绪`);this.editorRef.canPersist?.()!==!1&&(this.incrementalMode&&await this.flushMutationsNow(),await this.saveSnapshotNow())})}async saveSnapshotNow(){if(!this.editorRef||this.disposed)throw Error(`编辑器已关闭`);let e=this.editorRef.getData();if(!e)throw Error(`无法读取文档内容`);let t=e,n=this.revision,r=this.pendingMutations.length;this.saving=!0;try{if(this.cloudSync){let e=JSON.stringify(t),i=t,a=!1;if(e.length>nct&&typeof CompressionStream<`u`)try{i=fct(await uct(e)),a=!0}catch{i=t}await this.cloudSync.saveSnapshot({docKey:this.docKey,docType:this.docType,revision:n,data:i,compressed:a}),this.lastPersistedRevision=n,this.lastSnapshotRevision=n,this.needsInitialSnapshot=!1,this.pendingMutations.splice(0,r),this.pendingBytes=this.pendingMutations.reduce((e,t)=>e+(t._bytes??256),0),this.saveError=null}}catch(e){this.saveError=e instanceof Error?e:Error(`快照保存失败`),console.warn(`[EditorPersistence] 快照持久化失败`,e);try{this.onAutoSaveError?.(this.saveError)}catch{}throw this.saveError}finally{this.saving=!1}}takeSnapshotSync(){if(!this.editorRef||this.restoring||this.restoreError||this.disposed||this.editorRef.canPersist?.()===!1)return;let e=this.editorRef.getData();if(!e)return;let t=this.docType===`excel`?this.revision:this.editorRef.getVersion();if(this.cloudSync){let n=this.cloudSync.getBeaconUrl?.();if(n)try{let r=JSON.stringify({docKey:this.docKey,docType:this.docType,revision:t,data:e,timestamp:Date.now()});navigator.sendBeacon(n,r)}catch{}}}restore(e=!1){return this.restorePromise?this.restorePromise:this.restored&&!this.restoreError&&!e?Promise.resolve(this.revision):!this.editorRef||this.disposed?Promise.reject(Error(`编辑器未就绪`)):this.saving||this.pendingMutations.length||this.restored&&this.hasUnsavedChanges()?Promise.reject(Error(`请先保存本地修改`)):(this.restorePromise=this.restoreDocument().finally(()=>{this.restorePromise=null}),this.restorePromise)}async restoreDocument(){let e=this.editorRef,t=!this.restored;this.restoring=!0,this.restoreError=null,e.setRestoreState?.(!0,``);let n=e.getVersion(),r,i=!1;try{if(!this.cloudSync)return this.revision;let a=await this.cloudSync.restore(this.docKey,this.docType);if(this.disposed||this.editorRef!==e)throw Error(`编辑器已关闭`);if(!t&&e.getVersion()!==n)throw Error(`加载期间内容已变更,请保存后重试`);let o=a?.snapshot,s=[...a?.mutations??[]].sort((e,t)=>e.revision-t.revision);if(o?.data){if(!Number.isSafeInteger(o.revision)||o.revision<0)throw Error(`快照版本无效`);let t=s.filter(e=>e.revision>o.revision).filter(e=>!(this.docType===`excel`&&e.commandId.startsWith(`doc.mutation.`)||this.docType===`doc`&&e.commandId.startsWith(`sheet.mutation.`))),n=o.revision;for(let e of s){if(!Number.isSafeInteger(e.revision)||e.revision<0)throw Error(`增量版本无效`);if(e.revision!==n+1)throw Error(`增量版本不连续,无法安全恢复`);if(!/^[\w-]+\.mutation\.[\w.-]+$/.test(e.commandId)||!e.params||typeof e.params!=`object`)throw Error(`增量记录无效`);n=e.revision}if(a?.revision!=null&&a.revision!==n)throw Error(`恢复尾部不完整,不能确认服务器版本`);let c=e.getUniverAPI?.();if(t.length&&(!c?.syncExecuteCommand||!c.addEvent||!c.Event?.BeforeCommandExecute))throw Error(`编辑器不支持安全增量回放`);let l=o.data;for(let e=0;e<2&&typeof l==`string`;e++)l=JSON.parse(l);if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`快照格式无效,无法安全恢复`);if(r=e.getData(),i=!0,!e.setData(l))throw Error(`快照恢复失败`);for(let n of t){if(this.docType===`excel`&&n.commandId.startsWith(`doc.mutation.`)||this.docType===`doc`&&n.commandId.startsWith(`sheet.mutation.`))continue;let t=c.addEvent(c.Event.BeforeCommandExecute,e=>{e.id===n.commandId&&e.type!==2&&(e.cancel=!0)});try{let t=dct(n.params);(e.replayMutation?e.replayMutation(n.commandId,t):c.syncExecuteCommand(n.commandId,t,{onlyLocal:!0,fromChangeset:!0}))!==!0&&console.warn(`[EditorPersistenceManager] 增量回放跳过(不兼容):${n.commandId}`)}catch(e){console.warn(`[EditorPersistenceManager] 增量回放异常跳过:${n.commandId}`,e)}finally{t.dispose()}}this.needsInitialSnapshot=!1,this.lastSnapshotRevision=o.revision,this.revision=n}else{if(s.length||a?.revision!=null&&a.revision!==0)throw Error(`缺少基础快照,无法安全恢复增量`);if(this.needsInitialSnapshot=!0,e.canPersist?.()!==!1){let t=e.getData();if(!t)throw Error(`无法读取初始工作簿`);await this.cloudSync.saveSnapshot({docKey:this.docKey,docType:this.docType,revision:this.revision,data:t}),this.needsInitialSnapshot=!1,this.lastSnapshotRevision=this.revision}}return e.getData(),this.lastPersistedRevision=this.revision,this.lastFlushTime=Date.now(),this.restored=!0,this.revision}catch(t){if(this.restoreError=t instanceof Error?t:Error(`恢复失败`),i&&r&&!this.disposed)try{e.setData(r)}catch{}throw this.restoreError}finally{this.restoring=!1,this.disposed||e.setRestoreState?.(!!this.restoreError,this.restoreError?.message||``)}}getRevision(){return this.revision}getDocKey(){return this.docKey}hasUnsavedChanges(){return this.saving||this.saveError!=null||this.pendingMutations.length>0||this.revision>this.lastPersistedRevision}getSaveError(){return this.restoreError??this.saveError}getLastPersistedRevision(){return this.lastPersistedRevision}async clearLocalPersistence(){this.lastSnapshotRevision=0}async flush(){await this.takeSnapshot()}};async function uct(e){let t=new TextEncoder().encode(e),n=new CompressionStream(`gzip`),r=n.writable.getWriter(),i=n.readable.getReader();r.write(t),r.close();let a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.byteLength}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.byteLength;return s.buffer}function dct(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function fct(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.byteLength;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function _G(e){let{editorRef:n,docKey:r,docType:i,cloudSync:a,snapshotInterval:o,mutationFlushSize:s,enableIncremental:c=!0}=e,l=(0,t.ref)(`idle`),u=(0,t.ref)(null),d=(0,t.ref)(0),f=(0,t.shallowRef)(null),p=new lct({docKey:r,docType:i,cloudSync:a,snapshotInterval:o,mutationFlushSize:s,enableIncremental:c});f.value=p;let m=e.ready??n,h=null,g=null,_=!1;function v(){h||_||(h=setInterval(()=>{p.getSaveError()?l.value=`error`:p.hasUnsavedChanges()?l.value=`saving`:l.value===`saving`&&(l.value=`saved`,u.value=Date.now(),d.value=p.getRevision(),setTimeout(()=>{l.value===`saved`&&(l.value=`idle`)},2e3))},3e3))}function y(){return n.value?g??=p.attach(n.value):Promise.reject(Error(`编辑器未就绪`))}async function b(e={}){l.value=`saving`;try{await y().catch(()=>void 0);let t=await p.restore(e.force??!1);return d.value=t,l.value=`idle`,v(),t}catch(e){throw l.value=`error`,e}}(0,t.watch)(m,async e=>{if(e&&n.value)try{l.value=`saving`,await y(),d.value=p.getRevision(),l.value=`idle`,v()}catch(e){console.warn(`[useEditorPersistence] 初始化失败`,e),l.value=`error`}},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{_=!0,h&&clearInterval(h),p.dispose(),f.value=null});async function x(){l.value=`saving`;try{await p.takeSnapshot(),d.value=p.getRevision(),u.value=Date.now(),l.value=`saved`,setTimeout(()=>{l.value===`saved`&&(l.value=`idle`)},2e3)}catch(e){throw l.value=`error`,e}}async function S(){l.value=`saving`;try{await p.flush(),d.value=p.getRevision(),u.value=Date.now(),l.value=`saved`,setTimeout(()=>{l.value===`saved`&&(l.value=`idle`)},2e3)}catch(e){throw l.value=`error`,e}}async function C(){await p.clearLocalPersistence()}return{saveStatus:l,lastSavedAt:u,revision:d,manager:f,hasUnsavedChanges:()=>p.hasUnsavedChanges(),takeSnapshot:x,flush:S,clearPersistence:C,restore:b}}async function pct(e,t,n){if(!e)return e;try{let r=await n(t),i=typeof r==`string`?r:r?.url;return i?{...e,imageId:typeof r==`object`&&r?.imageId||e.imageId,imageSourceType:cb.URL,source:i}:e}catch{return e}}function mct(e){return class extends _Ye{async saveImage(t){return pct(await super.saveImage(t),t,e)}}}function hct(e,t){if(!e||typeof e.saveImage!=`function`||e.__hxyUploadPatched)return!1;let n=e.saveImage.bind(e);return e.saveImage=async e=>pct(await n(e),e,t),e.__hxyUploadPatched=!0,!0}var gct=25,_ct=200;function vG(e){let t=e?.server;if(!t||!t.imageUpload&&!t.resolveImage)return null;let n=e?.univer?.__getInjector?.();if(!n)return null;let r=null,i=0,a=!t.imageUpload,o=!t.resolveImage,s=null,c=()=>{r&&=(clearTimeout(r),null)},l=e=>typeof n.has!=`function`||n.has(e),u=()=>{if(a&&o)return c();if(i+=1,!a)try{l(ub)&&(n.replace([ub,{useClass:mct(t.imageUpload)}]),a=!0)}catch{try{hct(n.get(ub),t.imageUpload)&&(a=!0)}catch{}}if(!o)try{if(l(db)){let e=n.get(db);typeof e?.registerURLImageDownloader==`function`&&(s=e.registerURLImageDownloader(async e=>{try{return await t.resolveImage(e)||e}catch{return e}}),o=!0)}}catch{}if(a&&o)return c();if(i>=_ct){c();return}r=setTimeout(u,gct)};return u(),{dispose(){c(),s?.dispose?.(),s=null}}}var vct=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},yct={class:`doc-shell`},bct={class:`doc-layout`},xct={class:`doc-canvas`},Sct={key:0,class:`readonly-badge`,role:`status`},Cct=[`disabled`],wct={key:3,class:`attachment-error-tip`},Tct={class:`link-dialog`},Ect={class:`link-dialog-field`},Dct={class:`link-dialog-field`},Oct={key:0,class:`field-error`},kct={class:`link-dialog-tip`},Act={class:`link-dialog-actions`},jct=[`disabled`],Mct={key:0,class:`hover-icon-tip`},Nct={class:`hover-style`},Pct={key:0,class:`hover-style-menu`},Fct=[`onClick`],Ict={class:`style-check`},Lct={class:`style-name`},Rct=`univer-sheet://`,yG=`🔗 `,zct=`#e4f9fbff`,Bct=6,Vct=9,Hct=6,bG=2,Uct=`.pdf,.doc,.docx,.zip,.rar,.7z,.mp4,.mov,.webm,.avi,.mkv,.mp3,.wav,.m4a,.aac`,Wct=157286400,Gct=2097152,Kct=vct({__name:`DocEditor`,props:{visible:{type:Boolean,default:!0},type:{type:String,default:`edit`,validator:e=>[`view`,`edit`].includes(e)},server:{type:Object,default:null},collaboration:{type:Object,default:null}},emits:[`open-workbook`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(!!i.server?.cloudSync),s=(0,t.ref)(``),c=(0,t.computed)(()=>i.type===`view`||o.value),l=null;function u(e,t){o.value=e,s.value=t,vt()}async function d(){try{await v?.restore()}catch{}}let f=`demo-doc-01`;try{let e=ZI.prototype,t=e._buildCustomRangeBoundsBySegment;if(typeof t==`function`&&!t.__hoverSegmentFixed){let n=function(e,n=-1){return t.call(this,e??``,n)};n.__hoverSegmentFixed=!0,e._buildCustomRangeBoundsBySegment=n,console.log(`[hover-patch] prototype._buildCustomRangeBoundsBySegment patched ✓`)}else typeof t!=`function`&&console.warn(`[hover-patch] _buildCustomRangeBoundsBySegment not found on prototype — engine API changed?`);let n=XF.prototype,r=n._addTextRange;if(typeof r==`function`&&!r.__singleCaretFixed){let e=function(e){r.call(this,e);let t=0;for(let e of this._rangeList)e.collapsed&&t++;t<=1||(this._rangeList=this._rangeList.filter(t=>t===e||!t.collapsed||(t.dispose(),!1)))};e.__singleCaretFixed=!0,n._addTextRange=e}try{let e=wP,t=e?.preprocessHtml;typeof t==`function`&&!e.__lineSpacingNormalized&&(e.preprocessHtml=function(e){return t.call(this,Vst(e))},e.__lineSpacingNormalized=!0)}catch{}try{let e=wP,t=e?.afterProcessRules,n=t?.[0]?.handler;typeof n==`function`&&!e.__exactLineSpacingFixed&&(e.afterProcessRules=[{...t[0],handler(e,t){n.call(this,e,t),Xst(e,t);try{let n=t?.getAttribute?.(`style`)??``,r=n.match(/mso-line-height-rule\s*:\s*([a-z-]+)/i)?.[1]?.toLowerCase()??``;if(!r||r===`auto`)return;let i=n.match(/(?:^|;)\s*line-height\s*:\s*([0-9]*\.?[0-9]+)\s*(pt|px)?/i);if(!i)return;let a=e?.body?.paragraphs,o=a?.[a.length-1];if(!o)return;let s=parseFloat(i[1]);if((i[2]||``).toLowerCase()===`pt`&&(s/=.75),!Number.isFinite(s)||s<=0)return;o.paragraphStyle=o.paragraphStyle||{},o.paragraphStyle.spacingRule=r===`exactly`?2:1,o.paragraphStyle.lineSpacing=s}catch{}}}],e.__exactLineSpacingFixed=!0)}catch{}try{Qst(gE)&&console.log(`[pagebreak-patch] DocumentSkeleton._prepareLayoutContext patched ✓`)}catch{}}catch{}let p=(0,t.ref)(null),m=(0,t.shallowRef)(null),h=(0,t.ref)(null),g=null,_=(0,t.shallowRef)(null),v=i.server?.cloudSync?_G({editorRef:_,docKey:i.server.docKey||`doc:default`,docType:`doc`,cloudSync:i.server.cloudSync,snapshotInterval:i.server.snapshotInterval,mutationFlushSize:i.server.mutationFlushSize,enableIncremental:i.server.enableIncremental}):null,y=(0,t.ref)([]);(0,t.ref)(``);let b=(0,t.reactive)({words:0,paragraphs:0}),x=(0,t.reactive)({visible:!1,text:``,url:``,urlError:``,style:`text`,startOffset:0,endOffset:0,segmentId:``,replace:!1}),S=null,C=[{value:`text`,label:`文字链`},{value:`icon`,label:`图标+文字链`},{value:`card`,label:`卡片`}],w=(0,t.reactive)({visible:!1,url:``,text:``,style:`text`,linkId:``,segmentId:``,startIndex:0,endIndex:0,styleMenuOpen:!1,copied:!1,isAttachment:!1,fileName:``,fileSize:0,x:null,y:null}),T=null,E=null,D=null,O=!1,k=null,A=[],ee=null,te=!1,ne=!1;function re(e,t,n,r,i,a,o,s){if(!o&&!s){e.fillRect(t,n,r,i);return}let c=Math.max(0,Math.min(a,i/2,o&&s?r/2:r));e.beginPath(),e.moveTo(t+(o?c:0),n),e.arcTo(t+r,n,t+r,n+i,s?c:0),e.arcTo(t+r,n+i,t,n+i,s?c:0),e.arcTo(t,n+i,t,n,o?c:0),e.arcTo(t,n,t+r,n,o?c:0),e.closePath(),e.fill()}let ie=null,ae=null,oe=null,se=null,ce=0,le=-1,ue=[];function de(e){return ue.push(e),()=>{let t=ue.indexOf(e);t>=0&&ue.splice(t,1)}}function fe(e){let t=e.trim();return t?/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)?t:/^[w.-]+@([w-]+.)+[w-]{2,4}$/.test(t)?`mailto:${t}`:`https://${t}`:``}function pe(e){try{let t=new URL(fe(e));return[`http:`,`https:`,`mailto:`,`univer-sheet:`].includes(t.protocol)}catch{return!1}}function me(){if(c.value)return;let e=S,n=``;e&&!e.collapsed&&(n=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream||``).slice(e.startOffset,e.endOffset).replace(/[\r\n]+$/,``)),x.text=n,x.url=``,x.urlError=``,x.style=`text`,x.replace=!(!e||e.collapsed);let r=m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream?.length??0;x.startOffset=e?e.startOffset:Math.max(0,r-2),x.endOffset=e?e.endOffset:x.startOffset,x.segmentId=e?.segmentId||``,x.visible=!0,(0,t.nextTick)(()=>{x.text||h.value?.focus()})}function he(){x.visible=!1}function ge(e,t){return t===`text`?e:`${yG}${e}`}function _e(e,t,n,r){if(t===`card`){let i=`──查看`,a=` 📄${e}${i} `,o=a.indexOf(`📄`),s=o+2,c=a.indexOf(i),l={bg:{rgb:`#e4f9fbff`},fs:18,cl:{rgb:`#3370ff`}};return{dataStream:a,customRanges:[{startIndex:0,endIndex:a.length-1,rangeId:n,rangeType:3,wholeEntity:!0,properties:{url:r,text:e,style:t}}],textRuns:[{st:0,ed:1,ts:{...l}},{st:1,ed:2,ts:{...l}},{st:2,ed:o+2,ts:{...l}},{st:s,ed:c,ts:{...l,bl:!0}},{st:c,ed:a.length-1,ts:{...l,bl:!0}},{st:a.length-1,ed:a.length,ts:{...l}}]}}let i=ge(e,t),a={startIndex:0,endIndex:i.length-1,rangeId:n,rangeType:0,properties:{url:r,text:e,style:t}},o={dataStream:i,customRanges:[a]};return t===`icon`&&(a.show=!1,o.textRuns=[{st:0,ed:i.length,ts:{cl:{rgb:`#3370ff`}}}]),o}async function ve({text:e,url:t,style:n,startOffset:r,endOffset:i,segmentId:a,replace:o}){let s=`link-${Date.now()}-${Math.floor(Math.random()*1e4)}`,c=_e(e,n,s,t);return await m.value?.executeCommand?.(`doc.command.insert-text`,{unitId:f,range:{startOffset:r,endOffset:i,collapsed:!o,segmentId:a},segmentId:a,body:c,cursorOffset:c.dataStream.length})?{rangeId:s,startIndex:r,endIndex:r+c.dataStream.length-1}:null}async function ye(){if(!x.url.trim()){x.urlError=`请输入链接地址`;return}if(!pe(x.url)){x.urlError=`链接格式不正确`;return}await ve({text:(x.text.trim()||x.url.trim()).replace(/[\r\n]+/g,` `),url:fe(x.url),style:x.style,startOffset:x.startOffset,endOffset:x.endOffset,segmentId:x.segmentId,replace:x.replace})?(he(),at()):x.urlError=`插入失败,请重试`}let be=Uct.split(`,`).map(e=>e.slice(1)),j={pdf:`📕`,doc:`📘`,docx:`📘`,zip:`📦`,rar:`📦`,"7z":`📦`,mp4:`🎬`,mov:`🎬`,webm:`🎬`,avi:`🎬`,mkv:`🎬`,mp3:`🎵`,wav:`🎵`,m4a:`🎵`,aac:`🎵`},xe=(0,t.ref)(null),Se=(0,t.ref)(!1),Ce=(0,t.ref)(``),we=null;function Te(e){let t=String(e||``),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Ee(e){return j[Te(e)]||`📎`}function De(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e}B`:e<1048576?`${Number((e/1024).toFixed(1))}KB`:`${Number((e/1048576).toFixed(1))}MB`}function Oe(e,t=20){let n=String(e||``),r=Array.from(n);if(r.length<=t)return n;let i=n.lastIndexOf(`.`),a=i>0?n.slice(i):``,o=Array.from(a);return a&&o.length<=6?r.slice(0,Math.max(1,t-o.length-1)).join(``)+`…`+a:r.slice(0,Math.max(1,t-1)).join(``)+`…`}function ke(e){return!e||!be.includes(Te(e.name))?{ok:!1,error:`仅支持 PDF、Word、压缩包、视频、音频文件`}:e.size>Wct?{ok:!1,error:`文件大小不能超过 150MB`}:{ok:!0}}function Ae(e,t,n,r){let i=Ee(e),a=Oe(String(e||``).replace(/[\u0000-\u001f\u007f]/g,` `)),o=De(t),s=`下载`,c=` ${i}${a} · ${o} ${s} `,l=c.indexOf(i)+2,u=l+a.length,d=c.lastIndexOf(s),f={bg:{rgb:zct},fs:18,cl:{rgb:`#3370ff`}};return{dataStream:c,customRanges:[{startIndex:0,endIndex:c.length-1,rangeId:n,rangeType:3,wholeEntity:!0,properties:{attachment:!0,url:r,name:e,size:t}}],textRuns:[{st:0,ed:1,ts:{...f}},{st:1,ed:2,ts:{...f}},{st:2,ed:l,ts:{...f}},{st:l,ed:u,ts:{...f,bl:!0}},{st:u,ed:d,ts:{...f}},{st:d,ed:c.length-1,ts:{...f,bl:!0}},{st:c.length-1,ed:c.length,ts:{...f}}]}}async function je(e,t,n,r){if(typeof t==`function`)try{let n=await t(e),r=typeof n==`string`?n:n?.url||``;if(r)return{url:r}}catch{}if(e.size>n)return{error:`未配置附件上传服务,无法插入超过 2MB 的文件`};try{let t=await r(e);if(t)return{url:t}}catch{}return{error:`附件读取失败,请重试`}}function Me(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error||Error(`read failed`)),r.readAsDataURL(e)})}async function Ne(e,t){if(!e||e.startsWith(`data:`)||typeof t!=`function`)return e;try{return await t(e)||e}catch{return e}}async function Pe(e,t,n){let{fetchImpl:r,doc:i,urlApi:a,defer:o=e=>setTimeout(e,400)}=n,s=``,c=e;if(!e.startsWith(`data:`)){let t=await r(e);if(!t.ok)throw Error(`附件下载失败(HTTP ${t.status})`);let n=await t.blob();s=a.createObjectURL(n),c=s}let l=i.createElement(`a`);l.href=c,l.download=t||`附件`,l.style.display=`none`,i.body.appendChild(l);try{l.click()}finally{l.remove(),s&&o(()=>a.revokeObjectURL(s))}}function Fe(e){Ce.value=e,clearTimeout(we),we=setTimeout(()=>{Ce.value=``},4e3)}async function Ie(e){let t=e?.url||``;if(!t)return;let n=e?.name||`附件`;try{await Pe(await Ne(t,i.server?.resolveAttachment),n,{fetchImpl:(e,t)=>fetch(e,t),doc:document,urlApi:URL})}catch{Fe(`附件下载失败,请稍后重试`)}}function Le(){Ie({url:w.url,name:w.fileName,size:w.fileSize}),Ye()}function Re(){c.value||Se.value||xe.value?.click()}function ze(e){let t=e?.target?.files?.[0];if(e?.target&&(e.target.value=``),t)return Be(t)}async function Be(e){let t=m.value;if(c.value||Se.value||!t||!e)return;let n=ke(e);if(!n.ok){Fe(n.error);return}let r=f,a=t.getUniverDoc?.(r)?.getSnapshot(),o=S?.segmentId||``,s=o?a?.headers?.[o]?.body||a?.footers?.[o]?.body:a?.body,l=s?.dataStream;if(!l)return;let u=S?.startOffset??Math.max(0,l.length-2);Se.value=!0;try{let{url:n,error:d}=await je(e,i.server?.attachmentUpload,Gct,Me);if(!m.value)return;if(c.value||m.value!==t||f!==r||t.getUniverDoc?.(r)?.getSnapshot()!==a||s.dataStream!==l){Fe(`文档已变更或切为只读,请重新插入附件`);return}if(!n){Fe(d||`附件插入失败,请重试`);return}let p=`attachment-${Date.now()}-${Math.floor(Math.random()*1e4)}`,h=Ae(e.name,e.size,p,n);await t.executeCommand?.(`doc.command.insert-text`,{unitId:r,range:{startOffset:u,endOffset:u,collapsed:!0,segmentId:o},segmentId:o,body:h,cursorOffset:h.dataStream.length})?at():Fe(`附件插入失败,请重试`)}catch{m.value&&Fe(`附件插入失败,请重试`)}finally{Se.value=!1}}async function Ve(){let e=m.value;if(c.value||!e)return;let t=f,n=e.getUniverDoc?.(t)?.getSnapshot(),r=S?.segmentId||``,i=(r?n?.headers?.[r]?.body||n?.footers?.[r]?.body:n?.body)?.dataStream;if(!i)return;let a=S?.startOffset??Math.max(0,i.length-2),o={dataStream:`\f\r`};await e.executeCommand?.(`doc.command.insert-text`,{unitId:t,range:{startOffset:a,endOffset:a,collapsed:!0,segmentId:r},segmentId:r,body:o,cursorOffset:o.dataStream.length})&&at()}function He(e){return(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body)?.customRanges?.find(t=>t.rangeId===e&&(t.rangeType===0||t.rangeType===3))||null}function Ue(e){if(!e?.linkId){Ge();return}if(Ke(),w.visible&&e.linkId===w.linkId&&e.startIndex===w.startIndex)return;let t=He(e.linkId);if(!t){We();return}let n=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream||``).slice(t.startIndex,t.endIndex+1),r=t.properties||{};w.url=r.url||``,w.isAttachment=!!r.attachment,w.fileName=r.name||``,w.fileSize=r.size||0,w.text=(r.text||n.replace(yG,``)).replace(/[\s\u00A0\u2000-\u200B\u3000]+$/g,``),w.style=r.style||`text`,w.linkId=e.linkId,w.segmentId=e.segmentId||``,w.startIndex=t.startIndex,w.endIndex=t.endIndex,w.styleMenuOpen=!1,w.copied=!1,w.x=null,w.y=null,w.visible=!0,T=e,Xe()}function We(){clearTimeout(E),clearTimeout(D),D=null,O=!1,w.visible=!1,w.styleMenuOpen=!1,w.copied=!1}function Ge(e=320){O||(clearTimeout(D),D=setTimeout(()=>{D=null,We()},e))}function Ke(){clearTimeout(D),D=null}function qe(){O=!0,Ke()}function Je(){O=!1,Ge(160)}function Ye(){We(),m.value?.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`)}function Xe(e=12){if(clearTimeout(E),!w.visible)return;let t=Array.from(document.querySelectorAll(`[data-u-comp="rect-popup"]`)).find(e=>e.querySelector(`.univer-max-w-80`))?.getBoundingClientRect();if(!t||t.left<-9e3||!t.width&&!t.height){e>0?E=setTimeout(()=>Xe(e-1),50):We();return}w.x=t.left+t.width/2,w.y=Math.max(t.top,8)}function Ze(){let e=w.url;e.startsWith(Rct)?a(`open-workbook`,e.slice(15)):e&&window.open(e,`_blank`,`noopener noreferrer`),Ye()}async function Qe(){let e=w.url;try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else throw Error(`clipboard unavailable`)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;opacity:0`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`)}catch{}t.remove()}w.copied=!0,clearTimeout(k),k=setTimeout(()=>{w.copied=!1},1200)}function $e(){c.value||(We(),Ye(),x.text=w.text,x.url=w.url,x.urlError=``,x.style=w.style,x.replace=!0,x.startOffset=w.startIndex,x.endOffset=w.endIndex+1,x.segmentId=w.segmentId,x.visible=!0)}async function et(e){if(c.value||(w.styleMenuOpen=!1,e===w.style))return;let{text:t,url:n,segmentId:r,startIndex:i,endIndex:a}=w,o=await ve({text:t,url:n,style:e,startOffset:i,endOffset:a+1,segmentId:r,replace:!0});o&&(at(),m.value?.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`,{...T||{},unitId:f,linkId:o.rangeId,rangeId:o.rangeId,startIndex:o.startIndex,endIndex:o.endIndex}))}async function tt(){if(c.value)return;let{text:e,segmentId:t,startIndex:n,endIndex:r}=w;await m.value?.executeCommand?.(`doc.command.insert-text`,{unitId:f,range:{startOffset:n,endOffset:r+1,collapsed:!1,segmentId:t},segmentId:t,body:{dataStream:e},cursorOffset:e.length})&&(Ye(),at())}function nt(){w.styleMenuOpen&&=!1,w.visible&&We()}function rt(){w.visible&&We(),clearTimeout(rt._t),rt._t=setTimeout(()=>{if(ee)try{let e=m.value?.getUniverDoc?.(f)?.getSnapshot()?.body;if(!e?.customRanges)return;A=[];for(let t of e.customRanges){if(t.rangeType!==0&&t.rangeType!==3)continue;let e=JI({startOffset:t.startIndex,endOffset:t.endIndex+1,collapsed:!1},ee);e?.length&&A.push({rangeId:t.rangeId,startIndex:t.startIndex,endIndex:t.endIndex,rects:e,style:t.properties?.style||`text`,text:t.properties?.text||``,url:t.properties?.url||``})}}catch{}},200)}let it=null;function at(){clearTimeout(it),it=setTimeout(ot,300)}function ot(){let e=m.value?.getUniverDoc?.(f);if(!e)return;let t=e.getSnapshot()?.body;if(!t)return;let n=t.dataStream||``,r=t.paragraphs||[],i=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.paragraphStyle?.namedStyleType,o=a==null?t.paragraphStyle?.headingLevel:a>=qp.HEADING_1&&a<=qp.HEADING_5?a-qp.HEADING_1+1:0;if(!o)continue;let s=t.startIndex,c=n.lastIndexOf(`\r`,s-1)+1;for(;c<s&&n.charCodeAt(c)<32;)c++;let l=n.slice(c,s).replace(/[\u0000-\u001f]/g,``);l.trim()&&i.push({id:`h-${c}`,level:o,text:l,startIndex:c})}y.value=i,b.paragraphs=r.length;let a=n.replace(/[\r\n]/g,``),o=(a.match(/[\u4e00-\u9fff]/g)||[]).length,s=(a.replace(/[\u4e00-\u9fff]/g,` `).match(/[A-Za-z0-9]+/g)||[]).length;b.words=o+s}function st(e){if(e.id!==`doc.operation.click-hyper-link`)return;let{linkId:t}=e.params||{};if(!t)return;let n=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body)?.customRanges?.find(e=>e.rangeId===t);if(!n)return;if(n.properties?.attachment){Ie(n.properties),e.cancel=!0;return}let r=n.properties?.url||``;if(r){if(r.startsWith(Rct)){a(`open-workbook`,r.slice(15)),e.cancel=!0;return}n.rangeType===3&&pe(r)&&(window.open(fe(r),`_blank`,`noopener,noreferrer`),e.cancel=!0)}}function ct(){let e=m.value?.getUniverDoc?.(f),t=e?.getSnapshot()?.body?.dataStream||``;if(!e||!t)return!1;let n=Math.max(0,t.length-2);return e.setSelection(n,n),S={startOffset:n,endOffset:n,segmentId:``,collapsed:!0},!0}function lt(e){if(l&&!l.entered&&e.type===bG&&e.id===l.id&&e.params===l.params){l.entered=!0;return}if((o.value||l)&&e.type!==1||c.value&&e.type===bG){e.cancel=!0;return}if(i.collaboration?.onBeforeCommand&&!i.collaboration.onBeforeCommand(e.id,e.params)){e.cancel=!0;return}st(e),!c.value&&e.id===`doc.operation.show-hyper-link-edit-popup`&&!e.params?.link&&(e.cancel=!0,me()),[`doc.operation.create-table`,`doc.command.create-table`,`doc.command.insert-float-image`].includes(e.id)&&!S&&ct()&&(e.cancel=!0,m.value?.executeCommand?.(e.id,{...e.params||{}}))}function ut(e){if(e.id!==`doc.operation.set-selections`&&e.id!==`doc.operation.toggle-hyper-link-info-popup`&&ce++,e.type===bG&&!l&&!e.options?.fromChangeset&&!e.options?.fromCollab)for(let t of ue)try{t({id:e.id,params:e.params,type:e.type,timestamp:Date.now()})}catch{}if(e.id===`doc.operation.set-selections`){let t=e.params?.ranges?.[0];t&&(S={startOffset:t.startOffset,endOffset:t.endOffset,segmentId:t.segmentId||e.params?.segmentId||``,collapsed:t.collapsed??t.startOffset===t.endOffset})}e.id===`doc.operation.toggle-hyper-link-info-popup`&&Ue(e.params),at()}function dt(){if(!p.value||m.value)return;let{univer:e,univerAPI:t}=mS({locale:bp.ZH_CN,locales:{[bp.ZH_CN]:Rg([fat,nst,Nst])},presets:[cat({container:p.value,ribbonType:`simple`}),$ot(),Mst()]});try{e.__getInjector().get(Nm).setConfig(`menu`,{"doc.operation.show-hyper-link-edit-popup":{disabled:!1}},{merge:!0})}catch{}t.createUniverDoc({id:f,title:``,documentStyle:{pageSize:{width:794,height:1123},marginTop:72,marginBottom:72,marginLeft:80,marginRight:80},tableSource:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
594
|
-
`,textRuns:[],tables:[],sectionBreaks:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:0},lineSpacing:1.15,spaceBelow:{v:8}}}]}});try{e.__getInjector().get(z).focusUnit(f)}catch{}ie=e,m.value=t,gt(),vt(),g||=vG({univer:e,server:i.server}),v&&!_.value&&(_.value={getData:ft,setData:ht,getVersion:pt,isDirty:mt,setRestoreState:u,replayMutation:_t,canPersist:()=>i.type!==`view`,ready:()=>!!m.value,getUniverInstance:()=>ie,getUniverAPI:()=>m.value,onMutation:de}),t.addEvent(t.Event.CommandExecuted,ut),t.addEvent(t.Event.BeforeCommandExecute,lt),window.addEventListener(`pointerdown`,nt),window.addEventListener(`scroll`,rt,!0),window.addEventListener(`resize`,rt),ot(),bt(1e3)}function ft(){let e=m.value?.getUniverDoc?.(f)?.getSnapshot?.();return e?.body?.dataStream?(le=ce,{type:`univer-doc`,unitId:f,version:ce,savedAt:Date.now(),data:JSON.parse(JSON.stringify(e))}):null}function pt(){return ce}function mt(){return ce!==le}function ht(e){let t=e?.type===`univer-doc`?e.data:e;if(!t?.body?.dataStream)return!1;let n=m.value;if(!n)return!1;try{We()}catch{}try{n.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`)}catch{}ae?.abort(),ae=null,oe?.dispose?.(),oe=null;try{n.disposeUnit?.(f)}catch{}let r=t.id||f;n.createUniverDoc({...JSON.parse(JSON.stringify(t)),id:r}),f=r,gt(),ce++,S=null,A=[];try{ie?.__getInjector?.()?.get(z)?.focusUnit(f)}catch{}return bt(300),vt(),at(),!0}function gt(){try{let e=(ie?.__getInjector?.()?.get(z)?.getUniverDocInstance?.(f))?.getSnapshot?.(),t=e?.body;if(!t)return;t.textRuns??=[],t.tables??=[],t.sectionBreaks??=[],e.tableSource??={};let n=t.dataStream;if(typeof n==`string`&&n.length){t.paragraphs??=[];let e=t.paragraphs,r=new Set;for(let t of e)r.add(t?.startIndex);let i=!1;for(let t=0;t<n.length;t++)n.charCodeAt(t)===13&&!r.has(t)&&(e.push({startIndex:t}),i=!0);i&&e.sort((e,t)=>e.startIndex-t.startIndex)}}catch{}}function _t(e,t){if(!o.value||l)throw Error(`当前不允许回放`);let n=m.value,r=ie?.__getInjector?.()?.get(z)?.getUniverDocInstance?.(f);if(!n||!r||t?.unitId!==f)throw Error(`回放文档不匹配`);let i={...JSON.parse(JSON.stringify(t)),noHistory:!0,isSync:!0,noNeedSetTextRange:!0};l={id:e,params:i,entered:!1};try{r.setDisabled(!1);let t=n.syncExecuteCommand(e,i,{onlyLocal:!0,fromChangeset:!0});return l.entered?e===`doc.mutation.rich-text-editing`?t?.unitId===f&&Array.isArray(t.actions)&&(Vv.isNoop(i.actions)||!Vv.isNoop(t.actions)):t===!0:!1}finally{l=null,r.setDisabled(c.value)}}function vt(){try{(ie?.__getInjector?.()?.get(z)?.getUniverDocInstance?.(f))?.setDisabled?.(c.value)}catch{}}function yt(e,t,n){if(c.value||!Number.isFinite(n)||n<40)return!1;let r=(m.value?.getUniverDoc?.(f)?.getSnapshot())?.tableSource?.[e]?.tableColumns?.[t]?.size?.width?.v;if(!Number.isFinite(r)||r===n)return!1;let i=Vv.getInstance().replaceOp([`tableSource`,e,`tableColumns`,t,`size`,`width`,`v`],r,n);return!!m.value.syncExecuteCommand(`doc.mutation.rich-text-editing`,{unitId:f,actions:i,trigger:`pd-doc.table-resize`,noNeedSetTextRange:!0,debounce:!1})?.actions?.length}function bt(e=1e3){setTimeout(()=>{if(!ie)return;let t=ie.__getInjector().get(KE).getRenderById(f),n=p.value?.querySelector(`canvas`);if(!t||!n){if(e<2e3){bt(e+400);return}console.warn(`[canvas-features] render/canvas not ready`);return}if(ee=t,!te)try{let e=t.with(rD)?.getSkeleton();if(e){let t=e,n=null;for(;t;){let e=Object.getPrototypeOf(t);if(!e)break;if(e.draw&&e.isSkipByDiffBounds){n=e;break}t=e}if(n){let e=n.draw;if(!e.__cardBgPatch){let t=function(t,n){let r=null,i=null,a=null;try{let e=this.getSkeleton?.(),t=e?.getSkeletonData?.();if(t?.pages?.length){let n=((e.getViewModel?.())?.getDataModel?.())?.getBody?.();if(n?.customRanges){r=new Set,i=new Set,a=new Set;for(let e of n.customRanges)if(e.rangeType===3){for(let t=e.startIndex;t<=e.endIndex;t++)r.add(t);i.add(e.startIndex),a.add(e.endIndex)}if(r.size>0){let e=0;for(let n of t.pages)for(let t of n.sections)for(let n of t.columns)for(let t of n.lines)for(let n of t.divides)for(let t of n.glyphGroup)t.content&&r.has(e)&&(t.ts&&!t.ts.bg&&(t.ts.bg={rgb:zct}),t._isCardGlyph=!0,i.has(e)&&(t._cardRoundLeft=!0),a.has(e)&&(t._cardRoundRight=!0)),e+=t.count||1}}}if(r?.size>0){let e=this.getExtensionByKey?.(`DefaultDocsBackgroundExtension`);if(e&&!e.__cardPaddingPatched){let t=e.draw.bind(e);e.draw=function(e,n,r){if(r._isCardGlyph){let t=r.parent?.parent;if(t&&r.ts?.bg){let{contentHeight:n=0}=t,i=Hh(r.ts.bg),a=this.extensionOffset?.spanStartPoint;if(i&&a&&r.content!==`\r`){e.fillStyle=i,re(e,a.x-1,a.y-Vct,r.width+2,n+Vct+Hct,Bct,!!r._cardRoundLeft,!!r._cardRoundRight);return}}}return t(e,n,r)},e.__cardPaddingPatched=!0}}}catch{}return e.call(this,t,n)};t.__cardBgPatch=!0,n.draw=t,te=!0,console.log(`[card-bg-patch] Documents.draw patched ✓`)}}}}catch(e){console.warn(`[card-bg-patch] failed to apply:`,e)}if(!ne)try{let e=GF.prototype.refresh;if(!e.__cardSelectionPatch){let t=function(){e.call(this);try{if(!this._rangeShape)return;let e=(this._docSkeleton?.getViewModel?.())?.getDataModel?.()?.getBody?.();if(!e?.customRanges)return;let t=this.startOffset,n=this.endOffset;if(t==null||n==null)return;for(let r of e.customRanges)if(r.rangeType===3&&t<=r.endIndex&&n>=r.startIndex){this._rangeShape.hide();return}}catch{}};t.__cardSelectionPatch=!0,GF.prototype.refresh=t,ne=!0,console.log(`[card-selection-patch] TextRange.refresh patched ✓`)}}catch(e){console.warn(`[card-selection-patch] failed to apply:`,e)}ae?.abort(),oe?.dispose?.();let r=new AbortController;ae=r;let i={signal:r.signal};try{let e=t.with(ZI);if(e){let t=e._buildCustomRangeBoundsBySegment;typeof t==`function`&&!t.__instHoverFixed&&(e._buildCustomRangeBoundsBySegment=function(e,n=-1){return t.call(this,e??``,n)},e._buildCustomRangeBoundsBySegment.__instHoverFixed=!0)}function a(){A=[];try{let e=m.value?.getUniverDoc?.(f)?.getSnapshot()?.body;if(!e?.customRanges)return;for(let n of e.customRanges){if(n.rangeType!==0&&n.rangeType!==3)continue;let e=JI({startOffset:n.startIndex,endOffset:n.endIndex+1,collapsed:!1},t);e?.length&&A.push({rangeId:n.rangeId,startIndex:n.startIndex,endIndex:n.endIndex,rects:e,style:n.properties?.style||`text`,text:n.properties?.text||``,url:n.properties?.url||``})}console.log(`[hover-patch] link rects computed: ${A.length} links found`)}catch(e){console.warn(`[hover-patch] recomputeLinkRects failed:`,e)}}a(),oe=m.value?.addEvent?.(m.value?.Event?.CommandExecuted,()=>{clearTimeout(se),se=setTimeout(a,150)}),n&&(n.addEventListener(`mousemove`,e=>{if(!A.length)return;n.getBoundingClientRect();let t=e.clientX,r=e.clientY,i=null;for(let e of A){for(let n of e.rects)if(t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom){i=e;break}if(i)break}if(i){if(Ke(),w.visible&&i.rangeId===w.linkId)return;let e=He(i.rangeId);if(!e)return;let t=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream||``).slice(e.startIndex,e.endIndex+1),n=e.properties||{};w.url=n.url||``,w.isAttachment=!!n.attachment,w.fileName=n.name||``,w.fileSize=n.size||0,w.text=(n.text||t.replace(yG,``)).replace(/[\s\u00A0\u2000-\u200B\u3000]+$/g,``),w.style=n.style||`text`,w.linkId=i.rangeId,w.segmentId=``,w.startIndex=i.startIndex,w.endIndex=i.endIndex,w.styleMenuOpen=!1,w.copied=!1;let r=i.rects.reduce((e,t)=>e.top<t.top?e:t),a=i.rects[Math.floor(i.rects.length/2)];w.x=(a.left+a.right)/2,w.y=Math.max(r.top-4,40),w.visible=!0,T={unitId:f,linkId:i.rangeId,segmentId:``,segmentPage:-1,rangeId:i.rangeId,startIndex:i.startIndex,endIndex:i.endIndex},m.value?.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`,T)}else w.visible&&Ge()},i),console.log(`[hover-patch] DOM mousemove hover detection active ✓`))}catch(e){console.warn(`[hover-patch] self-implemented hover detection failed:`,e)}try{let e=null;function o(){let e=t.with(rD).getSkeleton()?.getSkeletonData();if(!e)return[];let n=[],{scene:r,engine:i}=t,{scaleX:a}=r.getAncestorScale(),o=r.getViewport(`viewMain`)?.viewportScrollX||0,s=i.getCanvasElement().getBoundingClientRect(),c=parseFloat(i.getCanvasElement().style.width)||s.width,l=s.width/c,{docsLeft:u}=t.mainComponent.getOffsetConfig(),d=e.pages[0]?.marginLeft||0,p=e=>(e-o+u*a)*l+s.left;for(let r of e.pages)for(let e of r.skeTables.values()){let r=d+e.left,i=r,o=[],c=(m.value?.getUniverDoc?.(f)?.getSnapshot())?.tableSource?.[e.tableId]?.tableColumns||[];if(c.length>0)for(let t=0;t<c.length;t++)i+=c[t].size.width.v,o.push({x:i,colIndex:t,tableId:e.tableId,colWidth:c[t].size.width.v});else for(let t of e.rows){let n=r;for(let r=0;r<t.cells.length;r++)n+=t.cells[r].pageWidth,o.push({x:n,colIndex:r,tableId:e.tableId,colWidth:t.cells[r].pageWidth});break}let u=1/0,h=-1/0;try{let n=JI({startOffset:e.st,endOffset:e.ed,collapsed:!1},t);if(n&&n.length>0)for(let e of n)u=Math.min(u,e.top),h=Math.max(h,e.bottom)}catch{}u===1/0&&(u=s.top,h=s.bottom);for(let e of o)n.push({screenX:p(e.x),screenTop:u,screenBottom:h,colIndex:e.colIndex,tableId:e.tableId,colWidth:e.colWidth,tableDocLeft:r,scaleCombined:a*l})}return n}n.addEventListener(`pointermove`,t=>{if(c.value||e)return;let r=o(),i=null;for(let e of r)if(t.clientY>=e.screenTop-6&&t.clientY<=e.screenBottom+6&&Math.abs(t.clientX-e.screenX)<=6){i=e;break}n.style.cursor=i?`col-resize`:``},i),n.addEventListener(`pointerdown`,t=>{if(c.value)return;let r=o(),i=null;for(let e of r)if(t.clientY>=e.screenTop-6&&t.clientY<=e.screenBottom+6&&Math.abs(t.clientX-e.screenX)<=6){i=e;break}i&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),n.style.cursor=`col-resize`,n.style.touchAction=`none`,e={tableId:i.tableId,colIndex:i.colIndex,startX:t.clientX,startWidth:i.colWidth,scaleCombined:i.scaleCombined})},{...i,capture:!0}),window.addEventListener(`pointermove`,t=>{e&&t.preventDefault()},i),window.addEventListener(`pointerup`,t=>{if(!e)return;let r=(t.clientX-e.startX)/e.scaleCombined,i=Math.max(40,Math.round(e.startWidth+r));try{yt(e.tableId,e.colIndex,i),clearTimeout(se),se=setTimeout(a,300)}catch(e){console.warn(`[table-resize] apply failed:`,e)}e=null,n.style.cursor=``,n.style.touchAction=``},i),console.log(`[table-resize] column drag-resize active ✓`)}catch(e){console.warn(`[table-resize] init failed:`,e)}},e)}return(0,t.watch)(()=>i.visible,e=>{e?setTimeout(dt,100):Ye()},{immediate:!0}),(0,t.watch)(()=>i.type,()=>{m.value&&vt()}),(0,t.onUnmounted)(()=>{clearTimeout(it),clearTimeout(E),clearTimeout(D),clearTimeout(k),clearTimeout(se),clearTimeout(we),ae?.abort(),oe?.dispose?.(),window.removeEventListener(`pointerdown`,nt),window.removeEventListener(`scroll`,rt,!0),window.removeEventListener(`resize`,rt),g?.dispose?.(),g=null,m.value?.dispose?.(),m.value=null}),n({getData:ft,setData:ht,getVersion:pt,isDirty:mt,ready:()=>!!m.value,getUniverInstance:()=>ie,getUniverAPI:()=>m.value,onMutation:de,replayRemoteMutations:e=>{if(!Array.isArray(e))return;let t=m.value;if(t)for(let n of e){let e=JSON.parse(JSON.stringify(n.params??{}));l={id:n.commandId,params:e,entered:!1};try{t.syncExecuteCommand(n.commandId,e,{onlyLocal:!0,fromChangeset:!0})}catch{}l=null}},persistence:v}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,yct,[(0,t.createElementVNode)(`div`,bct,[(0,t.createElementVNode)(`div`,xct,[(0,t.createElementVNode)(`div`,{ref_key:`containerRef`,ref:p,class:`doc-editor`},null,512),c.value&&m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Sct,[s.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createTextVNode)(`恢复失败:`+(0,t.toDisplayString)(s.value)+` `,1),(0,t.createElementVNode)(`button`,{onClick:d},`重试`)],64)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createTextVNode)((0,t.toDisplayString)(o.value?`正在恢复文档…`:`🔒 只读模式`),1)],64))])):(0,t.createCommentVNode)(``,!0),!c.value&&m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:1,class:`pagebreak-insert-btn`,title:`在光标处插入分页符`,onClick:Ve},`📄 插入分页符`)):(0,t.createCommentVNode)(``,!0),!c.value&&m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:2,class:`attachment-insert-btn`,disabled:Se.value,onClick:Re},(0,t.toDisplayString)(Se.value?`上传中…`:`📎 插入附件`),9,Cct)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`input`,{ref_key:`attachmentInputRef`,ref:xe,class:`attachment-file-input`,type:`file`,accept:Uct,onChange:ze},null,544),Ce.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,wct,(0,t.toDisplayString)(Ce.value),1)):(0,t.createCommentVNode)(``,!0),x.visible?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:4,class:`link-dialog-mask`,onClick:(0,t.withModifiers)(he,[`self`])},[(0,t.createElementVNode)(`div`,Tct,[n[8]||=(0,t.createElementVNode)(`div`,{class:`link-dialog-title`},`插入链接`,-1),(0,t.createElementVNode)(`div`,Ect,[n[6]||=(0,t.createElementVNode)(`label`,{class:`field-label`},`文字`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{"onUpdate:modelValue":n[0]||=e=>x.text=e,class:`field-input`,type:`text`,placeholder:`链接显示的文字(留空则显示链接地址)`,onKeydown:(0,t.withKeys)(ye,[`enter`])},null,544),[[t.vModelText,x.text]])]),(0,t.createElementVNode)(`div`,Dct,[n[7]||=(0,t.createElementVNode)(`label`,{class:`field-label`},`链接地址`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{ref_key:`linkUrlInputRef`,ref:h,"onUpdate:modelValue":n[1]||=e=>x.url=e,class:(0,t.normalizeClass)([`field-input`,{error:x.urlError}]),type:`text`,placeholder:`https:// 或 univer-sheet://wb-progress`,onInput:n[2]||=e=>x.urlError=``,onKeydown:(0,t.withKeys)(ye,[`enter`])},null,34),[[t.vModelText,x.url]]),x.urlError?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Oct,(0,t.toDisplayString)(x.urlError),1)):(0,t.createCommentVNode)(``,!0)]),(0,t.createElementVNode)(`div`,kct,(0,t.toDisplayString)(x.replace?`将替换选中的文字或原链接`:`将在光标处插入`)+` · 支持 univer-sheet:// 内链跳转表格 · 插入后悬停可改样式 `,1),(0,t.createElementVNode)(`div`,Act,[(0,t.createElementVNode)(`button`,{class:`dialog-btn cancel`,onClick:he},`取 消`),(0,t.createElementVNode)(`button`,{class:`dialog-btn confirm`,disabled:!x.url.trim(),onClick:ye},`确 定`,8,jct)])])])):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:`body`},[w.visible&&w.x!==null?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:0,class:`link-hover-bar`,style:(0,t.normalizeStyle)({left:w.x+`px`,top:w.y+`px`}),onPointerdown:n[5]||=(0,t.withModifiers)(()=>{},[`stop`]),onMouseenter:qe,onMouseleave:Je},[(0,t.createElementVNode)(`span`,{class:`hover-label`,onClick:n[3]||=e=>w.isAttachment?Le():Ze()},(0,t.toDisplayString)(w.isAttachment?`下载`:`打开链接`),1),w.isAttachment?(0,t.createCommentVNode)(``,!0):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[n[13]||=(0,t.createElementVNode)(`i`,{class:`hover-sep`},null,-1),(0,t.createElementVNode)(`button`,{class:`hover-icon-btn`,title:`复制`,onClick:Qe},[n[9]||=(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,t.createElementVNode)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})],-1),w.copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,Mct,`已复制`)):(0,t.createCommentVNode)(``,!0)]),c.value?(0,t.createCommentVNode)(``,!0):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createElementVNode)(`button`,{class:`hover-icon-btn`,title:`编辑`,onClick:$e},[...n[10]||=[(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`path`,{d:`M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z`})],-1)]]),(0,t.createElementVNode)(`div`,Nct,[(0,t.createElementVNode)(`button`,{class:`hover-icon-btn`,title:`切换样式`,onClick:n[4]||=e=>w.styleMenuOpen=!w.styleMenuOpen},[...n[11]||=[(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`path`,{d:`m6 9 6 6 6-6`})],-1)]]),w.styleMenuOpen?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Pct,[((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(C,e=>(0,t.createElementVNode)(`div`,{key:e.value,class:(0,t.normalizeClass)([`hover-style-item`,{active:e.value===w.style}]),onClick:t=>et(e.value)},[(0,t.createElementVNode)(`span`,Ict,(0,t.toDisplayString)(e.value===w.style?`✓`:``),1),(0,t.createElementVNode)(`span`,Lct,(0,t.toDisplayString)(e.label),1)],10,Fct)),64))])):(0,t.createCommentVNode)(``,!0)]),(0,t.createElementVNode)(`button`,{class:`hover-icon-btn hover-unlink-btn`,title:`取消链接`,onClick:tt},[...n[12]||=[(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`path`,{d:`M15 7h3a5 5 0 0 1 0 10h-3m-6 0H6a5 5 0 0 1 0-10h3`}),(0,t.createElementVNode)(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`})],-1)]])],64))],64)),n[14]||=(0,t.createElementVNode)(`div`,{class:`hover-bar-arrow`},null,-1)],36)):(0,t.createCommentVNode)(``,!0)]))])])]))}},[[`__scopeId`,`data-v-ca38b9dd`]]);function qct(e,t,n){var r;if(t.t)return t.t;if(t.v===null)return null;let i=e.getStyleByCell(t),a=e.getStyleByCell(n);if(n.t===Pp.FORCE_STRING){var o;if(!Ch(a==null||(o=a.n)==null?void 0:o.pattern)&&t.v!==void 0){if(Pg(t.v))return Pp.NUMBER;if($d(`${t.v}`))return Pp.BOOLEAN}return Pp.FORCE_STRING}if(Yct(i)){var s;return Ch(i==null||(s=i.n)==null?void 0:s.pattern)?Pp.STRING:Jct(t,n)}return Ch(a==null||(r=a.n)==null?void 0:r.pattern)?Pp.STRING:Jct(t,n)}function Jct(e,t){return e.v===void 0?xG(t.v,t.t):xG(e.v,e.t)}function Yct(e){var t;return!!(e!=null&&(t=e.n)!=null&&t.pattern)}function xG(e,t){return e===null?null:typeof e==`string`?Pg(e)?(+e==0||+e==1)&&t===Pp.BOOLEAN?Pp.BOOLEAN:t!==Pp.STRING&&t!==Pp.FORCE_STRING&&Lf(e)?Pp.FORCE_STRING:Pp.NUMBER:$d(e)?Pp.BOOLEAN:Pp.STRING:typeof e==`number`?(e===0||e===1)&&t===Pp.BOOLEAN?Pp.BOOLEAN:Pp.NUMBER:typeof e==`boolean`?Pp.BOOLEAN:Pp.FORCE_STRING}function Xct(e,t){let{unitId:n}=t,r=n?e.getUnit(n,M.UNIVER_SHEET):e.getCurrentUnitOfType(M.UNIVER_SHEET);return r?{workbook:r,unitId:r.getUnitId()}:null}function SG(e,t={}){let{unitId:n,subUnitId:r}=t,i=n?e.getUnit(n,M.UNIVER_SHEET):e.getCurrentUnitOfType(M.UNIVER_SHEET);if(!i)return null;let a=r?i.getSheetBySheetId(r):i.getActiveSheet(!0);return a?{worksheet:a,workbook:i,unitId:i.getUnitId(),subUnitId:a.getSheetId()}:null}function CG(e,t){let{unitId:n,subUnitId:r}=t,i=e.getUnit(n,M.UNIVER_SHEET);if(!i)return null;let a=i.getSheetBySheetId(r);return a?{worksheet:a,workbook:i}:null}var wG=(e,t)=>{if(!CG(e.get(z),t))throw Error(`Workbook or worksheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:F.deepClone(t.ranges)}},TG={id:`sheet.mutation.add-worksheet-merge`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or worksheet is null error!`);let{worksheet:r}=n,i=r.getConfig().mergeData,a=t.ranges;for(let e=0;e<a.length;e++)i.push(a[e]);return r.getSpanModel().rebuild(i),!0}},EG={CELL_CONTENT:Cf(`CELL_CONTENT`),ROW_FILTERED:Cf(`ROW_FILTERED`)},DG=function(e){return e[e.DATA_VALIDATION=9]=`DATA_VALIDATION`,e[e.NUMFMT=10]=`NUMFMT`,e[e.CELL_IMAGE=11]=`CELL_IMAGE`,e}({}),Zct=`sheet.interceptor.range-theme-id`,Qct=`sheet.interceptor.ignore-range-theme`;function OG(e){"@babel/helpers - typeof";return OG=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},OG(e)}function $ct(e,t){if(OG(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(OG(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function elt(e){var t=$ct(e,`string`);return OG(t)==`symbol`?t:t+``}function Z(e,t,n){return(t=elt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kG(e,t){return function(n,r){t(n,r,e)}}function AG(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var jG=Cf(`BEFORE_CELL_EDIT`),MG=Cf(`AFTER_CELL_EDIT`),NG=Cf(`VALIDATE_CELL`),PG=class extends P{constructor(e){super(),this._univerInstanceService=e,Z(this,`_interceptorsByName`,new Map),Z(this,`_commandInterceptors`,[]),Z(this,`_rangeInterceptors`,[]),Z(this,`_autoHeightInterceptors`,[]),Z(this,`_beforeCommandInterceptor`,[]),Z(this,`_afterCommandInterceptors`,[]),Z(this,`_workbookDisposables`,new Map),Z(this,`_worksheetDisposables`,new Map),Z(this,`_composedInterceptorByKey`,new Map),Z(this,`_composedInterceptorVersion`,0),Z(this,`writeCellInterceptor`,new Tf({BEFORE_CELL_EDIT:jG,AFTER_CELL_EDIT:MG,VALIDATE_CELL:NG})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(M.UNIVER_SHEET).subscribe(e=>{this._interceptWorkbook(e.unit)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_SHEET).subscribe(e=>this._disposeWorkbookInterceptor(e))),this.intercept(EG.CELL_CONTENT,{priority:-1,effect:Sf.Style|Sf.Value,handler:e=>e}),this.disposeWithMe(this.writeCellInterceptor.intercept(MG,{priority:-1,handler:e=>e})),this.disposeWithMe(this.writeCellInterceptor.intercept(jG,{priority:-1,handler:e=>e})),this.disposeWithMe(this.writeCellInterceptor.intercept(NG,{priority:-1,handler:e=>e}))}dispose(){super.dispose(),this._workbookDisposables.forEach(e=>e.dispose()),this._workbookDisposables.clear(),this._worksheetDisposables.forEach(e=>e.dispose()),this._worksheetDisposables.clear(),this._interceptorsByName.clear(),this._composedInterceptorByKey.clear()}interceptCommand(e){if(this._commandInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._commandInterceptors.push(e),this._commandInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._commandInterceptors,e)))}onCommandExecute(e){let t=this._commandInterceptors.map(t=>t.getMutations(e));return{preUndos:t.map(e=>e.preUndos??[]).flat(),undos:t.map(e=>e.undos).flat(),preRedos:t.map(e=>e.preRedos??[]).flat(),redos:t.map(e=>e.redos).flat()}}interceptAfterCommand(e){if(this._afterCommandInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._afterCommandInterceptors.push(e),this._afterCommandInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._afterCommandInterceptors,e)))}afterCommandExecute(e){let t=this._afterCommandInterceptors.map(t=>t.getMutations(e));return{undos:t.map(e=>e.undos).flat(),redos:t.map(e=>e.redos).flat()}}interceptAutoHeight(e){if(this._autoHeightInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._autoHeightInterceptors.push(e),this._autoHeightInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._autoHeightInterceptors,e)))}generateMutationsOfAutoHeight(e){let t=this._autoHeightInterceptors.map(t=>t.getMutations(e));return{preUndos:t.map(e=>e.preUndos??[]).flat(),undos:t.map(e=>e.undos).flat(),preRedos:t.map(e=>e.preRedos??[]).flat(),redos:t.map(e=>e.redos).flat()}}interceptBeforeCommand(e){if(this._beforeCommandInterceptor.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._beforeCommandInterceptor.push(e),this._beforeCommandInterceptor.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._beforeCommandInterceptor,e)))}async beforeCommandExecute(e){return(await Promise.all(this._beforeCommandInterceptor.map(t=>t.performCheck(e)))).every(e=>e)}interceptRanges(e){if(this._rangeInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._rangeInterceptors.push(e),this._rangeInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._rangeInterceptors,e)))}generateMutationsByRanges(e){let t=this._rangeInterceptors.map(t=>t.getMutations(e));return{preUndos:t.map(e=>e.preUndos??[]).flat(),undos:t.map(e=>e.undos).flat(),preRedos:t.map(e=>e.preRedos??[]).flat(),redos:t.map(e=>e.redos).flat()}}onWriteCell(e,t,n,r,i){let a={subUnitId:t.getSheetId(),unitId:e.getUnitId(),workbook:e,worksheet:t,row:n,col:r,origin:F.deepClone(i)};return this.writeCellInterceptor.fetchThroughInterceptors(MG)(i,a)}onValidateCell(e,t,n,r){let i={subUnitId:t.getSheetId(),unitId:e.getUnitId(),workbook:e,worksheet:t,row:n,col:r};return this.writeCellInterceptor.fetchThroughInterceptors(NG)(Promise.resolve(!0),i)}intercept(e,t){let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);r.push(t);let i=r.sort((e,t)=>(t.priority??0)-(e.priority??0));if(this._invalidateComposedInterceptors(),n===EG.CELL_CONTENT){let e=Sf.Style|Sf.Value;this._interceptorsByName.set(`${n}-${e}`,i);let r=Sf.Style|Sf.Value;return this._interceptorsByName.set(`${n}-${Sf.Style}`,i.filter(e=>((e.effect||r)&Sf.Style)>0)),this._interceptorsByName.set(`${n}-${Sf.Value}`,i.filter(e=>((e.effect||r)&Sf.Value)>0)),this.disposeWithMe(Wf(()=>{qd(this._interceptorsByName.get(n),t),qd(this._interceptorsByName.get(`${n}-${e}`),t),qd(this._interceptorsByName.get(`${n}-${Sf.Style}`),t),qd(this._interceptorsByName.get(`${n}-${Sf.Value}`),t),this._invalidateComposedInterceptors()}))}return this._interceptorsByName.set(n,i),this.disposeWithMe(Wf(()=>{qd(this._interceptorsByName.get(n),t),this._invalidateComposedInterceptors()}))}fetchThroughInterceptors(e,t,n,r){let i=t===void 0?e:`${e}-${t}`,a=n??i,o=this._composedInterceptorByKey.get(a);if(!o){let e=this._interceptorsByName.get(i);e&&r&&(e=e.filter(r)),o=wf(e||[]),this._composedInterceptorByKey.set(a,o)}return o}_invalidateComposedInterceptors(){this._composedInterceptorVersion+=1,this._composedInterceptorByKey.clear()}_getCommonCellContentInterceptor(e,t){let n=t.get(e);return n||(n=this.fetchThroughInterceptors(EG.CELL_CONTENT,e),t.set(e,n)),n}_getCommonRowFilteredInterceptor(e){return e.interceptor||=this.fetchThroughInterceptors(EG.ROW_FILTERED),e.interceptor}_interceptWorkbook(e){let t=new Gf,n=e.getUnitId(),r=this,i=t=>{let i=t.getSheetId();t.__interceptViewModel(a=>{let o=new Gf,s=new Map,c={interceptor:null},l=-1,u=-1;r._worksheetDisposables.set(tlt(n,t),o),o.add(a.registerCellContentInterceptor({getCell(a,o,c,u,d){let f=t.getCellRaw(a,o),p={unitId:n,subUnitId:i,row:a,col:o,worksheet:t,workbook:e,rawData:f};return u===void 0&&d===void 0?(l!==r._composedInterceptorVersion&&(s.clear(),l=r._composedInterceptorVersion),r._getCommonCellContentInterceptor(c,s)(f,p)):r.fetchThroughInterceptors(EG.CELL_CONTENT,c,u,d)(f,p)}})),o.add(a.registerRowFilteredInterceptor({getRowFiltered(a){return u!==r._composedInterceptorVersion&&(c.interceptor=null,u=r._composedInterceptorVersion),!!r._getCommonRowFilteredInterceptor(c)(!1,{unitId:n,subUnitId:i,row:a,workbook:e,worksheet:t})}}))})};e.getSheets().forEach(e=>i(e)),t.add(e.sheetCreated$.subscribe(e=>i(e))),t.add(Wf(()=>e.getSheets().forEach(e=>this._disposeSheetInterceptor(n,e)))),t.add(e.sheetDisposed$.subscribe(e=>this._disposeSheetInterceptor(n,e))),this._workbookDisposables.set(n,t)}_disposeWorkbookInterceptor(e){let t=e.getUnitId(),n=this._workbookDisposables.get(t);n&&(n.dispose(),this._workbookDisposables.delete(t))}_disposeSheetInterceptor(e,t){let n=tlt(e,t),r=this._worksheetDisposables.get(n);r&&(r.dispose(),this._worksheetDisposables.delete(n))}};PG=AG([kG(0,z)],PG);function tlt(e,t){return`${e}|${t.getSheetId()}`}var FG=e=>{let t={};return e.bg&&(t.bg={...e.bg}),e.ol&&(t.ol={...e.ol}),e.bd&&(t.bd={...e.bd}),e.cl&&(t.cl={...e.cl}),e.ht&&(t.ht=e.ht),e.vt&&(t.vt=e.vt),e.bl!==void 0&&(t.bl=e.bl),t};function nlt(e){let t={};if(e.length===1)return e[0];for(let n of e)n.bg&&(t.bg=n.bg),n.ol&&(t.ol=n.ol),n.bd&&(t.bd={...t.bd,...n.bd}),n.cl&&(t.cl=n.cl),n.ht&&(t.ht=n.ht),n.vt&&(t.vt=n.vt),n.bl!==void 0&&(t.bl=n.bl);return t}var IG={wholeStyle:1,headerRowStyle:2,headerColumnStyle:4,firstRowStyle:8,secondRowStyle:16,lastRowStyle:32,firstColumnStyle:128,secondColumnStyle:256,lastColumnStyle:512},LG=class{constructor(e,t){Z(this,`_name`,void 0),Z(this,`wholeStyle`,null),Z(this,`headerRowStyle`,null),Z(this,`headerColumnStyle`,null),Z(this,`firstRowStyle`,null),Z(this,`secondRowStyle`,null),Z(this,`lastRowStyle`,null),Z(this,`firstColumnStyle`,null),Z(this,`secondColumnStyle`,null),Z(this,`lastColumnStyle`,null),Z(this,`_mergeCacheMap`,new Map),t&&this.fromJson({...t,name:e}),this._name=e}getName(){return this._name}getWholeStyle(){return this.wholeStyle}setWholeStyle(e){this.wholeStyle=e,this._resetStyleCache()}getFirstRowStyle(){return this.firstRowStyle}setFirstRowStyle(e){this.firstRowStyle=e,this._resetStyleCache()}getSecondRowStyle(){return this.secondRowStyle}setSecondRowStyle(e){this.secondRowStyle=e,this._resetStyleCache()}getLastRowStyle(){return this.lastRowStyle}setLastRowStyle(e){this.lastRowStyle=e,this._resetStyleCache()}getFirstColumnStyle(){return this.firstColumnStyle}setFirstColumnStyle(e){this.firstColumnStyle=e,this._resetStyleCache()}getSecondColumnStyle(){return this.secondColumnStyle}setSecondColumnStyle(e){this.secondColumnStyle=e,this._resetStyleCache()}getLastColumnStyle(){return this.lastColumnStyle}setLastColumnStyle(e){this.lastColumnStyle=e,this._resetStyleCache()}getHeaderRowStyle(){return this.headerRowStyle}setHeaderRowStyle(e){this.headerRowStyle=e,this._resetStyleCache()}getHeaderColumnStyle(){return this.headerColumnStyle}setHeaderColumnStyle(e){this.headerColumnStyle=e,this._resetStyleCache()}getStyle(e,t,n,r,i){let a=0;return n&&(a|=IG.lastRowStyle),r&&(a|=IG.lastColumnStyle),e>=0&&t>=0&&(a|=IG.wholeStyle),e%2==1&&(a|=i?IG.secondRowStyle:IG.firstRowStyle),e%2==0&&(a|=i?IG.firstRowStyle:IG.secondRowStyle),e===0&&(a|=IG.headerRowStyle),t===0&&(a|=IG.headerColumnStyle),t%2==1&&(a|=IG.firstColumnStyle),t%2==0&&(a|=IG.secondColumnStyle),a===0?null:this._getMergeStyle(a)}_getMergeStyle(e){let t=this._mergeCacheMap.get(e);return t||(t=this._mergeStyle(e),this._mergeCacheMap.set(e,t)),t}_mergeStyle(e){let t=[];return this.wholeStyle&&e&IG.wholeStyle&&t.push(this.wholeStyle),this.firstColumnStyle&&e&IG.firstColumnStyle&&t.push(this.firstColumnStyle),this.secondColumnStyle&&e&IG.secondColumnStyle&&t.push(this.secondColumnStyle),this.firstRowStyle&&e&IG.firstRowStyle&&t.push(this.firstRowStyle),this.secondRowStyle&&e&IG.secondRowStyle&&t.push(this.secondRowStyle),this.headerColumnStyle&&e&IG.headerColumnStyle&&t.push(this.headerColumnStyle),this.lastColumnStyle&&e&IG.lastColumnStyle&&t.push(this.lastColumnStyle),this.headerRowStyle&&e&IG.headerRowStyle&&t.push(this.headerRowStyle),this.lastRowStyle&&e&IG.lastRowStyle&&t.push(this.lastRowStyle),nlt(t)}_resetStyleCache(){this._mergeCacheMap.clear()}toJson(){let e={name:this._name};return this.wholeStyle&&(e.wholeStyle=FG(this.wholeStyle)),this.headerRowStyle&&(e.headerRowStyle=FG(this.headerRowStyle)),this.headerColumnStyle&&(e.headerColumnStyle=FG(this.headerColumnStyle)),this.firstRowStyle&&(e.firstRowStyle=FG(this.firstRowStyle)),this.secondRowStyle&&(e.secondRowStyle=FG(this.secondRowStyle)),this.lastRowStyle&&(e.lastRowStyle=FG(this.lastRowStyle)),this.firstColumnStyle&&(e.firstColumnStyle=FG(this.firstColumnStyle)),this.secondColumnStyle&&(e.secondColumnStyle=FG(this.secondColumnStyle)),this.lastColumnStyle&&(e.lastColumnStyle=FG(this.lastColumnStyle)),e}fromJson(e){this._name=e.name,e.wholeStyle&&(this.wholeStyle=FG(e.wholeStyle)),e.headerRowStyle&&(this.headerRowStyle=FG(e.headerRowStyle)),e.headerColumnStyle&&(this.headerColumnStyle=FG(e.headerColumnStyle)),e.firstRowStyle&&(this.firstRowStyle=FG(e.firstRowStyle)),e.secondRowStyle&&(this.secondRowStyle=FG(e.secondRowStyle)),e.lastRowStyle&&(this.lastRowStyle=FG(e.lastRowStyle)),e.firstColumnStyle&&(this.firstColumnStyle=FG(e.firstColumnStyle)),e.secondColumnStyle&&(this.secondColumnStyle=FG(e.secondColumnStyle)),e.lastColumnStyle&&(this.lastColumnStyle=FG(e.lastColumnStyle))}dispose(){this._mergeCacheMap.clear()}},rlt=(e,t,n)=>new LG(`light-${e}`,{headerRowStyle:{bg:{rgb:t}},firstColumnStyle:{bg:{rgb:`rgb(255, 255, 255)`}},secondColumnStyle:{bg:{rgb:n}},lastRowStyle:{bg:{rgb:t}}}),ilt=(e,t,n)=>new LG(`middle-${e}`,{headerRowStyle:{bg:{rgb:t}},headerColumnStyle:{bg:{rgb:n}},secondRowStyle:{bg:{rgb:n}},lastRowStyle:{bg:{rgb:t}},lastColumnStyle:{bg:{rgb:n}}}),alt=(e,t,n,r)=>new LG(`dark-${e}`,{headerRowStyle:{bg:{rgb:t},cl:{rgb:`rgb(255, 255, 255)`},ht:Dp.CENTER,bl:Np.TRUE},firstRowStyle:{bg:{rgb:n}},secondRowStyle:{bg:{rgb:r}},lastRowStyle:{bg:{rgb:t}}}),olt=[{baseName:`blue`,header:`rgb(164, 202, 254)`,color:`rgb(225, 239, 254)`},{baseName:`grey`,header:`rgb(205, 208, 216)`,color:`rgb(238, 239, 241)`},{baseName:`red`,header:`rgb(248, 180, 180)`,color:`rgb(253, 232, 232)`},{baseName:`orange`,header:`rgb(253, 186, 140)`,color:`rgb(254, 236, 220)`},{baseName:`yellow`,header:`rgb(250, 200, 21)`,color:`rgb(255, 244, 185)`},{baseName:`green`,header:`rgb(132, 225, 188)`,color:`rgb(222, 247, 236)`},{baseName:`azure`,header:`rgb(126, 220, 226)`,color:`rgb(213, 245, 246)`},{baseName:`indigo`,header:`rgb(186, 198, 248)`,color:`rgb(233, 237, 255)`},{baseName:`purple`,header:`rgb(202, 191, 253)`,color:`rgb(237, 235, 254)`},{baseName:`magenta`,header:`rgb(248, 180, 217)`,color:`rgb(252, 232, 243)`}],slt=[{baseName:`blue`,rowHeader:`rgb(63, 131, 248)`,colHeader:`rgb(195, 221, 253)`},{baseName:`grey`,rowHeader:`rgb(95, 101, 116)`,colHeader:`rgb(227, 229, 234)`},{baseName:`red`,rowHeader:`rgb(240, 82, 82)`,colHeader:`rgb(251, 213, 213)`},{baseName:`orange`,rowHeader:`rgb(255, 90, 31)`,colHeader:`rgb(252, 217, 189)`},{baseName:`yellow`,rowHeader:`rgb(212, 157, 15)`,colHeader:`rgb(252, 220, 106)`},{baseName:`green`,rowHeader:`rgb(13, 164, 113)`,colHeader:`rgb(188, 240, 218)`},{baseName:`azure`,rowHeader:`rgb(6, 148, 162)`,colHeader:`rgb(175, 236, 239)`},{baseName:`indigo`,rowHeader:`rgb(70, 106, 247)`,colHeader:`rgb(210, 218, 250)`},{baseName:`purple`,rowHeader:`rgb(144, 97, 249)`,colHeader:`rgb(220, 215, 254)`},{baseName:`magenta`,rowHeader:`rgb(231, 70, 148)`,colHeader:`rgb(250, 209, 232)`}],clt=[{baseName:`blue`,rowHeader:`rgb(30, 66, 159)`,firstRow:`rgb(195, 221, 253)`,secondRow:`rgb(118, 169, 250)`},{baseName:`grey`,rowHeader:`rgb(44, 48, 64)`,firstRow:`rgb(227, 229, 234)`,secondRow:`rgb(151, 157, 172)`},{baseName:`red`,rowHeader:`rgb(155, 28, 28)`,firstRow:`rgb(251, 213, 213)`,secondRow:`rgb(249, 128, 128)`},{baseName:`orange`,rowHeader:`rgb(180, 52, 3)`,firstRow:`rgb(252, 217, 189)`,secondRow:`rgb(255, 138, 76)`},{baseName:`yellow`,rowHeader:`rgb(154, 109, 21)`,firstRow:`rgb(252, 220, 106)`,secondRow:`rgb(212, 157, 15)`},{baseName:`green`,rowHeader:`rgb(4, 108, 78)`,firstRow:`rgb(188, 240, 218)`,secondRow:`rgb(49, 196, 141)`},{baseName:`azure`,rowHeader:`rgb(3, 102, 114)`,firstRow:`rgb(175, 236, 239)`,secondRow:`rgb(22, 189, 202)`},{baseName:`indigo`,rowHeader:`rgb(16, 51, 191)`,firstRow:`rgb(210, 218, 250)`,secondRow:`rgb(98, 128, 249)`},{baseName:`purple`,rowHeader:`rgb(74, 29, 150)`,firstRow:`rgb(220, 215, 254)`,secondRow:`rgb(172, 148, 250)`},{baseName:`magenta`,rowHeader:`rgb(153, 21, 75)`,firstRow:`rgb(250, 209, 232)`,secondRow:`rgb(241, 126, 184)`}],llt=olt.map(({baseName:e,header:t,color:n})=>rlt(e,t,n)),ult=slt.map(({baseName:e,rowHeader:t,colHeader:n})=>ilt(e,t,n)),dlt=clt.map(({baseName:e,rowHeader:t,firstRow:n,secondRow:r})=>alt(e,t,n,r)),flt=[...llt,...ult,...dlt],plt={headerRowStyle:{bg:{rgb:`rgb(68,114,196)`},cl:{rgb:`rgb(255,255,255)`},ht:Dp.CENTER,bl:Np.TRUE},firstRowStyle:{bg:{rgb:`rgb(217,225,242)`}}},mlt=new LG(`default`,plt),hlt=new LG(`default-last-row`,{...plt,lastRowStyle:{bd:{t:{s:up.THIN,cl:{rgb:`rgb(68,114,196)`}}},ht:Dp.CENTER,bl:Np.TRUE}}),glt=class{constructor(){Z(this,`_toggleRanges`,[])}refresh(e,t){let{startRow:n,endRow:r}=e,i=[],a=0,o=!1,s=-1;for(let e=n;e<=r;e++){if(!t(e)){a++,a%2==1?o=!0:(o=!1,s!==-1&&(i.push([s,e-1]),s=-1));continue}a%2==1?o?s===-1&&(s=e):(o=!0,s=e):o&&(i.push([s,e-2]),o=!1,s=-1),e===r&&o&&i.push([s,e])}this._toggleRanges=i}getToggleRanges(){return this._toggleRanges.concat()}getIsToggled(e){let t=0,n=this._toggleRanges.length-1;for(;t<=n;){let r=Math.floor((t+n)/2),[i,a]=this._toggleRanges[r];if(e<i)n=r-1;else if(e>a)t=r+1;else return!0}return!1}},_lt=`SHEET_RANGE_THEME_MODEL_PLUGIN`,RG=class extends P{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._resourceManagerService=t,this._univerInstanceService=n,Z(this,`_rangeThemeStyleMap`,new Map),Z(this,`_rangeThemeStyleRuleMap`,new Map),Z(this,`_rTreeCollection`,new Map),Z(this,`_defaultRangeThemeMap`,new Map),Z(this,`_zebraCrossingCacheMap`,new Map),Z(this,`_rowVisibleFuncSet`,new Map),Z(this,`_rangeThemeMapChanged$`,new ao),Z(this,`rangeThemeMapChange$`,this._rangeThemeMapChanged$.asObservable()),this._registerIntercept(),this._initSnapshot(),this._initDefaultTheme()}_initDefaultTheme(){this.registerDefaultRangeTheme(mlt),this.registerDefaultRangeTheme(hlt);for(let e of flt)this.registerDefaultRangeTheme(e)}_ensureRangeThemeStyleMap(e){return this._rangeThemeStyleMap.has(e)||this._rangeThemeStyleMap.set(e,new Map),this._rangeThemeStyleMap.get(e)}_ensureRangeThemeStyleRuleMap(e){return this._rangeThemeStyleRuleMap.has(e)||this._rangeThemeStyleRuleMap.set(e,new Map),this._rangeThemeStyleRuleMap.get(e)}_ensureRTreeCollection(e){return this._rTreeCollection.has(e)||this._rTreeCollection.set(e,new Ox),this._rTreeCollection.get(e)}getDefaultRangeThemeStyle(e){return this._defaultRangeThemeMap.get(e)}getCustomRangeThemeStyle(e,t){return this._ensureRangeThemeStyleMap(e).get(t)}_getSheetRowVisibleFuncSet(e,t){this._rowVisibleFuncSet.has(e)||this._rowVisibleFuncSet.set(e,new Map);let n=this._rowVisibleFuncSet.get(e);return n.has(t)||n.set(t,new Set),n.get(t)}_getSheetRowVisibleHasInit(e,t){return!!(this._rowVisibleFuncSet.has(e)&&this._rowVisibleFuncSet.get(e)?.has(t))}refreshSheetRowVisibleFuncSet(e,t){let n=this._getSheetRowVisibleFuncSet(e,t);n.clear();let r=this._univerInstanceService.getUnit(e);if(r){let e=r.getSheetBySheetId(t);if(e){let t=e.getRowCount(),r=e.getRowManager();for(let i=1;i<=t;i++)e.getRowVisible(i)?r.getRowHeight(i)===0&&n.add(i):n.add(i)}}}_ensureZebraCrossingCache(e,t,n){this._zebraCrossingCacheMap.has(e)||this._zebraCrossingCacheMap.set(e,new Map);let r=this._zebraCrossingCacheMap.get(e);r.has(t)||r.set(t,new Map);let i=r.get(t);return i.has(n)||i.set(n,new glt),i.get(n)}registerRangeThemeRule(e,t){let{unitId:n,subUnitId:r,range:i}=t,a=ip(),o=this._ensureRangeThemeStyleRuleMap(n),s=this._ensureRTreeCollection(n);o.set(a,{rangeInfo:t,themeName:e}),s.insert({unitId:n,sheetId:r,range:i,id:a}),this._getSheetRowVisibleHasInit(n,r)||this.refreshSheetRowVisibleFuncSet(n,r);let c=this._ensureZebraCrossingCache(n,r,a),l=this._getSheetRowVisibleFuncSet(n,r);c.refresh(i,e=>!l.has(e))}getRegisteredRangeThemeStyle(e){let{unitId:t,subUnitId:n,range:r}=e,i=this._ensureRTreeCollection(t),a=Array.from(i.bulkSearch([{unitId:t,sheetId:n,range:r}]));if(a[0]){let e=this._ensureRangeThemeStyleRuleMap(t).get(a[0]);if(e)return e.themeName}}refreshZebraCrossingCacheBySheet(e,t){this._zebraCrossingCacheMap.has(e)||this._zebraCrossingCacheMap.set(e,new Map);let n=this._zebraCrossingCacheMap.get(e);n.has(t)||n.set(t,new Map);let r=n.get(t);r&&r.forEach((n,i)=>{let a=this._ensureRangeThemeStyleRuleMap(e).get(i);a?n.refresh(a.rangeInfo.range,n=>!this._getSheetRowVisibleFuncSet(e,t).has(n)):r.delete(i)})}removeRangeThemeRule(e,t){let{unitId:n,subUnitId:r,range:i}=t,a=this._ensureRTreeCollection(n),o=Array.from(a.bulkSearch([{unitId:n,sheetId:r,range:i}])),s=this._ensureRangeThemeStyleRuleMap(n);for(let t=0;t<o.length;t++){let c=s.get(o[t]);if(c&&c.themeName===e){s.delete(o[t]),a.remove({unitId:n,sheetId:r,range:i,id:o[t]});let e=this._zebraCrossingCacheMap.get(n);if(e){let n=e.get(r);n&&n.delete(o[t])}break}}}registerDefaultRangeTheme(e){this._defaultRangeThemeMap.set(e.getName(),e),this._rangeThemeMapChanged$.next({type:`add`,styleName:e.getName()})}unRegisterDefaultRangeTheme(e){this._defaultRangeThemeMap.delete(e),this._rangeThemeMapChanged$.next({type:`remove`,styleName:e})}getRegisteredRangeThemes(){return Array.from(this._defaultRangeThemeMap.keys())}registerRangeThemeStyle(e,t){this._ensureRangeThemeStyleMap(e).set(t.getName(),t),this._rangeThemeMapChanged$.next({type:`add`,styleName:t.getName()})}unregisterRangeThemeStyle(e,t){this._ensureRangeThemeStyleMap(e).delete(t),this._rangeThemeMapChanged$.next({type:`remove`,styleName:t})}getALLRegisteredTheme(e){return Array.from(this._ensureRangeThemeStyleMap(e).keys())}getRangeThemeStyle(e,t){return this._defaultRangeThemeMap.has(t)?this._defaultRangeThemeMap.get(t):this._ensureRangeThemeStyleMap(e).get(t)}getCellStyle(e,t,n,r){let i={startRow:n,startColumn:r,endRow:n,endColumn:r},a=this._ensureRTreeCollection(e),o=Array.from(a.bulkSearch([{unitId:e,sheetId:t,range:i}]));if(o[0]){let i=this._ensureRangeThemeStyleRuleMap(e).get(o[0]);if(i){let{rangeInfo:a,themeName:s}=i,c=n-a.range.startRow,l=r-a.range.startColumn,u=this.getRangeThemeStyle(e,s),d=this._ensureZebraCrossingCache(e,t,o[0]).getIsToggled(n);if(u)return u.getStyle(c,l,n===a.range.endRow,r===a.range.endColumn,d)}}}_registerIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(EG.CELL_CONTENT,{id:Zct,effect:Sf.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t,s=this.getCellStyle(a,o,r,i);if(s){let r=!e||e===t.rawData?{...t.rawData}:e;return r.themeStyle=s,n(r)}return n(e)}}))}toJson(e){let t=this._ensureRangeThemeStyleRuleMap(e),n=this._ensureRangeThemeStyleMap(e);if(n.size===0&&t.size===0)return`{}`;let r={};t.forEach((e,t)=>{r[t]=e});let i={};return n.forEach((e,t)=>{i[t]=e.toJson()}),JSON.stringify({rangeThemeStyleRuleMap:r,rangeThemeStyleMapJson:i})}fromJSON(e,t){let{rangeThemeStyleRuleMap:n,rangeThemeStyleMapJson:r}=t;n&&Object.keys(n).forEach(e=>{let{themeName:t,rangeInfo:r}=n[e];t.startsWith(`table`)||(this.registerRangeThemeRule(t,r),this._ensureRTreeCollection(r.unitId).insert({unitId:e,sheetId:r.subUnitId,range:r.range,id:e}))}),r&&Object.keys(r).forEach(t=>{let n=r[t],i=new LG(n.name);i.fromJson(n),this._ensureRangeThemeStyleMap(e).set(i.getName(),i)})}deleteUnitId(e){this._rangeThemeStyleMap.delete(e),this._rangeThemeStyleRuleMap.delete(e),this._rTreeCollection.delete(e)}_initSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource({toJson:e=>this.toJson(e),parseJson:e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}},businesses:[M.UNIVER_SHEET],pluginName:_lt,onLoad:(e,t)=>{this.fromJSON(e,t)},onUnLoad:e=>{this.deleteUnitId(e)}}))}dispose(){super.dispose(),this._rangeThemeStyleMap.clear(),this._rangeThemeStyleRuleMap.clear(),this._defaultRangeThemeMap.clear(),this._rTreeCollection.clear(),this._zebraCrossingCacheMap.clear(),this._rowVisibleFuncSet.clear()}};RG=AG([kG(0,j(PG)),kG(1,j(By)),kG(2,j(z))],RG);var zG={id:`sheet.mutation.set-worksheet-range-theme-style`,type:L.MUTATION,handler:(e,t)=>{if(!SG(e.get(z),t))return!1;let n=e.get(RG),{unitId:r,subUnitId:i,range:a,themeName:o}=t;return n.registerRangeThemeRule(o,{range:a,unitId:r,subUnitId:i}),!0}},vlt=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetRangeThemeStyleMutation]: worksheet is null error!`);let{worksheet:r}=n;return{unitId:t.unitId,subUnitId:r.getSheetId(),range:t.range,themeName:t.themeName}},BG={id:`sheet.mutation.remove-worksheet-range-theme-style`,type:L.MUTATION,handler:(e,t)=>{if(!SG(e.get(z),t))return!1;let n=e.get(RG),{unitId:r,subUnitId:i,range:a,themeName:o}=t;return n.removeRangeThemeRule(o,{range:a,unitId:r,subUnitId:i}),!0}},ylt=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[DeleteWorksheetRangeThemeStyleMutationFactory]: worksheet is null error!`);let{worksheet:r}=n;return{unitId:t.unitId,subUnitId:r.getSheetId(),range:t.range,themeName:t.themeName}},VG=(e,t)=>{if(!CG(e.get(z),t))throw Error(`Workbook or Worksheet not found at InsertRowMutationUndoFactory`);return{unitId:t.unitId,subUnitId:t.subUnitId,range:t.range}},HG={id:`sheet.mutation.insert-row`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or Worksheet not found at InsertRowMutation`);let{worksheet:r}=n,i=r.getRowManager(),{range:a,rowInfo:o}=t,{startRow:s,endRow:c}=a;i.insertRowsWithData(s,c,o);let l=c-s+1;return r.setRowCount(r.getRowCount()+l),r.getCellMatrix().insertRows(s,l),!0}},UG=(e,t)=>{if(!CG(e.get(z),t))throw Error(`Workbook or Worksheet not found at InsertColMutationUndoFactory`);return{unitId:t.unitId,subUnitId:t.subUnitId,range:t.range}},WG={id:`sheet.mutation.insert-col`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or Worksheet not found at InsertColMutation`);let{worksheet:r}=n,i=r.getColumnManager(),{range:a,colInfo:o}=t,{startColumn:s,endColumn:c}=a;i.insertColumnsWithData(s,c,o);let l=c-s+1;return r.setColumnCount(r.getColumnCount()+l),r.getCellMatrix().insertColumns(a.startColumn,l),!0}},GG={id:`sheet.mutation.move-range`,type:L.MUTATION,handler:(e,t)=>{let{from:n,to:r}=t;if(!n||!r)return!1;let i=e.get(z).getCurrentUnitOfType(M.UNIVER_SHEET);if(!i)return!1;let a=i.getSheetBySheetId(t.from.subUnitId),o=i.getSheetBySheetId(t.to.subUnitId);if(!a||!o)return!1;let s=a.getCellMatrix(),c=o.getCellMatrix();return new Rh(n.value).forValue((e,t,n)=>{n==null?s.realDeleteValue(e,t):s.setValue(e,t,n)}),new Rh(r.value).forValue((e,t,n)=>{n==null?c.realDeleteValue(e,t):c.setValue(e,t,n)}),!0}};function blt(e,t){let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=i.startRow>a.startRow,s=i.endRow-i.startRow+1;return o?{unitId:n,subUnitId:r,sourceRange:d_.clone(a),targetRange:{...i,endRow:i.endRow+s,startRow:i.startRow+s}}:{unitId:n,subUnitId:r,targetRange:d_.clone(i),sourceRange:{...a,endRow:a.endRow-s,startRow:a.startRow-s}}}var KG={id:`sheet.mutation.move-rows`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=e.get(z).getUniverSheetInstance(n);if(!o)throw Error(`[MoveRowMutation] univerSheet is null!`);let s=o.getSheetBySheetId(r);if(!s)throw Error(`[MoveRowMutation] worksheet is null!`);let c=i.startRow,l=i.endRow-i.startRow+1,u=a.startRow;return Fh(c,l,u,s.getRowManager().getRowData()),s.getCellMatrix().moveRows(c,l,u),!0}};function xlt(e,t){let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=i.startColumn>a.startColumn,s=i.endColumn-i.startColumn+1;return o?{unitId:n,subUnitId:r,sourceRange:d_.clone(a),targetRange:{...i,endColumn:i.endColumn+s,startColumn:i.startColumn+s}}:{unitId:n,subUnitId:r,targetRange:d_.clone(i),sourceRange:{...a,startColumn:a.startColumn-s,endColumn:a.endColumn-s}}}var qG={id:`sheet.mutation.move-columns`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=e.get(z).getUniverSheetInstance(n);if(!o)throw Error(`[MoveColumnMutation] univerSheet is null!`);let s=o.getSheetBySheetId(r);if(!s)throw Error(`[MoveColumnMutation] worksheet is null!`);let c=i.startColumn,l=i.endColumn-i.startColumn+1,u=a.startColumn;return Fh(c,l,u,s.getColumnManager().getColumnData()),s.getCellMatrix().moveColumns(c,l,u),!0}},Slt=(e,t)=>{let n=t.getRowManager().getRowData(),r={},i=e.range,a=Nh(r,Ph(i.startRow,i.endRow,n));return{unitId:e.unitId,subUnitId:e.subUnitId,range:e.range,rowInfo:a}},JG={id:`sheet.mutation.remove-rows`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(!r)return!1;let i=t.range,a=r.getRowManager().getRowData(),o=[];for(let e=i.startRow;e<=i.endRow;e++)r.getRowFiltered(e)&&o.push(e);let s=i.endRow-i.startRow+1;return Mh(i.startRow,s,a),r.getCellMatrix().removeRows(i.startRow,s),r.setRowCount(r.getRowCount()-s),!0}},Clt=(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(r==null)throw Error(`worksheet is null error!`);let i=r.getColumnManager().getColumnData(),a={},o=t.range,s=Nh(a,Ph(o.startColumn,o.endColumn,i));return{unitId:t.unitId,subUnitId:t.subUnitId,range:t.range,colInfo:s}},YG={id:`sheet.mutation.remove-col`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(!r)return!1;let i=t.range,a=r.getColumnManager().getColumnData(),o=i.endColumn-i.startColumn+1;return Mh(i.startColumn,o,a),r.setColumnCount(r.getColumnCount()-o),r.getCellMatrix().removeColumns(i.startColumn,o),!0}},XG=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or worksheet is null error!`);let{worksheet:r}=n,i=r.getConfig().mergeData,a=t.ranges,o=[];for(let e=0;e<a.length;e++)for(let t=i.length-1;t>=0;t--){let n=i[t],r=a[e];d_.intersects(n,r)&&o.push(i[t])}return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:o}},ZG={id:`sheet.mutation.remove-worksheet-merge`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or worksheet is null error!`);let{worksheet:r}=n,i=r.getConfig().mergeData,a=t.ranges;for(let e=0;e<a.length;e++)for(let t=i.length-1;t>=0;t--){let n=i[t],r=a[e];d_.intersects(n,r)&&i.splice(t,1)}return r.getSpanModel().rebuild(i),!0}},wlt=e=>{let{order:t}=e,n={};return Object.keys(t).forEach(e=>{n[t[Number(e)]]=Number(e)}),{...e,order:n}},QG={id:`sheet.mutation.reorder-range`,type:L.MUTATION,handler:(e,t)=>{let{subUnitId:n,unitId:r,range:i,order:a}=t,o=e.get(z).getUnit(r).getSheetBySheetId(n);if(!o)return!1;let s=new Rh;t_.foreach(i,(e,t)=>{if(a.hasOwnProperty(e)){let n=a[e],r=F.deepClone(o.getCellRaw(n,t));s.setValue(e,t,r)}});let c=o.getCellMatrix();return s.forValue((e,t,n)=>{c.setValue(e,t,n)}),!0}};function Tlt(e,t){if(e==null)return e;let n=F.deepClone(e);if(t==null)return n;let r={};return`h`in t&&(r.h=n.h),`ia`in t&&(r.ia=n.ia),`ah`in t&&(r.ah=n.ah),`hd`in t&&(r.hd=n.hd),`s`in t&&(r.s=n.s),`custom`in t&&(r.custom=n.custom),r}function Elt(e,t){if(e==null)return e;let n=F.deepClone(e);if(t==null)return n;let r={};return`w`in t&&(r.w=n.w),`hd`in t&&(r.hd=n.hd),`s`in t&&(r.s=n.s),`custom`in t&&(r.custom=n.custom),r}var Dlt=(e,t)=>{let{unitId:n,subUnitId:r,columnData:i}=e,a={},o=t.getColumnManager();for(let e in i){let t=i[e];a[e]=Elt(o.getColumn(Number(e)),t)}return{unitId:n,subUnitId:r,columnData:a}},$G={id:`sheet.mutation.set-col-data`,type:L.MUTATION,handler:(e,t)=>{let{columnData:n}=t,r=SG(e.get(z),t);if(!r)return!1;let{worksheet:i}=r,a=i.getColumnManager();for(let e in n){let t=n[e];if(t==null){a.removeColumn(Number(e));continue}let r=a.getColumnOrCreate(Number(e));Object.assign(r,t)}return!0}},Olt=(e,t)=>{if(e.get(z).getUniverSheetInstance(t.unitId)==null)throw Error(`universheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:t.ranges}},eK={id:`sheet.mutation.set-col-hidden`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(!n)return!1;let r=n.getSheetBySheetId(t.subUnitId).getColumnManager();for(let e=0;e<t.ranges.length;e++){let n=t.ranges[e];for(let e=n.startColumn;e<n.endColumn+1;e++){let t=r.getColumnOrCreate(e);t!=null&&(t.hd=Np.TRUE)}}return!0}},klt=(e,t)=>{if(e.get(z).getUniverSheetInstance(t.unitId)==null)throw Error(`universheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:t.ranges}},tK={id:`sheet.mutation.set-col-visible`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(!n)return!1;let r=n.getSheetBySheetId(t.subUnitId).getColumnManager();for(let e=0;e<t.ranges.length;e++){let n=t.ranges[e];for(let e=n.startColumn;e<n.endColumn+1;e++){let t=r.getColumnOrCreate(e);t!=null&&(t.hd=Np.FALSE)}}return!0}},nK={id:`sheet.mutation.set-gridlines-color`,type:L.MUTATION,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{worksheet:r}=n,i=r.getConfig();return i.gridlinesColor=t.color,!0}};function rK(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iK(e,t,n){for(let r of t)Object.prototype.hasOwnProperty.call(e,r)&&n(r,e[r])}function aK(e,t,n){if(e==null)return e;if(!rK(e))return;let r={},i=!1;if(iK(e,t,(e,t)=>{r[e]=t,i=!0}),n)for(let t in n){let a=n[t];if(!a||!Object.prototype.hasOwnProperty.call(e,t))continue;let o=a(e[t]);o!==void 0&&(r[t]=o,i=!0)}return i?r:void 0}function Alt(e,t,n){if(e==null)return e;if(!rK(e))return;let r={},i=!1;return iK(e,t,(e,t)=>{let a=n(t);a!==void 0&&(r[e]=a,i=!0)}),i?r:void 0}function jlt(e){switch(e){case`bd`:case`tr`:case`td`:case`ht`:case`vt`:case`tb`:case`pd`:case`bg`:return!0;default:return!1}}function Mlt(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function oK(e){return aK(e,pm)}function Nlt(e){return aK(e,fm,{cl:oK})}function Plt(e){return aK(e,mm,{cl:oK})}function Flt(e){return Alt(e,hm,Plt)}function Ilt(e){return aK(e,gm)}function Llt(e){return aK(e,_m)}function Rlt(e){if(e==null)return e;if(rK(e)&&Object.prototype.hasOwnProperty.call(e,`pattern`)&&typeof e.pattern==`string`)return{pattern:e.pattern}}function zlt(e,t){switch(e){case`ul`:case`bbl`:case`st`:case`ol`:return Nlt(t);case`bg`:case`cl`:return oK(t);case`bd`:return Flt(t);case`tr`:return Ilt(t);case`pd`:return Llt(t);case`n`:return Rlt(t);default:return Mlt(t)?t:void 0}}function Blt(e,t){if(t===null)return null;if(t===void 0)return e;let n=t,r=F.isObject(e)?{...e}:{};return iK(n,hm,(e,t)=>{let n=Plt(t);n!==void 0&&(r[e]=n)}),r}function Vlt(e,t,n){let r=e.getStyleByCell(t);r??delete t.s,typeof n.s==`string`&&(n.s=e.get(n.s));let i=sK(r,n.s?n.s:null);i&&(F.removeNull(i),Object.entries(i).forEach(([e,t])=>{typeof t==`object`&&t&&Object.keys(t).length===0&&delete i[e]})),F.isEmptyObject(i)?delete t.s:t.s=e.setValue(i);let a=n.v?`${n.v}\r\n`:``;!n.p&&t.p&&(a&&a!==t.p.body?.dataStream?delete t.p:Glt(t.p,n.s?n.s:null))}function Hlt(e,t){if(!t||!Object.keys(t).length)return e;let n=F.deepClone(e??{})||{},r=t;for(let e of vm){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=zlt(e,r[e]);t!==void 0&&(e===`bd`?n[e]=Ult(n[e]||{},t):e in n||(n[e]=null))}return n}function Ult(e,t){if(!t||!Object.keys(t).length)return e;let n=e;for(let r of hm)Object.prototype.hasOwnProperty.call(t,r)&&(r in e||(n[r]=null));return e}function sK(e,t,n=!1){if(t===null)return t;if(t===void 0)return e;let r=F.deepClone(e)||{},i=t;for(let e of vm){if(!Object.prototype.hasOwnProperty.call(i,e)||n&&jlt(e))continue;let t=zlt(e,i[e]);t!==void 0&&(r[e]=e===`bd`?Blt(r[e],t):t)}if(`cl`in r){let e=r,t=e.cl;`ul`in e&&e.ul&&(e.ul.cl=t),`ol`in e&&e.ol&&(e.ol.cl=t),`st`in e&&e.st&&(e.st.cl=t)}return r}function Wlt(e,t){return e.some(e=>e.startIndex===t)?Wlt(e,t+1):t}function Glt(e,t){if(e.body==null)return;Array.isArray(e.body.textRuns)||(e.body.textRuns=[]);let n=0,r=[],i=e.body?.paragraphs||[];for(let a of e.body.textRuns){let{st:e,ed:o,ts:s={}}=a;if(n<e){let i={st:n,ed:e},a=sK({},t,!0);a&&F.removeNull(a),F.isEmptyObject(a)||(i.ts=a),r.push(i)}let c=sK(s,t,!0);c&&F.removeNull(c),F.isEmptyObject(c)?delete a.ts:a.ts=c,r.push(a),n=Wlt(i,o)}let a=e.body.dataStream.endsWith(`\r
|
|
593
|
+
`})}function aW(e){return(0,H.jsx)(`div`,{className:`univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1`,children:e.children})}function oW(e){return(0,H.jsx)(fj,{title:e.title,placement:`bottom`,children:(0,H.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:W(`univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":e.active}),children:e.children})})}function sW(){return(0,H.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`1em`,height:`1em`,fill:`none`,"aria-hidden":`true`,children:[(0,H.jsx)(`path`,{d:`M2.5 4.5H8.2`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M11.8 4.5H17.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M2.5 10H5.7`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M14.3 10H17.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M2.5 15.5H8.2`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M11.8 15.5H17.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),(0,H.jsx)(`rect`,{x:`6.8`,y:`7`,width:`6.4`,height:`6`,rx:`1`,stroke:`currentColor`,strokeWidth:`1.4`})]})}function $at(){return(0,H.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`1em`,height:`1em`,fill:`none`,"aria-hidden":`true`,children:[(0,H.jsx)(`path`,{d:`M5 2.8V12.5C5 13.9 6.1 15 7.5 15H17.2`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M2.8 5H12.5C13.9 5 15 6.1 15 7.5V17.2`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M8.3 8.3H11.7V11.7H8.3V8.3Z`,stroke:`currentColor`,strokeWidth:`1.2`})]})}function eot(e){let[t,n]=(0,V.useState)(!1),r=e.options.find(t=>t.value===e.value)??e.options[0];return(0,H.jsx)(oj,{open:t,onOpenChange:n,overlay:(0,H.jsx)(`div`,{className:`univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,children:e.options.map(t=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{e.onChange(t.value),n(!1)},className:W(`univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800`,{"univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300":t.value===e.value}),children:[(0,H.jsx)(`span`,{className:`univer-flex univer-size-4 univer-items-center univer-justify-center`,children:t.icon}),(0,H.jsx)(`span`,{className:`univer-flex-1`,children:t.label})]},t.value))}),children:(0,H.jsx)(`span`,{children:(0,H.jsx)(fj,{title:e.title,placement:`bottom`,children:(0,H.jsxs)(`button`,{type:`button`,className:W(`univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":t}),children:[r.icon,(0,H.jsx)(ID,{className:`univer-text-xs`})]})})})})}function tot(e){let t=U(R),n=U(nx),r=U(z).getUnit(e.unitId,M.UNIVER_DOC)??void 0,[i,a]=(0,V.useState)(()=>Zat(r,e.drawingId)),[o,s]=(0,V.useState)(!1),c=t=>e.menuItems.find(e=>e.label===t),l=c(`drawing-ui.image-popup.edit`),u=c(`drawing-ui.image-popup.crop`),d=c(`drawing-ui.image-popup.delete`),f=[{label:n.t(`drawing-ui.image-text-wrap.inline`),value:`inline`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.square`),value:`wrapSquare`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.topAndBottom`),value:`wrapTopAndBottom`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.behindText`),value:`behindText`,icon:(0,H.jsx)(sW,{})},{label:n.t(`drawing-ui.image-text-wrap.inFrontText`),value:`inFrontOfText`,icon:(0,H.jsx)(sW,{})}],p=e=>{e&&!e.disable&&t.executeCommand(e.commandId,e.commandParams)};return o?null:(0,H.jsxs)(`div`,{"data-u-comp":`doc-image-floating-toolbar`,onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},className:W(`univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,qA),children:[(0,H.jsx)(aW,{children:(0,H.jsx)(eot,{title:f.find(e=>e.value===i)?.label??n.t(`drawing-ui.image-text-wrap.inline`),value:i,options:f,onChange:n=>{a(n),t.executeCommand(Xat,{unitId:e.unitId,subUnitId:e.subUnitId,drawings:[{unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}],wrappingStyle:n})}})}),(0,H.jsx)(Qat,{}),(0,H.jsxs)(aW,{children:[(0,H.jsx)(oW,{title:l?n.t(l.label):n.t(`drawing-ui.image-popup.edit`),disabled:!l||l.disable,onClick:()=>{s(!0),p(l)},children:(0,H.jsx)(xD,{})}),(0,H.jsx)(oW,{title:u?n.t(u.label):n.t(`drawing-ui.image-popup.crop`),disabled:!u||u.disable,onClick:()=>p(u),children:(0,H.jsx)($at,{})})]}),(0,H.jsx)(Qat,{}),(0,H.jsx)(aW,{children:(0,H.jsx)(oW,{title:d?n.t(d.label):n.t(`drawing-ui.image-popup.delete`),disabled:!d||d.disable,onClick:()=>p(d),children:(0,H.jsx)(yD,{})})})]})}function cW(e,t){return function(n,r){t(n,r,e)}}function lW(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var uW=class extends P{constructor(e,t,n){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._init()}_init(){this._initMenus(),this._initCommands(),this._initComponents()}_initMenus(){this._menuManagerService.mergeMenu(Jat)}_initCommands(){[QU,$U,tW,FU,IU,LU,RU,zU,BU,VU,HU,UU,eW,XU,ZU,WU,GU,KU,qU,JU].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initComponents(){[[iW,Yat],[`BottomIcon`,WAe],[`GroupIcon`,dMe],[`MoveDownIcon`,rNe],[`MoveUpIcon`,aNe],[`TopmostIcon`,iPe],[`UngroupIcon`,fPe]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};uW=lW([cW(0,j(Nj)),cW(1,R),cW(2,_M)],uW);function dW(e,t){let n=[];return e.forEach(e=>{let{oKey:r,left:i,top:a,height:o,width:s,angle:c}=e,l=t.getDrawingOKey(r);if(l==null)return n.push(null),!0;let{unitId:u,subUnitId:d,drawingId:f,drawingType:p}=l,m={unitId:u,subUnitId:d,drawingId:f,drawingType:p,transform:{left:i,top:a,height:o,width:s,angle:c}};p===um.DRAWING_IMAGE&&(m.srcRect=e.srcRect),n.push(m)}),n}function fW(e){"@babel/helpers - typeof";return fW=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},fW(e)}function not(e,t){if(fW(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(fW(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function rot(e){var t=not(e,`string`);return fW(t)==`symbol`?t:t+``}function pW(e,t,n){return(t=rot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mW=class extends P{constructor(e,t,n,r){super(),this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._drawingManagerService=r,pW(this,`_sceneListenerOnDrawingMap`,new WeakSet),this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){let e=this._drawingManagerService.drawingManagerData,t=Sat(this._currentUniverService);if(t==null)return;let{unitId:n,subUnitId:r}=t;Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(i=>{let a=e[t][i].data;a!=null&&t===n&&i===r&&Object.keys(a).forEach(e=>{a[e]&&this._insertDrawing([{unitId:t,subUnitId:i,drawingId:e}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===FU.id){let t=e.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(e=>{this._groupDrawings(e)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(e=>{this._ungroupDrawings(e)}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e)?.scene;return t==null?null:{scene:t,transformer:t.getTransformerByCreate()}}_groupDrawings(e){e.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;let{scene:s,transformer:c}=o;this._commandService.syncExecuteCommand($U.id);let l=[];if(n.forEach(e=>{let t=ON(e),n=s.getObjectIncludeInGroup(t);if(n==null||l.includes(n))return;l.push(n);let{transform:r}=e;r!=null&&(n.classType===yw.GROUP?n.transformByState({left:r.left,top:r.top}):n.transformByState(r))}),l.length===0)return;let u=new Dke(ON({unitId:r,subUnitId:i,drawingId:a}));s.addObject(u,4).attachTransformerTo(u),u.addObjects(...l),t.groupBaseBound&&u.setBaseBound(t.groupBaseBound),t.groupId&&(u.isInGroup=!0,nW({drawingId:t.groupId,unitId:r,subUnitId:i},u,s,this._drawingManagerService)),t.transform&&u.transformByState({left:t.transform.left,top:t.transform.top,width:t.transform.width,height:t.transform.height,angle:t.transform.angle}),c.clearSelectedObjects(),c.setSelectedControl(u)}_ungroupDrawings(e){e.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(e){let{parent:t,children:n}=e,r=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(r==null)return;let{scene:i,transformer:a}=r;n.forEach(e=>{let t=ON(e),n=i.getObjectIncludeInGroup(t);if(n==null)return!0;if(n==null)return;let{transform:r}=e;r!=null&&(n.classType===yw.GROUP?n.transformByState({left:r.left,top:r.top}):n.transformByState(r))});let o=ON(t),s=i.getObject(o),{width:c,height:l}=s;s.getObjects().forEach(e=>{s.removeSelfObjectAndTransform(e.oKey,c,l)}),s.dispose(),a.clearSelectedObjects()}_drawingAlign(e){let{alignType:t}=e,n=e.drawings||this._drawingManagerService.getFocusDrawings();if(t===`0`)return;let r=[],i=1/0,a=1/0,o=-1/0,s=-1/0,c=0;n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:l,drawingType:u}=e,d=this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:l});if(d==null||d.transform==null)return;r.push({unitId:t,subUnitId:n,drawingId:l,drawingType:u,transform:d.transform});let{left:f=0,top:p=0,width:m=0,height:h=0}=d.transform;i=Math.min(i,f),a=Math.min(a,p),o=Math.max(o,f+m),s=Math.max(s,p+h),c++}),c!==0&&(this._sortDrawingTransform(r,t),this._applyAlignType(r,t,i,a,o,s,c))}_applyAlignType(e,t,n,r,i,a,o){let s=Math.round((i-n)/o*10)/10,c=Math.round((a-r)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(e[0].unitId);if(u==null)return;let{scene:d,transformer:f}=u;e.forEach((e,o)=>{let{unitId:u,subUnitId:d,drawingId:f,transform:p,drawingType:m}=e,{left:h=0,top:g=0,width:_=0,height:v=0}=p,y=h,b=g;switch(t){case`1`:y=n;break;case`2`:y=n+(i-n)/2-_/2;break;case`3`:y=i-_;break;case`4`:b=r;break;case`5`:b=r+(a-r)/2-v/2;break;case`6`:b=a-v;break;case`7`:y=n+s*o;break;case`8`:b=r+c*o}(y!==h||b!==g)&&l.push({unitId:u,subUnitId:d,drawingId:f,drawingType:m,transform:{left:y,top:b}})}),this._drawingManagerService.featurePluginUpdateNotification(l),f.refreshControls().changeNotification()}_sortDrawingTransform(e,t){e.sort((e,n)=>{let r=e.transform,i=n.transform,{left:a=0,top:o=0,width:s=0,height:c=0}=r,{left:l=0,top:u=0,width:d=0,height:f=0}=i;switch(t){case`1`:return a-l;case`2`:return a+s/2-(l+d/2);case`3`:return a+s-(l+d);case`4`:return o-u;case`5`:return o+c/2-(u+f/2);case`6`:return o+c-(u+f);case`7`:return a+s/2-(l+d/2);case`8`:return o+c/2-(u+f/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(e=>{this._drawingArrange(e)}))}_drawingArrange(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let{scene:a}=i;r.forEach(e=>{let r=ON({unitId:t,subUnitId:n,drawingId:e}),i=a.fuzzyMathObjects(r,!0);if(i==null||i.length===0)return;let o=this._drawingManagerService.getDrawingOrder(t,n).indexOf(e);for(let e of i)e.setProps({zIndex:o}),e.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertDrawing(e)}))}_insertDrawing(e){let t=[];e.forEach(e=>{let{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;let r=this._getSceneAndTransformerByDrawingSearch(n);if(r==null)return;let{scene:i}=r;t.includes(i)||t.push(i)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let{scene:a}=i,o=ON({unitId:t,subUnitId:n,drawingId:r}),s=a.fuzzyMathObjects(o,!0);if(s.length>0){var c;for(let e of s)e.dispose();(c=a.getTransformer())==null||c.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var t;let{unitId:n,subUnitId:r,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o,drawingType:s}=a,c=this._getSceneAndTransformerByDrawingSearch(n);if(c==null)return;let{scene:l,transformer:u}=c;if(o==null)return!0;let{left:d=0,top:f=0,width:p=0,height:m=0,angle:h=0,flipX:g=!1,flipY:_=!1,skewX:v=0,skewY:y=0}=o,b=ON({unitId:n,subUnitId:r,drawingId:i}),x=l.getObject(b);if(x==null)return!0;x.transformByState({left:d,top:f,width:p,height:m,angle:h,flipX:g,flipY:_,skewX:v,skewY:y}),(t=l.getTransformer())==null||t.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o}=a,{scene:s}=i,c=ON({unitId:t,subUnitId:n,drawingId:r}),l=s.getObject(c);if(l==null||o==null)return!0;let{left:u=0,top:d=0,width:f=0,height:p=0,angle:m=0,flipX:h=!1,flipY:g=!1,skewX:_=0,skewY:v=0}=o;l.transformByState({left:u,top:d,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r,visible:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;let{scene:o}=a,s=ON({unitId:t,subUnitId:n,drawingId:r}),c=o.getObject(s);if(c==null)return!0;i?c.show():c.hide()})}))}_filterUpdateParams(e,t){return e.filter((e,n)=>{if(e==null)return!1;let{transform:r}=e;return th(r,t?.[n])})}_addListenerOnDrawing(e){let t=e.getTransformerByCreate(),n=null;this.disposeWithMe(Wf(t.changeStart$.subscribe(e=>{let{objects:t}=e,r=Array.from(t.values()),i=[];n=r.map(e=>{let{left:t,top:n,height:r,width:a,angle:o,oKey:s,isInGroup:c}=e,l=this._drawingManagerService.getDrawingOKey(s);if(c||e instanceof IE){let t=e.ancestorGroup;if(t==null&&e instanceof IE&&(t=e),t==null)return null;let n=this._drawingManagerService.getDrawingOKey(t.oKey);if(n){let{unitId:e,subUnitId:r,drawingId:a}=n;i.push({unitId:e,subUnitId:r,drawingId:a});let{left:o,top:s,height:c,width:l,angle:u}=t;return{left:o,top:s,height:c,width:l,angle:u}}}else if(l!=null){let{unitId:e,subUnitId:s,drawingId:c}=l;return i.push({unitId:e,subUnitId:s,drawingId:c}),{left:t,top:n,height:r,width:a,angle:o}}return null}).filter(e=>e!=null),i.length>0?this._commandService.syncExecuteCommand(SN.id,i):this._commandService.syncExecuteCommand(SN.id,[])}))),this.disposeWithMe(Wf(t.changeEnd$.subscribe(e=>{let{objects:t}=e,r=this._filterUpdateParams(dW(t,this._drawingManagerService),n);r.length>0&&this._drawingManagerService.featurePluginUpdateNotification(r)})))}};mW=lW([cW(0,z),cW(1,R),cW(2,KE),cW(3,xN)],mW);var hW=class extends wT{constructor(e,t){t??={},t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:`rgb(0, 0, 0)`,anchorStroke:`rgb(255, 255, 255)`,anchorSize:24},super(e,t),pW(this,`_srcRect`,void 0),pW(this,`_prstGeom`,void 0),pW(this,`_applyTransform`,void 0),pW(this,`_dragPadding`,8),pW(this,`_cacheCanvas`,void 0),t?.srcRect&&(this._srcRect=t.srcRect),t?.prstGeom&&(this._prstGeom=t.prstGeom),t?.applyTransform&&(this._applyTransform=t.applyTransform),t?.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){let t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){let t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var t;let{width:n,height:r}=this.getScene().getEngine();this._initialCacheCanvas(),(t=this._cacheCanvas)==null||t.clear();let i=this._cacheCanvas?.getContext();i!=null&&(i.save(),OE.drawWith(i,{left:0,top:0,width:n,height:r,fill:`rgba(0, 0, 0, 0.5)`}),i.setTransform(e.getTransform()),this._clipForApplyObject(i),this._applyCache(e),i.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation=`destination-out`,e.beginPath(),t===0){let t=this.transform.getMatrix();e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,r=0,{left:i=0,top:a=0,width:o=0,height:s=0,angle:c}=this._applyTransform;if(this._srcRect!=null){let{left:i=0,top:a=0,right:o=0,bottom:s=0}=this._srcRect;e=i,t=a,n=o,r=s}let l=i+e,u=a+t;this.transformByState({left:l,top:u,width:i+o-n-l,height:a+s-r-u,angle:c})}_applyCache(e){if(!e||this._cacheCanvas==null)return;let t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;let e=this.getScene();if(e==null)return;this._cacheCanvas=new rT;let t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var e;(e=this._cacheCanvas)==null||e.setSize(t.width,t.height),this.makeDirty(!0)})}},gW=class extends P{constructor(e,t,n,r,i,a){super(),this._commandService=e,this._drawingManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._messageService=i,this._localeService=a,pW(this,`_sceneListenerOnImageMap`,new WeakSet),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==eW.id)return;let t=e.params;if(t==null)return;let{cropType:n}=t,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;let{unitId:i,subUnitId:a,drawingId:o}=r[0],s=this._renderManagerService.getRenderById(i)?.scene;if(s==null)return!0;this._searchCropObject(s)!=null&&this._commandService.syncExecuteCommand($U.id,{isAuto:!0});let c=ON({unitId:i,subUnitId:a,drawingId:o}),l=s.getObject(c);if(!(l instanceof kE)){this._messageService.show({type:pj.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}l!=null&&(this._updateCropperObject(n,l),this._commandService.executeCommand(QU.id,{unitId:i,subUnitId:a,drawingId:o}))}))}_calculateSrcRectByRatio(e,t,n,r,i,a){let o=n/r,s=i/a,c=n,l=r;o>s?c=r*s:l=n/s;let u=(n-c)/2,d=(r-l)/2;return{left:Tw(u,1),top:Tw(d,1),right:Tw(n-(u+c),1),bottom:Tw(r-(d+l),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case`1`:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case`2`:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case`3`:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case`4`:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case`5`:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case`6`:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case`7`:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case`8`:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case`9`:o=this._calculateSrcRectByRatio(n,r,i,a,2,3)}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==QU.id)return;let t=e.params;if(t==null)return;let{unitId:n,subUnitId:r,drawingId:i}=t,a=this._renderManagerService.getRenderById(n)?.scene;if(a==null)return!0;if(this._sceneListenerOnImageMap.has(a)||(this._addListenerOnImage(a),this._sceneListenerOnImageMap.add(a)),this._drawingManagerService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:i})==null)return;let o=ON({unitId:n,subUnitId:r,drawingId:i}),s=a.getObject(o);if(s==null)return;if(!(s instanceof kE)){this._messageService.show({type:pj.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}let c=a.getTransformer();c?.clearControls();let l=new hW(`${o}-crop`,{srcRect:s.srcRect,prstGeom:s.prstGeom,applyTransform:s.calculateTransformWithSrcRect()});a.addObject(l,s.getLayerIndex()+1).attachTransformerTo(l),c?.createControlForCopper(l),this._addHoverForImageCopper(l),s.openRenderByCropper(),c?.refreshControls(),l.makeDirty(!0),this._commandService.syncExecuteCommand(SN.id,[{unitId:n,subUnitId:r,drawingId:i}])}))}_searchCropObject(e){let t=e.getAllObjectsByOrder();for(let e of t)if(e instanceof hW)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==$U.id)return;let t=this._univerInstanceService.getFocusedUnit();if(t==null)return;let n=t.getUnitId(),r=this._renderManagerService.getRenderById(n)?.scene;if(r==null)return!0;let i=this._searchCropObject(r);if(i==null)return;let a=this._getApplyObjectByCropObject(i);if(a==null)return;let o=r.getTransformerByCreate();o.detachFrom(i),o.clearCopperControl();let s=this._getSrcRectByTransformState(a,i),c=this._drawingManagerService.getDrawingOKey(a.oKey);if(c!=null){let{left:e,top:t,height:n,width:r}=i;this._drawingManagerService.featurePluginUpdateNotification([{...c,transform:{...c.transform,left:e,top:t,height:n,width:r},srcRect:s.srcRectAngle}])}a.setSrcRect({...s.srcRectAngle}),a.closeRenderByCropper(),a.makeDirty(!0),i?.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_SHEET).pipe(sc(e=>e?e.activeSheet$:ts(null)));this.disposeWithMe(e.subscribe(()=>{this._commandService.syncExecuteCommand($U.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey,n=t.slice(0,t.length-5),r=e.getScene();return r?r.getObject(n)??null:null}_addListenerOnImage(e){let t=e.getTransformerByCreate(),n=null;this.disposeWithMe(t.changeStart$.subscribe(e=>{let{objects:r}=e,i=r.values().next().value;if(i==null||!(i instanceof hW))return;let{left:a,top:o,height:s,width:c,angle:l}=i;n={left:a,top:o,height:s,width:c,angle:l},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(e=>{let{objects:r}=e,i=r.values().next().value;if(i==null||!(i instanceof hW))return;let{left:a,top:o,height:s,width:c,angle:l}=i;if(!th({left:a,top:o,height:s,width:c,angle:l},n))return;let u=this._getApplyObjectByCropObject(i);if(u==null)return;let d=this._getSrcRectByTransformState(u,i);i.refreshSrcRect(d.srcRect,u.getState()),t.createControlForCopper(i)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=_w.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=_w.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand($U.id)}))}_getSrcRectByTransformState(e,t){let{left:n,top:r,height:i,width:a,strokeWidth:o,angle:s}=t,{left:c,top:l,width:u,height:d,angle:f,strokeWidth:p}=e,m=n-c,h=r-l,g={left:m,top:h,right:u-m-a,bottom:d-h-i},_={...g};if(f!==0){let e=new zw(n+a/2,r+i/2),t=new zw(u/2+c,d/2+l),o=new zw(c,l);o.rotateByPoint(ww(f),t);let s=o.clone();s.rotateByPoint(ww(-f),e);let p=n-s.x,m=r-s.y;_.left=p,_.top=m,_.right=u-p-a,_.bottom=d-m-i}return{srcRect:g,srcRectAngle:_}}};gW=lW([cW(0,R),cW(1,xN),cW(2,KE),cW(3,z),cW(4,eM),cW(5,j(nx))],gW);var _W=class extends P{constructor(){super(),pW(this,`_clipDelegate`,null),pW(this,`_canUseShapeClip$`,new so(!1)),pW(this,`canUseShapeClip$`,this._canUseShapeClip$.asObservable())}setCanUseShapeClip(e){this._canUseShapeClip$.next(e)}registerClipDelegate(e){return this._clipDelegate=e,Wf(()=>{this._clipDelegate===e&&(this._clipDelegate=null)})}applyShapeClip(e,t,n,r,i){return this._clipDelegate?this._clipDelegate(e,t,n,r,i):!1}dispose(){this._clipDelegate=null,this._canUseShapeClip$.complete(),super.dispose()}},vW=class{constructor(e,t,n,r,i,a){this._drawingManagerService=e,this._imageIoService=t,this._galleryService=n,this._urlImageService=r,this._univerInstanceService=i,this._drawingImageClipService=a}async renderImages(e,t){let{transform:n,drawingType:r,source:i,imageSourceType:a,srcRect:o,prstGeom:s,groupId:c,unitId:l,subUnitId:u,drawingId:d,isMultiTransform:f,transforms:p,adjustValues:m,hidden:h}=e;if(r!==um.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||this._univerInstanceService.getUnitType(l)===M.UNIVER_SHEET&&u!==this._getActiveSheetId()||n==null)return;let g=f&&p?p:[n],_=[];for(let e of g){let{left:n,top:r,width:p,height:v,angle:y,flipX:b,flipY:x,skewX:S,skewY:C}=e,w=g.indexOf(e),T=ON({unitId:l,subUnitId:u,drawingId:d},f?w:void 0),E=t.getObject(T);if(E!=null){E.transformByState({left:n,top:r,width:p,height:v,angle:y,flipX:b,flipY:x,skewX:S,skewY:C});continue}let D=this._drawingManagerService.getDrawingOrder(l,u),O=D.indexOf(d),k={...e,zIndex:O===-1?D.length-1:O},A=this._imageIoService.getImageSourceCache(i,a),ee=!1;if(A!=null)k.image=A;else if(a===cb.UUID)try{k.url=await this._imageIoService.getImage(i)}catch(e){console.error(e);continue}else if(a===cb.URL){try{k.url=await this._urlImageService.getImage(i)}catch(e){console.error(e),k.url=i}ee=!0}else k.url=i,ee=!0;if(h&&(k.visible=!1),t.getObject(T))continue;k.printable=!0;let te=new kE(T,k);te.setClipService(this._drawingImageClipService),ee&&this._imageIoService.addImageSourceCache(i,a,te.getNative()),t.addObject(te,4),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(te),c&&nW({drawingId:c,unitId:l,subUnitId:u},te,t,this._drawingManagerService),s!=null&&te.setPrstGeom(s),m!=null&&te.setPrstGeomAdjValues(m),o!=null&&te.setSrcRect(o),_.push(te)}return _}_getActiveSheetId(){var e;return(e=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET))==null||(e=e.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(e,t){let{transform:n,drawingType:r,groupId:i,unitId:a,subUnitId:o,drawingId:s,isMultiTransform:c,transforms:l}=e;if(r!==um.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||n==null)return;let u=c&&l?l:[n],d=[];for(let n of u){let{left:r,top:l,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v}=n,y=u.indexOf(n),b=ON({unitId:a,subUnitId:o,drawingId:s},c?y:void 0),x=t.getObject(b);if(x!=null){x.transformByState({left:r,top:l,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v});continue}let S=this._drawingManagerService.getDrawingOrder(a,o),C=S.indexOf(s),w={...n,zIndex:C===-1?S.length-1:C};if(t.getObject(b))continue;w.printable=!1;let T=new OE(b,w);this._drawingManagerService.getDrawingVisible()&&(t.addObject(T,4),this._drawingManagerService.getDrawingEditable()&&e.allowTransform!==!1&&t.attachTransformerTo(T),i&&nW({drawingId:i,unitId:a,subUnitId:o},T,t,this._drawingManagerService),d.push(T))}return d}renderDrawing(e,t){let n=this._drawingManagerService.getDrawingByParam(e);if(n!=null)switch(n.drawingType){case um.DRAWING_IMAGE:return this.renderImages(n,t)}}previewImage(e,t,n,r){this._galleryService.open({images:[t],onOpenChange:e=>{e||this._galleryService.close()}})}_adjustImageSize(e,t,n,r){if(e<=n&&t<=r)return{width:e,height:t};let i=n/e,a=r/t,o=Math.min(i,a);return{width:Math.floor(e*o),height:Math.floor(t*o)}}};vW=lW([cW(0,xN),cW(1,ub),cW(2,lN),cW(3,db),cW(4,z),cW(5,j(_W))],vW);var yW=class extends P{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=r,this._imageIoService=i,this._currentUniverService=a,this._drawingRenderService=o,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===tW.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e)?.scene;return t==null?null:{scene:t,transformer:t.getTransformerByCreate()}}_resetImageSize(e){let t=[],n=[];e.forEach(e=>{let{unitId:r,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;let{scene:s}=o,c=ON({unitId:r,subUnitId:i,drawingId:a}),l=s.getObject(c);if(l==null)return!0;let u=this._drawingManagerService.getDrawingByParam(e);if(u==null)return!0;if(u.drawingType!==um.DRAWING_IMAGE)return;l.resetSize();let{width:d,height:f}=l.getNativeSize();n.includes(s)===!1&&n.push(s),t.push({...u,transform:{...u.transform,height:f,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(SN.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe(Bs(33),Ls(e=>e.length>0),os(e=>e.flat()),os(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),Ls(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{let{unitId:t,subUnitId:n}=e,r=this._getSceneAndTransformerByDrawingSearch(t),i=Sat(this._currentUniverService,t)?.subUnitId;if(r==null||i!==n)return;let a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let o=await this._drawingRenderService.renderImages(a,r.scene);if(this._drawingManagerService.refreshTransform([a]),o!=null&&o.length!==0)for(let e of o)this._addHoverForImage(e),this._addDialogForImage(e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._drawingManagerService.getDrawingByParam(e);if(i==null)return;let{transform:a,drawingType:o,srcRect:s,prstGeom:c,source:l,imageSourceType:u}=i;if(o!==um.DRAWING_IMAGE)return;let d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;let{scene:f,transformer:p}=d;if(a==null)return!0;let m=ON({unitId:t,subUnitId:n,drawingId:r}),h=f.getObject(m);if(h==null)return!0;h.setSrcRect(s),h.setPrstGeom(c),l!=null&&l.length>0&&(u===cb.BASE64||u===cb.URL)&&h.changeSource(l)})}))}_addHoverForImage(e){this.disposeWithMe(Wf(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=_w.GRAB}))),this.disposeWithMe(Wf(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=_w.DEFAULT})))}_addDialogForImage(e){this.disposeWithMe(Wf(e.onDblclick$.subscribeEvent(()=>{let t=`${e.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,e.getNative().src,e.getNativeSize().width,e.getNativeSize().height)})))}};yW=lW([cW(0,R),cW(1,KE),cW(2,xN),cW(3,sN),cW(4,ub),cW(5,z),cW(6,j(vW))],yW);var bW=class extends dx{constructor(e=Eat,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=Qi({},Eat,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(Tat,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(mW),this._injector.get(uW),this._injector.get(gW),this._injector.get(yW)}_initDependencies(){[[_W],[vW],[mW],[uW],[gW],[yW]].forEach(e=>this._injector.add(e))}};pW(bW,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),pW(bW,`packageName`,Cat),pW(bW,`version`,wat),bW=lW([cW(1,j(We)),cW(2,Nm)],bW);var iot=e=>{let t=U(R),n=U(nx),{drawings:r,alignShow:i}=e,[a,o]=(0,V.useState)(`0`),s=[{label:n.t(`drawing-ui.image-panel.align.default`),value:`0`},{options:[{label:n.t(`drawing-ui.image-panel.align.left`),value:`1`},{label:n.t(`drawing-ui.image-panel.align.center`),value:`2`},{label:n.t(`drawing-ui.image-panel.align.right`),value:`3`}]},{options:[{label:n.t(`drawing-ui.image-panel.align.top`),value:`4`},{label:n.t(`drawing-ui.image-panel.align.middle`),value:`5`},{label:n.t(`drawing-ui.image-panel.align.bottom`),value:`6`}]},{options:[{label:n.t(`drawing-ui.image-panel.align.horizon`),value:`7`},{label:n.t(`drawing-ui.image-panel.align.vertical`),value:`8`}]}];function c(e){o(e),t.executeCommand(FU.id,{alignType:e,drawings:r})}return(0,H.jsxs)(`div`,{className:W(`univer-relative univer-w-full`,{"univer-hidden":!i}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`drawing-ui.image-panel.align.title`)})}),(0,H.jsx)(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:(0,H.jsx)(`div`,{className:`univer-w-full univer-text-gray-900 dark:!univer-text-white`,children:(0,H.jsx)(bj,{value:a,options:s,onChange:c})})})]})},aot=e=>{let{arrangeShow:t,drawings:n}=e,r=U(nx),i=U(xN),a=U(R),o=U(Nj),s=o.get(`MoveUpIcon`),c=o.get(`MoveDownIcon`),l=o.get(`TopmostIcon`),u=o.get(`BottomIcon`),[d,f]=(0,V.useState)(n);(0,V.useEffect)(()=>{let e=i.focus$.subscribe(e=>{f(e)});return()=>{e.unsubscribe()}},[]);let p=e=>{a.syncExecuteCommand(WU.id,{arrangeType:e,drawings:d})};return(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!t}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.arrange.title`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[(0,H.jsxs)(HA,{onClick:()=>{p(lm.forward)},children:[(0,H.jsx)(s,{}),r.t(`drawing-ui.image-panel.arrange.forward`)]}),(0,H.jsxs)(HA,{onClick:()=>{p(lm.backward)},children:[(0,H.jsx)(c,{}),r.t(`drawing-ui.image-panel.arrange.backward`)]}),(0,H.jsxs)(HA,{onClick:()=>{p(lm.front)},children:[(0,H.jsx)(l,{}),r.t(`drawing-ui.image-panel.arrange.front`)]}),(0,H.jsxs)(HA,{onClick:()=>{p(lm.back)},children:[(0,H.jsx)(u,{}),r.t(`drawing-ui.image-panel.arrange.back`)]})]})]})},oot=e=>{let t=U(nx),n=U(KE),r=U(xN),i=U(R),a=U(Nj),{hasGroup:o,drawings:s}=e,c=a.get(`GroupIcon`),l=a.get(`UngroupIcon`),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(!0);return(0,V.useEffect)(()=>{let e=s[0];if(e==null)return;let{unitId:t}=e,i=n.getRenderById(t)?.scene;if(i==null)return;let a=i.getTransformerByCreate(),o=a.clearControl$.subscribe(e=>{e===!0&&d(!1)}),c=a.changeStart$.subscribe(e=>{let{objects:t}=e,n=dW(t,r),i=n.filter(e=>e?.drawingType===um.DRAWING_GROUP),a=!1,o=!1;n.length>1&&(a=!0),i.length>0&&(o=!0),d(a||o),p(a),h(o)});return()=>{c.unsubscribe(),o.unsubscribe()}},[]),(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":o===!0&&u===!1||o===!1}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:t.t(`drawing-ui.image-panel.group.title`)})}),(0,H.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,H.jsxs)(HA,{className:W({"univer-hidden":!f}),onClick:()=>{i.syncExecuteCommand(XU.id,{drawings:s})},children:[(0,H.jsx)(c,{}),t.t(`drawing-ui.image-panel.group.group`)]}),(0,H.jsxs)(HA,{className:W({"univer-hidden":!m}),onClick:()=>{i.syncExecuteCommand(ZU.id,{drawings:s})},children:[(0,H.jsx)(l,{}),t.t(`drawing-ui.image-panel.group.unGroup`)]})]})]})},sot=[-360,360],xW=300,cot=e=>{let t=U(nx),n=U(xN),r=U(KE),{drawings:i,transformShow:a}=e,o=i[0];if(o==null)return;let s=o.transform;if(s==null)return;let{unitId:c,subUnitId:l,drawingId:u,drawingType:d}=o,f=r.getRenderById(c)?.scene;if(f==null)return;let p=f.getEngine()?.activeScene;if(p==null)return;let m=f.getTransformerByCreate(),{width:h=0,height:g=0,left:_=0,top:v=0,angle:y=0}=s,[b,x]=(0,V.useState)(h),[S,C]=(0,V.useState)(g),[w,T]=(0,V.useState)(_),[E,D]=(0,V.useState)(v),[O,k]=(0,V.useState)(y),[A,ee]=(0,V.useState)(m.keepRatio),te=(e,t,n,r)=>{let{width:i,height:a}=p,{ancestorLeft:o,ancestorTop:s}=f,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=i-c-o,u<20&&(u=20),d=a-l-s,d<20&&(d=20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ne=e=>{let{objects:t}=e,r=dW(t,n);if(r.length!==1)return;let i=r[0];if(i==null)return;let{transform:a}=i;if(a==null)return;let{width:o,height:s,left:c,top:l,angle:u}=a;o!=null&&x(o),s!=null&&C(s),c!=null&&T(c),l!=null&&D(l),u!=null&&k(u)};(0,V.useEffect)(()=>{let e=[m.changeStart$.subscribe(e=>{ne(e)}),m.changing$.subscribe(e=>{ne(e)}),m.changeEnd$.subscribe(e=>{ne(e)}),n.focus$.subscribe(e=>{if(e.length!==1)return;let t=n.getDrawingByParam(e[0]);if(t==null)return;let r=t.transform;if(r==null)return;let{width:i,height:a,left:o,top:s,angle:c}=r;i!=null&&x(i),a!=null&&C(a),o!=null&&T(o),s!=null&&D(s),c!=null&&k(c)})];return()=>{e.forEach(e=>e.unsubscribe())}},[]);let re=Wi(e=>{if(e==null)return;let{limitWidth:t,limitHeight:r}=te(w,E,e,S);e=Math.min(e,t);let i={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{width:e}};if(A){let t=e/b*S;if(t=Math.max(t,20),t>r)return;C(t),i.transform.height=t}x(e),n.featurePluginUpdateNotification([i]),m.refreshControls().changeNotification()},xW),ie=Wi(e=>{if(e==null)return;let{limitHeight:t,limitWidth:r}=te(w,E,b,e);e=Math.min(e,t);let i={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{height:e}};if(A){let t=e/S*b;if(t=Math.max(t,20),t>r)return;x(t),i.transform.width=t}C(e),n.featurePluginUpdateNotification([i]),m.refreshControls().changeNotification()},xW),ae=Wi(e=>{if(e==null)return;let{limitLeft:t}=te(e,E,b,S);e=t;let r={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{left:e}};T(e),n.featurePluginUpdateNotification([r]),m.refreshControls().changeNotification()},xW),oe=Wi(e=>{if(e==null)return;let{limitTop:t}=te(w,e,b,S);e=t;let r={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{top:e}};D(e),n.featurePluginUpdateNotification([r]),m.refreshControls().changeNotification()},xW);return(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!a}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:t.t(`drawing-ui.image-panel.transform.title`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.width`)}),(0,H.jsx)(dj,{precision:1,value:b,min:20,onChange:e=>{re(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.height`)}),(0,H.jsx)(dj,{precision:1,value:S,min:20,onChange:e=>{ie(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.lock`)}),(0,H.jsx)(`div`,{className:`univer-text-center`,children:(0,H.jsx)($A,{checked:A,onChange:e=>{ee(e),m.keepRatio=e}})})]})]}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.x`)}),(0,H.jsx)(dj,{precision:1,value:w,onChange:e=>{ae(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.y`)}),(0,H.jsx)(dj,{precision:1,value:E,onChange:e=>{oe(e)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:t.t(`drawing-ui.image-panel.transform.rotate`)}),(0,H.jsx)(dj,{precision:1,value:O,min:sot[0],max:sot[1],onChange:e=>{if(e==null)return;let t={unitId:c,subUnitId:l,drawingId:u,drawingType:d,transform:{angle:e}};k(e),n.featurePluginUpdateNotification([t]),m.refreshControls().changeNotification()}})]})]})]})},lot=e=>{let t=U(R),n=U(nx),r=U(_W),i=U(Nj),a=QD(r.canUseShapeClip$,!1),{drawings:o,cropperShow:s}=e;if(o[0]==null)return;let[c,l]=(0,V.useState)(`0`),u=(0,V.useRef)(!1),d=[{label:n.t(`drawing-ui.image-panel.crop.mode`),value:`0`},{label:`1:1`,value:`1`},{label:`16:9`,value:`2`},{label:`9:16`,value:`3`},{label:`5:4`,value:`4`},{label:`4:5`,value:`5`},{label:`4:3`,value:`6`},{label:`3:4`,value:`7`},{label:`3:2`,value:`8`},{label:`2:3`,value:`9`}];(0,V.useEffect)(()=>{let e=t.onCommandExecuted(e=>{e.id===$U.id&&(e.params?.isAuto||(u.current=!1))});return()=>{e?.dispose()}},[]);function f(e){l(e),u.current&&t.executeCommand(eW.id,{cropType:e})}let p=e=>{t.executeCommand(eW.id,{cropType:e}),u.current=!0};return(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!s}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`drawing-ui.image-panel.crop.title`)})}),(0,H.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,H.jsxs)(HA,{onClick:()=>{p(c)},children:[(0,H.jsx)(dje,{}),n.t(`drawing-ui.image-panel.crop.start`)]}),(0,H.jsx)(bj,{value:c,options:d,onChange:f})]}),a&&(()=>{let e=i.get(`sheet.image-clip.shape.picker.component`);return e?(0,H.jsx)(e,{}):null})()]})},uot=e=>{let t=U(xN),n=U(KE),r=U(nx),{drawings:i,hasArrange:a=!0,hasTransform:o=!0,hasAlign:s=!0,hasCropper:c=!0,hasGroup:l=!0}=e,u=i[0];if(u==null)return;let{unitId:d}=u,f=n.getRenderById(d)?.scene;if(f==null)return;let p=f.getTransformerByCreate(),[m,h]=(0,V.useState)(!0),[g,_]=(0,V.useState)(!0),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(!0),[S,C]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let e=p.clearControl$.subscribe(e=>{e===!0&&(h(!1),_(!1),y(!1),x(!1),C(!0))}),n=p.changeStart$.subscribe(e=>{let{objects:n}=e,r=dW(n,t);r.length===0?(h(!1),_(!1),y(!1),x(!1),C(!0)):r.length===1?(h(!0),_(!0),y(!1),x(!0),C(!1)):(h(!0),_(!1),y(!0),x(!1),C(!1))}),r=t.focus$.subscribe(e=>{e.length===0?(h(!1),_(!1),y(!1),x(!1),C(!0)):e.length===1?(h(!0),_(!0),y(!1),x(!0),C(!1)):(h(!0),_(!1),y(!0),x(!1),C(!1))});return()=>{n.unsubscribe(),e.unsubscribe(),r.unsubscribe()}},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:W(`univer-h-full`,{"univer-hidden":!S}),children:(0,H.jsx)(`div`,{className:`univer-flex univer-h-full univer-items-center univer-justify-center`,children:(0,H.jsx)(`span`,{children:r.t(`drawing-ui.image-panel.null`)})})}),(0,H.jsx)(aot,{arrangeShow:a===!0&&m,drawings:i}),(0,H.jsx)(cot,{transformShow:o===!0&&g,drawings:i}),(0,H.jsx)(iot,{alignShow:s===!0&&v,drawings:i}),(0,H.jsx)(lot,{cropperShow:c===!0&&b,drawings:i}),(0,H.jsx)(oot,{hasGroup:l,drawings:i})]})},SW={id:`doc.command.remove-doc-image`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(z),i=e.get(KE),a=r.getCurrentUniverDocInstance();if(t==null||a==null)return!1;let o=i.getRenderById(t.unitId).with(XF),{drawings:s}=t,c=o.getSegment()??``,l=new Bv,u=Vv.getInstance(),d=a.getSelfOrHeaderFooterModel(c).getBody()?.customBlocks??[],f=s.map(e=>d.find(t=>t.blockId===e.drawingId)).filter(e=>!!e).sort((e,t)=>e.startIndex>t.startIndex?1:-1),p=s[0].unitId,m=new Pf;m.reset();let h=f[0].startIndex,g=[{startOffset:h,endOffset:h}],_={id:aD.id,params:{unitId:p,actions:[],textRanges:g}},v=[];for(let e of f){let{startIndex:t}=e;t>m.cursor&&l.push({t:Mm.RETAIN,len:t-m.cursor}),l.push({t:Mm.DELETE,len:1}),m.moveCursorTo(t+1)}let y=qN(a,c);v.push(u.editOp(l.serialize(),y));for(let e of f){let{blockId:t}=e,n=(a.getDrawings()??{})[t],r=a.getDrawingsOrder().indexOf(t),i=u.removeOp([`drawings`,t],n),o=u.removeOp([`drawingsOrder`,r],t);v.push(i),v.push(o)}return _.params.actions=v.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(_.id,_.params)}},dot={id:`doc.command.delete-drawing`,type:L.COMMAND,handler:e=>{let t=e.get(R),n=e.get(kU).getFocusDrawings();if(n.length===0)return!1;let{unitId:r}=n[0],i=n.map(e=>{let{unitId:t,subUnitId:n,drawingId:r,drawingType:i}=e;return{unitId:t,subUnitId:n,drawingId:r,drawingType:i}});return t.executeCommand(SW.id,{unitId:r,drawings:i})}},fot={id:`doc.command.group-doc-image`,type:L.COMMAND,handler:(e,t)=>!1},CW={id:`doc.command.insert-doc-image`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(nD),i=e.get(z),a=r.getActiveTextRange(),o=i.getCurrentUniverDocInstance();if(o==null)return!1;let s=o.getUnitId(),c=pot(e,s),l=c?{...a,startOffset:c.startOffset,endOffset:c.endOffset,collapsed:c.startOffset===c.endOffset,segmentId:c.segmentId??a?.segmentId??``}:a;if(l==null)return!1;let{drawings:u}=t,{collapsed:d,startOffset:f,segmentId:p=``}=l,m=o.getSelfOrHeaderFooterModel(p).getBody();if(m==null)return!1;let h=new Bv,g=Vv.getInstance(),_=[],v=o.getSnapshot().drawingsOrder?.length??0,y=0;if(d)f>0&&h.push({t:Mm.RETAIN,len:f});else{let e=Ey.selection.delete([l],m,0,null,!1);h.push(...e);let t=RYe(m,[l]),n=o.getDrawings()??{},r=o.getDrawingsOrder()??[],i=t.sort((e,t)=>r.indexOf(e)>r.indexOf(t)?-1:+(r.indexOf(e)<r.indexOf(t)));if(i.length>0)for(let e of i){let t=n[e],i=r.indexOf(e);if(t==null||i<0)continue;let a=g.removeOp([`drawings`,e],t),o=g.removeOp([`drawingsOrder`,i],e);_.push(a),_.push(o),y++}}h.push({t:Mm.INSERT,body:{dataStream:`\b`.repeat(u.length),customBlocks:u.map((e,t)=>({startIndex:t,blockId:e.drawingId}))},len:u.length});let b=qN(o,p),x=g.editOp(h.serialize(),b);_.push(x);for(let e of u){let{drawingId:t}=e,n=g.insertOp([`drawings`,t],e),r=g.insertOp([`drawingsOrder`,v-y],t);_.push(n),_.push(r)}let S={id:aD.id,params:{unitId:s,actions:[],textRanges:[]}};return S.params.actions=_.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(S.id,S.params)}};function pot(e,t){try{let n=e.get(zP).consumeInsertRange(t);return n==null?null:{startOffset:n.startOffset,endOffset:n.endOffset,collapsed:n.startOffset===n.endOffset,segmentId:n.segmentId}}catch{return null}}var mot={id:`doc.command.set-drawing-arrange`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(kU);if(t==null)return!1;let{unitId:i,subUnitId:a,drawingIds:o,arrangeType:s}=t,c={unitId:i,subUnitId:a,drawingIds:o},l;if(s===lm.forward?l=r.getForwardDrawingsOp(c):s===lm.backward?l=r.getBackwardDrawingOp(c):s===lm.front?l=r.getFrontDrawingsOp(c):s===lm.back&&(l=r.getBackDrawingsOp(c)),l==null)return!1;let{redo:u}=l;if(u==null)return!1;let d=[],f=F.deepClone(u);f=f.slice(3),f.unshift(`drawingsOrder`),d.push(f);let p={id:aD.id,params:{unitId:i,actions:[],textRanges:null}};return p.params.actions=d.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(p.id,p.params)}},hot={id:`doc.command.ungroup-doc-image`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(kU);if(!t)return!1;let r=[];t.forEach(({parent:e,children:t})=>{r.push(e.unitId),t.forEach(e=>{r.push(e.unitId)})});let{unitId:i,subUnitId:a,undo:o,redo:s,objects:c}=n.getUngroupDrawingOp(t);return!1}};function wW(e){"@babel/helpers - typeof";return wW=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},wW(e)}function got(e,t){if(wW(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(wW(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _ot(e){var t=got(e,`string`);return wW(t)==`symbol`?t:t+``}function TW(e,t,n){return(t=_ot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var EW=class{constructor(){TW(this,`_refreshDrawings$`,new so(null)),TW(this,`refreshDrawings$`,this._refreshDrawings$.asObservable())}refreshDrawings(e){this._refreshDrawings$.next(e)}};function DW(e,t){return function(n,r){t(n,r,e)}}function OW(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var kW=class extends P{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){super(),this._context=e,this._commandService=t,this._docSelectionManagerService=n,this._renderManagerSrv=r,this._imageIoService=i,this._docDrawingService=a,this._drawingManagerService=o,this._contextService=s,this._messageService=c,this._localeService=l,this._docSelectionRenderService=u,this._docRefreshDrawingsService=d,this._fileOpenerService=f,this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._transformDrawingListener(),this._editAreaChangeListener()}dispose(){super.dispose(),delete this._context}async insertDocImage(){let e=this._getCurrentImageInsertPosition(),t=await this._fileOpenerService.openFile({multiple:!0,accept:bN.map(e=>`.${e.replace(`image/`,``)}`).join(`,`)}),n=t.length;return n>10?(this._messageService.show({type:pj.Error,content:this._localeService.t(`docs-drawing-ui.update-status.exceedMaxCount`,`10`)}),!1):n!==0&&(await this._insertFloatImages(t,e),!0)}async _insertFloatImages(e,t){let n=[];try{n=await Promise.all(e.map(e=>this._imageIoService.saveImage(e)))}catch(e){let t=e.message,n=``;switch(t){case lb.ERROR_EXCEED_SIZE:n=this._localeService.t(`docs-drawing-ui.update-status.exceedMaxSize`,String(yN()/1048576));break;case lb.ERROR_IMAGE_TYPE:n=this._localeService.t(`docs-drawing-ui.update-status.invalidImageType`);break;case lb.ERROR_IMAGE:n=this._localeService.t(`docs-drawing-ui.update-status.invalidImage`)}this._messageService.show({type:pj.Error,content:n})}if(n.length===0)return;let{unitId:r}=this._context,i=[];for(let e of n){if(e==null)continue;let{imageId:n,imageSourceType:a,source:o,base64Cache:s}=e,{width:c,height:l,image:u}=await kN(s||``);this._imageIoService.addImageSourceCache(n,a,u);let d=1;if(c>500||l>500){let e=500/c,t=500/l;d=Math.min(e,t)}let f=t??this._getCurrentImageInsertPosition(),p=this._getImagePosition(c*d,l*d,f);if(p==null)return;let m=FN(p);m!=null&&f!=null&&(m.top=f.top);let h={unitId:r,subUnitId:r,drawingId:n,drawingType:um.DRAWING_IMAGE,imageSourceType:a,source:o,transform:m,docTransform:p,behindDoc:Np.FALSE,title:``,description:``,layoutType:Kp.INLINE,wrapText:Gp.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0};this._isInsertInHeaderFooter()&&(h.isMultiTransform=Np.TRUE,h.transforms=h.transform?[h.transform]:null),i.push(h)}this._commandService.executeCommand(CW.id,{unitId:r,drawings:i})}_isInsertInHeaderFooter(){let{unitId:e}=this._context,t=(this._renderManagerSrv.getRenderById(e)?.with(rD).getViewModel())?.getEditArea();return t===OT.HEADER||t===OT.FOOTER}_getImagePosition(e,t,n){let r=n??this._getCurrentImageInsertPosition()??{left:0,top:0};return{size:{width:e,height:t},positionH:{relativeFrom:nm.PAGE,posOffset:r.left},positionV:{relativeFrom:rm.PARAGRAPH,posOffset:0},angle:0}}_getCurrentImageInsertPosition(){let e=this._docSelectionRenderService.getActiveTextRange()?.getAbsolutePosition();return e==null?null:{left:e.left,top:e.top}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n,drawingIds:r,arrangeType:i}=e;this._commandService.executeCommand(mot.id,{unitId:t,subUnitId:n,drawingIds:r,arrangeType:i})}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(fot.id,e)})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(hot.id,e)}))}_getCurrentSceneAndTransformer(){let{scene:e,mainComponent:t}=this._context;if(e==null||t==null)return;let n=e.getTransformerByCreate(),{docsLeft:r,docsTop:i}=t.getOffsetConfig();return{scene:e,transformer:n,docsLeft:r,docsTop:i}}_transformDrawingListener(){let e=this._getCurrentSceneAndTransformer();if(e&&e.transformer)this.disposeWithMe(e.transformer.changeEnd$.pipe(Ks(30)).subscribe(e=>{this._docSelectionManagerService.refreshSelection()}));else throw Error(`transformer is not init`)}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{let{transformer:t,docsLeft:n,docsTop:r}=this._getCurrentSceneAndTransformer()??{};if(e==null||e.length===0)this._contextService.setContextValue(ab,!1),this._docDrawingService.focusDrawing([]),t&&t.resetProps({zeroTop:0,zeroLeft:0});else{this._contextService.setContextValue(ab,!0),this._docDrawingService.focusDrawing(e),this._setDrawingSelections(e);let i=this._docSelectionRenderService.getSegment(),a=this._findSegmentIdByDrawingId(e[0].drawingId);i!==a&&this._docSelectionRenderService.setSegment(a),t&&t.resetProps({zeroTop:r,zeroLeft:n})}}))}_findSegmentIdByDrawingId(e){let{unit:t}=this._context,{body:n,headers:r={},footers:i={}}=t.getSnapshot();if((n?.customBlocks??[]).some(t=>t.blockId===e))return``;for(let t of Object.keys(r))if(r[t].body.customBlocks?.some(t=>t.blockId===e))return t;for(let t of Object.keys(i))if(i[t].body.customBlocks?.some(t=>t.blockId===e))return t;return``}_updateDrawingsEditStatus(){if(!this._context)return;let{unit:e,scene:t,unitId:n}=this._context,r=this._renderManagerSrv.getRenderById(n)?.with(rD).getViewModel();if(r==null||e==null)return;let{drawings:i={}}=e.getSnapshot(),a=r.getEditArea()===OT.BODY;for(let e of Object.keys(i)){let r=i[e],o=ON({unitId:n,drawingId:r.drawingId,subUnitId:n}),s=t.fuzzyMathObjects(o,!0);if(s.length)for(let e of s){t.detachTransformerFrom(e);try{e.setOpacity(.5)}catch{}if(a&&r.isMultiTransform!==Np.TRUE||!a&&r.isMultiTransform===Np.TRUE){r.allowTransform!==!1&&t.attachTransformerTo(e);try{e.setOpacity(1)}catch{}}}}}_editAreaChangeListener(){let{unitId:e}=this._context,t=this._renderManagerSrv.getRenderById(e)?.with(rD).getViewModel();t!=null&&(this._updateDrawingsEditStatus(),this.disposeWithMe(t.editAreaChange$.subscribe(()=>{this._updateDrawingsEditStatus()})),this.disposeWithMe(this._docRefreshDrawingsService.refreshDrawings$.subscribe(e=>{e!=null&&queueMicrotask(()=>{this._updateDrawingsEditStatus()})})),this.disposeWithMe(this._commandService.onCommandExecuted(async e=>{e.id===aD.id&&queueMicrotask(()=>{this._updateDrawingsEditStatus()})})))}_setDrawingSelections(e){let{unit:t}=this._context,n=t.getSnapshot().body?.customBlocks??[],r=e.map(e=>{let t=e.drawingId,r=n.find(e=>e.blockId===t);return r?r.startIndex:null}).filter(e=>e!==null).map(e=>({startOffset:e,endOffset:e+1}));this._docSelectionManagerService.replaceDocRanges(r)}};kW=OW([DW(1,R),DW(2,j(nD)),DW(3,KE),DW(4,ub),DW(5,kU),DW(6,xN),DW(7,Fm),DW(8,eM),DW(9,j(nx)),DW(10,j(XF)),DW(11,j(EW)),DW(12,dN)],kW);var vot={id:`doc.command.insert-float-image`,type:L.COMMAND,handler:e=>{let t=e.get(z),n=e.get(KE);return qE(M.UNIVER_DOC,t,n)?.with(kW).insertDocImage()??!1}},yot={inline:Kp.INLINE,wrapSquare:Kp.WRAP_SQUARE,wrapTopAndBottom:Kp.WRAP_TOP_AND_BOTTOM,inFrontOfText:Kp.WRAP_NONE,behindText:Kp.WRAP_NONE};function AW(e,t,n,r){let i=e.skeDrawings.get(t);if(i)return{skeDrawing:i,pageMarginTop:n,pageMarginLeft:r};for(let n of e.skeTables.values())for(let e of n.rows)for(let n of e.cells){let e=AW(n,t,n.marginTop,n.marginLeft);if(e)return e}return null}function bot(e,t,n,r,i,a,o){var s;let c=new Bv,l=Vv.getInstance(),u=[],d=a.getSelfOrHeaderFooterModel(t).getBody(),f=a.getSelfOrHeaderFooterModel(e).getBody();if(d==null||f==null)return;let p=(s=d.customBlocks)==null||(s=s.find(e=>e.blockId===i))==null?void 0:s.startIndex;if(p!=null){if(r=Math.min(f.dataStream.length-2,r),e===t){if(r<p?(r>0&&c.push({t:Mm.RETAIN,len:r}),c.push({t:Mm.INSERT,body:{dataStream:`\b`,customBlocks:[{startIndex:0,blockId:i}]},len:1}),c.push({t:Mm.RETAIN,len:p-r}),c.push({t:Mm.DELETE,len:1})):(p>0&&c.push({t:Mm.RETAIN,len:p}),c.push({t:Mm.DELETE,len:1}),r-p-1>0&&c.push({t:Mm.RETAIN,len:r-p-1}),c.push({t:Mm.INSERT,body:{dataStream:`\b`,customBlocks:[{startIndex:0,blockId:i}]},len:1})),r!==p){let e=qN(a,t),n=l.editOp(c.serialize(),e);u.push(n)}}else{p>0&&c.push({t:Mm.RETAIN,len:p}),c.push({t:Mm.DELETE,len:1});let s=qN(a,t),d=l.editOp(c.serialize(),s);u.push(d),c.empty(),r>0&&c.push({t:Mm.RETAIN,len:r}),c.push({t:Mm.INSERT,body:{dataStream:`\b`,customBlocks:[{startIndex:0,blockId:i}]},len:1}),s=qN(a,e),d=l.editOp(c.serialize(),s),u.push(d),o.setSegment(e),o.setSegmentPage(n)}return u}}var xot={id:`doc.command.update-doc-drawing-wrapping-style`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let{drawings:n,wrappingStyle:r,unitId:i}=t,a=e.get(R),o=e.get(z),s=e.get(KE).getRenderById(i),c=s?.with(rD).getSkeleton().getSkeletonData(),l=s?.with(rD).getViewModel(),u=s?.scene,d=o.getCurrentUniverDocInstance();if(d==null||c==null||u==null||l==null)return!1;let f=l.getEditArea(),p=u.getTransformerByCreate(),{pages:m,skeHeaders:h,skeFooters:g}=c,_=Vv.getInstance(),v=[],{drawings:y={}}=d.getSnapshot();for(let e of n){let{drawingId:t}=e,n=y[t].layoutType,i=yot[r];if(n!==i){let e=_.replaceOp([`drawings`,t,`layoutType`],n,i);v.push(e)}if(r===`behindText`||r===`inFrontOfText`){let e=y[t].behindDoc,n=r===`behindText`?Np.TRUE:Np.FALSE;if(e!==n){let r=_.replaceOp([`drawings`,t,`behindDoc`],e,n);v.push(r)}}if(r===`inline`)continue;let a=null;for(let e of m){let{headerId:n,footerId:r,marginTop:i,marginLeft:o,marginBottom:s,pageWidth:c,pageHeight:l}=e;switch(f){case OT.HEADER:{let e=h.get(n)?.get(c);e!=null&&(a=AW(e,t,e.marginTop,o));break}case OT.FOOTER:{let e=g.get(r)?.get(c);e!=null&&(a=AW(e,t,l-s+e.marginTop,o));break}case OT.BODY:a=AW(e,t,i,o)}if(a!=null)break}if(a!=null){let{skeDrawing:e,pageMarginTop:n,pageMarginLeft:r}=a,{aTop:i,aLeft:o}=e,s=y[t].docTransform.positionH,c=o;s.relativeFrom===nm.MARGIN?c-=r:s.relativeFrom===nm.COLUMN&&(c-=e.columnLeft);let l={relativeFrom:s.relativeFrom,posOffset:c};if(s.posOffset!==l.posOffset){let e=_.replaceOp([`drawings`,t,`docTransform`,`positionH`],s,l);v.push(e)}let u=y[t].docTransform.positionV,d=i;u.relativeFrom===rm.PAGE?d+=n:u.relativeFrom===rm.LINE?d-=e.lineTop:u.relativeFrom===rm.PARAGRAPH&&(d-=e.blockAnchorTop);let f={relativeFrom:u.relativeFrom,posOffset:d};if(u.posOffset!==f.posOffset){let e=_.replaceOp([`drawings`,t,`docTransform`,`positionV`],u,f);v.push(e)}}}let b={id:aD.id,params:{unitId:i,actions:[],textRanges:null}};b.params.actions=v.reduce((e,t)=>Vv.compose(e,t),null);let x=a.syncExecuteCommand(b.id,b.params);return p.refreshControls(),!!x}},Sot={id:`doc.command.update-doc-drawing-distance`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(z).getCurrentUniverDocInstance();if(r==null)return!1;let{drawings:i,dist:a,unitId:o}=t,s=Vv.getInstance(),c=[],{drawings:l={}}=r.getSnapshot();for(let e of i){let{drawingId:t}=e;for(let[e,n]of Object.entries(a)){let r=l[t][e];if(r!==n){let i=s.replaceOp([`drawings`,t,e],r,n);c.push(i)}}}let u={id:aD.id,params:{unitId:o,actions:[],textRanges:null}};return u.params.actions=c.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(u.id,u.params)}},Cot={id:`doc.command.update-doc-drawing-wrap-text`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(z).getCurrentUniverDocInstance();if(r==null)return!1;let{drawings:i,wrapText:a,unitId:o}=t,s=Vv.getInstance(),c=[],{drawings:l={}}=r.getSnapshot();for(let e of i){let{drawingId:t}=e,n=l[t].wrapText;if(n!==a){let e=s.replaceOp([`drawings`,t,`wrapText`],n,a);c.push(e)}}let u={id:aD.id,params:{unitId:o,actions:[],textRanges:null}};return u.params.actions=c.reduce((e,t)=>Vv.compose(e,t),null),!!n.syncExecuteCommand(u.id,u.params)}},jW={id:`doc.command.update-drawing-doc-transform`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(R),r=e.get(z),i=e.get(KE).getRenderById(t.unitId)?.scene;if(i==null)return!1;let a=i.getTransformerByCreate(),o=r.getCurrentUniverDocInstance();if(o==null)return!1;let{drawings:s,unitId:c}=t,l=Vv.getInstance(),u=[],{drawings:d={}}=o.getSnapshot();for(let e of s){let{drawingId:t,key:n,value:r}=e,i=d[t].docTransform[n];if(!F.diffValue(i,r)){let e=l.replaceOp([`drawings`,t,`docTransform`,n],i,r);u.push(e)}}let f={id:aD.id,params:{unitId:c,actions:[],textRanges:null,debounce:!0}};f.params.actions=u.reduce((e,t)=>Vv.compose(e,t),null);let p=n.syncExecuteCommand(f.id,f.params);return a.refreshControls(),!!p}},wot={id:`doc.command.move-inline-drawing`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(KE),r=n.getRenderById(t.unitId)?.with(XF),i=e.get(EW),a=n.getRenderById(t.unitId),o=a?.scene,s=a?.with(rD).getSkeleton();if(o==null||r==null)return!1;let c=o.getTransformerByCreate(),l=e.get(R),u=e.get(z).getCurrentUniverDocInstance();if(u==null)return!1;let{drawing:d,unitId:f,offset:p,segmentId:m,segmentPage:h,needRefreshDrawings:g}=t;if(g)return i.refreshDrawings(s),c.refreshControls(),!0;let _=[],{drawingId:v}=d,y=bot(m,r.getSegment()??``,h,p,v,u,r);if(y==null||y.length===0)return i.refreshDrawings(s),c.refreshControls(),!1;_.push(...y);let b={id:aD.id,params:{unitId:f,actions:[],textRanges:null}};b.params.actions=_.reduce((e,t)=>Vv.compose(e,t),null);let x=l.syncExecuteCommand(b.id,b.params);return c.refreshControls(),!!x}},Tot={id:`doc.command.transform-non-inline-drawing`,type:L.COMMAND,handler:(e,t)=>{if(t==null)return!1;let n=e.get(KE),r=n.getRenderById(t.unitId)?.with(XF),i=n.getRenderById(t.unitId)?.scene;if(i==null||r==null)return!1;let a=i.getTransformerByCreate(),o=e.get(R),s=e.get(z).getCurrentUniverDocInstance();if(s==null)return!1;let{drawing:c,unitId:l,offset:u,docTransform:d,segmentId:f,segmentPage:p}=t,m=[],{drawingId:h}=c,g=bot(f,r.getSegment()??``,p,u,h,s,r);if(g==null)return!1;g.length>0&&m.push(...g);let _=Vv.getInstance(),{drawings:v={}}=s.getSnapshot(),{positionH:y,positionV:b,size:x,angle:S}=v[h].docTransform;if(!F.diffValue(y,d.positionH)){let e=_.replaceOp([`drawings`,h,`docTransform`,`positionH`],y,d.positionH);m.push(e)}if(!F.diffValue(b,d.positionV)){let e=_.replaceOp([`drawings`,h,`docTransform`,`positionV`],b,d.positionV);m.push(e)}if(!F.diffValue(x,d.size)){let e=_.replaceOp([`drawings`,h,`docTransform`,`size`],x,d.size);m.push(e)}if(!F.diffValue(S,d.angle)){let e=_.replaceOp([`drawings`,h,`docTransform`,`angle`],S,d.angle);m.push(e)}let C={id:aD.id,params:{unitId:l,actions:[],textRanges:null,debounce:!0}};C.params.actions=m.reduce((e,t)=>Vv.compose(e,t),null);let w=o.syncExecuteCommand(C.id,C.params);return a.refreshControls(),!!w}},MW={id:`doc.command.move-drawing`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(kU),i=e.get(z),a=e.get(KE),{direction:o}=t,s=r.getFocusDrawings();if(s.length===0)return!1;let c=s[0].unitId,l=a.getRenderById(c)?.scene;if(l==null)return!1;let u=l.getTransformerByCreate(),d=i.getUniverDocInstance(c),f=s.map(e=>{var t;let{drawingId:n}=e,r=d==null||(t=d.getSnapshot().drawings)==null?void 0:t[n];if(r==null||r.layoutType===Kp.INLINE)return null;let{positionH:i,positionV:a}=r.docTransform,s={...i},c={...a};return o===I.UP?c.posOffset=(c.posOffset??0)-2:o===I.DOWN?c.posOffset=(c.posOffset??0)+2:o===I.LEFT?s.posOffset=(s.posOffset??0)-2:o===I.RIGHT&&(s.posOffset=(s.posOffset??0)+2),{drawingId:n,key:o===I.UP||o===I.DOWN?`positionV`:`positionH`,value:o===I.UP||o===I.DOWN?c:s}}).filter(e=>e!=null);if(f.length===0)return!1;let p=n.syncExecuteCommand(jW.id,{unitId:c,subUnitId:c,drawings:f});return u.refreshControls(),!!p}},Eot={id:`doc.operation.clear-drawing-transformer`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(KE);return t.forEach(e=>{var t;(t=n.getRenderById(e))==null||(t=t.scene.getTransformer())==null||t.debounceRefreshControls()}),!0}},Dot=`COMPONENT_DOC_DRAWING_PANEL`,NW={id:`sidebar.operation.doc-image`,type:L.COMMAND,handler:async(e,t)=>{let n=e.get(Aj),r=e.get(nx),i=e.get(xN);switch(t.value){case`open`:n.open({header:{title:r.t(`docs-drawing-ui.panel.title`)},children:{label:Dot},onClose:()=>{i.focusDrawing(null)},width:360});break;default:n.close()}return!0}},PW={id:`doc.operation.edit-doc-image`,type:L.OPERATION,handler:(e,t)=>{let n=e.get(xN),r=e.get(R);return t!=null&&(n.focusDrawing([t]),r.executeCommand(NW.id,{value:`open`}),!0)}};function Oot(e,t,n=1,r=0){let{top:i,left:a,bottom:o,right:s}=e,c=s-a,l=o-i,{viewportScrollX:u,viewportScrollY:d}=t.getViewport(AN.VIEW_MAIN),{scaleX:f,scaleY:p}=t.getAncestorScale();return{startX:(a-u)*f,startY:(i-d)*p,endX:(a+c-u)*f,endY:(i+l-d)*p,width:c*f,height:l*p,rotate:r,absolute:{left:!1,top:!1},opacity:n??1}}function FW(e,t){let{top:n,left:r,width:i,height:a,angle:o,opacity:s}=e;return Oot({top:n,left:r,bottom:n+a,right:r+i},t.scene,s,o)}var IW=class extends P{constructor(e,t,n,r,i,a){super(),this._renderManagerService=e,this._drawingManagerService=t,this._drawingRenderService=n,this._canvasFloatDomService=r,this._univerInstanceService=i,this._commandService=a,TW(this,`_domLayerInfoMap`,new Map),this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddRemoveListener(),this._initScrollAndZoomEvent()}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e);if(t==null)return null;let n=t.scene;return{scene:n,transformer:n.getTransformerByCreate(),renderUnit:t,canvas:t.engine.getCanvasElement()}}_drawingAddRemoveListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertRects(e)})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{this._removeDom(e.drawingId)})}))}_insertRects(e){e.forEach(async e=>{let{unitId:t}=e;if(!this._univerInstanceService.getUnit(t,M.UNIVER_DOC))return;let n=this._getSceneAndTransformerByDrawingSearch(t);if(n==null)return;let r=this._drawingManagerService.getDrawingByParam(e);if(r==null)return;let i=await this._drawingRenderService.renderFloatDom(r,n.scene);if(i!=null&&i.length!==0)for(let e of i){this._addHoverForRect(e);let i=new Gf,a=new so(FW(e,n.renderUnit)),o=n.canvas,s=r.data,c={dispose:i,rect:e,position$:a,unitId:t};this._canvasFloatDomService.addFloatDom({position$:a,id:r.drawingId,componentKey:r.componentKey,onPointerDown:e=>{o.dispatchEvent(new PointerEvent(e.type,e))},onPointerMove:e=>{o.dispatchEvent(new PointerEvent(e.type,e))},onPointerUp:e=>{o.dispatchEvent(new PointerEvent(e.type,e))},onWheel:e=>{o.dispatchEvent(new WheelEvent(e.type,e))},data:s,unitId:t});let l=e.onTransformChange$.subscribeEvent(()=>{let t=FW(e,n.renderUnit);a.next(t)});i.add(()=>{this._canvasFloatDomService.removeFloatDom(r.drawingId)}),l&&i.add(l),this._domLayerInfoMap.set(r.drawingId,c)}})}_addHoverForRect(e){this.disposeWithMe(Wf(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=_w.GRAB}))),this.disposeWithMe(Wf(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=_w.DEFAULT})))}_removeDom(e){let t=this._domLayerInfoMap.get(e);if(!t)return;let{unitId:n}=t;this._domLayerInfoMap.delete(e),t.dispose.dispose();let r=this._getSceneAndTransformerByDrawingSearch(n);r&&r.scene.removeObject(t.rect)}_initScrollAndZoomEvent(){let e=e=>{let t=this._getSceneAndTransformerByDrawingSearch(e);t&&this._domLayerInfoMap.forEach(n=>{if(n.unitId!==e)return;let r=FW(n.rect,t.renderUnit);n.position$.next(r)})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_DOC).pipe(os(e=>{if(!e)return null;let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);return n?{render:n,unitId:t}:null}),sc(e=>e?zy(e.render.scene.getViewport(AN.VIEW_MAIN).onScrollAfter$).pipe(os(()=>({unitId:e.unitId}))):ts(null))).subscribe(t=>{if(!t)return;let{unitId:n}=t;e(n)})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===SF.id){let{unitId:n}=t.params;e(n)}}))}insertFloatDom(e,t){let n=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_DOC);if(!n)return!1;let r=this._getSceneAndTransformerByDrawingSearch(n.getUnitId());if(!r)return!1;let i=r.renderUnit.with(rD).getSkeleton().getSkeletonData()?.pages[0];if(!i)return!1;let{pageWidth:a,marginLeft:o,marginRight:s}=i,c=a-o-s,l={size:{width:t.width??c,height:t.height},positionH:{relativeFrom:nm.PAGE,posOffset:0},positionV:{relativeFrom:rm.PAGE,posOffset:0},angle:0},u=t.drawingId??ip(),d={unitId:n.getUnitId(),drawings:[{drawingId:u,drawingType:um.DRAWING_DOM,subUnitId:n.getUnitId(),unitId:n.getUnitId(),...e,title:``,description:``,docTransform:l,layoutType:Kp.INLINE,transform:FN(l)}]};return this._commandService.syncExecuteCommand(CW.id,d),u}};IW=OW([DW(0,KE),DW(1,xN),DW(2,j(vW)),DW(3,j(CM)),DW(4,z),DW(5,R)],IW);var kot=`doc.menu.image`,LW=vot.id,Aot=e=>{let t=e.get(nD),n=e.get(z);return new Ya(e=>{let r=t.textSelection$.subscribe(()=>{let r=t.getActiveTextRange();if(r){var i;let{segmentId:t,startOffset:a,endOffset:o}=r,s=n.getCurrentUniverDocInstance(),c=s==null||(i=s.getSelfOrHeaderFooterModel(t).getBody())==null?void 0:i.tables;if(c&&c.length&&c.some(e=>{let{startIndex:t,endIndex:n}=e;return a>=t&&a<n||o>=t&&o<n})){e.next(!0);return}}else{e.next(!0);return}e.next(!1)});return()=>r.unsubscribe()})};function jot(e){return{id:kot,type:bM.SUBITEMS,icon:`AddImageIcon`,tooltip:`docs-drawing-ui.title`,disabled$:Aot(e),hidden$:Pj(e,M.UNIVER_DOC,void 0,rf)}}function RW(e){return{id:LW,title:`docs-drawing-ui.upload.float`,type:bM.BUTTON,icon:`AddImageIcon`,hidden$:Pj(e,M.UNIVER_DOC,void 0,rf)}}var Mot=`@univerjs/docs-drawing-ui`,Not=`0.25.1`,Pot=`docs-drawing-ui.config`,Fot={};function Iot(e){if(Vv.isNoop(e)||!Array.isArray(e))return null;let t=e.find(e=>Array.isArray(e)&&e?.[0]===`drawings`);if(t==null||!Array.isArray(t)||t.length<3||typeof t[1]==`string`&&typeof t[2]!=`object`||Array.isArray(t[1])&&typeof t[1][1]!=`object`)return null;let n=[];if(Array.isArray(t?.[1])){for(let e of t)if(Array.isArray(e)){var r,i;n.push({type:e!=null&&(r=e[1])!=null&&r.i?`add`:`remove`,drawingId:e?.[0],drawing:e==null||(i=e[1])==null?void 0:i.i})}}else n.push({type:t[2]?.i?`add`:`remove`,drawingId:t[1],drawing:t[2]?.i});return n}function Lot(e){if(!Array.isArray(e)||e.length<3||e[0]!==`drawingsOrder`)return[];let t=[];for(let n=1;n<e.length;n++){let r=e[n];if(Array.isArray(r)&&typeof r[0]==`number`&&typeof r[1]==`object`)t.push(r[0]);else{t.length=0;break}}return t}var zW=class extends P{constructor(e,t,n,r,i){super(),this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=n,this._docDrawingService=r,this._renderManagerService=i,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id!==aD.id)return;let{unitId:t,actions:n,isSync:r,syncer:i}=e.params,a=Iot(n);if(a!=null)for(let{type:e,drawingId:n,drawing:o}of a)r&&o?.unitId===i||(e===`add`?this._addDrawings(t,[o]):this._removeDrawings(t,[n]))})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==aD.id)return;let{unitId:t,actions:n}=e.params;Lot(n).length>0&&this._updateDrawingsOrder(t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Cx.id&&e.id!==wx.id)return;let t=this._univerInstanceService.getCurrentUniverDocInstance()?.getUnitId(),n=this._drawingManagerService.getFocusDrawings();if(t==null||n.length===0)return;let r=this._renderManagerService.getRenderById(t)?.scene;if(r==null)return!1;r.getTransformerByCreate().refreshControls()}))}_addDrawings(e,t){let n=this._drawingManagerService,r=this._docDrawingService,{subUnitId:i,redo:a,objects:o}=this._docDrawingService.getBatchAddOp(t);n.applyJson1(e,i,a),r.applyJson1(e,i,a),n.addNotification(o),r.addNotification(o)}_removeDrawings(e,t){let n=this._drawingManagerService,r=this._docDrawingService,{subUnitId:i,redo:a,objects:o}=this._docDrawingService.getBatchRemoveOp(t.map(t=>({unitId:e,subUnitId:e,drawingId:t})));n.applyJson1(e,i,a),r.applyJson1(e,i,a),n.removeNotification(o),r.removeNotification(o)}_updateDrawingsOrder(e){let t=this._univerInstanceService.getUniverDocInstance(e);if(t==null)return;let n=t.getSnapshot().drawingsOrder;if(n==null)return;let r=this._drawingManagerService,i=this._docDrawingService;r.setDrawingOrder(e,e,n),i.setDrawingOrder(e,e,n);let a={unitId:e,subUnitId:e,drawingIds:n};r.orderNotification(a),i.orderNotification(a)}};zW=OW([DW(0,z),DW(1,R),DW(2,xN),DW(3,kU),DW(4,KE)],zW);var Rot=e=>{let{floatDomInfos:t,scene:n,offset:r,bound:i}=e,a=i.right-i.left,o=i.bottom-i.top;return(0,H.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-top-0`,children:(0,V.useMemo)(()=>t.map(e=>{let{width:t=0,height:r=0,left:i=0,top:a=0}=e.transform,o=Oot({left:i,right:i+t,top:a,bottom:a+r},n),s={position$:new so(o),position:o,id:e.drawingId,componentKey:e.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:e.unitId,data:e.data};return[e.drawingId,s]}).filter(([e,t])=>!(t.position.endX<0||t.position.endY<0||t.position.startX>a||t.position.startY>o)),[t,n,r,a,o]).map(([e,t])=>(0,H.jsx)(sYe,{layer:t,id:e,position:t.position},e))})},BW=class extends P{constructor(e,t,n,r,i){super(),this._docPrintInterceptorService=e,this._drawingRenderService=t,this._drawingManagerService=n,this._componetManager=r,this._injector=i,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._docPrintInterceptorService.interceptor.intercept(this._docPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(e,t,n)=>{let{unitId:r,scene:i}=t,a=this._drawingManagerService.getDrawingDataForUnit(r)?.[r];return a&&a.order.forEach(e=>{let t=a.data[e];t.drawingType!==um.DRAWING_CHART&&t.drawingType!==um.DRAWING_DOM&&this._drawingRenderService.renderDrawing(t,i)}),n()}}))}_initPrintingDom(){this.disposeWithMe(this._docPrintInterceptorService.interceptor.intercept(this._docPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(e,t,n)=>{let{unitId:r}=t,i=this._drawingManagerService.getDrawingDataForUnit(r)?.[r];if(i){let a=i.order.map(e=>{let t=i.data[e];if(t.drawingType===um.DRAWING_CHART)return{...t,componentKey:this._componetManager.get(Tm)};if(t.drawingType===um.DRAWING_DOM){let e=this._docPrintInterceptorService.getPrintComponent(t.componentKey);return{...t,componentKey:this._componetManager.get(e||t.componentKey)}}return null}).filter(Boolean);return Sj((0,H.jsx)(ZD(Rot,this._injector),{unitId:r,floatDomInfos:a,scene:t.scene,skeleton:t.skeleton,offset:t.offset,bound:t.bound}),t.root),e?.add(()=>{Cj(t.root)}),n(e)}}}))}};BW=OW([DW(0,j(Q2e)),DW(1,j(vW)),DW(2,xN),DW(3,j(Nj)),DW(4,j(We))],BW);function zot(e,t,n,r){let i=qT(t.tableId).tableId,a=ET(e,i),o=a&&a.contentWidth>a.viewportWidth?a.scrollLeft:0;return{left:t.left+r.left-o+r.marginLeft,top:t.top+n.top+r.marginTop}}var VW=class extends P{constructor(e,t,n,r,i,a,o,s){super(),this._context=e,this._docSkeletonManagerService=t,this._commandService=n,this._editorService=r,this._drawingManagerService=i,this._docRefreshDrawingsService=a,this._univerInstanceService=o,this._lifecycleService=s,TW(this,`_liquid`,new TT),this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._drawingInitializeListener(),this._initResize()}_initialRenderRefresh(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{e!=null&&this._refreshDrawing(e)})),this.disposeWithMe(this._docRefreshDrawingsService.refreshDrawings$.subscribe(e=>{e!=null&&this._refreshDrawing(e)}))}_commandExecutedListener(){let e=[aD.id,SF.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){let{unitId:e}=t.params,{unitId:n,mainComponent:r}=this._context;if(e!==n)return;let i=this._docSkeletonManagerService.getSkeleton();if(i==null)return;if(this._editorService.isEditor(n)&&n!==rf){r?.makeDirty();return}this._refreshDrawing(i)}}))}_initResize(){this.disposeWithMe(zy(this._context.engine.onTransformChange$).pipe(Ls(e=>e.type===qw.resize),Ks(16)).subscribe(()=>{var e;let t=this._docSkeletonManagerService.getSkeleton(),{scene:n}=this._context;(e=n.getTransformer())==null||e.refreshControls(),this._refreshDrawing(t)}))}_refreshDrawing(e){let t=e?.getSkeletonData(),{mainComponent:n,unitId:r}=this._context,i=n;if(!t)return;let{left:a,top:o,pageLayoutType:s,pageMarginLeft:c,pageMarginTop:l}=i,{pages:u,skeHeaders:d,skeFooters:f}=t,p={};this._liquid.reset();for(let e=0,t=u.length;e<t;e++){let t=u[e],{headerId:n,footerId:i,pageWidth:m}=t;if(n){let e=d.get(n)?.get(m);e&&(this._calculateDrawingPosition(r,e,a,o,p,e.marginTop,t.marginLeft),this._calculateTableCellDrawingPositions(r,e,a,o,p,e.marginTop,t.marginLeft))}if(i){let e=f.get(i)?.get(m);if(e){let n=t.pageHeight-t.marginBottom+e.marginTop;this._calculateDrawingPosition(r,e,a,o,p,n,t.marginLeft),this._calculateTableCellDrawingPositions(r,e,a,o,p,n,t.marginLeft)}}this._calculateDrawingPosition(r,t,a,o,p,t.marginTop,t.marginLeft),this._calculateTableCellDrawingPositions(r,t,a,o,p,t.marginTop,t.marginLeft),this._liquid.translatePage(t,s,c,l)}let m=Object.values(p),h=m.filter(e=>!e.isMultiTransform),g=m.filter(e=>e.isMultiTransform);h.length>0&&this._drawingManagerService.refreshTransform(h),this._handleMultiDrawingsTransform(g)}_handleMultiDrawingsTransform(e){let{scene:t,unitId:n}=this._context,r=t.getTransformerByCreate();e.forEach(e=>{let t=this._drawingManagerService.getDrawingByParam(e);t!=null&&(t.transform=e.transform,t.transforms=e.transforms,t.isMultiTransform=e.isMultiTransform)});let i=[...r.getSelectedObjectMap().keys()],a=Object.values(this._drawingManagerService.getDrawingData(n,n)).filter(e=>e.isMultiTransform===Np.TRUE);this._drawingManagerService.removeNotification(a),e.length>0&&this._drawingManagerService.addNotification(e);for(let e of i){let n=t.getObject(e);n&&r.setSelectedControl(n)}}_calculateDrawingPosition(e,t,n,r,i,a,o){let{skeDrawings:s}=t;this._liquid.translatePagePadding({marginTop:a,marginLeft:o}),s.forEach(t=>{let{aLeft:a,aTop:o,height:s,width:c,angle:l,drawingId:u,drawingOrigin:d}=t,f=d.layoutType===Kp.WRAP_NONE&&d.behindDoc===Np.TRUE,{isMultiTransform:p=Np.FALSE}=d,m={left:a+n+this._liquid.x,top:o+r+this._liquid.y,width:c,height:s,angle:l};i[u]==null?i[u]={unitId:e,subUnitId:e,drawingId:u,behindText:f,transform:m,transforms:[m],isMultiTransform:p}:p===Np.TRUE&&i[u].transforms.push(m)}),this._liquid.restorePagePadding({marginTop:a,marginLeft:o})}_calculateTableCellDrawingPositions(e,t,n,r,i,a,o){var s;(s=t.skeTables)==null||s.forEach(t=>{t.rows.forEach(s=>{s.cells.forEach(c=>{let l=zot(e,t,s,c),u=a+l.top,d=o+l.left;this._calculateDrawingPosition(e,c,n,r,i,u,d),this._calculateTableCellDrawingPositions(e,c,n,r,i,u,d)})})})}_drawingInitializeListener(){let e=()=>{let e=this._docSkeletonManagerService.getSkeleton();e!=null&&(this._refreshDrawing(e),this._drawingManagerService.initializeNotification(this._context.unitId))};this._lifecycleService.stage>=Xb.Rendered?this._docSkeletonManagerService.getSkeleton()?e():setTimeout(e,500):this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(Ls(e=>e===Xb.Rendered)).subscribe(e))}};VW=OW([DW(1,j(rD)),DW(2,R),DW(3,pI),DW(4,xN),DW(5,j(EW)),DW(6,z),DW(7,j($b))],VW);var Bot=`__InlineDrawingAnchor__`;function Vot(e,t){let n=t.parent,r=n?.parent,i=r?.parent;return!n||!r||!i||!n.cells?.includes(t)?null:{cell:t,hostPage:i,offset:zot(e,r,n,t),row:n,table:r}}var HW=class extends P{constructor(e,t,n,r){super(),this._commandService=e,this._univerInstanceService=t,this._drawingManagerService=n,this._renderManagerService=r,TW(this,`_liquid`,new TT),TW(this,`_listenerOnImageMap`,new Set),TW(this,`_transformerCache`,new Map),TW(this,`_anchorShape`,void 0),this._init()}_init(){this._listenDrawingFocus()}_listenDrawingFocus(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{if(e.length!==0)for(let t of e){let{unitId:e}=t;this._listenerOnImageMap.has(e)||(this._listenTransformerChange(e),this._listenerOnImageMap.add(e))}}))}_listenTransformerChange(e){let t=this._getSceneAndTransformerByDrawingSearch(e)?.transformer;if(t==null)return;this.disposeWithMe(Wf(t.changeStart$.subscribe(e=>{this._transformerCache.clear();let{objects:t}=e;for(let e of t.values()){var n;let{oKey:t,width:r,height:i,left:a,top:o,angle:s}=e,c=this._drawingManagerService.getDrawingOKey(t);if(c==null)continue;let l=this._univerInstanceService.getUniverDocInstance(c.unitId),u=l==null||(n=l.getSnapshot().drawings)==null?void 0:n[c.drawingId];if(u?.layoutType===Kp.INLINE)try{e.setOpacity(.2)}catch{}u!=null&&this._transformerCache.set(c.drawingId,{drawing:u,top:o,left:a,width:r,height:i,angle:s})}})));let n=_f(this._updateMultipleDrawingDocTransform.bind(this),50);this._nonInlineDrawingTransform.bind(this),this.disposeWithMe(Wf(t.changing$.subscribe(e=>{let{objects:t,offsetX:r,offsetY:i}=e;if(t.size>1)n(t);else if(t.size===1){let e=this._transformerCache.values().next().value,{width:n,height:a,top:o,left:s,angle:c}=t.values().next().value;if(e&&n===e.width&&a===e.height&&o===e.top&&s===e.left&&c===e.angle)return;e&&(e.drawing.layoutType,Kp.INLINE),e&&e.drawing.layoutType===Kp.INLINE&&r!=null&&i!=null&&this._updateInlineDrawingAnchor(e.drawing,r,i)}}))),this.disposeWithMe(Wf(t.changeEnd$.subscribe(e=>{let{objects:t,offsetX:n,offsetY:r}=e;for(let e of t.values()){let t=this._drawingManagerService.getDrawingOKey(e.oKey);if(t!=null&&this._transformerCache.get(t?.drawingId)?.drawing.layoutType===Kp.INLINE)try{e.setOpacity(1)}catch{}}if(this._anchorShape&&this._anchorShape.hide(),t.size>1)this._updateMultipleDrawingDocTransform(t);else if(t.size===1){let e=this._transformerCache.values().next().value,i=t.values().next().value,{width:a,height:o,top:s,left:c,angle:l}=i;if(e&&a===e.width&&o===e.height&&s===e.top&&c===e.left&&l===e.angle)return;e&&e.drawing.layoutType===Kp.INLINE?a!==e.width||o!==e.height||l!==e.angle?this._updateDrawingSize(e,i):n!=null&&r!=null&&this._moveInlineDrawing(e.drawing,n,r):e&&this._nonInlineDrawingTransform(e.drawing,i)}this._transformerCache.clear()})))}_updateMultipleDrawingDocTransform(e){if(e.size<1)return;let t=[],n,r;for(let i of e.values()){let{oKey:e,left:a,top:o,angle:s}=i,{width:c,height:l}=i,u=this._drawingManagerService.getDrawingOKey(e);if(u==null)continue;n??=u.unitId,r??=u.subUnitId;let d=this._transformerCache.get(u.drawingId);if(d==null)continue;let{drawing:f,top:p,left:m,width:h,height:g,angle:_}=d,{width:v,height:y}=this._getPageContentSize(f);if(c=Math.min(c,v),l=Math.min(l,y),(h!==c||g!==l)&&t.push({drawingId:u.drawingId,key:`size`,value:{width:c,height:l}}),_!==s&&t.push({drawingId:u.drawingId,key:`angle`,value:s}),p!==o||m!==a){let e=o-p,n=a-m;e!==0&&t.push({drawingId:u.drawingId,key:`positionV`,value:{relativeFrom:f.docTransform.positionV.relativeFrom,posOffset:f.docTransform.positionV.posOffset+e}}),n!==0&&t.push({drawingId:u.drawingId,key:`positionH`,value:{relativeFrom:f.docTransform.positionH.relativeFrom,posOffset:f.docTransform.positionH.posOffset+n}})}}t.length>0&&n&&r&&this._commandService.executeCommand(jW.id,{unitId:n,subUnitId:r,drawings:t})}_updateDrawingAnchor(e){if(this._transformerCache.size!==1)return;let t=this._transformerCache.values().next().value,n=e.values().next().value;this._getDrawingAnchor(t.drawing,n)}_updateInlineDrawingAnchor(e,t,n){if(this._transformerCache.size!==1)return;let{contentBoxPointGroup:r}=this._getInlineDrawingAnchor(e,t,n)??{};r!=null&&this._createOrUpdateInlineAnchor(e.unitId,r)}_getInlineDrawingAnchor(e,t,n){let r=this._renderManagerService.getRenderById(e.unitId),i=r?.with(rD).getSkeleton();if(r==null)return;let{mainComponent:a,scene:o}=r,s=a,c=o.getViewports()[0],{pageLayoutType:l=Rw.VERTICAL,pageMarginLeft:u,pageMarginTop:d}=s.getOffsetConfig(),f=null,p=!1,m=-1,h=``,g=this._getTransformCoordForDocumentOffset(s,c,t,n);if(g==null)return;let _=this._renderManagerService.getRenderById(e.unitId)?.with(XF);if(_==null)return;let v=i?.findNodeByCoord(g,l,u,d,{strict:!1,segmentId:_.getSegment(),segmentPage:_.getSegmentPage()});if(v){let{node:e,ratioX:t,segmentPage:n,segmentId:r}=v;p=t<.5,f=e,m=n,h=r}if(f==null)return;let y=i?.findPositionByGlyph(f,m),b=this._getDocObject();if(y==null||i==null||b==null)return;let x={...y,isBack:p},{cursorList:S,contentBoxPointGroup:C}=new BF(b.document.getOffsetConfig(),i).getRangePointData(x,x),{startOffset:w}=RF(S)??{};if(w!=null)return{offset:w,contentBoxPointGroup:C,segmentId:h,segmentPage:m}}_getDrawingAnchor(e,t){var n;let r=this._renderManagerService.getRenderById(e.unitId),i=r?.with(rD).getSkeleton(),a=i?.getSkeletonData();if(a==null||r==null)return;let{pages:o,skeHeaders:s,skeFooters:c}=a,{mainComponent:l,scene:u}=r,d=l,f=u.getViewports()[0],{pageLayoutType:p=Rw.VERTICAL,pageMarginLeft:m,pageMarginTop:h,docsLeft:g,docsTop:_}=d.getOffsetConfig(),{left:v,top:y,angle:b}=t,{width:x,height:S}=t,{positionV:C,positionH:w}=e.docTransform,{width:T,height:E}=this._getPageContentSize(e);x=Math.min(x,T),S=Math.min(S,E);let D=null,O=``,k=-1,A={...e.docTransform,size:{width:x,height:S},angle:b},{x:ee,y:te}=u.getViewportScrollXY(f),ne=this._getTransformCoordForDocumentOffset(d,f,v-ee,y-te);if(ne==null)return;let re=this._renderManagerService.getRenderById(e.unitId)?.with(XF);if(re==null)return;let ie=i?.findNodeByCoord(ne,p,m,h,{strict:!1,segmentId:re.getSegment(),segmentPage:re.getSegmentPage()});if(ie){let{node:e,segmentPage:t,segmentId:n}=ie;D=e,k=t,O=n}if(D==null)return;let ae=D.parent?.parent,oe=ae?.parent,se=oe?.lines.find(e=>e.paragraphIndex===ae?.paragraphIndex&&e.paragraphStart)??oe?.lines[0],ce=oe==null||(n=oe.parent)==null?void 0:n.parent;if(ae==null||oe==null||se==null||ce==null)return;this._liquid.reset();let le=ce.type===Iw.CELL?Vot(e.unitId,ce):null,ue=le?.hostPage??ce,de=ue.type;for(let e of o){let{headerId:t,footerId:n,pageHeight:r,pageWidth:i,marginLeft:a,marginBottom:l}=e,u=o.indexOf(e);if(k>-1&&u===k){switch(de){case Iw.HEADER:{let e=s.get(t)?.get(i);if(e)this._liquid.translatePagePadding({marginTop:e.marginTop,marginLeft:a});else throw Error(`header skeleton not found`);break}case Iw.FOOTER:{let e=c.get(n)?.get(i);if(e)this._liquid.translatePagePadding({marginTop:r-l+e.marginTop,marginLeft:a});else throw Error(`footer skeleton not found`);break}default:this._liquid.translatePagePadding(e)}break}if(this._liquid.translatePagePadding(e),e===ue)break;this._liquid.restorePagePadding(e),this._liquid.translatePage(e,p,m,h)}if(le&&this._liquid.translate(le.offset.left,le.offset.top),C.relativeFrom===rm.LINE)D=ae.divides[0].glyphGroup[0];else{var fe;D=((fe=se.divides)==null||(fe=fe[0])==null||(fe=fe.glyphGroup)==null?void 0:fe[0])??D}switch(A.positionH={relativeFrom:w.relativeFrom,posOffset:v-this._liquid.x-g},w.relativeFrom){case nm.MARGIN:A.positionH.posOffset=v-this._liquid.x-g-ce.marginLeft;break;case nm.COLUMN:A.positionH.posOffset=v-this._liquid.x-g-oe.left}switch(A.positionV={relativeFrom:C.relativeFrom,posOffset:y-this._liquid.y-_},C.relativeFrom){case rm.PAGE:A.positionV.posOffset=y-this._liquid.y-_-ce.marginTop;break;case rm.LINE:A.positionV.posOffset=y-this._liquid.y-_-ae.top;break;case rm.PARAGRAPH:A.positionV.posOffset=y-this._liquid.y-_-se.top}if(D==null)return;let pe=i?.findPositionByGlyph(D,k),me=this._getDocObject();if(pe==null||i==null||me==null)return;let he={...pe,isBack:!1},{cursorList:ge}=new BF(me.document.getOffsetConfig(),i).getRangePointData(he,he),{startOffset:_e}=RF(ge)??{};if(_e!=null)return{offset:_e,docTransform:A,segmentId:O,segmentPage:k}}_updateDrawingSize(e,t){let n=[],{drawing:r,width:i,height:a,angle:o}=e,{unitId:s,subUnitId:c}=r,{width:l,height:u,angle:d}=t,{width:f,height:p}=this._getPageContentSize(r);l=Math.min(f,l),u=Math.min(p,u),(l!==i||u!==a)&&n.push({drawingId:r.drawingId,key:`size`,value:{width:l,height:u}}),d!==o&&n.push({drawingId:r.drawingId,key:`angle`,value:d}),n.length>0&&s&&c&&this._commandService.executeCommand(jW.id,{unitId:s,subUnitId:c,drawings:n})}_moveInlineDrawing(e,t,n){let{offset:r,segmentId:i,segmentPage:a}=this._getInlineDrawingAnchor(e,t,n)??{};return this._commandService.executeCommand(wot.id,{unitId:e.unitId,subUnitId:e.unitId,drawing:e,offset:r,segmentId:i,segmentPage:a,needRefreshDrawings:r==null})}_limitDrawingInPage(e,t){let n=this._renderManagerService.getRenderById(e.unitId),{left:r,top:i,width:a,height:o,angle:s}=t,c=(n?.with(rD).getSkeleton())?.getSkeletonData(),{pages:l}=c??{};if(c==null||n==null||l==null)return{left:r,top:i,width:a,height:o,angle:s};let{mainComponent:u}=n,{top:d,pageLayoutType:f,pageMarginLeft:p,pageMarginTop:m}=u,h=i;this._liquid.reset();for(let e of l){let{marginBottom:t,pageHeight:n}=e,r=l[l.indexOf(e)+1];r!=null&&(F.hasIntersectionBetweenTwoRanges(i,i+o,this._liquid.y+d+n-t,this._liquid.y+d+n+m+r.marginTop)&&(h=i+o/2<this._liquid.y+d+n+m/2?Math.min(i,this._liquid.y+d+n-t-o):Math.max(i,this._liquid.y+d+n+m+r.marginTop)),this._liquid.translatePage(e,f,p,m))}return{left:r,top:h,width:a,height:o,angle:s}}_nonInlineDrawingTransform(e,t,n=!1){let r=e.isMultiTransform===Np.TRUE?t:this._limitDrawingInPage(e,t);if(n&&r.top!==t.top)return;let{offset:i,docTransform:a,segmentId:o,segmentPage:s}=this._getDrawingAnchor(e,r)??{};return i==null||a==null?this._updateMultipleDrawingDocTransform(new Map([[e.drawingId,t]])):this._commandService.executeCommand(Tot.id,{unitId:e.unitId,subUnitId:e.unitId,drawing:e,offset:i,docTransform:a,segmentId:o,segmentPage:s})}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e)?.scene;if(t!=null)return{scene:t,transformer:t.getTransformerByCreate()}}_getTransformCoordForDocumentOffset(e,t,n,r){let{documentTransform:i}=e.getOffsetConfig(),a=t.transformVector2SceneCoord(zw.FromArray([n,r]));if(a)return i.clone().invert().applyPoint(a)}_createOrUpdateInlineAnchor(e,t){let n=this._renderManagerService.getRenderById(e);if(n==null)return;let{mainComponent:r,scene:i}=n,{docsLeft:a,docsTop:o}=r.getOffsetConfig(),{left:s,top:c,height:l}=UF(t),u=s+a,d=c+o;if(this._anchorShape){this._anchorShape.transformByState({left:u,top:d,height:l}),this._anchorShape.show();return}let f=new OE(Bot+ip(6),{left:u,top:d,height:l,strokeWidth:2,stroke:xw(nh.darkgray,1),evented:!1});this._anchorShape=f,i.addObject(f,3)}_getDocObject(){return xYe(this._univerInstanceService,this._renderManagerService)}_getPageContentSize(e){let t=this._renderManagerService.getRenderById(e.unitId),n=(t?.with(rD).getSkeleton())?.getSkeletonData();if(n==null||t==null)return{width:500,height:500};let{pages:r}=n,i=null;for(let t of r){let{skeDrawings:n}=t;if(n.has(e.drawingId)){i=t;break}}if(i){let{pageWidth:e,pageHeight:t,marginLeft:n,marginBottom:r,marginRight:a,marginTop:o}=i;return{width:Math.max(500,e-n-a),height:Math.max(500,t-o-r)}}return{width:500,height:500}}};HW=OW([DW(0,R),DW(1,z),DW(2,xN),DW(3,KE)],HW);var Hot={[pM.MEDIA]:{[kot]:{order:0,menuItemFactory:jot,[LW]:{order:0,menuItemFactory:RW}}},[hM.PARAGRAPH]:{[gM.LAYOUT]:{[GI]:{[LW]:{order:5,menuItemFactory:RW}}},[BI]:{[gM.LAYOUT]:{[LW]:{order:5,menuItemFactory:RW}}},[I1e]:{[gM.LAYOUT]:{[LW]:{order:5,menuItemFactory:RW}}}}},Uot=-1e3,Wot=1e3,Got=e=>{let t=U(R),n=U(nx),r=U(xN),i=U(KE),a=U(z),{drawings:o}=e,s=o[0];if(s==null)return;let{unitId:c}=s,l=a.getUniverDocInstance(c),u=l?.getSnapshot().documentStyle.documentFlavor,d=i.getRenderById(c)?.scene;if(d==null)return;let f=d.getTransformerByCreate(),p=[{label:n.t(`docs-drawing-ui.image-position.column`),value:String(nm.COLUMN)},{label:n.t(`docs-drawing-ui.image-position.page`),value:String(nm.PAGE)},{label:n.t(`docs-drawing-ui.image-position.margin`),value:String(nm.MARGIN)}],m=[{label:n.t(`docs-drawing-ui.image-position.line`),value:String(rm.LINE),disabled:u===Vp.MODERN},{label:n.t(`docs-drawing-ui.image-position.page`),value:String(rm.PAGE),disabled:u===Vp.MODERN},{label:n.t(`docs-drawing-ui.image-position.margin`),value:String(rm.MARGIN),disabled:u===Vp.MODERN},{label:n.t(`docs-drawing-ui.image-position.paragraph`),value:String(rm.PARAGRAPH)}],[h,g]=(0,V.useState)(!0),[_,v]=(0,V.useState)({relativeFrom:nm.PAGE,posOffset:0}),[y,b]=(0,V.useState)({relativeFrom:rm.PAGE,posOffset:0}),[x,S]=(0,V.useState)(!0),[C,w]=(0,V.useState)(!0);function T(e,n){e===`positionH`?v(n):b(n);let a=r.getFocusDrawings();if(a.length===0)return;let o=a.map(e=>({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}));t.executeCommand(jW.id,{unitId:a[0].unitId,subUnitId:a[0].unitId,drawings:o.map(t=>({drawingId:t.drawingId,key:e,value:n}))});let s=i.getRenderById(c)?.with(XF);s&&s.blur(),f.refreshControls()}function E(e){let t=_.relativeFrom,n=_.posOffset,a=Number(e);if(t===a)return;let o=r.getFocusDrawings();if(o.length===0)return;let s=o[0].drawingId,c=o[0].unitId,l=null,u=0,d=(i.getRenderById(c)?.with(rD).getSkeleton())?.getSkeletonData();if(d==null)return;let{pages:f,skeHeaders:p,skeFooters:m}=d;for(let e of f){let{marginLeft:t,skeDrawings:n,headerId:r,footerId:i,pageWidth:a}=e;if(n.has(s)){l=n.get(s),u=t;break}let o=p.get(r)?.get(a);if(o?.skeDrawings.has(s)){l=o?.skeDrawings.get(s),u=t;break}let c=m.get(i)?.get(a);if(c?.skeDrawings.has(s)){l=c?.skeDrawings.get(s),u=t;break}}if(l==null)return;let h=0;t===nm.COLUMN?h-=l.columnLeft:t===nm.MARGIN&&(h-=u),a===nm.COLUMN?h+=l.columnLeft:a===nm.MARGIN?h+=u:nm.PAGE,T(`positionH`,{relativeFrom:a,posOffset:(n??0)-h})}function D(e){var t,n,o;let s=y.relativeFrom,c=y.posOffset,l=Number(e);if(s===l)return;let u=r.getFocusDrawings();if(u.length===0)return;let{drawingId:d,unitId:f}=u[0],p=a.getUniverDocInstance(f),m=i.getRenderById(f)?.with(rD).getSkeleton(),h=i.getRenderById(f)?.with(XF),g=h?.getSegment(),_=h?.getSegmentPage(),v=p==null||(t=p.getSelfOrHeaderFooterModel(g).getBody())==null||(t=t.customBlocks)==null?void 0:t.find(e=>e.blockId===d);if(v==null||m==null||h==null)return;let{startIndex:b}=v,x=m.findNodeByCharIndex(b,g,_),S=x==null||(n=x.parent)==null?void 0:n.parent,C=S?.parent,w=C?.lines.find(e=>e.paragraphIndex===S?.paragraphIndex&&e.paragraphStart),E=C==null||(o=C.parent)==null?void 0:o.parent;if(x==null||S==null||w==null||C==null||E==null)return;let D=0;s===rm.PARAGRAPH?D-=w.top:s===rm.LINE?D-=S.top:s===rm.PAGE&&(D+=E.marginTop),l===rm.PARAGRAPH?D+=w.top:l===rm.LINE?D+=S.top:l===rm.PAGE&&(D-=E.marginTop),T(`positionV`,{relativeFrom:l,posOffset:(c??0)-D})}function O(e){var t;let n=l?.getSnapshot(),r=n==null||(t=n.drawings)==null?void 0:t[e.drawingId];if(r==null)return;let{layoutType:i}=r,{positionH:a,positionV:o}=r.docTransform;v(a),b(o),g(i===Kp.INLINE),S(o.relativeFrom===rm.PARAGRAPH||o.relativeFrom===rm.LINE)}function k(){let e=r.getFocusDrawings();e.length!==0&&O(e[0])}function A(e){S(e),D(String(e?rm.PARAGRAPH:rm.PAGE))}return(0,V.useEffect)(()=>{k();let e=r.focus$.subscribe(e=>{if(e.length===0){w(!1);return}w(!0),O(e[0])}),n=t.onCommandExecuted(async e=>{e.id===aD.id&&k()});return()=>{e.unsubscribe(),n.dispose()}},[]),(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!C}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.title`)})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.horizontal`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.absolutePosition`)}),(0,H.jsx)(dj,{min:Uot,max:Wot,precision:1,disabled:h,value:_.posOffset,onChange:e=>{T(`positionH`,{relativeFrom:_.relativeFrom,posOffset:e})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.toTheRightOf`)}),(0,H.jsx)(bj,{value:String(_.relativeFrom),disabled:h,options:p,onChange:E})]})]}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.vertical`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.absolutePosition`)}),(0,H.jsx)(dj,{min:Uot,max:Wot,precision:1,disabled:h,value:y.posOffset,onChange:e=>{T(`positionV`,{relativeFrom:y.relativeFrom,posOffset:e})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-position.bellow`)}),(0,H.jsx)(bj,{disabled:h,value:String(y.relativeFrom),options:m,onChange:D})]})]}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-position.options`)})}),(0,H.jsx)(`div`,{children:(0,H.jsx)($A,{disabled:h,checked:x,onChange:A,children:n.t(`docs-drawing-ui.image-position.moveObjectWithText`)})})]})},UW=0,WW=100,Kot=e=>{let t=U(R),n=U(nx),r=U(xN),i=U(KE),a=U(z),{drawings:o}=e,s=o[0];if(s==null)return null;let{unitId:c}=s,l=a.getUniverDocInstance(c);if(i.getRenderById(c)?.scene==null)return null;let[u,d]=(0,V.useState)(!0),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(!0),[g,_]=(0,V.useState)(`inline`),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)({distT:0,distL:0,distB:0,distR:0}),[S,C]=(0,V.useState)(!0);function w(e){_(e);let n=r.getFocusDrawings();if(n.length===0)return;let{unitId:i,subUnitId:a}=n[0],o=n.map(({unitId:e,subUnitId:t,drawingId:n})=>({unitId:e,subUnitId:t,drawingId:n}));t.executeCommand(xot.id,{unitId:i,subUnitId:a,drawings:o,wrappingStyle:e})}function T(e){y(e);let n=r.getFocusDrawings();if(n.length===0)return;let i=n.map(e=>({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}));t.executeCommand(Cot.id,{unitId:n[0].unitId,subUnitId:n[0].unitId,drawings:i,wrapText:e})}function E(e,n){if(e==null)return;x({...b,[n]:e});let i=r.getFocusDrawings();if(i.length===0)return;let a=i.map(e=>({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}));t.executeCommand(Sot.id,{unitId:i[0].unitId,subUnitId:i[0].unitId,drawings:a,dist:{[n]:e}})}function D(){let e=r.getFocusDrawings();e.length!==0&&O(e[0])}function O(e){var t;let n=l==null||(t=l.getSnapshot())==null||(t=t.drawings)==null?void 0:t[e.drawingId];if(n==null)return;let{distT:r=0,distL:i=0,distB:a=0,distR:o=0,layoutType:s=Kp.INLINE,behindDoc:c=Np.FALSE,wrapText:u=Gp.BOTH_SIDES}=n;if(x({distT:r,distL:i,distB:a,distR:o}),y(u),d(s!==Kp.WRAP_SQUARE),s===Kp.WRAP_NONE||s===Kp.INLINE?p(!0):p(!1),s===Kp.WRAP_NONE||s===Kp.INLINE||s===Kp.WRAP_TOP_AND_BOTTOM?h(!0):h(!1),s===Kp.WRAP_NONE)c===Np.TRUE?_(`behindText`):_(`inFrontOfText`);else switch(s){case Kp.INLINE:_(`inline`);break;case Kp.WRAP_SQUARE:_(`wrapSquare`);break;case Kp.WRAP_TOP_AND_BOTTOM:_(`wrapTopAndBottom`);break;default:throw Error(`Unsupported layout type: ${s}`)}}return(0,V.useEffect)(()=>{D();let e=r.focus$.subscribe(e=>{if(e.length===0){C(!1);return}C(!0),O(e[0])}),n=t.onCommandExecuted(async e=>{e.id===aD.id&&D()});return()=>{e.unsubscribe(),n.dispose()}},[]),(0,H.jsxs)(`div`,{className:W(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!S}),children:[(0,H.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.title`)})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.wrappingStyle`)})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(vj,{value:g,onChange:w,direction:`vertical`,children:[(0,H.jsx)(yj,{value:`inline`,children:n.t(`docs-drawing-ui.image-text-wrap.inline`)}),(0,H.jsx)(yj,{value:`wrapSquare`,children:n.t(`docs-drawing-ui.image-text-wrap.square`)}),(0,H.jsx)(yj,{value:`wrapTopAndBottom`,children:n.t(`docs-drawing-ui.image-text-wrap.topAndBottom`)}),(0,H.jsx)(yj,{value:`behindText`,children:n.t(`docs-drawing-ui.image-text-wrap.behindText`)}),(0,H.jsx)(yj,{value:`inFrontOfText`,children:n.t(`docs-drawing-ui.image-text-wrap.inFrontText`)})]})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.wrapText`)})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(vj,{disabled:u,value:v,onChange:T,direction:`horizontal`,children:[(0,H.jsx)(yj,{value:Gp.BOTH_SIDES,children:n.t(`docs-drawing-ui.image-text-wrap.bothSide`)}),(0,H.jsx)(yj,{value:Gp.LEFT,children:n.t(`docs-drawing-ui.image-text-wrap.leftOnly`)}),(0,H.jsx)(yj,{value:Gp.RIGHT,children:n.t(`docs-drawing-ui.image-text-wrap.rightOnly`)})]})}),(0,H.jsx)(`div`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,H.jsx)(`div`,{children:n.t(`docs-drawing-ui.image-text-wrap.distanceFromText`)})}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.top`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:f,precision:1,value:b.distT,onChange:e=>{E(e,`distT`)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.left`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:m,precision:1,value:b.distL,onChange:e=>{E(e,`distL`)}})]})]}),(0,H.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.bottom`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:f,precision:1,value:b.distB,onChange:e=>{E(e,`distB`)}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:n.t(`docs-drawing-ui.image-text-wrap.right`)}),(0,H.jsx)(dj,{min:UW,max:WW,disabled:m,precision:1,value:b.distR,onChange:e=>{E(e,`distR`)}})]})]})]})},qot=()=>{let e=U(xN),[t,n]=(0,V.useState)(e.getFocusDrawings());return(0,V.useEffect)(()=>{let t=e.focus$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[]),!!t?.length&&(0,H.jsxs)(`div`,{className:`univer-text-sm`,children:[(0,H.jsx)(uot,{drawings:t,hasAlign:!1,hasCropper:!0,hasGroup:!1,hasTransform:!1}),(0,H.jsx)(Kot,{drawings:t}),(0,H.jsx)(Got,{drawings:t})]})};function GW(e){return e.getContextValue(`FOCUSING_DOC`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&e.getContextValue(`FOCUSING_COMMON_DRAWINGS`)}var Jot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-down`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_DOWN,priority:100,preconditions:GW,staticParameters:{direction:I.DOWN}},Yot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-up`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_UP,priority:100,preconditions:GW,staticParameters:{direction:I.UP}},Xot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-left`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_LEFT,priority:100,preconditions:GW,staticParameters:{direction:I.LEFT}},Zot={id:MW.id,description:`docs-drawing-ui.shortcut.drawing-move-right`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,binding:aM.ARROW_RIGHT,priority:100,preconditions:GW,staticParameters:{direction:I.RIGHT}},Qot={id:dot.id,description:`docs-drawing-ui.shortcut.drawing-delete`,group:`4_drawing-view`,groupTitle:`docs-drawing-ui.shortcut.drawing-view`,preconditions:GW,binding:aM.DELETE,mac:aM.BACKSPACE},KW=class extends P{constructor(e,t,n,r){super(),this._componentManager=e,this._menuManagerService=t,this._commandService=n,this._shortcutService=r,this._init()}_initCustomComponents(){let e=this._componentManager;this.disposeWithMe(e.register(Dot,qot))}_initMenus(){this._menuManagerService.mergeMenu(Hot)}_initCommands(){[vot,CW,xot,Sot,Cot,jW,wot,Tot,SW,NW,Eot,PW,fot,hot,MW,dot,mot].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initShortcuts(){[Jot,Yot,Xot,Zot,Qot].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};KW=OW([DW(0,j(Nj)),DW(1,_M),DW(2,R),DW(3,cM)],KW);var qW=class extends Kf{constructor(e,t,n,r,i,a){super(),this._drawingManagerService=e,this._canvasPopManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._contextService=i,this._commandService=a,TW(this,`_initImagePopupMenu`,new Set),TW(this,`_disposePopups`,[]),TW(this,`_isDrawingPanelOpen`,!1),this._init()}_init(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===PW.id&&(this._isDrawingPanelOpen=!0,this._clearPopups()),e.id===NW.id){let t=e.params;this._isDrawingPanelOpen=t?.value===`open`,this._isDrawingPanelOpen&&this._clearPopups()}})),this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e.length===0&&(this._isDrawingPanelOpen=!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_DOC).pipe(cc(this.dispose$)).subscribe(e=>this._create(e))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_DOC).pipe(cc(this.dispose$)).subscribe(e=>this._dispose(e))),this._univerInstanceService.getAllUnitsForType(M.UNIVER_DOC).forEach(e=>this._create(e))}_dispose(e){let t=e.getUnitId();this._clearPopups(),this._renderManagerService.removeRender(t)}_clearPopups(){this._disposePopups.forEach(e=>e.dispose()),this._disposePopups.length=0}_create(e){if(!e)return;let t=e.getUnitId();lf(t)||this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(e){let t=e.getAllObjects();for(let e of t)if(e instanceof hW)return!0;return!1}_popupMenuListener(e){let t=this._renderManagerService.getRenderById(e)?.scene;if(!t)return;let n=t.getTransformerByCreate();if(!n)return;let r=this._disposePopups;this.disposeWithMe(n.createControl$.subscribe(()=>{if(this._hasCropObject(t))return;let e=n.getSelectedObjectMap();if(r.forEach(e=>e.dispose()),r.length=0,this._isDrawingPanelOpen||e.size>1)return;let i=e.values().next().value;if(!i)return;let a=i.oKey,o=this._drawingManagerService.getDrawingOKey(a);if(!o||o.drawingType===um.DRAWING_DOM||o.drawingType===um.DRAWING_SHAPE)return;let{unitId:s,subUnitId:c,drawingId:l,drawingType:u}=o,d=u===um.DRAWING_IMAGE,f=this._canvasPopManagerService.attachPopupToObject(i,{componentKey:iW,direction:d?`top-center`:`horizontal`,offset:d?[0,8]:[2,0],extraProps:{menuItems:this._getImageMenuItems(s,c,l,u),variant:d?`doc-floating-toolbar`:void 0,unitId:s,subUnitId:c,drawingId:l}},s);r.push(this.disposeWithMe(f)),!this._drawingManagerService.getFocusDrawings().find(e=>e.unitId===s&&e.subUnitId===c&&e.drawingId===l)&&this._drawingManagerService.focusDrawing([{unitId:s,subUnitId:c,drawingId:l}])})),this.disposeWithMe(n.clearControl$.subscribe(()=>{r.forEach(e=>e.dispose()),r.length=0,this._contextService.setContextValue(ab,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(n.changing$.subscribe(()=>{r.forEach(e=>e.dispose()),r.length=0})),this.disposeWithMe(n.changeStart$.subscribe(()=>{r.forEach(e=>e.dispose()),r.length=0}))}_getImageMenuItems(e,t,n,r){return[{label:`docs-drawing-ui.image-popup.edit`,index:0,commandId:PW.id,commandParams:{unitId:e,subUnitId:t,drawingId:n},disable:r===um.DRAWING_DOM},{label:`docs-drawing-ui.image-popup.delete`,index:1,commandId:SW.id,commandParams:{unitId:e,drawings:[{unitId:e,subUnitId:t,drawingId:n}]},disable:!1},{label:`docs-drawing-ui.image-popup.crop`,index:2,commandId:QU.id,commandParams:{unitId:e,subUnitId:t,drawingId:n},disable:r===um.DRAWING_DOM},{label:`docs-drawing-ui.image-popup.reset`,index:3,commandId:tW.id,commandParams:[{unitId:e,subUnitId:t,drawingId:n}],disable:!0}]}};qW=OW([DW(0,xN),DW(1,j(YI)),DW(2,KE),DW(3,z),DW(4,Fm),DW(5,R)],qW);var JW=class extends dx{constructor(e=Fot,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=r;let{...i}=Qi({},Fot,this._config);this._configService.setConfig(Pot,i)}onStarting(){[[KW],[qW],[HW],[zW],[EW],[IW],[BW]].forEach(e=>this._injector.add(e))}onReady(){[[kW],[VW]].forEach(e=>this._renderManagerSrv.registerRenderModule(M.UNIVER_DOC,e)),this._injector.get(zW),this._injector.get(KW),this._injector.get(HW),this._injector.get(BW)}onRendered(){this._injector.get(qW),this._injector.get(IW)}};TW(JW,`type`,M.UNIVER_DOC),TW(JW,`pluginName`,`DOC_DRAWING_UI_PLUGIN`),TW(JW,`packageName`,Mot),TW(JW,`version`,Not),JW=OW([px(bW,DN,PU,_N),DW(1,j(We)),DW(2,KE),DW(3,Nm)],JW);function $ot(e={}){let{collaboration:t=!1}=e;return{plugins:[[DN,{override:t?[[ub,null]]:[]}],bW,PU,JW].filter(e=>!!e)}}var est={"docs-drawing-ui":{title:`图片`,upload:{float:`插入图片`},panel:{title:`编辑图片`},"image-popup":{replace:`替换`,delete:`删除`,edit:`编辑`,crop:`裁剪`,reset:`重置大小`},"image-text-wrap":{title:`文字环绕`,wrappingStyle:`环绕方式`,square:`四周型`,topAndBottom:`上下型`,inline:`嵌入型`,behindText:`衬于文字下方`,inFrontText:`浮于文字上方`,wrapText:`自动换行`,bothSide:`两侧`,leftOnly:`左侧`,rightOnly:`右侧`,distanceFromText:`距正文`,top:`上(px)`,left:`左(px)`,bottom:`下(px)`,right:`右(px)`},"image-position":{title:`位置`,horizontal:`水平`,vertical:`垂直`,absolutePosition:`绝对位置(px)`,relativePosition:`相对位置`,toTheRightOf:`右侧`,relativeTo:`相对于`,bellow:`下方`,options:`选项`,moveObjectWithText:`对象随文字移动`,column:`栏`,margin:`页边距`,page:`页面`,line:`行`,paragraph:`段落`},"update-status":{exceedMaxSize:`图片大小超过限制, 限制为{0}M`,invalidImageType:`图片类型错误`,exceedMaxCount:`图片只能一次上传{0}张`,invalidImage:`无效图片`},shortcut:{"drawing-view":`绘图视图`,"drawing-move-down":`下移绘图`,"drawing-move-up":`上移绘图`,"drawing-move-left":`左移绘图`,"drawing-move-right":`右移绘图`,"drawing-delete":`删除绘图`}}},tst={"drawing-ui":{"image-cropper":{error:`无法裁剪非图片元素`},"image-panel":{arrange:{title:`排列`,forward:`上移一层`,backward:`下移一层`,front:`置于顶层`,back:`置于底层`},transform:{title:`变换`,rotate:`旋转 (°)`,x:`X (px)`,y:`Y (px)`,width:`宽度 (px)`,height:`高度 (px)`,lock:`锁定比例 (%)`},crop:{title:`裁剪`,start:`开始裁剪`,mode:`自由比例裁剪`},group:{title:`组合`,group:`组合`,unGroup:`取消组合`},align:{title:`对齐方式`,default:`选择对齐方式`,left:`左对齐`,center:`水平居中`,right:`右对齐`,top:`顶部对齐`,middle:`垂直居中`,bottom:`底部对齐`,horizon:`水平分布`,vertical:`垂直分布`},null:`未选中任何对象`},"image-text-wrap":{title:`文字环绕`,wrappingStyle:`环绕方式`,square:`四周型`,topAndBottom:`上下型`,inline:`嵌入型`,behindText:`衬于文字下方`,inFrontText:`浮于文字上方`,wrapText:`自动换行`,bothSide:`两侧`,leftOnly:`左侧`,rightOnly:`右侧`,distanceFromText:`距正文`,top:`上(px)`,left:`左(px)`,bottom:`下(px)`,right:`右(px)`},"image-popup":{replace:`替换`,delete:`删除`,edit:`编辑`,crop:`裁剪`,reset:`重置大小`}}},nst=Rg(est,tst),rst=`@univerjs/docs-hyper-link`,ist=`0.25.1`,ast={id:`docs.mutation.add-hyper-link`,type:L.MUTATION,handler:()=>!0},ost={id:`docs.mutation.update-hyper-link`,type:L.MUTATION,handler:()=>!0},sst={id:`docs.mutation.delete-hyper-link`,type:L.MUTATION,handler:()=>!0},cst=`docs-hyper-link.config`,lst={};function YW(e,t){return function(n,r){t(n,r,e)}}function ust(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var dst=`DOC_HYPER_LINK_PLUGIN`,XW=class extends P{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){this._resourceManagerService.registerPluginResource({pluginName:dst,businesses:[M.UNIVER_DOC],onLoad:(e,t)=>{let n=this._univerInstanceService.getUnit(e,M.UNIVER_DOC);if(!n)return;let r=new Map,i=e=>{var t;return(t=e.getBody())==null||(t=t.customRanges)==null||t.forEach(e=>{e.rangeType===Rp.HYPERLINK&&r.set(e.rangeId,e)}),r};n.headerModelMap.forEach(e=>{i(e)}),n.footerModelMap.forEach(e=>{i(e)}),i(n),t.links.forEach(e=>{let t=r.get(e.id);t&&(t.properties={...t.properties,url:e.payload})})},onUnLoad:e=>{},toJson:e=>{let t=this._univerInstanceService.getUnit(e,M.UNIVER_DOC),n=[];if(t){let e=e=>{var t;(t=e.getBody())==null||(t=t.customRanges)==null||t.forEach(e=>{e.rangeType===Rp.HYPERLINK&&n.push({id:e.rangeId,payload:e.properties?.url||``})})};t.headerModelMap.forEach(t=>{e(t)}),t.footerModelMap.forEach(t=>{e(t)}),e(t)}return JSON.stringify({links:n})},parseJson(e){return JSON.parse(e)}})}};XW=ust([YW(0,j(By)),YW(1,z)],XW);function ZW(e){"@babel/helpers - typeof";return ZW=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ZW(e)}function fst(e,t){if(ZW(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ZW(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function pst(e){var t=fst(e,`string`);return ZW(t)==`symbol`?t:t+``}function QW(e,t,n){return(t=pst(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var $W=class extends dx{constructor(e=lst,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._commandService=r;let{...i}=Qi({},lst,this._config);this._configService.setConfig(cst,i)}onStarting(){[[XW]].forEach(e=>this._injector.add(e)),[ast,sst,ost].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),this._injector.get(XW)}};QW($W,`pluginName`,dst),QW($W,`packageName`,rst),QW($W,`version`,ist),QW($W,`type`,M.UNIVER_DOC),$W=ust([YW(1,j(We)),YW(2,Nm),YW(3,R)],$W);var mst=`@univerjs/docs-hyper-link-ui`,hst=`0.25.1`,gst=`docs-hyper-link-ui.config`,_st={},vst={type:L.COMMAND,id:`docs.command.add-hyper-link`,async handler(e,t){if(!t)return!1;let{payload:n,unitId:r,selections:i}=t,a=e.get(R),o=uAe(e,{rangeId:ip(),rangeType:Rp.HYPERLINK,properties:{url:n},unitId:r,selections:i});return o?a.syncExecuteCommand(o.id,o.params):!1}},yst={id:`docs.command.update-hyper-link`,type:L.COMMAND,handler(e,t){if(!t)return!1;let{unitId:n,payload:r,segmentId:i,linkId:a}=t,o=e.get(R),s=e.get(z),c=e.get(nD).getActiveTextRange(),l=s.getUnit(n,M.UNIVER_DOC);if(!c||!l)return!1;let u=yv(l.getSelfOrHeaderFooterModel(i).getBody(),c.startOffset,c.endOffset).textRuns?.[0];u&&(u.ed=t.label.length+1);let d=uD(e,{unitId:n,body:{dataStream:`${t.label}`,customRanges:[{rangeId:a,rangeType:Rp.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:r}}],textRuns:u?[u]:void 0},selection:{startOffset:c.startOffset,endOffset:c.endOffset,collapsed:!1,segmentId:i}});return d?o.syncExecuteCommand(d.id,d.params):!1}};function eG(e){return e.trim().length===0}function bst(e){return/^[a-zA-Z]+:\/\//.test(e)}function xst(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Sst(e){return bst(e)?e:xst(e)?`mailto://${e}`:`https://${e}`}var tG=()=>{let e=U(lG),t=U(nx),n=QD(e.editingLink$),r=U(R),i=U(z),a=U(nD),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),f=F.isLegalUrl(o),p=n?i.getUnit(n.unitId,M.UNIVER_DOC):i.getCurrentUnitOfType(M.UNIVER_DOC);(0,V.useEffect)(()=>{var e;let t=a.getActiveTextRange();if(!t)return;if(n){var r,i;let e=p==null||(r=p.getSelfOrHeaderFooterModel(n.segmentId))==null?void 0:r.getBody(),t=e==null||(i=e.customRanges)==null?void 0:i.find(e=>n?.linkId===e.rangeId&&e.startIndex===n.startIndex&&e.endIndex===n.endIndex);p&&t&&(s(t.properties?.url??``),l(Ey.transform.getPlainText(yv(e,t.startIndex,t.endIndex+1).dataStream)));return}let o=p==null||(e=p.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:e.getBody(),c=o?t:null,u=c&&Ey.customRange.getCustomRangesInterestsWithSelection(c,o?.customRanges??[])?.[0];if(p&&u){var d;s((u==null||(d=u.properties)==null?void 0:d.url)??``)}},[p,n,a,i]);let m=()=>{e.hideEditPopup()},h=()=>{if(d(!0),!f||!p)return;let t=Sst(o);if(!n)r.executeCommand(vst.id,{unitId:p.getUnitId(),payload:t});else{if(eG(c))return;r.executeCommand(yst.id,{unitId:p.getUnitId(),payload:t,linkId:n.linkId,label:c,segmentId:n.segmentId})}e.hideEditPopup()};if(p)return(0,H.jsxs)(`div`,{className:W(`univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900`,qA),children:[(0,H.jsxs)(`div`,{children:[n?(0,H.jsx)(cj,{label:t.t(`docs-hyper-link-ui.edit.label`),error:u&&eG(c)?t.t(`docs-hyper-link-ui.edit.labelError`):``,children:(0,H.jsx)(uj,{value:c,onChange:l,autoFocus:!0,onKeyDown:e=>{e.keyCode===aM.ENTER&&h()}})}):null,(0,H.jsx)(cj,{label:t.t(`docs-hyper-link-ui.edit.address`),error:u&&!f?t.t(`docs-hyper-link-ui.edit.addressError`):``,children:(0,H.jsx)(uj,{value:o,onChange:s,autoFocus:!0,onKeyDown:e=>{e.keyCode===aM.ENTER&&h()}})})]}),(0,H.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[(0,H.jsx)(HA,{onClick:m,children:t.t(`docs-hyper-link-ui.edit.cancel`)}),(0,H.jsx)(HA,{variant:`primary`,disabled:eG(o),onClick:h,children:t.t(`docs-hyper-link-ui.edit.confirm`)})]})]})};tG.componentKey=`docs-hyper-link-edit`;var Cst={type:L.COMMAND,id:`docs.command.delete-hyper-link`,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:r,segmentId:i}=t,a=e.get(R),o=dAe(e,{unitId:n,rangeId:r,segmentId:i});return o?await a.syncExecuteCommand(o.id,o.params):!1}},wst=e=>{let t=e.get(nD),n=e.get(z),r=t.getTextRanges();if(!r?.length)return!0;let i=r[0];return!(n.getCurrentUnitOfType(M.UNIVER_DOC)&&i&&!i.collapsed)},nG={type:L.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){let n=t?.link,r=e.get(z);if(wst(e)&&!n)return!1;let i=e.get(lG),a=n?.unitId||r.getCurrentUnitOfType(M.UNIVER_DOC)?.getUnitId();return a?(i.showEditPopup(a,n),!0):!1}},rG={type:L.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(lG);return t?(n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},Tst={type:L.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,t){var n;if(!t)return!1;let{unitId:r,linkId:i,segmentId:a}=t,o=e.get(z).getUnit(r,M.UNIVER_DOC)?.getSelfOrHeaderFooterModel(a).getBody(),s=o==null||(n=o.customRanges)==null||(n=n.find(e=>e.rangeId===i&&e.rangeType===Rp.HYPERLINK))==null||(n=n.properties)==null?void 0:n.url;return ep(s)?(window.open(s,`_blank`,`noopener noreferrer`),!0):!1}},iG=()=>{var e;let t=U(lG),n=U(R),r=U(eM),i=U(nx),a=QD(t.showingLink$),o=U(z);if(!a)return null;let{unitId:s,linkId:c,segmentId:l,startIndex:u,endIndex:d}=a,f=o.getUnit(s,M.UNIVER_DOC)?.getSelfOrHeaderFooterModel(l).getBody(),p=f==null||(e=f.customRanges)==null?void 0:e.find(e=>e.rangeId===c&&e.rangeType===Rp.HYPERLINK&&e.startIndex===u&&e.endIndex===d);if(!p)return null;let m=p.properties?.url;return(0,H.jsxs)(`div`,{className:W(`univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow dark:!univer-bg-gray-900`,qA),onClick:()=>{t.hideInfoPopup()},children:[(0,H.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500`,onClick:()=>window.open(m,void 0,`noopener noreferrer`),children:[(0,H.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white`,children:(0,H.jsx)(PD,{})}),(0,H.jsx)(fj,{showIfEllipsis:!0,title:m,children:(0,H.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:m})})]}),(0,H.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[(0,H.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{navigator.clipboard.writeText(m),r.show({content:i.t(`docs-hyper-link-ui.info.coped`),type:pj.Info})},children:(0,H.jsx)(fj,{placement:`bottom`,title:i.t(`docs-hyper-link-ui.info.copy`),children:(0,H.jsx)(vD,{})})}),(0,H.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{n.executeCommand(nG.id,{link:a})},children:(0,H.jsx)(fj,{placement:`bottom`,title:i.t(`docs-hyper-link-ui.info.edit`),children:(0,H.jsx)(KD,{})})}),(0,H.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{n.executeCommand(Cst.id,{unitId:s,linkId:p.rangeId,segmentId:l})},children:(0,H.jsx)(fj,{placement:`bottom`,title:i.t(`docs-hyper-link-ui.info.cancel`),children:(0,H.jsx)(WD,{})})})]})]})};iG.componentKey=`univer.doc.link-info-popup`;function aG(e){"@babel/helpers - typeof";return aG=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},aG(e)}function Est(e,t){if(aG(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(aG(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Dst(e){var t=Est(e,`string`);return aG(t)==`symbol`?t:t+``}function oG(e,t,n){return(t=Dst(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sG(e,t){return function(n,r){t(n,r,e)}}function cG(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var lG=class extends P{constructor(e,t,n){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,oG(this,`_editingLink$`,new so(null)),oG(this,`_showingLink$`,new so(null)),oG(this,`editingLink$`,this._editingLink$.asObservable()),oG(this,`showingLink$`,this._showingLink$.asObservable()),oG(this,`_editPopup`,null),oG(this,`_infoPopup`,null),this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);let n=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),r=n?.[n.length-1];if(t){let{segmentId:e,segmentPage:n,startIndex:i,endIndex:a}=t;r={collapsed:!1,startOffset:i,endOffset:a+1,segmentId:e,segmentPage:n},this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:a+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:tG.componentKey,direction:`bottom`},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){let{linkId:t,unitId:n,segmentId:r,segmentPage:i,startIndex:a,endIndex:o}=e;if((this.showing?.linkId!==t||this.showing?.unitId!==n||this.showing?.segmentId!==r||this.showing?.segmentPage!==i||this.showing?.startIndex!==a||this.showing?.endIndex!==o)&&(this._infoPopup&&this._infoPopup.dispose(),this._univerInstanceService.getUnit(n,M.UNIVER_DOC)))return this._showingLink$.next({unitId:n,linkId:t,segmentId:r,segmentPage:i,startIndex:a,endIndex:o}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:a,endOffset:o+1,segmentId:r,segmentPage:i},{componentKey:iG.componentKey,direction:`top-center`,multipleDirection:`top`,onClickOutside:()=>{this.hideInfoPopup()}},n),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};lG=cG([sG(0,j(YI)),sG(1,j(nD)),sG(2,z)],lG);var uG=class extends P{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===ZE.id){let{unitId:n,ranges:r,segmentId:i}=e.params,a=this._univerInstanceService.getUnit(n,M.UNIVER_DOC),o=r[0];if(o&&a){var t;let{startOffset:e,endOffset:r,collapsed:s,segmentPage:c}=o,l=(t=a.getSelfOrHeaderFooterModel(i))==null||(t=t.getBody())==null?void 0:t.customRanges;if(s){let t=l?.findIndex(t=>t.startIndex<e&&t.endIndex>r-1)??-1;if(t>-1){let e=l[t];this._docHyperLinkService.showInfoPopup({unitId:n,linkId:e.rangeId,segmentId:i,segmentPage:c,startIndex:e.startIndex,endIndex:e.endIndex});return}}else if(l?.find(t=>t.startIndex<=e&&t.endIndex>=r-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};uG=cG([sG(0,R),sG(1,z),sG(2,j(lG))],uG);var dG=class extends P{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,r,i,a){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=r,this._docSkeletonManagerService=i,this._docSelectionManagerService=a,this._context.unitId!==rf&&this._context.unitId!==tf&&(this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(rG.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===Rp.HYPERLINK),r=this._docSelectionManagerService.getTextRanges(),i=r==null||(t=r[0])==null?void 0:t.segmentId;if((n?.segmentId??``)!==i){this._hideInfoPopup();return}n?this._commandService.executeCommand(rG.id,{unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,rangeId:n.range.rangeId,startIndex:n.range.startIndex,endIndex:n.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;t&&this._commandService.executeCommand(Tst.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}))}};dG=cG([sG(1,j(ZI)),sG(2,R),sG(3,j(lG)),sG(4,j(rD)),sG(5,j(nD))],dG);var fG=class extends P{constructor(e,t,n,r){super(),this._context=e,this._docInterceptorService=t,this._hyperLinkService=n,this._docRenderController=r,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(cD.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(Ys((e,t)=>e?.linkId===t?.linkId&&e?.unitId===t?.unitId&&e?.startIndex===t?.startIndex),ec()).subscribe(([e,t])=>{t?t.unitId===this._context.unitId&&this._docRenderController.reRender(t.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)}))}};fG=cG([sG(1,j(lD)),sG(2,j(lG)),sG(3,j(uL))],fG);var Ost=`doc-hyper-link-icon`;function pG(e){return{id:nG.id,type:bM.BUTTON,icon:Ost,title:`docs-hyper-link-ui.menu.tooltip`,tooltip:`docs-hyper-link-ui.menu.tooltip`,hidden$:Pj(e,M.UNIVER_DOC),disabled$:new Ya(function(t){let n=e.get(nD).textSelection$.pipe(Ks(16)).subscribe(()=>{t.next(wst(e))});return()=>{n.unsubscribe()}})}}var kst={id:nG.id,binding:oM.CTRL_COMMAND|aM.K,description:`docs-hyper-link-ui.menu.tooltip`,preconditions:iL},Ast={[pM.MEDIA]:{[nG.id]:{order:1,menuItemFactory:pG}},[hM.MAIN_AREA]:{[gM.DATA]:{[nG.id]:{order:0,menuItemFactory:pG}}},[hM.PARAGRAPH]:{[gM.LAYOUT]:{[GI]:{[nG.id]:{order:6,menuItemFactory:pG}}},[BI]:{[gM.LAYOUT]:{[nG.id]:{order:6,menuItemFactory:pG}}}}},mG=class extends P{constructor(e,t,n,r){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[tG.componentKey,tG],[iG.componentKey,iG],[Ost,PD]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initCommands(){[vst,yst,Cst,nG,rG,Tst].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[kst].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.mergeMenu(Ast)}};mG=cG([sG(0,j(Nj)),sG(1,R),sG(2,_M),sG(3,cM)],mG);var jst=`DOC_HYPER_LINK_UI_PLUGIN`,hG=class extends dx{constructor(e=_st,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=r;let{menu:i,...a}=Qi({},_st,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(gst,a)}onStarting(){[[lG],[mG],[uG]].forEach(e=>{this._injector.add(e)}),this._injector.get(mG)}onReady(){this._injector.get(uG)}onRendered(){this._initRenderModule()}_initRenderModule(){[[fG],[dG]].forEach(e=>{this._renderManagerSrv.registerRenderModule(M.UNIVER_DOC,e)})}};oG(hG,`pluginName`,jst),oG(hG,`packageName`,mst),oG(hG,`version`,hst),oG(hG,`type`,M.UNIVER_DOC),hG=cG([px($W),sG(1,j(We)),sG(2,KE),sG(3,Nm)],hG);function Mst(){return{plugins:[$W,hG].filter(e=>!!e)}}var Nst=Rg({"docs-hyper-link-ui":{edit:{confirm:`确认`,cancel:`取消`,title:`链接`,address:`链接`,label:`文本`,labelError:`请输入链接文本`,placeholder:`请输入合法的链接`,addressError:`请输入合法的链接`},info:{copy:`复制`,edit:`编辑`,cancel:`取消链接`,coped:`链接已被复制到剪贴板`},menu:{tooltip:`添加链接`}}}),Pst=new Set([`line-height`,`margin-top`,`margin-bottom`,`font-size`,`mso-line-height-rule`]),Fst=/<style[^>]*>([\s\S]*?)<\/style>/gi,Ist=/([^{}]+)\{([^{}]*)\}/g;function Lst(e){let t=new Map;for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&i&&t.set(r,i)}return t}function Rst(e){let t=``;for(let[n,r]of e)t+=`${n}:${r};`;return t}function zst(e){let t=new Map;for(let n of e.matchAll(Fst)){let e=n[1];for(let n of e.matchAll(Ist)){let e=n[1].split(`,`).map(e=>e.trim()).filter(Boolean),r=new Map;for(let e of n[2].split(`;`)){let t=e.indexOf(`:`);if(t<=0)continue;let n=e.slice(0,t).trim().toLowerCase(),i=e.slice(t+1).trim();n&&i&&Pst.has(n)&&r.set(n,i)}if(r.size)for(let n of e){let e=n.match(/\.([A-Za-z0-9_-]+)/);if(!e)continue;let i=t.get(e[1])||{};for(let[e,t]of r)i[e]=t;t.set(e[1],i)}}}return t}function Bst(e,t){let n=e.trim().toLowerCase().match(/^([0-9]*\.?[0-9]+)(pt|px)$/);if(n){if(!t)return e;let r=parseFloat(n[1]),i=parseFloat(t);return!Number.isFinite(r)||!Number.isFinite(i)||i<=0?e:`${Math.round(r/i*100)}%`}return e}function Vst(e){if(typeof e!=`string`||!e||!/<style[^>]*>/i.test(e)||!/line-height/i.test(e))return e;let t=zst(e);return t.size?e.replace(/<(p|li|h[1-6])\b[^>]*>/gi,e=>{let n=e.match(/\bclass\s*=\s*"([^"]*)"/i);if(!n)return e;let r=n[1].trim().split(/\s+/).filter(Boolean),i=new Map;for(let e of r){let n=t.get(e);if(n)for(let[e,t]of Object.entries(n))i.set(e,t)}if(!i.size)return e;let a=e.match(/\bstyle\s*=\s*"([^"]*)"/i),o=a?Lst(a[1]):new Map,s=!1;for(let[e,t]of i)o.has(e)||(o.set(e,t),s=!0);if(!s&&!o.has(`line-height`))return e;let c=o.get(`line-height`),l=o.get(`mso-line-height-rule`);if(c&&/pt|px/i.test(c.trim())&&!l){let e=o.get(`font-size`);o.set(`line-height`,Bst(c,e?e.trim():null))}let u=Rst(o);return a?e.replace(/\bstyle\s*=\s*"[^"]*"/i,`style="${u}"`):e.replace(/>\s*$/,` style="${u}">`)}):e}var Hst=/(?:^|[;\s"'])(?:page-)?break-before\s*:\s*(?:always|page)\b(?![-\w])/i,Ust=/(?:^|[;\s"'])(?:page-)?break-after\s*:\s*(?:always|page)\b(?![-\w])/i,Wst=/break-(?:before|after)/i;function Gst(e){return e.replace(/<[^>]*>/g,``).replace(/ | | /gi,` `).trim().length>0}function Kst(e,t){let n=typeof e==`string`?e:``;if(Hst.test(n))return`before`;if(Ust.test(n))return`after`;let r=typeof t==`string`?t:``;if(!r||!Wst.test(r))return null;let i=/<[a-z][^>]*>/gi,a;for(;a=i.exec(r);){let e=a[0];if(!Wst.test(e))continue;let t=Hst.test(e),n=Ust.test(e);if(!t&&!n)continue;let i=t?a.index:a.index+e.length;return Gst(r.slice(0,i))?`after`:`before`}return null}function qst(e,t){let n=e&&e.tables;if(!Array.isArray(n))return!1;for(let e of n){if(!e||typeof e.startIndex!=`number`)continue;let n=typeof e.endIndex==`number`?e.endIndex:e.startIndex;if(t>=e.startIndex&&t<n)return!0}return!1}function gG(e,t,n=!1){if(Array.isArray(e))for(let r of e)r&&typeof r==`object`&&(typeof r.startIndex==`number`&&t<=r.startIndex&&(r.startIndex+=1),typeof r.st==`number`&&t<=r.st&&(r.st+=1),typeof r.endIndex==`number`&&(n?t<r.endIndex:t<=r.endIndex)&&(r.endIndex+=1),typeof r.ed==`number`&&t<r.ed&&(r.ed+=1))}function Jst(e,t){gG(e.paragraphs,t),gG(e.textRuns,t),gG(e.sectionBreaks,t),gG(e.customBlocks,t),gG(e.customRanges,t),gG(e.blockRanges,t),gG(e.tables,t,!0)}function Yst(e,t){if(!e||typeof e.dataStream!=`string`)return!1;let n=e.dataStream;return!Number.isInteger(t)||t<0||t>=n.length||t>0&&n[t-1]===`\f`||qst(e,t)?!1:(e.dataStream=n.slice(0,t)+`\f`+n.slice(t),Jst(e,t),!0)}function Xst(e,t){try{let n=e&&e.body;if(!n||typeof n.dataStream!=`string`||!t||typeof t.closest==`function`&&t.closest(`table`))return!1;let r=Kst(typeof t.getAttribute==`function`?t.getAttribute(`style`):``,t.innerHTML);if(!r)return!1;let i=n.dataStream;if(r===`after`)return i[i.length-1]===`\r`&&Yst(n,i.length-1);let a=i.lastIndexOf(`\r`,i.length-2);return a<=0?!1:Yst(n,a)}catch{return!1}}function Zst(e){let t=[],n=e&&typeof e.getChildren==`function`&&e.getChildren()||[];for(let e of n){let n=e&&e.children;if(Array.isArray(n))for(let e=0;e<n.length-1;e++){let r=n[e];if(!r||typeof r.content!=`string`||!/\f\r?$/.test(r.content))continue;let i=n[e+1];i&&typeof i.endIndex==`number`&&t.push(i.endIndex)}}return t}function Qst(e){let t=e&&e.prototype,n=t&&t._prepareLayoutContext;if(typeof n!=`function`||n.__pageBreakLayoutFixed)return!1;let r=function(...e){let t=n.apply(this,e);try{let e=Zst(typeof this.getViewModel==`function`?this.getViewModel():null);if(e.length&&t&&t.paragraphsOpenNewPage instanceof Set)for(let n of e)t.paragraphsOpenNewPage.add(n)}catch{}return t};return r.__pageBreakLayoutFixed=!0,t._prepareLayoutContext=r,!0}var $st=12e4,ect=65536,tct=5e3,nct=8192,rct=1500,ict=4e3,act=16384,oct=100,sct=512e3,cct=150,lct=class{docKey;docType;snapshotInterval;mutationFlushSize;cloudSync;incrementalMode;editorRef=null;revision=0;lastSnapshotRevision=0;lastPersistedRevision=0;pendingMutations=[];pendingBytes=0;snapshotTimer=null;disposed=!1;saving=!1;writeQueue=null;saveError=null;autoSaving=!1;onAutoSaveError=null;retryTimer=null;restoring=!1;restoreError=null;restorePromise=null;restored=!1;needsInitialSnapshot=!1;debounceTimer=null;lastFlushTime=0;mutationsSinceSnapshot=0;bytesSinceSnapshot=0;lastSnapshotTime=0;commandEventDisposable=null;pagehideHandler=null;constructor(e){this.docKey=e.docKey,this.docType=e.docType,this.snapshotInterval=e.snapshotInterval??$st,this.mutationFlushSize=e.mutationFlushSize??ect,this.cloudSync=e.cloudSync,this.incrementalMode=e.enableIncremental??!0}async attach(e){if(this.disposed)return;this.editorRef=e;let t=Date.now()+3e3;for(;Date.now()<t&&!(typeof e.ready==`function`?e.ready():e.getData()!=null);)await new Promise(e=>setTimeout(e,100));this.disposed||(this.revision=e.getVersion(),typeof e.onMutation==`function`&&(this.commandEventDisposable=e.onMutation(e=>{this.handleCommandEvent(e)}),console.log(`[EditorPersistence] 已接入 onMutation 增量事件`)),this.lastSnapshotTime=Date.now(),this.snapshotTimer=setInterval(()=>{this.takeSnapshotIfNeeded().catch(()=>void 0)},Math.min(this.snapshotInterval,3e4)),this.pagehideHandler=()=>{this.takeSnapshotSync()},window.addEventListener(`pagehide`,this.pagehideHandler),await this.restore())}dispose(){this.disposed||(this.disposed=!0,this.snapshotTimer&&=(clearInterval(this.snapshotTimer),null),this.debounceTimer&&=(clearTimeout(this.debounceTimer),null),this.retryTimer&&=(clearTimeout(this.retryTimer),null),this.commandEventDisposable?.(),this.commandEventDisposable=null,this.pagehideHandler&&=(window.removeEventListener(`pagehide`,this.pagehideHandler),null),this.editorRef=null)}handleCommandEvent(e){if(!e||!e.id||this.restoring||this.restoreError||this.disposed||this.editorRef?.canPersist?.()===!1)return;let t={commandId:e.id,params:dct(e.params??{}),timestamp:e.timestamp??Date.now()};if(this.revision++,!this.incrementalMode)return;this.pendingMutations.push(t),this.autoSaving=!0;let n=256;try{n=JSON.stringify(t.params).length*2}catch{}if(t._bytes=n,this.pendingBytes+=n,this.mutationsSinceSnapshot++,this.bytesSinceSnapshot+=n,n>=act){this.flushMutations().catch(()=>void 0);return}if(this.pendingBytes>=this.mutationFlushSize){this.flushMutations().catch(()=>void 0);return}this.resetDebounceTimer()}resetDebounceTimer(){this.debounceTimer&&clearTimeout(this.debounceTimer);let e=Date.now()-this.lastFlushTime;if(e>=ict){this.flushMutations().catch(()=>void 0);return}let t=Math.min(rct,ict-e);this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.flushMutations().catch(()=>void 0)},t)}enqueueWrite(e){let t=this.writeQueue?this.writeQueue.then(e):e(),n=t.catch(()=>void 0).finally(()=>{this.writeQueue===n&&(this.writeQueue=null)});return this.writeQueue=n,t}flushPendingMutations(){return this.flushMutations()}flushMutations(){return this.enqueueWrite(()=>this.flushMutationsNow())}async flushMutationsNow(){if(this.restoreError)throw this.restoreError;if(!this.pendingMutations.length||this.saving||this.restoring||this.restoreError||this.disposed||this.editorRef?.canPersist?.()===!1)return;if(!this.cloudSync){this.pendingMutations.length=0,this.pendingBytes=0;return}if(this.pendingMutations.length>cct)try{await this.saveSnapshotNow(),this.mutationsSinceSnapshot=0,this.bytesSinceSnapshot=0;return}catch{}let e=this.pendingMutations.splice(0);this.pendingBytes=0,this.saving=!0,this.lastFlushTime=Date.now();let t=this.compactMutations(e),n=this.revision;try{if(this.needsInitialSnapshot){let e=this.editorRef.getData();if(!e)throw Error(`无法读取初始工作簿`);await this.cloudSync.saveSnapshot({docKey:this.docKey,docType:this.docType,revision:n,data:e}),this.needsInitialSnapshot=!1,this.lastSnapshotRevision=n}else await this.cloudSync.saveMutations({docKey:this.docKey,mutations:t.map(e=>({revision:e._rev??this.revision,commandId:e.commandId,params:e.params,timestamp:e.timestamp}))});this.lastPersistedRevision=n,this.saveError=null,this.autoSaving=!1}catch(t){if(t&&typeof t==`object`&&`needsSnapshot`in t&&t.needsSnapshot===!0)try{await this.saveSnapshotNow();return}catch(e){t=e}this.pendingMutations.unshift(...e),this.pendingBytes+=e.reduce((e,t)=>e+(t._bytes??256),0),this.saveError=t instanceof Error?t:Error(`增量保存失败`),console.warn(`[EditorPersistence] 增量云端同步失败,将在下次重试`,t),this.scheduleRetry();try{this.onAutoSaveError?.(this.saveError)}catch{}throw this.autoSaving=!1,this.saveError}finally{this.saving=!1}}compactMutations(e){let t=this.revision-e.length;return e.map((e,n)=>({...e,_rev:t+n+1}))}scheduleRetry(){this.retryTimer||this.disposed||(this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.pendingMutations.length&&!this.disposed&&this.flushMutations().catch(()=>void 0)},tct))}async takeSnapshotIfNeeded(){if(!this.editorRef||this.saving||this.restoring||this.restoreError||this.disposed||this.editorRef.canPersist?.()===!1||!this.editorRef.isDirty()&&this.revision===this.lastSnapshotRevision)return;let e=Date.now()-this.lastSnapshotTime,t=this.mutationsSinceSnapshot>=oct,n=this.bytesSinceSnapshot>=sct,r=e>=this.snapshotInterval;(t||n||r)&&(await this.takeSnapshot(),this.mutationsSinceSnapshot=0,this.bytesSinceSnapshot=0,this.lastSnapshotTime=Date.now())}takeSnapshot(){return this.enqueueWrite(async()=>{if(this.restoreError)throw this.restoreError;if(!this.editorRef||this.restoring||this.disposed)throw Error(`编辑器尚未就绪`);this.editorRef.canPersist?.()!==!1&&(this.incrementalMode&&await this.flushMutationsNow(),await this.saveSnapshotNow())})}async saveSnapshotNow(){if(!this.editorRef||this.disposed)throw Error(`编辑器已关闭`);let e=this.editorRef.getData();if(!e)throw Error(`无法读取文档内容`);let t=e,n=this.revision,r=this.pendingMutations.length;this.saving=!0;try{if(this.cloudSync){let e=JSON.stringify(t),i=t,a=!1;if(e.length>nct&&typeof CompressionStream<`u`)try{i=fct(await uct(e)),a=!0}catch{i=t}await this.cloudSync.saveSnapshot({docKey:this.docKey,docType:this.docType,revision:n,data:i,compressed:a}),this.lastPersistedRevision=n,this.lastSnapshotRevision=n,this.needsInitialSnapshot=!1,this.pendingMutations.splice(0,r),this.pendingBytes=this.pendingMutations.reduce((e,t)=>e+(t._bytes??256),0),this.saveError=null}}catch(e){this.saveError=e instanceof Error?e:Error(`快照保存失败`),console.warn(`[EditorPersistence] 快照持久化失败`,e);try{this.onAutoSaveError?.(this.saveError)}catch{}throw this.saveError}finally{this.saving=!1}}takeSnapshotSync(){if(!this.editorRef||this.restoring||this.restoreError||this.disposed||this.editorRef.canPersist?.()===!1)return;let e=this.editorRef.getData();if(!e)return;let t=this.docType===`excel`?this.revision:this.editorRef.getVersion();if(this.cloudSync){let n=this.cloudSync.getBeaconUrl?.();if(n)try{let r=JSON.stringify({docKey:this.docKey,docType:this.docType,revision:t,data:e,timestamp:Date.now()});navigator.sendBeacon(n,r)}catch{}}}restore(e=!1){return this.restorePromise?this.restorePromise:this.restored&&!this.restoreError&&!e?Promise.resolve(this.revision):!this.editorRef||this.disposed?Promise.reject(Error(`编辑器未就绪`)):this.saving||this.pendingMutations.length||this.restored&&this.hasUnsavedChanges()?Promise.reject(Error(`请先保存本地修改`)):(this.restorePromise=this.restoreDocument().finally(()=>{this.restorePromise=null}),this.restorePromise)}async restoreDocument(){let e=this.editorRef,t=!this.restored;this.restoring=!0,this.restoreError=null,e.setRestoreState?.(!0,``);let n=e.getVersion(),r,i=!1;try{if(!this.cloudSync)return this.revision;let a=await this.cloudSync.restore(this.docKey,this.docType);if(this.disposed||this.editorRef!==e)throw Error(`编辑器已关闭`);if(!t&&e.getVersion()!==n)throw Error(`加载期间内容已变更,请保存后重试`);let o=a?.snapshot,s=[...a?.mutations??[]].sort((e,t)=>e.revision-t.revision);if(o?.data){if(!Number.isSafeInteger(o.revision)||o.revision<0)throw Error(`快照版本无效`);let t=s.filter(e=>e.revision>o.revision).filter(e=>!(this.docType===`excel`&&e.commandId.startsWith(`doc.mutation.`)||this.docType===`doc`&&e.commandId.startsWith(`sheet.mutation.`))),n=o.revision;for(let e of s){if(!Number.isSafeInteger(e.revision)||e.revision<0)throw Error(`增量版本无效`);if(e.revision!==n+1)throw Error(`增量版本不连续,无法安全恢复`);if(!/^[\w-]+\.mutation\.[\w.-]+$/.test(e.commandId)||!e.params||typeof e.params!=`object`)throw Error(`增量记录无效`);n=e.revision}if(a?.revision!=null&&a.revision!==n)throw Error(`恢复尾部不完整,不能确认服务器版本`);let c=e.getUniverAPI?.();if(t.length&&(!c?.syncExecuteCommand||!c.addEvent||!c.Event?.BeforeCommandExecute))throw Error(`编辑器不支持安全增量回放`);let l=o.data;for(let e=0;e<2&&typeof l==`string`;e++)l=JSON.parse(l);if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`快照格式无效,无法安全恢复`);if(r=e.getData(),i=!0,!e.setData(l))throw Error(`快照恢复失败`);for(let n of t){if(this.docType===`excel`&&n.commandId.startsWith(`doc.mutation.`)||this.docType===`doc`&&n.commandId.startsWith(`sheet.mutation.`))continue;let t=c.addEvent(c.Event.BeforeCommandExecute,e=>{e.id===n.commandId&&e.type!==2&&(e.cancel=!0)});try{let t=dct(n.params);(e.replayMutation?e.replayMutation(n.commandId,t):c.syncExecuteCommand(n.commandId,t,{onlyLocal:!0,fromChangeset:!0}))!==!0&&console.warn(`[EditorPersistenceManager] 增量回放跳过(不兼容):${n.commandId}`)}catch(e){console.warn(`[EditorPersistenceManager] 增量回放异常跳过:${n.commandId}`,e)}finally{t.dispose()}}this.needsInitialSnapshot=!1,this.lastSnapshotRevision=o.revision,this.revision=n}else{if(s.length||a?.revision!=null&&a.revision!==0)throw Error(`缺少基础快照,无法安全恢复增量`);if(this.needsInitialSnapshot=!0,e.canPersist?.()!==!1){let t=e.getData();if(!t)throw Error(`无法读取初始工作簿`);await this.cloudSync.saveSnapshot({docKey:this.docKey,docType:this.docType,revision:this.revision,data:t}),this.needsInitialSnapshot=!1,this.lastSnapshotRevision=this.revision}}return e.getData(),this.lastPersistedRevision=this.revision,this.lastFlushTime=Date.now(),this.restored=!0,this.revision}catch(t){if(this.restoreError=t instanceof Error?t:Error(`恢复失败`),i&&r&&!this.disposed)try{e.setData(r)}catch{}throw this.restoreError}finally{this.restoring=!1,this.disposed||e.setRestoreState?.(!!this.restoreError,this.restoreError?.message||``)}}getRevision(){return this.revision}getDocKey(){return this.docKey}hasUnsavedChanges(){return this.saving||this.saveError!=null||this.pendingMutations.length>0||this.revision>this.lastPersistedRevision}getSaveError(){return this.restoreError??this.saveError}getLastPersistedRevision(){return this.lastPersistedRevision}async clearLocalPersistence(){this.lastSnapshotRevision=0}async flush(){await this.takeSnapshot()}};async function uct(e){let t=new TextEncoder().encode(e),n=new CompressionStream(`gzip`),r=n.writable.getWriter(),i=n.readable.getReader();r.write(t),r.close();let a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.byteLength}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.byteLength;return s.buffer}function dct(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function fct(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.byteLength;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function _G(e){let{editorRef:n,docKey:r,docType:i,cloudSync:a,snapshotInterval:o,mutationFlushSize:s,enableIncremental:c=!0}=e,l=(0,t.ref)(`idle`),u=(0,t.ref)(null),d=(0,t.ref)(0),f=(0,t.shallowRef)(null),p=new lct({docKey:r,docType:i,cloudSync:a,snapshotInterval:o,mutationFlushSize:s,enableIncremental:c});f.value=p;let m=e.ready??n,h=null,g=null,_=!1;function v(){h||_||(h=setInterval(()=>{p.getSaveError()?l.value=`error`:p.hasUnsavedChanges()?l.value=`saving`:l.value===`saving`&&(l.value=`saved`,u.value=Date.now(),d.value=p.getRevision(),setTimeout(()=>{l.value===`saved`&&(l.value=`idle`)},2e3))},3e3))}function y(){return n.value?g??=p.attach(n.value):Promise.reject(Error(`编辑器未就绪`))}async function b(e={}){l.value=`saving`;try{await y().catch(()=>void 0);let t=await p.restore(e.force??!1);return d.value=t,l.value=`idle`,v(),t}catch(e){throw l.value=`error`,e}}(0,t.watch)(m,async e=>{if(e&&n.value)try{l.value=`saving`,await y(),d.value=p.getRevision(),l.value=`idle`,v()}catch(e){console.warn(`[useEditorPersistence] 初始化失败`,e),l.value=`error`}},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{_=!0,h&&clearInterval(h),p.dispose(),f.value=null});async function x(){l.value=`saving`;try{await p.takeSnapshot(),d.value=p.getRevision(),u.value=Date.now(),l.value=`saved`,setTimeout(()=>{l.value===`saved`&&(l.value=`idle`)},2e3)}catch(e){throw l.value=`error`,e}}async function S(){l.value=`saving`;try{await p.flush(),d.value=p.getRevision(),u.value=Date.now(),l.value=`saved`,setTimeout(()=>{l.value===`saved`&&(l.value=`idle`)},2e3)}catch(e){throw l.value=`error`,e}}async function C(){await p.clearLocalPersistence()}return{saveStatus:l,lastSavedAt:u,revision:d,manager:f,hasUnsavedChanges:()=>p.hasUnsavedChanges(),takeSnapshot:x,flush:S,clearPersistence:C,restore:b}}async function pct(e,t,n){if(!e)return e;try{let r=await n(t),i=typeof r==`string`?r:r?.url;return i?{...e,imageId:typeof r==`object`&&r?.imageId||e.imageId,imageSourceType:cb.URL,source:i}:e}catch{return e}}function mct(e){return class extends _Ye{async saveImage(t){return pct(await super.saveImage(t),t,e)}}}function hct(e,t){if(!e||typeof e.saveImage!=`function`||e.__hxyUploadPatched)return!1;let n=e.saveImage.bind(e);return e.saveImage=async e=>pct(await n(e),e,t),e.__hxyUploadPatched=!0,!0}var gct=25,_ct=200;function vG(e){let t=e?.server;if(!t||!t.imageUpload&&!t.resolveImage)return null;let n=e?.univer?.__getInjector?.();if(!n)return null;let r=null,i=0,a=!t.imageUpload,o=!t.resolveImage,s=null,c=()=>{r&&=(clearTimeout(r),null)},l=e=>typeof n.has!=`function`||n.has(e),u=()=>{if(a&&o)return c();if(i+=1,!a)try{l(ub)&&(n.replace([ub,{useClass:mct(t.imageUpload)}]),a=!0)}catch{try{hct(n.get(ub),t.imageUpload)&&(a=!0)}catch{}}if(!o)try{if(l(db)){let e=n.get(db);typeof e?.registerURLImageDownloader==`function`&&(s=e.registerURLImageDownloader(async e=>{try{return await t.resolveImage(e)||e}catch{return e}}),o=!0)}}catch{}if(a&&o)return c();if(i>=_ct){c();return}r=setTimeout(u,gct)};return u(),{dispose(){c(),s?.dispose?.(),s=null}}}var vct=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},yct={class:`doc-shell`},bct={class:`doc-layout`},xct={class:`doc-canvas`},Sct={key:0,class:`readonly-badge`,role:`status`},Cct=[`disabled`],wct={key:3,class:`attachment-error-tip`},Tct={class:`link-dialog`},Ect={class:`link-dialog-field`},Dct={class:`link-dialog-field`},Oct={key:0,class:`field-error`},kct={class:`link-dialog-tip`},Act={class:`link-dialog-actions`},jct=[`disabled`],Mct={key:0,class:`hover-icon-tip`},Nct={class:`hover-style`},Pct={key:0,class:`hover-style-menu`},Fct=[`onClick`],Ict={class:`style-check`},Lct={class:`style-name`},Rct=`univer-sheet://`,yG=`🔗 `,zct=`#e4f9fbff`,Bct=6,Vct=9,Hct=6,bG=2,Uct=`.pdf,.doc,.docx,.zip,.rar,.7z,.mp4,.mov,.webm,.avi,.mkv,.mp3,.wav,.m4a,.aac`,Wct=157286400,Gct=2097152,Kct=vct({__name:`DocEditor`,props:{visible:{type:Boolean,default:!0},type:{type:String,default:`edit`,validator:e=>[`view`,`edit`].includes(e)},server:{type:Object,default:null},collaboration:{type:Object,default:null}},emits:[`open-workbook`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(!!i.server?.cloudSync),s=(0,t.ref)(``),c=(0,t.computed)(()=>i.type===`view`||o.value),l=null;function u(e,t){o.value=e,s.value=t,vt()}async function d(){try{await v?.restore()}catch{}}let f=`demo-doc-01`;try{let e=ZI.prototype,t=e._buildCustomRangeBoundsBySegment;if(typeof t==`function`&&!t.__hoverSegmentFixed){let n=function(e,n=-1){return t.call(this,e??``,n)};n.__hoverSegmentFixed=!0,e._buildCustomRangeBoundsBySegment=n,console.log(`[hover-patch] prototype._buildCustomRangeBoundsBySegment patched ✓`)}else typeof t!=`function`&&console.warn(`[hover-patch] _buildCustomRangeBoundsBySegment not found on prototype — engine API changed?`);let n=XF.prototype,r=n._addTextRange;if(typeof r==`function`&&!r.__singleCaretFixed){let e=function(e){r.call(this,e);let t=0;for(let e of this._rangeList)e.collapsed&&t++;t<=1||(this._rangeList=this._rangeList.filter(t=>t===e||!t.collapsed||(t.dispose(),!1)))};e.__singleCaretFixed=!0,n._addTextRange=e}try{let e=wP,t=e?.preprocessHtml;typeof t==`function`&&!e.__lineSpacingNormalized&&(e.preprocessHtml=function(e){return t.call(this,Vst(e))},e.__lineSpacingNormalized=!0)}catch{}try{let e=wP,t=e?.afterProcessRules,n=t?.[0]?.handler;typeof n==`function`&&!e.__exactLineSpacingFixed&&(e.afterProcessRules=[{...t[0],handler(e,t){n.call(this,e,t),Xst(e,t);try{let n=t?.getAttribute?.(`style`)??``,r=n.match(/mso-line-height-rule\s*:\s*([a-z-]+)/i)?.[1]?.toLowerCase()??``;if(!r||r===`auto`)return;let i=n.match(/(?:^|;)\s*line-height\s*:\s*([0-9]*\.?[0-9]+)\s*(pt|px)?/i);if(!i)return;let a=e?.body?.paragraphs,o=a?.[a.length-1];if(!o)return;let s=parseFloat(i[1]);if((i[2]||``).toLowerCase()===`pt`&&(s/=.75),!Number.isFinite(s)||s<=0)return;o.paragraphStyle=o.paragraphStyle||{},o.paragraphStyle.spacingRule=r===`exactly`?2:1,o.paragraphStyle.lineSpacing=s}catch{}}}],e.__exactLineSpacingFixed=!0)}catch{}try{Qst(gE)&&console.log(`[pagebreak-patch] DocumentSkeleton._prepareLayoutContext patched ✓`)}catch{}}catch{}let p=(0,t.ref)(null),m=(0,t.shallowRef)(null),h=(0,t.ref)(null),g=null,_=(0,t.shallowRef)(null),v=i.server?.cloudSync?_G({editorRef:_,docKey:i.server.docKey||`doc:default`,docType:`doc`,cloudSync:i.server.cloudSync,snapshotInterval:i.server.snapshotInterval,mutationFlushSize:i.server.mutationFlushSize,enableIncremental:i.server.enableIncremental}):null,y=(0,t.ref)([]);(0,t.ref)(``);let b=(0,t.reactive)({words:0,paragraphs:0}),x=(0,t.reactive)({visible:!1,text:``,url:``,urlError:``,style:`text`,startOffset:0,endOffset:0,segmentId:``,replace:!1}),S=null,C=[{value:`text`,label:`文字链`},{value:`icon`,label:`图标+文字链`},{value:`card`,label:`卡片`}],w=(0,t.reactive)({visible:!1,url:``,text:``,style:`text`,linkId:``,segmentId:``,startIndex:0,endIndex:0,styleMenuOpen:!1,copied:!1,isAttachment:!1,fileName:``,fileSize:0,x:null,y:null}),T=null,E=null,D=null,O=!1,k=null,A=[],ee=null,te=!1,ne=!1;function re(e,t,n,r,i,a,o,s){if(!o&&!s){e.fillRect(t,n,r,i);return}let c=Math.max(0,Math.min(a,i/2,o&&s?r/2:r));e.beginPath(),e.moveTo(t+(o?c:0),n),e.arcTo(t+r,n,t+r,n+i,s?c:0),e.arcTo(t+r,n+i,t,n+i,s?c:0),e.arcTo(t,n+i,t,n,o?c:0),e.arcTo(t,n,t+r,n,o?c:0),e.closePath(),e.fill()}let ie=null,ae=null,oe=null,se=null,ce=0,le=-1,ue=[];function de(e){return ue.push(e),()=>{let t=ue.indexOf(e);t>=0&&ue.splice(t,1)}}function fe(e){let t=e.trim();return t?/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)?t:/^[w.-]+@([w-]+.)+[w-]{2,4}$/.test(t)?`mailto:${t}`:`https://${t}`:``}function pe(e){try{let t=new URL(fe(e));return[`http:`,`https:`,`mailto:`,`univer-sheet:`].includes(t.protocol)}catch{return!1}}function me(){if(c.value)return;let e=S,n=``;e&&!e.collapsed&&(n=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream||``).slice(e.startOffset,e.endOffset).replace(/[\r\n]+$/,``)),x.text=n,x.url=``,x.urlError=``,x.style=`text`,x.replace=!(!e||e.collapsed);let r=m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream?.length??0;x.startOffset=e?e.startOffset:Math.max(0,r-2),x.endOffset=e?e.endOffset:x.startOffset,x.segmentId=e?.segmentId||``,x.visible=!0,(0,t.nextTick)(()=>{x.text||h.value?.focus()})}function he(){x.visible=!1}function ge(e,t){return t===`text`?e:`${yG}${e}`}function _e(e,t,n,r){if(t===`card`){let i=`──查看`,a=` 📄${e}${i} `,o=a.indexOf(`📄`),s=o+2,c=a.indexOf(i),l={bg:{rgb:`#e4f9fbff`},fs:18,cl:{rgb:`#3370ff`}};return{dataStream:a,customRanges:[{startIndex:0,endIndex:a.length-1,rangeId:n,rangeType:3,wholeEntity:!0,properties:{url:r,text:e,style:t}}],textRuns:[{st:0,ed:1,ts:{...l}},{st:1,ed:2,ts:{...l}},{st:2,ed:o+2,ts:{...l}},{st:s,ed:c,ts:{...l,bl:!0}},{st:c,ed:a.length-1,ts:{...l,bl:!0}},{st:a.length-1,ed:a.length,ts:{...l}}]}}let i=ge(e,t),a={startIndex:0,endIndex:i.length-1,rangeId:n,rangeType:0,properties:{url:r,text:e,style:t}},o={dataStream:i,customRanges:[a]};return t===`icon`&&(a.show=!1,o.textRuns=[{st:0,ed:i.length,ts:{cl:{rgb:`#3370ff`}}}]),o}async function ve({text:e,url:t,style:n,startOffset:r,endOffset:i,segmentId:a,replace:o}){let s=`link-${Date.now()}-${Math.floor(Math.random()*1e4)}`,c=_e(e,n,s,t);return await m.value?.executeCommand?.(`doc.command.insert-text`,{unitId:f,range:{startOffset:r,endOffset:i,collapsed:!o,segmentId:a},segmentId:a,body:c,cursorOffset:c.dataStream.length})?{rangeId:s,startIndex:r,endIndex:r+c.dataStream.length-1}:null}async function ye(){if(!x.url.trim()){x.urlError=`请输入链接地址`;return}if(!pe(x.url)){x.urlError=`链接格式不正确`;return}await ve({text:(x.text.trim()||x.url.trim()).replace(/[\r\n]+/g,` `),url:fe(x.url),style:x.style,startOffset:x.startOffset,endOffset:x.endOffset,segmentId:x.segmentId,replace:x.replace})?(he(),at()):x.urlError=`插入失败,请重试`}let be=Uct.split(`,`).map(e=>e.slice(1)),j={pdf:`📕`,doc:`📘`,docx:`📘`,zip:`📦`,rar:`📦`,"7z":`📦`,mp4:`🎬`,mov:`🎬`,webm:`🎬`,avi:`🎬`,mkv:`🎬`,mp3:`🎵`,wav:`🎵`,m4a:`🎵`,aac:`🎵`},xe=(0,t.ref)(null),Se=(0,t.ref)(!1),Ce=(0,t.ref)(``),we=null;function Te(e){let t=String(e||``),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Ee(e){return j[Te(e)]||`📎`}function De(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e}B`:e<1048576?`${Number((e/1024).toFixed(1))}KB`:`${Number((e/1048576).toFixed(1))}MB`}function Oe(e,t=20){let n=String(e||``),r=Array.from(n);if(r.length<=t)return n;let i=n.lastIndexOf(`.`),a=i>0?n.slice(i):``,o=Array.from(a);return a&&o.length<=6?r.slice(0,Math.max(1,t-o.length-1)).join(``)+`…`+a:r.slice(0,Math.max(1,t-1)).join(``)+`…`}function ke(e){return!e||!be.includes(Te(e.name))?{ok:!1,error:`仅支持 PDF、Word、压缩包、视频、音频文件`}:e.size>Wct?{ok:!1,error:`文件大小不能超过 150MB`}:{ok:!0}}function Ae(e,t,n,r){let i=Ee(e),a=Oe(String(e||``).replace(/[\u0000-\u001f\u007f]/g,` `)),o=De(t),s=`下载`,c=` ${i}${a} · ${o} ${s} `,l=c.indexOf(i)+2,u=l+a.length,d=c.lastIndexOf(s),f={bg:{rgb:zct},fs:18,cl:{rgb:`#3370ff`}};return{dataStream:c,customRanges:[{startIndex:0,endIndex:c.length-1,rangeId:n,rangeType:3,wholeEntity:!0,properties:{attachment:!0,url:r,name:e,size:t}}],textRuns:[{st:0,ed:1,ts:{...f}},{st:1,ed:2,ts:{...f}},{st:2,ed:l,ts:{...f}},{st:l,ed:u,ts:{...f,bl:!0}},{st:u,ed:d,ts:{...f}},{st:d,ed:c.length-1,ts:{...f,bl:!0}},{st:c.length-1,ed:c.length,ts:{...f}}]}}async function je(e,t,n,r){if(typeof t==`function`)try{let n=await t(e),r=typeof n==`string`?n:n?.url||``;if(r)return{url:r}}catch{}if(e.size>n)return{error:`未配置附件上传服务,无法插入超过 2MB 的文件`};try{let t=await r(e);if(t)return{url:t}}catch{}return{error:`附件读取失败,请重试`}}function Me(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error||Error(`read failed`)),r.readAsDataURL(e)})}async function Ne(e,t){if(!e||e.startsWith(`data:`)||typeof t!=`function`)return e;try{return await t(e)||e}catch{return e}}async function Pe(e,t,n){let{fetchImpl:r,doc:i,urlApi:a,defer:o=e=>setTimeout(e,400)}=n,s=``,c=e;if(!e.startsWith(`data:`)){let t=await r(e);if(!t.ok)throw Error(`附件下载失败(HTTP ${t.status})`);let n=await t.blob();s=a.createObjectURL(n),c=s}let l=i.createElement(`a`);l.href=c,l.download=t||`附件`,l.style.display=`none`,i.body.appendChild(l);try{l.click()}finally{l.remove(),s&&o(()=>a.revokeObjectURL(s))}}function Fe(e){Ce.value=e,clearTimeout(we),we=setTimeout(()=>{Ce.value=``},4e3)}async function Ie(e){let t=e?.url||``;if(!t)return;let n=e?.name||`附件`;try{await Pe(await Ne(t,i.server?.resolveAttachment),n,{fetchImpl:(e,t)=>fetch(e,t),doc:document,urlApi:URL})}catch{Fe(`附件下载失败,请稍后重试`)}}function Le(){Ie({url:w.url,name:w.fileName,size:w.fileSize}),Ye()}function Re(){c.value||Se.value||xe.value?.click()}function ze(e){let t=e?.target?.files?.[0];if(e?.target&&(e.target.value=``),t)return Be(t)}async function Be(e){let t=m.value;if(c.value||Se.value||!t||!e)return;let n=ke(e);if(!n.ok){Fe(n.error);return}let r=f,a=t.getUniverDoc?.(r)?.getSnapshot(),o=S?.segmentId||``,s=o?a?.headers?.[o]?.body||a?.footers?.[o]?.body:a?.body,l=s?.dataStream;if(!l)return;let u=S?.startOffset??Math.max(0,l.length-2);Se.value=!0;try{let{url:n,error:d}=await je(e,i.server?.attachmentUpload,Gct,Me);if(!m.value)return;if(c.value||m.value!==t||f!==r||t.getUniverDoc?.(r)?.getSnapshot()!==a||s.dataStream!==l){Fe(`文档已变更或切为只读,请重新插入附件`);return}if(!n){Fe(d||`附件插入失败,请重试`);return}let p=`attachment-${Date.now()}-${Math.floor(Math.random()*1e4)}`,h=Ae(e.name,e.size,p,n);await t.executeCommand?.(`doc.command.insert-text`,{unitId:r,range:{startOffset:u,endOffset:u,collapsed:!0,segmentId:o},segmentId:o,body:h,cursorOffset:h.dataStream.length})?at():Fe(`附件插入失败,请重试`)}catch{m.value&&Fe(`附件插入失败,请重试`)}finally{Se.value=!1}}async function Ve(){let e=m.value;if(c.value||!e)return;let t=f,n=e.getUniverDoc?.(t)?.getSnapshot(),r=S?.segmentId||``,i=r?n?.headers?.[r]?.body||n?.footers?.[r]?.body:n?.body,a=i?.dataStream;if(!a)return;let o=Math.min(Math.max(0,S?.startOffset??a.length-2),Math.max(0,a.length-2)),s=(i.paragraphs||[]).find(e=>e.startIndex>=o),l={startIndex:1};s?.bullet&&(l.bullet=JSON.parse(JSON.stringify(s.bullet))),s?.paragraphStyle&&(l.paragraphStyle=JSON.parse(JSON.stringify(s.paragraphStyle)),delete l.paragraphStyle.borderBottom);let u=(i.textRuns||[]).find(e=>o>e.st&&o<=e.ed),d={dataStream:`\f\r`,paragraphs:[l],...u?{textRuns:[{st:0,ed:2,ts:JSON.parse(JSON.stringify(u.ts))}]}:{}};await e.executeCommand?.(`doc.command.insert-text`,{unitId:t,range:{startOffset:o,endOffset:o,collapsed:!0,segmentId:r},segmentId:r,body:d,cursorOffset:d.dataStream.length})&&at()}function He(e){return(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body)?.customRanges?.find(t=>t.rangeId===e&&(t.rangeType===0||t.rangeType===3))||null}function Ue(e){if(!e?.linkId){Ge();return}if(Ke(),w.visible&&e.linkId===w.linkId&&e.startIndex===w.startIndex)return;let t=He(e.linkId);if(!t){We();return}let n=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream||``).slice(t.startIndex,t.endIndex+1),r=t.properties||{};w.url=r.url||``,w.isAttachment=!!r.attachment,w.fileName=r.name||``,w.fileSize=r.size||0,w.text=(r.text||n.replace(yG,``)).replace(/[\s\u00A0\u2000-\u200B\u3000]+$/g,``),w.style=r.style||`text`,w.linkId=e.linkId,w.segmentId=e.segmentId||``,w.startIndex=t.startIndex,w.endIndex=t.endIndex,w.styleMenuOpen=!1,w.copied=!1,w.x=null,w.y=null,w.visible=!0,T=e,Xe()}function We(){clearTimeout(E),clearTimeout(D),D=null,O=!1,w.visible=!1,w.styleMenuOpen=!1,w.copied=!1}function Ge(e=320){O||(clearTimeout(D),D=setTimeout(()=>{D=null,We()},e))}function Ke(){clearTimeout(D),D=null}function qe(){O=!0,Ke()}function Je(){O=!1,Ge(160)}function Ye(){We(),m.value?.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`)}function Xe(e=12){if(clearTimeout(E),!w.visible)return;let t=Array.from(document.querySelectorAll(`[data-u-comp="rect-popup"]`)).find(e=>e.querySelector(`.univer-max-w-80`))?.getBoundingClientRect();if(!t||t.left<-9e3||!t.width&&!t.height){e>0?E=setTimeout(()=>Xe(e-1),50):We();return}w.x=t.left+t.width/2,w.y=Math.max(t.top,8)}function Ze(){let e=w.url;e.startsWith(Rct)?a(`open-workbook`,e.slice(15)):e&&window.open(e,`_blank`,`noopener noreferrer`),Ye()}async function Qe(){let e=w.url;try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else throw Error(`clipboard unavailable`)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;opacity:0`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`)}catch{}t.remove()}w.copied=!0,clearTimeout(k),k=setTimeout(()=>{w.copied=!1},1200)}function $e(){c.value||(We(),Ye(),x.text=w.text,x.url=w.url,x.urlError=``,x.style=w.style,x.replace=!0,x.startOffset=w.startIndex,x.endOffset=w.endIndex+1,x.segmentId=w.segmentId,x.visible=!0)}async function et(e){if(c.value||(w.styleMenuOpen=!1,e===w.style))return;let{text:t,url:n,segmentId:r,startIndex:i,endIndex:a}=w,o=await ve({text:t,url:n,style:e,startOffset:i,endOffset:a+1,segmentId:r,replace:!0});o&&(at(),m.value?.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`,{...T||{},unitId:f,linkId:o.rangeId,rangeId:o.rangeId,startIndex:o.startIndex,endIndex:o.endIndex}))}async function tt(){if(c.value)return;let{text:e,segmentId:t,startIndex:n,endIndex:r}=w;await m.value?.executeCommand?.(`doc.command.insert-text`,{unitId:f,range:{startOffset:n,endOffset:r+1,collapsed:!1,segmentId:t},segmentId:t,body:{dataStream:e},cursorOffset:e.length})&&(Ye(),at())}function nt(){w.styleMenuOpen&&=!1,w.visible&&We()}function rt(){w.visible&&We(),clearTimeout(rt._t),rt._t=setTimeout(()=>{if(ee)try{let e=m.value?.getUniverDoc?.(f)?.getSnapshot()?.body;if(!e?.customRanges)return;A=[];for(let t of e.customRanges){if(t.rangeType!==0&&t.rangeType!==3)continue;let e=JI({startOffset:t.startIndex,endOffset:t.endIndex+1,collapsed:!1},ee);e?.length&&A.push({rangeId:t.rangeId,startIndex:t.startIndex,endIndex:t.endIndex,rects:e,style:t.properties?.style||`text`,text:t.properties?.text||``,url:t.properties?.url||``})}}catch{}},200)}let it=null;function at(){clearTimeout(it),it=setTimeout(ot,300)}function ot(){let e=m.value?.getUniverDoc?.(f);if(!e)return;let t=e.getSnapshot()?.body;if(!t)return;let n=t.dataStream||``,r=t.paragraphs||[],i=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.paragraphStyle?.namedStyleType,o=a==null?t.paragraphStyle?.headingLevel:a>=qp.HEADING_1&&a<=qp.HEADING_5?a-qp.HEADING_1+1:0;if(!o)continue;let s=t.startIndex,c=n.lastIndexOf(`\r`,s-1)+1;for(;c<s&&n.charCodeAt(c)<32;)c++;let l=n.slice(c,s).replace(/[\u0000-\u001f]/g,``);l.trim()&&i.push({id:`h-${c}`,level:o,text:l,startIndex:c})}y.value=i,b.paragraphs=r.length;let a=n.replace(/[\r\n]/g,``),o=(a.match(/[\u4e00-\u9fff]/g)||[]).length,s=(a.replace(/[\u4e00-\u9fff]/g,` `).match(/[A-Za-z0-9]+/g)||[]).length;b.words=o+s}function st(e){if(e.id!==`doc.operation.click-hyper-link`)return;let{linkId:t}=e.params||{};if(!t)return;let n=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body)?.customRanges?.find(e=>e.rangeId===t);if(!n)return;if(n.properties?.attachment){Ie(n.properties),e.cancel=!0;return}let r=n.properties?.url||``;if(r){if(r.startsWith(Rct)){a(`open-workbook`,r.slice(15)),e.cancel=!0;return}n.rangeType===3&&pe(r)&&(window.open(fe(r),`_blank`,`noopener,noreferrer`),e.cancel=!0)}}function ct(){let e=m.value?.getUniverDoc?.(f),t=e?.getSnapshot()?.body?.dataStream||``;if(!e||!t)return!1;let n=Math.max(0,t.length-2);return e.setSelection(n,n),S={startOffset:n,endOffset:n,segmentId:``,collapsed:!0},!0}function lt(e){if(l&&!l.entered&&e.type===bG&&e.id===l.id&&e.params===l.params){l.entered=!0;return}if((o.value||l)&&e.type!==1||c.value&&e.type===bG){e.cancel=!0;return}if(i.collaboration?.onBeforeCommand&&!i.collaboration.onBeforeCommand(e.id,e.params)){e.cancel=!0;return}st(e),!c.value&&e.id===`doc.operation.show-hyper-link-edit-popup`&&!e.params?.link&&(e.cancel=!0,me()),[`doc.operation.create-table`,`doc.command.create-table`,`doc.command.insert-float-image`].includes(e.id)&&!S&&ct()&&(e.cancel=!0,m.value?.executeCommand?.(e.id,{...e.params||{}}))}function ut(e){if(e.id!==`doc.operation.set-selections`&&e.id!==`doc.operation.toggle-hyper-link-info-popup`&&ce++,e.type===bG&&!l&&!e.options?.fromChangeset&&!e.options?.fromCollab)for(let t of ue)try{t({id:e.id,params:e.params,type:e.type,timestamp:Date.now()})}catch{}if(e.id===`doc.operation.set-selections`){let t=e.params?.ranges?.[0];t&&(S={startOffset:t.startOffset,endOffset:t.endOffset,segmentId:t.segmentId||e.params?.segmentId||``,collapsed:t.collapsed??t.startOffset===t.endOffset})}e.id===`doc.operation.toggle-hyper-link-info-popup`&&Ue(e.params),at()}function dt(){if(!p.value||m.value)return;let{univer:e,univerAPI:t}=mS({locale:bp.ZH_CN,locales:{[bp.ZH_CN]:Rg([fat,nst,Nst])},presets:[cat({container:p.value,ribbonType:`simple`}),$ot(),Mst()]});try{e.__getInjector().get(Nm).setConfig(`menu`,{"doc.operation.show-hyper-link-edit-popup":{disabled:!1}},{merge:!0})}catch{}t.createUniverDoc({id:f,title:``,documentStyle:{pageSize:{width:794,height:1123},marginTop:72,marginBottom:72,marginLeft:80,marginRight:80},tableSource:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
594
|
+
`,textRuns:[],tables:[],sectionBreaks:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:0},lineSpacing:1.15,spaceBelow:{v:8}}}]}});try{e.__getInjector().get(z).focusUnit(f)}catch{}ie=e,m.value=t,gt(),vt(),g||=vG({univer:e,server:i.server}),v&&!_.value&&(_.value={getData:ft,setData:ht,getVersion:pt,isDirty:mt,setRestoreState:u,replayMutation:_t,canPersist:()=>i.type!==`view`,ready:()=>!!m.value,getUniverInstance:()=>ie,getUniverAPI:()=>m.value,onMutation:de}),t.addEvent(t.Event.CommandExecuted,ut),t.addEvent(t.Event.BeforeCommandExecute,lt),window.addEventListener(`pointerdown`,nt),window.addEventListener(`scroll`,rt,!0),window.addEventListener(`resize`,rt),ot(),bt(1e3)}function ft(){let e=m.value?.getUniverDoc?.(f)?.getSnapshot?.();return e?.body?.dataStream?(le=ce,{type:`univer-doc`,unitId:f,version:ce,savedAt:Date.now(),data:JSON.parse(JSON.stringify(e))}):null}function pt(){return ce}function mt(){return ce!==le}function ht(e){let t=e?.type===`univer-doc`?e.data:e;if(!t?.body?.dataStream)return!1;let n=m.value;if(!n)return!1;try{We()}catch{}try{n.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`)}catch{}ae?.abort(),ae=null,oe?.dispose?.(),oe=null;try{n.disposeUnit?.(f)}catch{}let r=t.id||f;n.createUniverDoc({...JSON.parse(JSON.stringify(t)),id:r}),f=r,gt(),ce++,S=null,A=[];try{ie?.__getInjector?.()?.get(z)?.focusUnit(f)}catch{}return bt(300),vt(),at(),!0}function gt(){try{let e=(ie?.__getInjector?.()?.get(z)?.getUniverDocInstance?.(f))?.getSnapshot?.(),t=e?.body;if(!t)return;t.textRuns??=[],t.tables??=[],t.sectionBreaks??=[],e.tableSource??={};let n=t.dataStream;if(typeof n==`string`&&n.length){t.paragraphs??=[];let e=t.paragraphs,r=new Set;for(let t of e)r.add(t?.startIndex);let i=!1;for(let t=0;t<n.length;t++)n.charCodeAt(t)===13&&!r.has(t)&&(e.push({startIndex:t}),i=!0);i&&e.sort((e,t)=>e.startIndex-t.startIndex)}}catch{}}function _t(e,t){if(!o.value||l)throw Error(`当前不允许回放`);let n=m.value,r=ie?.__getInjector?.()?.get(z)?.getUniverDocInstance?.(f);if(!n||!r||t?.unitId!==f)throw Error(`回放文档不匹配`);let i={...JSON.parse(JSON.stringify(t)),noHistory:!0,isSync:!0,noNeedSetTextRange:!0};l={id:e,params:i,entered:!1};try{r.setDisabled(!1);let t=n.syncExecuteCommand(e,i,{onlyLocal:!0,fromChangeset:!0});return l.entered?e===`doc.mutation.rich-text-editing`?t?.unitId===f&&Array.isArray(t.actions)&&(Vv.isNoop(i.actions)||!Vv.isNoop(t.actions)):t===!0:!1}finally{l=null,r.setDisabled(c.value)}}function vt(){try{(ie?.__getInjector?.()?.get(z)?.getUniverDocInstance?.(f))?.setDisabled?.(c.value)}catch{}}function yt(e,t,n){if(c.value||!Number.isFinite(n)||n<40)return!1;let r=(m.value?.getUniverDoc?.(f)?.getSnapshot())?.tableSource?.[e]?.tableColumns?.[t]?.size?.width?.v;if(!Number.isFinite(r)||r===n)return!1;let i=Vv.getInstance().replaceOp([`tableSource`,e,`tableColumns`,t,`size`,`width`,`v`],r,n);return!!m.value.syncExecuteCommand(`doc.mutation.rich-text-editing`,{unitId:f,actions:i,trigger:`pd-doc.table-resize`,noNeedSetTextRange:!0,debounce:!1})?.actions?.length}function bt(e=1e3){setTimeout(()=>{if(!ie)return;let t=ie.__getInjector().get(KE).getRenderById(f),n=p.value?.querySelector(`canvas`);if(!t||!n){if(e<2e3){bt(e+400);return}console.warn(`[canvas-features] render/canvas not ready`);return}if(ee=t,!te)try{let e=t.with(rD)?.getSkeleton();if(e){let t=e,n=null;for(;t;){let e=Object.getPrototypeOf(t);if(!e)break;if(e.draw&&e.isSkipByDiffBounds){n=e;break}t=e}if(n){let e=n.draw;if(!e.__cardBgPatch){let t=function(t,n){let r=null,i=null,a=null;try{let e=this.getSkeleton?.(),t=e?.getSkeletonData?.();if(t?.pages?.length){let n=((e.getViewModel?.())?.getDataModel?.())?.getBody?.();if(n?.customRanges){r=new Set,i=new Set,a=new Set;for(let e of n.customRanges)if(e.rangeType===3){for(let t=e.startIndex;t<=e.endIndex;t++)r.add(t);i.add(e.startIndex),a.add(e.endIndex)}if(r.size>0){let e=0;for(let n of t.pages)for(let t of n.sections)for(let n of t.columns)for(let t of n.lines)for(let n of t.divides)for(let t of n.glyphGroup)t.content&&r.has(e)&&(t.ts&&!t.ts.bg&&(t.ts.bg={rgb:zct}),t._isCardGlyph=!0,i.has(e)&&(t._cardRoundLeft=!0),a.has(e)&&(t._cardRoundRight=!0)),e+=t.count||1}}}if(r?.size>0){let e=this.getExtensionByKey?.(`DefaultDocsBackgroundExtension`);if(e&&!e.__cardPaddingPatched){let t=e.draw.bind(e);e.draw=function(e,n,r){if(r._isCardGlyph){let t=r.parent?.parent;if(t&&r.ts?.bg){let{contentHeight:n=0}=t,i=Hh(r.ts.bg),a=this.extensionOffset?.spanStartPoint;if(i&&a&&r.content!==`\r`){e.fillStyle=i,re(e,a.x-1,a.y-Vct,r.width+2,n+Vct+Hct,Bct,!!r._cardRoundLeft,!!r._cardRoundRight);return}}}return t(e,n,r)},e.__cardPaddingPatched=!0}}}catch{}return e.call(this,t,n)};t.__cardBgPatch=!0,n.draw=t,te=!0,console.log(`[card-bg-patch] Documents.draw patched ✓`)}}}}catch(e){console.warn(`[card-bg-patch] failed to apply:`,e)}if(!ne)try{let e=GF.prototype.refresh;if(!e.__cardSelectionPatch){let t=function(){e.call(this);try{if(!this._rangeShape)return;let e=(this._docSkeleton?.getViewModel?.())?.getDataModel?.()?.getBody?.();if(!e?.customRanges)return;let t=this.startOffset,n=this.endOffset;if(t==null||n==null)return;for(let r of e.customRanges)if(r.rangeType===3&&t<=r.endIndex&&n>=r.startIndex){this._rangeShape.hide();return}}catch{}};t.__cardSelectionPatch=!0,GF.prototype.refresh=t,ne=!0,console.log(`[card-selection-patch] TextRange.refresh patched ✓`)}}catch(e){console.warn(`[card-selection-patch] failed to apply:`,e)}ae?.abort(),oe?.dispose?.();let r=new AbortController;ae=r;let i={signal:r.signal};try{let e=t.with(ZI);if(e){let t=e._buildCustomRangeBoundsBySegment;typeof t==`function`&&!t.__instHoverFixed&&(e._buildCustomRangeBoundsBySegment=function(e,n=-1){return t.call(this,e??``,n)},e._buildCustomRangeBoundsBySegment.__instHoverFixed=!0)}function a(){A=[];try{let e=m.value?.getUniverDoc?.(f)?.getSnapshot()?.body;if(!e?.customRanges)return;for(let n of e.customRanges){if(n.rangeType!==0&&n.rangeType!==3)continue;let e=JI({startOffset:n.startIndex,endOffset:n.endIndex+1,collapsed:!1},t);e?.length&&A.push({rangeId:n.rangeId,startIndex:n.startIndex,endIndex:n.endIndex,rects:e,style:n.properties?.style||`text`,text:n.properties?.text||``,url:n.properties?.url||``})}console.log(`[hover-patch] link rects computed: ${A.length} links found`)}catch(e){console.warn(`[hover-patch] recomputeLinkRects failed:`,e)}}a(),oe=m.value?.addEvent?.(m.value?.Event?.CommandExecuted,()=>{clearTimeout(se),se=setTimeout(a,150)}),n&&(n.addEventListener(`mousemove`,e=>{if(!A.length)return;n.getBoundingClientRect();let t=e.clientX,r=e.clientY,i=null;for(let e of A){for(let n of e.rects)if(t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom){i=e;break}if(i)break}if(i){if(Ke(),w.visible&&i.rangeId===w.linkId)return;let e=He(i.rangeId);if(!e)return;let t=(m.value?.getUniverDoc?.(f)?.getSnapshot()?.body?.dataStream||``).slice(e.startIndex,e.endIndex+1),n=e.properties||{};w.url=n.url||``,w.isAttachment=!!n.attachment,w.fileName=n.name||``,w.fileSize=n.size||0,w.text=(n.text||t.replace(yG,``)).replace(/[\s\u00A0\u2000-\u200B\u3000]+$/g,``),w.style=n.style||`text`,w.linkId=i.rangeId,w.segmentId=``,w.startIndex=i.startIndex,w.endIndex=i.endIndex,w.styleMenuOpen=!1,w.copied=!1;let r=i.rects.reduce((e,t)=>e.top<t.top?e:t),a=i.rects[Math.floor(i.rects.length/2)];w.x=(a.left+a.right)/2,w.y=Math.max(r.top-4,40),w.visible=!0,T={unitId:f,linkId:i.rangeId,segmentId:``,segmentPage:-1,rangeId:i.rangeId,startIndex:i.startIndex,endIndex:i.endIndex},m.value?.executeCommand?.(`doc.operation.toggle-hyper-link-info-popup`,T)}else w.visible&&Ge()},i),console.log(`[hover-patch] DOM mousemove hover detection active ✓`))}catch(e){console.warn(`[hover-patch] self-implemented hover detection failed:`,e)}try{let e=null;function o(){let e=t.with(rD).getSkeleton()?.getSkeletonData();if(!e)return[];let n=[],{scene:r,engine:i}=t,{scaleX:a}=r.getAncestorScale(),o=r.getViewport(`viewMain`)?.viewportScrollX||0,s=i.getCanvasElement().getBoundingClientRect(),c=parseFloat(i.getCanvasElement().style.width)||s.width,l=s.width/c,{docsLeft:u}=t.mainComponent.getOffsetConfig(),d=e.pages[0]?.marginLeft||0,p=e=>(e-o+u*a)*l+s.left;for(let r of e.pages)for(let e of r.skeTables.values()){let r=d+e.left,i=r,o=[],c=(m.value?.getUniverDoc?.(f)?.getSnapshot())?.tableSource?.[e.tableId]?.tableColumns||[];if(c.length>0)for(let t=0;t<c.length;t++)i+=c[t].size.width.v,o.push({x:i,colIndex:t,tableId:e.tableId,colWidth:c[t].size.width.v});else for(let t of e.rows){let n=r;for(let r=0;r<t.cells.length;r++)n+=t.cells[r].pageWidth,o.push({x:n,colIndex:r,tableId:e.tableId,colWidth:t.cells[r].pageWidth});break}let u=1/0,h=-1/0;try{let n=JI({startOffset:e.st,endOffset:e.ed,collapsed:!1},t);if(n&&n.length>0)for(let e of n)u=Math.min(u,e.top),h=Math.max(h,e.bottom)}catch{}u===1/0&&(u=s.top,h=s.bottom);for(let e of o)n.push({screenX:p(e.x),screenTop:u,screenBottom:h,colIndex:e.colIndex,tableId:e.tableId,colWidth:e.colWidth,tableDocLeft:r,scaleCombined:a*l})}return n}n.addEventListener(`pointermove`,t=>{if(c.value||e)return;let r=o(),i=null;for(let e of r)if(t.clientY>=e.screenTop-6&&t.clientY<=e.screenBottom+6&&Math.abs(t.clientX-e.screenX)<=6){i=e;break}n.style.cursor=i?`col-resize`:``},i),n.addEventListener(`pointerdown`,t=>{if(c.value)return;let r=o(),i=null;for(let e of r)if(t.clientY>=e.screenTop-6&&t.clientY<=e.screenBottom+6&&Math.abs(t.clientX-e.screenX)<=6){i=e;break}i&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),n.style.cursor=`col-resize`,n.style.touchAction=`none`,e={tableId:i.tableId,colIndex:i.colIndex,startX:t.clientX,startWidth:i.colWidth,scaleCombined:i.scaleCombined})},{...i,capture:!0}),window.addEventListener(`pointermove`,t=>{e&&t.preventDefault()},i),window.addEventListener(`pointerup`,t=>{if(!e)return;let r=(t.clientX-e.startX)/e.scaleCombined,i=Math.max(40,Math.round(e.startWidth+r));try{yt(e.tableId,e.colIndex,i),clearTimeout(se),se=setTimeout(a,300)}catch(e){console.warn(`[table-resize] apply failed:`,e)}e=null,n.style.cursor=``,n.style.touchAction=``},i),console.log(`[table-resize] column drag-resize active ✓`)}catch(e){console.warn(`[table-resize] init failed:`,e)}},e)}return(0,t.watch)(()=>i.visible,e=>{e?setTimeout(dt,100):Ye()},{immediate:!0}),(0,t.watch)(()=>i.type,()=>{m.value&&vt()}),(0,t.onUnmounted)(()=>{clearTimeout(it),clearTimeout(E),clearTimeout(D),clearTimeout(k),clearTimeout(se),clearTimeout(we),ae?.abort(),oe?.dispose?.(),window.removeEventListener(`pointerdown`,nt),window.removeEventListener(`scroll`,rt,!0),window.removeEventListener(`resize`,rt),g?.dispose?.(),g=null,m.value?.dispose?.(),m.value=null}),n({getData:ft,setData:ht,getVersion:pt,isDirty:mt,ready:()=>!!m.value,getUniverInstance:()=>ie,getUniverAPI:()=>m.value,onMutation:de,replayRemoteMutations:e=>{if(!Array.isArray(e))return;let t=m.value;if(t)for(let n of e){let e=JSON.parse(JSON.stringify(n.params??{}));l={id:n.commandId,params:e,entered:!1};try{t.syncExecuteCommand(n.commandId,e,{onlyLocal:!0,fromChangeset:!0})}catch{}l=null}},persistence:v}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,yct,[(0,t.createElementVNode)(`div`,bct,[(0,t.createElementVNode)(`div`,xct,[(0,t.createElementVNode)(`div`,{ref_key:`containerRef`,ref:p,class:`doc-editor`},null,512),c.value&&m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Sct,[s.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createTextVNode)(`恢复失败:`+(0,t.toDisplayString)(s.value)+` `,1),(0,t.createElementVNode)(`button`,{onClick:d},`重试`)],64)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createTextVNode)((0,t.toDisplayString)(o.value?`正在恢复文档…`:`🔒 只读模式`),1)],64))])):(0,t.createCommentVNode)(``,!0),!c.value&&m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:1,class:`pagebreak-insert-btn`,title:`在光标处插入分页符`,onClick:Ve},`📄 插入分页符`)):(0,t.createCommentVNode)(``,!0),!c.value&&m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:2,class:`attachment-insert-btn`,disabled:Se.value,onClick:Re},(0,t.toDisplayString)(Se.value?`上传中…`:`📎 插入附件`),9,Cct)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`input`,{ref_key:`attachmentInputRef`,ref:xe,class:`attachment-file-input`,type:`file`,accept:Uct,onChange:ze},null,544),Ce.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,wct,(0,t.toDisplayString)(Ce.value),1)):(0,t.createCommentVNode)(``,!0),x.visible?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:4,class:`link-dialog-mask`,onClick:(0,t.withModifiers)(he,[`self`])},[(0,t.createElementVNode)(`div`,Tct,[n[8]||=(0,t.createElementVNode)(`div`,{class:`link-dialog-title`},`插入链接`,-1),(0,t.createElementVNode)(`div`,Ect,[n[6]||=(0,t.createElementVNode)(`label`,{class:`field-label`},`文字`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{"onUpdate:modelValue":n[0]||=e=>x.text=e,class:`field-input`,type:`text`,placeholder:`链接显示的文字(留空则显示链接地址)`,onKeydown:(0,t.withKeys)(ye,[`enter`])},null,544),[[t.vModelText,x.text]])]),(0,t.createElementVNode)(`div`,Dct,[n[7]||=(0,t.createElementVNode)(`label`,{class:`field-label`},`链接地址`,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{ref_key:`linkUrlInputRef`,ref:h,"onUpdate:modelValue":n[1]||=e=>x.url=e,class:(0,t.normalizeClass)([`field-input`,{error:x.urlError}]),type:`text`,placeholder:`https:// 或 univer-sheet://wb-progress`,onInput:n[2]||=e=>x.urlError=``,onKeydown:(0,t.withKeys)(ye,[`enter`])},null,34),[[t.vModelText,x.url]]),x.urlError?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Oct,(0,t.toDisplayString)(x.urlError),1)):(0,t.createCommentVNode)(``,!0)]),(0,t.createElementVNode)(`div`,kct,(0,t.toDisplayString)(x.replace?`将替换选中的文字或原链接`:`将在光标处插入`)+` · 支持 univer-sheet:// 内链跳转表格 · 插入后悬停可改样式 `,1),(0,t.createElementVNode)(`div`,Act,[(0,t.createElementVNode)(`button`,{class:`dialog-btn cancel`,onClick:he},`取 消`),(0,t.createElementVNode)(`button`,{class:`dialog-btn confirm`,disabled:!x.url.trim(),onClick:ye},`确 定`,8,jct)])])])):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:`body`},[w.visible&&w.x!==null?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:0,class:`link-hover-bar`,style:(0,t.normalizeStyle)({left:w.x+`px`,top:w.y+`px`}),onPointerdown:n[5]||=(0,t.withModifiers)(()=>{},[`stop`]),onMouseenter:qe,onMouseleave:Je},[(0,t.createElementVNode)(`span`,{class:`hover-label`,onClick:n[3]||=e=>w.isAttachment?Le():Ze()},(0,t.toDisplayString)(w.isAttachment?`下载`:`打开链接`),1),w.isAttachment?(0,t.createCommentVNode)(``,!0):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[n[13]||=(0,t.createElementVNode)(`i`,{class:`hover-sep`},null,-1),(0,t.createElementVNode)(`button`,{class:`hover-icon-btn`,title:`复制`,onClick:Qe},[n[9]||=(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,t.createElementVNode)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})],-1),w.copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,Mct,`已复制`)):(0,t.createCommentVNode)(``,!0)]),c.value?(0,t.createCommentVNode)(``,!0):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createElementVNode)(`button`,{class:`hover-icon-btn`,title:`编辑`,onClick:$e},[...n[10]||=[(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`path`,{d:`M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z`})],-1)]]),(0,t.createElementVNode)(`div`,Nct,[(0,t.createElementVNode)(`button`,{class:`hover-icon-btn`,title:`切换样式`,onClick:n[4]||=e=>w.styleMenuOpen=!w.styleMenuOpen},[...n[11]||=[(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`path`,{d:`m6 9 6 6 6-6`})],-1)]]),w.styleMenuOpen?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Pct,[((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(C,e=>(0,t.createElementVNode)(`div`,{key:e.value,class:(0,t.normalizeClass)([`hover-style-item`,{active:e.value===w.style}]),onClick:t=>et(e.value)},[(0,t.createElementVNode)(`span`,Ict,(0,t.toDisplayString)(e.value===w.style?`✓`:``),1),(0,t.createElementVNode)(`span`,Lct,(0,t.toDisplayString)(e.label),1)],10,Fct)),64))])):(0,t.createCommentVNode)(``,!0)]),(0,t.createElementVNode)(`button`,{class:`hover-icon-btn hover-unlink-btn`,title:`取消链接`,onClick:tt},[...n[12]||=[(0,t.createElementVNode)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,t.createElementVNode)(`path`,{d:`M15 7h3a5 5 0 0 1 0 10h-3m-6 0H6a5 5 0 0 1 0-10h3`}),(0,t.createElementVNode)(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`})],-1)]])],64))],64)),n[14]||=(0,t.createElementVNode)(`div`,{class:`hover-bar-arrow`},null,-1)],36)):(0,t.createCommentVNode)(``,!0)]))])])]))}},[[`__scopeId`,`data-v-f0db620e`]]);function qct(e,t,n){var r;if(t.t)return t.t;if(t.v===null)return null;let i=e.getStyleByCell(t),a=e.getStyleByCell(n);if(n.t===Pp.FORCE_STRING){var o;if(!Ch(a==null||(o=a.n)==null?void 0:o.pattern)&&t.v!==void 0){if(Pg(t.v))return Pp.NUMBER;if($d(`${t.v}`))return Pp.BOOLEAN}return Pp.FORCE_STRING}if(Yct(i)){var s;return Ch(i==null||(s=i.n)==null?void 0:s.pattern)?Pp.STRING:Jct(t,n)}return Ch(a==null||(r=a.n)==null?void 0:r.pattern)?Pp.STRING:Jct(t,n)}function Jct(e,t){return e.v===void 0?xG(t.v,t.t):xG(e.v,e.t)}function Yct(e){var t;return!!(e!=null&&(t=e.n)!=null&&t.pattern)}function xG(e,t){return e===null?null:typeof e==`string`?Pg(e)?(+e==0||+e==1)&&t===Pp.BOOLEAN?Pp.BOOLEAN:t!==Pp.STRING&&t!==Pp.FORCE_STRING&&Lf(e)?Pp.FORCE_STRING:Pp.NUMBER:$d(e)?Pp.BOOLEAN:Pp.STRING:typeof e==`number`?(e===0||e===1)&&t===Pp.BOOLEAN?Pp.BOOLEAN:Pp.NUMBER:typeof e==`boolean`?Pp.BOOLEAN:Pp.FORCE_STRING}function Xct(e,t){let{unitId:n}=t,r=n?e.getUnit(n,M.UNIVER_SHEET):e.getCurrentUnitOfType(M.UNIVER_SHEET);return r?{workbook:r,unitId:r.getUnitId()}:null}function SG(e,t={}){let{unitId:n,subUnitId:r}=t,i=n?e.getUnit(n,M.UNIVER_SHEET):e.getCurrentUnitOfType(M.UNIVER_SHEET);if(!i)return null;let a=r?i.getSheetBySheetId(r):i.getActiveSheet(!0);return a?{worksheet:a,workbook:i,unitId:i.getUnitId(),subUnitId:a.getSheetId()}:null}function CG(e,t){let{unitId:n,subUnitId:r}=t,i=e.getUnit(n,M.UNIVER_SHEET);if(!i)return null;let a=i.getSheetBySheetId(r);return a?{worksheet:a,workbook:i}:null}var wG=(e,t)=>{if(!CG(e.get(z),t))throw Error(`Workbook or worksheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:F.deepClone(t.ranges)}},TG={id:`sheet.mutation.add-worksheet-merge`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or worksheet is null error!`);let{worksheet:r}=n,i=r.getConfig().mergeData,a=t.ranges;for(let e=0;e<a.length;e++)i.push(a[e]);return r.getSpanModel().rebuild(i),!0}},EG={CELL_CONTENT:Cf(`CELL_CONTENT`),ROW_FILTERED:Cf(`ROW_FILTERED`)},DG=function(e){return e[e.DATA_VALIDATION=9]=`DATA_VALIDATION`,e[e.NUMFMT=10]=`NUMFMT`,e[e.CELL_IMAGE=11]=`CELL_IMAGE`,e}({}),Zct=`sheet.interceptor.range-theme-id`,Qct=`sheet.interceptor.ignore-range-theme`;function OG(e){"@babel/helpers - typeof";return OG=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},OG(e)}function $ct(e,t){if(OG(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(OG(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function elt(e){var t=$ct(e,`string`);return OG(t)==`symbol`?t:t+``}function Z(e,t,n){return(t=elt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kG(e,t){return function(n,r){t(n,r,e)}}function AG(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var jG=Cf(`BEFORE_CELL_EDIT`),MG=Cf(`AFTER_CELL_EDIT`),NG=Cf(`VALIDATE_CELL`),PG=class extends P{constructor(e){super(),this._univerInstanceService=e,Z(this,`_interceptorsByName`,new Map),Z(this,`_commandInterceptors`,[]),Z(this,`_rangeInterceptors`,[]),Z(this,`_autoHeightInterceptors`,[]),Z(this,`_beforeCommandInterceptor`,[]),Z(this,`_afterCommandInterceptors`,[]),Z(this,`_workbookDisposables`,new Map),Z(this,`_worksheetDisposables`,new Map),Z(this,`_composedInterceptorByKey`,new Map),Z(this,`_composedInterceptorVersion`,0),Z(this,`writeCellInterceptor`,new Tf({BEFORE_CELL_EDIT:jG,AFTER_CELL_EDIT:MG,VALIDATE_CELL:NG})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(M.UNIVER_SHEET).subscribe(e=>{this._interceptWorkbook(e.unit)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_SHEET).subscribe(e=>this._disposeWorkbookInterceptor(e))),this.intercept(EG.CELL_CONTENT,{priority:-1,effect:Sf.Style|Sf.Value,handler:e=>e}),this.disposeWithMe(this.writeCellInterceptor.intercept(MG,{priority:-1,handler:e=>e})),this.disposeWithMe(this.writeCellInterceptor.intercept(jG,{priority:-1,handler:e=>e})),this.disposeWithMe(this.writeCellInterceptor.intercept(NG,{priority:-1,handler:e=>e}))}dispose(){super.dispose(),this._workbookDisposables.forEach(e=>e.dispose()),this._workbookDisposables.clear(),this._worksheetDisposables.forEach(e=>e.dispose()),this._worksheetDisposables.clear(),this._interceptorsByName.clear(),this._composedInterceptorByKey.clear()}interceptCommand(e){if(this._commandInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._commandInterceptors.push(e),this._commandInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._commandInterceptors,e)))}onCommandExecute(e){let t=this._commandInterceptors.map(t=>t.getMutations(e));return{preUndos:t.map(e=>e.preUndos??[]).flat(),undos:t.map(e=>e.undos).flat(),preRedos:t.map(e=>e.preRedos??[]).flat(),redos:t.map(e=>e.redos).flat()}}interceptAfterCommand(e){if(this._afterCommandInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._afterCommandInterceptors.push(e),this._afterCommandInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._afterCommandInterceptors,e)))}afterCommandExecute(e){let t=this._afterCommandInterceptors.map(t=>t.getMutations(e));return{undos:t.map(e=>e.undos).flat(),redos:t.map(e=>e.redos).flat()}}interceptAutoHeight(e){if(this._autoHeightInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._autoHeightInterceptors.push(e),this._autoHeightInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._autoHeightInterceptors,e)))}generateMutationsOfAutoHeight(e){let t=this._autoHeightInterceptors.map(t=>t.getMutations(e));return{preUndos:t.map(e=>e.preUndos??[]).flat(),undos:t.map(e=>e.undos).flat(),preRedos:t.map(e=>e.preRedos??[]).flat(),redos:t.map(e=>e.redos).flat()}}interceptBeforeCommand(e){if(this._beforeCommandInterceptor.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._beforeCommandInterceptor.push(e),this._beforeCommandInterceptor.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._beforeCommandInterceptor,e)))}async beforeCommandExecute(e){return(await Promise.all(this._beforeCommandInterceptor.map(t=>t.performCheck(e)))).every(e=>e)}interceptRanges(e){if(this._rangeInterceptors.includes(e))throw Error(`[SheetInterceptorService]: Interceptor already exists!`);return this._rangeInterceptors.push(e),this._rangeInterceptors.sort((e,t)=>(t.priority??0)-(e.priority??0)),this.disposeWithMe(Wf(()=>qd(this._rangeInterceptors,e)))}generateMutationsByRanges(e){let t=this._rangeInterceptors.map(t=>t.getMutations(e));return{preUndos:t.map(e=>e.preUndos??[]).flat(),undos:t.map(e=>e.undos).flat(),preRedos:t.map(e=>e.preRedos??[]).flat(),redos:t.map(e=>e.redos).flat()}}onWriteCell(e,t,n,r,i){let a={subUnitId:t.getSheetId(),unitId:e.getUnitId(),workbook:e,worksheet:t,row:n,col:r,origin:F.deepClone(i)};return this.writeCellInterceptor.fetchThroughInterceptors(MG)(i,a)}onValidateCell(e,t,n,r){let i={subUnitId:t.getSheetId(),unitId:e.getUnitId(),workbook:e,worksheet:t,row:n,col:r};return this.writeCellInterceptor.fetchThroughInterceptors(NG)(Promise.resolve(!0),i)}intercept(e,t){let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);r.push(t);let i=r.sort((e,t)=>(t.priority??0)-(e.priority??0));if(this._invalidateComposedInterceptors(),n===EG.CELL_CONTENT){let e=Sf.Style|Sf.Value;this._interceptorsByName.set(`${n}-${e}`,i);let r=Sf.Style|Sf.Value;return this._interceptorsByName.set(`${n}-${Sf.Style}`,i.filter(e=>((e.effect||r)&Sf.Style)>0)),this._interceptorsByName.set(`${n}-${Sf.Value}`,i.filter(e=>((e.effect||r)&Sf.Value)>0)),this.disposeWithMe(Wf(()=>{qd(this._interceptorsByName.get(n),t),qd(this._interceptorsByName.get(`${n}-${e}`),t),qd(this._interceptorsByName.get(`${n}-${Sf.Style}`),t),qd(this._interceptorsByName.get(`${n}-${Sf.Value}`),t),this._invalidateComposedInterceptors()}))}return this._interceptorsByName.set(n,i),this.disposeWithMe(Wf(()=>{qd(this._interceptorsByName.get(n),t),this._invalidateComposedInterceptors()}))}fetchThroughInterceptors(e,t,n,r){let i=t===void 0?e:`${e}-${t}`,a=n??i,o=this._composedInterceptorByKey.get(a);if(!o){let e=this._interceptorsByName.get(i);e&&r&&(e=e.filter(r)),o=wf(e||[]),this._composedInterceptorByKey.set(a,o)}return o}_invalidateComposedInterceptors(){this._composedInterceptorVersion+=1,this._composedInterceptorByKey.clear()}_getCommonCellContentInterceptor(e,t){let n=t.get(e);return n||(n=this.fetchThroughInterceptors(EG.CELL_CONTENT,e),t.set(e,n)),n}_getCommonRowFilteredInterceptor(e){return e.interceptor||=this.fetchThroughInterceptors(EG.ROW_FILTERED),e.interceptor}_interceptWorkbook(e){let t=new Gf,n=e.getUnitId(),r=this,i=t=>{let i=t.getSheetId();t.__interceptViewModel(a=>{let o=new Gf,s=new Map,c={interceptor:null},l=-1,u=-1;r._worksheetDisposables.set(tlt(n,t),o),o.add(a.registerCellContentInterceptor({getCell(a,o,c,u,d){let f=t.getCellRaw(a,o),p={unitId:n,subUnitId:i,row:a,col:o,worksheet:t,workbook:e,rawData:f};return u===void 0&&d===void 0?(l!==r._composedInterceptorVersion&&(s.clear(),l=r._composedInterceptorVersion),r._getCommonCellContentInterceptor(c,s)(f,p)):r.fetchThroughInterceptors(EG.CELL_CONTENT,c,u,d)(f,p)}})),o.add(a.registerRowFilteredInterceptor({getRowFiltered(a){return u!==r._composedInterceptorVersion&&(c.interceptor=null,u=r._composedInterceptorVersion),!!r._getCommonRowFilteredInterceptor(c)(!1,{unitId:n,subUnitId:i,row:a,workbook:e,worksheet:t})}}))})};e.getSheets().forEach(e=>i(e)),t.add(e.sheetCreated$.subscribe(e=>i(e))),t.add(Wf(()=>e.getSheets().forEach(e=>this._disposeSheetInterceptor(n,e)))),t.add(e.sheetDisposed$.subscribe(e=>this._disposeSheetInterceptor(n,e))),this._workbookDisposables.set(n,t)}_disposeWorkbookInterceptor(e){let t=e.getUnitId(),n=this._workbookDisposables.get(t);n&&(n.dispose(),this._workbookDisposables.delete(t))}_disposeSheetInterceptor(e,t){let n=tlt(e,t),r=this._worksheetDisposables.get(n);r&&(r.dispose(),this._worksheetDisposables.delete(n))}};PG=AG([kG(0,z)],PG);function tlt(e,t){return`${e}|${t.getSheetId()}`}var FG=e=>{let t={};return e.bg&&(t.bg={...e.bg}),e.ol&&(t.ol={...e.ol}),e.bd&&(t.bd={...e.bd}),e.cl&&(t.cl={...e.cl}),e.ht&&(t.ht=e.ht),e.vt&&(t.vt=e.vt),e.bl!==void 0&&(t.bl=e.bl),t};function nlt(e){let t={};if(e.length===1)return e[0];for(let n of e)n.bg&&(t.bg=n.bg),n.ol&&(t.ol=n.ol),n.bd&&(t.bd={...t.bd,...n.bd}),n.cl&&(t.cl=n.cl),n.ht&&(t.ht=n.ht),n.vt&&(t.vt=n.vt),n.bl!==void 0&&(t.bl=n.bl);return t}var IG={wholeStyle:1,headerRowStyle:2,headerColumnStyle:4,firstRowStyle:8,secondRowStyle:16,lastRowStyle:32,firstColumnStyle:128,secondColumnStyle:256,lastColumnStyle:512},LG=class{constructor(e,t){Z(this,`_name`,void 0),Z(this,`wholeStyle`,null),Z(this,`headerRowStyle`,null),Z(this,`headerColumnStyle`,null),Z(this,`firstRowStyle`,null),Z(this,`secondRowStyle`,null),Z(this,`lastRowStyle`,null),Z(this,`firstColumnStyle`,null),Z(this,`secondColumnStyle`,null),Z(this,`lastColumnStyle`,null),Z(this,`_mergeCacheMap`,new Map),t&&this.fromJson({...t,name:e}),this._name=e}getName(){return this._name}getWholeStyle(){return this.wholeStyle}setWholeStyle(e){this.wholeStyle=e,this._resetStyleCache()}getFirstRowStyle(){return this.firstRowStyle}setFirstRowStyle(e){this.firstRowStyle=e,this._resetStyleCache()}getSecondRowStyle(){return this.secondRowStyle}setSecondRowStyle(e){this.secondRowStyle=e,this._resetStyleCache()}getLastRowStyle(){return this.lastRowStyle}setLastRowStyle(e){this.lastRowStyle=e,this._resetStyleCache()}getFirstColumnStyle(){return this.firstColumnStyle}setFirstColumnStyle(e){this.firstColumnStyle=e,this._resetStyleCache()}getSecondColumnStyle(){return this.secondColumnStyle}setSecondColumnStyle(e){this.secondColumnStyle=e,this._resetStyleCache()}getLastColumnStyle(){return this.lastColumnStyle}setLastColumnStyle(e){this.lastColumnStyle=e,this._resetStyleCache()}getHeaderRowStyle(){return this.headerRowStyle}setHeaderRowStyle(e){this.headerRowStyle=e,this._resetStyleCache()}getHeaderColumnStyle(){return this.headerColumnStyle}setHeaderColumnStyle(e){this.headerColumnStyle=e,this._resetStyleCache()}getStyle(e,t,n,r,i){let a=0;return n&&(a|=IG.lastRowStyle),r&&(a|=IG.lastColumnStyle),e>=0&&t>=0&&(a|=IG.wholeStyle),e%2==1&&(a|=i?IG.secondRowStyle:IG.firstRowStyle),e%2==0&&(a|=i?IG.firstRowStyle:IG.secondRowStyle),e===0&&(a|=IG.headerRowStyle),t===0&&(a|=IG.headerColumnStyle),t%2==1&&(a|=IG.firstColumnStyle),t%2==0&&(a|=IG.secondColumnStyle),a===0?null:this._getMergeStyle(a)}_getMergeStyle(e){let t=this._mergeCacheMap.get(e);return t||(t=this._mergeStyle(e),this._mergeCacheMap.set(e,t)),t}_mergeStyle(e){let t=[];return this.wholeStyle&&e&IG.wholeStyle&&t.push(this.wholeStyle),this.firstColumnStyle&&e&IG.firstColumnStyle&&t.push(this.firstColumnStyle),this.secondColumnStyle&&e&IG.secondColumnStyle&&t.push(this.secondColumnStyle),this.firstRowStyle&&e&IG.firstRowStyle&&t.push(this.firstRowStyle),this.secondRowStyle&&e&IG.secondRowStyle&&t.push(this.secondRowStyle),this.headerColumnStyle&&e&IG.headerColumnStyle&&t.push(this.headerColumnStyle),this.lastColumnStyle&&e&IG.lastColumnStyle&&t.push(this.lastColumnStyle),this.headerRowStyle&&e&IG.headerRowStyle&&t.push(this.headerRowStyle),this.lastRowStyle&&e&IG.lastRowStyle&&t.push(this.lastRowStyle),nlt(t)}_resetStyleCache(){this._mergeCacheMap.clear()}toJson(){let e={name:this._name};return this.wholeStyle&&(e.wholeStyle=FG(this.wholeStyle)),this.headerRowStyle&&(e.headerRowStyle=FG(this.headerRowStyle)),this.headerColumnStyle&&(e.headerColumnStyle=FG(this.headerColumnStyle)),this.firstRowStyle&&(e.firstRowStyle=FG(this.firstRowStyle)),this.secondRowStyle&&(e.secondRowStyle=FG(this.secondRowStyle)),this.lastRowStyle&&(e.lastRowStyle=FG(this.lastRowStyle)),this.firstColumnStyle&&(e.firstColumnStyle=FG(this.firstColumnStyle)),this.secondColumnStyle&&(e.secondColumnStyle=FG(this.secondColumnStyle)),this.lastColumnStyle&&(e.lastColumnStyle=FG(this.lastColumnStyle)),e}fromJson(e){this._name=e.name,e.wholeStyle&&(this.wholeStyle=FG(e.wholeStyle)),e.headerRowStyle&&(this.headerRowStyle=FG(e.headerRowStyle)),e.headerColumnStyle&&(this.headerColumnStyle=FG(e.headerColumnStyle)),e.firstRowStyle&&(this.firstRowStyle=FG(e.firstRowStyle)),e.secondRowStyle&&(this.secondRowStyle=FG(e.secondRowStyle)),e.lastRowStyle&&(this.lastRowStyle=FG(e.lastRowStyle)),e.firstColumnStyle&&(this.firstColumnStyle=FG(e.firstColumnStyle)),e.secondColumnStyle&&(this.secondColumnStyle=FG(e.secondColumnStyle)),e.lastColumnStyle&&(this.lastColumnStyle=FG(e.lastColumnStyle))}dispose(){this._mergeCacheMap.clear()}},rlt=(e,t,n)=>new LG(`light-${e}`,{headerRowStyle:{bg:{rgb:t}},firstColumnStyle:{bg:{rgb:`rgb(255, 255, 255)`}},secondColumnStyle:{bg:{rgb:n}},lastRowStyle:{bg:{rgb:t}}}),ilt=(e,t,n)=>new LG(`middle-${e}`,{headerRowStyle:{bg:{rgb:t}},headerColumnStyle:{bg:{rgb:n}},secondRowStyle:{bg:{rgb:n}},lastRowStyle:{bg:{rgb:t}},lastColumnStyle:{bg:{rgb:n}}}),alt=(e,t,n,r)=>new LG(`dark-${e}`,{headerRowStyle:{bg:{rgb:t},cl:{rgb:`rgb(255, 255, 255)`},ht:Dp.CENTER,bl:Np.TRUE},firstRowStyle:{bg:{rgb:n}},secondRowStyle:{bg:{rgb:r}},lastRowStyle:{bg:{rgb:t}}}),olt=[{baseName:`blue`,header:`rgb(164, 202, 254)`,color:`rgb(225, 239, 254)`},{baseName:`grey`,header:`rgb(205, 208, 216)`,color:`rgb(238, 239, 241)`},{baseName:`red`,header:`rgb(248, 180, 180)`,color:`rgb(253, 232, 232)`},{baseName:`orange`,header:`rgb(253, 186, 140)`,color:`rgb(254, 236, 220)`},{baseName:`yellow`,header:`rgb(250, 200, 21)`,color:`rgb(255, 244, 185)`},{baseName:`green`,header:`rgb(132, 225, 188)`,color:`rgb(222, 247, 236)`},{baseName:`azure`,header:`rgb(126, 220, 226)`,color:`rgb(213, 245, 246)`},{baseName:`indigo`,header:`rgb(186, 198, 248)`,color:`rgb(233, 237, 255)`},{baseName:`purple`,header:`rgb(202, 191, 253)`,color:`rgb(237, 235, 254)`},{baseName:`magenta`,header:`rgb(248, 180, 217)`,color:`rgb(252, 232, 243)`}],slt=[{baseName:`blue`,rowHeader:`rgb(63, 131, 248)`,colHeader:`rgb(195, 221, 253)`},{baseName:`grey`,rowHeader:`rgb(95, 101, 116)`,colHeader:`rgb(227, 229, 234)`},{baseName:`red`,rowHeader:`rgb(240, 82, 82)`,colHeader:`rgb(251, 213, 213)`},{baseName:`orange`,rowHeader:`rgb(255, 90, 31)`,colHeader:`rgb(252, 217, 189)`},{baseName:`yellow`,rowHeader:`rgb(212, 157, 15)`,colHeader:`rgb(252, 220, 106)`},{baseName:`green`,rowHeader:`rgb(13, 164, 113)`,colHeader:`rgb(188, 240, 218)`},{baseName:`azure`,rowHeader:`rgb(6, 148, 162)`,colHeader:`rgb(175, 236, 239)`},{baseName:`indigo`,rowHeader:`rgb(70, 106, 247)`,colHeader:`rgb(210, 218, 250)`},{baseName:`purple`,rowHeader:`rgb(144, 97, 249)`,colHeader:`rgb(220, 215, 254)`},{baseName:`magenta`,rowHeader:`rgb(231, 70, 148)`,colHeader:`rgb(250, 209, 232)`}],clt=[{baseName:`blue`,rowHeader:`rgb(30, 66, 159)`,firstRow:`rgb(195, 221, 253)`,secondRow:`rgb(118, 169, 250)`},{baseName:`grey`,rowHeader:`rgb(44, 48, 64)`,firstRow:`rgb(227, 229, 234)`,secondRow:`rgb(151, 157, 172)`},{baseName:`red`,rowHeader:`rgb(155, 28, 28)`,firstRow:`rgb(251, 213, 213)`,secondRow:`rgb(249, 128, 128)`},{baseName:`orange`,rowHeader:`rgb(180, 52, 3)`,firstRow:`rgb(252, 217, 189)`,secondRow:`rgb(255, 138, 76)`},{baseName:`yellow`,rowHeader:`rgb(154, 109, 21)`,firstRow:`rgb(252, 220, 106)`,secondRow:`rgb(212, 157, 15)`},{baseName:`green`,rowHeader:`rgb(4, 108, 78)`,firstRow:`rgb(188, 240, 218)`,secondRow:`rgb(49, 196, 141)`},{baseName:`azure`,rowHeader:`rgb(3, 102, 114)`,firstRow:`rgb(175, 236, 239)`,secondRow:`rgb(22, 189, 202)`},{baseName:`indigo`,rowHeader:`rgb(16, 51, 191)`,firstRow:`rgb(210, 218, 250)`,secondRow:`rgb(98, 128, 249)`},{baseName:`purple`,rowHeader:`rgb(74, 29, 150)`,firstRow:`rgb(220, 215, 254)`,secondRow:`rgb(172, 148, 250)`},{baseName:`magenta`,rowHeader:`rgb(153, 21, 75)`,firstRow:`rgb(250, 209, 232)`,secondRow:`rgb(241, 126, 184)`}],llt=olt.map(({baseName:e,header:t,color:n})=>rlt(e,t,n)),ult=slt.map(({baseName:e,rowHeader:t,colHeader:n})=>ilt(e,t,n)),dlt=clt.map(({baseName:e,rowHeader:t,firstRow:n,secondRow:r})=>alt(e,t,n,r)),flt=[...llt,...ult,...dlt],plt={headerRowStyle:{bg:{rgb:`rgb(68,114,196)`},cl:{rgb:`rgb(255,255,255)`},ht:Dp.CENTER,bl:Np.TRUE},firstRowStyle:{bg:{rgb:`rgb(217,225,242)`}}},mlt=new LG(`default`,plt),hlt=new LG(`default-last-row`,{...plt,lastRowStyle:{bd:{t:{s:up.THIN,cl:{rgb:`rgb(68,114,196)`}}},ht:Dp.CENTER,bl:Np.TRUE}}),glt=class{constructor(){Z(this,`_toggleRanges`,[])}refresh(e,t){let{startRow:n,endRow:r}=e,i=[],a=0,o=!1,s=-1;for(let e=n;e<=r;e++){if(!t(e)){a++,a%2==1?o=!0:(o=!1,s!==-1&&(i.push([s,e-1]),s=-1));continue}a%2==1?o?s===-1&&(s=e):(o=!0,s=e):o&&(i.push([s,e-2]),o=!1,s=-1),e===r&&o&&i.push([s,e])}this._toggleRanges=i}getToggleRanges(){return this._toggleRanges.concat()}getIsToggled(e){let t=0,n=this._toggleRanges.length-1;for(;t<=n;){let r=Math.floor((t+n)/2),[i,a]=this._toggleRanges[r];if(e<i)n=r-1;else if(e>a)t=r+1;else return!0}return!1}},_lt=`SHEET_RANGE_THEME_MODEL_PLUGIN`,RG=class extends P{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._resourceManagerService=t,this._univerInstanceService=n,Z(this,`_rangeThemeStyleMap`,new Map),Z(this,`_rangeThemeStyleRuleMap`,new Map),Z(this,`_rTreeCollection`,new Map),Z(this,`_defaultRangeThemeMap`,new Map),Z(this,`_zebraCrossingCacheMap`,new Map),Z(this,`_rowVisibleFuncSet`,new Map),Z(this,`_rangeThemeMapChanged$`,new ao),Z(this,`rangeThemeMapChange$`,this._rangeThemeMapChanged$.asObservable()),this._registerIntercept(),this._initSnapshot(),this._initDefaultTheme()}_initDefaultTheme(){this.registerDefaultRangeTheme(mlt),this.registerDefaultRangeTheme(hlt);for(let e of flt)this.registerDefaultRangeTheme(e)}_ensureRangeThemeStyleMap(e){return this._rangeThemeStyleMap.has(e)||this._rangeThemeStyleMap.set(e,new Map),this._rangeThemeStyleMap.get(e)}_ensureRangeThemeStyleRuleMap(e){return this._rangeThemeStyleRuleMap.has(e)||this._rangeThemeStyleRuleMap.set(e,new Map),this._rangeThemeStyleRuleMap.get(e)}_ensureRTreeCollection(e){return this._rTreeCollection.has(e)||this._rTreeCollection.set(e,new Ox),this._rTreeCollection.get(e)}getDefaultRangeThemeStyle(e){return this._defaultRangeThemeMap.get(e)}getCustomRangeThemeStyle(e,t){return this._ensureRangeThemeStyleMap(e).get(t)}_getSheetRowVisibleFuncSet(e,t){this._rowVisibleFuncSet.has(e)||this._rowVisibleFuncSet.set(e,new Map);let n=this._rowVisibleFuncSet.get(e);return n.has(t)||n.set(t,new Set),n.get(t)}_getSheetRowVisibleHasInit(e,t){return!!(this._rowVisibleFuncSet.has(e)&&this._rowVisibleFuncSet.get(e)?.has(t))}refreshSheetRowVisibleFuncSet(e,t){let n=this._getSheetRowVisibleFuncSet(e,t);n.clear();let r=this._univerInstanceService.getUnit(e);if(r){let e=r.getSheetBySheetId(t);if(e){let t=e.getRowCount(),r=e.getRowManager();for(let i=1;i<=t;i++)e.getRowVisible(i)?r.getRowHeight(i)===0&&n.add(i):n.add(i)}}}_ensureZebraCrossingCache(e,t,n){this._zebraCrossingCacheMap.has(e)||this._zebraCrossingCacheMap.set(e,new Map);let r=this._zebraCrossingCacheMap.get(e);r.has(t)||r.set(t,new Map);let i=r.get(t);return i.has(n)||i.set(n,new glt),i.get(n)}registerRangeThemeRule(e,t){let{unitId:n,subUnitId:r,range:i}=t,a=ip(),o=this._ensureRangeThemeStyleRuleMap(n),s=this._ensureRTreeCollection(n);o.set(a,{rangeInfo:t,themeName:e}),s.insert({unitId:n,sheetId:r,range:i,id:a}),this._getSheetRowVisibleHasInit(n,r)||this.refreshSheetRowVisibleFuncSet(n,r);let c=this._ensureZebraCrossingCache(n,r,a),l=this._getSheetRowVisibleFuncSet(n,r);c.refresh(i,e=>!l.has(e))}getRegisteredRangeThemeStyle(e){let{unitId:t,subUnitId:n,range:r}=e,i=this._ensureRTreeCollection(t),a=Array.from(i.bulkSearch([{unitId:t,sheetId:n,range:r}]));if(a[0]){let e=this._ensureRangeThemeStyleRuleMap(t).get(a[0]);if(e)return e.themeName}}refreshZebraCrossingCacheBySheet(e,t){this._zebraCrossingCacheMap.has(e)||this._zebraCrossingCacheMap.set(e,new Map);let n=this._zebraCrossingCacheMap.get(e);n.has(t)||n.set(t,new Map);let r=n.get(t);r&&r.forEach((n,i)=>{let a=this._ensureRangeThemeStyleRuleMap(e).get(i);a?n.refresh(a.rangeInfo.range,n=>!this._getSheetRowVisibleFuncSet(e,t).has(n)):r.delete(i)})}removeRangeThemeRule(e,t){let{unitId:n,subUnitId:r,range:i}=t,a=this._ensureRTreeCollection(n),o=Array.from(a.bulkSearch([{unitId:n,sheetId:r,range:i}])),s=this._ensureRangeThemeStyleRuleMap(n);for(let t=0;t<o.length;t++){let c=s.get(o[t]);if(c&&c.themeName===e){s.delete(o[t]),a.remove({unitId:n,sheetId:r,range:i,id:o[t]});let e=this._zebraCrossingCacheMap.get(n);if(e){let n=e.get(r);n&&n.delete(o[t])}break}}}registerDefaultRangeTheme(e){this._defaultRangeThemeMap.set(e.getName(),e),this._rangeThemeMapChanged$.next({type:`add`,styleName:e.getName()})}unRegisterDefaultRangeTheme(e){this._defaultRangeThemeMap.delete(e),this._rangeThemeMapChanged$.next({type:`remove`,styleName:e})}getRegisteredRangeThemes(){return Array.from(this._defaultRangeThemeMap.keys())}registerRangeThemeStyle(e,t){this._ensureRangeThemeStyleMap(e).set(t.getName(),t),this._rangeThemeMapChanged$.next({type:`add`,styleName:t.getName()})}unregisterRangeThemeStyle(e,t){this._ensureRangeThemeStyleMap(e).delete(t),this._rangeThemeMapChanged$.next({type:`remove`,styleName:t})}getALLRegisteredTheme(e){return Array.from(this._ensureRangeThemeStyleMap(e).keys())}getRangeThemeStyle(e,t){return this._defaultRangeThemeMap.has(t)?this._defaultRangeThemeMap.get(t):this._ensureRangeThemeStyleMap(e).get(t)}getCellStyle(e,t,n,r){let i={startRow:n,startColumn:r,endRow:n,endColumn:r},a=this._ensureRTreeCollection(e),o=Array.from(a.bulkSearch([{unitId:e,sheetId:t,range:i}]));if(o[0]){let i=this._ensureRangeThemeStyleRuleMap(e).get(o[0]);if(i){let{rangeInfo:a,themeName:s}=i,c=n-a.range.startRow,l=r-a.range.startColumn,u=this.getRangeThemeStyle(e,s),d=this._ensureZebraCrossingCache(e,t,o[0]).getIsToggled(n);if(u)return u.getStyle(c,l,n===a.range.endRow,r===a.range.endColumn,d)}}}_registerIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(EG.CELL_CONTENT,{id:Zct,effect:Sf.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t,s=this.getCellStyle(a,o,r,i);if(s){let r=!e||e===t.rawData?{...t.rawData}:e;return r.themeStyle=s,n(r)}return n(e)}}))}toJson(e){let t=this._ensureRangeThemeStyleRuleMap(e),n=this._ensureRangeThemeStyleMap(e);if(n.size===0&&t.size===0)return`{}`;let r={};t.forEach((e,t)=>{r[t]=e});let i={};return n.forEach((e,t)=>{i[t]=e.toJson()}),JSON.stringify({rangeThemeStyleRuleMap:r,rangeThemeStyleMapJson:i})}fromJSON(e,t){let{rangeThemeStyleRuleMap:n,rangeThemeStyleMapJson:r}=t;n&&Object.keys(n).forEach(e=>{let{themeName:t,rangeInfo:r}=n[e];t.startsWith(`table`)||(this.registerRangeThemeRule(t,r),this._ensureRTreeCollection(r.unitId).insert({unitId:e,sheetId:r.subUnitId,range:r.range,id:e}))}),r&&Object.keys(r).forEach(t=>{let n=r[t],i=new LG(n.name);i.fromJson(n),this._ensureRangeThemeStyleMap(e).set(i.getName(),i)})}deleteUnitId(e){this._rangeThemeStyleMap.delete(e),this._rangeThemeStyleRuleMap.delete(e),this._rTreeCollection.delete(e)}_initSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource({toJson:e=>this.toJson(e),parseJson:e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}},businesses:[M.UNIVER_SHEET],pluginName:_lt,onLoad:(e,t)=>{this.fromJSON(e,t)},onUnLoad:e=>{this.deleteUnitId(e)}}))}dispose(){super.dispose(),this._rangeThemeStyleMap.clear(),this._rangeThemeStyleRuleMap.clear(),this._defaultRangeThemeMap.clear(),this._rTreeCollection.clear(),this._zebraCrossingCacheMap.clear(),this._rowVisibleFuncSet.clear()}};RG=AG([kG(0,j(PG)),kG(1,j(By)),kG(2,j(z))],RG);var zG={id:`sheet.mutation.set-worksheet-range-theme-style`,type:L.MUTATION,handler:(e,t)=>{if(!SG(e.get(z),t))return!1;let n=e.get(RG),{unitId:r,subUnitId:i,range:a,themeName:o}=t;return n.registerRangeThemeRule(o,{range:a,unitId:r,subUnitId:i}),!0}},vlt=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetRangeThemeStyleMutation]: worksheet is null error!`);let{worksheet:r}=n;return{unitId:t.unitId,subUnitId:r.getSheetId(),range:t.range,themeName:t.themeName}},BG={id:`sheet.mutation.remove-worksheet-range-theme-style`,type:L.MUTATION,handler:(e,t)=>{if(!SG(e.get(z),t))return!1;let n=e.get(RG),{unitId:r,subUnitId:i,range:a,themeName:o}=t;return n.removeRangeThemeRule(o,{range:a,unitId:r,subUnitId:i}),!0}},ylt=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[DeleteWorksheetRangeThemeStyleMutationFactory]: worksheet is null error!`);let{worksheet:r}=n;return{unitId:t.unitId,subUnitId:r.getSheetId(),range:t.range,themeName:t.themeName}},VG=(e,t)=>{if(!CG(e.get(z),t))throw Error(`Workbook or Worksheet not found at InsertRowMutationUndoFactory`);return{unitId:t.unitId,subUnitId:t.subUnitId,range:t.range}},HG={id:`sheet.mutation.insert-row`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or Worksheet not found at InsertRowMutation`);let{worksheet:r}=n,i=r.getRowManager(),{range:a,rowInfo:o}=t,{startRow:s,endRow:c}=a;i.insertRowsWithData(s,c,o);let l=c-s+1;return r.setRowCount(r.getRowCount()+l),r.getCellMatrix().insertRows(s,l),!0}},UG=(e,t)=>{if(!CG(e.get(z),t))throw Error(`Workbook or Worksheet not found at InsertColMutationUndoFactory`);return{unitId:t.unitId,subUnitId:t.subUnitId,range:t.range}},WG={id:`sheet.mutation.insert-col`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or Worksheet not found at InsertColMutation`);let{worksheet:r}=n,i=r.getColumnManager(),{range:a,colInfo:o}=t,{startColumn:s,endColumn:c}=a;i.insertColumnsWithData(s,c,o);let l=c-s+1;return r.setColumnCount(r.getColumnCount()+l),r.getCellMatrix().insertColumns(a.startColumn,l),!0}},GG={id:`sheet.mutation.move-range`,type:L.MUTATION,handler:(e,t)=>{let{from:n,to:r}=t;if(!n||!r)return!1;let i=e.get(z).getCurrentUnitOfType(M.UNIVER_SHEET);if(!i)return!1;let a=i.getSheetBySheetId(t.from.subUnitId),o=i.getSheetBySheetId(t.to.subUnitId);if(!a||!o)return!1;let s=a.getCellMatrix(),c=o.getCellMatrix();return new Rh(n.value).forValue((e,t,n)=>{n==null?s.realDeleteValue(e,t):s.setValue(e,t,n)}),new Rh(r.value).forValue((e,t,n)=>{n==null?c.realDeleteValue(e,t):c.setValue(e,t,n)}),!0}};function blt(e,t){let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=i.startRow>a.startRow,s=i.endRow-i.startRow+1;return o?{unitId:n,subUnitId:r,sourceRange:d_.clone(a),targetRange:{...i,endRow:i.endRow+s,startRow:i.startRow+s}}:{unitId:n,subUnitId:r,targetRange:d_.clone(i),sourceRange:{...a,endRow:a.endRow-s,startRow:a.startRow-s}}}var KG={id:`sheet.mutation.move-rows`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=e.get(z).getUniverSheetInstance(n);if(!o)throw Error(`[MoveRowMutation] univerSheet is null!`);let s=o.getSheetBySheetId(r);if(!s)throw Error(`[MoveRowMutation] worksheet is null!`);let c=i.startRow,l=i.endRow-i.startRow+1,u=a.startRow;return Fh(c,l,u,s.getRowManager().getRowData()),s.getCellMatrix().moveRows(c,l,u),!0}};function xlt(e,t){let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=i.startColumn>a.startColumn,s=i.endColumn-i.startColumn+1;return o?{unitId:n,subUnitId:r,sourceRange:d_.clone(a),targetRange:{...i,endColumn:i.endColumn+s,startColumn:i.startColumn+s}}:{unitId:n,subUnitId:r,targetRange:d_.clone(i),sourceRange:{...a,startColumn:a.startColumn-s,endColumn:a.endColumn-s}}}var qG={id:`sheet.mutation.move-columns`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,sourceRange:i,targetRange:a}=t,o=e.get(z).getUniverSheetInstance(n);if(!o)throw Error(`[MoveColumnMutation] univerSheet is null!`);let s=o.getSheetBySheetId(r);if(!s)throw Error(`[MoveColumnMutation] worksheet is null!`);let c=i.startColumn,l=i.endColumn-i.startColumn+1,u=a.startColumn;return Fh(c,l,u,s.getColumnManager().getColumnData()),s.getCellMatrix().moveColumns(c,l,u),!0}},Slt=(e,t)=>{let n=t.getRowManager().getRowData(),r={},i=e.range,a=Nh(r,Ph(i.startRow,i.endRow,n));return{unitId:e.unitId,subUnitId:e.subUnitId,range:e.range,rowInfo:a}},JG={id:`sheet.mutation.remove-rows`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(!r)return!1;let i=t.range,a=r.getRowManager().getRowData(),o=[];for(let e=i.startRow;e<=i.endRow;e++)r.getRowFiltered(e)&&o.push(e);let s=i.endRow-i.startRow+1;return Mh(i.startRow,s,a),r.getCellMatrix().removeRows(i.startRow,s),r.setRowCount(r.getRowCount()-s),!0}},Clt=(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(r==null)throw Error(`worksheet is null error!`);let i=r.getColumnManager().getColumnData(),a={},o=t.range,s=Nh(a,Ph(o.startColumn,o.endColumn,i));return{unitId:t.unitId,subUnitId:t.subUnitId,range:t.range,colInfo:s}},YG={id:`sheet.mutation.remove-col`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(!r)return!1;let i=t.range,a=r.getColumnManager().getColumnData(),o=i.endColumn-i.startColumn+1;return Mh(i.startColumn,o,a),r.setColumnCount(r.getColumnCount()-o),r.getCellMatrix().removeColumns(i.startColumn,o),!0}},XG=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or worksheet is null error!`);let{worksheet:r}=n,i=r.getConfig().mergeData,a=t.ranges,o=[];for(let e=0;e<a.length;e++)for(let t=i.length-1;t>=0;t--){let n=i[t],r=a[e];d_.intersects(n,r)&&o.push(i[t])}return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:o}},ZG={id:`sheet.mutation.remove-worksheet-merge`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`Workbook or worksheet is null error!`);let{worksheet:r}=n,i=r.getConfig().mergeData,a=t.ranges;for(let e=0;e<a.length;e++)for(let t=i.length-1;t>=0;t--){let n=i[t],r=a[e];d_.intersects(n,r)&&i.splice(t,1)}return r.getSpanModel().rebuild(i),!0}},wlt=e=>{let{order:t}=e,n={};return Object.keys(t).forEach(e=>{n[t[Number(e)]]=Number(e)}),{...e,order:n}},QG={id:`sheet.mutation.reorder-range`,type:L.MUTATION,handler:(e,t)=>{let{subUnitId:n,unitId:r,range:i,order:a}=t,o=e.get(z).getUnit(r).getSheetBySheetId(n);if(!o)return!1;let s=new Rh;t_.foreach(i,(e,t)=>{if(a.hasOwnProperty(e)){let n=a[e],r=F.deepClone(o.getCellRaw(n,t));s.setValue(e,t,r)}});let c=o.getCellMatrix();return s.forValue((e,t,n)=>{c.setValue(e,t,n)}),!0}};function Tlt(e,t){if(e==null)return e;let n=F.deepClone(e);if(t==null)return n;let r={};return`h`in t&&(r.h=n.h),`ia`in t&&(r.ia=n.ia),`ah`in t&&(r.ah=n.ah),`hd`in t&&(r.hd=n.hd),`s`in t&&(r.s=n.s),`custom`in t&&(r.custom=n.custom),r}function Elt(e,t){if(e==null)return e;let n=F.deepClone(e);if(t==null)return n;let r={};return`w`in t&&(r.w=n.w),`hd`in t&&(r.hd=n.hd),`s`in t&&(r.s=n.s),`custom`in t&&(r.custom=n.custom),r}var Dlt=(e,t)=>{let{unitId:n,subUnitId:r,columnData:i}=e,a={},o=t.getColumnManager();for(let e in i){let t=i[e];a[e]=Elt(o.getColumn(Number(e)),t)}return{unitId:n,subUnitId:r,columnData:a}},$G={id:`sheet.mutation.set-col-data`,type:L.MUTATION,handler:(e,t)=>{let{columnData:n}=t,r=SG(e.get(z),t);if(!r)return!1;let{worksheet:i}=r,a=i.getColumnManager();for(let e in n){let t=n[e];if(t==null){a.removeColumn(Number(e));continue}let r=a.getColumnOrCreate(Number(e));Object.assign(r,t)}return!0}},Olt=(e,t)=>{if(e.get(z).getUniverSheetInstance(t.unitId)==null)throw Error(`universheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:t.ranges}},eK={id:`sheet.mutation.set-col-hidden`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(!n)return!1;let r=n.getSheetBySheetId(t.subUnitId).getColumnManager();for(let e=0;e<t.ranges.length;e++){let n=t.ranges[e];for(let e=n.startColumn;e<n.endColumn+1;e++){let t=r.getColumnOrCreate(e);t!=null&&(t.hd=Np.TRUE)}}return!0}},klt=(e,t)=>{if(e.get(z).getUniverSheetInstance(t.unitId)==null)throw Error(`universheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:t.ranges}},tK={id:`sheet.mutation.set-col-visible`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(!n)return!1;let r=n.getSheetBySheetId(t.subUnitId).getColumnManager();for(let e=0;e<t.ranges.length;e++){let n=t.ranges[e];for(let e=n.startColumn;e<n.endColumn+1;e++){let t=r.getColumnOrCreate(e);t!=null&&(t.hd=Np.FALSE)}}return!0}},nK={id:`sheet.mutation.set-gridlines-color`,type:L.MUTATION,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{worksheet:r}=n,i=r.getConfig();return i.gridlinesColor=t.color,!0}};function rK(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iK(e,t,n){for(let r of t)Object.prototype.hasOwnProperty.call(e,r)&&n(r,e[r])}function aK(e,t,n){if(e==null)return e;if(!rK(e))return;let r={},i=!1;if(iK(e,t,(e,t)=>{r[e]=t,i=!0}),n)for(let t in n){let a=n[t];if(!a||!Object.prototype.hasOwnProperty.call(e,t))continue;let o=a(e[t]);o!==void 0&&(r[t]=o,i=!0)}return i?r:void 0}function Alt(e,t,n){if(e==null)return e;if(!rK(e))return;let r={},i=!1;return iK(e,t,(e,t)=>{let a=n(t);a!==void 0&&(r[e]=a,i=!0)}),i?r:void 0}function jlt(e){switch(e){case`bd`:case`tr`:case`td`:case`ht`:case`vt`:case`tb`:case`pd`:case`bg`:return!0;default:return!1}}function Mlt(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function oK(e){return aK(e,pm)}function Nlt(e){return aK(e,fm,{cl:oK})}function Plt(e){return aK(e,mm,{cl:oK})}function Flt(e){return Alt(e,hm,Plt)}function Ilt(e){return aK(e,gm)}function Llt(e){return aK(e,_m)}function Rlt(e){if(e==null)return e;if(rK(e)&&Object.prototype.hasOwnProperty.call(e,`pattern`)&&typeof e.pattern==`string`)return{pattern:e.pattern}}function zlt(e,t){switch(e){case`ul`:case`bbl`:case`st`:case`ol`:return Nlt(t);case`bg`:case`cl`:return oK(t);case`bd`:return Flt(t);case`tr`:return Ilt(t);case`pd`:return Llt(t);case`n`:return Rlt(t);default:return Mlt(t)?t:void 0}}function Blt(e,t){if(t===null)return null;if(t===void 0)return e;let n=t,r=F.isObject(e)?{...e}:{};return iK(n,hm,(e,t)=>{let n=Plt(t);n!==void 0&&(r[e]=n)}),r}function Vlt(e,t,n){let r=e.getStyleByCell(t);r??delete t.s,typeof n.s==`string`&&(n.s=e.get(n.s));let i=sK(r,n.s?n.s:null);i&&(F.removeNull(i),Object.entries(i).forEach(([e,t])=>{typeof t==`object`&&t&&Object.keys(t).length===0&&delete i[e]})),F.isEmptyObject(i)?delete t.s:t.s=e.setValue(i);let a=n.v?`${n.v}\r\n`:``;!n.p&&t.p&&(a&&a!==t.p.body?.dataStream?delete t.p:Glt(t.p,n.s?n.s:null))}function Hlt(e,t){if(!t||!Object.keys(t).length)return e;let n=F.deepClone(e??{})||{},r=t;for(let e of vm){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=zlt(e,r[e]);t!==void 0&&(e===`bd`?n[e]=Ult(n[e]||{},t):e in n||(n[e]=null))}return n}function Ult(e,t){if(!t||!Object.keys(t).length)return e;let n=e;for(let r of hm)Object.prototype.hasOwnProperty.call(t,r)&&(r in e||(n[r]=null));return e}function sK(e,t,n=!1){if(t===null)return t;if(t===void 0)return e;let r=F.deepClone(e)||{},i=t;for(let e of vm){if(!Object.prototype.hasOwnProperty.call(i,e)||n&&jlt(e))continue;let t=zlt(e,i[e]);t!==void 0&&(r[e]=e===`bd`?Blt(r[e],t):t)}if(`cl`in r){let e=r,t=e.cl;`ul`in e&&e.ul&&(e.ul.cl=t),`ol`in e&&e.ol&&(e.ol.cl=t),`st`in e&&e.st&&(e.st.cl=t)}return r}function Wlt(e,t){return e.some(e=>e.startIndex===t)?Wlt(e,t+1):t}function Glt(e,t){if(e.body==null)return;Array.isArray(e.body.textRuns)||(e.body.textRuns=[]);let n=0,r=[],i=e.body?.paragraphs||[];for(let a of e.body.textRuns){let{st:e,ed:o,ts:s={}}=a;if(n<e){let i={st:n,ed:e},a=sK({},t,!0);a&&F.removeNull(a),F.isEmptyObject(a)||(i.ts=a),r.push(i)}let c=sK(s,t,!0);c&&F.removeNull(c),F.isEmptyObject(c)?delete a.ts:a.ts=c,r.push(a),n=Wlt(i,o)}let a=e.body.dataStream.endsWith(`\r
|
|
595
595
|
`)?e.body.dataStream.length-2:e.body.dataStream.length;if(n<a){let e={st:n,ed:a},i=sK({},t,!0);i&&F.removeNull(i),F.isEmptyObject(i)||(e.ts=i),r.push(e)}e.body.textRuns=T_(r)}function Klt(e,t){return t.v===void 0||t.v===null?t.v:e===Pp.NUMBER?Number(t.v):e===Pp.BOOLEAN?+!!qlt(t.v):e===Pp.STRING||e===Pp.FORCE_STRING?`${t.v}`:t.v}function qlt(e){if(typeof e==`string`){if(e.toUpperCase()===`TRUE`)return!0;if(e.toUpperCase()===`FALSE`)return!1;if(If(e)){if(Number(e)===0)return!1;if(Number(e)===1)return!0}}if(typeof e==`number`){if(e===0)return!1;if(e===1)return!0}return typeof e==`boolean`?e:null}function Jlt(e){return e==null?null:(e.f===void 0&&(e.f=null),e.si===void 0&&(e.si=null),e.p===void 0&&(e.p=null),e.v===void 0&&(e.v=null),e.t===void 0&&(e.t=null),e.s===void 0&&(e.s=null),e.custom===void 0&&(e.custom=null),e)}var cK=(e,t)=>{let{unitId:n,subUnitId:r,cellValue:i}=t,a=e.get(z).getUniverSheetInstance(n);if(a==null)throw Error(`workbook is null error!`);let o=a.getSheetBySheetId(r);if(o==null)throw Error(`worksheet is null error!`);let s=o.getCellMatrix(),c=a.getStyles(),l=new Rh;return new Rh(i).forValue((e,t,n)=>{let r=F.deepClone(s?.getValue(e,t))||{};r.s=Hlt(c.getStyleByCell(r),c.getStyleByCell(n)),l.setValue(e,t,Jlt(r))}),{...t,options:{},cellValue:l.getMatrix()}},lK={id:`sheet.mutation.set-range-values`,type:L.MUTATION,handler:(e,t)=>{let{cellValue:n,subUnitId:r,unitId:i}=t,a=e.get(z).getUnit(i);if(!a)return!1;let o=a.getSheetBySheetId(r);if(!o)return!1;let s=o.getCellMatrix(),c=a.getStyles();return new Rh(n).forValue((e,t,n)=>{if(!n)s.realDeleteValue(e,t);else{let r=s.getValue(e,t)||{};r=Xlt(n,r,c),F.isEmptyObject(r)?s.realDeleteValue(e,t):s.setValue(e,t,r)}}),!0}},Ylt=new Set([`f`,`p`,`si`,`custom`,`ref`,`xf`]);function Xlt(e,t,n){let r=qct(n,e,t);return Object.keys(e).forEach(i=>{let a=i;if(Ylt.has(a)){let n=e[a];Zlt(t,a,n)}else a===`v`?e.v!==void 0&&(t.v=Klt(r,e)):a===`s`&&Vlt(n,t,e)}),t.v!==void 0&&(t.t=r,t.v=Klt(r,t)),t.v===null&&(delete t.t,delete t.v),t}function Zlt(e,t,n){n===void 0||(n===null?delete e[t]:e[t]=n)}var Qlt=(e,t)=>{let{unitId:n,subUnitId:r,rowData:i}=e,a={},o=t.getRowManager();for(let e in i){let t=i[e];a[e]=Tlt(o.getRow(Number(e)),t)}return{unitId:n,subUnitId:r,rowData:a}},uK={id:`sheet.mutation.set-row-data`,type:L.MUTATION,handler:(e,t)=>{let{rowData:n}=t,r=SG(e.get(z),t);if(!r)return!1;let{worksheet:i}=r,a=i.getRowManager();for(let e in n){let t=n[e];if(t==null){a.removeRow(Number(e));continue}let r=a.getRowOrCreate(Number(e));Object.assign(r,t)}return!0}},$lt=(e,t)=>{if(e.get(z).getUniverSheetInstance(t.unitId)==null)throw Error(`universheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:t.ranges}},dK={id:`sheet.mutation.set-row-visible`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId).getRowManager();for(let e=0;e<t.ranges.length;e++){let n=t.ranges[e];for(let e=n.startRow;e<n.endRow+1;e++){let t=r.getRowOrCreate(e);t!=null&&(t.hd=0)}}return!0}},eut=(e,t)=>{if(e.get(z).getUniverSheetInstance(t.unitId)==null)throw Error(`universheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,ranges:t.ranges}},fK={id:`sheet.mutation.set-row-hidden`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId).getRowManager();for(let e=0;e<t.ranges.length;e++){let n=t.ranges[e];for(let e=n.startRow;e<n.endRow+1;e++){let t=r.getRowOrCreate(e);t!=null&&(t.hd=1)}}return!0}},pK=(e,t)=>{let{unitId:n,subUnitId:r,ranges:i}=e,a={},o=t.getColumnManager();for(let e=0;e<i.length;e++){let t=i[e];for(let e=t.startColumn;e<t.endColumn+1;e++)a[e]=o.getColumnWidth(e)}return{unitId:n,subUnitId:r,ranges:i,colWidth:a}},mK={id:`sheet.mutation.set-worksheet-col-width`,type:L.MUTATION,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{worksheet:r}=n,i=r.getColumnManager(),a=t.ranges;for(let e=0;e<a.length;e++){let n=a[e];for(let e=n.startColumn;e<n.endColumn+1;e++)r.getColVisible(e)&&(typeof t.colWidth==`number`?i.setColumnWidth(e,t.colWidth):F.isDefine(t.colWidth[e])&&i.setColumnWidth(e,t.colWidth[e]))}return!0}},tut=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetColumnCountUndoMutationFactory]: worksheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,columnCount:n.worksheet.getColumnCount()}},hK={id:`sheet.mutation.set-worksheet-column-count`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);return n?(n.worksheet.setColumnCount(t.columnCount),!0):!1}},gK={id:`sheet.mutation.set-worksheet-default-style`,type:L.MUTATION,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{worksheet:r}=n,{defaultStyle:i}=t;return r.setDefaultCellStyle(i),!0}},nut=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetDefaultStyleMutationFactory]: worksheet is null error!`);let{worksheet:r}=n;return{unitId:t.unitId,subUnitId:r.getSheetId(),defaultStyle:r.getDefaultCellStyle()}},rut=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetRowCountUndoMutationFactory]: worksheet is null error!`);return{unitId:t.unitId,subUnitId:t.subUnitId,rowCount:n.worksheet.getRowCount()}},_K={id:`sheet.mutation.set-worksheet-row-count`,type:L.MUTATION,handler:(e,t)=>{let n=CG(e.get(z),t);return n?(n.worksheet.setRowCount(t.rowCount),!0):!1}},iut=(e,t)=>{let{unitId:n,subUnitId:r,ranges:i}=e,a={},o=t.getRowManager();for(let{startRow:e,endRow:n}of i)for(let r=e;r<n+1;r++)a[r]=o.getRow(r)?.h??t.getConfig().defaultRowHeight;return{unitId:n,subUnitId:r,ranges:i,rowHeight:a}},vK=(e,t)=>{let{unitId:n,subUnitId:r,ranges:i}=e,a={},o=t.getRowManager();for(let{startRow:e,endRow:t}of i)for(let n=e;n<=t;n++)a[n]=o.getRow(n)?.ia;return{unitId:n,subUnitId:r,ranges:i,autoHeightInfo:a}},yK=(e,t)=>{let{unitId:n,subUnitId:r,rowsAutoHeightInfo:i}=e,a=[],o=t.getRowManager();for(let e of i){let{row:n}=e;a.push({row:n,autoHeight:o.getRow(n)?.ah??t.getConfig().defaultRowHeight})}return{unitId:n,subUnitId:r,rowsAutoHeightInfo:a}},bK={id:`sheet.mutation.set-worksheet-row-height`,type:L.MUTATION,handler:(e,t)=>{let{ranges:n,rowHeight:r}=t,i=SG(e.get(z),t);if(!i)return!1;let{worksheet:a}=i,o=a.getRowManager();for(let{startRow:e,endRow:t}of n)for(let n=e;n<=t;n++)typeof r==`number`?o.setRowHeight(n,r):F.isDefine(r[n])&&o.setRowHeight(n,r[n]);return!0}},xK={id:`sheet.mutation.set-worksheet-row-is-auto-height`,type:L.MUTATION,handler:(e,t)=>{let{ranges:n,autoHeightInfo:r}=t,i=SG(e.get(z),t);if(!i)return!1;let a=i.worksheet.getRowManager();for(let{startRow:e,endRow:t}of n)for(let n=e;n<=t;n++){let e=a.getRowOrCreate(n);e.ia=typeof r==`number`?r:r[n]??void 0}return!0}},SK={id:`sheet.mutation.set-worksheet-row-auto-height`,type:L.MUTATION,handler:(e,t)=>{let{rowsAutoHeightInfo:n}=t,r=SG(e.get(z),t);if(!r)return!1;let i=r.worksheet.getRowManager();for(let{row:e,autoHeight:t}of n){let n=i.getRowOrCreate(e);n.ah=t}return!0}},CK={id:`sheet.mutation.toggle-gridlines`,type:L.MUTATION,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{worksheet:r}=n,i=r.getConfig();return i.showGridlines=t.showGridlines,!0}},wK={id:`sheet.operation.set-worksheet-active`,type:L.OPERATION,handler:(e,t)=>{let n=e.get(z).getUnit(t.unitId,M.UNIVER_SHEET);if(!n)return!1;let r=n.getWorksheets();for(let[,e]of r)if(e.getSheetId()===t.subUnitId)return n.setActiveSheet(e),!0;return!1}},aut=function(e){return e.SET_WORKSHEET_ROW_HEIGHT=`sheet.mutation.set-worksheet-row-height`,e.SET_WORKSHEET_ROW_IS_AUTO_HEIGHT=`sheet.mutation.set-worksheet-row-is-auto-height`,e.SET_WORKSHEET_ROW_AUTO_HEIGHT=`sheet.mutation.set-worksheet-row-auto-height`,e.SET_WORKSHEET_COL_WIDTH=`sheet.mutation.set-worksheet-col-width`,e.SET_WORKSHEET_ACTIVE=`sheet.operation.set-worksheet-active`,e.MOVE_ROWS=`sheet.mutation.move-rows`,e.MOVE_COLUMNS=`sheet.mutation.move-columns`,e.SET_COL_HIDDEN=`sheet.mutation.set-col-hidden`,e.SET_COL_VISIBLE=`sheet.mutation.set-col-visible`,e.SET_ROW_HIDDEN=`sheet.mutation.set-row-hidden`,e.SET_ROW_VISIBLE=`sheet.mutation.set-row-visible`,e.INSERT_COL=`sheet.mutation.insert-col`,e.INSERT_ROW=`sheet.mutation.insert-row`,e.REMOVE_COL=`sheet.mutation.remove-col`,e.REMOVE_ROW=`sheet.mutation.remove-rows`,e.TOGGLE_GRIDLINES=`sheet.mutation.toggle-gridlines`,e.SET_GRIDLINES_COLOR=`sheet.mutation.set-gridlines-color`,e}({}),out=function(e){return e.SET_RANGE_VALUES=`sheet.mutation.set-range-values`,e.MOVE_RANGE=`sheet.mutation.move-range`,e.REMOVE_WORKSHEET_MERGE=`sheet.mutation.remove-worksheet-merge`,e.ADD_WORKSHEET_MERGE=`sheet.mutation.add-worksheet-merge`,e.REORDER_RANGE=`sheet.mutation.reorder-range`,e.SET_WORKSHEET_DEFAULT_STYLE=`sheet.mutation.set-worksheet-default-style`,e.SET_ROW_DATA=`sheet.mutation.set-row-data`,e.SET_COL_DATA=`sheet.mutation.set-col-data`,e.SET_WORKSHEET_RANGE_THEME_STYLE=`sheet.mutation.set-worksheet-range-theme-style`,e.DELETE_WORKSHEET_RANGE_THEME_STYLE=`sheet.mutation.delete-worksheet-range-theme-style`,e}({}),TK=[bK.id,xK.id,SK.id,mK.id,wK.id,KG.id,qG.id,eK.id,tK.id,fK.id,dK.id,WG.id,HG.id,YG.id,JG.id,CK.id,nK.id,_K.id,hK.id],sut=[lK.id,GG.id,ZG.id,TG.id,QG.id,gK.id,uK.id,$G.id,zG.id,BG.id];function cut(e,t){switch(t.id){case`sheet.mutation.set-range-values`:{let e=t.params,n=new Rh(e.cellValue).getDataRange();return n.endRow===-1?[]:e.cellValue?[{unitId:e.unitId,subUnitId:e.subUnitId,range:n}]:[]}case`sheet.mutation.move-range`:{let e=t.params;return[{unitId:e.unitId,subUnitId:e.from.subUnitId,range:new Rh(e.from.value).getRange()},{unitId:e.unitId,subUnitId:e.to.subUnitId,range:new Rh(e.to.value).getRange()}]}case`sheet.mutation.remove-worksheet-merge`:{let e=t.params;return e.ranges.map(t=>({unitId:e.unitId,subUnitId:e.subUnitId,range:t}))}case`sheet.mutation.add-worksheet-merge`:{let e=t.params;return e.ranges.map(t=>({unitId:e.unitId,subUnitId:e.subUnitId,range:t}))}case`sheet.mutation.reorder-range`:{let e=t.params;return[{unitId:e.unitId,subUnitId:e.subUnitId,range:e.range}]}case`sheet.mutation.set-worksheet-default-style`:{let n=SG(e,t.params);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n;return[{unitId:i,subUnitId:a,range:{startRow:0,endRow:r.getRowCount()-1,startColumn:0,endColumn:r.getColumnCount()-1}}]}case`sheet.mutation.set-row-data`:{let n=SG(e,t.params);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,{rowData:o}=t.params,s=Object.keys(o).map(Number);return s.length===0?[]:[{unitId:i,subUnitId:a,range:{startRow:Math.min(...s),endRow:Math.max(...s),startColumn:0,endColumn:r.getColumnCount()-1}}]}case`sheet.mutation.set-col-data`:{let n=SG(e,t.params);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,{columnData:o}=t.params,s=Object.keys(o).map(Number);return s.length===0?[]:[{unitId:i,subUnitId:a,range:{startRow:0,endRow:r.getRowCount()-1,startColumn:Math.min(...s),endColumn:Math.max(...s)}}]}case`sheet.mutation.set-worksheet-range-theme-style`:case`sheet.mutation.delete-worksheet-range-theme-style`:{let e=t.params;return[{unitId:e.unitId,subUnitId:e.subUnitId,range:e.range}]}default:return[]}}function lut(e,t){switch(e.id){case`sheet.mutation.set-worksheet-row-height`:case`sheet.mutation.set-worksheet-row-is-auto-height`:{let t=e.params;return t.ranges.map(e=>({unitId:t.unitId,subUnitId:t.subUnitId,range:{...e,rangeType:vh.ROW}}))}case`sheet.mutation.set-worksheet-row-auto-height`:{let n=e.params;return n.rowsAutoHeightInfo.map(e=>({unitId:n.unitId,subUnitId:n.subUnitId,range:{startRow:e.row,endRow:e.row,startColumn:0,endColumn:t-1,rangeType:vh.ROW}}))}case`sheet.mutation.set-worksheet-col-width`:{let t=e.params;return t.ranges.map(e=>({unitId:t.unitId,subUnitId:t.subUnitId,range:{...e,rangeType:vh.COLUMN}}))}case`sheet.mutation.move-rows`:case`sheet.mutation.move-columns`:{let t=e.params;return[{unitId:t.unitId,subUnitId:t.subUnitId,range:t.targetRange},{unitId:t.unitId,subUnitId:t.subUnitId,range:t.sourceRange}]}case`sheet.mutation.set-col-hidden`:case`sheet.mutation.set-col-visible`:{let t=e.params;return t.ranges.map(e=>({unitId:t.unitId,subUnitId:t.subUnitId,range:{...e,rangeType:vh.COLUMN}}))}case`sheet.mutation.set-row-hidden`:case`sheet.mutation.set-row-visible`:{let t=e.params;return t.ranges.map(e=>({unitId:t.unitId,subUnitId:t.subUnitId,range:{...e,rangeType:vh.ROW}}))}case`sheet.mutation.insert-col`:{let t=e.params;return[{unitId:t.unitId,subUnitId:t.subUnitId,range:{...t.range,rangeType:vh.COLUMN}}]}case`sheet.mutation.insert-row`:{let t=e.params;return[{unitId:t.unitId,subUnitId:t.subUnitId,range:{...t.range,rangeType:vh.ROW}}]}case`sheet.mutation.remove-col`:{let t=e.params;return[{unitId:t.unitId,subUnitId:t.subUnitId,range:{...t.range,rangeType:vh.COLUMN}}]}case`sheet.mutation.remove-rows`:{let t=e.params;return[{unitId:t.unitId,subUnitId:t.subUnitId,range:{...t.range,rangeType:vh.ROW}}]}case`sheet.mutation.toggle-gridlines`:case`sheet.mutation.set-gridlines-color`:return[];default:return[]}}function EK(e,t){if(e.length===0)return`sheets.definedName.nameEmpty`;let{unitId:n,formulaOrRefString:r,univerInstanceService:i,definedNamesService:a,superTableService:o,functionService:s,id:c}=t,l=a.getValueByName(n,e);if(l&&(c==null||c.length===0||l.id!==c)||o.hasTable(n,e))return`sheets.definedName.nameDuplicate`;if(!F.isValidParameter(e)||Dz(e)||!F.isStartValidPosition(e)&&!Ow(e.substring(0,1)))return`sheets.definedName.nameInvalid`;let u=i.getUnit(n,M.UNIVER_SHEET);if(!u)throw Error(`Workbook not found for unitId: ${n}`);return u.getSheets().some(t=>t.getName()===e)?`sheets.definedName.nameSheetConflict`:r.length===0?`sheets.definedName.formulaOrRefStringEmpty`:!s.hasExecutor(e.toUpperCase())||`sheets.definedName.nameConflict`}function uut(e){return e==null?!1:e.v!==void 0&&e.v!==null&&e.v!==``||e.p!==void 0}function DK(e,t){return e&&e.spanAnchor?uut(t.getValue(e.spanAnchor.startRow,e.spanAnchor.startColumn)):uut(e)}function dut(e,t,n,r,i){let a=e.getCellMatrix(),o=e.getSpanModel().getMergedCellRange(t,n,r,i),s=new Rh;return a.forValue((e,t)=>{let n=a.getValue(e,t);n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;g_(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),spanAnchor:{startRow:n,endRow:i,startColumn:t,endColumn:r}}),(e!==n||o!==t)&&(s.realDeleteValue(e,o),s.setValue(e,o,{spanAnchor:{startRow:n,endRow:i,startColumn:t,endColumn:r}}))})}),s}function fut(e,t,n,r){let{startRow:i,startColumn:a,endRow:o}=e,s=null,c=!1;for(let e=i;e<=o;e++){let i=t.getValue(e,a-n);if(c||=DK(i,t),!r&&c)break;i&&i.spanAnchor&&(s=s?{startRow:Math.min(i.spanAnchor.startRow,s.startRow),startColumn:Math.min(i.spanAnchor.startColumn,s.startColumn),endRow:Math.max(i.spanAnchor.endRow,s.endRow),endColumn:Math.max(i.spanAnchor.endColumn,s.endColumn)}:{startRow:i.spanAnchor.startRow,startColumn:i.spanAnchor.startColumn,endRow:i.spanAnchor.endRow,endColumn:i.spanAnchor.endColumn})}return c?(e.startColumn-=n,{spanAnchor:s,hasValue:!0,range:e}):s?{spanAnchor:d_.simpleRangesIntersect(e,s)?s:null,hasValue:!1,range:e}:{spanAnchor:null,hasValue:!1,range:e}}function put(e,t,n,r){let{startRow:i,endColumn:a,endRow:o}=e,s=null,c=!1;for(let e=i;e<=o;e++){let i=t.getValue(e,a+n);if(c||=DK(i,t),!r&&c)break;i&&i.spanAnchor&&(s=s?{startRow:Math.min(i.spanAnchor.startRow,s.startRow),startColumn:Math.min(i.spanAnchor.startColumn,s.startColumn),endRow:Math.max(i.spanAnchor.endRow,s.endRow),endColumn:Math.max(i.spanAnchor.endColumn,s.endColumn)}:{startRow:i.spanAnchor.startRow,startColumn:i.spanAnchor.startColumn,endRow:i.spanAnchor.endRow,endColumn:i.spanAnchor.endColumn})}return c?(e.endColumn+=n,{spanAnchor:s,hasValue:!0,range:e}):s?{spanAnchor:d_.simpleRangesIntersect(e,s)?s:null,hasValue:!1,range:e}:{spanAnchor:null,hasValue:!1,range:e}}function mut(e,t,n,r){let{startRow:i,startColumn:a,endColumn:o}=e,s=null,c=!1;for(let e=a;e<=o;e++){let a=t.getValue(i-n,e);if(c||=DK(a,t),!r&&c)break;a&&a.spanAnchor&&(s=s?{startRow:Math.min(a.spanAnchor.startRow,s.startRow),startColumn:Math.min(a.spanAnchor.startColumn,s.startColumn),endRow:Math.max(a.spanAnchor.endRow,s.endRow),endColumn:Math.max(a.spanAnchor.endColumn,s.endColumn)}:{startRow:a.spanAnchor.startRow,startColumn:a.spanAnchor.startColumn,endRow:a.spanAnchor.endRow,endColumn:a.spanAnchor.endColumn})}return c?(e.startRow-=n,{spanAnchor:s,hasValue:!0,range:e}):s?{spanAnchor:d_.simpleRangesIntersect(e,s)?s:null,hasValue:!1,range:e}:{spanAnchor:null,hasValue:!1,range:e}}function hut(e,t,n,r){let{startColumn:i,endColumn:a,endRow:o}=e,s=null,c=!1;for(let e=i;e<=a;e++){let i=t.getValue(o+n,e);if(c||=DK(i,t),!r&&c)break;i&&i.spanAnchor&&(s=s?{startRow:Math.min(i.spanAnchor.startRow,s.startRow),startColumn:Math.min(i.spanAnchor.startColumn,s.startColumn),endRow:Math.max(i.spanAnchor.endRow,s.endRow),endColumn:Math.max(i.spanAnchor.endColumn,s.endColumn)}:{startRow:i.spanAnchor.startRow,startColumn:i.spanAnchor.startColumn,endRow:i.spanAnchor.endRow,endColumn:i.spanAnchor.endColumn})}return c?(e.endRow+=n,{spanAnchor:s,hasValue:!0,range:e}):s?{spanAnchor:d_.simpleRangesIntersect(e,s)?s:null,hasValue:!1,range:e}:{spanAnchor:null,hasValue:!1,range:e}}function gut({range:e,allMatrixWithSpan:t,directions:n,isWorksheetHasSpan:r,maxRow:i,maxColumn:a}){let{left:o,right:s,up:c,down:l}=n,{startRow:u,startColumn:d,endRow:f,endColumn:p}=e,m=!1;if(o&&c&&u>0&&d>0){let n=t.getValue(u-1,d-1);DK(n,t)&&(r&&n.spanAnchor?(e.startRow=n.spanAnchor.startRow,e.startColumn=n.spanAnchor.startColumn):(e.startRow=u-1,e.startColumn=d-1),m=!0)}if(s&&c&&u>0&&p<a-1){let n=t.getValue(u-1,p+1);DK(n,t)&&(r&&n.spanAnchor?(e.startRow=n.spanAnchor.startRow,e.endColumn=n.spanAnchor.endColumn):(e.startRow=u-1,e.endColumn=p+1),m=!0)}if(o&&l&&f<i-1&&d>0){let n=t.getValue(f+1,d-1);DK(n,t)&&(r&&n.spanAnchor?(e.endRow=n.spanAnchor.endRow,e.startColumn=n.spanAnchor.startColumn):(e.endRow=f+1,e.startColumn=d-1),m=!0)}if(s&&l&&f<i-1&&p<a-1){let n=t.getValue(f+1,p+1);DK(n,t)&&(r&&n.spanAnchor?(e.endRow=n.spanAnchor.endRow,e.endColumn=n.spanAnchor.endColumn):(e.endRow=f+1,e.endColumn=p+1),m=!0)}return{hasValue:m,range:e}}function OK(e,t,n){let r=n.getMaxRows(),i=n.getMaxColumns(),a=dut(n,0,0,r-1,i-1),o=n.getSnapshot().mergeData.length>0,{left:s,right:c,up:l,down:u}=t,d=!0,f={...e},p=[];for(;d;){d=!1;let e=gut({range:f,allMatrixWithSpan:a,directions:t,isWorksheetHasSpan:o,maxRow:r,maxColumn:i});if(e.hasValue){f=e.range,d=!0;continue}if(l&&f.startRow!==0){let{hasValue:e,range:t,spanAnchor:n}=mut(f,a,1,o);if(n&&p.push(n),e){f=t,d=!0;continue}}if(u&&f.endRow!==r-1){let{hasValue:e,range:t,spanAnchor:n}=hut(f,a,1,o);if(n&&p.push(n),e){f=t,d=!0;continue}}if(s&&f.startColumn!==0){let{hasValue:e,range:t,spanAnchor:n}=fut(f,a,1,o);if(n&&p.push(n),e){f=t,d=!0;continue}}if(c&&f.endColumn!==i-1){let{hasValue:e,range:t,spanAnchor:n}=put(f,a,1,o);if(n&&p.push(n),e){f=t,d=!0;continue}}}return p.length>0&&(f=d_.union(f,...p)),f}var _ut=e=>{let t=new Rh;return e.forEach(e=>{t_.foreach(e,(e,n)=>{t.setValue(e,n,1)})}),t.forValue((e,n)=>{let r=t.getValue(e-1,n);r&&t.setValue(e,n,r+1)}),t},vut=e=>{let t={area:0},n=(e,n)=>t.area<e&&(t.area=e,t.range=n,!0);return e.forValue((t,r,i)=>{let a=1,o=i;n(a*o,{startRow:t-o+1,endRow:t,startColumn:r,endColumn:r});let s={startRow:t-o+1,endRow:t,startColumn:0,endColumn:r};for(let i=r-1;i>=0&&e.getValue(t,i);i--){o=Math.min(e.getValue(t,i)||0,o),a++;let r=o*a;s.startColumn=i,s.startRow=t-o+1,n(r,s)}}),t},yut=(e,t)=>{t_.foreach(t,(t,n)=>{e.realDeleteValue(t,n)});for(let n=t.startColumn;n<=t.endColumn;n++){let r=t.endRow+1;if(e.getValue(r,n)>0){e.setValue(r,n,1);let t=r+1;for(;e.getValue(t,n)>0;)e.setValue(t,n,e.getValue(t-1,n)+1),t++}}return e},but=e=>{let t=[],n=vut(e);for(;n.area>0;)n.range&&(t.push(n.range),yut(e,n.range)),n=vut(e);return t},kK=e=>but(_ut(e)),AK=1.5,jK=`rgba(255, 255, 255, 0.01)`;function MK(e){let{rangeWithCoord:t,primaryWithCoord:n,style:r}=e,i={range:{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,unitId:t.unitId,sheetId:t.sheetId},primary:null,style:r};return n!=null&&(i.primary=NK(n)),i}function NK(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=e.mergeInfo;return{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}}var xut=function(e){return e[e.Tab=1]=`Tab`,e[e.Comma=2]=`Comma`,e[e.Semicolon=4]=`Semicolon`,e[e.Space=8]=`Space`,e[e.Custom=16]=`Custom`,e}({}),Sut=class{constructor(){Z(this,`_tabCount`,0),Z(this,`_commaCount`,0),Z(this,`_semicolonCount`,0),Z(this,`_spaceCount`,0)}add(e){switch(e){case` `:this._tabCount++;break;case`,`:this._commaCount++;break;case`;`:this._semicolonCount++;break;case` `:this._spaceCount++}}update(e){e&&typeof e==`string`&&(e.includes(` `)&&this._tabCount++,e.includes(`,`)&&this._commaCount++,e.includes(`;`)&&this._semicolonCount++,e.trim().includes(` `)&&this._spaceCount++)}getDelimiter(){let e=Math.max(this._tabCount,this._commaCount,this._semicolonCount,this._spaceCount);return e===0||e===this._tabCount?1:e===this._commaCount?2:e===this._semicolonCount?4:e===this._spaceCount?8:1}};function Cut(e,t,n){let r=[];n!==void 0&&(e&16)>0&&r.push(n),(e&1)>0&&r.push(` `),(e&2)>0&&r.push(`,`),(e&4)>0&&r.push(`;`),(e&8)>0&&r.push(` `);let i=``;for(let e of r)i+=cp(e);let a=`[${i}]`;return t&&(a+=`+`),new RegExp(a)}var wut=e=>e.body?.dataStream.replace(/\r\n$/,``)||``;function Tut(e){if(e!=null){if(e.p)return wut(e.p);if(e.v&&typeof e.v==`string`)return e.v;if(e.t&&(e.t===Pp.FORCE_STRING||e.t===Pp.STRING))return String(e.v)}}function Eut(e,t,n,r,i=!1){let{startColumn:a,startRow:o,endColumn:s,endRow:c}=t_.transformRange(t,e);if(a!==s)throw Error(`The range must be in the same column.`);if(n&&(n&16)>0&&(r===void 0||r.length!==1))throw Error(`The custom delimiter must a character.`);let l=n===void 0,u=l?new Sut:null,d=[];for(let t=o;t<=c;t++){let n=Tut(e.getCell(t,a));d.push(n),u&&u.update(n)}let f=Cut(l?u.getDelimiter():n,i,r),p=-1,m=0,h=0,g=[];for(let e of d){if(e!==void 0){let t=String(e).split(f);p=p<0?t.length:Math.max(p,t.length),g.push(t),m=h}else g.push(void 0);h++}return{rs:g,maxLength:p===-1?0:p,lastRow:m}}var Dut=(e,t,n=``)=>e.reduce((e,r)=>{let i=r&&r[t];return typeof i==`string`?(i?(e[i]||(e[i]=[]),e[i].push(r)):e[n].push(r),e):(console.warn(r,`${t} is not string`),e)},{}),Out=(e=0)=>{let t=e;return function(){return t++}};function kut(e){return e==null?!1:e.v!==void 0&&e.v!==null&&e.v!==``||e.p!==void 0}function Aut(e,t){for(let n=e.startRow;n<=e.endRow;n++)for(let r=e.startColumn;r<=e.endColumn;r++)if(kut(t.getCell(n,r)))return{startRow:n,startColumn:r,endRow:n,endColumn:r};return null}function jut(e){let t=new Rh;return e.forEach(e=>{let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t.setValue(e,n,null)}),t.clone()}function Mut(e){let t=new Rh;return e.forEach(e=>{let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t.setValue(e,n,{v:null,p:null,f:null,si:null,custom:null})}),t.clone()}function Nut(e){let t=new Rh;return e.forEach(e=>{let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t.setValue(e,n,{s:null})}),t.clone()}function PK(e){let{rows:t,cols:n}=e;return{startRow:t[0],endRow:t[t.length-1],startColumn:n[0],endColumn:n[n.length-1]}}function FK(e,t,n,r){let i=t.get(z),a=n?i.getUnit(n,M.UNIVER_SHEET):i.getCurrentUnitOfType(M.UNIVER_SHEET),o=r?a?.getSheetBySheetId(r):a?.getActiveSheet();if(!o)return null;let{startRow:s,endRow:c,startColumn:l,endColumn:u}=e,d=[],f=[];for(let e=s;e<=c;e++)o.getRowFiltered(e)||d.push(e);for(let e=l;e<=u;e++)f.push(e);return{rows:d,cols:f}}function IK(e,t,n,r){let i=SG(t.get(z),{unitId:n,subUnitId:r});if(!i)return e;let{worksheet:a}=i,o=[];for(let t of e){let{startRow:e,endRow:n,startColumn:r,endColumn:i}=t,s=[],c=e;for(let t=e;t<=n;t++)a.getRowFiltered(t)?(c<t&&s.push([c,t-1]),c=t+1):t===n&&s.push([c,n]);let l=o.findIndex(e=>e.startColumn===r&&e.endColumn===i);l>-1?o[l].rowIntervals=o[l].rowIntervals.concat(s):o.push({startColumn:r,endColumn:i,rowIntervals:s})}let s=[];for(let e of o){let{startColumn:t,endColumn:n,rowIntervals:r}=e,i=Lg(r);for(let[e,r]of i)s.push({startRow:e,endRow:r,startColumn:t,endColumn:n})}return s}function Put(e){return JSON.stringify(e.filter(Boolean))}function LK(e){try{let t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t.filter(Boolean)}catch{}return e.split(`,`).filter(Boolean)}var RK=function(e){return e.OthersCanView=`othersCanView`,e.NoOneElseCanView=`noOneElseCanView`,e}({}),zK=function(e){return e.DesignedUserCanEdit=`designedUserCanEdit`,e.OnlyMe=`onlyMe`,e}({}),BK=class{constructor(){Z(this,`_model`,new Map),Z(this,`_ruleChange$`,new ao),Z(this,`ruleChange$`,this._ruleChange$.asObservable()),Z(this,`_ruleRefresh$`,new ao),Z(this,`ruleRefresh$`,this._ruleRefresh$.asObservable()),Z(this,`_rangeRuleInitStateChange`,new so(!1)),Z(this,`rangeRuleInitStateChange$`,this._rangeRuleInitStateChange.asObservable())}dispose(){this._ruleChange$.complete(),this._ruleRefresh$.complete()}ruleRefresh(e){this._ruleRefresh$.next(e)}getRangeRuleInitState(){return this._rangeRuleInitStateChange.value}changeRuleInitState(e){this._rangeRuleInitStateChange.next(e)}addRule(e,t,n){this._ensureRuleMap(e,t).set(n.id,n),this._ruleChange$.next({unitId:e,subUnitId:t,rule:n,type:`add`})}deleteRule(e,t,n){var r;let i=(r=this._model.get(e))==null||(r=r.get(t))==null?void 0:r.get(n);if(i){var a;(a=this._model.get(e))==null||(a=a.get(t))==null||a.delete(n),this._ruleChange$.next({unitId:e,subUnitId:t,rule:i,type:`delete`})}}setRule(e,t,n,r){let i=this.getRule(e,t,n);if(i){var a;(a=this._model.get(e))==null||(a=a.get(t))==null||a.set(n,r),this._ruleChange$.next({unitId:e,subUnitId:t,oldRule:i,rule:r,type:`set`})}}getRule(e,t,n){var r;return(r=this._model.get(e))==null||(r=r.get(t))==null?void 0:r.get(n)}getSubunitRuleList(e,t){return[...(this._model.get(e)?.get(t)||new Map).values()]}getSubunitRuleListLength(e,t){let n=this._model.get(e)?.get(t);return n?n.size:0}_ensureRuleMap(e,t){let n=this._model.get(e);n||(n=new Map,this._model.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}toObject(){let e={};return[...this._model.keys()].forEach(t=>{let n=this._model.get(t),r=[...n.keys()];e[t]={},r.forEach(r=>{let i=n.get(r);e[t][r]=[...i.values()]})}),e}fromObject(e){let t=new Map;Object.keys(e).forEach(n=>{let r=e[n],i=new Map;Object.keys(r).forEach(e=>{let t=r[e].reduce((e,t)=>(e.set(t.id,t),e),new Map);i.set(e,t)}),t.set(n,i)}),this._model=t}deleteUnitModel(e){this._model.delete(e)}createRuleId(e,t){let n=ip(4),r=this._ensureRuleMap(e,t);for(;r.has(n);)n=ip(4);return n}getTargetByPermissionId(e,t){let n=this._model.get(e);if(!n)return null;for(let[r,i]of n)for(let n of i.values())if(n.permissionId===t)return[e,r];return null}},VK={id:`sheet.mutation.delete-range-protection`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,ruleIds:i}=t,a=e.get(BK);return i.forEach(e=>{a.deleteRule(n,r,e)}),!0}},HK={id:`sheet.mutation.add-range-protection`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,rules:i}=t,a=e.get(BK);return i.forEach(e=>{a.addRule(n,r,e)}),!0}},Fut={type:L.COMMAND,id:`sheet.command.add-range-protection`,async handler(e,t){if(!t)return!1;let n=e.get(R),r=e.get(vx),i=e.get(BK),{rule:a,permissionId:o}=t,{unitId:s,subUnitId:c,ranges:l,description:u,viewState:d,editState:f}=a,p=[{ranges:l,permissionId:o,id:i.createRuleId(s,c),description:u,unitType:a.unitType,unitId:s,subUnitId:c,viewState:d,editState:f}];if(await n.executeCommand(HK.id,{unitId:s,subUnitId:c,rules:p})){let e=[{id:HK.id,params:{unitId:s,subUnitId:c,rules:p}}],t=[{id:VK.id,params:{unitId:s,subUnitId:c,ruleIds:p.map(e=>e.id)}}];r.pushUndoRedo({unitID:s,redoMutations:e,undoMutations:t})}return!0}},UK=function(e){return e[e.MOVE_START=0]=`MOVE_START`,e[e.MOVING=1]=`MOVING`,e[e.MOVE_END=2]=`MOVE_END`,e[e.ONLY_SET=3]=`ONLY_SET`,e}({}),Iut=class extends P{constructor(e){super(),this._workbook=e,Z(this,`_worksheetSelections`,new Map),Z(this,`_worksheetLastSelectionPrimaryCell`,new Map),Z(this,`_selectionMoveStart$`,new ao),Z(this,`selectionMoveStart$`,this._selectionMoveStart$.asObservable()),Z(this,`_selectionMoving$`,new ao),Z(this,`selectionMoving$`,this._selectionMoving$.asObservable()),Z(this,`_selectionMoveEnd$`,new so([])),Z(this,`selectionMoveEnd$`,this._selectionMoveEnd$.asObservable()),Z(this,`_selectionSet$`,new so([])),Z(this,`selectionSet$`,this._selectionSet$.asObservable()),Z(this,`selectionChanged$`,void 0),Z(this,`_beforeSelectionMoveEnd$`,new so([])),Z(this,`beforeSelectionMoveEnd$`,this._beforeSelectionMoveEnd$.asObservable()),this.selectionChanged$=Ps(this._selectionMoveEnd$,this._selectionSet$)}dispose(){super.dispose(),this._beforeSelectionMoveEnd$.complete(),this._selectionMoveEnd$.complete(),this._selectionMoving$.complete(),this._selectionMoveStart$.complete(),this._selectionSet$.complete(),this._workbook=null,this.clear()}addSelections(e,t){let n=this.getSelectionsOfWorksheet(e);n.push(...t),this._selectionSet$.next(n)}setSelections(e,t=[],n){switch(this.setSelectionsOfWorksheet(e,t),n){case 0:this._selectionMoveStart$.next(t);break;case 1:this._selectionMoving$.next(t);break;case 2:this._beforeSelectionMoveEnd$.next(t),this._selectionMoveEnd$.next(t);break;case 3:this._selectionSet$.next(t);break;default:this._selectionSet$.next(t)}}getCurrentSelections(){return this._getCurrentSelections()}getSelectionOfWorksheet(e){return this.getSelectionsOfWorksheet(e)}getSelectionsOfWorksheet(e){return this._worksheetSelections.has(e)||this._worksheetSelections.set(e,[]),this._worksheetSelections.get(e)}getLastSelectionPrimaryCellOfWorksheet(e){return this._worksheetLastSelectionPrimaryCell.get(e)??null}setSelectionsOfWorksheet(e,t){this._worksheetSelections.set(e,[...t]),t.length>0&&t[t.length-1].primary&&this._worksheetLastSelectionPrimaryCell.set(e,t[t.length-1].primary)}deleteSheetSelection(e){this._worksheetSelections.set(e,[]),this._worksheetLastSelectionPrimaryCell.delete(e)}clear(){this._worksheetSelections.clear(),this._worksheetLastSelectionPrimaryCell.clear(),this._selectionSet$.next([])}_getCurrentSelections(){return this.getSelectionsOfWorksheet(this._workbook.getActiveSheet().getSheetId())}getCurrentLastSelection(){let e=this._getCurrentSelections();return e[e.length-1]}},WK=class extends Kf{get _currentSelectionPos(){let e=this._instanceSrv.getCurrentUnitOfType(M.UNIVER_SHEET);if(!e)return null;let t=e.getActiveSheet();return{unitId:e.getUnitId(),sheetId:t.getSheetId()}}get currentSelectionParam(){return this._currentSelectionPos}constructor(e){super(),this._instanceSrv=e,Z(this,`_cellStylesCache`,new Map),Z(this,`selectionMoveStart$`,void 0),Z(this,`selectionMoving$`,void 0),Z(this,`selectionMoveEnd$`,void 0),Z(this,`selectionSet$`,void 0),Z(this,`selectionChanged$`,void 0),Z(this,`_workbookSelections`,new Map),this._init()}_init(){let e=this._instanceSrv.getCurrentTypeOfUnit$(M.UNIVER_SHEET).pipe(ic({bufferSize:1,refCount:!0}),cc(this.dispose$));this.selectionMoveStart$=e.pipe(sc(e=>e?this._ensureWorkbookSelection(e.getUnitId()).selectionMoveStart$:ts()),cc(this.dispose$)),this.selectionMoving$=e.pipe(sc(e=>e?this._ensureWorkbookSelection(e.getUnitId()).selectionMoving$:ts()),cc(this.dispose$)),this.selectionMoveEnd$=e.pipe(sc(e=>e?this._ensureWorkbookSelection(e.getUnitId()).selectionMoveEnd$:ts([])),cc(this.dispose$)),this.selectionSet$=e.pipe(sc(e=>e?this._ensureWorkbookSelection(e.getUnitId()).selectionSet$:ts([])),cc(this.dispose$)),this.selectionChanged$=e.pipe(sc(e=>e?this._ensureWorkbookSelection(e.getUnitId()).selectionChanged$:ts([])),Ys((e,t)=>e.length===t.length?e.length===0&&t.length===0||e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t[n])):!1),ac(1),cc(this.dispose$),nc()),this.disposeWithMe(this._instanceSrv.getTypeOfUnitDisposed$(M.UNIVER_SHEET).pipe(cc(this.dispose$)).subscribe(e=>{this._removeWorkbookSelection(e.getUnitId())})),this.disposeWithMe(this.selectionChanged$.pipe(cc(this.dispose$)).subscribe(()=>{this._cellStylesCache.clear()}))}dispose(){super.dispose(),this._cellStylesCache.clear(),this._workbookSelections.forEach(e=>e.dispose()),this._workbookSelections.clear(),this.selectionMoveStart$=ts(null),this.selectionMoving$=ts(null),this.selectionMoveEnd$=ts([]),this.selectionSet$=ts(null),this.selectionChanged$=ts(null)}clear(){this._workbookSelections.forEach(e=>e.clear())}getCurrentSelections(){return this._getCurrentSelections()}getCurrentLastSelection(){let e=this._getCurrentSelections();return e?.[e.length-1]}getCurrentLastSelectionPrimaryCell(){let e=this._currentSelectionPos;if(!e)return null;let{unitId:t,sheetId:n}=e;return this._ensureWorkbookSelection(t).getLastSelectionPrimaryCellOfWorksheet(n)}addSelections(e,t,n){if(typeof e==`string`){this._ensureWorkbookSelection(e).addSelections(t,n);return}let r=this._currentSelectionPos;if(!r)throw Error(`[SheetsSelectionsService]: cannot find current selection position!`);let{unitId:i,sheetId:a}=r;this._ensureWorkbookSelection(i).addSelections(a,e)}setSelections(e,t,n,r){if(typeof e==`string`&&typeof t==`string`){let i=e;this._ensureWorkbookSelection(i).setSelections(t,n||[],r??3);return}let i=this._currentSelectionPos;if(!i)throw Error(`[SheetsSelectionsService]: cannot find current selection position!`);let{unitId:a,sheetId:o}=i;if(typeof e==`object`){let r=e??n,i=t??3;this._ensureWorkbookSelection(a).setSelections(o,r,i)}}clearCurrentSelections(){this._getCurrentSelections().splice(0)}isOverlapping(){let e=this.getCurrentSelections();return e!=null&&e.some(({range:t},n)=>e.some(({range:e},r)=>n!==r&&t.startRow<=e.endRow&&t.endRow>=e.startRow&&t.startColumn<=e.endColumn&&t.endColumn>=e.startColumn))}_getCurrentSelections(){let e=this._currentSelectionPos;if(!e)return[];let{unitId:t,sheetId:n}=e;return this._ensureWorkbookSelection(t).getSelectionsOfWorksheet(n)}getWorkbookSelections(e){return this._ensureWorkbookSelection(e)}_ensureWorkbookSelection(e){let t=this._workbookSelections.get(e);if(!t){let n=this._instanceSrv.getUnit(e);if(!n)throw Error(`[SheetsSelectionsService]: cannot resolve unit with id "${e}"!`);t=new Iut(n),this._workbookSelections.set(e,t)}return t}_removeWorkbookSelection(e){this._workbookSelections.delete(e)}getCellStylesProperty(e){let t=this._instanceSrv.getCurrentUnitOfType(M.UNIVER_SHEET)?.getActiveSheet(),n=this.getCurrentSelections();if(!t||n.length===0)return{isAllValuesSame:!1,value:null};let r=null;for(let i=0;i<n.length;i++){let{startRow:a,endRow:o,startColumn:s,endColumn:c}=n[i].range;for(let n=a;n<=o;n++)for(let i=s;i<=c;i++){let a=`${n}_${i}`,o;this._cellStylesCache.has(a)?o=this._cellStylesCache.get(a):(o=t.getComposedCellStyle(n,i),this._cellStylesCache.set(a,o));let s=o[e];if(r!=null&&!F.diffValue(r,s))return{isAllValuesSame:!1,value:null};r=s}}return{isAllValuesSame:!0,value:r}}};WK=AG([kG(0,z)],WK);var GK=`SELECTIONS_ENABLED`,KK=`REF_SELECTIONS_ENABLED`,qK=class extends P{constructor(e,t){super(),this._injector=e,this._univerInstanceService=t,Z(this,`_sceneMap`,new Map),Z(this,`_sheetSkeletonParamStore`,new Map),Z(this,`_buildSkeleton$`,new ao),Z(this,`buildSkeleton$`,this._buildSkeleton$.asObservable()),this._init()}dispose(){super.dispose(),this._sheetSkeletonParamStore.forEach(e=>e.forEach(e=>e.skeleton.dispose())),this._sheetSkeletonParamStore.clear()}_disposeByUnitId(e){let t=this._sheetSkeletonParamStore.get(e);t&&(t.forEach(e=>e.skeleton.dispose()),this._sheetSkeletonParamStore.delete(e))}_init(){this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(M.UNIVER_SHEET).subscribe(e=>this._initWorkbookSkeleton(e.unit))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_SHEET).subscribe(e=>this._disposeByUnitId(e.getUnitId())))}_initWorkbookSkeleton(e){let t=e.getUnitId();this._initSheetsSkeleton(e),this.disposeWithMe(e.sheetCreated$.subscribe(n=>{let r=this._sheetSkeletonParamStore.get(t);if(!r)return;let i=n.getSheetId(),a=this._buildSkeleton(n,e.getStyles());r.set(i,{unitId:t,sheetId:i,skeleton:a,dirty:!1})})),this.disposeWithMe(e.sheetDisposed$.subscribe(e=>{let n=this._sheetSkeletonParamStore.get(t);if(!n)return;let r=e.getSheetId(),i=n.get(r);i&&i.skeleton.dispose(),n.delete(r)}))}_initSheetsSkeleton(e){let t=e.getUnitId(),n=new Map;e.getWorksheets().forEach(r=>{let i=r.getSheetId(),a=this._buildSkeleton(r,e.getStyles());n.set(i,{unitId:t,sheetId:i,skeleton:a,dirty:!1})}),this._sheetSkeletonParamStore.set(t,n)}_buildSkeleton(e,t){let n=this._injector.createInstance(CE,e,t),r=e.getUnitId(),i=this._sceneMap.get(r);return i&&n.setScene(i),this._buildSkeleton$.next(n),n}setScene(e,t){this._sceneMap.set(e,t);let n=this._sheetSkeletonParamStore.get(e);n&&n.forEach(e=>e.skeleton.setScene(t))}getSkeletonsByUnitId(e){let t=this._sheetSkeletonParamStore.get(e);return t?Array.from(t.values()).map(e=>e.skeleton):[]}getSkeleton(e,t){return this.getSkeletonParam(e,t)?.skeleton}getSkeletonParam(e,t){let n=this._sheetSkeletonParamStore.get(e);if(n)return n.get(t)}newSkeleton(e,t,n,r){return this.newSkeletonParam(e,t,n,r).skeleton}newSkeletonParam(e,t,n,r){let i=this._buildSkeleton(n,r),a=this._sheetSkeletonParamStore.get(e);a||(a=new Map,this._sheetSkeletonParamStore.set(e,a));let o={unitId:e,sheetId:t,skeleton:i,dirty:!1};return a.set(t,o),o}ensureSkeleton(e,t){let n=this.getSkeleton(e,t);if(n)return n;let r=this._univerInstanceService.getUnit(e);if(!r)return;let i=r.getSheetBySheetId(t);if(i)return this.newSkeleton(e,t,i,r.getStyles())}};qK=AG([kG(0,j(We)),kG(1,j(z))],qK);function JK(e,t){let n=new Rh;return e.map(e=>t_.transformRange(e,t)).forEach(e=>{t_.foreach(e,(e,r)=>{let i=t.getCellHeight(e,r);i&&n.setValue(e,r,i)})}),n}var Lut=1e4;function YK(e,t){if(!t)return{suitableRanges:e,remainingRanges:[]};let n=t.worksheet.getColumnCount(),r=Math.ceil(Lut/n),i=[],a=[],o=t.getOffsetRelativeToRowCol(0,t.scrollY).row,s=e.map(e=>{let t;return t=o>=e.startRow&&o<=e.endRow?0:o<e.startRow?e.startRow-o:o-e.endRow,{range:e,distance:t,rowCount:e.endRow-e.startRow+1}});s.sort((e,t)=>e.distance===t.distance?e.rowCount-t.rowCount:e.distance-t.distance);let c=0;for(let e of s)if(c+e.rowCount<=r)i.push(e.range),c+=e.rowCount;else{let t=r-c;if(t>0){let n={...e.range,endRow:e.range.startRow+t-1},o={...e.range,startRow:e.range.startRow+t};i.push(n),a.push(o),c=r}else a.push(e.range)}return{suitableRanges:i,remainingRanges:a}}function Rut(e){let t=0;return e.forEach(()=>{t++}),t}var XK={id:`sheet.command.clear-selection-all`,type:L.COMMAND,handler:(e,t)=>{let n=SG(e.get(z),{unitId:t?.unitId,subUnitId:t?.subUnitId});if(!n)return!1;let r=e.get(WK),{unitId:i,subUnitId:a}=n,o=t?.ranges||r.getCurrentSelections()?.map(e=>e.range);if(!o?.length)return!1;let s=e.get(qK).getSkeleton(i,a);if(!s)return!1;let c=e.get(R),l=e.get(vx),u=e.get(PG),d=[],f=[],p={subUnitId:a,unitId:i,cellValue:jut(IK(o,e,i,a))},m=cK(e,p);d.push({id:lK.id,params:p}),f.push({id:lK.id,params:m});let h=u.onCommandExecute({id:XK.id,params:t});d.push(...h.redos),f.unshift(...h.undos);let g=Km(d,c),{suitableRanges:_,remainingRanges:v}=YK(o,s),{undos:y,redos:b}=u.generateMutationsOfAutoHeight({unitId:i,subUnitId:a,ranges:_,autoHeightRanges:_,lazyAutoHeightRanges:v}),x=Km(b,c);return g.result&&x.result?(d.push(...b),f.push(...y),l.pushUndoRedo({unitID:i,undoMutations:f,redoMutations:d}),!0):!1}},ZK={id:`sheet.command.clear-selection-format`,type:L.COMMAND,handler:(e,t)=>{let n=SG(e.get(z),{unitId:t?.unitId,subUnitId:t?.subUnitId});if(!n)return!1;let r=e.get(WK),{unitId:i,subUnitId:a}=n,o=t?.ranges||r.getCurrentSelections()?.map(e=>e.range);if(!o?.length)return!1;let s=e.get(qK).getSkeleton(i,a);if(!s)return!1;let c=e.get(R),l=e.get(vx),u=e.get(PG),d=[],f=[],p={subUnitId:a,unitId:i,cellValue:Nut(IK(o,e,i,a))},m=cK(e,p);d.push({id:lK.id,params:p}),f.push({id:lK.id,params:m});let h=u.onCommandExecute({id:ZK.id,params:t});d.push(...h.redos),f.unshift(...h.undos);let g=Km(d,c),{suitableRanges:_,remainingRanges:v}=YK(o,s),{undos:y,redos:b}=u.generateMutationsOfAutoHeight({unitId:i,subUnitId:a,ranges:_,autoHeightRanges:_,lazyAutoHeightRanges:v}),x=Km(b,c);return g.result&&x.result?(d.push(...b),f.push(...y),l.pushUndoRedo({unitID:i,undoMutations:f,redoMutations:d}),!0):!1}};function QK(e,t,n=!0){let r=t.getMatrixWithMergedCells(...lee(e)),i=[];if(r.forValue((t,n,r)=>{if(r.colSpan!==void 0&&r.rowSpan!==void 0){let a={startRow:t,startColumn:n,endRow:t+r.rowSpan-1,endColumn:n+r.colSpan-1};d_.contains(e,a)||i.push(a)}}),i.length===0)return e;let a=d_.union(e,...i);return n?QK(a,t,n):a}function $K(e,t,n){let r=null;return n.getMatrixWithMergedCells(e,t,e,t).forValue((e,t,n)=>(r={actualRow:e,actualColumn:t,startRow:e,startColumn:t,isMerged:n.rowSpan!==void 0||n.colSpan!==void 0,isMergedMainCell:n.rowSpan!==void 0&&n.colSpan!==void 0,endRow:e+(n.rowSpan===void 0?0:n.rowSpan-1),endColumn:t+(n.colSpan===void 0?0:n.colSpan-1),rangeType:vh.NORMAL},!1)),r||{actualColumn:t,actualRow:e,startRow:e,startColumn:t,endRow:e,endColumn:t,isMerged:!1,isMergedMainCell:!1,rangeType:vh.NORMAL}}function zut(e,t,n){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e;return Number.isNaN(r)&&(e.startRow=0),Number.isNaN(a)&&(e.endRow=t-1),Number.isNaN(i)&&(e.startColumn=0),Number.isNaN(o)&&(e.endColumn=n-1),e}function eq(e,t){let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.startColumn)?0:e.startColumn,i=t.getMergedCell(n,r);return i?{...i,actualRow:n,actualColumn:r,rangeType:vh.NORMAL,isMerged:!0,isMergedMainCell:!0}:{startRow:n,startColumn:r,endRow:e.startRow,endColumn:e.startColumn,actualRow:n,actualColumn:r,rangeType:vh.NORMAL,isMerged:!1,isMergedMainCell:!1}}var tq=(e,t,n)=>({id:oq.id,params:{unitId:t.getUnitId(),subUnitId:n.getSheetId(),reveal:!0,selections:[{range:e,primary:eq(e,n)}]}});function But(e){if(!e)return!1;let{range:t,primary:n}=e;return d_.equals(t,n)}function Vut(e){function t(t,n){function r(t){for(let r=t.startRow;r<=t.endRow;r++)if(!e.getRowFiltered(r))for(let e=t.startColumn;e<=t.endColumn;e++)n(r,e,t)}r(t)}return{forOperableEach:t}}var Hut=e=>e.id!==Zct;function nq(e,t,n,r,i,a,o){let s={};for(let c=t;c<=n;c++)for(let t=r;t<=i;t++){let n=a?e.getCellWithFilteredInterceptors(o,t,Qct,Hut):e.getCellWithFilteredInterceptors(c,o,Qct,Hut);n&&n.s&&(s[c]||(s[c]={}),s[c][t]={s:n.s})}for(let e in s){for(let t in s[e]){let n=s[e][t];n.s&&typeof n.s==`object`&&F.isEmptyObject(n.s)&&delete n.s,F.isEmptyObject(n)&&delete s[e][t]}F.isEmptyObject(s[e])&&delete s[e]}return s}var rq=ce(`sheets-formula.ref-selections.service`),iq=class extends WK{constructor(e){super(e)}_init(){let e=this._getAliveWorkbooks$().pipe(cc(this.dispose$));this.selectionMoveStart$=e.pipe(sc(e=>Ps(...e.map(e=>e.selectionMoveStart$)))),this.selectionMoving$=e.pipe(sc(e=>Ps(...e.map(e=>e.selectionMoving$)))),this.selectionMoveEnd$=e.pipe(sc(e=>Ps(...e.map(e=>e.selectionMoveEnd$)))),this.selectionSet$=e.pipe(sc(e=>Ps(...e.map(e=>e.selectionSet$))))}dispose(){super.dispose(),this.selectionMoveStart$=ts(null),this.selectionMoving$=ts(null),this.selectionMoveEnd$=ts(null),this.selectionSet$=ts(null),delete this._instanceSrv,this._workbookSelections.clear()}_getAliveWorkbooks$(){let e=this._instanceSrv.getAllUnitsForType(M.UNIVER_SHEET);e.forEach(e=>this._ensureWorkbookSelection(e.getUnitId()));let t=new so(e);return this.disposeWithMe(this._instanceSrv.getTypeOfUnitAdded$(M.UNIVER_SHEET).subscribe(e=>{let{unit:n}=e;this._ensureWorkbookSelection(n.getUnitId()),t.next([...t.getValue(),n])})),this.disposeWithMe(this._instanceSrv.getTypeOfUnitDisposed$(M.UNIVER_SHEET).subscribe(e=>{this._removeWorkbookSelection(e.getUnitId()),t.next(t.getValue().filter(t=>t!==e))})),t.pipe(os(e=>e.map(e=>this._ensureWorkbookSelection(e.getUnitId()))))}};iq=AG([kG(0,z)],iq);function aq(e,t){let n=e.get(Fm).getContextValue(KK);return e.get(n&&!t?rq:WK)}var oq={id:`sheet.operation.set-selections`,type:L.OPERATION,handler:(e,t)=>{if(!t)return!1;let{selections:n,type:r,unitId:i,subUnitId:a}=t;return aq(e).setSelections(i,a,[...n],r),!0}},Uut={id:`sheet.command.select-range`,type:L.COMMAND,handler:(e,t)=>{if(!t)return!1;let{unitId:n,subUnit:r,range:i}=t,a=e.get(R),o=SG(e.get(z),t);if(!o)return!1;let s=[{range:i,primary:eq(i,o.worksheet),style:null}];return a.syncExecuteCommand(oq.id,{unitId:n,subUnitId:r,selections:s})}},Wut=`sheet.command.move-range`,sq={type:L.COMMAND,id:Wut,handler:async(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(sb),a=e.get(nx);if(!await e.get(PG).beforeCommandExecute({id:sq.id,params:t}))return!1;let o=Kut(e,t);return o?Km(o.redos,n).result?(r.pushUndoRedo({unitID:o.unitId,undoMutations:o.undos,redoMutations:o.redos}),!0):!1:(i.emit(a.t(`sheets.info.acrossMergedCell`)),!1)}};function Gut(e,t){let n=e.get(z),r=SG(n),i=t.toUnitId??t.fromUnitId??r?.unitId,a=t.fromSubUnitId??r?.subUnitId,o=t.toSubUnitId??t.fromSubUnitId??r?.subUnitId;if(!i||!a||!o||t.fromUnitId&&t.toUnitId&&t.fromUnitId!==t.toUnitId)return null;let s=n.getUniverSheetInstance(i),c=s?.getSheetBySheetId(a),l=s?.getSheetBySheetId(o);return!c||!l?null:{unitId:i,fromSubUnitId:a,toSubUnitId:o,fromWorksheet:c,toWorksheet:l}}function Kut(e,t,n={}){let{includeSelection:r=!0,includeAfterCommand:i=!0,includeAutoHeight:a=!0}=n,o=Gut(e,t);if(!o)return null;let s=e.get(PG),{unitId:c,fromSubUnitId:l,toSubUnitId:u,fromWorksheet:d,toWorksheet:f}=o,p=cq(e,{unitId:c,subUnitId:l,range:t.fromRange},{unitId:c,subUnitId:u,range:t.toRange});if(p===null)return null;let m={id:sq.id,params:t},h=s.onCommandExecute(m),g=[...h.preRedos??[],...p.redos,...h.redos],_=[...h.preUndos??[],...p.undos,...h.undos];if(r&&(g.push({id:oq.id,params:{unitId:c,subUnitId:u,selections:[{range:t.toRange,primary:qut(t.fromRange,t.toRange,d,f)}],type:2}}),_.push({id:oq.id,params:{unitId:c,subUnitId:l,selections:[{range:t.fromRange,primary:eq(t.fromRange,d)}],type:2}})),i){let e=s.afterCommandExecute(m);g.push(...e.redos),_.push(...e.undos)}if(a){let{undos:e,redos:n}=s.generateMutationsOfAutoHeight({unitId:c,subUnitId:u,ranges:l===u?[t.fromRange,t.toRange]:[t.toRange]});g.push(...n),_.push(...e)}return{unitId:c,redos:g,undos:_}}function cq(e,t,n,r=!1){let i=t.unitId,a=e.get(z).getUnit(i,M.UNIVER_SHEET);if(!a)return null;let{subUnitId:o,range:s}=t,{subUnitId:c,range:l}=n,u=a.getSheetBySheetId(o),d=a.getSheetBySheetId(c);if(!u||!d)return null;let f=QK(l,d,!1);if(!d_.equals(l,f)&&!r)return null;let p=u.getCellMatrix(),m=d.getCellMatrix(),h=new Rh,g=new Rh,_=new Rh,v=new Rh;t_.foreach(s,(e,t)=>{let n=F.deepClone(p.getValue(e,t))??null;n?.s&&(n.s=a.getStyles().get(n.s)),h.setValue(e,t,null),g.setValue(e,t,n);let r=Yh(e,t),i=d_.getRelativeRange(r,s),o=d_.getPositionRange(i,l);_.setValue(o.startRow,o.startColumn,F.deepClone(n))}),t_.foreach(l,(e,t)=>{let n=F.deepClone(m.getValue(e,t))??null;v.setValue(e,t,n)});let y={fromRange:t.range,toRange:n.range,from:{value:h.getMatrix(),subUnitId:o},to:{value:_.getMatrix(),subUnitId:c},unitId:i},b={fromRange:n.range,toRange:t.range,from:{value:v.getMatrix(),subUnitId:c},to:{value:g.getMatrix(),subUnitId:o},unitId:i};return{redos:[{id:GG.id,params:y}],undos:[{id:GG.id,params:b}]}}function qut(e,t,n,r=n){let i=e.startRow,a=e.startColumn,o=n.getMergedCell(i,a),s=eq(t,r);if(o){let e=o.endRow-o.startRow+1,t=o.endColumn-o.startColumn+1;s.endRow=s.startRow+e-1,s.endColumn=s.startColumn+t-1,s.actualRow=s.startRow,s.actualColumn=s.startColumn,s.isMerged=!1,s.isMergedMainCell=!0}return s}var lq={id:`sheet.command.set-range-values`,type:L.COMMAND,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let r=e.get(WK).getCurrentSelections()?.map(e=>e.range),{value:i,range:a,redoUndoId:o}=t,s=a?[a]:r;if(!s||!s.length)return!1;let c=e.get(R),l=e.get(vx),u=e.get(PG),{subUnitId:d,unitId:f,workbook:p,worksheet:m}=n,h=new Rh,g;if(F.isArray(i))for(let e=0;e<s.length;e++){let{startRow:t,startColumn:n,endRow:r,endColumn:a}=s[e];for(let e=t;e<=r;e++)for(let r=n;r<=a;r++)h.setValue(e,r,i[e-t][r-n])}else if(gh(i))for(let e=0;e<s.length;e++){let{startRow:t,startColumn:n,endRow:r,endColumn:a}=s[e];for(let e=t;e<=r;e++)for(let t=n;t<=a;t++)h.setValue(e,t,i)}else g=i,s=g?[new Rh(g).getStartEndScope()]:[];let _={unitId:f,subUnitId:d,cellValue:g??h.getMatrix()},v=cK(e,_),y=Ah(_.cellValue,(e,t)=>m.getCellHeight(e,t)||void 0);if(!c.syncExecuteCommand(lK.id,_))return!1;let{undos:b,redos:x}=u.onCommandExecute({id:lq.id,params:_}),{undos:S,redos:C}=u.generateMutationsOfAutoHeight({unitId:f,subUnitId:d,ranges:s,cellHeights:new Rh(y)});if(Km([...x,...C],c).result){let e=[{id:lK.id,params:_},...x,...C,tq(s[s.length-1],p,m)],t=[{id:lK.id,params:v},...b,...S];return r&&r.length&&t.push(tq(r[r.length-1],p,m)),l.pushUndoRedo({unitID:f,undoMutations:t,redoMutations:e,id:o}),!0}return!1}};function Jut(e,t){let n=[],r=[],{unitId:i,subUnitId:a,range:o,shiftDimension:s,cellValue:c={}}=t,l=e.get(z),u=e.get(PG),d=l.getUniverSheetInstance(i)?.getSheetBySheetId(a);if(d){let t=d.getCellMatrix(),l=t.getDataRange();if(o.startColumn<=l.endColumn||o.startRow<=l.endRow){let c,u;if(s===_p.COLUMNS){let e=Math.min(o.endRow,l.endRow),n=0;for(let r=o.startRow;r<=e;r++){let e=t.getRow(r),i=e?jh(e)-1:0;n=Math.max(n,i)}c={startRow:o.startRow,startColumn:o.startColumn,endRow:e,endColumn:n};let r=o.endColumn-o.startColumn+1;u={startRow:o.startRow,startColumn:c.startColumn+r,endRow:e,endColumn:c.endColumn+r}}else{let e=Math.min(o.endColumn,l.endColumn),t=l.endRow;c={startRow:o.startRow,startColumn:o.startColumn,endRow:t,endColumn:e};let n=o.endRow-o.startRow+1;u={startRow:c.startRow+n,startColumn:o.startColumn,endRow:c.endRow+n,endColumn:e}}let d=cq(e,{unitId:i,subUnitId:a,range:c},{unitId:i,subUnitId:a,range:u},!0);d&&(n.push(...d.redos),r.push(...d.undos))}if(Object.entries(c).length===0)for(let e=o.startRow;e<=o.endRow;e++){c[e]||(c[e]={});for(let t=o.startColumn;t<=o.endColumn;t++)c[e][t]=null}let f={subUnitId:a,unitId:i,cellValue:c},p=cK(e,f),{undos:m,redos:h}=u.onCommandExecute({id:lq.id,params:{...f,range:o}});n.push({id:lK.id,params:f},...h),r.push({id:lK.id,params:p},...m)}return{redo:n,undo:r}}function Yut(e,t){let n=[],r=[],{unitId:i,subUnitId:a,range:o,shiftDimension:s}=t,c=e.get(z),l=e.get(PG),u=c.getUniverSheetInstance(i)?.getSheetBySheetId(a);if(u){let t=u.getCellMatrix(),c=t.getDataRange(),d={subUnitId:a,unitId:i,cellValue:jut([o])},f=cK(e,d),p=l.onCommandExecute({id:lq.id,params:d});if(n.push({id:lK.id,params:d},...p.redos),r.push(...p.undos,{id:lK.id,params:f}),o.startColumn<=c.endColumn||o.startRow<=c.endRow){let l=null,u=null;if(s===_p.COLUMNS&&o.endColumn<c.endColumn){let e=Math.min(o.endRow,c.endRow),n=0;for(let r=o.startRow;r<=e;r++){let e=t.getRow(r),i=e?jh(e)-1:0;n=Math.max(n,i)}l={startRow:o.startRow,startColumn:o.endColumn+1,endRow:e,endColumn:n};let r=o.endColumn-o.startColumn+1;u={startRow:o.startRow,startColumn:l.startColumn-r,endRow:e,endColumn:l.endColumn-r}}if(s===_p.ROWS&&o.endRow<c.endRow){let e=Math.min(o.endColumn,c.endColumn),t=c.endRow;l={startRow:o.endRow+1,startColumn:o.startColumn,endRow:t,endColumn:e};let n=o.endRow-o.startRow+1;u={startRow:l.startRow-n,startColumn:o.startColumn,endRow:l.endRow-n,endColumn:e}}if(l&&u){let t=cq(e,{unitId:i,subUnitId:a,range:l},{unitId:i,subUnitId:a,range:u},!0);t&&(n.push(...t.redos),r.push(...t.undos))}}}return{redo:n,undo:r}}var Xut=`sheet.command.delete-range-move-left`,uq={type:L.COMMAND,id:Xut,handler:async(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(WK),o=e.get(PG),s=SG(i);if(!s)return!1;let{worksheet:c,workbook:l,subUnitId:u,unitId:d}=s,f=t?.range;if(f||=a.getCurrentLastSelection()?.range,!f)return!1;let p={range:f,subUnitId:u,unitId:d,shiftDimension:_p.COLUMNS},m=o.onCommandExecute({id:uq.id,params:{range:f}}),{redo:h,undo:g}=Yut(e,p),_=[...m.preRedos??[],...h],v=[...m.undos,...g];if(_.push(...m.redos),_.push(tq(f,l,c)),v.push(...m.preUndos??[]),Km(_,n).result){let e=o.afterCommandExecute({id:uq.id,params:{range:f}});return Km(e.redos,n),v.push(...e.undos),_.push(...e.redos),r.pushUndoRedo({unitID:d,undoMutations:v.reverse(),redoMutations:_}),!0}return!1}},Zut=`sheet.command.delete-range-move-up`,dq={type:L.COMMAND,id:Zut,handler:async(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(WK),o=e.get(PG),s=SG(i);if(!s)return!1;let{unitId:c,subUnitId:l,workbook:u,worksheet:d}=s,f=t?.range;if(f||=a.getCurrentLastSelection()?.range,!f)return!1;let p={range:f,subUnitId:l,unitId:c,shiftDimension:_p.ROWS},m=o.onCommandExecute({id:dq.id,params:{range:f}}),{redo:h,undo:g}=Yut(e,p),_=[...m.preRedos??[],...h],v=[...m.undos,...g];if(_.push(...m.redos),_.push(tq(f,u,d)),v.push(...m.preUndos??[]),Km(_,n).result){let e=o.afterCommandExecute({id:dq.id,params:{range:f}});return Km(e.redos,n),v.push(...e.undos),_.push(...e.redos),r.pushUndoRedo({unitID:c,undoMutations:v.reverse(),redoMutations:_}),!0}return!1}},Qut=`sheet.command.insert-range-move-down`,fq={type:L.COMMAND,id:Qut,handler:async(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(WK),o=e.get(PG),s=e.get(sb),c=e.get(nx);if(a.isOverlapping())return s.emit(c.t(`sheets.info.overlappingSelections`)),!1;let l=SG(i);if(!l)return!1;let{unitId:u,subUnitId:d,worksheet:f,workbook:p}=l,m=t?.range;if(m||=a.getCurrentLastSelection()?.range,!m)return!1;let h=[],g=[],_=f.getCellMatrix(),v=_.getDataRange(),y=_.getSlice(v.startRow,v.endRow,m.startColumn,m.endColumn).getDataRange().endRow,b=Math.max(y+(m.endRow-m.startRow+1)-v.endRow,0);if(b>0){let t=m.startRow-1,n=f.getRowHeight(t),r={unitId:u,subUnitId:d,range:{startRow:v.endRow+1,endRow:v.endRow+b,startColumn:v.startColumn,endColumn:v.endColumn},rowInfo:Array(b).fill(void 0).map(()=>({h:n,hd:Np.FALSE}))};h.push({id:HG.id,params:r});let i=VG(e,r);g.push({id:JG.id,params:i})}let x={};t_.foreach(m,(e,t)=>{let n=f.getCell(e,t);n&&(x[e]||(x[e]={}),x[e][t]={s:n.s})});let{redo:S,undo:C}=Jut(e,{range:m,subUnitId:d,unitId:u,shiftDimension:_p.ROWS,cellValue:x});h.push(...S),g.push(...C);let w=o.onCommandExecute({id:fq.id,params:{range:m}});if(h.push(...w.redos),h.push(tq(m,p,f)),g.push(...w.preUndos??[]),h.unshift(...w.preRedos??[]),g.unshift(...w.undos),Km(h,n).result){let e=o.afterCommandExecute({id:fq.id,params:{range:m}});return Km(e.redos,n),g.push(...e.undos),h.push(...e.redos),r.pushUndoRedo({unitID:u,undoMutations:g.reverse(),redoMutations:h}),!0}return!1}},$ut=`sheet.command.insert-range-move-right`,pq={type:L.COMMAND,id:$ut,handler:async(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(WK),o=e.get(PG),s=e.get(sb),c=e.get(nx);if(a.isOverlapping())return s.emit(c.t(`sheets.info.overlappingSelections`)),!1;let l=SG(i);if(!l)return!1;let{workbook:u,worksheet:d,unitId:f,subUnitId:p}=l,m=t?.range;if(m||=a.getCurrentLastSelection()?.range,!m)return!1;let h=[],g=[],_=d.getCellMatrix(),v=_.getDataRange(),y=_.getSlice(m.startRow,m.endRow,v.startColumn,v.endColumn).getDataRange().endColumn,b=Math.max(y+(m.endColumn-m.startColumn+1)-v.endColumn,0);if(b>0){let t=m.startColumn-1,n=d.getColumnWidth(t),r={unitId:f,subUnitId:p,range:{startRow:v.startRow+1,endRow:v.endRow,startColumn:v.endColumn+1,endColumn:v.endColumn+b},colInfo:Array(b).fill(void 0).map(()=>({w:n,hd:Np.FALSE}))};h.push({id:WG.id,params:r});let i=UG(e,r);g.push({id:YG.id,params:i})}let x={};t_.foreach(m,(e,t)=>{let n=d.getCell(e,t);n&&n.s&&(x[e]||(x[e]={}),x[e][t]={s:n.s})});let{redo:S,undo:C}=Jut(e,{range:m,subUnitId:p,unitId:f,shiftDimension:_p.COLUMNS,cellValue:x});h.push(...S),g.push(...C);let w=o.onCommandExecute({id:pq.id,params:{range:m}});if(h.push(...w.redos),h.push(tq(m,u,d)),g.push(...w.preUndos??[]),h.unshift(...w.preRedos??[]),g.unshift(...w.undos),Km(h,n).result){let e=o.afterCommandExecute({id:pq.id,params:{range:m}});return Km(e.redos,n),g.push(...e.undos),h.push(...e.redos),r.pushUndoRedo({unitID:f,undoMutations:g.reverse(),redoMutations:h}),!0}return!1}},edt=`sheet.command.insert-row`,mq={type:L.COMMAND,id:edt,handler:async(e,t)=>{let n=e.get(R),r=e.get(PG),{range:i,direction:a,unitId:o,subUnitId:s,cellValue:c}=t;return await r.beforeCommandExecute({id:mq.id,params:t})?n.syncExecuteCommand(hq.id,{range:i,direction:a,unitId:o,subUnitId:s,cellValue:c}):!1}},hq={type:L.COMMAND,id:`sheet.command.insert-row-by-range`,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)throw Error(`Workbook or Worksheet not found at InsertRowByRangeCommand`);let{workbook:r,worksheet:i,unitId:a,subUnitId:o}=n,{range:s,direction:c,cellValue:l}=t,{startRow:u,endRow:d}=s;s.rangeType=vh.ROW;let f=c===I.UP?u:u-1;if(f<0||f>i.getRowCount()-1)throw Error(`Anchor row is out of bounds in InsertRowByRangeCommand`);let p=e.get(R),m=e.get(vx),h=e.get(PG),g={unitId:a,subUnitId:o,range:s},_=i.getRowHeight(f);_!==i.getConfig().defaultRowHeight&&(g.rowInfo=Array(d-u+1).fill(void 0).map(()=>({h:_,hd:Np.FALSE})));let v=VG(e,g),y=[{id:HG.id,params:g}],b=[{id:JG.id,params:v}];l&&Object.keys(l).length>0&&y.push({id:lK.id,params:{unitId:a,subUnitId:o,cellValue:l}});let x=h.onCommandExecute({id:mq.id,params:t});if(y.unshift(...x.preRedos??[]),y.push(...x.redos??[]),y.push(tq(s,r,i)),b.unshift(...x.preUndos??[]),b.push(...x.undos??[]),Km(y,p).result){let e=h.afterCommandExecute({id:mq.id,params:t});return Km(e.redos,p),y.push(...e.redos),b.push(...e.undos),m.pushUndoRedo({unitID:t.unitId,undoMutations:b,redoMutations:y}),!0}return!1}},gq={type:L.COMMAND,id:`sheet.command.insert-row-before`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections()?.map(e=>e.range),r;if(n?.length===1)r=n[0];else return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,subUnitId:o,unitId:s}=i,c=t.value||0,l=r.startRow,u=r.startRow+c-1,d=a.getColumnCount()-1,f={unitId:s,subUnitId:o,direction:I.UP,range:{startRow:l,endRow:u,startColumn:0,endColumn:d},cellValue:nq(a,l,u,0,d,!0,l-1)};return e.get(R).executeCommand(mq.id,f)}},tdt={type:L.COMMAND,id:`sheet.command.insert-row-after`,handler:async e=>{let t=e.get(WK).getCurrentSelections()?.map(e=>e.range),n;if(t?.length===1)n=t[0];else return!1;let r=SG(e.get(z));if(!r)return!1;let{worksheet:i,unitId:a,subUnitId:o}=r,s=n.endRow-n.startRow+1,c=n.endRow+1,l=n.endRow+s,u=i.getColumnCount()-1,d={unitId:a,subUnitId:o,direction:I.DOWN,range:{startRow:c,endRow:l,startColumn:0,endColumn:u,rangeType:vh.ROW},cellValue:nq(i,c,l,0,u,!0,n.endRow)};return e.get(R).executeCommand(mq.id,d)}},_q={type:L.COMMAND,id:`sheet.command.insert-multi-rows-above`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections()?.map(e=>e.range),r;if(n?.length===1)r=n[0];else return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,unitId:o,subUnitId:s}=i,c=t.value||0,l=r.startRow,u=r.startRow+c-1,d=a.getColumnCount()-1,f=nq(a,l,u,0,d,!0,l-1),p={unitId:o,subUnitId:s,direction:I.UP,range:{startRow:l,endRow:u,startColumn:0,endColumn:d,rangeType:vh.ROW},cellValue:f};return e.get(R).executeCommand(mq.id,p)}},vq={type:L.COMMAND,id:`sheet.command.insert-multi-rows-after`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections()?.map(e=>e.range),r;if(n?.length===1)r=n[0];else return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,unitId:o,subUnitId:s}=i,c=t.value||0,l=r.endRow+1,u=r.endRow+c,d=a.getColumnCount()-1,f={unitId:o,subUnitId:s,direction:I.DOWN,range:{startRow:l,endRow:u,startColumn:0,endColumn:d,rangeType:vh.ROW},cellValue:nq(a,l,u,0,d,!0,r.endRow)};return e.get(R).executeCommand(mq.id,f)}},ndt=`sheet.command.insert-col`,yq={type:L.COMMAND,id:ndt,handler:async(e,t)=>{let n=e.get(R),r=e.get(PG),{range:i,direction:a,subUnitId:o,unitId:s,cellValue:c}=t;return await r.beforeCommandExecute({id:yq.id,params:t})?n.syncExecuteCommand(bq.id,{range:i,direction:a,unitId:s,subUnitId:o,cellValue:c}):!1}},bq={type:L.COMMAND,id:`sheet.command.insert-col-by-range`,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)throw Error(`Workbook or Worksheet not found at InsertColByRangeCommand`);let{workbook:r,worksheet:i,unitId:a,subUnitId:o}=n,{range:s,direction:c,cellValue:l}=t,{startColumn:u,endColumn:d}=s;s.rangeType=vh.COLUMN;let f=c===I.LEFT?u:u-1;if(f<0||f>i.getColumnCount()-1)throw Error(`Anchor column is out of bounds in InsertColByRangeCommand`);let p=e.get(R),m=e.get(vx),h=e.get(PG),g={unitId:a,subUnitId:o,range:s},_=i.getColumnWidth(f);_!==i.getConfig().defaultColumnWidth&&(g.colInfo=Array(d-u+1).fill(void 0).map(()=>({w:_,hd:Np.FALSE})));let v=UG(e,g),y=[{id:WG.id,params:g}],b=[{id:YG.id,params:v}];l&&Object.keys(l).length>0&&y.push({id:lK.id,params:{unitId:a,subUnitId:o,cellValue:l}});let x=h.onCommandExecute({id:yq.id,params:t});if(y.unshift(...x.preRedos??[]),y.push(...x.redos??[]),y.push(tq(s,r,i)),b.unshift(...x.preUndos??[]),b.push(...x.undos??[]),Km(y,p).result){let e=h.afterCommandExecute({id:yq.id,params:t});return Km(e.redos,p),y.push(...e.redos),b.push(...e.undos),m.pushUndoRedo({unitID:t.unitId,undoMutations:b.filter(Boolean),redoMutations:y.filter(Boolean)}),!0}return!1}},xq={type:L.COMMAND,id:`sheet.command.insert-col-before`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections(),r;if(n?.length===1)r=n[0].range;else return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,unitId:o,subUnitId:s}=i,c=t.value||0,l=r.startColumn,u=r.startColumn+c-1,d=a.getRowCount()-1,f={unitId:o,subUnitId:s,direction:I.LEFT,range:{startColumn:l,endColumn:u,startRow:0,endRow:d,rangeType:vh.COLUMN},cellValue:nq(a,0,d,l,u,!1,l-1)};return e.get(R).executeCommand(yq.id,f)}},rdt={type:L.COMMAND,id:`sheet.command.insert-col-after`,handler:async e=>{let t=e.get(WK).getCurrentSelections(),n;if(t?.length===1)n=t[0].range;else return!1;let r=SG(e.get(z));if(!r)return!1;let{worksheet:i,unitId:a,subUnitId:o}=r,s=n.endColumn-n.startColumn+1,c=n.endColumn+1,l=n.endColumn+s,u=i.getRowCount()-1,d={unitId:a,subUnitId:o,direction:I.RIGHT,range:{startColumn:c,endColumn:l,startRow:0,endRow:u},cellValue:nq(i,0,u,c,l,!1,n.endColumn)};return e.get(R).executeCommand(yq.id,d)}},Sq={type:L.COMMAND,id:`sheet.command.insert-multi-cols-before`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections(),r;if(n?.length===1)r=n[0].range;else return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,unitId:o,subUnitId:s}=i,c=t.value||0,l=r.startColumn,u=r.startColumn+c-1,d=a.getRowCount()-1,f={unitId:o,subUnitId:s,direction:I.LEFT,range:{startColumn:l,endColumn:u,startRow:0,endRow:d,rangeType:vh.COLUMN},cellValue:nq(a,0,d,l,u,!1,l-1)};return e.get(R).executeCommand(yq.id,f)}},Cq={type:L.COMMAND,id:`sheet.command.insert-multi-cols-right`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections(),r;if(n?.length===1)r=n[0].range;else return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,unitId:o,subUnitId:s}=i,c=t.value||0,l=r.endColumn+1,u=r.endColumn+c,d=a.getRowCount()-1,f={unitId:o,subUnitId:s,direction:I.RIGHT,range:{startColumn:l,endColumn:u,startRow:0,endRow:d},cellValue:nq(a,0,d,l,u,!1,r.endColumn)};return e.get(R).executeCommand(yq.id,f)}},idt=_f((e,t,n,r)=>{if(!r.disposed){let i=tq(e,t,n);r.executeCommand(i.id,i.params)}},300),wq=`sheet.command.remove-row`,Tq={type:L.COMMAND,id:`sheet.command.remove-row-by-range`,handler:(e,t)=>{if(!t)return!1;let n=SG(e.get(z),t);if(!n)return!1;let{workbook:r,worksheet:i}=n,a=e.get(PG),{range:o,unitId:s,subUnitId:c}=t,l=IK([o],e,s,c).reverse(),u=[],d=[];l.forEach(e=>{let t=[],n=[],r={unitId:s,subUnitId:c,range:e},a=Slt(r,i),o={unitId:s,subUnitId:c,cellValue:i.getCellMatrix().getSlice(e.startRow,e.endRow,0,i.getColumnCount()-1).getMatrix()};n.push({id:JG.id,params:r}),t.push({id:HG.id,params:a}),t.push({id:lK.id,params:o}),d.push(...n),u.unshift(...t)});let f=a.onCommandExecute({id:wq,params:{range:o}}),p=e.get(R);if(Km([...f.preRedos??[],...d,...f.redos],p).result){idt(o,r,i,p);let t=a.afterCommandExecute({id:wq,params:{range:o}});return Km(t.redos,p),e.get(vx).pushUndoRedo({unitID:s,undoMutations:[...f.preUndos??[],...u,...f.undos,...t.undos],redoMutations:[...f.preRedos??[],...d,...f.redos,...t.redos]}),!0}return!1}},Eq={type:L.COMMAND,id:wq,handler:async(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let r=e.get(WK),i=t?.range||r.getCurrentLastSelection()?.range;if(!i)return!1;let a=e.get(PG),o=e.get(R),{worksheet:s,unitId:c,subUnitId:l}=n;return i={...i,startColumn:0,endColumn:Math.max(s.getMaxColumns()-1,0)},await a.beforeCommandExecute({id:Eq.id,params:{range:i}})?o.syncExecuteCommand(Tq.id,{range:i,unitId:c,subUnitId:l}):!1}},Dq=`sheet.command.remove-col`,Oq={type:L.COMMAND,id:`sheet.command.remove-col-by-range`,handler:(e,t)=>{if(!t)return!1;let n=SG(e.get(z),t);if(!n)return!1;let{workbook:r,worksheet:i}=n,a=e.get(PG),{range:o,unitId:s,subUnitId:c}=t,l={unitId:s,subUnitId:c,range:o},u=Clt(e,l),d={unitId:s,subUnitId:c,cellValue:i.getCellMatrix().getSlice(0,i.getRowCount()-1,o.startColumn,o.endColumn).getMatrix()},f=a.onCommandExecute({id:Dq,params:{range:o}}),p=e.get(R);if(Km([...f.preRedos??[],{id:YG.id,params:l},...f.redos],p).result){idt(o,r,i,p);let t=a.afterCommandExecute({id:Dq,params:{range:o}});return Km(t.redos,p),e.get(vx).pushUndoRedo({unitID:s,undoMutations:[...f.preUndos??[],{id:WG.id,params:u},{id:lK.id,params:d},...f.undos,...t.undos],redoMutations:[...f.preRedos??[],{id:YG.id,params:l},...f.redos,...t.redos]}),!0}return!1}},kq={type:L.COMMAND,id:Dq,handler:async(e,t)=>{let n=e.get(WK),r=e.get(PG),i=e.get(R),a=t?.range;if(a||=n.getCurrentLastSelection()?.range,!a)return!1;let o=SG(e.get(z));if(!o)return!1;let{worksheet:s,subUnitId:c,unitId:l}=o;return a={...a,startRow:0,endRow:Math.max(s.getMaxRows()-1,0)},await r.beforeCommandExecute({id:kq.id,params:{range:a}})?i.syncExecuteCommand(Oq.id,{range:a,unitId:l,subUnitId:c}):!1}},adt=(e,t)=>{let n=e.get(z),{subUnitId:r,unitId:i}=t,a=CG(n,t);if(!a)throw Error(`[RemoveSheetUndoMutationFactory]: Worksheet is null error!`);let{workbook:o,worksheet:s}=a,c=s.getConfig();return{index:o.getConfig().sheetOrder.findIndex(e=>e===r),sheet:c,unitId:i}},Aq={id:`sheet.mutation.remove-sheet`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z),{subUnitId:r,unitId:i}=t,a=n.getUniverSheetInstance(i);return a?a.removeSheet(r):!1}};function odt(e,t){return t.getMergeData().some(t=>t.startRow<e&&e<=t.endRow)}function sdt(e,t){return t.getMergeData().some(t=>t.startColumn<e&&e<=t.endColumn)}var cdt=`sheet.command.move-rows`,jq={id:cdt,type:L.COMMAND,handler:(e,t)=>{let n=e.get(WK),{fromRange:{startRow:r},toRange:{startRow:i},range:a}=t,o=(a?[udt(a)]:n.getCurrentSelections())?.filter(e=>e.range.rangeType===vh.ROW&&e.range.startRow<=r&&r<=e.range.endRow);if(o?.length!==1)return!1;let s=e.get(PG),c=SG(e.get(z),t);if(!c)return!1;let{workbook:l,worksheet:u}=c,d=l.getUnitId(),f=u.getSheetId(),p=e.get(sb),m=e.get(nx),h=o[0].range,g=o[0].primary,_=QK(h,u,!1);if(!d_.equals(h,_))return p.emit(m.t(`sheets.info.partOfCell`)),!1;if(odt(i,u))return p.emit(m.t(`sheets.info.acrossMergedCell`)),!1;let v={...h,startRow:i,endRow:i+h.endRow-h.startRow},y={unitId:d,subUnitId:f,sourceRange:h,targetRange:v},b=blt(e,y),x=e.get(R),S=s.onCommandExecute({id:jq.id,params:t}),C=[...S.preRedos??[],{id:KG.id,params:y}],w=[...S.preUndos??[],{id:KG.id,params:b}];if(g){let e=i-r<0,t=h.endRow-h.startRow+1,n=e?v:{...v,startRow:v.startRow-t,endRow:v.endRow-t},a={unitId:d,subUnitId:f,type:2,selections:[{range:n,primary:eq(n,u),style:null}]},o={unitId:d,subUnitId:f,type:2,selections:[{range:h,primary:g,style:null}]};C.push({id:oq.id,params:a}),w.push({id:oq.id,params:o})}if(C.push(...S.redos),w.push(...S.undos),Km(C,x).result){let n=s.afterCommandExecute({id:jq.id,params:t});return Km(n.redos,x),C.push(...n.redos),w.push(...n.undos),e.get(vx).pushUndoRedo({unitID:d,undoMutations:w,redoMutations:C}),!0}return!1}},ldt=`sheet.command.move-cols`,Mq={id:ldt,type:L.COMMAND,handler:(e,t)=>{let n=e.get(WK),{fromRange:{startColumn:r},toRange:{startColumn:i},range:a}=t,o=(a?[udt(a)]:n.getCurrentSelections())?.filter(e=>e.range.rangeType===vh.COLUMN&&e.range.startColumn<=r&&r<=e.range.endColumn);if(o?.length!==1)return!1;let s=e.get(PG),c=SG(e.get(z),t);if(!c)return!1;let{workbook:l,worksheet:u}=c,d=l.getUnitId(),f=u.getSheetId(),p=e.get(sb),m=e.get(nx),h=o[0].range,g=o[0].primary,_=QK(h,u,!1);if(!d_.equals(h,_))return p.emit(m.t(`sheets.info.partOfCell`)),!1;if(sdt(i,u))return p.emit(m.t(`sheets.info.acrossMergedCell`)),!1;let v={...h,startColumn:i,endColumn:i+h.endColumn-h.startColumn},y={unitId:d,subUnitId:f,sourceRange:h,targetRange:v},b=xlt(e,y),x=e.get(R),S=s.onCommandExecute({id:Mq.id,params:t}),C=[...S.preRedos??[],{id:qG.id,params:y}],w=[...S.preUndos??[],{id:qG.id,params:b}];if(g){let e=h.endColumn-h.startColumn+1,t=i-r<0?v:{...v,startColumn:v.startColumn-e,endColumn:v.endColumn-e},n={unitId:d,subUnitId:f,type:2,selections:[{range:t,primary:eq(t,u),style:null}]},a={unitId:d,subUnitId:f,type:2,selections:[{range:h,primary:g,style:null}]};C.push({id:oq.id,params:n}),w.push({id:oq.id,params:a})}if(C.push(...S.redos),w.push(...S.undos),Km(C,x).result){let n=s.afterCommandExecute({id:Mq.id,params:t});return Km(n.redos,x),C.push(...n.redos),w.push(...n.undos),e.get(vx).pushUndoRedo({unitID:d,undoMutations:w,redoMutations:C}),!0}return!1}};function udt(e){return{range:e,primary:null,style:null}}var ddt=`sheet.command.reorder-range`,Nq={id:ddt,type:L.COMMAND,handler:(e,t)=>{let{subUnitId:n,unitId:r,range:i,order:a}=t,o=e.get(R),s={id:QG.id,params:{unitId:r,subUnitId:n,order:a,range:i}},c={id:QG.id,params:wlt(s.params)},l=e.get(PG),u=l.onCommandExecute({id:Nq.id,params:t}),d=[...u.preRedos??[],s,...u.redos],f=[...u.preUndos??[],c,...u.undos],p=Km(d,o),{suitableRanges:m,remainingRanges:h}=YK([i],e.get(qK).getSkeleton(r,n)),{undos:g,redos:_}=l.generateMutationsOfAutoHeight({unitId:r,subUnitId:n,ranges:[i],autoHeightRanges:m,lazyAutoHeightRanges:h}),v=l.afterCommandExecute({id:Nq.id,params:t});return p.result?(Km([...v.redos,..._],o),e.get(vx).pushUndoRedo({unitID:r,undoMutations:[...f,...v.undos,...g],redoMutations:[...d,...v.redos,..._]}),!0):!1}},Pq={MoveRangeCommandId:Wut,InsertRowCommandId:edt,InsertColCommandId:ndt,RemoveColCommandId:Dq,RemoveRowCommandId:wq,DeleteRangeMoveLeftCommandId:Xut,DeleteRangeMoveUpCommandId:Zut,InsertRangeMoveDownCommandId:Qut,InsertRangeMoveRightCommandId:$ut,MoveColsCommandId:ldt,MoveRowsCommandId:cdt,ReorderRangeCommandId:ddt},Fq=e=>{let t={...e},n=Number.isNaN(t.startRow)&&Number.isNaN(t.endRow)&&!Number.isNaN(t.startColumn)&&!Number.isNaN(t.endColumn),r=Number.isNaN(t.startColumn)&&Number.isNaN(t.endColumn)&&!Number.isNaN(t.startRow)&&!Number.isNaN(t.endRow);return(t.rangeType===vh.COLUMN||n)&&(t.startRow=0,t.endRow=Qg-1),(t.rangeType===vh.ROW||r)&&(t.startColumn=0,t.endColumn=$g-1),t.rangeType===vh.ALL&&(t.startColumn=0,t.endColumn=$g-1,t.startRow=0,t.endRow=Qg-1),t},Iq=e=>{let t=e.rangeType;return e.rangeType===vh.COLUMN?t=vh.ROW:e.rangeType===vh.ROW&&(t=vh.COLUMN),{startRow:e.startColumn,endRow:e.endColumn,startColumn:e.startRow,endColumn:e.endRow,rangeType:t}},Lq=(e,t,n)=>{let r={...n},i={...t},a=(e,t)=>{let n=Math.max(e.start,t.start),r=Math.min(e.end,t.end);return r<n?null:{start:n,end:r}},o=e=>e.end-e.start+1,s=(e,t)=>({start:e.start-t.start,end:e.start-t.start+e.end-e.start}),c=(e,t)=>({start:t.start+e.start,end:t.start+e.start+e.end-e.start}),l=t.start>e.start;if(l){let n=Math.min(e.end,t.start)-e.start+1;i.start-=n,i.end-=n}let u=o(e),d=u,f=a(e,r),p=f&&o(f)>=o(r);if(e.end<r.start)r.start-=u,r.end-=u;else if(f){let t=o(f);if(p){let t=c(s(r,e),i);r.start=t.start,r.end=t.end}else f.start>e.start?l?(r.end-=t+u,r.start-=u):r.end-=t:l?r.end-=t:r.start>e.start&&r.end>e.end?(r.start-=u,r.end-=u+t):r.end-=t}let m=a(i,r);return p||(i.start<=r.start?(r.start+=d,r.end+=d):m&&(l?i.end<=r.start||i.start<=r.start&&i.end>=r.start?(r.start+=d,r.end+=d):i.start>=r.start&&i.start<=r.end&&(r.end+=d):r.start<i.start&&r.end>i.start?r.end+=d:(r.start>=i.end||r.start>=i.start&&r.start<=i.end)&&(r.end+=d,r.start+=d))),{step:r.start-n.start,length:o(r)-o(n)}},Rq=(e,t)=>{let{fromRange:n,toRange:r}=e.params||{};if(!r||!n)return[];let i=Fq(n),a=Fq(r),o=Fq(t),s=Lq({start:i.startRow,end:i.endRow},{start:a.startRow,end:a.endRow},{start:o.startRow,end:o.endRow});return s===null?[{type:1}]:[{type:3,step:s.step||0,length:s.length||0}]},fdt=(e,t)=>{let{fromRange:n,toRange:r}=e.params||{};if(!n||!r)return[t];let i=n.startRow,a=n.endRow-n.startRow+1,o=r.startRow,s=new Rh;return t_.foreach(t,(e,t)=>{s.setValue(e,t,1)}),s.moveRows(i,a,o),h_(s,e=>e===1)},pdt=(e,t)=>{let{range:n,order:r}=e.params||{};if(!n||!r)return[t];let i=new Rh;t_.foreach(t,(e,t)=>{i.setValue(e,t,1)});let a=new Rh;return t_.foreach(n,(e,t)=>{if(Object.prototype.hasOwnProperty.call(r,e)){let n=r[e],o=i.getValue(n,t)??0;a.setValue(e,t,o)}}),a.forValue((e,t,n)=>{i.setValue(e,t,n)}),h_(i,e=>e===1)},zq=(e,t)=>{let{fromRange:n,toRange:r}=e.params||{};if(!r||!n)return[];let i=Fq(n),a=Fq(r),o=Fq(t),s=Lq({start:i.startColumn,end:i.endColumn},{start:a.startColumn,end:a.endColumn},{start:o.startColumn,end:o.endColumn});return s===null?[{type:1}]:[{type:2,step:s.step||0,length:s.length||0}]},mdt=(e,t)=>{let{fromRange:n,toRange:r}=e.params||{};if(!n||!r)return[t];let i=n.startColumn,a=n.endColumn-n.startColumn+1,o=r.startColumn,s=new Rh;return t_.foreach(t,(e,t)=>{s.setValue(e,t,1)}),s.moveColumns(i,a,o),h_(s,e=>e===1)},Bq=(e,t)=>{let n=e.params?.toRange,r=e.params?.fromRange;if(!n||!r)return[];let i=[];if(d_.contains(n,t)&&i.push({type:1}),d_.contains(r,t)){i.push({type:1});let e=d_.getRelativeRange(t,r);return[{type:0,range:d_.getPositionRange(e,n)}]}return i},hdt=(e,t)=>{let n=e.params?.toRange,r=e.params?.fromRange;if(!n||!r||!d_.intersects(r,t)&&!d_.intersects(n,t))return[t];if(d_.contains(r,t)){let e=d_.getRelativeRange(t,r);return[d_.getPositionRange(e,n)]}let i=new Rh;t_.foreach(t,(e,t)=>{i.setValue(e,t,1)});let a=new Rh,o=d_.getIntersects(r,t);o&&t_.foreach(o,(e,t)=>{i.getValue(e,t)&&(i.setValue(e,t,void 0),a.setValue(e,t,1))});let s=n.startColumn-r.startColumn,c=n.startRow-r.startRow,l={startColumn:n.startColumn-s,endColumn:n.endColumn-s,startRow:n.startRow-c,endRow:n.endRow-c};return l&&t_.foreach(l,(e,t)=>{let n=e+c,r=t+s;i.setValue(n,r,a.getValue(e,t)??0)}),h_(i,e=>e===1)},Vq=(e,t)=>{let n=Fq(e),r=Fq(t),i=e=>e.endColumn-e.startColumn+1,a=e=>e.endRow-e.startRow+1;if(n.startRow<=r.startRow&&n.endRow>=r.endRow){if(r.startColumn<n.startColumn&&r.endColumn>=n.startColumn&&r.endColumn<=n.endColumn||r.startColumn<n.startColumn&&r.endColumn>=n.endColumn){let e=d_.getIntersects(r,n);if(e)return{step:0,length:-i(e)}}if(r.startColumn>=n.startColumn&&r.endColumn<=n.endColumn&&a(n)>=a(r))return null;if(r.startColumn>=n.startColumn&&r.startColumn<=n.endColumn&&r.endColumn>n.endColumn){let e=d_.getIntersects(r,n);if(e){let t=-i(e);return{step:-(i(n)-i(e)),length:t}}}if(r.startColumn>n.endColumn)return{step:-i(n),length:0}}return{step:0,length:0}},Hq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],i=Vq(n,t);if(!i)r.push({type:1});else{let{step:e,length:t}=i;r.push({type:2,step:e,length:t})}return r},Uq=(e,t,n)=>{let r=e.params?.range;if(!r)return[];let i=[];if(n&&n.length>0){let e=r.startRow;for(let t=r.startRow;t<=r.endRow;t++){if(n.includes(t)){if(t===e){e=t+1;continue}a({...r,startRow:e,endRow:t-1}),e=t+1;continue}t===r.endRow&&a({...r,startRow:e,endRow:r.endRow})}}else a(r);function a(e){let n=Vq(Iq(e),Iq(t));if(!n)i.push({type:1});else{let{step:e,length:t}=n;i.push({type:3,step:e,length:t})}}return i},gdt=(e,t)=>{let{range:n,order:r}=e.params||{};if(!n||!r)return[];if(d_.contains(n,t)&&t.endRow===t.startRow){let e=[],n=t.startRow;for(let t in r)if(r[t]===n){let r=Number(t);return e.push({type:3,step:r-n,length:0}),e}return[]}return[]},Wq=(e,t)=>{let n=Fq(e),r=Fq(t),i=e=>e.endColumn-e.startColumn+1;return n.startRow<=r.startRow&&n.endRow>=r.endRow?r.startColumn<n.startColumn&&r.endColumn>=n.startColumn&&r.endColumn<=n.endColumn||r.startColumn<n.startColumn&&r.endColumn>=n.endColumn?{step:0,length:i(n)}:r.startColumn>=n.startColumn&&r.endColumn<=n.endColumn||r.startColumn>=n.startColumn&&r.startColumn<=n.endColumn&&r.endColumn>n.endColumn||r.startColumn>=n.endColumn?{step:i(n),length:0}:{step:0,length:0}:{step:0,length:0}};function _dt(e,t,n){let r=[];if(d_.contains(t,n)&&r.push({type:1}),d_.contains(e,n)){r.push({type:1});let i=d_.getRelativeRange(n,e);return[{type:0,range:d_.getPositionRange(i,t)}]}return r}var Gq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],{step:i,length:a}=Wq(Iq(n),Iq(t));return r.push({type:3,step:i,length:a}),r},Kq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],{step:i,length:a}=Wq(n,t);return r.push({type:2,step:i,length:a}),r},qq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],{step:i,length:a}=Wq(Iq(n),Iq(t));return r.push({type:3,step:i,length:a}),r},vdt=(e,t)=>{let n=e.params?.range;if(!n)return[t];let r=n.endRow-n.startRow+1,i={...n,startRow:n.startRow,endRow:1/0},a=d_.subtract(t,i),o=d_.getIntersects(i,t);if(!o)return[t];let s=new Rh;return a.forEach(e=>{t_.foreach(e,(e,t)=>{s.setValue(e,t,1)})}),o&&t_.foreach(o,(e,t)=>{s.setValue(e+r,t,1)}),h_(s,e=>e===1)},Jq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],{step:i,length:a}=Wq(n,t);return r.push({type:2,step:i,length:a}),r},ydt=(e,t)=>{let n=e.params?.range;if(!n)return[t];let r=n.endColumn-n.startColumn+1,i={...n,startColumn:n.startColumn,endColumn:1/0},a=d_.subtract(t,i),o=d_.getIntersects(i,t);if(!o)return[t];let s=new Rh;return a.forEach(e=>{t_.foreach(e,(e,t)=>{s.setValue(e,t,1)})}),o&&t_.foreach(o,(e,t)=>{s.setValue(e,t+r,1)}),h_(s,e=>e===1)},Yq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],i=Vq(n,t);if(!i)r.push({type:1});else{let{step:e,length:t}=i;r.push({type:2,step:e,length:t})}return r},bdt=(e,t)=>{let n=e.params?.range;if(!n)return[t];let r={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:1/0},i=n.endColumn-n.startColumn+1,a=d_.getIntersects(n,t),o=d_.subtract(t,r),s=d_.getIntersects(r,t);if(!a&&!s)return[t];let c=new Rh;return s&&t_.foreach(s,(e,t)=>{c.setValue(e,t-i,1)}),a&&t_.foreach(a,(e,t)=>{c.setValue(e,t-i,0)}),o.forEach(e=>{t_.foreach(e,(e,t)=>{c.setValue(e,t,1)})}),h_(c,e=>e===1)},Xq=(e,t)=>{let n=e.params?.range;if(!n)return[];let r=[],i=Vq(Iq(n),Iq(t));if(!i)r.push({type:1});else{let{step:e,length:t}=i;r.push({type:3,step:e,length:t})}return r},xdt=(e,t)=>{let n=e.params?.range;if(!n)return[t];let r={...n,startRow:n.startRow,endRow:1/0},i=n.endRow-n.startRow+1,a=d_.getIntersects(n,t),o=d_.subtract(t,r),s=d_.getIntersects(r,t);if(!a&&!s)return[t];let c=new Rh;return s&&t_.foreach(s,(e,t)=>{c.setValue(e-i,t,1)}),a&&t_.foreach(a,(e,t)=>{c.setValue(e-i,t,0)}),o.forEach(e=>{t_.foreach(e,(e,t)=>{c.setValue(e,t,1)})}),h_(c,e=>e===1)},Sdt=(e,t)=>{let n=Lg((e.ranges??[e.range]).map(e=>[e.startRow,e.endRow])),r=t.startRow,i=t.endRow;for(let e=n.length-1;e>=0;e--){let[a,o]=n[e];if(a<=t.startRow&&o>=t.endRow)return[];if(o<r){let e=o-a+1;r-=e,i-=e}else if(!(a>i)){let e=Math.max(a,r),t=Math.min(o,i)-e+1;if(i-=t,a<=r){let t=e-r;r-=t}}}return[{...t,startRow:r,endRow:i}]},Cdt=(e,t)=>{let n=e.params,r=n.range.startRow,i=n.range.endRow-n.range.startRow+1;if(n.direction===I.UP){if(r<t.startRow)return[{...t,startRow:t.startRow+i,endRow:t.endRow+i}];if(r<=t.endRow)return[{...t,endRow:t.endRow+i}]}else if(r<=t.startRow)return[{...t,startRow:t.startRow+i,endRow:t.endRow+i}];else if(r<=t.endRow+1)return[{...t,endRow:t.endRow+i}];return[t]},wdt=(e,t)=>{let n=e.params,r=n.range.startColumn,i=n.range.endColumn-n.range.startColumn+1;if(n.direction===I.LEFT){if(r<t.startColumn)return[{...t,startColumn:t.startColumn+i,endColumn:t.endColumn+i}];if(r<=t.endColumn)return[{...t,endColumn:t.endColumn+i}]}else if(r<=t.startColumn)return[{...t,startColumn:t.startColumn+i,endColumn:t.endColumn+i}];else if(r<=t.endColumn+1)return[{...t,endColumn:t.endColumn+i}];return[t]},Zq=(e,t)=>{let n={...t};return e.forEach(e=>{switch(e.type){case 1:n=null;break;case 2:if(!n)return;n.startColumn+=e.step,n.endColumn+=e.step+(e.length||0);break;case 3:if(!n)return;n.startRow+=e.step,n.endRow+=e.step+(e.length||0);break;case 0:n=e.range}}),n&&(n.endColumn<n.startColumn||n.endRow<n.startRow)?null:n},Qq=(e,t)=>{let n=[];switch(t.id){case Pq.DeleteRangeMoveLeftCommandId:n=Yq(t,e);break;case Pq.DeleteRangeMoveUpCommandId:n=Xq(t,e);break;case Pq.InsertColCommandId:n=Kq(t,e);break;case Pq.InsertRangeMoveDownCommandId:n=qq(t,e);break;case Pq.InsertRangeMoveRightCommandId:n=Jq(t,e);break;case Pq.InsertRowCommandId:n=Gq(t,e);break;case Pq.MoveColsCommandId:n=zq(t,e);break;case Pq.MoveRangeCommandId:n=Bq(t,e);break;case Pq.MoveRowsCommandId:n=Rq(t,e);break;case Pq.RemoveColCommandId:n=Hq(t,e);break;case Pq.RemoveRowCommandId:n=Uq(t,e);break;case Pq.ReorderRangeCommandId:n=gdt(t,e)}return Zq(n,e)},Tdt=(e,t,n)=>[uq.id,dq.id].includes(t.id)||Odt(t,n).some(t=>d_.intersects(t,e))?Qq(e,t):e,$q=(e,t)=>{let n=[];switch(t.id){case Pq.DeleteRangeMoveLeftCommandId:return bdt(t,e);case Pq.DeleteRangeMoveUpCommandId:return xdt(t,e);case Pq.InsertRangeMoveDownCommandId:return vdt(t,e);case Pq.InsertRangeMoveRightCommandId:return ydt(t,e);case Pq.InsertColCommandId:return wdt(t,e);case Pq.InsertRowCommandId:return Cdt(t,e);case Pq.MoveColsCommandId:return mdt(t,e);case Pq.MoveRangeCommandId:return hdt(t,e);case Pq.MoveRowsCommandId:return fdt(t,e);case Pq.ReorderRangeCommandId:return pdt(t,e);case Pq.RemoveColCommandId:n=Hq(t,e);break;case Pq.RemoveRowCommandId:return Sdt(t.params,e)}let r=Zq(n,e);return r?[r]:[]},Edt=(e,t,n)=>[uq.id,dq.id,fq.id,`sheet.command.insert-range-move-right`].includes(t.id)||Odt(t,n).some(t=>d_.intersects(t,e))?$q(e,t):e;function Ddt(e,t){let{id:n,params:r}=t,i={length:0,step:0,type:4};switch(n){case Aq.id:i.type=1;break;case KG.id:i=Lq({start:r.sourceRange.startRow,end:r.sourceRange.endRow},{start:r.targetRange.startRow,end:r.targetRange.endRow},{start:e.startRow,end:e.endRow}),i.type=3;break;case qG.id:i=Lq({start:r.sourceRange.startColumn,end:r.sourceRange.endColumn},{start:r.targetRange.startColumn,end:r.targetRange.endColumn},{start:e.startColumn,end:e.endColumn}),i.type=2;break;case YG.id:i=Vq(r.range,e),i?i.type=2:i={step:0,length:0,type:1};break;case JG.id:i=Vq(Iq(r.range),Iq(e)),i?i.type=3:i={step:0,length:0,type:1};break;case HG.id:i=Wq(Iq(r.range),Iq(e)),i.type=3;break;case WG.id:i=Wq(r.range,e),i.type=2;break;case GG.id:i=_dt(r.fromRange||new Rh(r.from).getRange(),r.toRange||new Rh(r.to).getRange(),e)}return i?Zq(Array.isArray(i)?i:[i],e):e}function Odt(e,t){let{selectionManagerService:n}=t;switch(e.id){case Pq.MoveColsCommandId:{let t=e.params;return[t.fromRange,{...t.toRange,startColumn:t.toRange.startColumn-.5,endColumn:t.toRange.endColumn-.5}]}case Pq.MoveRowsCommandId:{let t=e.params;return[t.fromRange,{...t.toRange,startRow:t.toRange.startRow-.5,endRow:t.toRange.startRow-.5}]}case Pq.MoveRangeCommandId:{let t=e;return[t.params.fromRange,t.params.toRange]}case Pq.InsertRowCommandId:{let t=e.params.range;return[{...t,startRow:t.startRow-.5,endRow:t.endRow-.5}]}case Pq.InsertColCommandId:{let t=e.params.range;return[{...t,startColumn:t.startColumn-.5,endColumn:t.endColumn-.5}]}case Pq.RemoveRowCommandId:return[e.params.range];case Pq.RemoveColCommandId:return[e.params.range];case Pq.DeleteRangeMoveUpCommandId:case Pq.InsertRangeMoveDownCommandId:{var r;let t=e.params?.range||((r=n.getCurrentSelections())==null||(r=r.map(e=>e.range))==null?void 0:r[0]);return t?[t]:[]}case Pq.DeleteRangeMoveLeftCommandId:case Pq.InsertRangeMoveRightCommandId:{var i;let t=e.params?.range||((i=n.getCurrentSelections())==null||(i=i.map(e=>e.range))==null?void 0:i[0]);return t?[t]:[]}case Pq.ReorderRangeCommandId:{let{range:t,order:n}=e.params,r=[];for(let e=t.startRow;e<=t.endRow;e++)e in n&&r.push({startRow:e,endRow:e,startColumn:t.startColumn,endColumn:t.endColumn});return r}}}function kdt(e){switch(e.id){case qG.id:{let t=e.params;return[t.sourceRange,{...t.targetRange,startColumn:t.targetRange.startColumn-.5,endColumn:t.targetRange.startColumn-.5}]}case KG.id:{let t=e.params;return[t.sourceRange,{...t.targetRange,startRow:t.targetRange.startRow-.5,endRow:t.targetRange.startRow-.5}]}case GG.id:{let t=e.params;return[new Rh(t.from.value).getRange(),new Rh(t.to.value).getRange()]}case WG.id:{let t=e.params.range;return[{...t,startColumn:t.startColumn-.5,endColumn:t.startColumn-.5}]}case HG.id:{let t=e.params.range;return[{...t,startRow:t.startRow-.5,endRow:t.startRow-.5}]}case YG.id:return[e.params.range];case JG.id:return[e.params.range]}}function Adt(e,t){let n=e.get(z);switch(t.id){case Pq.MoveColsCommandId:{let e=t.params,r=SG(n,e);if(!r)return;let{unitId:i,subUnitId:a}=r,{fromRange:o,toRange:s}=e;return{unitId:i,subUnitId:a,ranges:[o,{...s,startColumn:o.startColumn<s.startColumn?o.endColumn+1:s.startColumn,endColumn:o.startColumn<s.startColumn?s.endColumn-1:o.startColumn-1}]}}case Pq.MoveRowsCommandId:{let e=t.params,r=SG(n,e);if(!r)return;let{unitId:i,subUnitId:a}=r,{fromRange:o,toRange:s}=e;return{unitId:i,subUnitId:a,ranges:[o,{...s,startRow:o.startRow<s.startRow?o.endRow+1:s.startRow,endRow:o.startRow<s.startRow?s.endRow-1:o.startRow-1}]}}case Pq.MoveRangeCommandId:{let e=t.params,r=SG(n);if(!r)return;let{unitId:i,subUnitId:a}=r,{fromRange:o,toRange:s}=e;return{unitId:i,subUnitId:a,ranges:[o,s]}}case Pq.InsertRowCommandId:{let e=t.params,r=SG(n,e);if(!r)return;let{worksheet:i,unitId:a,subUnitId:o}=r,{range:s}=e;return{unitId:a,subUnitId:o,ranges:[...s.startRow>0?[{...s,startRow:s.startRow-1,endRow:s.endRow-1}]:[],{...s,startRow:s.startRow,endRow:i.getRowCount()-1}]}}case Pq.InsertColCommandId:{let e=t.params,r=SG(n,e);if(!r)return;let{worksheet:i,unitId:a,subUnitId:o}=r,{range:s}=e;return{unitId:a,subUnitId:o,ranges:[...s.startColumn>0?[{...s,startColumn:s.startColumn-1,endColumn:s.endColumn-1}]:[],{...s,startColumn:s.startColumn,endColumn:i.getColumnCount()-1}]}}case Pq.RemoveRowCommandId:{let e=t.params,r=SG(n);if(!r)return;let{worksheet:i,unitId:a,subUnitId:o}=r,{range:s}=e;return{unitId:a,subUnitId:o,ranges:[s,{...s,startRow:s.endRow+1,endRow:i.getRowCount()-1}]}}case Pq.RemoveColCommandId:{let e=t.params,r=SG(n);if(!r)return;let{worksheet:i,unitId:a,subUnitId:o}=r,{range:s}=e;return{unitId:a,subUnitId:o,ranges:[s,{...s,startColumn:s.endColumn+1,endColumn:i.getColumnCount()-1}]}}case Pq.DeleteRangeMoveUpCommandId:case Pq.InsertRangeMoveDownCommandId:{let e=t.params,r=SG(n);if(!r)return;let{worksheet:i,unitId:a,subUnitId:o}=r,{range:s}=e;return{unitId:a,subUnitId:o,ranges:[s,{...s,startRow:s.endRow+1,endRow:i.getRowCount()-1}]}}case Pq.DeleteRangeMoveLeftCommandId:case Pq.InsertRangeMoveRightCommandId:{let e=t.params,r=SG(n);if(!r)return;let{worksheet:i,unitId:a,subUnitId:o}=r,{range:s}=e;return{unitId:a,subUnitId:o,ranges:[s,{...s,startColumn:s.endColumn+1,endColumn:i.getColumnCount()-1}]}}case Pq.ReorderRangeCommandId:{let e=t.params,r=SG(n);if(!r)return;let{unitId:i,subUnitId:a}=r,{range:o,order:s}=e,c=[];for(let e=o.startRow;e<=o.endRow;e++)e in s&&c.push({startRow:e,endRow:e,startColumn:o.startColumn,endColumn:o.endColumn});return{unitId:i,subUnitId:a,ranges:c}}}}var jdt=Cf(`MERGE_REDO`),Mdt=Cf(`MERGE_UNDO`),Ndt=class extends P{constructor(e,t,n,r,i=!1){super(),this._unitId=e,this._subUnitId=t,this._range=n,this._callback=r,this._skipIntersects=i}onMutation(e){if(e.params?.unitId!==this._unitId)return;if(e.id===GG.id){let t=e.params;if(t.from.subUnitId!==this._subUnitId||t.to.subUnitId!==this._subUnitId)return}else if(e.params?.subUnitId!==this._subUnitId)return;if(!this._range||this._skipIntersects&&(e.id===Aq.id||kdt(e)?.some(e=>d_.intersects(e,this._range))))return;let t=Ddt(this._range,e);if(t&&d_.equals(t,this._range))return!1;let n=this._range;this._range=t,this._callback(n,t)}},eJ=class extends P{constructor(e,t,n,r){super(),this._commandService=e,this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=r,Z(this,`interceptor`,new Tf({MERGE_REDO:jdt,MERGE_UNDO:Mdt})),Z(this,`_watchRanges`,new Set),Z(this,`_refRangeManagerMap`,new Map),Z(this,`_serializer`,Ldt()),Z(this,`_onRefRangeChange`,()=>{this._sheetInterceptorService.interceptCommand({getMutations:e=>{let t=(()=>{switch(e.id){case Pq.MoveColsCommandId:{let t=e.params,n=SG(this._univerInstanceService,t);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o=Math.min(t.fromRange.startColumn,t.toRange.startColumn);return this._checkRange([{...t.fromRange,startColumn:o,endColumn:r.getColumnCount()-1}],i,a)}case Pq.MoveRowsCommandId:{let t=e.params,n=SG(this._univerInstanceService,t);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o=Math.min(t.fromRange.startRow,t.toRange.startRow);return this._checkRange([{...t.fromRange,startRow:o,endRow:r.getRowCount()-1}],i,a)}case Pq.MoveRangeCommandId:{let t=e.params,n=SG(this._univerInstanceService,{unitId:t.fromUnitId,subUnitId:t.fromSubUnitId}),r=SG(this._univerInstanceService,{unitId:t.toUnitId??t.fromUnitId,subUnitId:t.toSubUnitId??t.fromSubUnitId});if(!n&&!r)return[];if(n&&r&&n.unitId===r.unitId&&n.subUnitId===r.subUnitId)return this._checkRange([t.fromRange,t.toRange],n.unitId,n.subUnitId);let i=[];return n&&i.push(...this._checkRange([t.fromRange],n.unitId,n.subUnitId)),r&&i.push(...this._checkRange([t.toRange],r.unitId,r.subUnitId)),i}case Pq.InsertRowCommandId:{let t=e.params,n=SG(this._univerInstanceService,t);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o={startRow:Math.max(0,t.range.startRow-1),endRow:r.getRowCount()-1,startColumn:0,endColumn:r.getColumnCount()-1,rangeType:vh.ROW};return this._checkRange([o],i,a)}case Pq.InsertColCommandId:{let t=e.params,n=SG(this._univerInstanceService,t);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o={startRow:0,endRow:r.getRowCount()-1,startColumn:Math.max(0,t.range.startColumn-1),endColumn:r.getColumnCount()-1,rangeType:vh.COLUMN};return this._checkRange([o],i,a)}case Pq.RemoveRowCommandId:{let t=e.params,n=SG(this._univerInstanceService);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o={startRow:t.range.startRow,endRow:r.getRowCount()-1,startColumn:0,endColumn:r.getColumnCount()-1,rangeType:vh.ROW};return this._checkRange([o],i,a)}case Pq.RemoveColCommandId:{let t=e.params,n=SG(this._univerInstanceService);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o={startRow:0,endRow:r.getRowCount()-1,startColumn:t.range.startColumn,endColumn:r.getColumnCount()-1,rangeType:vh.COLUMN};return this._checkRange([o],i,a)}case Pq.DeleteRangeMoveUpCommandId:case Pq.InsertRangeMoveDownCommandId:{let t=e.params,n=SG(this._univerInstanceService);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o={...t.range,endRow:r.getRowCount()-1};return this._checkRange([o],i,a)}case Pq.DeleteRangeMoveLeftCommandId:case Pq.InsertRangeMoveRightCommandId:{let t=e.params,n=SG(this._univerInstanceService);if(!n)return[];let{worksheet:r,unitId:i,subUnitId:a}=n,o={...t.range,endColumn:r.getColumnCount()-1};return this._checkRange([o],i,a)}case Pq.ReorderRangeCommandId:{let t=e.params,n=SG(this._univerInstanceService);if(!n)return[];let{unitId:r,subUnitId:i}=n,{range:a,order:o}=t,s=[];for(let e=a.startRow;e<=a.endRow;e++)e in o&&s.push({startRow:e,endRow:e,startColumn:a.startColumn,endColumn:a.endColumn});return this._checkRange(s,r,i)}}})();if(!t||t.length===0)return{redos:[],undos:[],preRedos:[],preUndos:[]};let n=t.reduce((t,n)=>{let r=n(e);return t.push(r),t},[]).reduce((e,t)=>(e.redos.push(...t.redos),e.undos.push(...t.undos),e.preRedos.push(...t.preRedos??[]),e.preUndos.push(...t.preUndos??[]),e),{redos:[],undos:[],preUndos:[],preRedos:[]}),r=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(n.preRedos,null)||[],i=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(n.redos,null)||[],a=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_UNDO)(n.preUndos,null)||[];return{redos:i,undos:this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_UNDO)(n.undos,null)||[],preRedos:r,preUndos:a}}})}),Z(this,`_checkRange`,(e,t,n)=>{let r=Idt(t,n),i=this._refRangeManagerMap.get(r);if(i){let t=new Set;return[...i.keys()].forEach(n=>{let r=i.get(n),a=this._serializer.deserialize(n),o={...a,startRow:+a.startRow,endRow:+a.endRow,startColumn:+a.startColumn,endColumn:+a.endColumn,rangeType:a.rangeType&&+a.rangeType};e.some(e=>d_.intersects(e,o))&&r&&r.forEach(e=>{t.add(e)})}),[...t]}return[]}),Z(this,`registerRefRange`,(e,t,n,r)=>{let i=n||Pdt(this._univerInstanceService),a=r||Fdt(this._univerInstanceService);if(!i||!a)return Wf(()=>{});let o=Idt(i,a),s=this._serializer.serialize(e),c=this._refRangeManagerMap.get(o);c||(c=new Map,this._refRangeManagerMap.set(o,c));let l=c.get(s);return l?l.add(t):c.set(s,new Set([t])),Wf(()=>{let e=c.get(s);e&&(e.delete(t),e.size||(c.delete(s),c.size||this._refRangeManagerMap.delete(o)))})}),this._onRefRangeChange(),this.interceptor.intercept(this.interceptor.getInterceptPoints().MERGE_REDO,{priority:-1,handler:e=>e}),this.interceptor.intercept(this.interceptor.getInterceptPoints().MERGE_UNDO,{priority:-1,handler:e=>e})}watchRange(e,t,n,r,i){let a;this._watchRanges.size===0&&(a=this._commandService.onCommandExecuted(e=>{if(e.type!==L.MUTATION)return!1;for(let t of this._watchRanges)t.onMutation(e)}));let o=new Ndt(e,t,n,r,i);this._watchRanges.add(o);let s=Wf(()=>{this._watchRanges.delete(o),this._watchRanges.size===0&&(a?.dispose(),a=null)}),c=this.disposeWithMe(s);return Wf(()=>{c.dispose(),s.dispose()})}};eJ=AG([kG(0,R),kG(1,j(PG)),kG(2,j(z)),kG(3,j(WK))],eJ);function Pdt(e){return e.getCurrentUnitOfType(M.UNIVER_SHEET)?.getUnitId()}function Fdt(e){var t;return(t=e.getCurrentUnitOfType(M.UNIVER_SHEET))==null||(t=t.getActiveSheet())==null?void 0:t.getSheetId()}function Idt(e,t){return`${e}_${t}`}function Ldt(){let e=[`startRow`,`startColumn`,`endRow`,`endColumn`,`rangeType`];return{deserialize:t=>{let n=e.reduce((e,t,n)=>(e[String(n)]=t,e),{});return t.split(`_`).reduce((e,t,r)=>{let i=String(r);return t&&n[i]&&(e[n[i]]=t),e},{})},serialize:t=>e.reduce((e,n,r)=>{let i=t[n];return i===void 0?`${e}`:`${e}${r>0?`_`:``}${i}`},``)}}var Rdt=[WG.id,HG.id,YG.id,JG.id],zdt=[KG.id,qG.id];function tJ(e,t){let n=e;if(t!==void 0){let e=[];for(let r=0;r<n.length;r++){let{startRow:i,endRow:a,startColumn:o,endColumn:s}=n[r];if(t===_p.ROWS)for(let t=i;t<=a;t++){let n={startRow:t,endRow:t,startColumn:o,endColumn:s};e.push(n)}else if(t===_p.COLUMNS)for(let t=o;t<=s;t++){let n={startRow:i,endRow:a,startColumn:t,endColumn:t};e.push(n)}}n=e}return n}var Bdt=Cf(`mergeCellPermissionCheck`),nJ=class extends P{constructor(e,t,n,r,i,a){super(),this._commandService=e,this._refRangeService=t,this._univerInstanceService=n,this._injector=r,this._sheetInterceptorService=i,this._selectionManagerService=a,Z(this,`disposableCollection`,new Gf),Z(this,`interceptor`,new Tf({MERGE_CELL_INTERCEPTOR_CHECK:Bdt})),this._onRefRangeChange(),this._initCommandInterceptor(),this._commandExecutedListener()}_initCommandInterceptor(){let e=this;this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case XK.id:case ZK.id:{let t=e._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET),n=t.getUnitId(),r=t?.getActiveSheet();if(!r)return{redos:[],undos:[]};let i=r.getSheetId(),a=r.getConfig().mergeData,o=e._selectionManagerService.getCurrentSelections()?.map(e=>e.range);if(o&&o.length>0&&o.some(e=>a.some(t=>d_.intersects(t,e)))){let t={unitId:n,subUnitId:i,ranges:o},r=XG(e._injector,t);return{redos:[{id:ZG.id,params:t}],undos:[{id:TG.id,params:r}]}}}}return{redos:[],undos:[]}}}),this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{let r=[],i=[],a={redos:r,undos:i};if(!n||!n.length)return a;let o=SG(this._univerInstanceService,{unitId:e,subUnitId:t});if(!o)return a;let{worksheet:s}=o,c=s.getMergeData().filter(e=>n.some(t=>d_.intersects(e,t)));return c.length?(r.push({id:ZG.id,params:{unitId:e,subUnitId:t,ranges:c}}),i.push({id:TG.id,params:{unitId:e,subUnitId:t,ranges:c}}),{undos:i,redos:r}):a}})}refRangeHandle(e,t,n){switch(e.id){case Pq.MoveColsCommandId:{let r=e.params;return this._handleMoveColsCommand(r,t,n)}case Pq.MoveRowsCommandId:{let r=e.params;return this._handleMoveRowsCommand(r,t,n)}case mq.id:{let r=e.params,i=r.unitId||t,a=r.subUnitId||n;return this._handleInsertRowCommand(r,i,a)}case yq.id:{let r=e.params,i=r.unitId||t,a=r.subUnitId||n;return this._handleInsertColCommand(r,i,a)}case kq.id:{let r=e.params;return this._handleRemoveColCommand(r,t,n)}case Eq.id:{let r=e.params;return this._handleRemoveRowCommand(r,t,n)}case sq.id:{let r=e.params;return this._handleMoveRangeCommand(r,t,n)}case pq.id:{let r=e.params;return this._handleInsertRangeMoveRightCommand(r,t,n)}case fq.id:{let r=e.params;return this._handleInsertRangeMoveDownCommand(r,t,n)}case dq.id:{let r=e.params;return this._handleDeleteRangeMoveUpCommand(r,t,n)}case uq.id:{let r=e.params;return this._handleDeleteRangeMoveLeftCommand(r,t,n)}}return{redos:[],undos:[]}}_onRefRangeChange(){let e=(e,t)=>{let n=this._univerInstanceService.getUniverSheetInstance(e);if(!n)return;let r=n?.getSheetBySheetId(t);if(!r)return;this.disposableCollection.dispose();let i=r.getMergeData(),a=n=>this.refRangeHandle(n,e,t);i.forEach(n=>{this.disposableCollection.add(this._refRangeService.registerRefRange(n,a,e,t))})};this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===wK.id){let n=t.params,r=n.subUnitId,i=n.unitId;if(!r||!i)return;e(i,r)}if(t.id===TG.id){let n=t.params,r=n.subUnitId,i=n.unitId;if(!r||!i)return;e(n.unitId,n.subUnitId)}})),this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_SHEET).pipe($s(e=>!!e)).subscribe(t=>{let n=t.getActiveSheet();n&&e(t.getUnitId(),n.getSheetId())})}_handleMoveRowsCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let a=[...i.getMergeData()],o={unitId:t,subUnitId:n,ranges:[]},s={unitId:t,subUnitId:n,ranges:[]},{fromRange:c}=e,{startRow:l,endRow:u}=c;if(a.forEach(t=>{if(l<=t.startRow&&u>=t.endRow){o.ranges.push(t);let n=Zq(Rq({id:Pq.MoveRowsCommandId,params:e},t),t);n&&s.ranges.push(n)}}),o.ranges.length===0)return this._handleNull();let d=XG(this._injector,o),f=wG(this._injector,s);return{preRedos:[{id:ZG.id,params:o}],redos:[{id:TG.id,params:s}],preUndos:[{id:ZG.id,params:f}],undos:[{id:TG.id,params:d}]}}_handleMoveColsCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let a=[...i.getMergeData()],o={unitId:t,subUnitId:n,ranges:[]},s={unitId:t,subUnitId:n,ranges:[]},{fromRange:c}=e,{startColumn:l,endColumn:u}=c;if(a.forEach(t=>{if(l<=t.startColumn&&u>=t.endColumn){o.ranges.push(t);let n=Zq(zq({id:Pq.MoveColsCommandId,params:e},t),t);n&&s.ranges.push(n)}}),o.ranges.length===0)return this._handleNull();let d=XG(this._injector,o),f=wG(this._injector,s);return{preRedos:[{id:ZG.id,params:o}],redos:[{id:TG.id,params:s}],preUndos:[{id:ZG.id,params:f}],undos:[{id:TG.id,params:d}]}}_handleMoveRangeCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=e.fromSubUnitId??n,a=e.toSubUnitId??i,o=iJ(r,i),s=iJ(r,a);if(!o||!s)return this._handleNull();let c=o.getMergeData().filter(t=>d_.intersects(t,e.fromRange)),l=s.getMergeData().filter(t=>d_.intersects(t,e.toRange)),u=tJ(c.map(t=>d_.getRelativeRange(t,e.fromRange)).map(t=>d_.getPositionRange(t,e.toRange))).filter(e=>!s.getMergeData().some(t=>d_.equals(e,t))),d=[],f=[];return n===i&&c.length>0&&(d.push({id:ZG.id,params:{unitId:t,subUnitId:i,ranges:c}}),f.push({id:TG.id,params:{unitId:t,subUnitId:i,ranges:c}})),n===a&&l.length>0&&(d.push({id:ZG.id,params:{unitId:t,subUnitId:a,ranges:l}}),f.push({id:TG.id,params:{unitId:t,subUnitId:a,ranges:l}})),n===a&&u.length>0&&(d.push({id:TG.id,params:{unitId:t,subUnitId:a,ranges:u}}),f.unshift({id:ZG.id,params:{unitId:t,subUnitId:a,ranges:u}})),d.length===0?this._handleNull():{redos:d,undos:f}}_handleInsertRowCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let{range:a}=e,{startRow:o,endRow:s}=a,c=F.deepClone(i.getMergeData()).reduce((e,t)=>(o>t.startRow&&o<=t.endRow&&e.push(t),e),[]);if(c.length===0)return this._handleNull();let l=F.deepClone(i.getMergeData()).reduce((e,t)=>{if(o>t.startRow&&o<=t.endRow){let n=s-o+1;t.endRow+=n,this._checkIsMergeCell(t)&&e.push(t)}return e},[]),u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f);return{redos:[{id:ZG.id,params:u},{id:TG.id,params:f}],undos:[{id:ZG.id,params:p},{id:TG.id,params:d}]}}_handleInsertColCommand(e,t,n){let{range:r}=e,i=rJ(this._univerInstanceService,t);if(!i)return this._handleNull();let a=iJ(i,n);if(!a)return this._handleNull();let{startColumn:o,endColumn:s}=r,c=F.deepClone(a.getMergeData()).reduce((e,t)=>(o>t.startColumn&&o<=t.endColumn&&e.push(t),e),[]);if(c.length===0)return this._handleNull();let l=F.deepClone(a.getMergeData()).reduce((e,t)=>{if(o>t.startColumn&&o<=t.endColumn){let n=s-o+1;t.endColumn+=n,this._checkIsMergeCell(t)&&e.push(t)}return e},[]),u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f);return{redos:[{id:ZG.id,params:u},{id:TG.id,params:f}],undos:[{id:ZG.id,params:p},{id:TG.id,params:d}]}}_handleRemoveColCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let{range:a}=e,{startColumn:o,endColumn:s}=a,c=F.deepClone(i.getMergeData()).reduce((e,t)=>(d_.intersects(a,t)&&e.push(t),e),[]);if(c.length===0)return this._handleNull();let l=F.deepClone(i.getMergeData()).reduce((e,t)=>{if(d_.intersects(a,t)){if(o<=t.startColumn&&s>=t.endColumn)return e;o>=t.startColumn&&s<=t.endColumn?t.endColumn-=s-o+1:o<t.startColumn?(t.startColumn=o,t.endColumn-=s-o+1):s>t.endColumn&&(t.endColumn=o-1),this._checkIsMergeCell(t)&&e.push(t)}return e},[]),u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f),m=[{id:ZG.id,params:u}],h=[{id:TG.id,params:f}];return{preUndos:[{id:ZG.id,params:p}],undos:[{id:TG.id,params:d}],preRedos:m,redos:h}}_handleRemoveRowCommand(e,t,n){let{range:r}=e,i=rJ(this._univerInstanceService,t);if(!i)return this._handleNull();let a=iJ(i,n);if(!a)return this._handleNull();let{startRow:o,endRow:s}=r,c=F.deepClone(a.getMergeData()).reduce((e,t)=>(d_.intersects(r,t)&&e.push(t),e),[]);if(c.length===0)return this._handleNull();let l=F.deepClone(a.getMergeData()).reduce((e,t)=>{if(d_.intersects(r,t)){if(o<=t.startRow&&s>=t.endRow)return e;o>=t.startRow&&s<=t.endRow?t.endRow-=s-o+1:o<t.startRow?(t.startRow=o,t.endRow-=s-o+1):s>t.endRow&&(t.endRow=o-1),this._checkIsMergeCell(t)&&e.push(t)}return e},[]),u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f),m=[{id:ZG.id,params:u}],h=[{id:TG.id,params:f}];return{preUndos:[{id:ZG.id,params:p}],undos:[{id:TG.id,params:d}],preRedos:m,redos:h}}_handleInsertRangeMoveRightCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let a=e.range,o=i.getMaxColumns()-1,s=i.getMergeData(),c=[],l=[];s.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:i}=a;if(d_.intersects({startRow:t,startColumn:r,endRow:n,endColumn:o},e)&&(c.push(e),d_.contains({startRow:t,startColumn:r,endRow:n,endColumn:o},e))){let t=i-r+1;l.push({startRow:e.startRow,startColumn:e.startColumn+t,endRow:e.endRow,endColumn:e.endColumn+t})}});let u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f);return{preRedos:[{id:ZG.id,params:u}],redos:[{id:TG.id,params:f}],preUndos:[{id:ZG.id,params:p}],undos:[{id:TG.id,params:d}]}}_handleInsertRangeMoveDownCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let a=e.range,o=i.getMaxRows()-1,s=i.getMergeData(),c=[],l=[];s.forEach(e=>{let{startRow:t,startColumn:n,endColumn:r,endRow:i}=a;if(d_.intersects({startRow:t,startColumn:n,endRow:o,endColumn:r},e)&&(c.push(e),d_.contains({startRow:t,startColumn:n,endRow:o,endColumn:r},e))){let n=i-t+1;l.push({startRow:e.startRow+n,startColumn:e.startColumn,endRow:e.endRow+n,endColumn:e.endColumn})}});let u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f),m=[{id:ZG.id,params:u}],h=[{id:TG.id,params:f}],g=[{id:ZG.id,params:p}];return{redos:h,undos:[{id:TG.id,params:d}],preRedos:m,preUndos:g}}_handleDeleteRangeMoveUpCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let a=e.range,o=i.getMaxRows()-1,s=i.getMergeData(),c=[],l=[];s.forEach(e=>{let{startRow:t,startColumn:n,endColumn:r,endRow:i}=a;if(d_.intersects({startRow:t,startColumn:n,endRow:o,endColumn:r},e)&&(c.push(e),d_.contains({startRow:t,startColumn:n,endRow:o,endColumn:r},e))){let n=i-t+1,r=d_.moveVertical(e,-n);l.push(r)}});let u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f),m=[{id:ZG.id,params:u}],h=[{id:TG.id,params:f}],g=[{id:ZG.id,params:p}];return{redos:h,undos:[{id:TG.id,params:d}],preRedos:m,preUndos:g}}_handleDeleteRangeMoveLeftCommand(e,t,n){let r=rJ(this._univerInstanceService,t);if(!r)return this._handleNull();let i=iJ(r,n);if(!i)return this._handleNull();let a=e.range,o=i.getMaxColumns()-1,s=i.getMergeData(),c=[],l=[];s.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:i}=a;if(d_.intersects({startRow:t,startColumn:r,endRow:n,endColumn:o},e)&&(c.push(e),d_.contains({startRow:t,startColumn:r,endRow:n,endColumn:o},e))){let t=i-r+1;l.push({startRow:e.startRow,startColumn:e.startColumn-t,endRow:e.endRow,endColumn:e.endColumn-t})}});let u={unitId:t,subUnitId:n,ranges:c},d=XG(this._injector,u),f={unitId:t,subUnitId:n,ranges:l},p=wG(this._injector,f);return{preRedos:[{id:ZG.id,params:u}],redos:[{id:TG.id,params:f}],undos:[{id:TG.id,params:d}],preUndos:[{id:ZG.id,params:p}]}}_checkIsMergeCell(e){return e.startRow!==e.endRow||e.startColumn!==e.endColumn}_handleNull(){return{redos:[],undos:[]}}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(zdt.includes(e.id)){if(!e.params)return;let t=this._univerInstanceService.getUniverSheetInstance(e.params.unitId);if(!t)return;let n=t.getSheetBySheetId(e.params.subUnitId);if(!n)return;let{sourceRange:r,targetRange:i}=e.params,a=r.startColumn===i.startColumn&&r.endColumn===i.endColumn,o=a?r.endRow-r.startRow+1:r.endColumn-r.startColumn+1,s=a?r.startRow:r.startColumn,c=a?i.startRow:i.startColumn,l=n.getConfig().mergeData,u=[];l.forEach(e=>{let{startRow:t,endRow:n,startColumn:i,endColumn:l,rangeType:d}=e;d_.intersects(e,r)||(a?s<t&&c>n?(t-=o,n-=o):s>n&&c<=t&&(t+=o,n+=o):s<i&&c>l?(i-=o,l-=o):s>l&&c<=i&&(i+=o,l+=o)),(e.startRow!==e.endRow||e.startColumn!==e.endColumn)&&u.push({startRow:t,endRow:n,startColumn:i,endColumn:l,rangeType:d})}),n.setMergeData(u),this.disposableCollection.dispose();let{unitId:d,subUnitId:f}=e.params,p=e=>this.refRangeHandle(e,d,f);u.forEach(e=>{this.disposableCollection.add(this._refRangeService.registerRefRange(e,p,d,f))})}if(Rdt.includes(e.id)){let t=this._univerInstanceService.getUniverSheetInstance(e.params.unitId);if(!t)return;let n=t.getSheetBySheetId(e.params.subUnitId);if(!n)return;let r=n.getConfig().mergeData,i=e.params;if(!i)return;let{range:a}=i,o=e.id.includes(`row`),s=e.id.includes(`insert`),c=o?a.startRow:a.startColumn,l=o?a.endRow:a.endColumn,u=l-c+1,d=[];r.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:i,rangeType:a}=e;s?o?c<=t&&(t+=u,n+=u):c<=r&&(r+=u,i+=u):o?l<t&&(t-=u,n-=u):l<r&&(r-=u,i-=u),(e.startRow!==e.endRow||e.startColumn!==e.endColumn)&&d.push({startRow:t,endRow:n,startColumn:r,endColumn:i,rangeType:a})}),n.setMergeData(d),this.disposableCollection.dispose();let{unitId:f,subUnitId:p}=e.params,m=e=>this.refRangeHandle(e,f,p);d.forEach(e=>{this.disposableCollection.add(this._refRangeService.registerRefRange(e,m,f,p))})}}))}};nJ=AG([kG(0,j(R)),kG(1,j(eJ)),kG(2,j(z)),kG(3,j(We)),kG(4,j(PG)),kG(5,j(WK))],nJ);function rJ(e,t){return t?e.getUniverSheetInstance(t):e.getCurrentUnitOfType(M.UNIVER_SHEET)}function iJ(e,t){return t?e.getSheetBySheetId(t):e.getActiveSheet()}var Vdt=(e,t,n)=>{let r=e.get(WK).getCurrentSelections(),{value:i,selections:a,unitId:o,subUnitId:s}=t;if(r&&r.length>0){let e=r[r?.length-1].primary;if(e){let{actualColumn:t,actualRow:c}=e,{startRow:l,startColumn:u,endRow:d,endColumn:f}=a[a.length-1];if(i===_p.COLUMNS){let e=n.find(e=>e.startColumn===t&&e.endColumn===t&&c===e.startRow);e&&(f=e.endColumn,l=e.startRow,d=e.endRow)}else if(i===_p.ROWS){let e=n.find(e=>e.startRow===c&&e.endRow===c&&t===e.startColumn);e&&(d=e.endRow,u=e.startColumn,f=e.endColumn)}let p={startRow:l,startColumn:u,endRow:d,endColumn:f,actualRow:c,actualColumn:t,isMerged:!0,isMergedMainCell:l===c&&u===t},m={unitId:o,subUnitId:s,type:3,selections:r.map((e,t,n)=>({range:e.range,style:null,primary:t===n.length-1?p:null}))};return{id:oq.id,params:m}}return null}return null},Hdt=(e,t)=>{let n=e.get(WK).getCurrentSelections(),{unitId:r,subUnitId:i}=t;if(n&&n.length>0&&n[n?.length-1].primary){let e={unitId:r,subUnitId:i,type:3,selections:[...n]};return{id:oq.id,params:e}}return null},aJ={type:L.COMMAND,id:`sheet.command.remove-worksheet-merge`,handler:(e,t)=>{let n=e.get(WK),r=e.get(R),i=e.get(vx),a=t?.ranges||n.getCurrentSelections()?.map(e=>e.range);if(!a?.length)return!1;let o=SG(e.get(z),t);if(!o)return!1;let{subUnitId:s,unitId:c,worksheet:l}=o,u={unitId:c,subUnitId:s,ranges:a},d=l.getConfig().mergeData.filter(e=>a.some(t=>d_.intersects(t,e)));if(!d.length)return!1;let f=XG(e,u),p=n.getCurrentSelections(),m=F.deepClone(p),h=F.deepClone(p);if(p.length){let e=h[h.length-1],{startRow:t,startColumn:n}=e.range;e.primary={startRow:t,startColumn:n,endRow:t,endColumn:n,actualRow:t,actualColumn:n,isMerged:!1,isMergedMainCell:!1}}let g={unitId:c,subUnitId:s,cellValue:Udt(l,d).getMatrix()},_=cK(e,g),v=[{id:ZG.id,params:f},{id:lK.id,params:g},{id:oq.id,params:{unitId:c,subUnitId:s,selections:h,type:3}}],y=[{id:TG.id,params:f},{id:lK.id,params:_},{id:oq.id,params:{unitId:c,subUnitId:s,selections:m,type:3}}];return Km(v,r).result?(i.pushUndoRedo({unitID:c,undoMutations:y,redoMutations:v}),!0):!1}};function Udt(e,t){let n=new Rh;return t.forEach(t=>{let{startRow:r,startColumn:i,endColumn:a,endRow:o}=t,s=e.getCellMatrix().getValue(r,i);if(s?.s)for(let e=r;e<=o;e++)for(let t=i;t<=a;t++)(e!==r||t!==i)&&n.setValue(e,t,{s:s.s})}),n}function Wdt(e,t){return t.some(t=>Gdt(e,t))}function Gdt(e,t){let{startRow:n,startColumn:r,endColumn:i,endRow:a}=t,o=e.getMatrixWithMergedCells(n,r,a,i),s=!1;return o.forValue((t,i,a)=>{if(a&&(t!==n||i!==r)&&e.cellHasValue(a))return s=!0,!1}),s}function Kdt(e,t,n,r){let i=[],a=[],o=n.getSheetId();return r.forEach(r=>{let s={unitId:t,subUnitId:o,cellValue:qdt(n,r).getData()},c=cK(e,s);i.push({id:lK.id,params:c}),a.push({id:lK.id,params:s})}),{undos:i,redos:a}}function qdt(e,t){let{startRow:n,startColumn:r,endColumn:i,endRow:a}=t,o=e.getMatrixWithMergedCells(n,r,a,i,Sh.Raw),s=new Rh,c=null;return o.forValue((t,i,a)=>{if(a&&t>=n&&i>=r){var o;!c&&e.cellHasValue(a)&&(a.v!==``||(((o=a.p)==null||(o=o.body)==null||(o=o.dataStream)==null?void 0:o.length)??0)>2)&&(c=a),s.setValue(t,i,a.s?{v:null,t:null,f:null,si:null,p:null,s:a.s}:null)}}),s.setValue(n,r,c),s}var oJ={type:L.COMMAND,id:`sheet.command.add-worksheet-merge`,handler:async(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{worksheet:r}=n,{unitId:i,subUnitId:a,selections:o}=t,s=e.get(R),c=e.get(vx),l=tJ(o,t.value),u=Wdt(r,l);if(u&&!t.defaultMerge){let t=e.get(qy),n=e.get(nx);if(!await t.confirm({id:`merge.confirm.add-worksheet-merge`,title:{title:`sheets.merge.confirm.warning`},children:{title:`sheets.merge.confirm.title`},cancelText:n.t(`sheets.merge.confirm.cancel`),confirmText:n.t(`sheets.merge.confirm.confirm`)}))return!1}let d=[],f=[],p={unitId:i,subUnitId:a,ranges:F.deepClone(l)},m={unitId:i,subUnitId:a,ranges:F.deepClone(l)},h=XG(e,p),g=wG(e,m);if(h.ranges.length>0&&d.push({id:ZG.id,params:h}),d.push({id:TG.id,params:m}),f.push({id:ZG.id,params:g}),h.ranges.length>0&&f.push({id:TG.id,params:h}),u){let t=Kdt(e,i,r,l);d.unshift(...t.redos),f.push(...t.undos)}let _=Vdt(e,t,l);_&&d.push(_);let v=Hdt(e,t);v&&f.push(v);let y=e.get(PG).onCommandExecute({id:oJ.id,params:{unitId:i,subUnitId:a,ranges:l}});return d.push(...y.redos),f.push(...y.undos),Km(d,s).result?(c.pushUndoRedo({unitID:i,undoMutations:f,redoMutations:d}),!0):!1}},sJ={type:L.COMMAND,id:`sheet.command.add-worksheet-merge-all`,handler:async e=>{let t=dJ(`mergeAll`,e.get(WK).getCurrentSelections()?.map(e=>e.range));if(!t?.length)return!1;let n=SG(e.get(z));if(!n)return!1;let{worksheet:r}=n,i=r.getUnitId(),a=r.getSheetId();return e.get(R).executeCommand(oJ.id,{selections:t,unitId:i,subUnitId:a})}},cJ={type:L.COMMAND,id:`sheet.command.add-worksheet-merge-vertical`,handler:async e=>{let t=dJ(`mergeVertical`,e.get(WK).getCurrentSelections()?.map(e=>e.range));if(!t?.length)return!1;let n=SG(e.get(z));if(!n)return!1;let{worksheet:r}=n,i=r.getUnitId(),a=r.getSheetId();return e.get(R).executeCommand(oJ.id,{value:_p.COLUMNS,selections:t,unitId:i,subUnitId:a})}},lJ={type:L.COMMAND,id:`sheet.command.add-worksheet-merge-horizontal`,handler:async e=>{let t=dJ(`mergeHorizontal`,e.get(WK).getCurrentSelections()?.map(e=>e.range));if(!t?.length)return!1;let n=SG(e.get(z));if(!n)return!1;let{workbook:r,worksheet:i}=n,a=r.getUnitId(),o=i.getSheetId();return e.get(R).executeCommand(oJ.id,{value:_p.ROWS,selections:t,unitId:a,subUnitId:o})}};function uJ(e,t,n,r,i={}){let a=SG(e.get(z),{unitId:t,subUnitId:n});if(!a)return;let o=e.get(R),{defaultMerge:s=!0,isForceMerge:c=!1}=i,{worksheet:l}=a;if(l.getMergeData().some(e=>r.some(t=>d_.intersects(t,e)))){if(!c)throw Error(`The ranges to be merged overlap with the existing merged cells`);o.syncExecuteCommand(aJ.id,{unitId:t,subUnitId:n,ranges:r})}o.executeCommand(oJ.id,{unitId:t,subUnitId:n,selections:r,defaultMerge:s})}function dJ(e,t){return t?e===`mergeAll`?t.filter(e=>e.startRow!==e.endRow||e.startColumn!==e.endColumn):e===`mergeVertical`?t.filter(e=>e.startRow!==e.endRow):e===`mergeHorizontal`?t.filter(e=>e.startColumn!==e.endColumn):t:null}var fJ=class{constructor(){Z(this,`_model`,new Map),Z(this,`_ruleChange`,new ao),Z(this,`_ruleRefresh`,new ao),Z(this,`_resetOrder`,new ao),Z(this,`ruleChange$`,this._ruleChange.asObservable()),Z(this,`ruleRefresh$`,this._ruleRefresh.asObservable()),Z(this,`resetOrder$`,this._resetOrder.asObservable()),Z(this,`_worksheetRuleInitStateChange`,new so(!1)),Z(this,`worksheetRuleInitStateChange$`,this._worksheetRuleInitStateChange.asObservable())}changeRuleInitState(e){this._worksheetRuleInitStateChange.next(e)}getSheetRuleInitState(){return this._worksheetRuleInitStateChange.value}addRule(e,t){this._ensureSubUnitMap(e).set(t.subUnitId,t),this._ruleChange.next({unitId:e,rule:t,type:`add`,subUnitId:t.subUnitId})}deleteRule(e,t){var n;let r=(n=this._model)==null||(n=n.get(e))==null?void 0:n.get(t);if(r){var i;(i=this._model.get(e))==null||i.delete(t),this._ruleChange.next({unitId:e,rule:r,type:`delete`,subUnitId:t})}}setRule(e,t,n){let r=this.getRule(e,t);if(r){var i;(i=this._model)==null||(i=i.get(e))==null||i.set(t,n),this._ruleChange.next({unitId:e,oldRule:r,rule:n,type:`set`,subUnitId:t})}}getRule(e,t){var n;return(n=this._model)==null||(n=n.get(e))==null?void 0:n.get(t)}toObject(){let e={};return[...this._model.keys()].forEach(t=>{let n=this._model.get(t);n?.size&&(e[t]=[],[...n.keys()].forEach(r=>{let i=n.get(r);i&&e[t].push(i)}))}),e}fromObject(e){let t=new Map;Object.keys(e).forEach(n=>{let r=e[n];if(r?.length){let e=new Map;r.forEach(t=>{e.set(t.subUnitId,t)}),t.set(n,e)}}),this._model=t}deleteUnitModel(e){this._model.delete(e)}_ensureSubUnitMap(e){let t=this._model.get(e);return t||(t=new Map,this._model.set(e,t)),t}ruleRefresh(e){this._ruleRefresh.next(e)}resetOrder(){this._resetOrder.next(Math.random())}getTargetByPermissionId(e,t){let n=this._model.get(e);if(!n)return null;for(let[r,i]of n)if(i.permissionId===t)return[e,r]}},pJ={id:`sheet.mutation.add-worksheet-protection`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(fJ),{unitId:r,rule:i}=t;return n.addRule(r,i),!0}},mJ={id:`sheet.mutation.delete-worksheet-protection`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(fJ),{unitId:r,subUnitId:i}=t;return n.deleteRule(r,i),!0}},hJ={type:L.COMMAND,id:`sheet.command.add-worksheet-protection`,async handler(e,t){if(!t)return!1;let n=e.get(R),r=e.get(vx),{rule:i,unitId:a}=t,o=i.subUnitId;if(await n.executeCommand(pJ.id,{unitId:a,rule:i,subUnitId:i.subUnitId})){let e=[{id:pJ.id,params:{unitId:a,rule:i,subUnitId:i.subUnitId}}],t=[{id:mJ.id,params:{unitId:a,subUnitId:o}}];r.pushUndoRedo({unitID:a,redoMutations:e,undoMutations:t})}return!0}},Jdt={type:L.COMMAND,id:`sheet.command.set-worksheet-range-theme-style`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),{unitId:i}=t,a=vlt(e,t);return n.syncExecuteCommand(zG.id,t)?(r.pushUndoRedo({unitID:i,undoMutations:[{id:BG.id,params:a}],redoMutations:[{id:zG.id,params:t}]}),!0):!1}},Ydt={type:L.COMMAND,id:`sheet.command.append-row`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),{unitId:i,subUnitId:a,cellValue:o,insertRowNums:s,insertColumnNums:c,maxRows:l,maxColumns:u}=t,d={unitId:i,subUnitId:a,cellValue:o},f=cK(e,d),p=[{id:lK.id,params:d}],m=[{id:lK.id,params:f}];if(s){let t={unitId:i,subUnitId:a,range:{startRow:l,endRow:l,startColumn:0,endColumn:u-1}},n=VG(e,t);p.unshift({id:HG.id,params:t}),m.push({id:JG.id,params:n})}if(c){let t={unitId:i,subUnitId:a,range:{startRow:0,endRow:l-1,startColumn:u,endColumn:u-1+c}},n=UG(e,t);p.unshift({id:WG.id,params:t}),m.push({id:YG.id,params:n})}return Km(p,n).result?(r.pushUndoRedo({unitID:i,undoMutations:m,redoMutations:p}),!0):!1}},Xdt=[`ff`,`fs`,`tr`,`tb`],gJ={type:L.COMMAND,id:`sheet.command.set-style`,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{unitId:r,subUnitId:i,worksheet:a}=n,{range:o,style:s}=t,c=e.get(R),l=e.get(vx),u=e.get(WK),d=o?[o]:u.getCurrentSelections()?.map(e=>e.range);if(!d?.length)return!1;let f=new Rh,p=Vut(a);if(F.isArray(s.value))for(let e=0;e<d.length;e++)p.forOperableEach(d[e],(e,t,n)=>{f.setValue(e,t,{s:{[s.type]:s.value[e-n.startRow][t-n.startColumn]}})});else for(let e=0;e<d.length;e++){let t={s:{[s.type]:s.value}};p.forOperableEach(d[e],(e,n)=>f.setValue(e,n,t))}let m={subUnitId:i,unitId:r,cellValue:f.getMatrix()},h=e.get(qK).getSkeleton(r,i),g=cK(e,m),_=null;if(Xdt.includes(t?.style.type)){let{suitableRanges:e,remainingRanges:t}=YK(d,h);_={suitableRanges:e,remainingRanges:t,cellHeights:JK(e,a)}}let v=c.syncExecuteCommand(lK.id,m),y=e.get(PG),b=[],x=[];if(_){let{suitableRanges:e,remainingRanges:t,cellHeights:n}=_,{undos:a,redos:o}=y.generateMutationsOfAutoHeight({unitId:r,subUnitId:i,ranges:e,autoHeightRanges:e,lazyAutoHeightRanges:t,cellHeights:n});b=a,x=o}let{undos:S,redos:C}=y.onCommandExecute({id:gJ.id,params:t}),w=Km([...C,...x],c);return v&&w.result?(l.pushUndoRedo({unitID:m.unitId,undoMutations:[{id:lK.id,params:g},...S,...b],redoMutations:[{id:lK.id,params:m},...C,...x]}),!0):!1}},_J={type:L.COMMAND,id:`sheet.command.set-bold`,handler:e=>{let t=e.get(WK).getCurrentLastSelection();if(!t)return!1;let n=SG(e.get(z));if(!n)return!1;let{worksheet:r}=n,{actualRow:i,actualColumn:a}=t.primary,o={style:{type:`bl`,value:r.getRange(i,a).getFontWeight()===jp.BOLD?Np.FALSE:Np.TRUE}};return e.get(R).syncExecuteCommand(gJ.id,o)}},vJ={type:L.COMMAND,id:`sheet.command.set-italic`,handler:e=>{let t=e.get(WK).getCurrentLastSelection();if(!t)return!1;let n=SG(e.get(z));if(!n)return!1;let{worksheet:r}=n,i=!0;if(t.primary){let{startRow:e,startColumn:n}=t.primary;i=r.getRange(e,n).getFontStyle()===Ap.ITALIC}let a={style:{type:`it`,value:i?Np.FALSE:Np.TRUE}};return e.get(R).syncExecuteCommand(gJ.id,a)}},yJ={type:L.COMMAND,id:`sheet.command.set-underline`,handler:e=>{let t=e.get(WK).getCurrentLastSelection();if(!t)return!1;let n=SG(e.get(z));if(!n)return!1;let{worksheet:r}=n,i=!0;t.primary&&(i=!!r.getRange(t.primary.startRow,t.primary.startColumn).getUnderline().s);let a={style:{type:`ul`,value:{s:i?Np.FALSE:Np.TRUE}}};return e.get(R).syncExecuteCommand(gJ.id,a)}},bJ={type:L.COMMAND,id:`sheet.command.set-stroke`,handler:e=>{let t=e.get(WK).getCurrentLastSelection();if(!t)return!1;let n=SG(e.get(z));if(!n)return!1;let{worksheet:r}=n,i=!0;t.primary&&(i=!!r.getRange(t.primary.actualRow,t.primary.actualColumn).getStrikeThrough().s);let a={style:{type:`st`,value:{s:i?Np.FALSE:Np.TRUE}}};return e.get(R).syncExecuteCommand(gJ.id,a)}};L.COMMAND;var xJ={type:L.COMMAND,id:`sheet.command.set-font-family`,handler:(e,t)=>{if(!t)return!1;let n=e.get(R),r={style:{type:`ff`,value:t.value}};return n.syncExecuteCommand(gJ.id,r)}},SJ={type:L.COMMAND,id:`sheet.command.set-font-size`,handler:(e,t)=>{if(!t)return!1;let n=e.get(R),r={style:{type:`fs`,value:t.value}};return n.syncExecuteCommand(gJ.id,r)}},CJ={type:L.COMMAND,id:`sheet.command.set-text-color`,handler:(e,t)=>{if(!t)return!1;let n=e.get(R),r={style:{type:`cl`,value:{rgb:t.value}}};return n.syncExecuteCommand(gJ.id,r)}},Zdt={type:L.COMMAND,id:`sheet.command.reset-text-color`,handler:e=>e.get(R).syncExecuteCommand(gJ.id,{style:{type:`cl`,value:{rgb:null}}})},wJ={type:L.COMMAND,id:`sheet.command.set-background-color`,handler:(e,t)=>{if(!t||!t.value)return!1;let n=e.get(R),r={style:{type:`bg`,value:{rgb:t.value}}};return n.syncExecuteCommand(gJ.id,r)}},TJ={type:L.COMMAND,id:`sheet.command.reset-background-color`,handler:e=>e.get(R).syncExecuteCommand(gJ.id,{style:{type:`bg`,value:{rgb:null}}})},EJ={type:L.COMMAND,id:`sheet.command.set-vertical-text-align`,handler:(e,t)=>{if(!t)return!1;let n=e.get(R),r={unitId:t.unitId,subUnitId:t.subUnitId,range:t.range,style:{type:`vt`,value:t.value}};return n.syncExecuteCommand(gJ.id,r)}},DJ={type:L.COMMAND,id:`sheet.command.set-horizontal-text-align`,handler:(e,t)=>{if(!t)return!1;let n=e.get(R),r={unitId:t.unitId,subUnitId:t.subUnitId,range:t.range,style:{type:`ht`,value:t.value}};return n.syncExecuteCommand(gJ.id,r)}},OJ={type:L.COMMAND,id:`sheet.command.set-text-wrap`,handler:(e,t)=>{if(!t)return!1;let n=e.get(R),r={unitId:t.unitId,subUnitId:t.subUnitId,range:t.range,style:{type:`tb`,value:t.value}};return n.syncExecuteCommand(gJ.id,r)}},kJ={type:L.COMMAND,id:`sheet.command.set-text-rotation`,handler:(e,t)=>{if(!t)return!1;let n=typeof t.value==`number`?{a:t.value}:{a:0,v:Np.TRUE},r=e.get(R),i={unitId:t.unitId,subUnitId:t.subUnitId,range:t.range,style:{type:`tr`,value:n}};return r.syncExecuteCommand(gJ.id,i)}},AJ={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},jJ=[`零`,`一`,`二`,`三`,`四`,`五`,`六`,`七`,`八`,`九`],MJ=[``,`万`,`亿`,`万亿`,`亿亿`],Qdt=[``,`十`,`百`,`千`],NJ={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function PJ(e){if(!e)return 0;let t=0,n=0,r=0,i=!1,a=e.split(``);for(let e=0;e<a.length;e++){let o=AJ[a[e]];if(o!==void 0)r=o,e===a.length-1&&(n+=r);else{let o=NJ[a[e]],s=o.value;i=o.secUnit,i?(n=(n+r)*s,t+=n,n=0):n+=r*s,r=0}}return t+n}function $dt(e){let t=``,n=``,r=0,i=!0;for(;e>0;){let a=e%10;a===0?i||(i=!0,n=jJ[a]+n):(i=!1,t=jJ[a],t+=Qdt[r],n=t+n),r++,e=Math.floor(e/10)}return n}function eft(e){let t=0,n=``,r=``,i=!1;if(e===0)return jJ[0];for(;e>0;){let a=e%1e4;i&&(r=jJ[0]+r),n=$dt(a),n+=a===0?MJ[0]:MJ[t],r=n+r,i=a<1e3&&a>0,e=Math.floor(e/1e4),t++}return r}function tft(e){if(!e)return!1;let t=!0;if(e){if(e.length===1)t=e===`日`||e in AJ;else{let n=e.split(``);for(let e=0;e<n.length;e++)if(!(n[e]in AJ||n[e]in NJ)){t=!1;break}}}return t}function nft(e){if(!e)return{isExtendNumber:!1};let t=[...e.matchAll(/\d+/g)];if(!t.length)return{isExtendNumber:!1};let n=t[t.length-1],r=n[0],i=n.index,a=e.substring(0,i),o=e.substring(i+r.length);return{isExtendNumber:!0,rawMatchTxt:r,matchNumber:Number(r),beforeTxt:a,afterTxt:o}}function rft(e){let t;return t=e.length===1?e===`日`||PJ(e)<7:!1,t}function ift(e){let t;return t=e.length===2?e===`周一`||e===`周二`||e===`周三`||e===`周四`||e===`周五`||e===`周六`||e===`周日`:!1,t}function aft(e){let t;return t=e.length===3?e===`星期一`||e===`星期二`||e===`星期三`||e===`星期四`||e===`星期五`||e===`星期六`||e===`星期日`:!1,t}function oft(e,t){let n=0;for(let r=0;r<e.length&&e[r]<t;r++)n++;return n}function sft(e){if(e.length<3)return!0;let t=e[1]-e[0],n=!1;for(let r=2;r<e.length;r++){let i=e[r]-e[r-1];if(i!==t){if(n||i!==-t)return!1;t=i,n=!0}}return!0}function cft(e,t,n){let r=[],i=Math.floor(t/e),a=t%e,o=0;if(i>0){for(let t=0;t<i;t++)for(let i=0;i<n.length;i++)r[n[i]+t*e]=o,o++;for(let t=0;t<n.length&&n[t]<a;t++)r[n[t]+e*i]=o,o++}else for(let e=0;e<n.length&&n[e]<a;e++)r[n[e]]=o,o++;return r}function lft(e,t){let n=[];for(let r=1;r<=t;r++){let t=(r-1)%e.length,i=F.deepClone(e[t]);LJ(i),n.push({v:null,s:null,p:null,f:null,si:null,t:null,...i})}return n}function uft(e,t){let n=[];for(let r=1;r<=t;r++){let t={s:e[(r-1)%e.length]?.s};n.push(t)}return n}function dft(e){let t=!0,n=e[1]/e[0];for(let r=1;r<e.length;r++)if(e[r]/e[r-1]!==n){t=!1;break}return t}function fft(e){let t=[];for(let n=1;n<=e;n++)t.push(n);return t}function pft(e,t,n){let r=[],i=[];for(let t=0;t<e.length;t++)i.push(Number(e[t]?.v));if(e.length>2&&dft(i))for(let n=1;n<=t;n++){let t=(n-1)%e.length,i=F.deepClone(e[t]);LJ(i);let a=Number(e[e.length-1]?.v)*(Number(e[1]?.v)/Number(e[0]?.v))**n;i&&(IJ(i)&&(i.v=a),r.push(i))}else{let a=fft(e.length);for(let o=1;o<=t;o++){let t=(o-1)%e.length,s=F.deepClone(e[t]);LJ(s);let c=n===I.DOWN||n===I.RIGHT,l=mft(e.length+o,i,a,c);s&&(IJ(s)&&(s.v=l),r.push(s))}}return r}function mft(e,t,n,r=!0){function i(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}let a=i(n),o=i(t),s=0,c=0;for(let e=0;e<n.length;e++)s+=(n[e]-a)*(t[e]-o),c+=(n[e]-a)*(n[e]-a);let l;l=c===0?r?1:-1:s/c;let u=o-l*a;return Math.round((u+l*e)*1e5)/1e5}function hft(e,t,n){let r=[],i=e[e.length-1],a=nft(`${i?.v}`);if(!a.isExtendNumber)return lft(e,t);let{matchNumber:o,rawMatchTxt:s,beforeTxt:c,afterTxt:l}=a,u=s.length;for(let i=1;i<=t;i++){let t=(i-1)%e.length,a=F.deepClone(e[t]);if(LJ(a),!a||!a.v)continue;let s=Math.abs(o+n*i).toString();s.length<u&&(s=s.padStart(u,`0`));let d=`${c}${s}${l}`;a&&(a.v=d,r.push(a))}return r}function gft(e,t){let n=[];for(let r=1;r<=t;r++){let t=(r-1)%e.length,i=F.deepClone(e[t]);LJ(i),i&&(delete i.v,n.push(i))}return n}function _ft(e,t,n,r=0){let i=[[`日`,`一`,`二`,`三`,`四`,`五`,`六`],[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`],[`星期日`,`星期一`,`星期二`,`星期三`,`星期四`,`星期五`,`星期六`]];if(r>=i.length)return[];let a=i[r],o=[];for(let r=1;r<=t;r++){let t=(r-1)%e.length,i=F.deepClone(e[t]);LJ(i);let s=0;if(e[e.length-1]?.v===a[0])s=7+n*r;else{let t=`${e[e.length-1]?.v}`;t&&(s=PJ(t.substr(t.length-1,1))+n*r)}s<0&&(s=Math.ceil(Math.abs(s)/7)*7+s);let c=s%7;i&&(i.v=a[c],o.push(i))}return o}function vft(e,t,n){let r=[];for(let i=1;i<=t;i++){let t=(i-1)%e.length,a=F.deepClone(e[t]);LJ(a);let o=PJ(`${e[e.length-1]?.v}`)+n*i,s;s=o<=0?`零`:eft(o),a&&(a.v=s,r.push(a))}return r}var FJ={enWeek1:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],enWeek2:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],enMonth1:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],enMonth2:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],chnMonth1:[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`],chnMonth2:[`正月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`腊月`],chHour1:[`子`,`丑`,`寅`,`卯`,`辰`,`巳`,`午`,`未`,`申`,`酉`,`戌`,`亥`],chHour2:[`子时`,`丑时`,`寅时`,`卯时`,`辰时`,`巳时`,`午时`,`未时`,`申时`,`酉时`,`戌时`,`亥时`],chYear1:[`甲`,`乙`,`丙`,`丁`,`戊`,`己`,`庚`,`辛`,`壬`,`癸`],chSeason1:[`春`,`夏`,`秋`,`冬`],chSeason2:[`春季`,`夏季`,`秋季`,`冬季`]};function yft(e){let t=!1;return Object.keys(FJ).forEach(n=>{FJ[n].includes(e)&&(t=!0)}),t}function bft(e){let t=``,n=[];return Object.keys(FJ).forEach(r=>{FJ[r].includes(e)&&(t=r,n.push(...FJ[r]))}),{name:t,series:n}}function xft(e,t,n,r){let i=r.length,a=[];for(let o=1;o<=t;o++){let t=(o-1)%e.length,s=F.deepClone(e[t]);LJ(s);let c=`${e[e.length-1]?.v}`,l=r.indexOf(c)+n*o;l<0&&(l+=Math.abs(n)*i);let u=l%i;s&&(s.v=r[u],a.push(s))}return a}function Sft(e,t){let n=[],r;if(t.startRow<e.startRow)r=I.UP;else if(t.endRow>e.endRow)r=I.DOWN;else if(t.startColumn<e.startColumn)r=I.LEFT;else if(t.endColumn>e.endColumn)r=I.RIGHT;else return[];if(r===I.DOWN||r===I.UP){let i=e.endRow-e.startRow+1,a=t.endRow-t.startRow+1,o=Math.floor(a/i),s=a%i,c={startRow:0,startColumn:0,endRow:e.endRow-e.startRow,endColumn:e.endColumn-e.startColumn};if(r===I.DOWN){for(let t=0;t<o;t++)n.push({repeatStartCell:{row:e.startRow+(t+1)*i,col:e.startColumn},relativeRange:c});s>0&&n.push({repeatStartCell:{row:e.startRow+(o+1)*i,col:e.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:s-1,endColumn:e.endColumn-e.startColumn}})}else{for(let t=0;t<o;t++)n.push({repeatStartCell:{row:e.startRow-(t+1)*i,col:e.startColumn},relativeRange:c});s>0&&n.push({repeatStartCell:{row:e.startRow-(o+1)*i,col:e.startColumn},relativeRange:{startRow:i-s,endRow:i-1,startColumn:0,endColumn:e.endColumn-e.startColumn}})}}if(r===I.RIGHT||r===I.LEFT){let i=e.endColumn-e.startColumn+1,a=t.endColumn-t.startColumn+1,o=Math.floor(a/i),s=a%i,c={startRow:0,startColumn:0,endRow:e.endRow-e.startRow,endColumn:e.endColumn-e.startColumn};if(r===I.RIGHT){for(let t=0;t<o;t++)n.push({repeatStartCell:{row:e.startRow,col:e.startColumn+(t+1)*i},relativeRange:c});s>0&&n.push({repeatStartCell:{row:e.startRow,col:e.startColumn+(o+1)*i},relativeRange:{startRow:0,startColumn:0,endRow:e.endRow-e.startRow,endColumn:s-1}})}else{for(let t=0;t<o;t++)n.push({repeatStartCell:{row:e.startRow,col:e.startColumn-(t+1)*i},relativeRange:c});s>0&&n.push({repeatStartCell:{row:e.startRow,col:e.startColumn-(o+1)*i},relativeRange:{startRow:0,startColumn:i-s,endRow:e.endRow-e.startRow,endColumn:i-1}})}}return n}function IJ(e){return!(Uh(e.f)||Wh(e.si)||e.t===Pp.BOOLEAN)}function LJ(e){e&&`custom`in e&&delete e.custom}function Cft(e,t){return t?e.reverse():e}function wft(e){let t=new Rh;return e.forEach(e=>{let{rows:n,cols:r}=e;n.forEach(e=>{r.forEach(n=>{t.setValue(e,n,{v:null,s:null,p:null,f:null,si:null,custom:null})})})}),t.clone()}var RJ={chnNumChar:AJ,chnNumChar2:jJ,chnUnitSection:MJ,chnUnitChar:Qdt,chnNameValue:NJ,chineseToNumber:PJ,sectionToChinese:$dt,numberToChinese:eft,isChnNumber:tft,matchExtendNumber:nft,isChnWeek1:rft,isChnWeek2:ift,isChnWeek3:aft,getLenS:oft,isEqualDiff:sft,getDataIndex:cft,fillCopy:lft,fillCopyStyles:uft,isEqualRatio:dft,getXArr:fft,fillSeries:pft,forecast:mft,fillExtendNumber:hft,fillOnlyFormat:gft,fillChnWeek:_ft,fillChnNumber:vft,isLoopSeries:yft,getLoopSeriesInfo:bft,fillLoopSeries:xft,getAutoFillRepeatRange:Sft,needsUpdateCellValue:IJ,removeCellCustom:LJ,reverseIfNeed:Cft,generateNullCellValueRowCol:wft},zJ=function(e){return e.COPY=`COPY`,e.SERIES=`SERIES`,e.ONLY_FORMAT=`ONLY_FORMAT`,e.NO_FORMAT=`NO_FORMAT`,e}({}),Tft=function(e){return e.NUMBER=`number`,e.DATE=`date`,e.EXTEND_NUMBER=`extendNumber`,e.CHN_NUMBER=`chnNumber`,e.CHN_WEEK2=`chnWeek2`,e.CHN_WEEK3=`chnWeek3`,e.LOOP_SERIES=`loopSeries`,e.FORMULA=`formula`,e.OTHER=`other`,e}({}),Eft=function(e){return e.APPEND=`APPEND`,e.DEFAULT=`DEFAULT`,e.ONLY=`ONLY`,e}({}),{chineseToNumber:BJ,fillChnNumber:Dft,fillChnWeek:VJ,fillCopy:HJ,fillExtendNumber:Oft,fillLoopSeries:kft,fillSeries:UJ,getLoopSeriesInfo:WJ,isChnNumber:Aft,isChnWeek2:jft,isChnWeek3:Mft,isEqualDiff:GJ,isLoopSeries:Nft,matchExtendNumber:KJ,reverseIfNeed:qJ}=RJ,Pft={dateRule:{type:`date`,priority:1100,match:(e,t)=>{if(e?.f||e?.si)return!1;if((typeof e?.v==`number`||e?.t===Pp.NUMBER)&&e.s){if(typeof e.s==`string`){var n;let r=t.get(z).getCurrentUnitOfType(M.UNIVER_SHEET);if(!r)return!1;let i=r.getStyles().get(e.s),a=i==null||(n=i.n)==null?void 0:n.pattern;if(a)return ld(a).isDate}else if(e.s.n&&ld(e.s.n.pattern).isDate)return!0}return!1},isContinue:(e,t)=>e.type===`date`,applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e;return n===I.LEFT||n===I.UP?(r.reverse(),UJ(r,t,n).reverse()):UJ(r,t,n)}}},numberRule:{type:`number`,priority:1e3,match:e=>typeof e?.v==`number`||e?.t===Pp.NUMBER,isContinue:(e,t)=>e.type===`number`,applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e;return n===I.LEFT||n===I.UP?(r.reverse(),UJ(r,t,n).reverse()):UJ(r,t,n)}}},extendNumberRule:{type:`extendNumber`,priority:900,match:e=>KJ(`${e?.v}`||``).isExtendNumber,isContinue:(e,t)=>{if(e.type===`extendNumber`){let n=KJ(`${e.cellData?.v}`||``),r=KJ(`${t?.v}`||``);if(n.isExtendNumber&&r.isExtendNumber){let{beforeTxt:e,afterTxt:t}=n,{beforeTxt:i,afterTxt:a}=r;if(e===i&&t===a)return!0}}return!1},applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e,i=n===I.UP||n===I.LEFT,a;if(r.length===1)return a=i?-1:1,qJ(Oft(r,t,a),i);let o=[];for(let e=0;e<r.length;e++){let t=KJ(`${r[e]?.v}`);t.isExtendNumber&&o.push(t.matchNumber)}if(i&&(r.reverse(),o.reverse()),GJ(o)){let e=r.length;return a=o[e-1]-o[e-2],qJ(Oft(r,t,a),i)}return HJ(r,t)}}},chnNumberRule:{type:`chnNumber`,priority:830,match:e=>!!Aft(`${e?.v}`||``),isContinue:(e,t)=>e.type===`chnNumber`,applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e,i=n===I.LEFT||n===I.UP;if(r.length===1){let e=`${r[0]?.v}`,n;return n=i?-1:1,e&&(e===`日`||BJ(e)<7)?qJ(VJ(r,t,n),i):qJ(Dft(r,t,n),i)}let a=!1;for(let e=0;e<r.length;e++)if(r[e]?.v===`日`){a=!0;break}let o=[],s=0;for(let e=0;e<r.length;e++){let t=`${r[e]?.v}`;t===`日`?e===0?o.push(0):(s++,o.push(s*7)):a&&BJ(t)>0&&BJ(t)<7?o.push(BJ(t)+s*7):o.push(BJ(t))}if(i&&(r.reverse(),o.reverse()),GJ(o)){if(a||o[o.length-1]<6&&o[0]>0||o[0]<6&&o[o.length-1]>0){let e=r.length;return qJ(VJ(r,t,o[e-1]-o[e-2]),i)}return qJ(Dft(r,t,o[1]-o[0]),i)}return HJ(r,t)}}},chnWeek2Rule:{type:`chnWeek2`,priority:820,match:e=>!!jft(`${e?.v}`||``),isContinue:(e,t)=>e.type===`chnWeek2`,applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e,i=n===I.LEFT||n===I.UP;if(r.length===1){let e;return e=i?-1:1,qJ(VJ(r,t,e,1),i)}let a=[],o=0;for(let e=0;e<r.length;e++){let t=`${r[e]?.v}`,n=t?.substr(t.length-1,1);t===`周日`?e===0?a.push(0):(o++,a.push(o*7)):a.push(BJ(n)+o*7)}if(i&&(r.reverse(),a.reverse()),GJ(a)){let e=r.length;return qJ(VJ(r,t,a[e-1]-a[e-2],1),i)}return HJ(r,t)}}},chnWeek3Rule:{type:`chnWeek3`,priority:810,match:e=>Mft(`${e?.v}`||``),isContinue:(e,t)=>e.type===`chnWeek3`,applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e,i=n===I.LEFT||n===I.UP;if(r.length===1){let e;return e=i?-1:1,qJ(VJ(r,t,e,2),i)}let a=[],o=0;for(let e=0;e<r.length;e++){let t=`${r[e]?.v}`;if(t){let n=t.substr(t.length-1,1);t===`星期日`?e===0?a.push(0):(o++,a.push(o*7)):a.push(BJ(n)+o*7)}}if(i&&(r.reverse(),a.reverse()),GJ(a)){let e=r.length;return qJ(VJ(r,t,a[e-1]-a[e-2],2),i)}return HJ(r,t)}}},loopSeriesRule:{type:`loopSeries`,priority:800,match:e=>Nft(`${e?.v}`||``),isContinue:(e,t)=>e.type===`loopSeries`&&WJ(`${e.cellData?.v}`||``).name===WJ(`${t?.v}`||``).name,applyFunctions:{SERIES:(e,t,n)=>{let{data:r}=e,i=n===I.LEFT||n===I.UP,{series:a}=WJ(`${r[0]?.v}`||``);if(r.length===1){let e;return e=i?-1:1,qJ(kft(r,t,e,a),i)}let o=[],s=0;for(let e=0;e<r.length;e++){let t=`${r[e]?.v}`;t&&(t===a[0]?e===0?o.push(0):(s++,o.push(s*a.length)):o.push(a.indexOf(t)+s*7))}if(i&&(r.reverse(),o.reverse()),GJ(o)){let e=r.length;return qJ(kft(r,t,o[e-1]-o[e-2],a),i)}return HJ(r,t)}}},otherRule:{type:`other`,priority:0,match:()=>!0,isContinue:(e,t)=>e.type===`other`}},{chnNumberRule:Fft,chnWeek2Rule:Ift,chnWeek3Rule:Lft,dateRule:Rft,extendNumberRule:zft,loopSeriesRule:Bft,numberRule:Vft,otherRule:Hft}=Pft,JJ=class extends P{constructor(e,t,n,r){super(),this._commandService=e,this._undoRedoService=t,this._univerInstanceService=n,this._injector=r,Z(this,`_rules`,[]),Z(this,`_hooks`,[]),Z(this,`_applyType$`,new so(`SERIES`)),Z(this,`_isFillingStyle`,!0),Z(this,`_prevUndos`,[]),Z(this,`_autoFillLocation$`,new so(null)),Z(this,`autoFillLocation$`,this._autoFillLocation$.asObservable()),Z(this,`_showMenu$`,new so(!1)),Z(this,`showMenu$`,this._showMenu$.asObservable()),Z(this,`_direction`,I.DOWN),Z(this,`applyType$`,this._applyType$.asObservable()),Z(this,`_menu$`,new so([{label:`sheets.autoFill.copy`,value:`COPY`,disable:!1},{label:`sheets.autoFill.series`,value:`SERIES`,disable:!1},{label:`sheets.autoFill.formatOnly`,value:`ONLY_FORMAT`,disable:!1},{label:`sheets.autoFill.noFormat`,value:`NO_FORMAT`,disable:!1}])),Z(this,`menu$`,this._menu$.asObservable()),this._init()}_init(){this._rules=[Rft,Vft,zft,Fft,Ift,Lft,Bft,Hft].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((e,t)=>(t.priority||0)>(e.priority||0)?t:e,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,n,r,i){if(n.startColumn===r.startColumn&&n.startRow===r.startRow&&n.endColumn===r.endColumn&&n.endRow===r.endRow)return!1;if(r.endColumn<n.endColumn&&r.endColumn>n.startColumn)return this._commandService.executeCommand(ZJ.id,{clearRange:{startRow:r.startRow,endRow:r.endRow,startColumn:r.endColumn+1,endColumn:n.endColumn},selectionRange:r});if(r.endRow<n.endRow&&r.endRow>n.startRow)return this._commandService.executeCommand(ZJ.id,{clearRange:{startRow:r.endRow+1,endRow:n.endRow,startColumn:r.startColumn,endColumn:r.endColumn},selectionRange:r});let a={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn},o=null;if(r.startRow<n.startRow)o=I.UP,a.endRow=n.startRow-1;else if(r.endRow>n.endRow)o=I.DOWN,a.startRow=n.endRow+1;else if(r.startColumn<n.startColumn)o=I.LEFT,a.endColumn=n.startColumn-1;else if(r.endColumn>n.endColumn)o=I.RIGHT,a.startColumn=n.endColumn+1;else return!1;this.direction=o;let s=this._injector.invoke(e=>FK(n,e)),c=this._injector.invoke(e=>FK(a,e));if(!s||!c)return!1;this.autoFillLocation={source:s,target:c,unitId:e,subUnitId:t};let l=[];if(this.getActiveHooks().forEach(n=>{var r;let i=n==null||(r=n.onBeforeFillData)==null?void 0:r.call(n,{source:s,target:c,unitId:e,subUnitId:t},o);i&&l.unshift(i)}),this._initPrevUndo(),i)return this.fillData(i);for(let e=0;e<l.length;e++){let t=this.menu.find(t=>t.value===l[e]);if(t&&!t.disable)return this.fillData(l[e])}let u=this.menu.find(e=>e.disable===!1)?.value;return u?this.fillData(u):!1}addHook(e){if(this._hooks.find(t=>t.id===e.id))throw Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=`APPEND`),this._hooks.push(e),Wf(()=>{let t=this._hooks.findIndex(t=>t===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(t=>t.type===e.type))throw Error(`Registry rule failed, type '${e.type}' already exist!`);let t=this._rules.findIndex(t=>t.priority<e.priority);this._rules.splice(t===-1?this._rules.length:t,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){let{source:e,target:t,unitId:n,subUnitId:r}=this.autoFillLocation||{};if(!e||!t||!n||!r)return[];let i=this._hooks.filter(i=>!i.disable?.call(i,{source:e,target:t,unitId:n,subUnitId:r},this._direction,this.applyType)),a=i.filter(e=>e.type===`ONLY`);if(a.length>0)return this._getOneByPriority(a);let o=this._getOneByPriority(i.filter(e=>e.type===`DEFAULT`)),s=i.filter(e=>e.type===`APPEND`)||[];return[...o,...s]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,t){this._menu$.next(this._menu$.getValue().map(n=>n.value===e?{...n,disable:t}:n))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var t;this.applyType=e;let n=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET),r=n?.getUnitId(),i=n==null||(t=n.getActiveSheet())==null?void 0:t.getSheetId(),{source:a,target:o,unitId:s=r,subUnitId:c=i}=this.autoFillLocation||{};if(!a||!o||!s||!c)return!1;let l=this._univerInstanceService.getUnit(s,M.UNIVER_SHEET);if(!l)return!1;let u=l.getSheetBySheetId(c);if(!u)return!1;let d=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(e=>{this._commandService.syncExecuteCommand(e.id,e.params)}),this._prevUndos=[];let f=d_.union(PK(a),PK(o)),p=this.getActiveHooks();s===r&&c===i&&this._commandService.syncExecuteCommand(oq.id,{selections:[{primary:eq({startRow:a.rows[0],endRow:a.rows[a.rows.length-1],startColumn:a.cols[0],endColumn:a.cols[a.cols.length-1]},u),range:{...f,rangeType:vh.NORMAL}}],unitId:s,subUnitId:c});let m=[],h=[];p.forEach(t=>{let{undos:n,redos:r}=t.onFillData?.call(t,{source:a,target:o,unitId:s,subUnitId:c},d,e)||{};n&&m.push(...n),r&&h.push(...r)});let g=h.every(e=>this._commandService.syncExecuteCommand(e.id,e.params)),{redos:_,undos:v}=this._getAutoHeightUndoRedos(h,l,u);return h.push(..._),m.push(...v),g&&(this._prevUndos=m,this._undoRedoService.pushUndoRedo({unitID:s,undoMutations:m,redoMutations:h})),p.forEach(t=>{var n;(n=t.onAfterFillData)==null||n.call(t,{source:a,target:o,unitId:s,subUnitId:c},d,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,n){if(this.applyType===`NO_FORMAT`)return{undos:[],redos:[]};let r=[],i=n.getConfig().defaultRowHeight,a=n.getRowManager();if(e.forEach(e=>{if(e.id===lK.id){let{cellValue:o}=e.params;new Rh(o).forValue((e,o,s)=>{let c=Object.keys(t.getStyles().get(s?.s)||{});if(s?.p||c.length&&Xdt.some(e=>c.includes(e))){let t=n.getCellHeight(e,o),s=a.getRow(e);(!s&&t!==i||s&&t!==a.getRowHeight(e))&&r.push({row:e,autoHeight:t})}})}}),r.length===0)return{undos:[],redos:[]};let o={unitId:t.getUnitId(),subUnitId:n.getSheetId(),rowsAutoHeightInfo:r},s=yK(o,n),c={id:SK.id,params:o};return this._commandService.syncExecuteCommand(c.id,c.params)?{redos:[c],undos:[{id:SK.id,params:s}]}:{undos:[],redos:[]}}};JJ=AG([kG(0,R),kG(1,vx),kG(2,j(z)),kG(3,j(We))],JJ);var YJ=ce(`univer.auto-fill-service`),XJ={type:L.COMMAND,id:`sheet.command.auto-fill`,handler:async(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{unitId:r,subUnitId:i}=n,{sourceRange:a,targetRange:o,applyType:s}=t;return e.get(YJ).triggerAutoFill(r,i,a,o,s)}};function Uft(e,t){let n=e.get(WK).getCurrentLastSelection();if(!n)return null;let r=SG(e.get(z));if(!r)return null;let{unitId:i,subUnitId:a}=r,{startRow:o,endRow:s,startColumn:c,endColumn:l}=n.range;return t===`down`?o===s?o===0?null:{sourceRange:{startRow:o-1,endRow:o-1,startColumn:c,endColumn:l},targetRange:{startRow:o-1,endRow:s,startColumn:c,endColumn:l},unitId:i,subUnitId:a,applyType:`COPY`}:{sourceRange:{startRow:o,endRow:o,startColumn:c,endColumn:l},targetRange:{startRow:o,endRow:s,startColumn:c,endColumn:l},unitId:i,subUnitId:a,applyType:`COPY`}:c===l?c===0?null:{sourceRange:{startRow:o,endRow:s,startColumn:c-1,endColumn:c-1},targetRange:{startRow:o,endRow:s,startColumn:c-1,endColumn:l},unitId:i,subUnitId:a,applyType:`COPY`}:{sourceRange:{startRow:o,endRow:s,startColumn:c,endColumn:c},targetRange:{startRow:o,endRow:s,startColumn:c,endColumn:l},unitId:i,subUnitId:a,applyType:`COPY`}}async function Wft(e,t){let n=Uft(e,t);if(!n)return!1;let r=await e.get(R).executeCommand(XJ.id,n);return r&&e.get(YJ).setShowMenu(!1),r}var Gft={type:L.COMMAND,id:`sheet.command.copy-down`,handler:async e=>Wft(e,`down`)},Kft={type:L.COMMAND,id:`sheet.command.copy-right`,handler:async e=>Wft(e,`right`)},ZJ={id:`sheet.command.auto-clear-content`,type:L.COMMAND,handler:async(e,t)=>{let n=SG(e.get(z));if(!n)return!1;let r=e.get(R),i=e.get(vx),a=e.get(PG),o=e.get(WK),{unitId:s,subUnitId:c}=n,{clearRange:l,selectionRange:u}=t,{startColumn:d,startRow:f}=u,p={subUnitId:c,unitId:s,cellValue:Mut([l])},m=cK(e,p),h=[{id:lK.id,params:p},{id:oq.id,params:{selections:[{primary:{startColumn:d,startRow:f,endColumn:d,endRow:f,actualRow:f,actualColumn:d,isMerged:!1,isMergedMainCell:!1},range:{...u}}],unitId:s,subUnitId:c}}],g=[{id:lK.id,params:m},{id:oq.id,params:{selections:[o.getCurrentLastSelection()],unitId:s,subUnitId:c}}];if(Km(h,r).result){let e=a.afterCommandExecute({id:lK.id,params:p});return Km(e.redos,r),i.pushUndoRedo({unitID:s,undoMutations:[...g,...e.undos],redoMutations:[...h,...e.redos]}),!0}return!1}},QJ={id:`sheet.command.clear-selection-content`,type:L.COMMAND,handler:(e,t)=>{let n=SG(e.get(z),{unitId:t?.unitId,subUnitId:t?.subUnitId});if(!n)return!1;let r=e.get(WK),{unitId:i,subUnitId:a}=n,o=t?.ranges||r.getCurrentSelections()?.map(e=>e.range);if(!o?.length)return!1;let s=e.get(qK).getSkeleton(i,a);if(!s)return!1;let c=e.get(R),l=e.get(vx),u=e.get(PG),d=[],f=[],p={subUnitId:a,unitId:i,cellValue:Mut(IK(o,e,i,a))},m=cK(e,p);d.push({id:lK.id,params:p}),f.push({id:lK.id,params:m});let h=u.onCommandExecute({id:QJ.id,params:t});d.push(...h.redos),f.unshift(...h.undos);let g=Km(d,c),{suitableRanges:_,remainingRanges:v}=YK(o,s),{undos:y,redos:b}=u.generateMutationsOfAutoHeight({unitId:i,subUnitId:a,ranges:_,autoHeightRanges:_,lazyAutoHeightRanges:v}),x=Km(b,c);return g.result&&x.result?(d.push(...b),f.push(...y),l.pushUndoRedo({unitID:i,undoMutations:f,redoMutations:d}),!0):!1}},$J=`sheets.config`,eY={largeSheetCellCountThreshold:6e3,batchSize:3e3},qft={},tY=class extends P{constructor(e,t){super(),this._commandService=e,this._univerInstanceService=t,Z(this,`_tasks`,new Map),Z(this,`_idleCallbackId`,null),Z(this,`_beforeUnloadHandler`,null),this._setupBeforeUnloadListener(),this.disposeWithMe(()=>{this._cancelAllTasks(),this._removeBeforeUnloadListener()})}hasPendingTasks(){return this._tasks.size>0}getPendingMutationsCount(){let e=0;for(let t of this._tasks.values())e+=t.mutations.length-t.currentIndex;return e}scheduleMutations(e,t,n){if(n.length===0)return;let r=`${e}_${t}`;this._cancelTask(r),this._tasks.set(r,{unitId:e,subUnitId:t,mutations:n,currentIndex:0}),this._scheduleNextIdle()}cancelScheduledMutations(e,t){let n=`${e}_${t}`;this._cancelTask(n)}_cancelTask(e){this._tasks.delete(e),this._tasks.size===0&&this._idleCallbackId!==null&&(typeof cancelIdleCallback<`u`&&cancelIdleCallback(this._idleCallbackId),this._idleCallbackId=null)}_cancelAllTasks(){this._tasks.clear(),this._idleCallbackId!==null&&(typeof cancelIdleCallback<`u`&&cancelIdleCallback(this._idleCallbackId),this._idleCallbackId=null)}_scheduleNextIdle(){this._idleCallbackId===null&&(this._idleCallbackId=typeof requestIdleCallback<`u`?requestIdleCallback(e=>this._processIdleTasks(e),{timeout:6e4}):setTimeout(()=>{this._processIdleTasks({didTimeout:!1,timeRemaining:()=>16})},16))}_processIdleTasks(e){this._idleCallbackId=null;for(let[t,n]of this._tasks){if(!this._isSheetExist(n.unitId,n.subUnitId)){this._tasks.delete(t);continue}for(n.currentIndex;n.currentIndex<n.mutations.length;){if(e.timeRemaining()<=0&&!e.didTimeout){this._scheduleNextIdle();return}let t=n.mutations[n.currentIndex];this._commandService.syncExecuteCommand(t.id,t.params,{onlyLocal:!0}),n.currentIndex++}this._tasks.delete(t)}this._tasks.size>0&&this._scheduleNextIdle()}_isSheetExist(e,t){let n=this._univerInstanceService.getUnit(e,M.UNIVER_SHEET);return n?n.getSheetBySheetId(t)!==null:!1}_setupBeforeUnloadListener(){typeof window>`u`||(this._beforeUnloadHandler=e=>{if(this.hasPendingTasks())return e.preventDefault(),e.returnValue=``,``},window.addEventListener(`beforeunload`,this._beforeUnloadHandler))}_removeBeforeUnloadListener(){typeof window>`u`||!this._beforeUnloadHandler||(window.removeEventListener(`beforeunload`,this._beforeUnloadHandler),this._beforeUnloadHandler=null)}};tY=AG([kG(0,R),kG(1,z)],tY);var Jft={id:`sheet.mutation.copy-worksheet-end`,type:L.MUTATION,handler:()=>!0},Yft=(e,t)=>({subUnitId:t.sheet.id,unitId:t.unitId,subUnitName:t.sheet.name}),nY={id:`sheet.mutation.insert-sheet`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z),{sheet:r,index:i,unitId:a,styles:o}=t,s=n.getUniverSheetInstance(a);return s?(o&&s.addStyles(o),s.addWorksheet(r.id,i,Fb(r))):!1}};function Xft(e){let t=0;for(let n of Object.keys(e)){let r=e[Number(n)];r&&(t+=Object.keys(r).length)}return t}function Zft(e,t,n,r){let i=[],a={},o=0;for(let e in n){let t=Number(e),s=n[t];if(!s)continue;let c=Object.keys(s).length;o>0&&o+c>r&&(i.push(a),a={},o=0),a[t]=s,o+=c,o>=r&&(i.push(a),a={},o=0)}return o>0&&i.push(a),{firstChunkCellData:i.length>0?i[0]:{},remainingMutations:i.slice(1).map(n=>({id:lK.id,params:{unitId:e,subUnitId:t,cellValue:n,__splitChunk__:!0}}))}}var Qft=`sheet.command.copy-sheet`;function $ft(e,t,n,r,i,a,o){let s=e.get(Nm).getConfig($J),c={...eY,...s?.largeSheetOperation},l=Fb(n.getConfig());l.name=ept(t,a,l.name);let u=ip();l.id=u;let d=t.getSheetIndex(n),{cellData:f}=l,p=Xft(f)>=c.largeSheetCellCountThreshold,m,h=[];if(p){let{firstChunkCellData:e,remainingMutations:t}=Zft(r,u,f,c.batchSize),n={...l,cellData:e};m={index:d+1,sheet:n,unitId:r},h=t}else m={index:d+1,sheet:l,unitId:r};let g=Yft(e,m),_=o.onCommandExecute({id:Qft,params:{unitId:r,subUnitId:i,targetSubUnitId:l.id}});return{redos:[..._.preRedos??[],{id:nY.id,params:m},..._.redos],undos:[..._.preUndos??[],{id:Aq.id,params:g},..._.undos],unitId:r,newSheetId:u,isSplit:p,scheduledMutations:h}}var rY={type:L.COMMAND,id:Qft,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(PG),o=e.get(nx),s=e.get(tY),c=SG(i,t);if(!c)return!1;let{workbook:l,worksheet:u,unitId:d,subUnitId:f}=c,{redos:p,undos:m,newSheetId:h,isSplit:g,scheduledMutations:_}=$ft(e,l,u,d,f,o,a);if(Km(p,n).result){if(g){if(r.pushUndoRedo({unitID:d,undoMutations:m,redoMutations:[]}),_.length>0){for(let e of _)n.syncExecuteCommand(e.id,e.params,{syncOnly:!0});n.syncExecuteCommand(Jft.id,{unitId:d,subUnitId:h},{syncOnly:!0}),s.scheduleMutations(d,h,_)}}else r.pushUndoRedo({unitID:d,undoMutations:m,redoMutations:p});return!0}return!1}};function ept(e,t,n){let r=`${n} ${t.t(`sheets.tabs.sheetCopy`,``)}`,i=2;for(;e.checkSheetName(r);)r=`${n} ${t.t(`sheets.tabs.sheetCopy`,`${i}`)}`,i++;return r}var tpt={type:L.COMMAND,id:`sheet.command.delete-range-protection`,async handler(e,t){if(!t)return!1;let n=e.get(R),r=e.get(vx),{unitId:i,subUnitId:a,rule:o}=t,s={unitId:i,subUnitId:a,ruleIds:[o.id]};return await n.executeCommand(VK.id,s)&&r.pushUndoRedo({unitID:i,redoMutations:[{id:VK.id,params:s}],undoMutations:[{id:HK.id,params:{unitId:i,subUnitId:a,rules:[o]}}]}),!0}},iY={type:L.COMMAND,id:`sheet.command.delete-worksheet-protection`,handler(e,t){if(!t)return!1;let n=e.get(R),r=e.get(vx),{rule:i,unitId:a,subUnitId:o}=t;n.executeCommand(mJ.id,{unitId:a,subUnitId:o});let s=[{id:mJ.id,params:{unitId:a,subUnitId:o}}],c=[{id:pJ.id,params:{unitId:a,rule:i,subUnitId:o}}];return r.pushUndoRedo({unitID:a,redoMutations:s,undoMutations:c}),!0}},npt={type:L.COMMAND,id:`sheet.command.remove-worksheet-range-theme-style`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),{unitId:i}=t,a=ylt(e,t);return n.syncExecuteCommand(BG.id,t)?(r.pushUndoRedo({unitID:i,undoMutations:[{id:zG.id,params:a}],redoMutations:[{id:BG.id,params:t}]}),!0):!1}},aY={id:`sheet.command.insert-defined-name`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(vx);if(!t)return!1;let i={...t};return n.syncExecuteCommand(Iz.id,i)?(r.pushUndoRedo({unitID:t.unitId,undoMutations:[{id:Lz.id,params:i}],redoMutations:[{id:Iz.id,params:i}]}),!0):!1}},oY={id:`sheet.command.insert-sheet`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(nx),o=Xct(i,{unitId:t?.unitId});if(!o)return!1;let{unitId:s,workbook:c}=o,l=c.getSheets().length,u=t?.sheet,d=u?.id,f=u?.name,p=Bb(u||{});t?(l=t.index??l,p.id=d||ip(),p.name=f?c.uniqueSheetName(f):c.generateNewSheetName(`${a.t(`sheets.tabs.sheet`)}`)):(p.id=ip(),p.name=c.generateNewSheetName(`${a.t(`sheets.tabs.sheet`)}`));let m={index:l,sheet:p,unitId:s},h=Yft(e,m);return n.syncExecuteCommand(nY.id,m)?(r.pushUndoRedo({unitID:s,undoMutations:[{id:Aq.id,params:h}],redoMutations:[{id:nY.id,params:m}]}),!0):!1}},sY={id:`sheet.command.refill`,type:L.COMMAND,handler:async(e,t)=>e.get(YJ).fillData(t.type)},cY={id:`sheet.mutation.register-worksheet-range-theme-style`,type:L.MUTATION,handler:(e,t)=>{if(!SG(e.get(z),t))return!1;let n=e.get(RG),{unitId:r,rangeThemeStyleJson:i,themeName:a}=t,o=new LG(a,i);return n.registerRangeThemeStyle(r,o),!0}},lY={id:`sheet.mutation.unregister-worksheet-range-theme-style`,type:L.MUTATION,handler:(e,t)=>{if(!SG(e.get(z),t))return!1;let n=e.get(RG),{unitId:r,themeName:i}=t;return n.unregisterRangeThemeStyle(r,i),!0}},rpt={id:`sheet.command.register-worksheet-range-theme-style`,type:L.COMMAND,handler:(e,t)=>{if(!t)return!1;let{unitId:n,rangeThemeStyle:r}=t,i=e.get(z),a=e.get(R),o=e.get(vx);if(!SG(i,t))return!1;let s={unitId:n,themeName:r.getName(),rangeThemeStyleJson:r.toJson()},c={unitId:n,themeName:r.getName()};return a.syncExecuteCommand(cY.id,s)&&o.pushUndoRedo({unitID:n,undoMutations:[{id:lY.id,params:c}],redoMutations:[{id:cY.id,params:s}]}),!0}},uY={id:`sheet.command.remove-defined-name`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(PG);if(!t)return!1;let a={...t},o=i.onCommandExecute({id:uY.id,params:t}),s=[...o.preRedos??[],{id:Lz.id,params:a},...o.redos],c=[...o.preUndos??[],{id:Iz.id,params:a},...o.undos];return Km(s,n).result?(r.pushUndoRedo({unitID:t.unitId,undoMutations:c.filter(Boolean),redoMutations:s.filter(Boolean)}),!0):!1}},dY={id:`sheet.command.remove-sheet`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(PG),o=e.get(Nm),s=SG(i,t);if(!s)return!1;let{unitId:c,subUnitId:l,workbook:u,worksheet:d}=s;if(u.getSheets().length<=1)return!1;let f=o.getConfig($J),p={...eY,...f?.largeSheetOperation},m=Rut(d.getCellMatrix())>=p.largeSheetCellCountThreshold,h={subUnitId:l,unitId:c,subUnitName:d.getName()},g=m?null:adt(e,h),_=a.onCommandExecute({id:dY.id,params:{unitId:c,subUnitId:l}}),v=[..._.preRedos??[],{id:Aq.id,params:h},..._.redos],y=m?[]:[..._.preUndos??[],{id:nY.id,params:g},..._.undos];return Km(v,n).result?(m?r.clearUndoRedo(c):r.pushUndoRedo({unitID:c,undoMutations:y,redoMutations:v}),!0):!1}},fY=class{constructor(){Z(this,`_borderInfo`,{type:dp.ALL,color:`#000000`,style:up.THIN,activeBorderType:!1}),Z(this,`_borderInfo$`,new so(this._borderInfo)),Z(this,`borderInfo$`,this._borderInfo$.asObservable())}dispose(){this._borderInfo$.complete()}setType(e){this._borderInfo.type=e,this.setActiveBorderType(!0),this._refresh()}setColor(e){this._borderInfo.color=e,this._refresh()}setStyle(e){this._borderInfo.style=e,this._refresh()}setActiveBorderType(e){this._borderInfo.activeBorderType=e}getBorderInfo(){return this._borderInfo}_refresh(){this._borderInfo$.next(this._borderInfo)}};function pY(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}var mY=(e,t,n,r)=>{let{mr:i,worksheet:a}=e;t.startRow<0||t.startColumn<0||pY(t,(e,t)=>{let o=a.getMergedCell(e,t),s=n;if(o&&(n.bc_tr||n.ml_tr||n.bl_tr||n.tl_mr||n.tl_bc||n.tl_br)){if(r){let e=F.deepClone(i.getValue(o.startRow,o.startColumn)?.s);s=e?.bd?Object.assign(e.bd,n):n}i.setValue(o.startRow,o.startColumn,{s:{bd:s}})}else{if(r){let r=F.deepClone(i.getValue(e,t)?.s);s=r?.bd?Object.assign(r.bd,n):n}i.setValue(e,t,{s:{bd:s}})}})},ipt=e=>({topRangeOut:{startRow:e.startRow-1,startColumn:e.startColumn,endRow:e.startRow-1,endColumn:e.endColumn},leftRangeOut:{startRow:e.startRow,startColumn:e.startColumn-1,endRow:e.endRow,endColumn:e.startColumn-1},bottomRangeOut:{startRow:e.endRow+1,startColumn:e.startColumn,endRow:e.endRow+1,endColumn:e.endColumn},rightRangeOut:{startRow:e.startRow,startColumn:e.endColumn+1,endRow:e.endRow,endColumn:e.endColumn+1},topRange:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.startRow,endColumn:e.endColumn},leftRange:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.startColumn},bottomRange:{startRow:e.endRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn},rightRange:{startRow:e.startRow,startColumn:e.endColumn,endRow:e.endRow,endColumn:e.endColumn}});function apt(e,t,n){let{style:r,color:i,type:a}=e.getBorderInfo(),o=a===dp.TOP||a===dp.ALL||a===dp.OUTSIDE,s=a===dp.LEFT||a===dp.ALL||a===dp.OUTSIDE,c=a===dp.BOTTOM||a===dp.ALL||a===dp.OUTSIDE,l=a===dp.RIGHT||a===dp.ALL||a===dp.OUTSIDE,u=a===dp.VERTICAL||a===dp.ALL||a===dp.INSIDE,d=a===dp.HORIZONTAL||a===dp.ALL||a===dp.INSIDE,f=a.indexOf(`tlbr`)>-1,p=a.indexOf(`tlbc`)>-1,m=a.indexOf(`tlmr`)>-1,h=a.indexOf(`bltr`)>-1,g=a.indexOf(`mltr`)>-1,_=a.indexOf(`bctr`)>-1,v=n[0],{topRangeOut:y,leftRangeOut:b,bottomRangeOut:x,rightRangeOut:S,topRange:C,leftRange:w,bottomRange:T,rightRange:E}=ipt(v),D=new Rh,{worksheet:O,unitId:k,subUnitId:A}=t;return{worksheet:O,unitId:k,subUnitId:A,style:r,color:i,type:a,top:o,left:s,right:l,bottom:c,vertical:u,horizontal:d,tl_br:f,tl_bc:p,tl_mr:m,bl_tr:h,ml_tr:g,bc_tr:_,topRangeOut:y,leftRangeOut:b,bottomRangeOut:x,rightRangeOut:S,topRange:C,leftRange:w,bottomRange:T,rightRange:E,range:v,mr:D,borderStyle:{s:r,cl:{rgb:i}}}}var opt=e=>{let{range:t,mr:n,borderStyle:r,vertical:i,horizontal:a,worksheet:o}=e;i&&pY(t,(e,i)=>{let a=o.getMergedCell(e,i);if(a){let o=n.getValue(a.startRow,a.startColumn)?.s;a.startColumn!==t.startColumn&&n.setValue(e,i,{s:{bd:o?.bd?Object.assign(o.bd,{l:F.deepClone(r)}):{l:F.deepClone(r)}}})}else{if(i!==t.endColumn){let t=n.getValue(e,i)?.s;n.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{r:F.deepClone(r)}):{r:F.deepClone(r)}}})}if(i!==t.startColumn){let t=n.getValue(e,i)?.s;n.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{l:F.deepClone(r)}):{l:F.deepClone(r)}}})}}}),a&&pY(t,(e,i)=>{let a=o.getMergedCell(e,i);if(a){let o=n.getValue(a.startRow,a.startColumn)?.s;a.startRow!==t.startRow&&n.setValue(e,i,{s:{bd:o?.bd?Object.assign(o.bd,{t:F.deepClone(r)}):{t:F.deepClone(r)}}})}else{if(e!==t.endRow){let t=n.getValue(e,i)?.s;n.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{b:F.deepClone(r)}):{b:F.deepClone(r)}}})}if(e!==t.startRow){let t=n.getValue(e,i)?.s;n.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{t:F.deepClone(r)}):{t:F.deepClone(r)}}})}}})};function spt(e){let{borderStyle:t,tl_br:n,tl_bc:r,tl_mr:i,bl_tr:a,ml_tr:o,bc_tr:s}=e,c=(t,n,r)=>{mY(e,t,n,r)};n&&c(e.range,{tl_br:F.deepClone(t)},!0),r&&c(e.range,{tl_bc:F.deepClone(t)},!0),i&&c(e.range,{tl_mr:F.deepClone(t)},!0),a&&c(e.range,{bl_tr:F.deepClone(t)},!0),o&&c(e.range,{ml_tr:F.deepClone(t)},!0),s&&c(e.range,{bc_tr:F.deepClone(t)},!0)}var cpt=e=>{let{top:t,left:n,right:r,bottom:i,borderStyle:a,bottomRange:o,topRange:s,leftRange:c,rightRange:l,bottomRangeOut:u,topRangeOut:d,leftRangeOut:f,rightRangeOut:p}=e,m=(t,n,r)=>{mY(e,t,n,r)};t&&(m(d,{b:null}),m(s,{t:F.deepClone(a)},!0)),i&&(m(u,{t:null}),m(o,{b:F.deepClone(a)},!0)),n&&(m(f,{r:null}),m(c,{l:F.deepClone(a)},!0)),r&&(m(p,{l:null}),m(l,{r:F.deepClone(a)},!0))},lpt=e=>{let{range:t,worksheet:n,mr:r,top:i,bottom:a,left:o,right:s,vertical:c,horizontal:l,tl_br:u,tl_bc:d,tl_mr:f,bl_tr:p,ml_tr:m,bc_tr:h,topRange:g,bottomRange:_,leftRange:v,rightRange:y,topRangeOut:b,bottomRangeOut:x,leftRangeOut:S,rightRangeOut:C}=e,w=(t,n,r)=>{mY(e,t,n,r)};!i&&!a&&!o&&!s&&!c&&!l&&!u&&!d&&!f&&!p&&!m&&!h&&(pY(t,(e,i)=>{let a=n.getMergedCell(e,i);if(a){if(a.endColumn!==t.endColumn){let t=r.getValue(a.startRow,a.startColumn)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{r:null}):{r:null}}})}if(a.startColumn!==t.startColumn){let t=r.getValue(a.startRow,a.startColumn)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{l:null}):{l:null}}})}if(a.endRow!==t.endRow){let t=r.getValue(a.startRow,a.startColumn)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{b:null}):{b:null}}})}if(a.startRow!==t.startRow){let t=r.getValue(a.startRow,a.startColumn)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{t:null}):{t:null}}})}}else{if(i!==t.endColumn){let t=r.getValue(e,i)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{r:null}):{r:null}}})}if(i!==t.startColumn){let t=r.getValue(e,i)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{l:null}):{l:null}}})}if(e!==t.endRow){let t=r.getValue(e,i)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{b:null}):{b:null}}})}if(e!==t.startRow){let t=r.getValue(e,i)?.s;r.setValue(e,i,{s:{bd:t?.bd?Object.assign(t.bd,{t:null}):{t:null}}})}}}),w(b,{b:null}),w(g,{t:null},!0),w(x,{t:null}),w(_,{b:null},!0),w(S,{r:null}),w(v,{l:null},!0),w(C,{l:null}),w(y,{r:null},!0),w(t,{tl_br:null},!0),w(t,{tl_bc:null},!0),w(t,{tl_mr:null},!0),w(t,{bl_tr:null},!0),w(t,{ml_tr:null},!0),w(t,{bc_tr:null},!0))},hY={id:`sheet.command.set-border`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(z),a=e.get(WK),o=e.get(fY),s=SG(i,t);if(!s)return!1;let c=t?.ranges||a.getCurrentSelections()?.map(e=>e.range);if(!c?.length)return!1;let{activeBorderType:l}=o.getBorderInfo();if(!l)return!1;let u=apt(o,s,c);opt(u),cpt(u),spt(u),lpt(u);let{unitId:d,subUnitId:f,mr:p}=u,m={unitId:d,subUnitId:f,cellValue:p.getData()},h=cK(e,m);return n.syncExecuteCommand(lK.id,m)?(r.pushUndoRedo({unitID:d,undoMutations:[{id:lK.id,params:h}],redoMutations:[{id:lK.id,params:m}]}),!0):!1}},upt={id:`sheet.command.set-border-position`,type:L.COMMAND,handler:(e,t)=>{if(!t.value)return!1;let n=e.get(R);return e.get(fY).setType(t.value),n.syncExecuteCommand(hY.id)}},dpt={id:`sheet.command.set-border-style`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R);return e.get(fY).setStyle(t.value),n.syncExecuteCommand(hY.id)}},fpt={id:`sheet.command.set-border-color`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R);return e.get(fY).setColor(t.value),n.syncExecuteCommand(hY.id)}},gY={id:`sheet.command.set-border-basic`,type:L.COMMAND,handler:(e,t)=>{let{unitId:n,subUnitId:r,value:i,ranges:a}=t,{type:o,color:s,style:c}=i,l=e.get(R),u=e.get(fY);return u.setType(o),s&&u.setColor(s),u.setStyle(c),l.syncExecuteCommand(hY.id,{unitId:n,subUnitId:r,ranges:a})}},_Y={type:L.COMMAND,id:`sheet.command.set-col-data`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),t);if(!i)return!1;let{columnData:a}=t,{unitId:o,subUnitId:s,worksheet:c}=i,l={subUnitId:s,unitId:o,columnData:a},u=Dlt(l,c);return n.syncExecuteCommand($G.id,l)?(r.pushUndoRedo({unitID:o,undoMutations:[{id:$G.id,params:u}],redoMutations:[{id:$G.id,params:l}]}),!0):!1}},vY={type:L.COMMAND,id:`sheet.command.set-col-visible-on-cols`,handler:(e,t)=>{let{unitId:n,subUnitId:r,ranges:i}=t,a=e.get(PG),o=e.get(R),s=SG(e.get(z),{unitId:n,subUnitId:r});if(!s)return!1;let{worksheet:c}=s,l={unitId:n,subUnitId:r,ranges:i},u={unitId:n,subUnitId:r,reveal:!0,selections:i.map(e=>({range:e,primary:eq(e,c),style:null}))},d=klt(e,l),f={unitId:n,subUnitId:r,selections:mpt(i).map(e=>({range:e,primary:eq(e,c),style:null}))},p=Km([{id:tK.id,params:l},{id:oq.id,params:u}],o),m=a.onCommandExecute({id:vY.id,params:t}),h=Km([...m.redos],o);if(p.result&&h.result){let r=a.afterCommandExecute({id:vY.id,params:t});return Km(r.redos,o),e.get(vx).pushUndoRedo({unitID:n,undoMutations:[{id:eK.id,params:d},{id:oq.id,params:f},...m.undos??[],...r.undos],redoMutations:[...m.preRedos??[],{id:tK.id,params:l},{id:oq.id,params:u},...m.redos,...r.redos]}),!0}return!0}},yY={type:L.COMMAND,id:`sheet.command.set-selected-cols-visible`,handler:e=>{let t=e.get(WK),n=e.get(R),r=t.getCurrentSelections()?.map(e=>e.range).filter(e=>e.rangeType===vh.COLUMN);if(!r?.length)return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,unitId:o,subUnitId:s}=i,c=r.map(e=>a.getHiddenCols(e.startColumn,e.endColumn)).flat();return n.executeCommand(vY.id,{unitId:o,subUnitId:s,ranges:c})}},bY={type:L.COMMAND,id:`sheet.command.set-col-hidden`,handler:(e,t)=>{var n;let r=e.get(WK),i=e.get(PG),a=e.get(z),o=e.get(R),s=t!=null&&(n=t.ranges)!=null&&n.length?t.ranges:r.getCurrentSelections()?.map(e=>e.range).filter(e=>e.rangeType===vh.COLUMN);if(!s?.length)return!1;let c=SG(a,t);if(!c)return!1;let{worksheet:l,unitId:u,subUnitId:d}=c;s=ppt(c.worksheet,s);let f={unitId:u,subUnitId:d,ranges:s},p={unitId:u,subUnitId:d,selections:mpt(s).map(e=>({range:e,primary:eq(e,l),style:null}))},m=Olt(e,f),h={unitId:u,subUnitId:d,reveal:!0,selections:s.map(e=>({range:e,primary:eq(e,l),style:null}))},g=Km([{id:eK.id,params:f},{id:oq.id,params:p}],o),_=i.onCommandExecute({id:bY.id,params:f}),v=Km([..._.redos],o);if(g.result&&v.result){let t=i.afterCommandExecute({id:bY.id,params:f});return Km(t.redos,o),e.get(vx).pushUndoRedo({unitID:u,undoMutations:[{id:tK.id,params:m},{id:oq.id,params:h},..._.undos??[],...t.undos],redoMutations:[..._.preRedos??[],{id:eK.id,params:f},{id:oq.id,params:p},..._.redos,...t.redos]}),!0}return!1}};function ppt(e,t){let n=e.getRowCount()-1,r=e.getHiddenCols(),i=[];return t.forEach(e=>{let t=r.filter(t=>t.startColumn>=e.startColumn&&t.endColumn<=e.endColumn);if(t.length){let r=e.startColumn;t.forEach(e=>{e.startColumn>r&&(i.push({startColumn:r,endColumn:e.startColumn-1,startRow:0,endRow:n}),r=e.endColumn+1)}),r<=e.endColumn&&i.push({startColumn:r,endColumn:e.endColumn,startRow:0,endRow:n})}else i.push(e)}),i}function mpt(e){return hpt(e).map(e=>{let t=e.startColumn===0?e.endColumn+1:e.startColumn-1;return{...e,startColumn:t,endColumn:t}})}function hpt(e){let t=[],n;return e.sort((e,t)=>e.startColumn-t.startColumn).forEach(e=>{if(!n){n=e;return}n.endColumn===e.startColumn-1?n.endColumn=e.endColumn:(t.push(n),n=e)}),t.push(n),t}var xY={id:`sheet.command.set-defined-name`,type:L.COMMAND,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(PG);if(!t)return!1;let a={...t},o=g8e(e,t),s=i.onCommandExecute({id:xY.id,params:t}),c=[...s.preRedos??[],...o?[{id:Lz.id,params:o}]:[],{id:Iz.id,params:a},...s.redos],l=[...s.preUndos??[],{id:Lz.id,params:a},...o?[{id:Iz.id,params:o}]:[],...s.undos];return Km(c,n).result?(r.pushUndoRedo({unitID:t.unitId,undoMutations:l.filter(Boolean),redoMutations:c.filter(Boolean)}),!0):!1}},SY=(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(r==null)throw Error(`worksheet is null error!`);let i=r.getConfig().freeze;return{unitId:t.unitId,subUnitId:t.subUnitId,...i}},CY={id:`sheet.mutation.set-frozen`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)throw Error(`universheet is null error!`);let r=n.getSheetBySheetId(t.subUnitId);if(!r)return!1;let i=r.getConfig(),{startRow:a,startColumn:o,ySplit:s,xSplit:c}=t;return i.freeze={startRow:a,startColumn:o,ySplit:s,xSplit:c},!0}},wY={type:L.COMMAND,id:`sheet.command.set-frozen`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),{unitId:t.unitId,subUnitId:t.subUnitId});if(!i)return!1;let{unitId:a,subUnitId:o,worksheet:s}=i,{startColumn:c,startRow:l,xSplit:u,ySplit:d}=t;if(l>=s.getRowCount()||c>=s.getColumnCount()||u>=s.getColumnCount()||d>=s.getRowCount())return!1;let f={unitId:a,subUnitId:o,...t},p=SY(e,f);return n.syncExecuteCommand(CY.id,f)?(r.pushUndoRedo({unitID:a,undoMutations:[{id:CY.id,params:p}],redoMutations:[{id:CY.id,params:f}]}),!0):!1}},TY={type:L.COMMAND,id:`sheet.command.cancel-frozen`,handler:(e,t)=>{let n=e.get(R),r=e.get(z),i=e.get(vx),a=SG(r,{unitId:t?.unitId,subUnitId:t?.subUnitId});if(!a)return!1;let{unitId:o,subUnitId:s}=a,c={unitId:o,subUnitId:s,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},l=SY(e,c);return n.syncExecuteCommand(CY.id,c)&&i.pushUndoRedo({unitID:o,undoMutations:[{id:CY.id,params:l}],redoMutations:[{id:CY.id,params:c}]}),!0}},EY={type:L.COMMAND,id:`sheet.command.set-gridlines-color`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),t);if(!i)return!1;let{worksheet:a}=i,o=a.getConfig().gridlinesColor;if(o===t?.color)return!1;let{unitId:s,subUnitId:c}=i,l={color:t?.color,unitId:s,subUnitId:c},u={color:o,unitId:s,subUnitId:c};return n.syncExecuteCommand(nK.id,l)?(r.pushUndoRedo({unitID:s,undoMutations:[{id:nK.id,params:u}],redoMutations:[{id:nK.id,params:l}]}),!0):!1}},DY={id:`sheet.mutation.set-range-protection`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,rule:i,ruleId:a}=t;return e.get(BK).setRule(n,r,a,i),!0}},OY={id:`sheet.mutation.set-worksheet-protection`,type:L.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r,rule:i}=t;return e.get(fJ).setRule(n,r,i),!0}},gpt={type:L.COMMAND,id:`sheet.command.set-protection`,async handler(e,t){if(!t)return!1;let n=e.get(R),r=e.get(vx),i=e.get(BK),{rule:a,oldRule:o}=t,{unitId:s,subUnitId:c}=a,l=[],u=[];return o?.unitType===a.unitType?a.unitType===ra.Worksheet?(l.push({id:OY.id,params:{unitId:s,subUnitId:c,rule:a}}),u.push({id:OY.id,params:{unitId:s,subUnitId:c,rule:o}})):(l.push({id:DY.id,params:{unitId:s,subUnitId:c,rule:a,ruleId:a.id}}),u.push({id:DY.id,params:{unitId:s,subUnitId:c,ruleId:o.id,rule:o}})):(o&&(o.unitType===ra.Worksheet?(l.push({id:mJ.id,params:{unitId:s,subUnitId:c}}),u.push({id:pJ.id,params:{unitId:s,rule:o,subUnitId:o.subUnitId}})):o.unitType===ra.SelectRange&&(l.push({id:VK.id,params:{unitId:s,subUnitId:c,ruleIds:[o.id]}}),u.push({id:HK.id,params:{unitId:s,subUnitId:c,rules:[o]}}))),a.unitType===ra.Worksheet?(l.push({id:pJ.id,params:{unitId:s,rule:a,subUnitId:a.subUnitId}}),u.unshift({id:mJ.id,params:{unitId:s,subUnitId:c}})):a.unitType===ra.SelectRange&&(a.id=i.createRuleId(s,c),l.push({id:HK.id,params:{unitId:s,subUnitId:c,rules:[a]}}),u.unshift({id:VK.id,params:{unitId:s,subUnitId:c,ruleIds:[a.id]}}))),Km(l,n).result&&r.pushUndoRedo({unitID:s,undoMutations:u,redoMutations:l}),!0}},kY={id:`sheet.command.set-range-custom-metadata`,type:L.COMMAND,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let r=e.get(R),{unitId:i,subUnitId:a}=n,{range:o,customMetadata:s}=t,{startRow:c,startColumn:l,endRow:u,endColumn:d}=o,f=F.isArray(s),p=new Rh;for(let e=c;e<=u;e++)for(let t=l;t<=d;t++){let n=f?s[e-c][t-l]:s;p.setValue(e,t,n)}return r.syncExecuteCommand(lK.id,{unitId:i,subUnitId:a,cellValue:p.getMatrix()})}},AY={type:L.COMMAND,id:`sheet.command.set-row-data`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),t);if(!i)return!1;let{rowData:a}=t,{unitId:o,subUnitId:s,worksheet:c}=i,l={subUnitId:s,unitId:o,rowData:a},u=Qlt(l,c);return n.syncExecuteCommand(uK.id,l)?(r.pushUndoRedo({unitID:o,undoMutations:[{id:uK.id,params:u}],redoMutations:[{id:uK.id,params:l}]}),!0):!1}},jY={type:L.COMMAND,id:`sheet.command.set-specific-rows-visible`,handler:(e,t)=>{let{unitId:n,subUnitId:r,ranges:i}=t,a=e.get(R),o=e.get(vx),s=e.get(PG),c=SG(e.get(z),{unitId:n,subUnitId:r});if(!c)return!1;let{worksheet:l}=c,u={unitId:n,subUnitId:r,ranges:i},d={unitId:n,subUnitId:r,reveal:!0,selections:i.map(e=>({range:e,primary:eq(e,l),style:null}))},f=$lt(e,u),p={unitId:n,subUnitId:r,selections:vpt(i).map(e=>({range:e,primary:eq(e,l),style:null}))},m=Km([{id:dK.id,params:u},{id:oq.id,params:d}],a),h=s.onCommandExecute({id:jY.id,params:t}),g=Km([...h.redos],a);if(m.result&&g.result){let e=s.afterCommandExecute({id:jY.id,params:t});return Km(e.redos,a),o.pushUndoRedo({unitID:n,undoMutations:[...h.preUndos??[],{id:fK.id,params:f},{id:oq.id,params:p},...h.undos??[],...e.undos],redoMutations:[...h.preRedos??[],{id:dK.id,params:u},{id:oq.id,params:d},...h.redos,...e.redos]}),!0}return!0}},MY={type:L.COMMAND,id:`sheet.command.set-selected-rows-visible`,handler:async e=>{let t=e.get(WK),n=e.get(z),r=e.get(R),i=t.getCurrentSelections()?.map(e=>e.range).filter(e=>e.rangeType===vh.ROW);if(!i?.length)return!1;let a=SG(n);if(!a)return!1;let{worksheet:o,unitId:s,subUnitId:c}=a,l=i.map(e=>o.getHiddenRows(e.startRow,e.endRow)).flat();return r.executeCommand(jY.id,{unitId:s,subUnitId:c,ranges:l})}},NY={type:L.COMMAND,id:`sheet.command.set-rows-hidden`,handler:(e,t)=>{var n;let r=e.get(WK),i=e.get(R),a=e.get(vx),o=e.get(z),s=e.get(PG),c=t!=null&&(n=t.ranges)!=null&&n.length?t.ranges:r.getCurrentSelections()?.map(e=>e.range).filter(e=>e.rangeType===vh.ROW);if(!c?.length)return!1;let l=SG(o,t);if(!l)return!1;c=_pt(l.worksheet,c);let{unitId:u,subUnitId:d,worksheet:f}=l,p={unitId:u,subUnitId:d,ranges:c},m={unitId:u,subUnitId:d,selections:vpt(c).map(e=>({range:e,primary:eq(e,f),style:null}))},h=eut(e,p),g={unitId:u,subUnitId:d,reveal:!0,selections:c.map(e=>({range:e,primary:eq(e,f),style:null}))},_=s.onCommandExecute({id:NY.id,params:p});if(Km([..._.preRedos??[],{id:fK.id,params:p},{id:oq.id,params:m},..._.redos],i).result){let e=s.afterCommandExecute({id:NY.id,params:p});return Km(e.redos,i),a.pushUndoRedo({unitID:u,undoMutations:[..._.preUndos??[],{id:dK.id,params:h},{id:oq.id,params:g},..._.undos??[],...e.undos],redoMutations:[..._.preRedos??[],{id:fK.id,params:p},{id:oq.id,params:m},..._.redos,...e.redos]}),!0}return!0}};function _pt(e,t){let n=e.getMaxColumns()-1,r=e.getHiddenRows(),i=[];return t.forEach(e=>{let t=r.filter(t=>t.startRow>=e.startRow&&t.endRow<=e.endRow);if(t.length){let r=e.startRow;t.forEach(e=>{e.startRow>r&&(i.push({startRow:r,endRow:e.startRow-1,startColumn:0,endColumn:n}),r=e.endRow+1)}),r<=e.endRow&&i.push({startRow:r,endRow:e.endRow,startColumn:0,endColumn:n})}else i.push(e)}),i}function vpt(e){return ypt(e).map(e=>{let t=e.startRow===0?e.endRow+1:e.startRow-1;return{...e,startRow:t,endRow:t}})}function ypt(e){let t=[],n;return e.sort((e,t)=>e.startRow-t.startRow).forEach(e=>{if(!n){n=e;return}e.startRow===n.endRow+1?n.endRow=e.endRow:(t.push(n),n=e)}),t.push(n),t}var bpt=(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.subUnitId).getConfig().tabColor;return{...F.deepClone(t),color:n}},PY={id:`sheet.mutation.set-tab-color`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(!n)return!1;let r=n.getSheetBySheetId(t.subUnitId);return r?(r.getConfig().tabColor=t.color,!0):!1}},FY={type:L.COMMAND,id:`sheet.command.set-tab-color`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),t);if(!i)return!1;let{unitId:a,subUnitId:o}=i,s={color:t.value,unitId:a,subUnitId:o},c=bpt(e,s);return n.syncExecuteCommand(PY.id,s)?(r.pushUndoRedo({unitID:a,undoMutations:[{id:PY.id,params:c}],redoMutations:[{id:PY.id,params:s}]}),!0):!1}},xpt={id:`sheet.mutation.set-workbook-name`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUnit(t.unitId,M.UNIVER_SHEET);return n?(n.setName(t.name),!0):!1}},IY={type:L.COMMAND,id:`sheet.command.set-workbook-name`,handler:(e,t)=>{let n=e.get(R),r=e.get(PG);if(!Xct(e.get(z),t))return!1;let i=r.onCommandExecute({id:IY.id,params:t}),a={name:t.name,unitId:t.unitId};return Km([...i.preRedos??[],{id:xpt.id,params:a},...i.redos],n).result}},Spt=4,LY={type:L.COMMAND,id:`sheet.command.set-worksheet-activate`,handler:(e,t,n)=>{let r=e.get(R),i=SG(e.get(z),t);if(!i)return!1;let{unitId:a,subUnitId:o}=i;return new Promise(e=>{setTimeout(()=>{e(r.syncExecuteCommand(wK.id,{unitId:a,subUnitId:o},n))},Spt)})}},RY={type:L.COMMAND,id:`sheet.command.delta-column-width`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections();if(!n?.length)return!1;let r=e.get(R),i=e.get(vx),a=SG(e.get(z));if(!a)return!1;let{worksheet:o,unitId:s,subUnitId:c}=a,{anchorCol:l,deltaX:u}=t,d=o.getColumnWidth(l)+u,f=n.length===1&&n[0].range.rangeType===vh.ALL,p=n.filter(e=>e.range.rangeType===vh.COLUMN),m=f?vh.ALL:p.some(({range:e})=>{let{startColumn:t,endColumn:n}=e;return t<=l&&l<=n})?vh.COLUMN:vh.NORMAL,h;if(m===vh.ALL){let e=o.getRowCount();h={subUnitId:c,unitId:s,colWidth:d,ranges:Array(o.getColumnCount()).fill(void 0).map((t,n)=>({startRow:0,endRow:e-1,startColumn:n,endColumn:n}))}}else h=m===vh.COLUMN?{subUnitId:c,unitId:s,ranges:p.map(e=>d_.clone(e.range)),colWidth:d}:{subUnitId:c,unitId:s,colWidth:d,ranges:[{startRow:0,endRow:o.getMaxRows()-1,startColumn:l,endColumn:l}]};let g=e.get(qK).getSkeleton(s,c),{suitableRanges:_,remainingRanges:v}=YK(h.ranges,g);JK(_,o);let y=e.get(PG),{undos:b,redos:x}=y.onCommandExecute({id:RY.id,params:h}),S=pK(h,o),C=r.syncExecuteCommand(mK.id,h),{undos:w,redos:T}=y.generateMutationsOfAutoHeight({unitId:s,subUnitId:c,ranges:_,autoHeightRanges:_,lazyAutoHeightRanges:v}),{undos:E,redos:D}=e.get(PG).afterCommandExecute({id:RY.id,params:h}),O=Km([...x,...D,...T],r);return C&&O.result&&i.pushUndoRedo({unitID:s,undoMutations:[{id:mK.id,params:S},...b,...E,...w],redoMutations:[{id:mK.id,params:h},...x,...D,...T]}),!0}},zY={type:L.COMMAND,id:`sheet.command.set-worksheet-col-width`,handler:(e,t)=>{var n;let r=e.get(WK),i=e.get(R),a=e.get(vx),o=e.get(PG),s=t!=null&&(n=t.ranges)!=null&&n.length?t.ranges:r.getCurrentSelections()?.map(e=>e.range);if(!s?.length)return!1;let c=SG(e.get(z),t);if(!c)return!1;let{subUnitId:l,unitId:u,worksheet:d}=c,f=e.get(qK).getSkeleton(u,l),p={subUnitId:l,unitId:u,ranges:s,colWidth:t.value},{suitableRanges:m,remainingRanges:h}=YK(p.ranges,f);JK(m,d);let g=pK(p,d),_=i.syncExecuteCommand(mK.id,p),{undos:v,redos:y}=o.generateMutationsOfAutoHeight({unitId:u,subUnitId:l,ranges:m,autoHeightRanges:m,lazyAutoHeightRanges:h}),b=o.onCommandExecute({id:zY.id,params:p}),x=Km([...b.redos,...y],i);if(_&&x.result){let e=o.afterCommandExecute({id:zY.id,params:p});return Km(e.redos,i),a.pushUndoRedo({unitID:u,undoMutations:[...b.preUndos??[],{id:mK.id,params:g},...b.undos,...e.undos,...v],redoMutations:[...b.preRedos??[],{id:mK.id,params:p},...b.redos,...e.redos,...y]}),!0}return!1}},Cpt={type:L.COMMAND,id:`sheet.command.set-col-is-auto-width`,handler:async(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(WK),a=SG(e.get(z),t);if(!a)return!1;let{unitId:o,subUnitId:s}=a,c=[];if(t?.ranges)c=[...t.ranges];else{let e=i.getCurrentSelections();for(let t=0;t<e.length;t++)c.push(e[t].range)}if(!c?.length)return!1;let l={unitId:o,subUnitId:s,ranges:c},{undos:u,redos:d}=e.get(PG).onCommandExecute({id:Cpt.id,params:l});return Km([...d],n).result?(r.pushUndoRedo({unitID:o,undoMutations:[...u],redoMutations:[...d]}),!0):!1}},wpt={type:L.COMMAND,id:`sheet.command.set-worksheet-column-count`,handler:(e,t)=>{let{unitId:n,subUnitId:r,columnCount:i}=t,a=e.get(R),o=e.get(vx);if(!SG(e.get(z),t))return!1;let s={unitId:n,subUnitId:r,columnCount:i},c=tut(e,s);return a.syncExecuteCommand(hK.id,s)?(o.pushUndoRedo({unitID:n,undoMutations:[{id:hK.id,params:c}],redoMutations:[{id:hK.id,params:s}]}),!0):!1}},Tpt={type:L.COMMAND,id:`sheet.command.set-worksheet-default-style`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),{unitId:i}=t,a=nut(e,t);return n.syncExecuteCommand(gK.id,t)?(r.pushUndoRedo({unitID:i,undoMutations:[{id:gK.id,params:a}],redoMutations:[{id:gK.id,params:t}]}),!0):!1}},Ept=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetHideMutationFactory]: worksheet is null error!`);let{worksheet:r}=n;return{hidden:r.isSheetHidden(),unitId:t.unitId,subUnitId:r.getSheetId()}},BY={id:`sheet.mutation.set-worksheet-hidden`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)return!1;let r=n.getSheetBySheetId(t.subUnitId);return r?(r.getConfig().hidden=t.hidden,!0):!1}},VY={type:L.COMMAND,id:`sheet.command.set-worksheet-hidden`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(sb),a=e.get(nx),o=SG(e.get(z),t);if(!o)return!1;let{workbook:s,worksheet:c,unitId:l,subUnitId:u}=o;if(c.getConfig().hidden===Np.TRUE)return!1;let d={unitId:l,subUnitId:u,hidden:Np.TRUE},f=Ept(e,d);return s.getSheets().filter(e=>e.getConfig().hidden===Np.FALSE).length===1?(i.emit(a.t(`sheets.info.hideSheet`)),!1):n.syncExecuteCommand(BY.id,d)?(r.pushUndoRedo({unitID:l,undoMutations:[{id:BY.id,params:f}],redoMutations:[{id:BY.id,params:d}]}),!0):!1}},Dpt=(e,t)=>{let n=CG(e.get(z),t);if(!n)throw Error(`[SetWorksheetNameMutationFactory]: worksheet is null error!`);let{worksheet:r}=n;return{unitId:t.unitId,name:r.getName(),subUnitId:r.getSheetId()}},HY={id:`sheet.mutation.set-worksheet-name`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(n==null)return!1;let r=n.getSheetBySheetId(t.subUnitId);return r?(r.getConfig().name=t.name,!0):!1}},UY={type:L.COMMAND,id:`sheet.command.set-worksheet-name`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=e.get(PG),a=SG(e.get(z),t);if(!a)return!1;let{unitId:o,subUnitId:s}=a,c={subUnitId:s,name:t.name,unitId:o},l=Dpt(e,c),u=i.onCommandExecute({id:UY.id,params:t}),d=[...u.preRedos??[],{id:HY.id,params:c},...u.redos],f=[...u.preUndos??[],{id:HY.id,params:l},...u.undos];return Km(d,n).result?(r.pushUndoRedo({unitID:o,undoMutations:f,redoMutations:d}),!0):!1}},Opt=(e,t)=>({...F.deepClone(t),toOrder:t.fromOrder,fromOrder:t.toOrder}),WY={id:`sheet.mutation.set-worksheet-order`,type:L.MUTATION,handler:(e,t)=>{let n=e.get(z).getUniverSheetInstance(t.unitId);if(!n)return!1;let r=n.getConfig();return r.sheetOrder.splice(t.fromOrder,1),r.sheetOrder.splice(t.toOrder,0,t.subUnitId),n.ensureSheetOrderUnique(),!0}},GY={type:L.COMMAND,id:`sheet.command.set-worksheet-order`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),t);if(!i)return!1;let{workbook:a,unitId:o,subUnitId:s}=i,c={fromOrder:a.getConfig().sheetOrder.indexOf(s),toOrder:t.order,unitId:o,subUnitId:s},l=Opt(e,c);return n.syncExecuteCommand(WY.id,c)?(r.pushUndoRedo({unitID:o,undoMutations:[{id:WY.id,params:l}],redoMutations:[{id:WY.id,params:c}]}),!0):!1}},KY=class{constructor(){Z(this,`_model`,new Map),Z(this,`_pointChange`,new ao),Z(this,`pointChange$`,this._pointChange.asObservable())}addRule(e){this._ensureSubUnitMap(e.unitId).set(e.subUnitId,e),this._pointChange.next(e)}deleteRule(e,t){let n=this._model.get(e)?.get(t);if(n){var r;(r=this._model)==null||(r=r.get(e))==null||r.delete(t),this._pointChange.next(n)}}getRule(e,t){var n;return(n=this._model)==null||(n=n.get(e))==null?void 0:n.get(t)}toObject(){let e={};return[...this._model.keys()].forEach(t=>{let n=this._model.get(t);n?.size&&(e[t]=[],[...n.keys()].forEach(r=>{let i=n.get(r);i&&e[t].push(i)}))}),e}fromObject(e){let t=new Map;Object.keys(e).forEach(n=>{let r=e[n];if(r?.length){let e=new Map;r.forEach(t=>{e.set(t.subUnitId,t)}),t.set(n,e)}}),this._model=t}deleteUnitModel(e){this._model.delete(e)}_ensureSubUnitMap(e){let t=this._model.get(e);return t||(t=new Map,this._model.set(e,t)),t}getTargetByPermissionId(e,t){let n=this._model.get(e);if(!n)return null;for(let[r,i]of n)if(i.permissionId===t)return[e,r]}},qY=class{constructor(e,t,n){Z(this,`type`,ra.SelectRange),Z(this,`subType`,ta.Delete),Z(this,`status`,ax.INIT),Z(this,`value`,!0),Z(this,`id`,void 0),Z(this,`unitId`,void 0),Z(this,`subUnitId`,void 0),Z(this,`permissionId`,void 0),this.unitId=e,this.subUnitId=t,this.permissionId=n,this.id=`${ra.SelectRange}.${ta.Delete}.${n}`}},JY=class{constructor(e,t,n){Z(this,`type`,ra.SelectRange),Z(this,`subType`,ta.Edit),Z(this,`status`,ax.INIT),Z(this,`value`,!0),Z(this,`id`,void 0),Z(this,`unitId`,void 0),Z(this,`subUnitId`,void 0),Z(this,`permissionId`,void 0),this.unitId=e,this.subUnitId=t,this.permissionId=n,this.id=`${ra.SelectRange}.${ta.Edit}.${n}`}},YY=class{constructor(e,t,n){Z(this,`type`,ra.SelectRange),Z(this,`subType`,ta.ManageCollaborator),Z(this,`status`,ax.INIT),Z(this,`value`,!0),Z(this,`id`,void 0),Z(this,`unitId`,void 0),Z(this,`subUnitId`,void 0),Z(this,`permissionId`,void 0),this.unitId=e,this.subUnitId=t,this.permissionId=n,this.id=`${ra.SelectRange}.${ta.ManageCollaborator}.${n}`}},XY=class{constructor(e,t,n){Z(this,`type`,ra.SelectRange),Z(this,`subType`,ta.View),Z(this,`status`,ax.INIT),Z(this,`value`,!1),Z(this,`id`,void 0),Z(this,`unitId`,void 0),Z(this,`subUnitId`,void 0),Z(this,`permissionId`,void 0),this.unitId=e,this.subUnitId=t,this.permissionId=n,this.id=`${ra.SelectRange}.${ta.View}.${n}`}},ZY=()=>[XY,JY,YY,qY],QY=[ta.Edit,ta.View,ta.ManageCollaborator,ta.Delete],kpt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Comment),this.unitId=e,this.id=`${this.type}.${ta.Comment}_${e}`}},$Y=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Copy),this.unitId=e,this.id=`${this.type}.${ta.Copy}_${e}`}},Apt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`subType`,ta.CopySheet),Z(this,`status`,ax.INIT),this.unitId=e,this.id=`${this.type}.${ta.CopySheet}_${e}`}},eX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.CreatePermissionObject),this.unitId=e,this.id=`${this.type}.${ta.CreatePermissionObject}_${e}`}},tX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.CreateSheet),this.unitId=e,this.id=`${this.type}.${ta.CreateSheet}_${e}`}},nX=class{constructor(e){this.unitId=e,Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.DeleteColumn),this.id=`${this.type}.${ta.DeleteColumn}_${e}`}},rX=class{constructor(e){this.unitId=e,Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.DeleteRow),this.id=`${this.type}.${ta.DeleteRow}_${e}`}},iX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.DeleteSheet),this.unitId=e,this.id=`${this.type}.${ta.DeleteSheet}_${e}`}},jpt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Duplicate),this.unitId=e,this.id=`${this.type}.${ta.Duplicate}_${e}`}},aX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Edit),this.unitId=e,this.id=`${this.type}.${ta.Edit}_${e}`}},Mpt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Export),this.unitId=e,this.id=`${this.type}.${ta.Export}_${e}`}},oX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.HideSheet),this.unitId=e,this.id=`${this.type}.${ta.HideSheet}_${e}`}},sX=class{constructor(e){this.unitId=e,Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.InsertColumn),this.id=`${this.type}.${ta.InsertColumn}_${e}`}},cX=class{constructor(e){this.unitId=e,Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.InsertRow),this.id=`${this.type}.${ta.InsertRow}_${e}`}},lX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.ManageCollaborator),this.unitId=e,this.id=`${this.type}.${ta.ManageCollaborator}_${e}`}},uX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.MoveSheet),this.unitId=e,this.id=`${this.type}.${ta.MoveSheet}_${e}`}},Npt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Print),this.unitId=e,this.id=`${this.type}.${ta.Print}_${e}`}},Ppt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.RecoverHistory),this.unitId=e,this.id=`${this.type}.${ta.RecoverHistory}_${e}`}},dX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.RenameSheet),this.unitId=e,this.id=`${this.type}.${ta.RenameSheet}_${e}`}},Fpt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.Share),this.unitId=e,this.id=`${this.type}.${ta.Share}_${e}`}},fX=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.View),this.unitId=e,this.id=`${this.type}.${ta.View}_${e}`}},Ipt=class{constructor(e){this.unitId=e,Z(this,`id`,void 0),Z(this,`value`,!0),Z(this,`type`,ra.Workbook),Z(this,`status`,ax.INIT),Z(this,`subType`,ta.ViewHistory),this.unitId=e,this.id=`${this.type}.${ta.ViewHistory}_${e}`}},pX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.Copy),this.id=`${this.type}.${ta.Copy}_${e}_${t}`}},mX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.DeleteColumn),this.id=`${this.type}.${ta.DeleteColumn}_${e}_${t}`}},hX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.Delete),this.id=`${this.type}.${ta.Delete}_${e}_${t}`}},gX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.DeleteRow),this.id=`${this.type}.${ta.DeleteRow}_${e}_${t}`}},_X=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.Edit),this.id=`${this.type}.${ta.Edit}_${e}_${t}`}},Lpt=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.EditExtraObject),this.id=`${this.type}.${ta.EditExtraObject}_${e}_${t}`}},vX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.Filter),this.id=`${this.type}.${ta.Filter}_${e}_${t}`}},yX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.InsertColumn),this.id=`${this.type}.${ta.InsertColumn}_${e}_${t}`}},bX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.InsertHyperlink),this.id=`${this.type}.${ta.InsertHyperlink}_${e}_${t}`}},xX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.InsertRow),this.id=`${this.type}.${ta.InsertRow}_${e}_${t}`}},SX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.ManageCollaborator),this.id=`${this.type}.${ta.ManageCollaborator}_${e}_${t}`}},Rpt=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.PivotTable),this.id=`${this.type}.${ta.PivotTable}_${e}_${t}`}},zpt=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.SelectProtectedCells),this.id=`${this.type}.${ta.SelectProtectedCells}_${e}_${t}`}},Bpt=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.SelectUnProtectedCells),this.id=`${this.type}.${ta.SelectUnProtectedCells}_${e}_${t}`}},CX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.SetCellStyle),this.id=`${this.type}.${ta.SetCellStyle}_${e}_${t}`}},wX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.SetCellValue),this.id=`${this.type}.${ta.SetCellValue}_${e}_${t}`}},TX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.SetColumnStyle),this.id=`${this.type}.${ta.SetColumnStyle}_${e}_${t}`}},EX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.SetRowStyle),this.id=`${this.type}.${ta.SetRowStyle}_${e}_${t}`}},DX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.Sort),this.id=`${this.type}.${ta.Sort}_${e}_${t}`}},OX=class{constructor(e,t){this.unitId=e,this.subUnitId=t,Z(this,`value`,!0),Z(this,`type`,ra.Worksheet),Z(this,`status`,ax.INIT),Z(this,`id`,void 0),Z(this,`subType`,ta.View),this.id=`${this.type}.${ta.View}_${e}_${t}`}},kX=()=>[aX,Npt,kpt,fX,$Y,Mpt,lX,tX,iX,dX,oX,jpt,Fpt,uX,Apt,Ipt,Ppt,eX,cX,sX,rX,nX],Vpt=[ta.Edit,ta.Print,ta.Comment,ta.View,ta.Copy,ta.Export,ta.ManageCollaborator,ta.CreateSheet,ta.DeleteSheet,ta.RenameSheet,ta.HideSheet,ta.Duplicate,ta.Share,ta.MoveSheet,ta.CopySheet,ta.RecoverHistory,ta.ViewHistory,ta.CreatePermissionObject,ta.InsertRow,ta.InsertColumn,ta.DeleteRow,ta.DeleteColumn],AX=()=>[_X,OX,SX,hX],jX=()=>[pX,mX,gX,Lpt,vX,yX,xX,bX,Rpt,CX,wX,TX,EX,DX],Hpt=[ta.Copy,ta.DeleteColumn,ta.DeleteRow,ta.EditExtraObject,ta.Filter,ta.InsertColumn,ta.InsertRow,ta.InsertHyperlink,ta.PivotTable,ta.SetCellStyle,ta.SetCellValue,ta.SetColumnStyle,ta.SetRowStyle,ta.Sort],Upt=`SHEET_WORKSHEET_PROTECTION_PLUGIN`,Wpt=`SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN`,MX=class extends Kf{constructor(e,t,n,r,i,a,o,s){super(),this._permissionService=e,this._univerInstanceService=t,this._injector=n,this._worksheetProtectionRuleModel=r,this._worksheetProtectionPointRuleModel=i,this._resourceManagerService=a,this._rangeProtectionRuleModel=o,this._logService=s,this._init(),this._initRuleChange(),this._initRuleSnapshot(),this._initPointSnapshot()}_init(){let e=e=>{let t=e.getUnitId(),n=e=>{let n=e.getSheetId();[...AX(),...jX()].forEach(e=>{let r=new e(t,n);this._permissionService.addPermissionPoint(r)}),this._logService.debug(`[WorksheetPermissionService]`,`Initialization completed`,t,n)};e.getSheets().forEach(e=>{n(e)}),e.sheetCreated$.subscribe(e=>{n(e)}),e.sheetDisposed$.subscribe(e=>{let n=e.getSheetId();this._rangeProtectionRuleModel.getSubunitRuleList(t,n).forEach(e=>{[...ZY()].forEach(r=>{let i=new r(t,n,e.permissionId);this._permissionService.deletePermissionPoint(i.id)})}),[...AX(),...jX()].forEach(e=>{let r=new e(t,n);this._permissionService.deletePermissionPoint(r.id)})})};this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).forEach(t=>e(t)),this._univerInstanceService.getTypeOfUnitAdded$(M.UNIVER_SHEET).pipe(cc(this.dispose$)).subscribe(t=>e(t.unit)),this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_SHEET).pipe(cc(this.dispose$)).subscribe(e=>{e.getSheets().forEach(t=>{let n=e.getUnitId(),r=t.getSheetId();AX().forEach(e=>{let t=new e(n,r);this._permissionService.deletePermissionPoint(t.id)})})})}_initRuleChange(){this.disposeWithMe(this._worksheetProtectionRuleModel.ruleChange$.subscribe(e=>{switch(e.type){case`add`:break;case`delete`:AX().forEach(t=>{let n=new t(e.unitId,e.subUnitId);this._permissionService.updatePermissionPoint(n.id,!0)});break;case`set`:AX().forEach(t=>{let n=new t(e.unitId,e.subUnitId);this._permissionService.updatePermissionPoint(n.id,e.rule)})}}))}_initRuleSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource({toJson:()=>{let e=this._worksheetProtectionRuleModel.toObject();return JSON.stringify(e)},parseJson:e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}},pluginName:Upt,businesses:[M.UNIVER_SHEET],onLoad:(e,t)=>{this._worksheetProtectionRuleModel.fromObject(t),Object.keys(t).forEach(t=>{AX().forEach(n=>{let r=new n(e,t);r.value=!1,this._permissionService.addPermissionPoint(r)})}),this._worksheetProtectionRuleModel.changeRuleInitState(!0)},onUnLoad:e=>{let t=this._univerInstanceService.getUnit(e);t&&(t.getSheets().forEach(t=>{let n=t.getSheetId();[...AX(),...jX()].forEach(t=>{let r=new t(e,n);this._permissionService.deletePermissionPoint(r.id)})}),kX().forEach(t=>{let n=new t(e);this._permissionService.deletePermissionPoint(n.id)})),this._worksheetProtectionRuleModel.deleteUnitModel(e)}}))}_initPointSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource({toJson:()=>{let e=this._worksheetProtectionPointRuleModel.toObject();return JSON.stringify(e)},parseJson:e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}},pluginName:Wpt,businesses:[M.UNIVER_SHEET],onLoad:(e,t)=>{this._worksheetProtectionPointRuleModel.fromObject(t),Object.keys(t).forEach(t=>{jX().forEach(n=>{let r=new n(e,t);this._permissionService.addPermissionPoint(r)})})},onUnLoad:e=>{this._worksheetProtectionPointRuleModel.deleteUnitModel(e)}}))}};MX=AG([kG(0,j(ox)),kG(1,j(z)),kG(2,j(We)),kG(3,j(fJ)),kG(4,j(KY)),kG(5,j(By)),kG(6,j(BK)),kG(7,j(Rm))],MX);var Gpt={id:`sheet.mutation.set-worksheet-permission-points`,type:L.MUTATION,handler:(e,t)=>{let{rule:n}=t;return e.get(KY).addRule(n),!0}},Kpt={type:L.COMMAND,id:`sheet.command.set-worksheet-permission-points`,async handler(e,t){if(!t)return!1;let n=e.get(R),{rule:r}=t;return n.executeCommand(Gpt.id,{rule:r,unitId:r.unitId,subUnitId:r.subUnitId}),!0}},qpt={type:L.COMMAND,id:`sheet.command.set-worksheet-protection`,async handler(e,t){if(!t)return!1;let n=e.get(R),r=e.get(vx),{rule:i,permissionId:a,oldRule:o}=t,{unitId:s,subUnitId:c}=i,l={...i,permissionId:a};if(await n.executeCommand(OY.id,{unitId:s,subUnitId:c,newRule:l})){let e=[{id:OY.id,params:{unitId:s,subUnitId:c,newRule:l}}],t=[{id:OY.id,params:{unitId:s,subUnitId:c,rule:o}}];r.pushUndoRedo({unitID:s,redoMutations:e,undoMutations:t})}return!0}};L.MUTATION,L.COMMAND;var Jpt={type:L.COMMAND,id:`sheet.command.set-worksheet-row-count`,handler:(e,t)=>{let{unitId:n,subUnitId:r,rowCount:i}=t,a=e.get(R),o=e.get(vx);if(!SG(e.get(z),t))return!1;let s={unitId:n,subUnitId:r,rowCount:i},c=rut(e,s);return a.syncExecuteCommand(_K.id,s)?(o.pushUndoRedo({unitID:n,undoMutations:[{id:_K.id,params:c}],redoMutations:[{id:_K.id,params:s}]}),!0):!1}},NX={type:L.COMMAND,id:`sheet.command.delta-row-height`,handler:async(e,t)=>{let n=e.get(WK).getCurrentSelections(),r=e.get(PG);if(!n?.length)return!1;let i=SG(e.get(z));if(!i)return!1;let{worksheet:a,subUnitId:o,unitId:s}=i,{anchorRow:c,deltaY:l}=t,u=a.getRowHeight(c)+l,d=n.length===1&&n[0].range.rangeType===vh.ALL,f=n.filter(e=>e.range.rangeType===vh.ROW),p=d?vh.ALL:f.some(({range:e})=>{let{startRow:t,endRow:n}=e;return t<=c&&c<=n})?vh.ROW:vh.NORMAL,m;if(p===vh.ALL){let e=a.getColumnCount();m={subUnitId:o,unitId:s,rowHeight:u,ranges:Array(a.getRowCount()).fill(void 0).map((t,n)=>({startRow:n,endRow:n,startColumn:0,endColumn:e-1}))}}else m=p===vh.ROW?{subUnitId:o,unitId:s,ranges:f.map(e=>d_.clone(e.range)),rowHeight:u}:{subUnitId:o,unitId:s,rowHeight:u,ranges:[{startRow:c,endRow:c,startColumn:0,endColumn:a.getMaxColumns()-1}]};let h=iut(m,a),g={unitId:s,subUnitId:o,ranges:m.ranges,autoHeightInfo:Np.FALSE},_=vK(g,a),v=e.get(R),y=e.get(vx),b=r.onCommandExecute({id:NX.id,params:m}),x=Km([{id:bK.id,params:m},{id:xK.id,params:g}],v),S=Km([...b.redos],v);if(x.result&&S.result){let e=r.afterCommandExecute({id:NX.id,params:m});return Km(e.redos,v),y.pushUndoRedo({unitID:s,undoMutations:[...b.preUndos??[],{id:bK.id,params:h},{id:xK.id,params:_},...b.undos,...e.undos],redoMutations:[...b.preRedos??[],{id:bK.id,params:m},{id:xK.id,params:g},...b.redos,...e.redos]}),!0}return!1}},PX={type:L.COMMAND,id:`sheet.command.set-row-height`,handler:(e,t)=>{var n;let r=e.get(WK),i=e.get(R),a=e.get(vx),o=e.get(z),s=e.get(PG),c=t!=null&&(n=t.ranges)!=null&&n.length?t.ranges:r.getCurrentSelections()?.map(e=>e.range);if(!c?.length)return!1;let l=SG(o,t);if(!l)return!1;let{unitId:u,subUnitId:d,worksheet:f}=l,p={subUnitId:d,unitId:u,ranges:c,rowHeight:t.value},m=iut(p,f),h={unitId:u,subUnitId:d,ranges:p.ranges,autoHeightInfo:Np.FALSE},g=vK(h,f),_=Km([{id:bK.id,params:p},{id:xK.id,params:h}],i),v=s.onCommandExecute({id:PX.id,params:p}),y=Km([...v.redos],i);if(_.result&&y.result){let e=s.afterCommandExecute({id:PX.id,params:p});return Km(e.redos,i),a.pushUndoRedo({unitID:u,undoMutations:[...v.preRedos??[],{id:bK.id,params:m},{id:xK.id,params:g},...v.undos,...e.undos],redoMutations:[...v.preRedos??[],{id:bK.id,params:p},{id:xK.id,params:h},...v.redos,...e.redos]}),!0}return!1}},FX={type:L.COMMAND,id:`sheet.command.set-row-is-auto-height`,handler:(e,t)=>{var n;let r=e.get(R),i=e.get(vx),a=e.get(WK),o=SG(e.get(z),t);if(!o)return!1;let{unitId:s,subUnitId:c,worksheet:l}=o,u=t!=null&&(n=t.ranges)!=null&&n.length?t.ranges:a.getCurrentSelections()?.map(e=>e.range);if(!u?.length)return!1;let d={unitId:s,subUnitId:c,ranges:u,autoHeightInfo:Np.TRUE},f=vK(d,l),p=r.syncExecuteCommand(xK.id,d),m=e.get(qK).getSkeleton(s,c),{suitableRanges:h,remainingRanges:g}=YK(d.ranges,m),_=e.get(PG),{undos:v,redos:y}=_.generateMutationsOfAutoHeight({unitId:s,subUnitId:c,ranges:h,autoHeightRanges:h,lazyAutoHeightRanges:g}),{undos:b,redos:x}=_.onCommandExecute({id:FX.id,params:d}),S=Km([...x,...y],r);return p&&S.result?(i.pushUndoRedo({unitID:s,undoMutations:[{id:xK.id,params:f},...b,...v],redoMutations:[{id:xK.id,params:d},...x,...y]}),!0):!1}},IX={type:L.COMMAND,id:`sheet.command.set-worksheet-show`,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{unitId:r,subUnitId:i,worksheet:a}=n;if(a.getConfig().hidden===Np.FALSE)return!1;let o=e.get(R),s=e.get(vx),c={unitId:r,subUnitId:i,hidden:Np.FALSE},l=Ept(e,c),u=o.syncExecuteCommand(BY.id,c),d={unitId:r,subUnitId:i},f=o.syncExecuteCommand(wK.id,d);return u&&f?(s.pushUndoRedo({unitID:r,undoMutations:[{id:BY.id,params:l}],redoMutations:[{id:BY.id,params:c}]}),!0):!1}},Ypt={type:L.COMMAND,id:`sheet.command.split-text-to-columns`,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let{unitId:r,subUnitId:i,worksheet:a}=n,{range:o,delimiter:s,customDelimiter:c,treatMultipleDelimitersAsOne:l}=t,{lastRow:u,rs:d,maxLength:f}=Eut(a,o,s,c,l),p=a.getColumnCount(),{startColumn:m}=t_.transformRange(o,a);if(o.startColumn!==o.endColumn)return!1;let h=e.get(R),g=e.get(vx),_=[],v=[],y=m+f+1-p;if(y>0){let t={unitId:r,subUnitId:i,range:{startRow:0,endRow:a.getRowCount()-1,startColumn:p-1,endColumn:p-1+y}};_.push({id:WG.id,params:t});let n=UG(e,t);v.push({id:YG.id,params:n})}let b={startRow:o.startRow,endRow:u,startColumn:m,endColumn:m+f},x=new Rh;for(let e=b.startRow;e<=b.endRow;e++)for(let t=b.startColumn;t<=b.endColumn;t++){let n=d[e-b.startRow];t===0&&n?.length===1?x.setValue(e,t,a.getCell(e,t)):x.setValue(e,t,{v:n?.[t-b.startColumn]||null,p:null,f:null,si:null,custom:null})}let S={unitId:r,subUnitId:i,cellValue:x.clone()},C=cK(e,S);return _.push({id:lK.id,params:S}),v.unshift({id:lK.id,params:C}),Km(_,h).result?(g.pushUndoRedo({unitID:r,undoMutations:v,redoMutations:_}),!0):!1}},LX=ce(`INumfmtService`),Xpt=(e,t)=>{let n=e.get(LX),{values:r,unitId:i,subUnitId:a}=t,o=[],s=[];Object.keys(r).forEach(e=>{r[e].ranges.forEach(e=>{t_.foreach(e,(e,t)=>{let r=n.getValue(i,a,e,t);r?o.push({pattern:r.pattern,row:e,col:t}):s.push({startColumn:t,endColumn:t,startRow:e,endRow:e})})})});let c=[];if(o.length){let e=BX(i,a,o);Object.keys(e.values).forEach(t=>{let n=e.values[t];n.ranges=kK(n.ranges)}),c.push({id:RX.id,params:BX(i,a,o)})}return s.length&&c.push({id:zX.id,params:{unitId:i,subUnitId:a,ranges:s}}),c},RX={id:`sheet.mutation.set.numfmt`,type:L.MUTATION,handler:(e,t)=>{if(!t)return!1;let{values:n,refMap:r}=t,i=e.get(LX),a=t.unitId,o=t.subUnitId,s=Object.keys(n).reduce((e,t)=>{let i=r[t],a=n[t].ranges;return i&&e.push({...i,ranges:a}),e},[]);return i.setValues(a,o,s),!0}},zX={id:`sheet.mutation.remove.numfmt`,type:L.MUTATION,handler:(e,t)=>{if(!t)return!1;let{unitId:n,subUnitId:r,ranges:i}=t;return e.get(LX).deleteValues(n,r,i),!0}},Zpt=(e,t)=>{let n=e.get(LX),{ranges:r,unitId:i,subUnitId:a}=t,o=[];if(r.forEach(e=>{t_.foreach(e,(e,t)=>{let r=n.getValue(i,a,e,t);r&&o.push({pattern:r.pattern,row:e,col:t})})}),!o.length)return[];let s=BX(i,a,o);return Object.keys(s.values).forEach(e=>{let t=s.values[e];t.ranges=kK(t.ranges)}),[{id:RX.id,params:s}]},BX=(e,t,n)=>{let r=Dut(n,`pattern`),i={},a={},o=Out();return Object.keys(r).forEach(e=>{let t=r[e],n=o();i[n]={pattern:e},t.forEach(e=>{a[n]||(a[n]={ranges:[]}),a[n].ranges.push(Yh(e.row,e.col))})}),{unitId:e,subUnitId:t,refMap:i,values:a}},Qpt={id:`sheet.command.text-to-number`,type:L.COMMAND,handler:(e,t)=>{let n=SG(e.get(z),t);if(!n)return!1;let r=t?.ranges||e.get(WK).getCurrentSelections()?.map(e=>e.range);if(!r?.length)return!1;let i=e.get(R),a=e.get(vx),{worksheet:o,unitId:s,subUnitId:c}=n,l=new Rh,u=[];for(let e=0;e<r.length;e++)for(let t=r[e].startRow;t<=r[e].endRow;t++)for(let n=r[e].startColumn;n<=r[e].endColumn;n++){var d,f;if(l.getValue(t,n))continue;let e=o.getCellRaw(t,n),r=typeof e?.s==`string`?(d=o.getStyleDataByHash(e.s))==null||(d=d.n)==null?void 0:d.pattern:e==null||(f=e.s)==null||(f=f.n)==null?void 0:f.pattern;e&&e.v&&(e.t!==Pp.NUMBER||Ch(r))&&Pg(e.v)&&(l.setValue(t,n,{v:Number(e.v),t:Pp.NUMBER}),Ch(r)&&u.push({startRow:t,endRow:t,startColumn:n,endColumn:n}))}let p={subUnitId:c,unitId:s,cellValue:l.getMatrix()},m=[{id:lK.id,params:p}],h=[{id:lK.id,params:cK(e,p)}];if(u.length){let t={unitId:s,subUnitId:c,ranges:u};m.push({id:zX.id,params:t}),h.push(...Zpt(e,t))}return Km(m,i).result?(a.pushUndoRedo({unitID:s,undoMutations:h,redoMutations:m}),!0):!1}},$pt={id:`sheet.command.toggle-cell-checkbox`,type:L.COMMAND,handler:(e,t)=>{if(!t)return!1;let{unitId:n,subUnitId:r,row:i,col:a,paragraphIndex:o}=t,s=e.get(z).getUnit(n,M.UNIVER_SHEET)?.getSheetBySheetId(r),c=e.get(vx),l=e.get(R);if(!s)return!1;let u=s.getCell(i,a);if(!u?.p)return!1;let d=F.deepClone(u.p),f=new Xv(d),p=Ey.paragraph.bullet.toggleChecklist({document:f,paragraphIndex:o});if(!p)return!1;Bv.apply(f.getBody(),p.serialize());let m={unitId:n,subUnitId:r,cellValue:{[i]:{[a]:{p:d,t:Pp.STRING}}}},h={id:lK.id,params:m},g=cK(e,m),_={id:lK.id,params:g},v=[h],y=[_];return c.pushUndoRedo({redoMutations:v,undoMutations:y,unitID:n}),l.syncExecuteCommand(h.id,h.params)}},VX={type:L.COMMAND,id:`sheet.command.toggle-gridlines`,handler:(e,t)=>{let n=e.get(R),r=e.get(vx),i=SG(e.get(z),t);if(!i)return!1;let{worksheet:a}=i,o=a.getConfig().showGridlines;if(o===t?.showGridlines)return!1;let{unitId:s,subUnitId:c}=i,l={showGridlines:o===Np.TRUE?Np.FALSE:Np.TRUE,unitId:s,subUnitId:c},u={showGridlines:o,unitId:s,subUnitId:c};return n.syncExecuteCommand(CK.id,l)?(r.pushUndoRedo({unitID:s,undoMutations:[{id:CK.id,params:u}],redoMutations:[{id:CK.id,params:l}]}),!0):!1}},emt={id:`sheet.command.unregister-worksheet-range-theme-style`,type:L.COMMAND,handler:(e,t)=>{if(!t||!SG(e.get(z),t))return!1;let n=e.get(R),r=e.get(vx),i=e.get(RG),{unitId:a,themeName:o}=t,s={unitId:a,themeName:o},c={unitId:a,themeName:o,rangeThemeStyleJson:i.getRangeThemeStyle(a,o)?.toJson()};return n.syncExecuteCommand(cY.id,t)?(r.pushUndoRedo({unitID:a,undoMutations:[{id:cY.id,params:c}],redoMutations:[{id:lY.id,params:s}]}),!0):!1}},tmt={id:`sheet.mutation.add-range-theme`,type:L.MUTATION,handler:(e,t)=>{if(!t)return!1;let{styleJSON:n,unitId:r}=t,i=e.get(RG),a=new LG(n.name);return a.fromJson(n),i.registerRangeThemeStyle(r,a),!0}},nmt={id:`sheet.mutation.empty`,type:L.MUTATION,handler:()=>!0},HX={id:`sheet.mutation.mark-dirty-filter-change`,type:L.MUTATION,handler:()=>!0},rmt={id:`sheet.mutation.remove-range-theme`,type:L.MUTATION,handler:(e,t)=>{if(!t)return!1;let{styleName:n,unitId:r}=t;return e.get(RG).unregisterRangeThemeStyle(r,n),!0}},imt={id:`sheet.mutation.set-range-theme`,type:L.MUTATION,handler:(e,t)=>{if(!t)return!1;let{unitId:n,styleName:r,style:i}=t,a=e.get(RG).getRangeThemeStyle(n,r);return a&&(i.headerRowStyle&&a.setHeaderRowStyle(i.headerRowStyle),i.firstRowStyle&&a.setFirstRowStyle(i.firstRowStyle),i.secondRowStyle&&a.setSecondRowStyle(i.secondRowStyle),i.lastRowStyle&&a.setLastRowStyle(i.lastRowStyle)),!0}},amt={id:`sheet.operation.mark-dirty-row-auto-height`,type:L.OPERATION,handler:()=>!0},omt={id:`sheet.operation.cancel-mark-dirty-row-auto-height`,type:L.OPERATION,handler:()=>!0},UX={id:`sheet.operation.scroll-to-cell`,type:L.OPERATION,handler:()=>!0},{getLenS:smt,getDataIndex:cmt,fillCopy:lmt,fillCopyStyles:umt,generateNullCellValueRowCol:dmt}=RJ,{otherRule:fmt}=Pft,WX=class extends P{constructor(e,t,n){super(),this._univerInstanceService=e,this._autoFillService=t,this._injector=n,Z(this,`_beforeApplyData`,[]),Z(this,`_copyData`,[]),this._init()}_init(){this._initDefaultHook()}quit(){this._beforeApplyData=[],this._copyData=[]}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook({id:`default`,type:`DEFAULT`,priority:0,onBeforeFillData:(e,t)=>this._presetAndCacheData(e,t),onFillData:(e,t,n)=>this._fillData(e,t,n)}))}_presetAndCacheData(e,t){let{unitId:n,subUnitId:r,target:i}=e,a=this._univerInstanceService.getUnit(n)?.getSheetBySheetId(r);if(!a)throw Error(`Worksheet not found for unitId: ${n}, subUnitId: ${r}`);let o=a.getCellMatrix(),s=[];return i.rows.forEach(e=>{let t=[];i.cols.forEach(n=>{t.push(F.deepClone(o.getValue(e,n)))}),s.push(t)}),this._beforeApplyData=s,this._copyData=this._getCopyData(e,t),this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(`SERIES`,!0),`COPY`):(this._autoFillService.setDisableApplyType(`SERIES`,!1),this._getPreferredApplyType(this._copyData))}_getApplyData(e,t,n,r,i,a=!0,o){let s=[],c=Math.floor(n/t),l=n%t,u=this._autoFillService.getRules();if(!a&&i===`ONLY_FORMAT`)return console.error(`ERROR: only format can not be applied when hasStyle is false`),[];let d={};u.forEach(e=>{d[e.type]=[]}),u.forEach(a=>{let{type:s,applyFunctions:u={}}=a,f=e[s];f&&f.forEach(a=>{let f=smt(a.index,l),p=a.index.length*c+f,m=this._applyFunctions(a,p,r,i,u,e,o),h=cmt(t,n,a.index);d[s].push({data:m,index:h})})});for(let e=0;e<n;e++)u.forEach(t=>{let{type:n}=t,r=d[n];for(let t=0;t<r.length;t++)e in r[t].index&&s.push(r[t].data[r[t].index[e]])});return s}_applyFunctions(e,t,n,r,i,a,o){let{data:s}=e,c=n===I.UP||n===I.LEFT;if(r===`COPY`){let r=i?.COPY;return r?r(e,t,n,a,o):(c&&s.reverse(),lmt(s,t))}if(r===`SERIES`){let r=i?.SERIES;return r?r(e,t,n,a):(c&&s.reverse(),i?.COPY?i.COPY(e,t,n,a,o):lmt(s,t))}if(r===`ONLY_FORMAT`){let r=i?.ONLY_FORMAT;return r?r(e,t,n,a):umt(s,t)}}_getCopyData(e,t){let{unitId:n,subUnitId:r,source:i}=e,a=this._univerInstanceService.getUnit(n)?.getSheetBySheetId(r);if(!a)throw Error(`No worksheet found`);let o=a.getCellMatrix(),s=this._autoFillService.getRules(),c=[],l=t===I.DOWN||t===I.UP,u,d;return l?(u=i.cols,d=i.rows):(u=i.rows,d=i.cols),u.forEach(e=>{let t=this._getEmptyCopyDataPiece(),n={type:void 0,cellData:void 0};d.forEach(r=>{let i;i=l?o.getValue(r,e):o.getValue(e,r);let{type:a,isContinue:c}=s.find(e=>e.match(i,this._injector))||fmt;if(c(n,i)){let e=t[a],n=e[e.length-1];n.data.push(i),n.index.push(r-d[0])}else{let e=t[a];e?e.push({data:[i],index:[r-d[0]]}):t[a]=[{data:[i],index:[r-d[0]]}]}n.type=a,n.cellData=i}),c.push(t)}),c}_getEmptyCopyDataPiece(){let e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,n,r,i){let{unitId:a,subUnitId:o}=i,s=this._univerInstanceService.getUnit(a)?.getSheetBySheetId(o);if(!s)throw Error(`No active sheet found`);let c=[];for(let i=e.startRow;i<=e.endRow;i++)for(let a=e.startColumn;a<=e.endColumn;a++){let{isMergedMainCell:e,startRow:o,startColumn:l,endRow:u,endColumn:d}=s.getCellInfoInMergeData(i,a);if(e){if(n===I.DOWN){let e=o+r,n=u+r;for(;n<=t.endRow;)c.push({startRow:e,startColumn:l,endRow:n,endColumn:d}),e+=r,n+=r}else if(n===I.UP){let e=o-r,n=u-r;for(;e>=t.startRow;)c.push({startRow:e,startColumn:l,endRow:n,endColumn:d}),e-=r,n-=r}else if(n===I.RIGHT){let e=l+r,n=d+r;for(;n<=t.endColumn;)c.push({startRow:o,startColumn:e,endRow:u,endColumn:n}),e+=r,n+=r}else if(n===I.LEFT){let e=l-r,n=d-r;for(;e>=t.startColumn;)c.push({startRow:o,startColumn:e,endRow:u,endColumn:n}),e-=r,n-=r}}}return c}_fillData(e,t,n){let r=[],i=[],a=!0;n===`NO_FORMAT`&&(a=!1,n=`SERIES`);let{source:o,target:s,unitId:c,subUnitId:l}=e;if(!o||!s||t==null)return{undos:r,redos:i};let u=PK(o),d=PK(s),{cols:f,rows:p}=s,{cols:m,rows:h}=o,g=this._copyData,_;_=t===I.DOWN||t===I.UP?h.length:m.length;let v=[];if(t===I.DOWN||t===I.UP){let r=p.length,i=[];f.forEach((o,s)=>{let c=g[s],l=this._getApplyData(c,_,r,t,n,a,e);i.push(l)});for(let e=0;e<i[0].length;e++){let t=[];for(let n=0;n<i.length;n++)t.push({s:null,...i[n][e]});v.push(t)}}else{let r=f.length;p.forEach((i,o)=>{let s=g[o],c=this._getApplyData(s,_,r,t,n,a,e),l=[];for(let e=0;e<c.length;e++)l.push({s:null,...c[e]});v.push(l)})}let y=[],b=this._univerInstanceService.getUnit(c)?.getStyles();if(a?(y=this._getMergeApplyData(u,d,t,_,e),v.forEach(e=>{e.forEach(e=>{e&&b&&b&&(e.s=b.getStyleByCell(e))})})):v.forEach((e,t)=>{e.forEach((e,n)=>{e&&b&&(e.s=b.getStyleByCell(this._beforeApplyData[t][n])||null)})}),n===`ONLY_FORMAT`&&v.forEach((e,t)=>{e.forEach((e,n)=>{if(e){let r=this._beforeApplyData[t][n]||{};e.f=r.f,e.si=r.si,e.t=r.t,e.v=r.v}})}),a){var x;let e=[],t=(x=this._univerInstanceService.getUniverSheetInstance(c))==null||(x=x.getSheetBySheetId(l))==null?void 0:x.getMergeData();if(t&&t.forEach(t=>{d_.intersects(t,d)&&e.push(t)}),e.length){let t={unitId:c,subUnitId:l,ranges:e},n=this._injector.invoke(XG,t);i.push({id:ZG.id,params:t}),r.unshift({id:TG.id,params:n})}}let S={subUnitId:l,unitId:c,cellValue:dmt([s])},C=this._injector.invoke(cK,S);i.push({id:lK.id,params:S}),r.unshift({id:lK.id,params:C});let w=new Rh;p.forEach((e,t)=>{f.forEach((n,r)=>{v[t][r]&&w.setValue(e,n,v[t][r])})});let T=w.getMatrix(),E={subUnitId:l,unitId:c,cellValue:T},D=this._injector.invoke(cK,E);if(this._autoFillService.getActiveHooks().forEach(r=>{var i;(i=r.onBeforeSubmit)==null||i.call(r,e,t,n,T)}),r.unshift({id:lK.id,params:D}),i.push({id:lK.id,params:E}),y?.length){let e={unitId:c,subUnitId:l,ranges:tJ(y)},t=this._injector.invoke(wG,e);r.unshift({id:ZG.id,params:t}),i.push({id:TG.id,params:e})}return{undos:r,redos:i}}_shouldDisableSeries(e){return e.every(e=>Object.keys(e).every(t=>e[t]?.length===0||[`other`,`formula`].includes(t)))}_getPreferredApplyType(e){return e.every(e=>Object.keys(e).every(t=>e[t]?.length===0||e[t]?.length===1&&e[t][0].data.length===1&&t===`number`))?`COPY`:`SERIES`}};WX=AG([kG(0,z),kG(1,YJ),kG(2,j(We))],WX);var pmt=`maxCellsPerSheet`,mmt=3e6,hmt=`SHEET_DEFINED_NAME_PLUGIN`,GX=`AllDefaultWorkbook`,KX=class extends P{constructor(e,t){super(),this._definedNamesService=e,this._resourceManagerService=t,this._initialize()}_initialize(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._definedNamesService.getDefinedNameMap(e);return t?JSON.stringify(t):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:hmt,businesses:[M.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._definedNamesService.removeUnitDefinedName(e)},onLoad:(e,t)=>{this._definedNamesService.registerDefinedNames(e,t)}}))}};KX=AG([kG(0,Fz),kG(1,By)],KX);var gmt=[CY.id],_mt=[HG.id,WG.id,JG.id,YG.id,KG.id,qG.id],qX=class extends P{constructor(e,t,n){super(),this._univerInstanceService=e,this._commandService=t,this._configService=n,Z(this,`_d`,new Gf),Z(this,`_enabled`,!0);let r=this._configService.getConfig(`sheets.config`)?.freezeSync??!0;this.setEnabled(r)}getEnabled(){return this._enabled}setEnabled(e){e?this._d.dispose():this._initOnlyLocalListener(),this._enabled=e}_initOnlyLocalListener(){this._d.add(this._commandService.beforeCommandExecuted((e,t)=>{gmt.includes(e.id)&&(t||={},t.onlyLocal=!0)})),this._d.add(this._commandService.onCommandExecuted((e,t)=>{if(_mt.includes(e.id)&&t?.fromCollab){let{id:n,params:r}=e;n===HG.id?this._handleInsertRowMutation(r,t):n===WG.id?this._handleInsertColMutation(r,t):n===JG.id?this._handleRemoveRowMutation(r,t):n===YG.id?this._handleRemoveColMutation(r,t):n===KG.id?this._handleMoveRowsMutation(r,t):n===qG.id&&this._handleMoveColsMutation(r,t)}}))}_handleInsertRowMutation(e,t){let{range:n,unitId:r,subUnitId:i}=e,a=this._getFreeze(r,i);if(a&&n.startRow<a.startRow){let e=n.endRow-n.startRow+1,o={...a,startRow:Math.max(1,a.startRow+e),ySplit:Math.max(1,a.ySplit+e)};this._sequenceExecute(r,i,o,t)}}_handleInsertColMutation(e,t){let{range:n,unitId:r,subUnitId:i}=e,a=this._getFreeze(r,i);if(a&&n.startColumn<a.startColumn){let e=n.endColumn-n.startColumn+1,o={...a,startColumn:Math.max(1,a.startColumn+e),xSplit:Math.max(1,a.xSplit+e)};this._sequenceExecute(r,i,o,t)}}_handleRemoveRowMutation(e,t){let{range:n,unitId:r,subUnitId:i}=e,a=this._getFreeze(r,i);if(a&&n.startRow<a.startRow){let e=Math.min(a.startRow,n.endRow+1)-n.startRow,o={...a,startRow:Math.max(1,a.startRow-e),ySplit:Math.max(1,a.ySplit-e)};this._sequenceExecute(r,i,o,t)}}_handleRemoveColMutation(e,t){let{range:n,unitId:r,subUnitId:i}=e,a=this._getFreeze(r,i);if(a&&n.startColumn<a.startColumn){let e=Math.min(a.startColumn,n.endColumn+1)-n.startColumn,o={...a,startColumn:Math.max(1,a.startColumn-e),xSplit:Math.max(1,a.xSplit-e)};this._sequenceExecute(r,i,o,t)}}_handleMoveRowsMutation(e,t){let{sourceRange:n,targetRange:r,unitId:i,subUnitId:a}=e,o=this._getFreeze(i,a);if(!o||o.startRow<=0||n.startRow>=o.startRow&&r.startRow>=o.startRow||n.endRow<o.startRow&&r.endRow<o.startRow)return;let s=n.endRow-n.startRow+1,c=Math.max(Math.min(o.startRow,n.endRow+1)-n.startRow,0),l={...o};r.startRow>=o.startRow?(l.startRow=Math.max(1,o.startRow-c),l.ySplit=Math.max(1,o.ySplit-c)):(l.startRow=o.startRow+s-c,l.ySplit=o.ySplit+s-c),this._sequenceExecute(i,a,l,t)}_handleMoveColsMutation(e,t){let{sourceRange:n,targetRange:r,unitId:i,subUnitId:a}=e,o=this._getFreeze(i,a);if(!o||o.startColumn<=0||n.startColumn>=o.startColumn&&r.startColumn>=o.startColumn||n.endColumn<o.startColumn&&r.endColumn<o.startColumn)return;let s=n.endColumn-n.startColumn+1,c=Math.max(Math.min(o.startColumn,n.endColumn+1)-n.startColumn,0),l={...o};r.startColumn>=o.startColumn?(l.startColumn=Math.max(1,o.startColumn-c),l.xSplit=Math.max(1,o.xSplit-c)):(l.startColumn=o.startColumn+s-c,l.xSplit=o.xSplit+s-c),this._sequenceExecute(i,a,l,t)}_getFreeze(e,t){let n=this._univerInstanceService.getUnit(e,M.UNIVER_SHEET);if(!n)return null;let r=n.getSheetBySheetId(t);return r?r.getFreeze():null}_sequenceExecute(e,t,n,r){Km([{id:CY.id,params:{...n,unitId:e,subUnitId:t,resetScroll:!1}}],this._commandService,r)}};qX=AG([kG(0,j(z)),kG(1,R),kG(2,Nm)],qX);var JX=class extends P{constructor(e,t,n,r,i,a,o,s,c){super(),this._commandService=e,this._univerInstanceService=t,this._permissionService=n,this._selectionManagerService=r,this._rangeProtectionRuleModel=i,this._worksheetProtectionRuleModel=a,this._localeService=o,this._lexerTreeBuilder=s,this._definedNamesService=c,Z(this,`disposableCollection`,new Gf),Z(this,`_triggerPermissionUIEvent$`,new ao),Z(this,`triggerPermissionUIEvent$`,this._triggerPermissionUIEvent$.asObservable()),this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{this._getPermissionCheck(e)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===HY.id){let t=SG(this._univerInstanceService,e.params);if(!t)return;let{unitId:n,subUnitId:r}=t,i=this._worksheetProtectionRuleModel.getRule(n,r);i&&this._worksheetProtectionRuleModel.ruleRefresh(i.permissionId),this._rangeProtectionRuleModel.getSubunitRuleList(n,r).length&&this._rangeProtectionRuleModel.ruleRefresh(r)}}))}blockExecuteWithoutPermission(e){throw this._triggerPermissionUIEvent$.next(e),new mf(`have no permission`)}_getPermissionCheck(e){let{id:t}=e,n=!0,r=``,i;switch(t){case lq.id:i=e.params,gh(i.value)&&i.value.f?(n=this._permissionCheckWithFormula(i),r=this._localeService.t(`sheets.permission.dialog.formulaErr`)):(n=this._permissionCheckBySetRangeValue({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},i),r=this._localeService.t(`sheets.permission.dialog.editErr`));break;case gJ.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[CX,_X],rangeTypes:[JY]},i.range?[i.range]:void 0,i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setStyleErr`);break;case hY.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[CX,_X],rangeTypes:[JY]},i?.ranges,i?.unitId,i?.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setStyleErr`);break;case XK.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,CX,_X],rangeTypes:[JY]},i?.ranges,i?.unitId,i?.subUnitId),r=this._localeService.t(`sheets.permission.dialog.editErr`);break;case QJ.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},i?.ranges,i?.unitId,i?.subUnitId),r=this._localeService.t(`sheets.permission.dialog.editErr`);break;case ZK.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[CX,_X],rangeTypes:[JY]},i?.ranges,i?.unitId,i?.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setStyleErr`);break;case RY.id:n=this.permissionCheckWithoutRange({worksheetTypes:[TX]}),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case zY.id:i=e.params,n=this.permissionCheckWithoutRange({worksheetTypes:[TX]},i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case NX.id:n=this.permissionCheckWithoutRange({worksheetTypes:[EX]}),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case PX.id:case FX.id:i=e.params,n=this.permissionCheckWithoutRange({worksheetTypes:[EX]},i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case jq.id:case Mq.id:i=e.params,n=this._permissionCheckByMoveRowsColsCommand(i),r=this._localeService.t(`sheets.permission.dialog.moveRowColErr`);break;case sq.id:i=e.params,n=this._permissionCheckByMoveRangeCommand(i),r=this._localeService.t(`sheets.permission.dialog.moveRangeErr`);break;case hq.id:case bq.id:i=e.params,n=this._permissionCheckByInsertRowColCommand(i),r=this._localeService.t(`sheets.permission.dialog.insertRowColErr`);break;case Tq.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX,rX],worksheetTypes:[_X,gX],rangeTypes:[JY]},[i.range],i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.removeRowColErr`);break;case Oq.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX,nX],worksheetTypes:[_X,mX],rangeTypes:[JY]},[i.range],i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.removeRowColErr`);break;case GY.id:i=e.params,n=this._permissionCheckByWorksheetCommand([aX,uX],i),r=this._localeService.t(`sheets.permission.dialog.operatorSheetErr`);break;case UY.id:i=e.params,n=this._permissionCheckByWorksheetCommand([aX,dX],i),r=this._localeService.t(`sheets.permission.dialog.operatorSheetErr`);break;case IX.id:i=e.params,n=this._permissionCheckByWorksheetCommand([aX,oX],i),r=this._localeService.t(`sheets.permission.dialog.operatorSheetErr`);break;case vY.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[_X,TX],rangeTypes:[JY]},i.ranges,i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case jY.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[_X,EX],rangeTypes:[JY]},i.ranges,i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case yY.id:n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[_X,TX],rangeTypes:[JY]}),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case MY.id:n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[_X,EX],rangeTypes:[JY]}),r=this._localeService.t(`sheets.permission.dialog.setRowColStyleErr`);break;case pq.id:i=e.params,n=this._permissionCheckWithInsertOrDeleteMoveRange(`right`,i),r=this._localeService.t(`sheets.permission.dialog.insertOrDeleteMoveRangeErr`);break;case fq.id:i=e.params,n=this._permissionCheckWithInsertOrDeleteMoveRange(`down`,i),r=this._localeService.t(`sheets.permission.dialog.insertOrDeleteMoveRangeErr`);break;case uq.id:i=e.params,n=this._permissionCheckWithInsertOrDeleteMoveRange(`left`,i),r=this._localeService.t(`sheets.permission.dialog.insertOrDeleteMoveRangeErr`);break;case dq.id:i=e.params,n=this._permissionCheckWithInsertOrDeleteMoveRange(`up`,i),r=this._localeService.t(`sheets.permission.dialog.insertOrDeleteMoveRangeErr`);break;case XJ.id:i=e.params,n=this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},[i.targetRange],i.unitId,i.subUnitId),r=this._localeService.t(`sheets.permission.dialog.autoFillErr`);break;case aY.id:case xY.id:case uY.id:i=e.params,n=!i.localSheetId||i.localSheetId===`AllDefaultWorkbook`?this.permissionCheckWithoutRange({workbookTypes:[aX]},i.unitId):this.permissionCheckWithoutRange({workbookTypes:[aX],worksheetTypes:[_X]},i.unitId,i.localSheetId),r=this._localeService.t(`sheets.permission.dialog.editErr`)}n||this.blockExecuteWithoutPermission(r)}permissionCheckWithRanges(e,t,n,r){let i=SG(this._univerInstanceService,{unitId:n,subUnitId:r});if(!i)return!1;let{unitId:a,subUnitId:o}=i,{workbookTypes:s,worksheetTypes:c,rangeTypes:l}=e;if(s&&s.some(e=>{let t=new e(a);return this._permissionService.getPermissionPoint(t.id)?.value===!1})||c&&c.some(e=>{let t=new e(a,o);return this._permissionService.getPermissionPoint(t.id)?.value===!1}))return!1;if(l&&l.length>0){let e=t??this._selectionManagerService.getCurrentSelections()?.map(e=>e.range);if(!e)return!1;let n=this._rangeProtectionRuleModel.getSubunitRuleList(a,o);if(n.length===0)return!0;for(let t=0;t<n.length;t++){let r=n[t];if(e.some(e=>r.ranges.some(t=>d_.intersects(t,e)))){let e=r.permissionId;if(l.some(t=>{let n=new t(a,o,e);return this._permissionService.getPermissionPoint(n.id)?.value===!1}))return!1}}}return!0}permissionCheckWithoutRange(e,t,n){let r=SG(this._univerInstanceService,{unitId:t,subUnitId:n});if(!r)return!1;let{worksheet:i,unitId:a,subUnitId:o}=r,{workbookTypes:s,worksheetTypes:c,rangeTypes:l}=e;if(s&&s.some(e=>{let t=new e(a);return this._permissionService.getPermissionPoint(t.id)?.value===!1})||c&&c.some(e=>{let t=new e(a,o);return this._permissionService.getPermissionPoint(t.id)?.value===!1}))return!1;if(l&&l.length>0){var u;let e=this._selectionManagerService.getCurrentLastSelection()?.primary;if(!e)return!1;let{actualRow:t,actualColumn:n}=e,r=i.getCell(t,n),s=r==null||(u=r.selectionProtection)==null?void 0:u[0];if(!s?.ruleId)return!0;let c=this._rangeProtectionRuleModel.getRule(a,o,s.ruleId)?.permissionId;if(!c)return!0;if(l.some(e=>{let t=new e(a,o,c);return this._permissionService.getPermissionPoint(t.id)?.value===!1}))return!1}return!0}_permissionCheckWithFormula(e){let t=SG(this._univerInstanceService,e);if(!t)return!1;let{workbook:n,unitId:r,subUnitId:i}=t,a=e.value.f;if(a){let e=a.substring(1),t=this._definedNamesService.getValueByName(r,e);if(t){let e=t.formulaOrRefString;e.startsWith(AR.EQUALS)&&(e=e.slice(1));let r=e.split(`,`);for(let e=0;e<r.length;e++){let t=r[e],{sheetName:i,range:a}=Ez(t);if(i){let e=n.getSheetBySheetName(i);if(!e)return!0;let{startRow:t,endRow:r,startColumn:s,endColumn:c}=a;for(let n=t;n<=r;n++)for(let t=s;t<=c;t++){var o;let r=e.getCell(n,t);if((r==null||(o=r.selectionProtection)==null?void 0:o[0])?.[ta.View]===!1)return!1}}}return!0}{let e=this._lexerTreeBuilder.sequenceNodesBuilder(a);if(!e)return!0;for(let t=0;t<e.length;t++){let i=e[t];if(typeof i==`string`||i.nodeType!==bB.REFERENCE)continue;let{token:a}=i,{unitId:o,sheetName:c,range:l}=yB(a),u=n;if(o&&o!==r){let e=this._univerInstanceService.getUnit(o,M.UNIVER_SHEET);if(!e)return!0;u=e}let d=c?u.getSheetBySheetName(c):u.getActiveSheet();if(!d)return!0;if(c){let e=this._permissionService.getPermissionPoint(new OX(u.getUnitId(),d.getSheetId()).id);if(!e||e.value===!1)return!1}let{startRow:f,endRow:p,startColumn:m,endColumn:h}=l;for(let e=f;e<=p;e++)for(let t=m;t<=h;t++){var s;let n=d.getCell(e,t);if((n==null||(s=n.selectionProtection)==null?void 0:s[0])?.[ta.View]===!1)return!1}}return!0}}let{range:c}=e;if(c){let e=this._rangeProtectionRuleModel.getSubunitRuleList(r,i);if(e.length===0)return!0;let t=e.filter(e=>e.ranges.some(e=>d_.intersects(e,c))).map(e=>new JY(r,i,e.permissionId).id);return this._permissionService.composePermission(t).every(e=>e.value)}return!0}_permissionCheckBySetRangeValue(e,t){let{unitId:n,subUnitId:r,value:i,range:a}=t,o=[];return o=(F.isArray(i)||gh(i))&&a?[a]:[new Rh(i).getStartEndScope()],this.permissionCheckWithRanges(e,o,n,r)}_permissionCheckByMoveRowsColsCommand(e){let t=SG(this._univerInstanceService,e);if(!t)return!1;let{worksheet:n,unitId:r,subUnitId:i}=t,{fromRange:a,toRange:o}=e;if(!this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},[a],r,i))return!1;let s={...o};return s.endRow===n.getRowCount()-1?s.endColumn=s.startColumn:s.endRow=s.startRow,this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},[s],r,i)}_permissionCheckByMoveRangeCommand(e){let{fromUnitId:t,fromSubUnitId:n,fromRange:r,toUnitId:i,toSubUnitId:a,toRange:o}=e,s=SG(this._univerInstanceService,{unitId:t,subUnitId:n});if(!s)return!1;let c=SG(this._univerInstanceService,{unitId:i,subUnitId:a});return!c||!this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},[r],s.unitId,s.subUnitId)?!1:this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[wX,_X],rangeTypes:[JY]},[o],c.unitId,c.subUnitId)}_permissionCheckByInsertRowColCommand(e){let t=SG(this._univerInstanceService,e);if(!t)return!1;let{worksheet:n,unitId:r,subUnitId:i}=t,{range:a,direction:o}=e,s={...a},c={workbookTypes:[aX],worksheetTypes:[_X],rangeTypes:[JY]};if(o===I.UP||o===I.DOWN){let e=o===I.UP?a.startRow:a.startRow-1;if(e<0||e>n.getRowCount()-1)return!1;s.startRow=e,s.endRow=e,c.workbookTypes.push(cX),c.worksheetTypes.push(xX)}else if(o===I.LEFT||o===I.RIGHT){let e=o===I.LEFT?a.startColumn:a.startColumn-1;if(e<0||e>n.getColumnCount()-1)return!1;s.startColumn=e,s.endColumn=e,c.workbookTypes.push(sX),c.worksheetTypes.push(yX)}return this.permissionCheckWithRanges(c,[s],r,i)}_permissionCheckByWorksheetCommand(e,t){let n=SG(this._univerInstanceService,t);if(!n)return this._worksheetProtectionRuleModel.resetOrder(),!1;let{unitId:r}=n;return!e.some(e=>{let t=new e(r);return this._permissionService.getPermissionPoint(t.id)?.value===!1})||(this._worksheetProtectionRuleModel.resetOrder(),!1)}_permissionCheckWithInsertOrDeleteMoveRange(e,t){let n=SG(this._univerInstanceService);if(!n)return!1;let{worksheet:r,unitId:i,subUnitId:a}=n,o=t?.range??this._selectionManagerService.getCurrentLastSelection()?.range;if(!o||!this.permissionCheckWithRanges({workbookTypes:[aX],worksheetTypes:[_X],rangeTypes:[JY]},[o],i,a))return!1;let s=this._rangeProtectionRuleModel.getSubunitRuleList(i,a);if(s.length===0)return!0;let c={...o};return e===`right`||e===`left`?c.endColumn=r.getColumnCount()-1:(e===`down`||e===`up`)&&(c.endRow=r.getRowCount()-1),!s.some(e=>e.ranges.some(e=>d_.intersects(e,c)))}};JX=AG([kG(0,R),kG(1,z),kG(2,ox),kG(3,j(WK)),kG(4,j(BK)),kG(5,j(fJ)),kG(6,j(nx)),kG(7,j(TB)),kG(8,Fz)],JX);var YX=class extends P{constructor(e,t,n,r,i){super(),this._permissionService=e,this._univerInstanceService=t,this._rangeProtectionRuleModel=n,this._worksheetProtectionRuleModel=r,this._worksheetProtectionPointModel=i,Z(this,`_unitPermissionInitStateChange`,new so(!1)),Z(this,`unitPermissionInitStateChange$`,this._unitPermissionInitStateChange.asObservable()),this._init()}_init(){let e=e=>{let t=e.getUnitId();kX().forEach(e=>{let n=new e(t);this._permissionService.addPermissionPoint(n)})};this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).forEach(t=>e(t)),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(M.UNIVER_SHEET).subscribe(t=>e(t.unit))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(M.UNIVER_SHEET).subscribe(e=>{let t=e.getUnitId();e.getSheets().forEach(e=>{let n=e.getSheetId();this._rangeProtectionRuleModel.getSubunitRuleList(t,n).forEach(e=>{[...ZY()].forEach(r=>{let i=new r(t,n,e.permissionId);this._permissionService.deletePermissionPoint(i.id)})}),[...AX(),...jX()].forEach(e=>{let r=new e(t,n);this._permissionService.deletePermissionPoint(r.id)})}),kX().forEach(e=>{let n=new e(t);this._permissionService.deletePermissionPoint(n.id)}),this._rangeProtectionRuleModel.deleteUnitModel(t),this._worksheetProtectionPointModel.deleteUnitModel(t),this._worksheetProtectionRuleModel.deleteUnitModel(t)}))}changeUnitInitState(e){this._unitPermissionInitStateChange.next(e)}};YX=AG([kG(0,j(ox)),kG(1,j(z)),kG(2,j(BK)),kG(3,j(fJ)),kG(4,j(KY))],YX);var XX=class extends P{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._univerInstanceService=e,this._permissionService=t,this._authzIoService=n,this._rangeProtectionRuleModel=r,this._worksheetProtectionRuleModel=i,this._userManagerService=a,this._worksheetProtectionPointRuleModel=o,this._workbookPermissionService=s,this._undoRedoService=c,this._commandService=l}initPermission(){this._initRangePermissionFromSnapshot(),this._initRangePermissionChange(),this._initWorksheetPermissionFromSnapshot(),this._initWorksheetPermissionChange(),this._initWorksheetPermissionPointsChange(),this._initWorkbookPermissionFromSnapshot(),this._initUserChange(),this._refreshPermissionByCollaCreate()}refreshRangeProtectPermission(){this._initRangePermissionFromSnapshot()}async _initRangePermissionFromSnapshot(){let e=async e=>{let t=[],n=e.getUnitId(),r=e.getSheets(),i=new Map;if(r.forEach(e=>{let r=e.getSheetId();this._rangeProtectionRuleModel.getSubunitRuleList(n,r).forEach(e=>{i.set(e.permissionId,e),t.push({objectID:e.permissionId,unitID:n,objectType:ra.SelectRange,actions:QY})})}),!t.length){this._rangeProtectionRuleModel.changeRuleInitState(!0);return}this._authzIoService.batchAllowed(t).then(e=>{e.forEach(e=>{let t=i.get(e.objectID);if(t){if(!this._rangeProtectionRuleModel.getRule(n,t.subUnitId,t.id))return;ZY().forEach(r=>{let i=new r(n,t.subUnitId,e.objectID),a=i.subType,o=e.actions.find(e=>e.action===a);o?.allowed!==void 0&&this._permissionService.updatePermissionPoint(i.id,o.allowed)})}}),this._rangeProtectionRuleModel.changeRuleInitState(!0)})};await Promise.all(this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).map(t=>e(t))),this._rangeProtectionRuleModel.changeRuleInitState(!0)}_initRangePermissionChange(){this.disposeWithMe(this._rangeProtectionRuleModel.ruleChange$.subscribe(e=>{e.type===`delete`?this._rangeProtectionRuleModel.getSubunitRuleList(e.unitId,e.subUnitId).length===0&&(this._worksheetProtectionPointRuleModel.deleteRule(e.unitId,e.subUnitId),[...jX()].forEach(t=>{let n=new t(e.unitId,e.subUnitId);this._permissionService.updatePermissionPoint(n.id,n.value)})):this._authzIoService.allowed({objectID:e.rule.permissionId,unitID:e.unitId,objectType:ra.SelectRange,actions:QY}).then(t=>{this._rangeProtectionRuleModel.getRule(e.unitId,e.subUnitId,e.rule.id)&&(ZY().forEach(n=>{if(e.type===`set`){let{rule:t,oldRule:n}=e;if(t.permissionId===n?.permissionId)return}let r=e.rule,i=new n(r.unitId,r.subUnitId,r.permissionId),a=i.subType,o=t.find(e=>e.action===a);o&&this._permissionService.updatePermissionPoint(i.id,o.allowed)}),this._rangeProtectionRuleModel.ruleRefresh(e.rule.permissionId))})}))}async initWorkbookPermissionChange(e){let t=e||this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET)?.getUnitId();if(t)return this._authzIoService.allowed({objectID:t,objectType:ra.Workbook,unitID:t,actions:Vpt}).then(e=>{kX().forEach(n=>{let r=new n(t),i=r.subType,a=e.find(e=>e.action===i);a&&this._permissionService.updatePermissionPoint(r.id,a.allowed)})})}async _initWorkbookPermissionFromSnapshot(){await Promise.all(this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).map(e=>this.initWorkbookPermissionChange(e.getUnitId()))),this._workbookPermissionService.changeUnitInitState(!0)}_initWorksheetPermissionChange(){this.disposeWithMe(this._worksheetProtectionRuleModel.ruleChange$.subscribe(e=>{e.type===`delete`?([...AX(),...jX()].forEach(t=>{let n=new t(e.unitId,e.subUnitId);this._permissionService.updatePermissionPoint(n.id,!0)}),this._worksheetProtectionPointRuleModel.deleteRule(e.unitId,e.subUnitId)):this._authzIoService.allowed({objectID:e.rule.permissionId,unitID:e.unitId,objectType:ra.Worksheet,actions:QY}).then(t=>{let n=this._worksheetProtectionRuleModel.getRule(e.unitId,e.subUnitId);n&&n.permissionId===e.rule.permissionId&&(AX().forEach(n=>{let r=new n(e.unitId,e.subUnitId),i=r.subType,a=t.find(e=>e.action===i);a&&this._permissionService.updatePermissionPoint(r.id,a.allowed)}),this._worksheetProtectionRuleModel.ruleRefresh(e.rule.permissionId))})}))}_initWorksheetPermissionPointsChange(){this.disposeWithMe(this._worksheetProtectionPointRuleModel.pointChange$.subscribe(e=>{this._authzIoService.allowed({objectID:e.permissionId,unitID:e.unitId,objectType:ra.Worksheet,actions:Hpt}).then(t=>{let n=this._worksheetProtectionPointRuleModel.getRule(e.unitId,e.subUnitId);n&&n.permissionId===e.permissionId&&jX().forEach(n=>{let r=new n(e.unitId,e.subUnitId),i=r.subType,a=t.find(e=>e.action===i);a&&this._permissionService.updatePermissionPoint(r.id,a.allowed)})})}))}async _initWorksheetPermissionFromSnapshot(){let e=async e=>{let t=[],n=e.getUnitId(),r=e.getSheets(),i=new Map;if(r.forEach(e=>{let r=e.getSheetId(),a=this._worksheetProtectionRuleModel.getRule(n,r);a&&(i.set(a.permissionId,a),t.push({objectID:a.permissionId,unitID:n,objectType:ra.Worksheet,actions:QY}));let o=this._worksheetProtectionPointRuleModel.getRule(n,r);o&&(i.set(o.permissionId,o),t.push({objectID:o.permissionId,unitID:n,objectType:ra.Worksheet,actions:Hpt}))}),!t.length){this._worksheetProtectionRuleModel.changeRuleInitState(!0);return}this._authzIoService.batchAllowed(t).then(e=>{e.forEach(e=>{let t=i.get(e.objectID);if(t){let r=this._worksheetProtectionRuleModel.getRule(n,t.subUnitId)||this._worksheetProtectionPointRuleModel.getRule(n,t.subUnitId);if(!r||r.permissionId!==e.objectID)return;[...AX(),...jX()].forEach(r=>{let i=new r(n,t.subUnitId),a=i.subType,o=e.actions.find(e=>e.action===a);o?.allowed!==void 0&&this._permissionService.updatePermissionPoint(i.id,o.allowed)})}}),this._worksheetProtectionRuleModel.changeRuleInitState(!0)})};await Promise.all(this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).map(t=>e(t))),this._worksheetProtectionRuleModel.changeRuleInitState(!0)}_initUserChange(){this.disposeWithMe(this._userManagerService.currentUser$.pipe(ac(1)).subscribe(()=>{let e=this._permissionService.getAllPermissionPoint();this._permissionService.clearPermissionMap(),this._worksheetProtectionRuleModel.changeRuleInitState(!1),this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).forEach(t=>{let n=t.getUnitId();kX().forEach(t=>{let r=new t(n);e.has(r.id)&&(r=e.get(r.id)),this._permissionService.addPermissionPoint(r)}),t.getSheets().forEach(t=>{let r=t.getSheetId();[...AX(),...jX()].forEach(t=>{let i=new t(n,r);e.has(i.id)&&(i=e.get(i.id)),this._permissionService.addPermissionPoint(i)}),this._rangeProtectionRuleModel.getSubunitRuleList(n,r).forEach(t=>{ZY().forEach(i=>{let a=new i(n,r,t.permissionId);e.has(a.id)&&(a=e.get(a.id)),this._permissionService.addPermissionPoint(a)})})}),this._initWorkbookPermissionFromSnapshot(),this._initWorksheetPermissionFromSnapshot(),this._initRangePermissionFromSnapshot()})}))}refreshPermission(e,t){let n=this._worksheetProtectionRuleModel.getTargetByPermissionId(e,t),r=!1;if(n){let[i,a]=n;this._authzIoService.allowed({objectID:t,unitID:e,objectType:ra.Worksheet,actions:QY}).then(n=>{if(!this._worksheetProtectionRuleModel.getTargetByPermissionId(e,t))return;let i=``;AX().forEach(t=>{let o=new t(e,a),s=o.subType,c=n.find(e=>e.action===s);c&&(this._permissionService.getPermissionPoint(o.id)?.value!==c.allowed&&(r=!0),this._permissionService.updatePermissionPoint(o.id,c.allowed),i+=`${c.action}_${c.allowed}`)}),this._worksheetProtectionRuleModel.ruleRefresh(`${t}_${i}`),r&&this._undoRedoService.clearUndoRedo(e)})}let i=this._worksheetProtectionPointRuleModel.getTargetByPermissionId(e,t);if(i){let[n,a]=i;this._authzIoService.allowed({objectID:t,unitID:e,objectType:ra.Worksheet,actions:Hpt}).then(n=>{this._worksheetProtectionPointRuleModel.getTargetByPermissionId(e,t)&&(jX().forEach(t=>{let i=new t(e,a),o=i.subType,s=n.find(e=>e.action===o);s&&(this._permissionService.getPermissionPoint(i.id)?.value!==s.allowed&&(r=!0),this._permissionService.updatePermissionPoint(i.id,s.allowed))}),r&&this._undoRedoService.clearUndoRedo(e))})}let a=this._rangeProtectionRuleModel.getTargetByPermissionId(e,t);if(a){let[n,i]=a;this._authzIoService.allowed({objectID:t,unitID:e,objectType:ra.SelectRange,actions:QY}).then(n=>{if(!this._rangeProtectionRuleModel.getTargetByPermissionId(e,t))return;let a=``;ZY().forEach(o=>{let s=new o(e,i,t),c=s.subType,l=n.find(e=>e.action===c);l&&(this._permissionService.getPermissionPoint(s.id)?.value!==l.allowed&&(r=!0),this._permissionService.updatePermissionPoint(s.id,l.allowed),a+=`${l.action}_${l.allowed}`)}),this._rangeProtectionRuleModel.ruleRefresh(`${t}_${a}`),r&&this._undoRedoService.clearUndoRedo(e)})}}_refreshPermissionByCollaCreate(){this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{if(t?.fromCollab&&(e.id===HK.id||e.id===pJ.id||e.id===Gpt.id)){let t=e.params;this._undoRedoService.clearUndoRedo(t.unitId)}}))}};XX=AG([kG(0,z),kG(1,ox),kG(2,Ky),kG(3,j(BK)),kG(4,j(fJ)),kG(5,j(Wy)),kG(6,j(KY)),kG(7,j(YX)),kG(8,j(vx)),kG(9,j(R))],XX);var ZX=class extends P{constructor(e,t,n){super(),this._commandService=e,this._sheetRangeThemeModel=t,this._univerInstanceService=n,Z(this,`_zebraCacheUpdateSubject`,new ao),this._init()}_init(){this._initializeCommandListener(),this._initTriggerCacheUpdateListener()}updateZebraCrossingCache(e,t){this._zebraCacheUpdateSubject.next({unitId:e,subUnitId:t})}_initializeCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{let{id:t}=e,n,r;switch(t){case HG.id:{let t=e.params;n=t.unitId,r=t.subUnitId}break;case dK.id:{let t=e.params;n=t.unitId,r=t.subUnitId}break;case fK.id:{let t=e.params;n=t.unitId,r=t.subUnitId}break;case JG.id:{let t=e.params;n=t.unitId,r=t.subUnitId}break;case bK.id:{let t=e.params;n=t.unitId,r=t.subUnitId}}n&&r&&(this._sheetRangeThemeModel.refreshSheetRowVisibleFuncSet(n,r),this._sheetRangeThemeModel.refreshZebraCrossingCacheBySheet(n,r))}))}_initTriggerCacheUpdateListener(){this.disposeWithMe(this._zebraCacheUpdateSubject.subscribe(({unitId:e,subUnitId:t})=>{this._sheetRangeThemeModel.refreshSheetRowVisibleFuncSet(e,t),this._sheetRangeThemeModel.refreshZebraCrossingCacheBySheet(e,t)}))}};ZX=AG([kG(0,j(R)),kG(1,j(RG)),kG(2,j(z))],ZX);var QX=class{constructor(e,t){this._selectionProtectionRuleModel=e,this._permissionService=t,Z(this,`_cache`,new Yg(1e4)),this._init()}_init(){this._permissionService.permissionPointUpdate$.pipe(Ls(e=>e.type===ra.SelectRange),Ls(e=>ZY().some(t=>e instanceof t)),os(e=>e)).subscribe(e=>{let t=this._selectionProtectionRuleModel.getSubunitRuleList(e.unitId,e.subUnitId);for(let n of t)n.permissionId===e.permissionId&&n.ranges.forEach(t=>{t_.foreach(t,(t,n)=>{let r=this._createKey(e.unitId,e.subUnitId,t,n);this._cache.delete(r)})})}),this._selectionProtectionRuleModel.ruleChange$.subscribe(e=>{if(e.rule.ranges.forEach(t=>{t_.foreach(t,(t,n)=>{let r=this._createKey(e.unitId,e.subUnitId,t,n);this._cache.delete(r)})}),e.type===`set`){var t;(t=e.oldRule)==null||t.ranges.forEach(t=>{t_.foreach(t,(t,n)=>{let r=this._createKey(e.unitId,e.subUnitId,t,n);this._cache.delete(r)})})}})}_createKey(e,t,n,r){return`${e}_${t}_${n}_${r}`}getCellInfo(e,t,n,r){let i=this._selectionProtectionRuleModel.getSubunitRuleList(e,t),a=[];if(!i||!i.length)return a;let o=this._createKey(e,t,n,r),s=this._cache.get(o);if(s)return s;let c=[];for(let a of i)if(a.ranges.some(e=>e.startRow<=n&&e.endRow>=n&&e.startColumn<=r&&e.endColumn>=r)){let n=ZY().reduce((n,r)=>{let i=new r(e,t,a.permissionId),o=this._permissionService.getPermissionPoint(i.id);return n[i.subType]=o?.value??i.value,n},{});c.push({...n,ruleId:a.id,ranges:a.ranges})}return this._cache.set(o,c),c}clear(){this._cache.clear()}};QX=AG([kG(0,j(BK)),kG(1,j(ox))],QX);var $X=class extends P{constructor(e,t,n){super(),this._ruleModel=e,this._permissionService=t,this._univerInstanceService=n,Z(this,`_cellRuleCache`,new Map),Z(this,`_permissionIdCache`,new Map),Z(this,`_cellInfoCache`,new Map),Z(this,`_rowInfoCache`,new Map),Z(this,`_colInfoCache`,new Map),this._initUpdateCellRuleCache(),this._initUpdateCellInfoCache(),this._initUpdateRowColInfoCache(),this._initCache()}_initCache(){this._univerInstanceService.getAllUnitsForType(M.UNIVER_SHEET).forEach(e=>{e.getSheets().forEach(t=>{let n=e.getUnitId(),r=t.getSheetId();this.reBuildCache(n,r)})})}_initUpdateCellInfoCache(){this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe(Ls(e=>e.type===ra.SelectRange),os(e=>e)).subscribe(e=>{let{subUnitId:t,unitId:n,permissionId:r}=e,i=this._permissionIdCache.get(r);if(!i)return;let a=this._ruleModel.getRule(n,t,i);if(!a)return;let o=this._ensureCellInfoMap(n,t);a.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:i}=e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++)o.delete(`${e}-${t}`)})})),this.disposeWithMe(this._ruleModel.ruleChange$.subscribe(e=>{let{unitId:t,subUnitId:n}=e,r=this._ensureCellInfoMap(t,n);if(e.rule.ranges.forEach(e=>{t_.foreach(e,(e,t)=>{r.delete(`${e}-${t}`)})}),e.type===`set`){var i;(i=e.oldRule)==null||i.ranges.forEach(e=>{t_.foreach(e,(e,t)=>{this._cellInfoCache.delete(`${e}-${t}`)})})}}))}_initUpdateCellRuleCache(){this.disposeWithMe(this._ruleModel.ruleChange$.subscribe(e=>{let{type:t}=e;t===`add`?this._addCellRuleCache(e):t===`delete`?this._deleteCellRuleCache(e):(this._deleteCellRuleCache({...e,rule:e.oldRule}),this._addCellRuleCache(e))}))}_ensureRuleMap(e,t){let n=this._cellRuleCache.get(e);n||(n=new Map,this._cellRuleCache.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_ensureCellInfoMap(e,t){let n=this._cellInfoCache.get(e);n||(n=new Map,this._cellInfoCache.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_ensureRowColInfoMap(e,t,n){let r=n===`row`?this._rowInfoCache.get(e):this._colInfoCache.get(e);r||(r=new Map,n===`row`?this._rowInfoCache.set(e,r):this._colInfoCache.set(e,r));let i=r.get(t);return i||(i=new Map,r.set(t,i)),i}_addCellRuleCache(e){let{subUnitId:t,unitId:n,rule:r}=e,i=this._ensureRuleMap(n,t);r.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:a,endColumn:o}=e;for(let e=t;e<=n;e++)for(let t=a;t<=o;t++)i.set(`${e}-${t}`,r.id)}),this._permissionIdCache.set(r.permissionId,r.id)}_deleteCellRuleCache(e){let{subUnitId:t,unitId:n,rule:r}=e,i=this._ensureRuleMap(n,t),a=this._ensureCellInfoMap(n,t);r.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:o}=e;for(let e=t;e<=n;e++)for(let t=r;t<=o;t++)i.delete(`${e}-${t}`),a.delete(`${e}-${t}`)}),this._permissionIdCache.delete(r.permissionId)}_getSelectionActions(e,t,n){let r=this._permissionService.getPermissionPoint(new JY(e,t,n.permissionId)?.id)?.value??!1,i=this._permissionService.getPermissionPoint(new XY(e,t,n.permissionId)?.id)?.value??!1,a=this._permissionService.getPermissionPoint(new YY(e,t,n.permissionId)?.id)?.value??!1,o=this._permissionService.getPermissionPoint(new qY(e,t,n.permissionId)?.id)?.value??!1;return{[ta.Edit]:r,[ta.View]:i,[ta.ManageCollaborator]:a,[ta.Delete]:o}}reBuildCache(e,t){let n=this._ensureRuleMap(e,t),r=this._ensureCellInfoMap(e,t);n.clear(),r.clear();let i=this._ensureRowColInfoMap(e,t,`row`),a=this._ensureRowColInfoMap(e,t,`col`);i.clear(),a.clear(),this._ruleModel.getSubunitRuleList(e,t).forEach(o=>{let s=this._getSelectionActions(e,t,o),c={...s,ruleId:o.id,ranges:o.ranges};o.ranges.forEach(e=>{let{startRow:t,endRow:l,startColumn:u,endColumn:d}=e;for(let e=t;e<=l;e++){let t=i.get(`${e}`);t?t.set(o.id,s):i.set(`${e}`,new Map([[o.id,s]]));for(let t=u;t<=d;t++){n.set(`${e}-${t}`,o.id),r.set(`${e}-${t}`,c);let i=a.get(`${t}`);i?i.set(o.id,s):a.set(`${t}`,new Map([[o.id,s]]))}}}),this._permissionIdCache.set(o.permissionId,o.id)})}getRowPermissionInfo(e,t,n,r){let i=this._rowInfoCache.get(e)?.get(t);if(!i)return!0;let a=i.get(`${n}`);return!a||r.every(e=>{for(let t of a.values())if(t[e]===!1)return!1;return!0})}getColPermissionInfo(e,t,n,r){let i=this._colInfoCache.get(e)?.get(t);if(!i)return!0;let a=i.get(`${n}`);return!a||r.every(e=>{for(let t of a.values())if(t[e]===!1)return!1;return!0})}_initUpdateRowColInfoCache(){this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe(Ls(e=>e.type===ra.SelectRange),os(e=>e)).subscribe({next:e=>{let{subUnitId:t,unitId:n,permissionId:r}=e,i=this._permissionIdCache.get(r);if(!i)return;let a=this._ruleModel.getRule(n,t,i);if(!a)return;let o=this._ensureRowColInfoMap(n,t,`row`),s=this._ensureRowColInfoMap(n,t,`col`),c=this._getSelectionActions(n,t,a);a.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:a}=e;for(let e=t;e<=n;e++){let t=o.get(`${e}`);t?t.set(i,c):o.set(`${e}`,new Map([[i,c]]));for(let e=r;e<=a;e++){let t=s.get(`${e}`);t?t.set(i,c):s.set(`${e}`,new Map([[i,c]]))}}})}})),this.disposeWithMe(this._ruleModel.ruleChange$.subscribe(e=>{if(e.type===`delete`){let{unitId:t,subUnitId:n,rule:r}=e,i=this._ensureRowColInfoMap(t,n,`row`),a=this._ensureRowColInfoMap(t,n,`col`);r.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:o,endColumn:s}=e;for(let e=t;e<=n;e++){i.get(`${e}`)?.delete(r.id);for(let e=o;e<=s;e++)a.get(`${e}`)?.delete(r.id)}})}}))}getCellInfo(e,t,n,r){var i;let a=this._ensureCellInfoMap(e,t),o=a.get(`${n}-${r}`);if(o)return o;let s=(i=this._cellRuleCache.get(e))==null||(i=i.get(t))==null?void 0:i.get(`${n}-${r}`);if(!s)return;let c=this._ruleModel.getRule(e,t,s);if(c){let i={...this._getSelectionActions(e,t,c),ruleId:s,ranges:c.ranges};return a.set(`${n}-${r}`,i),i}}deleteUnit(e){this._cellRuleCache.delete(e),this._cellInfoCache.delete(e),this._rowInfoCache.delete(e),this._colInfoCache.delete(e),this._univerInstanceService.getUnit(e)?.getSheets().forEach(t=>{let n=t.getSheetId();this._ruleModel.getSubunitRuleList(e,n).forEach(e=>{this._permissionIdCache.delete(e.permissionId)})})}};$X=AG([kG(0,j(BK)),kG(1,j(ox)),kG(2,j(z))],$X);var vmt=`@univerjs/sheets`,ymt=`0.25.1`,eZ=class extends P{constructor(e,t){super(),this._commandService=e,this._univerInstanceService=t,Z(this,`_previousSheetIndex`,-1),this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===Aq.id)return this._beforeAdjustActiveSheetOnRemoveSheet(e)})),this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{if(e.id===Aq.id)return this._adjustActiveSheetOnRemoveSheet(e);if(e.id===BY.id&&e.params.hidden)return this._adjustActiveSheetOnHideSheet(e);if(t?.fromCollab)return!1;if(e.id===nY.id)return this._adjustActiveSheetOnInsertSheet(e);if(e.id===BY.id&&!e.params.hidden)return this._adjustActiveSheetOnShowSheet(e);if(e.id===oq.id)return this._adjustActiveSheetOnSelection(e)}))}_adjustActiveSheetOnHideSheet(e){let{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r||r.getActiveSheet()?.getSheetId()!==n)return;let i=bmt(r,r.getActiveSheetIndex());this._switchToNextSheet(t,i)}_beforeAdjustActiveSheetOnRemoveSheet(e){let{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r)return;let i=r.getSheetBySheetId(n);i&&(this._previousSheetIndex=r.getSheetIndex(i))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;let{unitId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(n&&n.getActiveSheet().getSheetId()===e.params.subUnitId){let e=this._previousSheetIndex,r=bmt(n,e>=1?e-1:0);this._switchToNextSheet(t,r)}}_adjustActiveSheetOnInsertSheet(e){let{unitId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){let{unitId:t,subUnitId:n}=e.params;this._switchToNextSheet(t,n)}_adjustActiveSheetOnSelection(e){let{unitId:t,subUnitId:n}=e.params;n!==this._univerInstanceService.getUnit(t)?.getActiveSheet().getSheetId()&&this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(wK.id,{unitId:e,subUnitId:t})}};eZ=AG([kG(0,R),kG(1,z)],eZ);function bmt(e,t){let n=e.getSheetSize();for(let n=t;n>-1;n--){let t=e.getSheetByIndex(n);if(!t.getConfig().hidden)return t.getSheetId()}for(let r=t;r<n;r++){let t=e.getSheetByIndex(r);if(!t.getConfig().hidden)return t.getSheetId()}throw Error(`[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.`)}var xmt=`ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY`,tZ=class extends P{constructor(e,t,n){super(),this._commandService=e,this._configService=t,this._dataSyncPrimaryController=n,[lK,WG,HG,nY,GG,KG,qG,YG,JG,Aq,ZG,zX,TG,xpt,HY,RX,QG,nmt,fK,dK,amt,omt,Jft,_K,hK,HX].forEach(e=>{var t;this._commandService.registerCommand(e),(t=this._dataSyncPrimaryController)==null||t.registerSyncingMutations(e)}),(this._configService.getConfig(`ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY`)??!1)||[oJ,sJ,cJ,lJ,Ydt,XK,QJ,ZK,rY,uq,dq,RY,NX,rdt,xq,Sq,Cq,bq,yq,fq,pq,tdt,gq,vq,_q,hq,mq,oY,Mq,sq,jq,Tq,kq,Oq,Eq,dY,Nq,aJ,TJ,Zdt,wJ,gY,fpt,hY,upt,dpt,bY,eK,tK,zY,_Y,$G,wY,CY,TY,DJ,kY,lq,PX,NY,AY,uK,yY,MY,vY,jY,gJ,FY,PY,CJ,kJ,OJ,EJ,IY,LY,wK,VY,BY,UY,GY,WY,SK,bK,FX,xK,mK,Jpt,wpt,Uut,oq,UX,aY,uY,xY,IX,VX,CK,EY,nK,Qpt,Kpt,pJ,OY,mJ,Gpt,Fut,gpt,tpt,hJ,iY,qpt,HK,VK,DY,$pt,gK,Tpt,Ypt,BG,zG,lY,cY,emt,rpt,Jdt,npt,tmt,imt,rmt,XJ,Gft,Kft,ZJ,sY].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this._configService.setConfig(pmt,mmt)}};tZ=AG([kG(0,R),kG(1,Nm),kG(2,be(xR))],tZ);var nZ=class extends P{constructor(e,t){super(),this._univerInstanceService=e,this._commandService=t,this._initialize()}_initialize(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Kz.id)return;let{unitData:t}=e.params,n=Object.keys(t),r=[];for(let e=0;e<n.length;e++){let i=n[e],a=t[i];if(a==null)continue;let o=Object.keys(a);for(let e=0;e<o.length;e++){let t=o[e],n=a[t];if(n==null)continue;let s={subUnitId:t,unitId:i,cellValue:this._getMergedCellData(i,t,n)};r.push({id:lK.id,params:s})}}return Km(r,this._commandService,{onlyLocal:!0,fromFormula:!0,applyFormulaCalculationResult:!0})}))}_getMergedCellData(e,t,n){let r=this._univerInstanceService.getUniverSheetInstance(e),i=r?.getStyles(),a=(r?.getSheetBySheetId(t))?.getCellMatrix(),o=new Rh(n);return o.forValue((e,t,n)=>{let r=F8e(a?.getValue(e,t),n,i);o.setValue(e,t,r)}),o.getMatrix()}};nZ=AG([kG(0,j(z)),kG(1,R)],nZ);var rZ=class extends P{constructor(e){super(),this._sheetInterceptorService=e,this._initialize()}_initialize(){this._initInterceptorCellContent()}_initInterceptorCellContent(){this.disposeWithMe(this._sheetInterceptorService.intercept(EG.CELL_CONTENT,{priority:11,effect:Sf.Value|Sf.Style,handler:(e,t,n)=>{var r;if(!e)return n(e);let i=t.workbook.getStyles().getStyleByCell(e);return wh(i==null||(r=i.n)==null?void 0:r.pattern)&&e?.t===Pp.NUMBER&&e.v!==void 0&&e.v!==null&&Pg(e.v)?((!e||e===t.rawData)&&(e={...t.rawData}),e.v=GB(Number(e.v)),n(e)):n(e)}}))}};rZ=AG([kG(0,j(PG))],rZ);var iZ=class extends P{constructor(e,t,n,r){super(),this._permissionService=e,this._worksheetProtectionRuleModel=t,this._sheetInterceptorService=n,this._rangeProtectionCache=r,this._initViewModelByRangeInterceptor(),this._initViewModelBySheetInterceptor()}_initViewModelByRangeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(EG.CELL_CONTENT,{priority:999,effect:Sf.Value|Sf.Style,handler:(e,t,n)=>{let{unitId:r,subUnitId:i,row:a,col:o}=t,s=this._rangeProtectionCache.getCellInfo(r,i,a,o);if(s){let r=s[ta.View]===!1,i=!e||e===t.rawData?{...t.rawData}:e;return i.selectionProtection=[s],r?(delete i.s,delete i.v,delete i.p,i):n(i)}return n(e)}}))}_initViewModelBySheetInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(EG.CELL_CONTENT,{priority:999,effect:Sf.Value|Sf.Style,handler:(e,t,n)=>{let{unitId:r,subUnitId:i}=t;if(this._worksheetProtectionRuleModel.getRule(r,i)?.permissionId){let a=[{[ta.View]:this._permissionService.getPermissionPoint(new OX(r,i).id)?.value??!1,[ta.Edit]:this._permissionService.getPermissionPoint(new _X(r,i).id)?.value??!1}],o=!a[0]?.[ta.View],s=!e||e===t.rawData?{...e}:e;return s.hasWorksheetRule=!0,s.selectionProtection=a,o?(delete s.s,delete s.v,delete s.p,s):n(s)}return n(e)}}))}};iZ=AG([kG(0,ox),kG(1,j(fJ)),kG(2,j(PG)),kG(3,j($X))],iZ);var aZ=ce(`univer.exclusive-range.service`),Smt=class extends P{constructor(...e){super(...e),Z(this,`_exclusiveRanges`,new Map),Z(this,`_exclusiveRangesChange$`,new ao),Z(this,`exclusiveRangesChange$`,this._exclusiveRangesChange$.asObservable())}_ensureUnitMap(e){return this._exclusiveRanges.has(e)||this._exclusiveRanges.set(e,new Map),this._exclusiveRanges.get(e)}_ensureSubunitMap(e,t){let n=this._ensureUnitMap(e);return n.has(t)||n.set(t,new Map),n.get(t)}_ensureFeature(e,t,n){let r=this._ensureSubunitMap(e,t);return r.has(n)||r.set(n,[]),r.get(n)}addExclusiveRange(e,t,n,r){let i=this._ensureFeature(e,t,n);i.push(...r),this._exclusiveRangesChange$.next({unitId:e,subUnitId:t,ranges:i.map(e=>e.range)})}getExclusiveRanges(e,t,n){var r;return(r=this._exclusiveRanges.get(e))==null||(r=r.get(t))==null?void 0:r.get(n)}clearExclusiveRanges(e,t,n){let r=this.getExclusiveRanges(e,t,n);this._exclusiveRangesChange$.next({unitId:e,subUnitId:t,ranges:r?.map(e=>e.range)||[]}),this._ensureFeature(e,t,n),this._exclusiveRanges.get(e).get(t).set(n,[])}clearExclusiveRangesByGroupId(e,t,n,r){let i=this.getExclusiveRanges(e,t,n);this._exclusiveRangesChange$.next({unitId:e,subUnitId:t,ranges:i?.map(e=>e.range)||[]});let a=this.getExclusiveRanges(e,t,n);if(a){let i=a.filter(e=>e.groupId!==r);this._exclusiveRanges.get(e).get(t).set(n,i)}}getInterestGroupId(e){let t=[];return e.forEach(e=>{let n=e.range,{unitId:r,sheetId:i}=n;if(!r||!i)return;let a=this._exclusiveRanges.get(r)?.get(i);if(a)for(let e of a.keys()){let r=a.get(e);if(r){for(let i of r)if(d_.intersects(n,i.range)){t.push(e);break}}}}),t}},oZ=class extends P{constructor(e,t,n){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._logService=n}getValue(e,t,n,r){let i=this._univerInstanceService.getUniverSheetInstance(e);if(!i)return;let a=i?.getSheetBySheetId(t);if(!a)return;let o=i.getStyles(),s=a.getCellRaw(n,r);if(s?.s){let e=o.get(s.s);if(e?.n)return e.n}return null}deleteValues(e,t,n){let r=this._univerInstanceService.getUniverSheetInstance(e);if(!r)return;let i=r?.getSheetBySheetId(t);if(!i)return;let a=r.getStyles();n.forEach(e=>{t_.foreach(e,(e,t)=>{let n=i.getCellRaw(e,t);if(!n)return;let r=n?.s,o={...r&&a.get(r)||{}};delete o.n,n.s=a.setValue(o)})})}setValues(e,t,n){let r=this._univerInstanceService.getUniverSheetInstance(e);if(!r)return;let i=r?.getSheetBySheetId(t);if(!i)return;let a=r.getStyles(),o=i.getCellMatrix();n.forEach(e=>{e.ranges.forEach(t=>{t_.foreach(t,(t,n)=>{let r=i.getCellRaw(t,n);if(r){let t={...a.getStyleByCell(r)||{},n:{pattern:e.pattern}};r.s=a.setValue(t)}else{let r={n:{pattern:e.pattern}},i=a.setValue(r);i&&o.setValue(t,n,{s:i})}})})})}};oZ=AG([kG(0,By),kG(1,z),kG(2,Rm)],oZ);var Cmt=[WG.id,HG.id,YG.id,JG.id],wmt=[KG.id,qG.id],sZ=class extends P{constructor(e,t,n,r,i,a,o,s){super(),this._selectionProtectionRuleModel=e,this._univerInstanceService=t,this._commandService=n,this._refRangeService=r,this._selectionProtectionRenderModel=i,this._rangeProtectionCache=a,this._sheetInterceptorService=o,this._rangeProtectionRuleModel=s,Z(this,`disposableCollection`,new Gf),this._onRefRangeChange(),this._correctPermissionRange(),this._initReBuildCache(),this._initRemoveSheet()}_onRefRangeChange(){let e=(e,t)=>{let n=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET);if(!n||!n?.getSheetBySheetId(t))return;this.disposableCollection.dispose();let r=n=>this.refRangeHandle(n,e,t);this._selectionProtectionRuleModel.getSubunitRuleList(e,t).reduce((e,t)=>[...e,...t.ranges],[]).forEach(n=>{this.disposableCollection.add(this._refRangeService.registerRefRange(n,r,e,t))})};this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===LY.id){let n=t.params,r=n.subUnitId,i=n.unitId;if(!r||!i)return;e(i,r)}if(t.id===DY.id||t.id===HK.id){let n=t.params,r=n.subUnitId,i=n.unitId;if(!r||!i)return;e(i,r)}}));let t=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET);if(t){let n=t.getActiveSheet();if(!n)return;e(t.getUnitId(),n.getSheetId())}}refRangeHandle(e,t,n){switch(e.id){case jq.id:return this._getRefRangeMutationsByMoveRows(e.params,t,n);case Mq.id:return this._getRefRangeMutationsByMoveCols(e.params,t,n);case mq.id:return this._getRefRangeMutationsByInsertRows(e.params,t,n);case yq.id:return this._getRefRangeMutationsByInsertCols(e.params,t,n);case kq.id:return this._getRefRangeMutationsByDeleteCols(e.params,t,n);case Eq.id:return this._getRefRangeMutationsByDeleteRows(e.params,t,n)}return{redos:[],undos:[]}}_getRefRangeMutationsByDeleteCols(e,t,n){let r=this._selectionProtectionRuleModel.getSubunitRuleList(t,n).filter(t=>t.ranges.some(t=>d_.intersects(t,e.range))),i=e.range;if(r.length){let e=[],a=[];return r.forEach(r=>{let o=F.deepClone(r);o.ranges=o.ranges.reduce((e,t)=>{if(d_.intersects(t,i)){let n=F.deepClone(t),{startColumn:r,endColumn:a}=i;if(r<=n.startColumn&&a>=n.endColumn)return e;r>=n.startColumn&&a<=n.endColumn?n.endColumn-=a-r+1:r<n.startColumn?(n.startColumn=r,n.endColumn-=a-r+1):a>n.endColumn&&(n.endColumn=r-1),this._checkIsRightRange(n)&&e.push(n)}return e},[]),o.ranges.length?(e.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:o,ruleId:r.id}}),a.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:r,ruleId:r.id}})):(e.push({id:VK.id,params:{unitId:t,subUnitId:n,ruleIds:[r.id]}}),a.push({id:HK.id,params:{unitId:t,subUnitId:n,name:``,rules:[r]}}))}),{redos:e,undos:a}}return{undos:[],redos:[]}}_getRefRangeMutationsByDeleteRows(e,t,n){let r=this._selectionProtectionRuleModel.getSubunitRuleList(t,n).filter(t=>t.ranges.some(t=>d_.intersects(t,e.range))),i=e.range;if(r.length){let e=[],a=[];return r.forEach(r=>{let o=F.deepClone(r);o.ranges=o.ranges.reduce((e,t)=>{if(d_.intersects(t,i)){let n=F.deepClone(t),{startRow:r,endRow:a}=i;if(r<=n.startRow&&a>=n.endRow)return e;r>=n.startRow&&a<=n.endRow?n.endRow-=a-r+1:r<n.startRow?(n.startRow=r,n.endRow-=a-r+1):a>n.endRow&&(n.endRow=r-1),this._checkIsRightRange(n)&&e.push(n)}return e},[]),e.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:o,ruleId:r.id}}),a.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:r,ruleId:r.id}})}),{redos:e,undos:a}}return{undos:[],redos:[]}}_getRefRangeMutationsByInsertCols(e,t,n){let r=e.range.startColumn,i=e.range.endColumn-e.range.startColumn+1,a=this._selectionProtectionRuleModel.getSubunitRuleList(t,n).filter(e=>e.ranges.some(e=>r>e.startColumn&&r<=e.endColumn));if(a.length){let e=[],o=[];return a.forEach(a=>{let s=F.deepClone(a),c=!1;s.ranges.forEach(e=>{r>e.startColumn&&r<=e.endColumn&&(e.endColumn+=i,c=!0)}),c&&(e.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:s,ruleId:a.id}}),o.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:a,ruleId:a.id}}))}),{redos:e,undos:o}}return{undos:[],redos:[]}}_getRefRangeMutationsByInsertRows(e,t,n){let r=e.range.startRow,i=e.range.endRow-e.range.startRow+1,a=this._selectionProtectionRuleModel.getSubunitRuleList(t,n).filter(e=>e.ranges.some(e=>r>e.startRow&&r<=e.endRow));if(a.length){let e=[],o=[];return a.forEach(a=>{let s=F.deepClone(a),c=!1;s.ranges.forEach(e=>{r>e.startRow&&r<=e.endRow&&(e.endRow+=i,c=!0)}),c&&(e.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:s,ruleId:a.id}}),o.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:a,ruleId:a.id}}))}),{redos:e,undos:o}}return{undos:[],redos:[]}}_getRefRangeMutationsByMoveRows(e,t,n){let r=e.toRange,i=r.startRow,a=r.endRow-r.startRow+1,o=this._selectionProtectionRuleModel.getSubunitRuleList(t,n).filter(e=>e.ranges.some(e=>i>e.startRow&&i<=e.endRow));if(o.length){let r=[],s=[];return o.forEach(o=>{let c=F.deepClone(o),l=e.fromRange.startRow,u=!1;c.ranges.forEach(e=>{i>e.startRow&&i<=e.endRow&&(l<e.startRow&&(e.startRow-=a,e.endRow-=a),e.endRow+=a,u=!0)}),u&&(r.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:c,ruleId:o.id}}),s.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:o,ruleId:o.id}}))}),{redos:r,undos:s}}return{undos:[],redos:[]}}_getRefRangeMutationsByMoveCols(e,t,n){let r=e.toRange,i=r.startColumn,a=r.endColumn-r.startColumn+1,o=this._selectionProtectionRuleModel.getSubunitRuleList(t,n).filter(e=>e.ranges.some(e=>i>e.startColumn&&i<=e.endColumn));if(o.length){let r=[],s=[];return o.forEach(o=>{let c=F.deepClone(o),l=e.fromRange.startColumn,u=!1;c.ranges.forEach(e=>{i>e.startColumn&&i<=e.endColumn&&(l<e.startColumn&&(e.startColumn-=a,e.endColumn-=a),e.endColumn+=a,u=!0)}),u&&(r.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:c,ruleId:o.id}}),s.push({id:DY.id,params:{unitId:t,subUnitId:n,rule:o,ruleId:o.id}}))}),{redos:r,undos:s}}return{undos:[],redos:[]}}_correctPermissionRange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(wmt.includes(e.id)){if(!e.params)return;let t=this._univerInstanceService.getCurrentUnitOfType(M.UNIVER_SHEET);if(!t)return;let n=t.getSheetBySheetId(e.params.subUnitId);if(!n)return;let{sourceRange:r,targetRange:i}=e.params,a=r.startColumn===i.startColumn&&r.endColumn===i.endColumn,o=a?r.endRow-r.startRow+1:r.endColumn-r.startColumn+1,s=a?r.startRow:r.startColumn,c=a?i.startRow:i.startColumn;this._selectionProtectionRuleModel.getSubunitRuleList(t.getUnitId(),n.getSheetId()).forEach(e=>{e.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:i,endColumn:l}=e;d_.intersects(e,r)||(a?s<t&&c>n?(t-=o,n-=o):s>n&&c<=t&&(t+=o,n+=o):s<i&&c>l?(i-=o,l-=o):s>l&&c<=i&&(i+=o,l+=o)),this._checkIsRightRange({startRow:t,endRow:n,startColumn:i,endColumn:l})&&(e.startColumn=i,e.endColumn=l,e.startRow=t,e.endRow=n)})}),this.disposableCollection.dispose();let{unitId:l,subUnitId:u}=e.params,d=e=>this.refRangeHandle(e,l,u);this._selectionProtectionRuleModel.getSubunitRuleList(l,u).reduce((e,t)=>[...e,...t.ranges],[]).forEach(e=>{this.disposableCollection.add(this._refRangeService.registerRefRange(e,d,l,u))}),this._selectionProtectionRenderModel.clear()}if(Cmt.includes(e.id)){let t=this._univerInstanceService.getUniverSheetInstance(e.params.unitId);if(!t)return;let n=t.getSheetBySheetId(e.params.subUnitId);if(!n)return;let r=e.params;if(!r)return;let{range:i}=r,a=e.id.includes(`row`),o=e.id.includes(`insert`),s=a?i.startRow:i.startColumn,c=a?i.endRow:i.endColumn,l=c-s+1;this._selectionProtectionRuleModel.getSubunitRuleList(t.getUnitId(),n.getSheetId()).forEach(e=>{e.ranges.forEach(e=>{let{startRow:t,endRow:n,startColumn:r,endColumn:i}=e;o?a?s<=t&&(t+=l,n+=l):s<=r&&(r+=l,i+=l):a?c<t&&(t-=l,n-=l):c<r&&(r-=l,i-=l),this._checkIsRightRange({startRow:t,endRow:n,startColumn:r,endColumn:i})&&(e.startColumn=r,e.endColumn=i,e.startRow=t,e.endRow=n)})}),this.disposableCollection.dispose();let{unitId:u,subUnitId:d}=e.params,f=e=>this.refRangeHandle(e,u,d);this._selectionProtectionRuleModel.getSubunitRuleList(u,d).reduce((e,t)=>[...e,...t.ranges],[]).forEach(e=>{this.disposableCollection.add(this._refRangeService.registerRefRange(e,f,u,d))}),this._selectionProtectionRenderModel.clear()}}))}_checkIsRightRange(e){return e.startRow<=e.endRow&&e.startColumn<=e.endColumn}_initReBuildCache(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(Cmt.includes(e.id)||wmt.includes(e.id)){let{unitId:t,subUnitId:n}=e.params;this._rangeProtectionCache.reBuildCache(t,n)}}))}_initRemoveSheet(){this._sheetInterceptorService.interceptCommand({getMutations:e=>{let t=[],n=[],r=[],i=[];if(e.id===dY.id){let n=e.params,i=[],a=[];this._rangeProtectionRuleModel.getSubunitRuleList(n.unitId,n.subUnitId).forEach(e=>{i.push(e.id),a.push(e)}),i.length&&a.length&&(r.push({id:VK.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,ruleIds:i}}),t.push({id:HK.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,name:``,rules:a}}))}return{redos:n,undos:t,preRedos:r,preUndos:i}}})}};sZ=AG([kG(0,j(BK)),kG(1,j(z)),kG(2,R),kG(3,j(eJ)),kG(4,j(QX)),kG(5,j($X)),kG(6,j(PG)),kG(7,j(BK))],sZ);var Tmt=`SHEET_RANGE_PROTECTION_PLUGIN`,cZ=class extends P{constructor(e,t,n,r,i){super(),this._selectionProtectionRuleModel=e,this._permissionService=t,this._resourceManagerService=n,this._selectionProtectionCache=r,this._univerInstanceService=i,this._initSnapshot(),this._initRuleChange()}_initRuleChange(){this.disposeWithMe(this._selectionProtectionRuleModel.ruleChange$.subscribe(e=>{switch(e.type){case`add`:ZY().forEach(t=>{let n=new t(e.unitId,e.subUnitId,e.rule.permissionId);this._permissionService.addPermissionPoint(n)});break;case`delete`:ZY().forEach(t=>{let n=new t(e.unitId,e.subUnitId,e.rule.permissionId);this._permissionService.deletePermissionPoint(n.id)});break;case`set`:e.oldRule.permissionId!==e.rule.permissionId&&ZY().forEach(t=>{let n=new t(e.unitId,e.subUnitId,e.oldRule.permissionId);this._permissionService.deletePermissionPoint(n.id);let r=new t(e.unitId,e.subUnitId,e.rule.permissionId);this._permissionService.addPermissionPoint(r)})}}))}_initSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource({toJson:e=>{let t=this._selectionProtectionRuleModel.toObject()[e];return t?JSON.stringify(t):``},parseJson:e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}},pluginName:Tmt,businesses:[M.UNIVER_SHEET],onLoad:(e,t)=>{let n=this._selectionProtectionRuleModel.toObject();n[e]=t,this._selectionProtectionRuleModel.fromObject(n);let r=[];Object.keys(t).forEach(n=>{let i=t[n];this._selectionProtectionRuleModel.getSubunitRuleList(e,n).forEach(t=>{r.push({objectID:t.permissionId,unitID:e,objectType:ra.SelectRange,actions:QY})}),i.forEach(t=>{ZY().forEach(r=>{let i=new r(e,n,t.permissionId);i.value=!1,this._permissionService.addPermissionPoint(i)})}),this._selectionProtectionCache.reBuildCache(e,n)})},onUnLoad:e=>{this._selectionProtectionCache.deleteUnit(e)}}))}};cZ=AG([kG(0,j(BK)),kG(1,j(ox)),kG(2,j(By)),kG(3,j($X)),kG(4,j(z))],cZ);var lZ=class extends P{constructor(e){super(),this._sheetRangeThemeModel=e}registerRangeTheme(e,t){this._sheetRangeThemeModel.registerRangeThemeStyle(e,t)}removeRangeThemeRule(e,t){this._sheetRangeThemeModel.removeRangeThemeRule(e,t)}getALLRegisterThemes(e){return this._sheetRangeThemeModel.getALLRegisteredTheme(e)}registerRangeThemeStyle(e,t){this._sheetRangeThemeModel.registerRangeThemeRule(e,t)}getAppliedRangeThemeStyle(e){return this._sheetRangeThemeModel.getRegisteredRangeThemeStyle(e)}getRegisteredRangeThemes(){return this._sheetRangeThemeModel.getRegisteredRangeThemes()}};lZ=AG([kG(0,j(RG))],lZ);var uZ=class extends dx{constructor(e=qft,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=Qi({},qft,this._config);this._configService.setConfig($J,r),this._initConfig(),this._initDependencies()}_initConfig(){this._config?.onlyRegisterFormulaRelatedMutations&&this._configService.setConfig(xmt,!0),this._config?.isRowStylePrecedeColumnStyle&&this._configService.setConfig(of,!0),this._config?.autoHeightForMergedCells&&this._configService.setConfig(sf,!0)}_initDependencies(){let e=[[fY],[tY],[WK],[eJ],[YX],[LX,{useClass:oZ}],[PG],[lZ],[qK],[tZ],[nJ],[rZ],[KX],[ZX],[qX],[MX],[fJ],[KY],[iZ],[XX],[JX],[RG],[QX],[BK],[$X],[sZ],[cZ],[aZ,{useClass:Smt,deps:[WK]}],[YJ,{useClass:JJ}],[WX]];this._config?.notExecuteFormula||e.push([nZ]),df(this._injector,cx(e,this._config.override)),ff(this._injector,[[PG],[cZ],[aZ],[XX],[qX]])}onStarting(){ff(this._injector,[[tZ],[nJ],[YX],[MX],[iZ],[qK],[WX]]),this._config?.onlyRegisterFormulaRelatedMutations||this._injector.add([eZ])}onRendered(){ff(this._injector,[[LX]])}onReady(){ff(this._injector,[[eZ],[nZ],[KX],[ZX],[RG],[rZ],[QX],[sZ],[eJ],[JX]])}};Z(uZ,`pluginName`,`SHEET_PLUGIN`),Z(uZ,`packageName`,vmt),Z(uZ,`version`,ymt),Z(uZ,`type`,M.UNIVER_SHEET),uZ=AG([px(pU),kG(1,j(We)),kG(2,Nm)],uZ);var Emt=(e,t,n,r=1,i=!0,a=!0)=>{let{startRow:o,endRow:s}=t_.transformRange(e,t),c=n.startRow-r,l=t.getMergedCell(c,n.startColumn),u=!l||l.startRow===c&&l.startColumn===n.startColumn;for(;!t.getRowVisible(c)||!u;)c--,l=t.getMergedCell(c,n.startColumn),u=!l||l.startRow===c&&l.startColumn===n.startColumn;if(c>=o)return{...n,startRow:c,endRow:c};if(a)return Omt(e,t,{...n,startRow:s,endRow:s},r,i,!1)},Dmt=(e,t,n,r=1,i=!0,a=!0)=>{let{startRow:o,endRow:s}=t_.transformRange(e,t),c=n.endRow+r,l=t.getMergedCell(c,n.startColumn),u=!l||l.startRow===c&&l.startColumn===n.startColumn;for(;!t.getRowVisible(c)||!u;)c++,l=t.getMergedCell(c,n.startColumn),u=!l||l.startRow===c&&l.startColumn===n.startColumn;if(c<=s)return{...n,startRow:c,endRow:c};if(a)return kmt(e,t,{...n,startRow:o,endRow:o},r,i,!1)},Omt=(e,t,n,r=1,i=!0,a=!0)=>{let{startColumn:o,endColumn:s}=t_.transformRange(e,t),c=n.startColumn-r,l=t.getMergedCell(n.startRow,c),u=!l||l.startRow===n.startRow&&l.startColumn===c;for(;!t.getColVisible(c)||!u;)c--,l=t.getMergedCell(n.startRow,c),u=!l||l.startRow===n.startRow&&l.startColumn===c;if(c>=o)return{...n,startColumn:c,endColumn:c};if(a)return Emt(e,t,{...n,startColumn:s,endColumn:s},r,i,!1)},kmt=(e,t,n,r=1,i=!0,a=!0)=>{let{startColumn:o,endColumn:s}=t_.transformRange(e,t),c=n.endColumn+r,l=t.getMergedCell(n.startRow,c),u=!l||l.startRow===n.startRow&&l.startColumn===c;for(;!t.getColVisible(c)||!u;)c++,l=t.getMergedCell(n.startRow,c),u=!l||l.startRow===n.startRow&&l.startColumn===c;if(c<=s)return{...n,endColumn:c,startColumn:c};if(a)return Dmt(e,t,{...n,startColumn:o,endColumn:o},r,i,!1)};function dZ(e,t,n){let r=null;return n.getMatrixWithMergedCells(e,t,e,t).forValue((e,t,n)=>(r={actualRow:e,actualColumn:t,startRow:e,startColumn:t,isMerged:n.rowSpan!==void 0||n.colSpan!==void 0,isMergedMainCell:n.rowSpan!==void 0&&n.colSpan!==void 0,endRow:e+(n.rowSpan===void 0?0:n.rowSpan-1),endColumn:t+(n.colSpan===void 0?0:n.colSpan-1),rangeType:vh.NORMAL},!1)),r||{actualColumn:t,actualRow:e,startRow:e,startColumn:t,endRow:e,endColumn:t,isMerged:!1,isMergedMainCell:!1,rangeType:vh.NORMAL}}var Amt=(e,t,n,r,i=1)=>{switch(r){case I.UP:return Emt(e,t,n,i);case I.DOWN:return Dmt(e,t,n,i);case I.LEFT:return Omt(e,t,n,i);case I.RIGHT:return kmt(e,t,n,i)}},jmt=(e,t,n)=>{let r,i=-1,a;for(let t=0;t<e.length;t++)if(e[t].primary){r=e[t],i=t,a=r.primary;break}if(i===-1)return null;let o=t===I.LEFT||t===I.UP,s=e[o?i-1>=0?i-1:e.length-1:i+1<e.length?i+1:0];if(!r||!a)return null;let c={...a},{startRow:l,startColumn:u,endRow:d,endColumn:f}=r.range,p=o?c.startRow===l&&c.startColumn===u:c.endRow===d&&c.endColumn===f,m=p&&o;if(!d_.equals(r.range,c)){let e=p?s.range:Amt(r.range,n,c,t);if(!e)return null;let i=m?dZ(e.endRow,e.endColumn,n):dZ(e.startRow,e.startColumn,n);return{startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn}}let h=m?dZ(s.range.endRow,s.range.endColumn,n):dZ(s.range.startRow,s.range.startColumn,n);return{startRow:h.startRow,startColumn:h.startColumn,endRow:h.endRow,endColumn:h.endColumn}};function fZ(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a,rangeType:o}=t,s=i<n?i:n,c=i<n?n:i,l=a<r?a:r,u=a<r?r:a,d=e.getNoMergeCellWithCoordByIndex(s,l),f=e.getNoMergeCellWithCoordByIndex(c,u);return{startRow:n,startColumn:r,endRow:i,endColumn:a,rangeType:o,startY:d?.startY||0,endY:f?.endY||0,startX:d?.startX||0,endX:f?.endX||0}}function pZ(e,t){let{range:n,primary:r,style:i}=e;return{rangeWithCoord:fZ(t,n),primaryWithCoord:r&&mZ(t,r),style:i}}function mZ(e,t){let{actualRow:n,actualColumn:r,isMerged:i,isMergedMainCell:a,startRow:o,startColumn:s,endRow:c,endColumn:l}=t,u=e.getNoMergeCellWithCoordByIndex(n,r),d=e.getNoMergeCellWithCoordByIndex(o,s),f=e.getNoMergeCellWithCoordByIndex(c,l);return{actualRow:n,actualColumn:r,isMerged:i,isMergedMainCell:a,startX:u.startX,startY:u.startY,endX:u.endX,endY:u.endY,mergeInfo:{startRow:o,startColumn:s,endRow:c,endColumn:l,startY:d?.startY||0,endY:f?.endY||0,startX:d?.startX||0,endX:f?.endX||0}}}function Mmt(e,t,n,r){let{from:i,to:a}=n,{column:o,columnOffset:s,row:c,rowOffset:l}=i,{column:u,columnOffset:d,row:f,rowOffset:p}=a,m=fZ(r,{startColumn:o,endColumn:o,startRow:c,endRow:c}),h=fZ(r,{startColumn:u,endColumn:u,startRow:f,endRow:f}),{startX:g,startY:_}=m,{startX:v,startY:y}=h,b=Tw(g+s,1),x=Tw(_+l,1),S=Tw(v+d-b,1),C=Tw(y+p-x,1);return m.startX===h.endX&&(S=0),m.startY===h.endY&&(C=0),{unitId:e,subUnitId:t,left:b,top:x,width:S,height:C}}function Nmt(e,t,n,r,i,a){let{column:o,columnOffset:s,row:c,rowOffset:l}=n,{startX:u,startY:d}=fZ(a,{startColumn:o,endColumn:o,startRow:c,endRow:c}),f=Tw(u+s,1),p=Tw(d+l,1),m=a.getCellIndexAndOffsetByPosition(f+r,p+i);return{unitId:e,subUnitId:t,sheetTransform:{from:{column:o,columnOffset:s,row:c,rowOffset:l},to:m},transform:{left:f,top:p,width:r,height:i}}}var Pmt=ce(`telemetry.service`);function hZ(e,t){if(e==null)return;let n=t.getRenderById(e);if(n==null)return;let{mainComponent:r,scene:i,engine:a,components:o}=n;return{document:r,docBackground:o.get(bYe.BACKGROUND),scene:i,engine:a}}function gZ(e){return e.getContextValue(Yy)}function _Z(e){return e.getContextValue(`FOCUSING_SHEET`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&!e.getContextValue(`EDITOR_ACTIVATED`)&&!e.getContextValue(`FOCUSING_COMMON_DRAWINGS`)}function vZ(e){return e.getContextValue(`FOCUSING_SHEET`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&!e.getContextValue(`FOCUSING_COMMON_DRAWINGS`)}function Fmt(e){return e.getContextValue(`FOCUSING_SHEET`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&!e.getContextValue(`EDITOR_ACTIVATED`)&&!e.getContextValue(`FOCUSING_FX_BAR_EDITOR`)&&!e.getContextValue(`FOCUSING_COMMON_DRAWINGS`)}function Imt(e){return e.getContextValue(`FOCUSING_SHEET`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&e.getContextValue(`EDITOR_ACTIVATED`)}function yZ(e){return e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&e.getContextValue(`EDITOR_ACTIVATED`)}function bZ(e){return e.getContextValue(`FOCUSING_FX_BAR_EDITOR`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)}function xZ(e){return e.getContextValue(`FOCUSING_SHEET`)&&e.getContextValue(`FOCUSING_UNIVER_EDITOR`)&&e.getContextValue(`EDITOR_ACTIVATED`)&&!e.getContextValue(`FOCUSING_EDITOR_INPUT_FORMULA`)&&!e.getContextValue(`FOCUSING_EDITOR_INPUT_FORMULA`)}function SZ(e){let t=[],n=[],r=[];return e.forEach(e=>{t=t.concat(e.rows),n=n.concat(e.cols)}),t=Array.from(new Set(t)).sort((e,t)=>e-t),n=Array.from(new Set(n)).sort((e,t)=>e-t),e.forEach(e=>{r.push({startRow:t.findIndex(t=>t===e.rows[0]),endRow:t.findIndex(t=>t===e.rows[e.rows.length-1]),startColumn:n.findIndex(t=>t===e.cols[0]),endColumn:n.findIndex(t=>t===e.cols[e.cols.length-1])})}),{ranges:r,mapFunc:(e,r)=>({row:t[e],col:n[r]})}}var CZ=Cf(`rangeMovePermissionCheck`),wZ=Cf(`rangeFillPermissionCheck`),Lmt=function(e){return e[e.FORMULA_EDITOR_SHOW=100]=`FORMULA_EDITOR_SHOW`,e[e.MARK_SELECTION=1e4]=`MARK_SELECTION`,e}({});function TZ(e){let t=e.getColorFromTheme(`primary.600`),n=e.getColorFromTheme(`white`),r=new rh(t).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:t,fill:r,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:n,autofillSize:6,autofillStrokeWidth:1,autofillStroke:n,rowHeaderFill:r,rowHeaderStroke:t,rowHeaderStrokeWidth:1,columnHeaderFill:r,columnHeaderStroke:t,columnHeaderStrokeWidth:1,expandCornerSize:40}}var EZ=[10,400],DZ=`RANGE_SELECTOR_COMPONENT_KEY`,OZ=`EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY`,kZ=function(e){return e.MAIN=`__SpreadsheetRender__`,e.ROW=`__SpreadsheetRowHeader__`,e.COLUMN=`__SpreadsheetColumnHeader__`,e.LEFT_TOP=`__SpreadsheetLeftTopPlaceholder__`,e}({});function AZ(e){"@babel/helpers - typeof";return AZ=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},AZ(e)}function Rmt(e,t){if(AZ(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(AZ(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function zmt(e){var t=Rmt(e,`string`);return AZ(t)==`symbol`?t:t+``}function Q(e,t,n){return(t=zmt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bmt=class{constructor(){Q(this,`_startColumn`,-1),Q(this,`_startRow`,-1),Q(this,`_endColumn`,-1),Q(this,`_endRow`,-1),Q(this,`_startX`,0),Q(this,`_startY`,0),Q(this,`_endX`,0),Q(this,`_endY`,0),Q(this,`_primary`,void 0),Q(this,`_rangeType`,vh.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._primary}get rangeType(){return this._rangeType}isEqual(e){let{startColumn:t,startRow:n,endColumn:r,endRow:i}=this,{startColumn:a,startRow:o,endColumn:s,endRow:c}=e;return t===a&&n===o&&r===s&&i===c}highlightToSelection(){if(this._primary)return zh(this._primary)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._primary}getRangeType(){return this._rangeType}setRangeType(e){this._rangeType=e}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(e,t){let{startColumn:n,startRow:r,endColumn:i,endRow:a,startX:o,startY:s,endX:c,endY:l,rangeType:u}=e;this._startColumn=n,this._startRow=r,this._endColumn=i,this._endRow=a,this._startX=o,this._startY=s,this._endX=c,this._endY=l,u!==void 0&&(this._rangeType=u),t!==void 0&&this.setCurrentCell(t)}setCurrentCell(e){this._primary=e}clearCurrentCell(){this._primary=null}},jZ={id:`sheet.command.set-row-header-width`,type:L.COMMAND,handler:async(e,t)=>{if(!t)return!1;let n=e.get(KE);if(!n)return!1;let{unitId:r,subUnitId:i,size:a}=t,o=n.getRenderById(r);if(o){n.getRenderById(r).with(RZ).setRowHeaderSize(o,i,a);let{components:e}=o,t=e.get(`__SpreadsheetRowHeader__`);t&&t.setCustomHeader({headerStyle:{size:a}},i)}return!0}},MZ={id:`sheet.command.set-col-header-height`,type:L.COMMAND,handler:async(e,t)=>{if(!t)return!1;let n=e.get(KE);if(!n)return!1;let{unitId:r,subUnitId:i,size:a}=t,o=n.getRenderById(r);if(o){n.getRenderById(r).with(RZ).setColumnHeaderSize(o,i,a);let{components:e}=o,t=e.get(`__SpreadsheetColumnHeader__`);t&&t.setCustomHeader({headerStyle:{size:a}},i)}return!0}},Vmt=class extends FE{render(e,t=!1){let n=F.now();return super.render(e,t),this._afterRender(n),this}_afterRender(e){this.scene.getEngine().renderFrameTimeMetric$.next([`selectionLayer`,F.now()-e])}},NZ=ce(`univer.sheet.selection-render-service`),PZ=class extends P{get selectionMoving(){return this._selectionMoving}constructor(e,t,n,r,i){super(),this._injector=e,this._themeService=t,this._shortcutService=n,this._sheetSkeletonManagerService=r,this.contextService=i,Q(this,`_downObserver`,void 0),Q(this,`_scenePointerMoveSub`,void 0),Q(this,`_scenePointerUpSub`,void 0),Q(this,`_controlFillConfig$`,new so(null)),Q(this,`controlFillConfig$`,this._controlFillConfig$.asObservable()),Q(this,`_selectionControls`,[]),Q(this,`_startRangeWhenPointerDown`,{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}),Q(this,`_activeControlIndex`,-1),Q(this,`_startViewportPosX`,0),Q(this,`_startViewportPosY`,0),Q(this,`_scrollTimer`,void 0),Q(this,`_cancelDownSubscription`,void 0),Q(this,`_cancelUpSubscription`,void 0),Q(this,`_skeleton`,void 0),Q(this,`_scene`,void 0),Q(this,`_highlightHeader`,!0),Q(this,`_rangeType`,vh.NORMAL),Q(this,`_selectionStyle`,void 0),Q(this,`_remainLastEnabled`,!1),Q(this,`_skipLastEnabled`,!1),Q(this,`_singleSelectionEnabled`,!1),Q(this,`_selectionMoveEnd$`,new so([])),Q(this,`selectionMoveEnd$`,this._selectionMoveEnd$.asObservable()),Q(this,`_selectionMoving$`,new ao),Q(this,`selectionMoving$`,this._selectionMoving$.asObservable()),Q(this,`_selectionMoveStart$`,new ao),Q(this,`selectionMoveStart$`,this._selectionMoveStart$.asObservable()),Q(this,`_selectionMoving`,!1),Q(this,`_selectionTheme`,void 0),Q(this,`_activeViewport`,void 0),Q(this,`interceptor`,new Tf({RANGE_MOVE_PERMISSION_CHECK:CZ,RANGE_FILL_PERMISSION_CHECK:wZ})),Q(this,`_escapeShortcutDisposable`,null),this._initSelectionThemeFromThemeService(),this._initMoving()}get _shouldDetectMergedCells(){return this._rangeType===vh.NORMAL}_initMoving(){this.disposeWithMe(this._selectionMoving$.subscribe(()=>{this._selectionMoving=!0})),this.disposeWithMe(this._selectionMoveEnd$.subscribe(()=>{this._selectionMoving=!1}))}_setSelectionStyle(e){this._selectionStyle=e}getViewPort(){return this._activeViewport}setSingleSelectionEnabled(e=!1){this._singleSelectionEnabled=e}newSelectionControl(e,t,n){let r=this.getSelectionControls().length,{rowHeaderWidth:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeight:o,columnHeaderHeightAndMarginTop:s}=t,c=new zZ(e,r,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:i,columnHeaderHeight:o,rowHeaderOffsetX:Math.max(0,a-i),columnHeaderOffsetY:Math.max(0,s-o)});this._selectionControls.push(c);let l=pZ(n,t);return c.updateRangeBySelectionWithCoord(l,t),c.setControlExtension({skeleton:t,scene:e,themeService:this._selectionTheme,injector:this._injector,selectionHooks:{selectionMoveEnd:()=>{this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}}}),c}resetSelectionsByModelData(e){let t=this.getSelectionControls(),n=this._skeleton;if(t&&n){for(let r=0,i=e.length;r<i;r++){let i=e[r],a=pZ(i,this._skeleton),o=t[r];o?o.updateRangeBySelectionWithCoord(a,n):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,n,i)}e.length<t.length&&t.splice(e.length).forEach(e=>e.dispose())}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}refreshSelectionMoveEnd(){this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}_initSelectionThemeFromThemeService(){let e=this._themeService.getCurrentTheme();this._selectionTheme=new _x,this._selectionTheme.setTheme(e)}setSelectionTheme(e){this._selectionTheme.setTheme(e)}_changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t?.getViewports()[0],t.findLayerByZIndex(1)||t.addLayer(new Vmt(t,[],1))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){let e=this._selectionControls;if(this._skeleton.worksheet){let[t,n]=this._skeleton.getLocation();return e.map(e=>{let r=e.getValue();return r.rangeWithCoord.sheetId=n,r.rangeWithCoord.unitId=t,r})}return[]}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){let t=this._skeleton,n=e.style??TZ(this._selectionTheme),r=this._scene;return e.style=n,this.newSelectionControl(r,t,e)}_clearAllSelectionControls(){let e=this._selectionControls;for(let t of e)t.dispose();this._selectionControls.length=0}_getFreeze(){return this._sheetSkeletonManagerService.getCurrentParam()?.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(e===void 0||t===void 0)return null;let n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0||e>n.startRow&&t>n.startColumn)return this._scene.getViewport(oT.VIEW_MAIN);if(e<=n.startRow&&t<=n.startColumn)return this._scene.getViewport(oT.VIEW_MAIN_LEFT_TOP);if(e<=n.startRow&&t>n.startColumn)return this._scene.getViewport(oT.VIEW_MAIN_TOP);if(e>n.startRow&&t<=n.startColumn)return this._scene.getViewport(oT.VIEW_MAIN_LEFT)}getActiveRange(){let e=this.getSelectionControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}setActiveSelectionIndex(e){this._activeControlIndex=e}resetActiveSelectionIndex(){this._activeControlIndex=-1}getActiveSelectionControl(){let e=this.getSelectionControls();if(e)return this._activeControlIndex<0?e[e.length-1]:e[this._activeControlIndex]}endSelection(){var e;this._clearUpdatingListeners(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),(e=this._escapeShortcutDisposable)==null||e.dispose(),this._escapeShortcutDisposable=null}_reset(){var e;this._clearAllSelectionControls(),(e=this._downObserver)==null||e.unsubscribe(),this._downObserver=null}_setupPointerMoveListener(e,t,n,r=BE.ALL,i,a){let o=0,s=0,c=i,l=a;this._scrollTimer=VE.create(this._scene,r),this._scrollTimer.startScroll(e?.left??0,e?.top??0,e);let u=this._scene,d=u.getActiveViewportByCoord(zw.FromArray([i,a]));this._scenePointerMoveSub=u.onPointerMove$.subscribeEvent(r=>{let{offsetX:i,offsetY:a}=r,{x:f,y:p}=u.getCoordRelativeToViewport(zw.FromArray([i,a]));this._movingHandler(f,p,t,n);let m=f,h=p,g=this.getActiveSelectionControl(),_=this._getFreeze(),v=g?.model,y=u.getActiveViewportByCoord(zw.FromArray([i,a]))??this._getViewportByCell(v?.endRow,v?.endColumn);if((()=>{if(!d||!y||!e)return!1;let t=[oT.VIEW_MAIN,oT.VIEW_MAIN_LEFT_TOP,oT.VIEW_MAIN_TOP,oT.VIEW_MAIN_LEFT];return t.includes(d.viewportKey)&&t.includes(y.viewportKey)})()){if(!d||!y||!e)return!1;let t=c<e.left&&f>e.left||c>e.left&&f<e.left,n=l<e.top&&p>e.top||l>e.top&&p<e.top;t&&(o+=1),n&&(s+=1);let r=d.viewportKey,u=y.viewportKey;if(r===oT.VIEW_ROW_TOP)a<e.top&&(v?.endRow??0)<(_?.startRow??0)?h=e.top:n&&s%2==1&&e.scrollToViewportPos({viewportScrollY:0});else if(r===oT.VIEW_COLUMN_LEFT)i<e.left&&(v?.endColumn??0)<(_?.startColumn??0)?m=e.left:t&&o%2==1&&e.scrollToViewportPos({viewportScrollX:0});else if(r===u){let t=!1,n=!1;r===oT.VIEW_MAIN_LEFT_TOP?(t=!0,n=!0):r===oT.VIEW_MAIN_TOP?n=!0:r===oT.VIEW_MAIN_LEFT&&(t=!0),(v?.endRow??0)>(_?.startRow??0)&&(n=!1),(v?.endColumn??0)>(_?.startColumn??0)&&(t=!1),t&&(m=e.left),n&&(h=e.top)}else{let i={x:d.scrollX,y:d.scrollY},a={x:y.scrollX,y:y.scrollY},c=i.x!==a.x&&t&&o%2==1,l=i.y!==a.y&&n&&s%2==1;(c||l)&&(e.scrollToBarPos({x:c?i.x:void 0,y:l?i.y:void 0}),c||(m=e.left),l||(h=e.top)),(r===oT.VIEW_MAIN_LEFT_TOP&&u===oT.VIEW_MAIN_LEFT||u===oT.VIEW_MAIN_LEFT_TOP&&r===oT.VIEW_MAIN_LEFT)&&(m=e.left),(r===oT.VIEW_MAIN_LEFT_TOP&&u===oT.VIEW_MAIN_TOP||u===oT.VIEW_MAIN_LEFT_TOP&&r===oT.VIEW_MAIN_TOP)&&(h=e.top)}c=f,l=p}this._scrollTimer.scrolling(m,h,()=>{this._movingHandler(f,p,t,n)})})}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,n){let r=this._scene,i=n??this._skeleton,a=r.getViewportScrollXY(r.getViewport(oT.VIEW_MAIN)),{scaleX:o,scaleY:s}=r.getAncestorScale();return i.getCellWithCoordByOffset(e-a.x,t-a.y,o,s,a)}_movingHandler(e,t,n,r){let i=this._skeleton,a=this._scene,[o,s]=i.getLocation(),c={startRow:n?.model.startRow??-1,endRow:n?.model.endRow??-1,startColumn:n?.model.startColumn??-1,endColumn:n?.model.endColumn??-1,unitId:o,sheetId:s},l=a.getViewport(oT.VIEW_MAIN),u=this._getViewportByCell(c.endRow,c.endColumn)??l,d=a.getScrollXYInfoByViewport(zw.FromArray([this._startViewportPosX,this._startViewportPosY]),u),{scaleX:f,scaleY:p}=a.getAncestorScale();r===vh.ROW?e=1/0:r===vh.COLUMN&&(t=1/0);let m=this._skeleton.getCellByOffset(e,t,f,p,d);if(!m)return;let h={startRow:Math.min(m.startRow,this._startRangeWhenPointerDown.startRow),startColumn:Math.min(m.startColumn,this._startRangeWhenPointerDown.startColumn),endRow:Math.max(m.endRow,this._startRangeWhenPointerDown.endRow),endColumn:Math.max(m.endColumn,this._startRangeWhenPointerDown.endColumn)};this._shouldDetectMergedCells&&(h=i.expandRangeByMerge(h,this.inRefSelectionMode()));let g=pZ({range:h,primary:void 0,style:null},i);g.rangeWithCoord.unitId=o,g.rangeWithCoord.sheetId=s,g.rangeWithCoord.rangeType=r;let _=c.startRow!==h.startRow||c.startColumn!==h.startColumn||c.endRow!==h.endRow||c.endColumn!==h.endColumn;n!=null&&_&&(n.updateRangeBySelectionWithCoord(g),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var e,t,n,r,i;this._scene.enableObjectsEvent(),(e=this._scenePointerMoveSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerUpSub=null,(n=this._cancelDownSubscription)==null||n.unsubscribe(),this._cancelDownSubscription=null,(r=this._cancelUpSubscription)==null||r.unsubscribe(),this._cancelUpSubscription=null,(i=this._scrollTimer)==null||i.dispose()}_addEndingListeners(){var e,t;let n=this._scene,r=n.getEngine()?.activeScene;r&&r!==n&&((e=this._cancelDownSubscription)==null||e.unsubscribe(),this._cancelDownSubscription=null,(t=this._cancelUpSubscription)==null||t.unsubscribe(),this._cancelUpSubscription=null,this._cancelDownSubscription=r.onPointerDown$.subscribeEvent(()=>this._clearUpdatingListeners()),this._cancelUpSubscription=r.onPointerUp$.subscribeEvent(()=>this._clearUpdatingListeners()))}_getSelectionWithCoordByOffset(e,t,n,r,i){let a=this._skeleton;if(a==null)return null;if(this._shouldDetectMergedCells){let o=a?.getCellWithCoordByOffset(e,t,n,r,i,{firstMatch:!0});return o?{primaryWithCoord:o,rangeWithCoord:zh(o)}:void 0}let{row:o,column:s}=a.getCellIndexByOffset(e,t,n,r,i),{startX:c,startY:l,endX:u,endY:d}=a.getNoMergeCellWithCoordByIndex(o,s),f={startY:l,endY:d,startX:c,endX:u,startRow:o,endRow:o,startColumn:s,endColumn:s};return{primaryWithCoord:{mergeInfo:f,actualRow:o,actualColumn:s,isMerged:!1,isMergedMainCell:!1,startY:l,endY:d,startX:c,endX:u},rangeWithCoord:f}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,n,r,i){let{actualRow:a,actualColumn:o,mergeInfo:s}=e;this._startRangeWhenPointerDown={...e.mergeInfo};let c=Math.min(a,t.startRow,s.startRow),l=Math.max(a,t.endRow,s.endRow),u=Math.min(o,t.startColumn,s.startColumn),d=Math.max(o,t.endColumn,s.endColumn),f=pZ({range:n.expandRangeByMerge({startRow:c,startColumn:u,endRow:l,endColumn:d}),primary:NK(e),style:null},n);i.updateRangeBySelectionWithCoord(f)}isSelectionEnabled(){return this.contextService.getContextValue(GK)}isSelectionDisabled(){return this.contextService.getContextValue(GK)===!1}inRefSelectionMode(){return this.contextService.getContextValue(KK)}};function FZ(e){return{range:{startRow:0,startColumn:0,endRow:e.getRowCount()-1,endColumn:e.getColumnCount()-1,rangeType:vh.ALL},primary:IZ(e).primary,style:null}}function IZ(e){return Hmt(e,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Hmt(e,t){let n=e.worksheet.getCellInfoInMergeData(t.startRow,t.startColumn),r=e.worksheet.getCellInfoInMergeData(t.endRow,t.endColumn);return{range:{startRow:n.startRow,startColumn:n.startColumn,endRow:r.endRow,endColumn:r.endColumn,rangeType:vh.NORMAL},primary:{actualRow:n.startRow,actualColumn:n.startColumn,startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,isMerged:n.isMerged,isMergedMainCell:n.isMergedMainCell},style:null}}function $(e,t){return function(n,r){t(n,r,e)}}function LZ(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var RZ=class extends P{constructor(e,t){super(),this._context=e,this._sheetSkeletonService=t,Q(this,`_sheetId`,``),Q(this,`_currentSkeleton$`,new so(null)),Q(this,`currentSkeleton$`,this._currentSkeleton$.asObservable()),Q(this,`_currentSkeletonBefore$`,new so(null)),Q(this,`currentSkeletonBefore$`,this._currentSkeletonBefore$.asObservable());let{unitId:n,scene:r}=this._context;this._sheetSkeletonService.setScene(n,r),this._initSkeletonsRegisterGetCellHeight(n)}_initSkeletonsRegisterGetCellHeight(e){this._sheetSkeletonService.getSkeletonsByUnitId(e).forEach(e=>e.registerGetCellHeight()),this.disposeWithMe(this._sheetSkeletonService.buildSkeleton$.subscribe(e=>e.registerGetCellHeight()))}dispose(){super.dispose(),this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete()}getCurrentSkeleton(){return this.getCurrentParam()?.skeleton}getCurrentParam(){return this._getSkeletonParam(this._sheetId)}getSkeleton(e){return this._getSkeleton(e)}getSkeletonParam(e){return this._getSkeletonParam(e)}setCurrent(e){this._setCurrent(e.sheetId)}_setCurrent(e){this._sheetId=e;let t=this._getSkeletonParam(e);if(t)this.reCalculate(t);else{let n=this._context.unit,r=n.getSheetBySheetId(e),i=this._context.unitId;if(!r)return;t=this._sheetSkeletonService.newSkeletonParam(i,e,r,n.getStyles())}this._currentSkeletonBefore$.next(t),this._currentSkeleton$.next(t)}reCalculate(e){let t=e||this.getCurrentParam();t&&(t.dirty&&=(t.skeleton.makeDirty(!0),!1),t.skeleton.calculate())}makeDirty(e,t=!0){let n=this._getSkeletonParam(e.sheetId);n!=null&&(n.dirty=t)}ensureSkeleton(e){return this._sheetSkeletonService.ensureSkeleton(this._context.unitId,e)}_getSkeletonParam(e){return this._sheetSkeletonService.getSkeletonParam(this._context.unitId,e)}_getSkeleton(e){return this._sheetSkeletonService.getSkeleton(this._context.unitId,e)}setColumnHeaderSize(e,t,n){if(!e)return;let r=this.getSkeleton(t);if(!r)return;r.columnHeaderHeight=n,e.scene.getViewports()[0].top=n,e.scene.getViewport(oT.VIEW_COLUMN_RIGHT).setViewportSize({height:n}),e.scene.getViewport(oT.VIEW_COLUMN_LEFT).setViewportSize({height:n}),e.scene.getViewport(oT.VIEW_ROW_BOTTOM).setViewportSize({top:n}),e.scene.getViewport(oT.VIEW_ROW_TOP).setViewportSize({top:n}),e.scene.getViewport(oT.VIEW_LEFT_TOP).setViewportSize({height:n});let i=e?.with(WK),a=e?.with(NZ),o=i.getCurrentSelections();a.resetSelectionsByModelData(o);let s=this._sheetSkeletonService.getSkeletonParam(e.unitId,t);s&&(s.commandId=MZ.id,this._currentSkeleton$.next(s))}setRowHeaderSize(e,t,n){if(!e)return;let r=this.getSkeleton(t);if(!r)return;r.rowHeaderWidth=n;let i=n-(e.scene.getViewport(oT.VIEW_LEFT_TOP).width||46),a=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=a+i,e.scene.getViewport(oT.VIEW_ROW_BOTTOM).setViewportSize({width:n}),e.scene.getViewport(oT.VIEW_ROW_TOP).setViewportSize({width:n}),e.scene.getViewport(oT.VIEW_COLUMN_LEFT).setViewportSize({left:n});let o=e.scene.getViewport(oT.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(oT.VIEW_COLUMN_RIGHT).setViewportSize({left:o+i}),e.scene.getViewport(oT.VIEW_LEFT_TOP).setViewportSize({width:n});let s=e?.with(WK),c=e?.with(NZ),l=s.getCurrentSelections();c.resetSelectionsByModelData(l);let u=this._sheetSkeletonService.getSkeletonParam(e.unitId,t);u&&(u.commandId=jZ.id,this._currentSkeleton$.next(u))}};RZ=LZ([$(1,j(qK))],RZ);var Umt=`__SpreadsheetHelperSelectionTempRect`,Wmt=35,Gmt=class{constructor(e,t){this._control=e,Q(this,`_startOffsetX`,0),Q(this,`_startOffsetY`,0),Q(this,`_relativeSelectionPositionRow`,0),Q(this,`_relativeSelectionPositionColumn`,0),Q(this,`_relativeSelectionRowLength`,0),Q(this,`_relativeSelectionColumnLength`,0),Q(this,`_scenePointerMoveSub`,void 0),Q(this,`_scenePointerUpSub`,void 0),Q(this,`_disabled`,!1),Q(this,`_helperSelection`,void 0),Q(this,`_scrollTimer`,void 0),Q(this,`_activeViewport`,void 0),Q(this,`_targetSelection`,{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}),Q(this,`_isInMergeState`,!1),Q(this,`_fillControlColors`,[]),Q(this,`_skeleton`,void 0),Q(this,`_scene`,void 0),Q(this,`_themeService`,void 0),Q(this,`_injector`,void 0),Q(this,`_selectionHooks`,void 0),this._skeleton=t.skeleton,this._scene=t.scene,this._themeService=t.themeService,this._injector=t.injector,this._selectionHooks=t.selectionHooks,this._initialControl(),this._initialWidget(),this._initialAutoFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}setDisabled(e){this._disabled=e}_getFreeze(){var e;return(e=JE(M.UNIVER_SHEET,RZ,this._injector.get(z),this._injector.get(KE)))==null||(e=e.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(e,t){let n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(t.viewportKey){case oT.VIEW_MAIN:return e.endRow>=n.startRow&&e.endColumn>=n.startColumn;case oT.VIEW_MAIN_TOP:case oT.VIEW_COLUMN_RIGHT:return e.endColumn>=n.startColumn&&e.startRow<n.startRow;case oT.VIEW_MAIN_LEFT:case oT.VIEW_ROW_BOTTOM:return e.endRow>=n.startRow&&e.startColumn<n.startColumn;case oT.VIEW_MAIN_LEFT_TOP:case oT.VIEW_COLUMN_LEFT:case oT.VIEW_ROW_TOP:case oT.VIEW_LEFT_TOP:return e.startRow<n.startRow&&e.startColumn<n.startColumn}}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){let{leftControl:e,rightControl:t,topControl:n,bottomControl:r}=this._control;[e,t,n,r].forEach(e=>{e.onPointerEnter$.subscribeEvent(()=>{this._injector.get(NZ,D.OPTIONAL)?.interceptor.fetchThroughInterceptors(CZ)(!1,null)!==!1&&e.setCursor(_w.MOVE)}),e.onPointerLeave$.subscribeEvent(()=>{e.resetCursor()}),e.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(e,t){var n;let r=this._scene,i=r.getScrollXYInfoByViewport(zw.FromArray([e,t])),{scaleX:a,scaleY:o}=r.getAncestorScale(),{row:s,column:c}=this._skeleton.getCellIndexByOffset(e,t,a,o,i),l=this._skeleton.getRowCount()-1,u=this._skeleton.getColumnCount()-1,d=Math.max(0,s+this._relativeSelectionPositionRow),f=d+this._relativeSelectionRowLength;f>l&&(f=l,f-d<this._relativeSelectionRowLength&&(d=f-this._relativeSelectionRowLength));let p=Math.max(0,c+this._relativeSelectionPositionColumn),m=p+this._relativeSelectionColumnLength;m>u&&(m=u,m-p<this._relativeSelectionColumnLength&&(p=m-this._relativeSelectionColumnLength));let h=this._skeleton.worksheet.getCellInfoInMergeData(d,p),g=pZ({range:{startRow:d,endRow:f,startColumn:p,endColumn:m},primary:h,style:null},this._skeleton),_=this._skeleton.getNoMergeCellWithCoordByIndex(d,p),v=this._skeleton.getNoMergeCellWithCoordByIndex(f,m),y=_?.startY||0,b=v?.endY||0,x=_?.startX||0,S=v?.endX||0;(n=this._helperSelection)==null||n.transformByState({left:x,top:y,width:S-x,height:b-y}),this._targetSelection={...g.rangeWithCoord},this._control.selectionMoving$.next(g.rangeWithCoord)}_controlPointerDownHandler(e){let{offsetX:t,offsetY:n}=e,r=this._scene,i=r.getCoordRelativeToViewport(zw.FromArray([t,n])),{x:a,y:o}=i,s=r.getScrollXYInfoByViewport(i),{scaleX:c,scaleY:l}=r.getAncestorScale(),u=this._skeleton.getCellIndexByOffset(a,o,c,l,s);this._startOffsetX=a,this._startOffsetY=o;let{row:d,column:f}=u,{startRow:p,startColumn:m,endRow:h,endColumn:g}=this._control.model,_=0,v=0;d<p?--_:d>h&&(_+=1),f<m?--v:f>g&&(v+=1),this._relativeSelectionPositionRow=p-d+_,this._relativeSelectionPositionColumn=m-f+v,this._relativeSelectionRowLength=h-p,this._relativeSelectionColumnLength=g-m;let y=this._control.currentStyle,b=this._getScale();this.isHelperSelection&&(this._helperSelection=new OE(Umt,{stroke:y.stroke,strokeWidth:y.strokeWidth/b}),r.addObject(this._helperSelection));let x=r.getViewport(oT.VIEW_MAIN),S=VE.create(r);this._scrollTimer=S,S.startScroll(a,o,x),r.disableObjectsEvent(),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(e=>{if(this._disabled)return;let{offsetX:t,offsetY:n}=e;if(this._injector.get(NZ,D.OPTIONAL)?.interceptor.fetchThroughInterceptors(CZ)(!1,null)===!1)return;let{x:i,y:a}=r.getCoordRelativeToViewport(zw.FromArray([t,n]));this._controlMoving(i,a),r.setCursor(_w.MOVE),S.scrolling(i,a,()=>{this._controlMoving(i,a)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var e,t,n,r;(e=this._helperSelection)==null||e.dispose();let i=this._scene;i.resetCursor(),this._clearObserverEvent(),i.enableObjectsEvent(),(t=this._scrollTimer)==null||t.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(n=(r=this._selectionHooks).selectionMoveEnd)==null||n.call(r)})}_initialWidget(){let{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:r,middleRightWidget:i,bottomLeftWidget:a,bottomCenterWidget:o,bottomRightWidget:s}=this._control,c=[_w.NORTH_WEST_RESIZE,_w.NORTH_RESIZE,_w.NORTH_EAST_RESIZE,_w.WEST_RESIZE,_w.EAST_RESIZE,_w.SOUTH_WEST_RESIZE,_w.SOUTH_RESIZE,_w.SOUTH_EAST_RESIZE];[e,t,n,r,i,a,o,s].forEach((e,t)=>{e.onPointerEnter$.subscribeEvent(()=>{e.setCursor(c[t])}),e.onPointerLeave$.subscribeEvent(()=>{e.resetCursor()}),e.onPointerDown$.subscribeEvent(e=>{this._widgetPointerDownEvent(e,c[t])})})}_widgetPointerDownEvent(e,t){let n=this._scene,{offsetX:r,offsetY:i}=e,{x:a,y:o}=n.getCoordRelativeToViewport(zw.FromArray([r,i]));this._startOffsetX=r,this._startOffsetY=i;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=this._control.model,d=Math.min(s,l),f=Math.min(c,u),p=Math.max(s,l),m=Math.max(c,u);this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-d,this._relativeSelectionColumnLength=m-f,t===_w.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=m):t===_w.NORTH_RESIZE||t===_w.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:t===_w.WEST_RESIZE||t===_w.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=m:t===_w.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=d);let h=VE.create(n),g=n.getViewport(oT.VIEW_MAIN);h.startScroll(a,o,g),this._scrollTimer=h,n.disableObjectsEvent(),this._scenePointerMoveSub=n.onPointerMove$.subscribeEvent(e=>{let{offsetX:r,offsetY:i}=e,{x:a,y:o}=n.getCoordRelativeToViewport(zw.FromArray([r,i]));this._widgetMoving(a,o,t),n.setCursor(t),h.scrolling(a,o,()=>{this._widgetMoving(a,o,t)})}),this._scenePointerUpSub=n.onPointerUp$.subscribeEvent(()=>{var e,t,n;let r=this._scene;r.resetCursor(),this._clearObserverEvent(),r.enableObjectsEvent(),(e=this._scrollTimer)==null||e.dispose(),this._control.selectionScaled$.next(this._targetSelection),(t=(n=this._selectionHooks).selectionMoveEnd)==null||t.call(n)})}_widgetMoving(e,t,n){let r=this._scene,i=r.getScrollXYInfoByViewport(zw.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:a,scaleY:o}=r.getAncestorScale(),{row:s,column:c}=this._skeleton.getCellIndexByOffset(e,t,a,o,i),l=this._relativeSelectionPositionRow,u=this._relativeSelectionPositionColumn,d=s,f=c;n===_w.NORTH_WEST_RESIZE?(l=s,u=c,d=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):n===_w.NORTH_RESIZE?(l=s,u=this._relativeSelectionPositionColumn,d=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===_w.NORTH_EAST_RESIZE?(l=s,u=this._relativeSelectionPositionColumn,d=this._relativeSelectionPositionRow,f=c):n===_w.WEST_RESIZE?(l=this._relativeSelectionPositionRow,u=c,d=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):n===_w.EAST_RESIZE?d=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===_w.SOUTH_WEST_RESIZE?(l=this._relativeSelectionPositionRow,u=c,d=s,f=this._relativeSelectionPositionColumn):n===_w.SOUTH_RESIZE&&(l=this._relativeSelectionPositionRow,u=this._relativeSelectionPositionColumn,d=s,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);let p=pZ({range:this._swapPositions(l,u,d,f),primary:this._skeleton.getCellWithMergeInfoByIndex(l,u),style:null},this._skeleton);this._targetSelection={...p.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(p),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){let{fillControl:e}=this._control;e.onPointerEnter$.subscribeEvent(t=>{this._injector.get(NZ).interceptor.fetchThroughInterceptors(wZ)(!1,{x:t.offsetX,y:t.offsetY,skeleton:this._skeleton,scene:this._scene})&&e.setCursor(_w.CROSSHAIR)}),e.onPointerLeave$.subscribeEvent(()=>{e.resetCursor()}),e.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(e,t){let n=this._scene,r=n.getViewportScrollXY(this._activeViewport),{scaleX:i,scaleY:a}=n.getAncestorScale(),{row:o,column:s}=this._skeleton.getCellIndexByOffset(e,t,i,a,r),c=n.getCoordRelativeToViewport(zw.FromArray([e,t])),l=this._skeleton.getRowCount()-1,u=this._skeleton.getColumnCount()-1,d=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,m=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,h=!1,g=!0;if((s<f||s>m)&&o>=d&&o<=p){let e=this._fillRuler(s,f,m,this._relativeSelectionColumnLength,u);f=e.startRowOrColumn,m=e.endRowOrColumn,h=e.isLighten,g=!1}else if((o<d||o>p)&&s>=f&&s<=m){let e=this._fillRuler(o,d,p,this._relativeSelectionRowLength,l);d=e.startRowOrColumn,p=e.endRowOrColumn,h=e.isLighten}else if(Math.abs(this._startOffsetX-c.x-r.x)/2>Math.abs(this._startOffsetY-c.y-r.y)){let e=this._fillRuler(s,f,m,this._relativeSelectionColumnLength,u);f=e.startRowOrColumn,m=e.endRowOrColumn,h=e.isLighten,g=!1}else{let e=this._fillRuler(o,d,p,this._relativeSelectionRowLength,l);d=e.startRowOrColumn,p=e.endRowOrColumn,h=e.isLighten}let _=this._skeleton.getNoMergeCellWithCoordByIndex(d,f),v=this._skeleton.getNoMergeCellWithCoordByIndex(p,m),y=_?.startY||0,b=v?.endY||0,x=_?.startX||0,S=v?.endX||0;h?this._controlHandler((e,t)=>{let n=new rh(this._fillControlColors[t]).lighten(Wmt).toRgbString();e.setProps({fill:n})}):this._controlHandler((e,t)=>{e.setProps({fill:this._fillControlColors[t]})});let C=AK/this._getScale();if(d===p&&g===!0||f===m&&g===!1){var w;(w=this._helperSelection)==null||w.hide()}else{var T,E;(T=this._helperSelection)==null||T.transformByState({left:x-C/2,top:y-C/2,width:S-x,height:b-y}),(E=this._helperSelection)==null||E.show()}this._targetSelection={startY:y,endY:b,startX:x,endX:S,startRow:d,endRow:p,startColumn:f,endColumn:m},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(e){let{offsetX:t,offsetY:n}=e,r=this._scene,{x:i,y:a}=r.getCoordRelativeToViewport(zw.FromArray([t,n]));this._startOffsetX=i,this._startOffsetY=a;let{startRow:o,startColumn:s,endRow:c,endColumn:l}=this._control.model;this._isInMergeState=this._hasMergeInRange(o,s,c,l),this._relativeSelectionPositionRow=o,this._relativeSelectionPositionColumn=s,this._relativeSelectionRowLength=c-o,this._relativeSelectionColumnLength=l-s;let u=this._control.currentStyle,d=u?.stroke,f=u?.strokeWidth,p=TZ(this._themeService);d??=p.stroke,f??=p.strokeWidth;let m=this._getScale();f/=m;let h=AK/m,g=new rh(d).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new OE(Umt,{stroke:g,strokeWidth:f+h/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(zw.FromArray([t,n]));let _=r.getViewport(oT.VIEW_MAIN),v=VE.create(r,this._activeViewport.viewportKey===oT.VIEW_MAIN?BE.ALL:BE.NONE);v.startScroll(i,a,_),this._scrollTimer=v,r.disableObjectsEvent(),this._controlHandler(e=>{this._fillControlColors.push(e.fill)}),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(t=>{let{offsetX:n,offsetY:i}=t,a=r.getActiveViewportByCoord(zw.FromArray([n,i]));if(!this._injector.get(NZ).interceptor.fetchThroughInterceptors(wZ)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene}))return;let{x:l,y:u}=r.getCoordRelativeToViewport(zw.FromArray([n,i]));this._autoFillMoving(l,u),r.setCursor(_w.CROSSHAIR);let d=this._targetSelection;if(_&&a&&this._activeViewport?.viewportKey!==a?.viewportKey){let e;d.startRow===o?d.endRow===c?d.startColumn===s?(v.scrollTimerType=BE.X,e={...d,startColumn:d.endColumn}):(v.scrollTimerType=BE.X,e={...d,endColumn:d.startColumn}):(v.scrollTimerType=BE.Y,e={...d,startRow:d.endRow}):(v.scrollTimerType=BE.Y,e={...d,endRow:d.startRow}),this._isSelectionInViewport(e,a)&&(this._viewportMainScrollBarNeedResetPosition(v.scrollTimerType,this._activeViewport.viewportKey,a.viewportKey)&&_.scrollToBarPos({x:v.scrollTimerType===BE.X?0:void 0,y:v.scrollTimerType===BE.Y?0:void 0}),this._activeViewport=a)}v.scrolling(l,u,()=>{this._autoFillMoving(l,u)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var e,t;(e=this._helperSelection)==null||e.dispose();let n=this._scene;n.resetCursor(),this._clearObserverEvent(),n.enableObjectsEvent(),(t=this._scrollTimer)==null||t.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((e,t)=>{e.setProps({fill:this._fillControlColors[t]})}),this._fillControlColors=[]})}_viewportMainScrollBarNeedResetPosition(e,t,n){return!((e!==BE.X||t!==oT.VIEW_MAIN_LEFT&&t!==oT.VIEW_MAIN_LEFT_TOP||n!==oT.VIEW_MAIN&&n!==oT.VIEW_MAIN_TOP)&&(e!==BE.Y||t!==oT.VIEW_MAIN_TOP&&t!==oT.VIEW_MAIN_LEFT_TOP||n!==oT.VIEW_MAIN&&n!==oT.VIEW_MAIN_LEFT))}_hasMergeInRange(e,t,n,r){return this._skeleton.worksheet.getMergedCellRange(e,t,n,r).length>0}_swapPositions(e,t,n,r){return{startRow:Math.min(e,n),startColumn:Math.min(t,r),endRow:Math.max(e,n),endColumn:Math.max(t,r)}}_controlHandler(e){let{leftControl:t,rightControl:n,topControl:r,bottomControl:i,backgroundControlTop:a,backgroundControlMiddleLeft:o,backgroundControlMiddleRight:s,backgroundControlBottom:c,fillControl:l}=this._control,u=[t,n,r,i,a,o,s,c,l];for(let t=0,n=u.length;t<n;t++){let n=u[t];e(n,t)}}_fillRuler(e,t,n,r,i){let a=!1;if(e<t){if(this._isInMergeState&&e<t){let n=t-e,i=r+1,a=Math.ceil(n/i),o=t-a*i;o<0&&(o=t-(a-1)*i),t=o}else t=e}else if(e>=t&&e<=n)a=!0,this._isInMergeState||(n=e);else if(this._isInMergeState&&e>n){let t=e-n,a=r+1,o=Math.ceil(t/a),s=n+o*a;s>i&&(s=n+(o-1)*a),n=s}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:a}}_getScale(){let{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}},Kmt=.3,zZ=class extends P{constructor(e,t,n,r){super(),this._scene=e,this._zIndex=t,this._themeService=n,Q(this,`_isHelperSelection`,!0),Q(this,`_enableAutoFill`,!0),Q(this,`_showAutoFill`,!1),Q(this,`_highlightHeader`,!0),Q(this,`_selectionRenderModel`,void 0),Q(this,`_leftBorder`,void 0),Q(this,`_rightBorder`,void 0),Q(this,`_topBorder`,void 0),Q(this,`_bottomBorder`,void 0),Q(this,`_backgroundControlTop`,void 0),Q(this,`_backgroundControlBottom`,void 0),Q(this,`_backgroundControlMiddleLeft`,void 0),Q(this,`_backgroundControlMiddleRight`,void 0),Q(this,`_autoFillControl`,void 0),Q(this,`_selectionShapeGroup`,void 0),Q(this,`_rowHeaderBackground`,void 0),Q(this,`_rowHeaderBorder`,void 0),Q(this,`_rowHeaderGroup`,void 0),Q(this,`_columnHeaderBackground`,void 0),Q(this,`_columnHeaderBorder`,void 0),Q(this,`_columnHeaderGroup`,void 0),Q(this,`_dashedRect`,void 0),Q(this,`_topLeftWidget`,void 0),Q(this,`_topCenterWidget`,void 0),Q(this,`_topRightWidget`,void 0),Q(this,`_middleLeftWidget`,void 0),Q(this,`_middleRightWidget`,void 0),Q(this,`_bottomLeftWidget`,void 0),Q(this,`_bottomCenterWidget`,void 0),Q(this,`_bottomRightWidget`,void 0),Q(this,`_defaultStyle`,void 0),Q(this,`_currentStyle`,void 0),Q(this,`_rowHeaderWidth`,0),Q(this,`_columnHeaderHeight`,0),Q(this,`_rowHeaderOffsetX`,0),Q(this,`_columnHeaderOffsetY`,0),Q(this,`_widgetRects`,[]),Q(this,`_controlExtension`,void 0),Q(this,`_dispose$`,new so(this)),Q(this,`dispose$`,this._dispose$.asObservable()),Q(this,`selectionMoving$`,new ao),Q(this,`selectionMoveEnd$`,new ao),Q(this,`selectionScaling$`,new ao),Q(this,`selectionScaled$`,new ao),Q(this,`selectionFilling$`,new ao),Q(this,`_selectionFilled$`,new ao),Q(this,`selectionFilled$`,this._selectionFilled$.asObservable()),Q(this,`_antLineOffset`,0),Q(this,`_antRequestNewFrame`,-1),this._enableAutoFill=r?.enableAutoFill??!0,this._highlightHeader=r?.highlightHeader??!0,this._rowHeaderWidth=r?.rowHeaderWidth??0,this._columnHeaderHeight=r?.columnHeaderHeight??0,this._rowHeaderOffsetX=r?.rowHeaderOffsetX??0,this._columnHeaderOffsetY=r?.columnHeaderOffsetY??0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=TZ(this._themeService),this._currentStyle=TZ(this._themeService),this._selectionRenderModel=new Bmt;let e=this._zIndex;this._leftBorder=new OE(`__SpreadsheetSelectionShapeLeftControl__`+e,{zIndex:e}),this._rightBorder=new OE(`__SpreadsheetSelectionShapeRightControl__`+e,{zIndex:e}),this._topBorder=new OE(`__SpreadsheetSelectionTopControl__`+e,{zIndex:e}),this._bottomBorder=new OE(`__SpreadsheetSelectionBottomControl__`+e,{zIndex:e}),this._backgroundControlTop=new OE(`__SpreadsheetSelectionBackgroundControlTop__`+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new OE(`__SpreadsheetSelectionBackgroundControlBottom__`+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new OE(`__SpreadsheetSelectionBackgroundControlMiddleLeft__`+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new OE(`__SpreadsheetSelectionBackgroundControlMiddleRight__`+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new OE(`__SpreadsheetSelectionFillControl__`+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new ake(`__SpreadsheetDragDashControl__`+e,{zIndex:e+2,evented:!1,stroke:`#fff`});let t=[this._autoFillControl,this._leftBorder,this._rightBorder,this._topBorder,this._bottomBorder,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashedRect];this._widgetRects=this._initialWidget(),this._selectionShapeGroup=new IE(`__SpreadsheetSelectionShape__`+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;let n=this.getScene();n.addObject(this._selectionShapeGroup,1),this.disposeWithMe(Wf(n.onTransformChange$.subscribeEvent(e=>{e.type===qw.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){let e=this._zIndex;this._rowHeaderBackground=new OE(`__SpreadSheetSelectionRowHeaderBackground__`+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new OE(`__SpreadSheetSelectionRowHeaderBorder__`+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new IE(`__SpreadSheetSelectionRowHeaderGroup__`+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new OE(`__SpreadSheetSelectionColumnHeaderBackground__`+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new OE(`__SpreadSheetSelectionColumnHeaderBorder__`+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new IE(`__SpreadSheetSelectionColumnHeaderGroup__`+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],11)}_initialWidget(){let e=this._zIndex;return this._topLeftWidget=new OE(`__SpreadSheetSelectionTopLeftWidget__`+e,{zIndex:e+1}),this._topCenterWidget=new OE(`__SpreadSheetSelectionTopCenterWidget__`+e,{zIndex:e+1}),this._topRightWidget=new OE(`__SpreadSheetSelectionTopRightWidget__`+e,{zIndex:e+1}),this._middleLeftWidget=new OE(`__SpreadSheetSelectionMiddleLeftWidget__`+e,{zIndex:e+1}),this._middleRightWidget=new OE(`__SpreadSheetSelectionMiddleRightWidget__`+e,{zIndex:e+1}),this._bottomLeftWidget=new OE(`__SpreadSheetSelectionBottomLeftWidget__`+e,{zIndex:e+1}),this._bottomCenterWidget=new OE(`__SpreadSheetSelectionBottomCenterWidget__`+e,{zIndex:e+1}),this._bottomRightWidget=new OE(`__SpreadSheetSelectionBottomRightWidget__`+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}get zIndex(){return this._zIndex}get leftControl(){return this._leftBorder}get rightControl(){return this._rightBorder}get topControl(){return this._topBorder}get bottomControl(){return this._bottomBorder}get fillControl(){return this._autoFillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShapeGroup}get columnHeaderGroup(){return this._columnHeaderGroup}get rowHeaderGroup(){return this._rowHeaderGroup}get selectionShapeGroup(){return this._selectionShapeGroup}get model(){return this._selectionRenderModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get themeService(){return this._themeService}get selectionModel(){return this._selectionRenderModel}set selectionModel(e){this._selectionRenderModel=e}get currentStyle(){return this._currentStyle}set currentStyle(e){this._currentStyle=e}get dashedRect(){return this._dashedRect}get isHelperSelection(){return this._isHelperSelection}get rowHeaderWidth(){return this._rowHeaderWidth}set rowHeaderWidth(e){this._rowHeaderWidth=e}get columnHeaderHeight(){return this._columnHeaderHeight}set columnHeaderHeight(e){this._columnHeaderHeight=e}setControlExtension(e){this._controlExtension=new Gmt(this,e)}setControlExtensionDisable(e){this._controlExtension&&this._controlExtension.setDisabled(e)}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}refreshSelectionFilled(e){this._selectionFilled$.next(e)}_updateLayoutOfSelectionControl(e){e&&(this.currentStyle=Object.assign({},this._defaultStyle,e));let t=this.currentStyle,{stroke:n,widgets:r,autofillStroke:i,strokeDash:a,isAnimationDash:o}=t,s=t.autofillSize,c=t.strokeWidth,l=t.autofillStrokeWidth,u=this._getScale(),d=(c+AK)/2/u;c/=u,s/=u,l/=u<1?1:u;let f=AK/u,p=bw/u,{startX:m,startY:h,endX:g,endY:_}=this._selectionRenderModel;if(this.leftControl.transformByState({height:_-h,left:-d+p,width:c,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:n,stroke:jK}),this.rightControl.transformByState({height:_-h,left:g-m-d+p,width:c,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:n,stroke:jK}),this.topControl.transformByState({width:g-m+c,top:-d+p,left:-d+p,height:c,strokeWidth:f}),this.topControl.setProps({fill:n,stroke:jK}),this.bottomControl.transformByState({width:g-m+c,top:_-h-d+p,height:c,left:-d+p,strokeWidth:f}),this.bottomControl.setProps({fill:n,stroke:jK}),a==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{let e=t.strokeWidth*2/u;this.dashedRect.transformByState({height:_-h,width:g-m,strokeWidth:e,left:-e/2+p,top:-e/2+p}),this.dashedRect.setProps({strokeDashArray:[0,a/u]}),this._stopAntLineAnimation(),o!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(r)){let e={fill:n,stroke:i,strokeScaleEnabled:!1},t={width:s-l,height:s-l,left:g-m-s/2+l/2-p,top:_-h-s/2+l/2-p,strokeWidth:l};this._autoFillControl.setProps(e),this._autoFillControl.transformByState(t),this._autoFillControl.show()}else this._autoFillControl.hide();this._updateBackgroundControl(t),this._updateHeaderBackground(t),this._updateWidgets(t)}_updateControlCoord(){let{startX:e,startY:t}=this._selectionRenderModel;this.selectionShapeGroup.show(),this.selectionShapeGroup.translate(e,t),this.selectionShapeGroup.makeDirtyNoDebounce(!0)}updateStyle(e){this._updateLayoutOfSelectionControl(e),this._updateControlCoord()}updateRange(e,t){this._selectionRenderModel.setValue(e,t),this._showAutoFill=t!==null,this._updateLayoutOfSelectionControl(),this._updateControlCoord()}updateRangeBySelectionWithCoord(e,t){t&&(this._rowHeaderWidth=t.rowHeaderWidth,this._columnHeaderHeight=t.columnHeaderHeight,this._rowHeaderOffsetX=Math.max(0,t.rowHeaderWidthAndMarginLeft-t.rowHeaderWidth),this._columnHeaderOffsetY=Math.max(0,t.columnHeaderHeightAndMarginTop-t.columnHeaderHeight)),this._selectionRenderModel.setValue(e.rangeWithCoord,e.primaryWithCoord),this._showAutoFill=e.primaryWithCoord!==null,this._updateLayoutOfSelectionControl(e.style),this._updateControlCoord()}update(e,t=0,n=0,r,i){this._rowHeaderWidth=t,this._columnHeaderHeight=n,this._rowHeaderOffsetX=0,this._columnHeaderOffsetY=0,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:i,style:r}),r&&this.updateStyle(r)}updateCurrCell(e){this._showAutoFill=e!==null,this._selectionRenderModel.setCurrentCell(e)}clearHighlight(){this._showAutoFill=!1,this._selectionRenderModel.clearCurrentCell(),this._updateLayoutOfSelectionControl(this._currentStyle)}getScene(){return this._scene}dispose(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(n=this._topBorder)==null||n.dispose(),(r=this._bottomBorder)==null||r.dispose(),(i=this._backgroundControlTop)==null||i.dispose(),(a=this._backgroundControlMiddleLeft)==null||a.dispose(),(o=this._backgroundControlMiddleRight)==null||o.dispose(),(s=this._backgroundControlBottom)==null||s.dispose(),this._autoFillControl.dispose(),(c=this._selectionShapeGroup)==null||c.dispose(),(l=this._rowHeaderBackground)==null||l.dispose(),(u=this._rowHeaderBorder)==null||u.dispose(),(d=this._rowHeaderGroup)==null||d.dispose(),(f=this._rowHeaderBackground)==null||f.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(m=this._columnHeaderBorder)==null||m.dispose(),(h=this._columnHeaderGroup)==null||h.dispose(),(g=this._topLeftWidget)==null||g.dispose(),(_=this._topCenterWidget)==null||_.dispose(),(v=this._topRightWidget)==null||v.dispose(),(y=this._middleLeftWidget)==null||y.dispose(),(b=this._middleRightWidget)==null||b.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(S=this._bottomCenterWidget)==null||S.dispose(),(C=this._bottomRightWidget)==null||C.dispose(),(w=this._controlExtension)==null||w.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){let e=this.model.currentCell;if(e){let t;if(e.isMerged){let n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{let{actualRow:n,actualColumn:r,startX:i,endX:a,startY:o,endY:s}=e;t={startRow:n,endRow:n,startColumn:r,endColumn:r,startX:i,endX:a,startY:o,endY:s}}return t}}getValue(){return{...this._selectionRenderModel.getValue(),style:this._currentStyle}}getRange(){return this._selectionRenderModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}_updateHeaderBackground(e){let{startX:t,startY:n,endX:r,endY:i,rangeType:a}=this._selectionRenderModel,o=this._currentStyle,s=this._getScale(),{stroke:c,rowHeaderFill:l=o.rowHeaderFill,rowHeaderStroke:u=o.rowHeaderStroke,columnHeaderFill:d=o.columnHeaderFill,columnHeaderStroke:f=o.columnHeaderStroke}=e,{rowHeaderStrokeWidth:p=o.rowHeaderStrokeWidth,columnHeaderStrokeWidth:m=o.columnHeaderStrokeWidth}=e;p/=s,m/=s;let h=this._rowHeaderWidth,g=this._columnHeaderHeight,_=this._rowHeaderOffsetX,v=this._columnHeaderOffsetY;if(this._highlightHeader&&g>0){let e=d;a===vh.COLUMN&&(e=new rh(c).setAlpha(Kmt).toString()),this._columnHeaderBackground.setProps({fill:e}),this._columnHeaderBackground.resize(r-t,g),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:r-t,height:m,top:g-m+1/s}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(t,v)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),this._highlightHeader&&h>0){let e=l;a===vh.ROW&&(e=new rh(c).setAlpha(Kmt).toString()),this._rowHeaderBackground.setProps({fill:e}),this._rowHeaderBackground.resize(h,i-n),this._rowHeaderBorder.setProps({fill:u}),this._rowHeaderBorder.transformByState({width:p,height:i-n,left:h-p+1/s}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(_,n)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){let{startX:t,startY:n,endX:r,endY:i}=this._selectionRenderModel,a=this._getScale(),{fill:o=e.fill}=e,{strokeWidth:s}=e;s/=a;let c=this._selectionRenderModel.highlightToSelection();if(!c){this._backgroundControlTop.resize(r-t,i-n),this._backgroundControlTop.setProps({fill:o}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}let{startX:l,startY:u,endX:d,endY:f}=c,p=s/2,m={left:-p,top:-p,width:r-t+p*2,height:u-n+p};m.height<0&&(m.width=0,m.height=0),this._backgroundControlTop.transformByState(m);let h={left:-p,top:u-n,width:l-t+p,height:f-u};h.width<0&&(h.width=0,h.height=0),this._backgroundControlMiddleLeft.transformByState(h);let g={left:d-t-p,top:u-n,width:r-d+p*2,height:f-u};g.width<0&&(g.width=0,g.height=0),this._backgroundControlMiddleRight.transformByState(g);let _={left:-p,top:f-n,width:r-t+p*2,height:i-f+p};_.height<0&&(_.width=0,_.height=0),this._backgroundControlBottom.transformByState(_),this._backgroundControlTop.setProps({fill:o}),this._backgroundControlMiddleLeft.setProps({fill:o}),this._backgroundControlMiddleRight.setProps({fill:o}),this._backgroundControlBottom.setProps({fill:o})}_updateWidgets(e){let{startX:t,startY:n,endX:r,endY:i}=this._selectionRenderModel,{stroke:a=e.stroke,widgets:o=e.widgets,widgetStroke:s=e.widgetStroke}=e,c=this._getScale(),{widgetSize:l,widgetStrokeWidth:u}=e;l/=c,u/=c;let d={left:-l/2+u/2,center:(r-t)/2-l/2+u/2,right:r-t-l/2+u/2,top:-l/2,middle:(i-n)/2-l/2,bottom:i-n-l/2+u/2},f=l-u;this._widgetRects.forEach(e=>{e.setProps({fill:a,stroke:s})}),o.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:d.left,top:d.top,strokeWidth:u}),this._topLeftWidget.show()):this._topLeftWidget.hide(),o.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:d.center,top:d.top,strokeWidth:u}),this._topCenterWidget.show()):this._topCenterWidget.hide(),o.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:d.right,top:d.top,strokeWidth:u}),this._topRightWidget.show()):this._topRightWidget.hide(),o.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:d.left,top:d.middle,strokeWidth:u}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),o.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:d.right,top:d.middle,strokeWidth:u}),this._middleRightWidget.show()):this._middleRightWidget.hide(),o.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:d.left,top:d.bottom,strokeWidth:u}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),o.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:d.center,top:d.bottom,strokeWidth:u}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),o.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:d.right,top:d.bottom,strokeWidth:u}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;let t=Object.keys(e);if(t.length===0)return!1;for(let n of t)if(e[n]===!0)return!0;return!1}_getScale(){let{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,YSe(this._antRequestNewFrame)}_startAntLineAnimation(){let e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>160/e&&(this._antLineOffset=0),this.dashedRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=Cw(()=>{this._startAntLineAnimation()})}},qmt=1e4,BZ=ce(`univer.mark-selection-service`),VZ=class extends P{constructor(e,t,n,r){super(),this._currentService=e,this._sheetSkeletonService=t,this._renderManagerService=n,this._themeService=r,Q(this,`_shapeMap`,new Map)}addShape(e,t=[],n=qmt){let r=this._currentService.getCurrentUnitOfType(M.UNIVER_SHEET),i=r.getActiveSheet()?.getSheetId();if(!i)return null;let a=ip(),o={selection:e,subUnitId:i,unitId:r.getUnitId(),zIndex:n,control:null,exits:t};return this._shapeMap.set(a,o),this.refreshShapes(),a}addShapeWithNoFresh(e,t=[],n=qmt){let r=this._currentService.getCurrentUnitOfType(M.UNIVER_SHEET),i=r.getActiveSheet()?.getSheetId();if(!i)return null;let a=ip();return this._shapeMap.set(a,{selection:e,subUnitId:i,unitId:r.getUnitId(),zIndex:n,control:null,exits:t}),a}refreshShapes(){let e=this._currentService.getCurrentUnitOfType(M.UNIVER_SHEET);if(!e)return;let t=e.getUnitId(),n=e.getActiveSheet()?.getSheetId();this._shapeMap.forEach(e=>{let{unitId:r,subUnitId:i,selection:a,control:o,zIndex:s}=e;if(o?.dispose(),r!==t||i!==n)return;let c=this._renderManagerService.getRenderById(r);if(!c)return;let l=this._sheetSkeletonService.getSkeleton(r,i);if(!l)return;let{scene:u}=c,{rowHeaderWidth:d,columnHeaderHeight:f}=l,p=new zZ(u,s,this._themeService,{enableAutoFill:!1,highlightHeader:!1,rowHeaderWidth:d,columnHeaderHeight:f}),m=pZ(a,l);p.updateRangeBySelectionWithCoord(m),e.control=p})}getShapeMap(){return this._shapeMap}removeShape(e){let t=this._shapeMap.get(e);if(!t)return;let{control:n}=t;n?.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(let e of this._shapeMap.values()){let{control:t}=e;t?.dispose()}this._shapeMap.clear()}};VZ=LZ([$(0,z),$(1,j(qK)),$(2,KE),$(3,j(_x))],VZ);function Jmt(e){return{strokeWidth:1.5,stroke:e.getColorFromTheme(`primary.600`),fill:`rgba(178, 178, 178, 0.10)`,widgets:{},strokeDash:8}}function Ymt(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:kb(e.p)),e.s!==void 0&&(t.s=e.s===null||typeof e.s==`string`?e.s:kb(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:kb(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.plain!==void 0&&(t.plain=e.plain),t}var Xmt=10;function Zmt(e){let t=e.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}var Qmt=class{constructor(){Q(this,`_cache`,new Yg(Xmt)),Q(this,`_lastCopyId$`,new so(null)),Q(this,`lastCopyId$`,this._lastCopyId$.asObservable())}set(e,t){this._cache.set(e,t),this._lastCopyId$.next(e)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e),this._lastCopyId$.getValue()===e&&this._lastCopyId$.next(null)}clear(){this._cache.clear(),this._lastCopyId$.next(null)}clearWithUnitId(e){this._cache.forEach((t,n)=>{t.unitId===e&&this._cache.delete(n)})}getLastCopyId(){return this._lastCopyId$.getValue()}};new Qmt;function HZ(e,t){let n=t??e.style,r={},i=e.tagName.toLowerCase();switch(i){case`b`:case`em`:case`strong`:r.bl=Np.TRUE;break;case`s`:r.st={s:Np.TRUE};break;case`u`:r.ul={s:Np.TRUE};break;case`i`:r.it=Np.TRUE;break;case`sub`:case`sup`:r.va=i===`sup`?Mp.SUPERSCRIPT:Mp.SUBSCRIPT}return $mt(n,r),r}function $mt(e,t){if(e instanceof CSSStyleDeclaration)for(let n=0;n<e.length;n++){let r=e[n];eht(r,e.getPropertyValue(r),t)}else for(let n in e){let r=e[n];eht(n,r,t)}}function eht(e,t,n){switch(e){case`font-family`:n.ff=t;break;case`font-size`:{let e=Number.parseInt(t);Number.isNaN(e)||(t.endsWith(`pt`)?n.fs=e:t.endsWith(`px`)&&(n.fs=e*.75));break}case`font-style`:t===`italic`&&(n.it=Np.TRUE);break;case`font-weight`:(Number(t)>400||t===`bold`)&&(n.bl=Np.TRUE);break;case`text-decoration`:/underline/.test(t)?n.ul={s:Np.TRUE}:/overline/.test(t)?n.ol={s:Np.TRUE}:/line-through/.test(t)&&(n.st={s:Np.TRUE});break;case`color`:try{let e=new rh(t);e.isValid&&(n.cl={rgb:e.toRgbString()})}catch{}break;case`background-color`:{let e=new rh(t);e.isValid&&(n.bg={rgb:e.toRgbString()});break}}}function tht(e){if(e.nodeType===Node.TEXT_NODE){e.textContent=(e.textContent||``).replace(/\r?\n[\t ]*/g,` `);return}e.childNodes.forEach(tht)}function nht(e){let t=document.implementation.createHTMLDocument(``),n=t.createRange();n.selectNodeContents(t.body);let r=n.createContextualFragment(e);return DJe(r,{strippedSelector:`script, iframe, object, embed`}),tht(r),t.body.append(r),t.body}function rht(e){let t=e.style,n={};for(let e=0;e<t.length;e++){let r=t[e],i=t.getPropertyValue(r);switch(r){case`margin-top`:{let e=Number.parseInt(i);n.spaceAbove={v:/pt/.test(i)?Nw(e):e};break}case`margin-bottom`:{let e=Number.parseInt(i);n.spaceBelow={v:/pt/.test(i)?Nw(e):e};break}case`line-height`:n.lineSpacing=Number.parseFloat(i)}}return Object.getOwnPropertyNames(n).length?n:null}function UZ(e,t){let n=[];for(let t=0,r=e.length;t<r;t++)e[t]===Uv.PARAGRAPH&&n.push({startIndex:t});if(t)for(let e of n)t.bullet&&(e.bullet=F.deepClone(t.bullet)),t.paragraphStyle&&(e.paragraphStyle=F.deepClone(t.paragraphStyle));return n}function iht(e,t,n){let r=t.length,i=(n?.length??0)===1&&n[0].st===0&&n[0].ed===r;if(e.p){var a;return i&&(a=e.p.body)!=null&&(a=a.textRuns)!=null&&a.length?(e.p.body.textRuns=[],{...e,s:n[0].ts}):e}return i?{...e,s:n[0].ts}:e}var aht=[`color`,`background`,`font-size`,`text-align`,`vertical-align`,`font-weight`,`font-style`,`font-family`,`text-decoration`,`white-space`,`word-wrap`,`border-left`,`border-right`,`border-top`,`border-bottom`,`--data-rotate`];function oht(e,t){let n=e.tagName.toLowerCase();return typeof t==`string`?n===t:Array.isArray(t)?t.some(e=>e===n):t(e)}var WZ=class e{static use(e){if(this._pluginList.includes(e))throw Error(`Univer paste plugin ${e.name} already added`);this._pluginList.push(e)}constructor(e){Q(this,`_styleMap`,new Map),Q(this,`_styleCache`,new Map),Q(this,`_styleRules`,[]),Q(this,`_afterProcessRules`,[]),Q(this,`_dom`,null),Q(this,`_msoNumfmtMap`,new Map),Q(this,`_getCurrentSkeleton`,void 0),this._getCurrentSkeleton=e.getCurrentSkeleton}convert(t){let n=e._pluginList.find(e=>e.checkPasteType(t));n&&(this._styleRules=[...n.stylesRules],this._afterProcessRules=[...n.afterProcessRules]);let r=new Rh;this._dom=nht(t);let i=this._dom.querySelector(`style`);if(i){this._parseMsoNumfmtFromCssText(i.textContent??``);let e=document.createElement(`div`),t=e.attachShadow({mode:`open`});document.body.appendChild(e),t.appendChild(i);for(let e of i.sheet.cssRules){let t=e,n=t.selectorText,r=t.style;this._styleMap.set(n,r)}i.remove(),e.remove()}let a={dataStream:``,textRuns:[]},o=[],s=[],c=t.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi);this.process(null,this._dom.childNodes,a,[]);let{paragraphs:l,dataStream:u,textRuns:d,payloads:f,customRanges:p}=a;if(l){let e=l.map(e=>e.startIndex+1);e.unshift(0);for(let t=0;t<e.length;t++){let n;if(t===e.length-1){if(n=`${u.substring(e[t])}\r\n`,n===`\r
|
|
596
596
|
`)continue}else n=`${u.substring(e[t],e[t+1]-1)}\r\n`;let i=[];d?.forEach(n=>{n.st>=e[t]&&n.ed<=e[t+1]&&i.push({st:n.st-e[t],ed:n.ed-e[t],ts:n.ts})});let a=[];p?.forEach(n=>{n.startIndex>=e[t]&&n.endIndex<=e[t+1]&&a.push({...n,startIndex:n.startIndex-e[t],endIndex:n.endIndex-e[t]})});let s=this._generateDocumentDataModelSnapshot({body:{dataStream:n,textRuns:i,paragraphs:UZ(n),customRanges:a}}),c=Object.keys(r.getMatrix()).length===0;r.setValue(c?0:r.getLength(),0,{v:n,p:s}),o.push({})}}else if(u){let e=`${u}\r\n`,t={dataStream:e,textRuns:d,paragraphs:UZ(e),payloads:f,customRanges:p};if(!p?.length)r.setValue(0,0,iht({v:u},u,d));else{let e=this._generateDocumentDataModelSnapshot({body:t});r.setValue(0,0,iht({v:u,p:e},u,d))}o.push({})}return c&&c.forEach((e,t)=>{let n=r.getDataRange().endRow+1,{cellMatrix:i,rowProperties:a,colProperties:c}=this._parseTable(e,t);i&&i.forValue((e,t,i)=>{r.setValue(n+e,t,i)}),c&&s.push(...c),o.push(...a)}),this.dispose(),{rowProperties:o,colProperties:s,cellMatrix:r}}_parseMsoNumfmtFromCssText(e){let t=/([^{]+)\{([^}]*)\}/g,n;for(;(n=t.exec(e))!==null;){let e=n[1].trim(),t=n[2].match(/mso-number-format\s*:\s*("(?:[^"\\]|\\.)*"|[^;]+)/i);if(!t)continue;let r=t[1].trim();r.startsWith(`"`)&&r.endsWith(`"`)&&(r=r.slice(1,-1));let i=mht(r);e.split(`,`).forEach(e=>{this._msoNumfmtMap.set(e.trim(),i)})}}_getMsoNumfmtForNode(e){for(let t of e.classList){let e=this._msoNumfmtMap.get(`.${t}`);if(e)return e}if(e.id){let t=this._msoNumfmtMap.get(`#${e.id}`);if(t)return t}return this._msoNumfmtMap.get(e.nodeName.toLowerCase())}_getStyleBySelectorText(e,t){return this._styleMap.get(e)?.getPropertyValue(t)||``}_getStyle(e,t){let n=cht(t),r=e.style,i=``;for(let t=0;t<aht.length;t++){let a=aht[t];if(a===`background`){let t=``;e.classList.forEach(e=>{t=this._getStyleBySelectorText(`.${e}`,`background-color`)||this._getStyleBySelectorText(`.${e}`,a)});let o=r.getPropertyValue(`background-color`)||t||this._getStyleBySelectorText(`#${e.id}`,`background-color`)||this._getStyleBySelectorText(`#${e.id}`,a)||this._getStyleBySelectorText(e.nodeName.toLowerCase(),a)||this._getStyleBySelectorText(e.nodeName,`background-color`)||n[`background-color`]||``;o&&(i+=`background:${o};`);continue}if(a===`text-decoration`){let t=``;e.classList.forEach(e=>{t=this._getStyleBySelectorText(`.${e}`,`text-decoration-line`)||this._getStyleBySelectorText(`.${e}`,a)});let o=r.getPropertyValue(`text-decoration-line`)||r.getPropertyValue(`text-decoration`)||t||this._getStyleBySelectorText(`#${e.id}`,`text-decoration-line`)||this._getStyleBySelectorText(`#${e.id}`,a)||this._getStyleBySelectorText(e.nodeName.toLowerCase(),a)||this._getStyleBySelectorText(e.nodeName,`text-decoration-line`)||n[`text-decoration-line`]||``;o&&(i+=`text-decoration:${o};`);continue}let o=``;e.classList.forEach(e=>{o=this._getStyleBySelectorText(`.${e}`,a)}),o=r.getPropertyValue(a)||this._getStyleBySelectorText(`#${e.id}`,a)||o||this._getStyleBySelectorText(e.nodeName.toLowerCase(),a)||n[a]||``,o&&(i+=`${a}:${o};`)}return i}_parseTable(e,t){let n=new Rh,r=uht(e)??[],{rowProperties:i=[]}=sht(e),a=this._parseTableByHtml(this._dom,t,this._getCurrentSkeleton()?.skeleton);return a&&a.forValue((e,t,r)=>{var i,a;let o=rYe(void 0,r.style);if(r!=null&&(i=r.richTextParma)!=null&&(i=i.p)!=null&&(i=i.body)!=null&&(i=i.textRuns)!=null&&i.length){var s,c,l;let e=r==null||(s=r.richTextParma)==null||(s=s.v)==null?void 0:s.length;for(let t=0;t<(r==null||(c=r.richTextParma)==null||(c=c.p)==null||(c=c.body)==null||(c=c.textRuns)==null?void 0:c.length);t++){var u;let n=r==null||(u=r.richTextParma)==null||(u=u.p)==null||(u=u.body)==null?void 0:u.textRuns[t];if(n.st===0&&n.ed===e){var d;o={...n.ts,...o},r==null||(d=r.richTextParma)==null||(d=d.p)==null||(d=d.body)==null||d.textRuns.splice(t,1),t--}}if((r==null||(l=r.richTextParma)==null||(l=l.p)==null||(l=l.body)==null||(l=l.textRuns)==null?void 0:l.length)===0){var f;r.content=r==null||(f=r.richTextParma)==null?void 0:f.v,delete r.richTextParma}}let p=r!=null&&(a=r.richTextParma)!=null&&(a=a.p)!=null&&(a=a.body)!=null&&a.textRuns?{v:r.richTextParma.v,p:r.richTextParma.p,s:o,rowSpan:r.rowSpan,colSpan:r.colSpan}:{v:r.content,s:o,rowSpan:r.rowSpan,colSpan:r.colSpan};r.numfmtPattern&&(p.s={...p.s,n:{pattern:r.numfmtPattern}},p.v=Number(p.v)),n.setValue(e,t,p)}),{rowProperties:i,colProperties:r,cellMatrix:n}}_parseTableByHtml(e,t,n){let r=new Rh,i=e.querySelectorAll(`table`)[t];if(!i)return r;let a=this._getStyle(i,``),o=i?.querySelectorAll(`tr`);for(let e=0;e<o.length;e++){let t=o[e],i=this._getStyle(t,a),l=t.querySelectorAll(`td, th`),u=0;for(let t=0;t<l.length;){let a=l[t],o=``,d=Number(a.getAttribute(`rowSpan`))||1,f=Number(a.getAttribute(`colSpan`))||1;if(o=this._getStyle(a,i),e>0){var s;let t=r.getValue(e-1,u);if(t!=null&&(s=t.style)!=null&&s.includes(`border-bottom`)&&o.includes(`border-top`)){let e=fht(t.style,`border-bottom`);e&&vN(e.substr(e.indexOf(`:`)+1))!==`none`&&(o=o.replace(/border-top:[^;]+;/,``))}}if(t>0){var c;let t=r.getValue(e,u-1);if(t!=null&&(c=t.style)!=null&&c.includes(`border-right`)&&o.includes(`border-left`)){let e=fht(t.style,`border-right`);e&&vN(e.substr(e.indexOf(`:`)+1))!==`none`&&(o=o.replace(/border-left:[^;]+;/,``))}}let p=``,m,h,g=this._getMsoNumfmtForNode(a);if(g){p=a.innerHTML,p.includes(`mso-spacerun:yes`)&&(p=hht(p));let e=kh(p);if(typeof e?.v==`number`&&(e.z===g||rd(g,e.v)===p))p=e.v.toString(),h=g;else if(e&&e.z)p=e.v.toString(),h=e.z;else if(!e){let e=ght(p);e!==null&&!Number.isNaN(e)&&rd(g,e)===p&&(p=e.toString(),h=g)}}if(!h){let e=this._getCellTextAndRichText(a,o,n);p=e.cellText,m=e.cellRichStyle}let _={rowSpan:d,colSpan:f,content:p,style:o,richTextParma:{p:m,v:p},numfmtPattern:h};if(r.getValue(e,u)){u+=1;continue}d>1||f>1?pht(r,o,_,{colSpan:f,rowSpan:d,rowIndex:e,colIndex:t,colSetValueIndex:u}):r.setValue(e,u,_),u+=f,t++}}return r}_parseCellHtml(e,t,n,r=new Map,i){for(let a of t)if(a.nodeType===Node.TEXT_NODE){let t=a.nodeValue?.replace(/[\r\n]/g,``),i;e&&r.has(e)&&(i=r.get(e)),n.dataStream+=t,i&&Object.getOwnPropertyNames(i).length&&n.textRuns.push({st:n.dataStream.length-t.length,ed:n.dataStream.length,ts:i})}else if(a.nodeType===Node.COMMENT_NODE||a.nodeName===`STYLE`)continue;else if(a.nodeName.toLowerCase()===`br`)n.paragraphs||=[],n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+=`\r`;else if(a.nodeType===Node.ELEMENT_NODE){let t=this._getStyle(a,i),o=e?r.get(e):{},s=HZ(a,cht(t));r.set(a,{...o,...s});let{childNodes:c}=a;this._parseCellHtml(a,c,n,r,t)}}_getCellTextAndRichText(e,t,n){if(e.innerHTML.includes(`mso-spacerun:yes`)){let t=hht(e.innerHTML),n=kh(t);if(n&&n.z&&typeof n.v==`number`)return{cellText:t,cellRichStyle:void 0}}let r=``,i;if(/<[^>]+>/.test(e.innerHTML)&&n){let a={dataStream:``,textRuns:[]};this._parseCellHtml(null,e.childNodes,a,void 0,t);let o=n.getBlankCellDocumentModel()?.documentModel,s=o?.getSnapshot(),c=`${a.dataStream}\r\n`,l={...s,body:{dataStream:c,textRuns:a.textRuns,paragraphs:UZ(c)}};o?.reset(l),i=o?.getSnapshot(),r=a.dataStream}else r=dht(e.innerHTML.replace(/[\r\n]/g,``));return{cellText:r,cellRichStyle:i}}_generateDocumentDataModelSnapshot(e){let t=this._getCurrentSkeleton();if(t==null)return null;let{skeleton:n}=t,r=n.getBlankCellDocumentModel()?.documentModel,i={...r?.getSnapshot(),...e};return r?.reset(i),r?.getSnapshot()}process(e,t,n,r){for(let a of t)if(a.nodeName.toLowerCase()===`table`){var i;r.push({index:(n==null||(i=n.paragraphs)==null?void 0:i.length)||0})}else if(a.nodeType===Node.TEXT_NODE){if(a.nodeValue?.trim()===``)continue;let t=a.nodeValue?.replace(/[\r\n]/g,``),r;e&&this._styleCache.has(e)&&(r=this._styleCache.get(e));let i={dataStream:``,textRuns:[]};n.dataStream+=t,i.dataStream+=t,r&&Object.getOwnPropertyNames(r).length&&(n.textRuns.push({st:n.dataStream.length-t.length,ed:n.dataStream.length,ts:r}),i.textRuns.push({st:n.dataStream.length-t.length,ed:n.dataStream.length,ts:r}))}else if(Ix.includes(a.nodeName.toLowerCase()))continue;else if(a.nodeName.toLowerCase()===`br`)n.paragraphs||=[],n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+=`\r`;else if(a.nodeType===Node.ELEMENT_NODE){if(a.nodeName===`STYLE`)continue;let t=a,i=this._processBeforeLink(t,{body:n}),o=e?this._styleCache.get(e):{},s=this._styleRules.find(({filter:e})=>oht(a,e)),c=s?s.getStyle(a):HZ(a);this._styleCache.set(a,{...o,...c});let{childNodes:l}=a;this.process(a,l,n,r);let u=this._afterProcessRules.find(({filter:e})=>oht(a,e));u&&u.handler(n,a),this._processAfterLink(t,{body:n},i)}}_processBeforeLink(e,t){return t.body.dataStream.length}_processAfterLink(e,t,n){let r=t.body,i=e;if(i.tagName.toUpperCase()===`A`){let e=i.href;if(!ep(e))return;r.customRanges=r.customRanges??[],r.customRanges.push({startIndex:n,endIndex:r.dataStream.length-1,rangeId:i.dataset.rangeid??ip(),rangeType:Rp.HYPERLINK,properties:{url:e}})}}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear(),this._msoNumfmtMap.clear()}};Q(WZ,`_pluginList`,[]);function sht(e){let t=e.matchAll(/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi);if(!t)return{rowProperties:[],rowCount:0};let n=Array.from(t).map(e=>lht(e[1])).map(e=>{if(!e.height){let t=e.style,n=t&&t.match(/height\s*:\s*(\d+(\.\d+)?)px/);e.height=`${n?Number.parseInt(n[1],10):24}`}return e});return{rowProperties:n,rowCount:n.length}}function cht(e){let t={};return e.split(`;`).forEach(e=>{let[n,r]=e.split(`:`);t[n]=r}),t}function lht(e){if(!e)return{};let t={},n=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g,r;for(;(r=n.exec(e))!==null;){let[,e,,n,i]=r;t[e]=n===void 0?i:n}return t}function uht(e){let t=e.match(/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/),n=/<col([\s\S]*?)>/g,r;if(r=t?.[2]?t[2].matchAll(n):e.matchAll(n),!r)return null;let i=Array.from(r).map(e=>lht(e[1])),a=[];return i.forEach(e=>{let t=Number(e.span);if(t)for(let n=0;n<t;n++){let t={...e};delete t.span,a.push(t)}else a.push(e)}),a}function dht(e){let t={"<":`<`,">":`>`,"&":`&`,""":`"`,"'":`'`," ":` `};return e.replace(/<|>|&|"|'| |<br>/g,e=>t[e])}function fht(e,t){if(!e||!t)return null;let n=RegExp(`(${t}\\s*:\\s*[^;]+);`,`i`),r=e.match(n);return r?r[1]:null}function pht(e,t,n,r){let{rowSpan:i,colSpan:a,rowIndex:o,colSetValueIndex:s}=r;for(let r=o;r<o+i;r++)for(let i=s;i<s+a;i++)r===o&&i===s?e.setValue(r,i,{...n,style:t}):e.setValue(r,i,{style:t})}function mht(e){let t=e.replace(/\\([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));return t=t.replace(/\\\\/g,`\0BACKSLASH\0`),t=t.replace(/\\([^\\])/g,`$1`),t=t.replace(/\x00BACKSLASH\x00/g,`\\`),t}function hht(e){return e.replace(/<span[^>]*mso-spacerun:yes[^>]*>/gi,``).replace(/<\/span>/gi,``).replace(/\u00A0| /gi,``)}function ght(e){let t=e.match(/\(?-?\d[\d,]*(\.\d+)?%?\)?/);if(!t)return null;let n=t[0],r=n.includes(`%`);n=n.replace(/[,%]/g,``),/^\(.*\)$/.test(n)&&(n=`-${n.slice(1,-1)}`);let i=Number(n);return r&&(i/=100),i}var _ht={name:`univer-sheet-paste-plugin-lark`,checkPasteType(e){return/lark-record-clipboard/i.test(e)},stylesRules:[{filter:[`s`],getStyle(e){let t=HZ(e);return{st:{s:Np.TRUE},...t}}}],afterProcessRules:[{filter(e){return e.tagName===`DIV`&&/ace-line/i.test(e.className)},handler(e){e.paragraphs??=[],e.paragraphs.push({startIndex:e.dataStream.length}),e.dataStream+=`\r`}}]},vht={name:`univer-sheet-paste-plugin-univer`,checkPasteType(e){return/UniverNormal/i.test(e)},stylesRules:[],afterProcessRules:[{filter(e){return e.tagName===`P`&&/UniverNormal/i.test(e.className)},handler(e,t){e.paragraphs??=[];let n={startIndex:e.dataStream.length},r=rht(t);r&&(n.paragraphStyle=r),e.paragraphs.push(n),e.dataStream+=`\r`}}]},yht={name:`univer-sheet-paste-plugin-word`,checkPasteType(e){return/word|mso/i.test(e)},stylesRules:[{filter:[`b`],getStyle(e){let t=HZ(e);return{bl:Np.TRUE,...t}}}],afterProcessRules:[{filter(e){return e.tagName===`P`&&/mso/i.test(e.className)},handler(e,t){e.paragraphs??=[];let n={startIndex:e.dataStream.length},r=rht(t);r&&(n.paragraphStyle=r),e.paragraphs.push(n),e.dataStream+=`\r`}}]},GZ=function(e){return e.COPY=`COPY`,e.CUT=`CUT`,e}({});function bht(e,t,n,r,i){return`<tr${qZ(KZ(n.map(t=>t.onCopyRow?.call(t,e)).filter(e=>!!e)))}>${t.map(t=>{if(!i.has(`${e}-${t}`)){let a=r.getValue(e,t);if(a?.rowSpan&&a?.colSpan)for(let n=e;n<e+a.rowSpan;n++)for(let e=t;e<t+a.colSpan;e++)i.add(`${n}-${e}`);return xht(e,t,n,r)}return null}).filter(e=>!!e).join(``)}</tr>`}function xht(e,t,n,r){let i=r.getValue(e,t);return`<td${qZ(KZ(n.map(n=>n.onCopyCellStyle?.call(n,e,t,i?.rowSpan,i?.colSpan)).filter(e=>!!e)))}>${n.reduce((n,r)=>n||r.onCopyCellContent?.call(r,e,t)||``,``)}</td>`}function Sht(e,t){return`<colgroup>${e.map(e=>`<col ${qZ(KZ(t.map(t=>t.onCopyColumn?.call(t,e)).filter(e=>!!e)))} />`).join(``)}</colgroup>`}function KZ(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]?e[n]+=`;${t[n]}`:e[n]=t[n]}),e),{})}function qZ(e){return Object.keys(e).reduce((t,n)=>`${t} ${n}="${e[n]}"`,``)}var Cht=class{convert(e,t,n,r){let{cols:i,rows:a}=t;if(!i.length)return``;let o=Sht(i,n),s=[],c=new Set;return a.forEach(t=>{s.push(bht(t,i,n,e,c))}),`<google-sheets-html-origin><table data-copy-id="${r}" xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${o}
|
|
597
597
|
<tbody>${s.join(``)}</tbody></table>`}},wht=(e,t,n=!1)=>{let r=e=>e.endRow-e.startRow+1,i=e=>e.endColumn-e.startColumn+1,a=r(t)%r(e),o=i(t)%i(e),s={startRow:0,endRow:r(e)-1,startColumn:0,endColumn:i(e)-1},c=Math.floor(r(t)/r(e)),l=Math.floor(i(t)/i(e)),u=[];if(!a&&!o)for(let n=1;n<=c;n++)for(let a=1;a<=l;a++){let o=r(e)*(n-1),c=i(e)*(a-1),l={startRow:o+t.startRow,endRow:o+t.startRow,startColumn:c+t.startColumn,endColumn:c+t.startColumn};u.push({repeatRelativeRange:s,startRange:l})}else if(!a&&o&&!n)for(let n=1;n<=c;n++){let i=r(e)*(n-1),a={startRow:i+t.startRow,endRow:i+t.startRow,startColumn:0+t.startColumn,endColumn:0+t.startColumn};u.push({repeatRelativeRange:s,startRange:a})}else if(a&&!o&&!n)for(let n=1;n<=l;n++){let r=i(e)*(n-1),a={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:r+t.startColumn,endColumn:r+t.startColumn};u.push({repeatRelativeRange:s,startRange:a})}else{let e={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};u.push({startRange:e,repeatRelativeRange:s})}return u};function Tht(e){return e?[/<td[^>]*class=".*?xl.*?"[^>]*>/i,/xmlns:x="urn:schemas-microsoft-com:office:excel"/i,/ProgId="Excel.Sheet"/i,/xmlns:o="urn:schemas-microsoft-com:office:office"/i,/@mso-|mso-excel/i,/<x:ExcelWorkbook>/i].some(t=>t.test(e)):!1}function Eht(e){return e?(e.match(/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i)||[]).length>0:!1}function Dht(...e){if(e.length===1)return e[0];let t=new Rh;return e.forEach(e=>{e&&new Rh(e).forValue((e,n,r)=>{t.setValue(e,n,{...t.getValue(e,n),...r})})}),t.getMatrix()}function Oht(e,t){return e.id===t.id&&e.params.unitId===t.params.unitId&&e.params.subUnitId===t.params.subUnitId}function kht(e){let t=[];for(let n=0;n<e.length;){let r=1;if(e[n].id===lK.id){let i=e[n],a=[i];for(;n+r<e.length&&Oht(i,e[n+r]);)a.push(e[n+r]),r+=1;let o=Dht(...a.map(e=>e.params.cellValue||{}));t.push({...i,params:{...i.params,cellValue:o}})}else t.push(e[n]);n+=r}return t}function Aht(e,t={}){let{maxCellsPerChunk:n=2500,threshold:r=6e3,maxChunks:i=10}=t;if(e.id!==lK.id)return[e];let{cellValue:a}=e.params;if(!a)return[e];let o=new Rh(a),s=0,c=1/0,l=-1/0,u=1/0,d=-1/0;if(o.forValue((e,t)=>{s++,c=Math.min(c,e),l=Math.max(l,e),u=Math.min(u,t),d=Math.max(d,t)}),c===1/0||s<=r)return[e];let f=[],p=d-u+1,m=Math.max(1,Math.floor(n/p)),h=l-c+1;Math.ceil(h/m)>i&&(m=Math.ceil(h/i));for(let t=c;t<=l;t+=m){let n=Math.min(t+m-1,l),r=new Rh,i=!1;for(let e=t;e<=n;e++)for(let t=u;t<=d;t++){let n=o.getValue(e,t);n!==void 0&&(r.setValue(e,t,n),i=!0)}i&&f.push({...e,params:{...e.params,cellValue:r.getMatrix(),__splitChunk__:!0}})}return f.length>0?f:[e]}function JZ(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e;for(let e=n;e<=r;e++)for(let n=i;n<=a;n++)if(t.rows.includes(e)&&t.cols.includes(n))return!0}function jht(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=t;for(let t=n;t<=r;t++)if(!e.rows.includes(t))return!1;for(let t=i;t<=a;t++)if(!e.cols.includes(t))return!1;return!0}function Mht(e){let t=e.trim().split(`
|