@univerjs/drawing 0.1.17 → 0.2.1
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +79 -77
- package/lib/types/index.d.ts +1 -1
- package/lib/types/models/image-model-interface.d.ts +1 -2
- package/lib/types/services/drawing-manager-impl.service.d.ts +1 -0
- package/lib/types/services/drawing-manager.service.d.ts +1 -0
- package/lib/types/services/interface.d.ts +1 -5
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var $t=Object.defineProperty;var Wt=(n,e,t)=>e in n?$t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var F=(n,e,t)=>Wt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("rxjs"),Qe=require("@univerjs/core"),nt=require("@wendellhu/redi"),Gt=500,Bt=500,xt=10,Ct=5*1024*1024,Et=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V={},At={},dt={};Object.defineProperty(dt,"__esModule",{value:!0});function Lt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!ft(n[t],e[t]))return!1;for(let t in e)if(n[t]===void 0)return!1;return!0}function Ht(n,e){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!ft(n[t],e[t]))return!1;return!0}function ft(n,e){return n===e?!0:n===null||e===null||typeof n!="object"||typeof e!="object"?!1:Array.isArray(n)?Ht(n,e):Lt(n,e)}dt.default=ft;var ht={};Object.defineProperty(ht,"__esModule",{value:!0});function ct(n){if(n===null)return null;if(Array.isArray(n))return n.map(ct);if(typeof n=="object"){const e={};for(let t in n)e[t]=ct(n[t]);return e}else return n}ht.default=ct;var pt={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.eachChildOf=n.advancer=n.readCursor=n.writeCursor=n.WriteCursor=n.ReadCursor=n.isValidPathItem=void 0;function e(O,o){if(!O)throw new Error(o)}const t=O=>O!=null&&typeof O=="object"&&!Array.isArray(O),s=(O,o)=>typeof O==typeof o?O>o:typeof O=="string"&&typeof o=="number";function i(O,o){for(let c in O){const h=c;o.write(h,O[h])}}n.isValidPathItem=O=>typeof O=="number"||typeof O=="string"&&O!=="__proto__";class d{constructor(o=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=o}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,t(this.container[this.idx])&&this.idx--)}getPath(){const o=[];let c=this.container,h=this.parents.length-1,j=this.idx;for(;j>=0;)o.unshift(c[j]),j===0?(j=this.indexes[h*2],c=this.parents[h--]):j-=t(c[j-1])?2:1;return o}}class l extends d{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let o;return this.container&&this.container.length>this.idx+1&&t(o=this.container[this.idx+1])?o:null}descendFirst(){let o=this.idx+1;if(!this.container||o>=this.container.length||t(this.container[o])&&o+1>=this.container.length)return!1;t(this.container[o])&&o++;const c=this.container[o];return Array.isArray(c)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(o),this.idx=0,this.container=c):this.idx=o,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const o=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return o>=c.length?!1:(e(!isNaN(o)),this.indexes[this.indexes.length-1]=o,this.container=c[o],!0)}_init(o,c,h,j){this.container=o,this.idx=c,this.parents=h.slice(),this.indexes=j.slice()}clone(){const o=new l;return o._init(this.container,this.idx,this.parents,this.indexes),o}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(o,c){const h=this.getComponent();h&&c(h,o);for(const j of this)o&&o.descend(j),this.traverse(o,c),o&&o.ascend()}eachPick(o,c){this.traverse(o,(h,j)=>{h.p!=null&&c(h.p,j)})}eachDrop(o,c){this.traverse(o,(h,j)=>{h.d!=null&&c(h.d,j)})}}n.ReadCursor=l;class a extends d{constructor(o=null){super(o),this.pendingDescent=[],this._op=o}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let o=0;o<this.pendingDescent.length;o++){const c=this.pendingDescent[o];let h=this.idx+1;if(h<this.container.length&&t(this.container[h])&&h++,e(h===this.container.length||!t(this.container[h])),h===this.container.length)this.container.push(c),this.idx=h;else if(this.container[h]===c)this.idx=h;else{if(!Array.isArray(this.container[h])){const j=this.container.splice(h,this.container.length-h);this.container.push(j),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(s(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&s(c,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===c)this.container=this.container[h];else{const j=[c];this.container.splice(h,0,j),this.container=j}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const o=this.idx+1;if(o<this.container.length&&t(this.container[o]))return this.container[o];{const c={};return this.container.splice(o,0,c),c}}write(o,c){const h=this.getComponent();e(h[o]==null||h[o]===c,"Internal consistency error: Overwritten component. File a bug"),h[o]=c}get(){return this._op}descend(o){if(!n.isValidPathItem(o))throw Error("Invalid JSON key");this.pendingDescent.push(o)}descendPath(o){return this.pendingDescent.push(...o),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(o,c=i){if(o===null)return;if(e(Array.isArray(o)),o===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,j=this.parents.length;let Y=0;for(let pe=0;pe<o.length;pe++){const J=o[pe];typeof J=="string"||typeof J=="number"?(Y++,this.descend(J)):Array.isArray(J)?this.mergeTree(J,c):typeof J=="object"&&c(J,this)}for(;Y--;)this.ascend();this.lcIdx=this.parents.length===j?h:-1}at(o,c){this.descendPath(o),c(this);for(let h=0;h<o.length;h++)this.ascend();return this}writeAtPath(o,c,h){return this.at(o,()=>this.write(c,h)),this.reset(),this}writeMove(o,c,h=0){return this.writeAtPath(o,"p",h).writeAtPath(c,"d",h)}getPath(){const o=super.getPath();return o.push(...this.pendingDescent),o}}n.WriteCursor=a,n.writeCursor=()=>new a,n.readCursor=O=>new l(O);function E(O,o,c){let h,j;j=h=O?O.descendFirst():!1;function Y(pe){let J;for(;j;){const Ie=J=O.getKey();if(pe!=null){let xe=!1;if(o&&typeof Ie=="number"&&(J=o(Ie,O.getComponent()),J<0&&(J=~J,xe=!0)),s(J,pe))return null;if(J===pe&&!xe)return O}c&&typeof J=="number"&&c(J,O.getComponent()),j=O.nextSibling()}return null}return Y.end=()=>{h&&O.ascend()},Y}n.advancer=E;function W(O,o,c){let h,j,Y,pe;for(h=j=O&&O.descendFirst(),Y=pe=o&&o.descendFirst();h||Y;){let J=h?O.getKey():null,Ie=Y?o.getKey():null;J!==null&&Ie!==null&&(s(Ie,J)?Ie=null:J!==Ie&&(J=null)),c(J==null?Ie:J,J!=null?O:null,Ie!=null?o:null),J!=null&&h&&(h=O.nextSibling()),Ie!=null&&Y&&(Y=o.nextSibling())}j&&O.ascend(),pe&&o.ascend()}n.eachChildOf=W})(pt);var gt={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(n.ConflictType||(n.ConflictType={}))})(gt);var ot={},Ve={},bt;function _t(){return bt||(bt=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.uniToStrPos=Ve.strPosToUni=void 0,Ve.strPosToUni=(n,e=n.length)=>{let t=0,s=0;for(;s<e;s++){const i=n.charCodeAt(s);i>=55296&&i<=57343&&(t++,s++)}if(s!==e)throw Error("Invalid offset - splits unicode bytes");return s-t},Ve.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const s=n.charCodeAt(t);t+=s>=55296&&s<=57343?2:1}return t}),Ve}var lt={},mt;function ut(){return mt||(mt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=_t(),t=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let _=null;for(let w=0;w<f.length;w++){const L=f[w];switch(typeof L){case"object":if(typeof L.d!="number"&&typeof L.d!="string")throw Error("Delete must be number or string");if(n.dlen(L.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(L.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(L>0))throw Error("Skip components must be >0");if(typeof _=="number")throw Error("Adjacent skip components should be combined");break}_=L}if(typeof _=="number")throw Error("Op has a trailing skip")};function s(f,_){let w=0,L=0;for(let z=0;z<f.length;z++){const H=f[z];switch(_(H,w,L),typeof H){case"object":w+=n.dlen(H.d);break;case"string":L+=e.strPosToUni(H);break;case"number":w+=H,L+=H;break}}}n.eachOp=s;function i(f,_){const w=[],L=a(w);return s(f,(z,H,Ae)=>{L(_(z,H,Ae))}),o(w)}const d=f=>f,l=f=>i(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const a=f=>_=>{if(!(!_||_.d===0||_.d===""))if(f.length===0)f.push(_);else if(typeof _==typeof f[f.length-1])if(typeof _=="object"){const w=f[f.length-1];w.d=typeof w.d=="string"&&typeof _.d=="string"?w.d+_.d:n.dlen(w.d)+n.dlen(_.d)}else f[f.length-1]+=_;else f.push(_)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);n.uniSlice=(f,_,w)=>{const L=e.uniToStrPos(f,_),z=w==null?1/0:e.uniToStrPos(f,w);return f.slice(L,z)};const W=(f,_,w)=>typeof f=="number"?w==null?f-_:Math.min(f,w)-_:n.uniSlice(f,_,w),O=f=>{let _=0,w=0;return{take:(H,Ae)=>{if(_===f.length)return H===-1?null:H;const ue=f[_];let ne;if(typeof ue=="number")return H===-1||ue-w<=H?(ne=ue-w,++_,w=0,ne):(w+=H,H);if(typeof ue=="string"){if(H===-1||Ae==="i"||e.strPosToUni(ue.slice(w))<=H)return ne=ue.slice(w),++_,w=0,ne;{const ae=w+e.uniToStrPos(ue.slice(w),H);return ne=ue.slice(w,ae),w=ae,ne}}else{if(H===-1||Ae==="d"||n.dlen(ue.d)-w<=H)return ne={d:W(ue.d,w)},++_,w=0,ne;{let ae=W(ue.d,w,w+H);return w+=H,{d:ae}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,_,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");t(f),t(_);const L=[],z=a(L),{take:H,peek:Ae}=O(f);for(let ne=0;ne<_.length;ne++){const ae=_[ne];let ge,De;switch(typeof ae){case"number":for(ge=ae;ge>0;)De=H(ge,"i"),z(De),typeof De!="string"&&(ge-=E(De));break;case"string":w==="left"&&typeof Ae()=="string"&&z(H(-1)),z(e.strPosToUni(ae));break;case"object":for(ge=n.dlen(ae.d);ge>0;)switch(De=H(ge,"i"),typeof De){case"number":ge-=De;break;case"string":z(De);break;case"object":ge-=n.dlen(De.d)}break}}let ue;for(;ue=H(-1);)z(ue);return o(L)}function h(f,_){t(f),t(_);const w=[],L=a(w),{take:z}=O(f);for(let Ae=0;Ae<_.length;Ae++){const ue=_[Ae];let ne,ae;switch(typeof ue){case"number":for(ne=ue;ne>0;)ae=z(ne,"d"),L(ae),typeof ae!="object"&&(ne-=E(ae));break;case"string":L(ue);break;case"object":ne=n.dlen(ue.d);let ge=0;for(;ge<ne;)switch(ae=z(ne-ge,"d"),typeof ae){case"number":L({d:W(ue.d,ge,ge+ae)}),ge+=ae;break;case"string":ge+=e.strPosToUni(ae);break;case"object":L(ae)}break}}let H;for(;H=z(-1);)L(H);return o(w)}const j=(f,_)=>{let w=0;for(let L=0;L<_.length&&f>w;L++){const z=_[L];switch(typeof z){case"number":{w+=z;break}case"string":const H=e.strPosToUni(z);w+=H,f+=H;break;case"object":f-=Math.min(n.dlen(z.d),f-w);break}}return f},Y=(f,_)=>typeof f=="number"?j(f,_):f.map(w=>j(w,_));function pe(f,_,w){return i(f,(L,z)=>typeof L=="object"&&typeof L.d=="number"?{d:w.slice(_,z,z+L.d)}:L)}function J(f){return i(f,_=>{switch(typeof _){case"object":if(typeof _.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return _.d;case"string":return{d:_};case"number":return _}})}function Ie(f){return i(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function xe(f){let _=!0;return s(f,w=>{typeof w=="object"&&typeof w.d=="number"&&(_=!1)}),_}function ve(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:l,checkOp:t,create(_=""){if(typeof _!="string")throw Error("Initial data must be a string");return f.create(_)},apply(_,w){t(w);const L=f.builder(_);for(let z=0;z<w.length;z++){const H=w[z];switch(typeof H){case"number":L.skip(H);break;case"string":L.append(H);break;case"object":L.del(n.dlen(H.d));break}}return L.build()},transform:c,compose:h,transformPosition:j,transformSelection:Y,isInvertible:xe,makeInvertible(_,w){return pe(_,w,f)},stripInvertible:Ie,invert:J,invertWithDoc(_,w){return J(pe(_,w,f))},isNoop:_=>_.length===0}}n.default=ve}(lt)),lt}var tt={},wt;function Kt(){if(wt)return tt;wt=1,Object.defineProperty(tt,"__esModule",{value:!0});const n=ut(),e=_t();function t(s,i){return{get:s,getLength(){return s().length},insert(d,l,a){const E=e.strPosToUni(s(),d);return i([E,l],a)},remove(d,l,a){const E=e.strPosToUni(s(),d);return i([E,{d:l}],a)},_onOp(d){n.eachOp(d,(l,a,E)=>{switch(typeof l){case"string":this.onInsert&&this.onInsert(E,l);break;case"object":const W=n.dlen(l.d);this.onRemove&&this.onRemove(E,W)}})},onInsert:null,onRemove:null}}return tt.default=t,t.provides={text:!0},tt}var It;function Ft(){return It||(It=1,function(n){var e=Ce&&Ce.__createBinding||(Object.create?function(c,h,j,Y){Y===void 0&&(Y=j),Object.defineProperty(c,Y,{enumerable:!0,get:function(){return h[j]}})}:function(c,h,j,Y){Y===void 0&&(Y=j),c[Y]=h[j]}),t=Ce&&Ce.__setModuleDefault||(Object.create?function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}:function(c,h){c.default=h}),s=Ce&&Ce.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var j in c)Object.hasOwnProperty.call(c,j)&&e(h,c,j);return t(h,c),h},i=Ce&&Ce.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(n,"__esModule",{value:!0}),n.type=n.remove=n.insert=void 0;const d=_t(),l=s(ut()),a=i(Kt()),E={create(c){return c},toString(c){return c},builder(c){if(typeof c!="string")throw Error("Invalid document snapshot: "+c);const h=[];return{skip(j){let Y=d.uniToStrPos(c,j);if(Y>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,Y)),c=c.slice(Y)},append(j){h.push(j)},del(j){c=c.slice(d.uniToStrPos(c,j))},build(){return h.join("")+c}}},slice:l.uniSlice},W=l.default(E),O=Object.assign(Object.assign({},W),{api:a.default});n.type=O,n.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],n.remove=(c,h)=>l.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var o=ut();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ot)),ot}(function(n){var e=Ce&&Ce.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(n,"__esModule",{value:!0}),n.editOp=n.replaceOp=n.insertOp=n.moveOp=n.removeOp=n.type=void 0;const t=e(dt),s=e(ht),i=pt,d=gt;function l(r,u){if(!r)throw new Error(u)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:i.readCursor,writeCursor:i.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:J,checkValidOp:z,normalize:H,apply:Ae,transformPosition:ue,compose:ne,tryTransform:it,transform:Tt,makeInvertible:De,invert:ae,invertWithDoc:Rt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,u,y)=>vt(()=>!0,r,u,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(u,y,A)=>vt(r,u,y,A)})};const a=r=>r?r.getComponent():null;function E(r){return r&&typeof r=="object"&&!Array.isArray(r)}const W=r=>Array.isArray(r)?r.slice():r!==null&&typeof r=="object"?Object.assign({},r):r,O=r=>r&&(r.p!=null||r.r!==void 0),o=r=>r&&(r.d!=null||r.i!==void 0);function c(r,u){return l(r!=null),typeof u=="number"?(l(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(u,1)):(l(E(r),"Invalid key - child is not an object"),delete(r=Object.assign({},r))[u]),r}function h(r,u,y){return typeof u=="number"?(l(r!=null,"Container is missing for key"),l(Array.isArray(r),"Cannot use numerical key for object container"),l(r.length>=u,"Cannot insert into out of bounds index"),r.splice(u,0,y)):(l(E(r),"Cannot insert into missing item"),l(r[u]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),r[u]=y),y}n.removeOp=(r,u=!0)=>i.writeCursor().writeAtPath(r,"r",u).get(),n.moveOp=(r,u)=>i.writeCursor().writeMove(r,u).get(),n.insertOp=(r,u)=>i.writeCursor().writeAtPath(r,"i",u).get(),n.replaceOp=(r,u,y)=>i.writeCursor().at(r,A=>{A.write("r",u),A.write("i",y)}).get(),n.editOp=(r,u,y,A=!1)=>i.writeCursor().at(r,b=>_(b,u,y,A)).get();const j=(r,u)=>r!=null&&(typeof u=="number"?Array.isArray(r):typeof r=="object"),Y=(r,u)=>j(r,u)?r[u]:void 0,pe={};function J(r){let u=r.type?r.type:r;u.name&&(pe[u.name]=u),u.uri&&(pe[u.uri]=u)}const Ie=r=>{const u=pe[r];if(u)return u;throw Error("Missing type: "+r)};J(Ft());const xe=(r,u)=>r+u;J({name:"number",apply:xe,compose:xe,invert:r=>-r,transform:r=>r});const ve=r=>r==null?null:r.et?Ie(r.et):r.es?pe["text-unicode"]:r.ena!=null?pe.number:null,f=r=>r.es?r.es:r.ena!=null?r.ena:r.e,_=(r,u,y,A=!1)=>{const[b,C]=typeof u=="string"?[Ie(u),u]:[u,u.name];!A&&b.isNoop&&b.isNoop(y)||(C==="number"?r.write("ena",y):C==="text-unicode"?r.write("es",y):(r.write("et",C),r.write("e",y)))};function w(r){l(typeof r=="number"),l(r>=0),l(r===(0|r))}function L(r){typeof r=="number"?w(r):l(typeof r=="string")}function z(r){if(r===null)return;const u=new Set,y=new Set,A=C=>{let $=!0,T=!1;for(let p in C){const v=C[p];if($=!1,l(p==="p"||p==="r"||p==="d"||p==="i"||p==="e"||p==="es"||p==="ena"||p==="et","Invalid component item '"+p+"'"),p==="p")w(v),l(!u.has(v)),u.add(v),l(C.r===void 0);else if(p==="d")w(v),l(!y.has(v)),y.add(v),l(C.i===void 0);else if(p==="e"||p==="es"||p==="ena"){l(!T),T=!0;const m=ve(C);l(m,"Missing type in edit"),m.checkValidOp&&m.checkValidOp(f(C))}}l(!$)},b=(C,$,T)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");$||L(C[0]);let p=1,v=0,m=0;for(let I=0;I<C.length;I++){const k=C[I];if(l(k!=null),Array.isArray(k)){const G=b(k,!1);if(v){const g=typeof m,M=typeof G;g===M?l(m<G,"descent keys are not in order"):l(g==="number"&&M==="string")}m=G,v++,p=3}else typeof k=="object"?(l(p===1,`Prev not scalar - instead ${p}`),A(k),p=2):(l(p!==3),L(k),l(i.isValidPathItem(k),"Invalid path key"),p=1)}return l(v!==1,"Operation makes multiple descents. Remove some []"),l(p===2||p===3),C[0]};b(r,!0),l(u.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<u.size;C++)l(u.has(C)),l(y.has(C))}function H(r){let u=0,y=[];const A=i.writeCursor();return A.mergeTree(r,(b,C)=>{const $=ve(b);if($){const p=f(b);_(C,$,$.normalize?$.normalize(p):p)}for(const p of["r","p","i","d"])if(b[p]!==void 0){const v=p==="p"||p==="d"?(T=b[p],y[T]==null&&(y[T]=u++),y[T]):b[p];C.write(p,v)}var T}),A.get()}function Ae(r,u){if(z(u),u===null)return r;const y=[];return function A(b,C){let $=b,T=0,p={root:b},v=0,m=p,I="root";function k(){for(;v<T;v++){let G=C[v];typeof G!="object"&&(l(j(m,I)),m=m[I]=W(m[I]),I=G)}}for(;T<C.length;T++){const G=C[T];if(Array.isArray(G)){const g=A($,G);g!==$&&g!==void 0&&(k(),$=m[I]=g)}else if(typeof G=="object"){G.d!=null?(k(),$=h(m,I,y[G.d])):G.i!==void 0&&(k(),$=h(m,I,G.i));const g=ve(G);if(g)k(),$=m[I]=g.apply($,f(G));else if(G.e!==void 0)throw Error("Subtype "+G.et+" undefined")}else $=Y($,G)}return p.root}(r=function A(b,C){const $=[];let T=0;for(;T<C.length;T++){const I=C[T];if(Array.isArray(I))break;typeof I!="object"&&($.push(b),b=Y(b,I))}for(let I=C.length-1;I>=T;I--)b=A(b,C[I]);for(--T;T>=0;T--){const I=C[T];if(typeof I!="object"){const k=$.pop();b=b===Y(k,I)?k:b===void 0?c(k,I):(v=I,m=b,(p=W(p=k))[v]=m,p)}else O(I)&&(l(b!==void 0,"Cannot pick up or remove undefined"),I.p!=null&&(y[I.p]=b),b=void 0)}var p,v,m;return b}(r,u),u)}function ue(r,u){r=r.slice(),z(u);const y=i.readCursor(u);let A,b,C=!1;const $=[];for(let p=0;;p++){const v=r[p],m=y.getComponent();if(m&&(m.r!==void 0?C=!0:m.p!=null&&(C=!1,A=m.p,b=p)),p>=r.length)break;let I=0;const k=i.advancer(y,void 0,(g,M)=>{O(M)&&I++});$.unshift(k);const G=k(v);if(typeof v=="number"&&(r[p]-=I),!G)break}if($.forEach(p=>p.end()),C)return null;const T=()=>{let p=0;if(A!=null){const v=y.getPath();p=v.length,r=v.concat(r.slice(b))}for(;p<r.length;p++){const v=r[p],m=a(y),I=ve(m);if(I){const g=f(m);I.transformPosition&&(r[p]=I.transformPosition(r[p],g));break}let k=0;const G=i.advancer(y,(g,M)=>o(M)?~(g-k):g-k,(g,M)=>{o(M)&&k++})(v);if(typeof v=="number"&&(r[p]+=k),!G)break}};return A!=null?y.eachDrop(null,p=>{p===A&&T()}):T(),r}function ne(r,u){if(z(r),z(u),r==null)return u;if(u==null)return r;let y=0;const A=i.readCursor(r),b=i.readCursor(u),C=i.writeCursor(),$=[],T=[],p=[],v=[],m=[],I=[],k=new Set;A.traverse(null,g=>{g.p!=null&&(p[g.p]=A.clone())}),b.traverse(null,g=>{g.d!=null&&(v[g.d]=b.clone())});const G=i.writeCursor();return function g(M,re,te,K,se,ke,be,_e){l(re||te);const oe=a(re),Pe=a(te),Ue=!!Pe&&Pe.r!==void 0,Le=!!oe&&oe.i!==void 0,Se=oe?oe.d:null,Ee=Pe?Pe.p:null,$e=(ke||Ue)&&Ee==null;if(Ee!=null)K=v[Ee],be=T[Ee]=new i.WriteCursor;else if(Pe&&Pe.r!==void 0)K=null;else{const P=a(K);P&&P.d!=null&&(K=null)}const Q=a(K);if(Se!=null)if(M=p[Se],_e=$[Se]=new i.WriteCursor,$e)ke&&!Ue&&_e.write("r",!0);else{const P=m[Se]=y++;be.write("d",P)}else if(oe&&oe.i!==void 0)M=null;else{const P=a(M);P&&P.p!=null&&(M=null)}let S;Le?(l(se===void 0),S=oe.i):S=se;const B=(Ee==null?!Le||ke||Ue:S===void 0)?null:be.getComponent();if(Ee!=null){if(!(se!==void 0||Le)){const P=Se!=null?m[Se]:y++;I[Ee]=P,_e.write("p",P)}}else Ue&&(Le||se!==void 0||(Pe.r,_e.write("r",Pe.r)));const U=$e?null:ve(oe),D=ve(Q);if((U||D)&&(U&&U.name,D&&D.name),U&&D){l(U===D);const P=f(oe),x=f(Q),he=U.compose(P,x);_(be,U,he),k.add(Q)}else U?_(be,U,f(oe)):D&&(_(be,D,f(Q)),k.add(Q));const N=typeof S=="object"&&S!=null;let X=!1,Z=0,ee=0,fe=0,de=0,le=0;const ye=i.advancer(K,(P,x)=>o(x)?de-P-1:P-de,(P,x)=>{o(x)&&de++}),q=i.advancer(M,(P,x)=>O(x)?Z-P-1:P-Z,(P,x)=>{O(x)&&Z++});if(i.eachChildOf(re,te,(P,x,he)=>{let me,We,He=P,Me=P,Ye=P;if(typeof P=="number"){let Oe=P+fe;We=ye(Oe),Me=Oe+de;let ce=P+ee;me=q(ce),o(a(We))&&(me=null),He=ce+Z,Ye=P+le,l(He>=0,"p1PickKey is negative"),l(Me>=0,"p2DropKey is negative");const Ne=o(a(x)),Ge=O(a(he));(Ne||Ge&&!$e)&&le--,Ne&&ee--,Ge&&fe--}else me=q(P),We=ye(P);_e.descend(He),be.descend(Me);const ze=N&&!o(a(x))?S[Ye]:void 0,Re=g(me,x,he,We,ze,$e,be,_e);var Te,R,ie;N&&!$e?ze!==Re&&(X||(S=Array.isArray(S)?S.slice():Object.assign({},S),X=!0),Te=S,ie=Re,typeof(R=Ye)=="number"?(l(Array.isArray(Te)),l(R<Te.length)):(l(!Array.isArray(Te)),l(Te[R]!==void 0)),ie===void 0?typeof R=="number"?Te.splice(R,1):delete Te[R]:Te[R]=ie):l(Re===void 0),be.ascend(),_e.ascend()}),q.end(),ye.end(),B!=null)B.i=S;else if(!ke&&!Ue&&Ee==null)return S}(A,A.clone(),b,b.clone(),void 0,!1,C,G),C.reset(),C.mergeTree(G.get()),C.reset(),C.get(),$.map(g=>g.get()),T.map(g=>g.get()),A.traverse(C,(g,M)=>{const re=g.p;if(re!=null){const te=m[re];te!=null&&M.write("p",te);const K=$[re];K&&K.get(),K&&M.mergeTree(K.get())}else g.r!==void 0&&M.write("r",g.r)}),C.reset(),C.get(),b.traverse(C,(g,M)=>{const re=g.d;if(re!=null){const K=I[re];K!=null&&M.write("d",K);const se=T[re];se&&M.mergeTree(se.get())}else g.i!==void 0&&M.write("i",g.i);const te=ve(g);te&&!k.has(g)&&_(M,te,f(g))}),C.get()}function ae(r){if(r==null)return null;const u=new i.ReadCursor(r),y=new i.WriteCursor;let A;const b=[],C=[];return function $(T,p,v){const m=T.getComponent();let I,k=!1;if(m){m.p!=null&&(p.write("d",m.p),b[m.p]=T.clone()),m.r!==void 0&&p.write("i",m.r),m.d!=null&&(p.write("p",m.d),v=void 0),m.i!==void 0&&(v=I=m.i);const g=ve(m);g&&(v===void 0?(A||(A=new Set),A.add(m)):(f(m),v=g.apply(v,f(m)),k=!0))}let G=0;for(const g of T){p.descend(g);const M=typeof g=="number"?g-G:g,re=Y(v,M);o(T.getComponent())&&G++;const te=$(T,p,re);if(v!==void 0&&te!==void 0){if(k||(k=!0,v=W(v)),!j(v,M))throw Error("Cannot modify child - invalid operation");v[M]=te}p.ascend()}if(I===void 0)return k?v:void 0;p.write("r",v)}(u,y,void 0),A&&(y.reset(),function $(T,p,v){const m=p.getComponent();if(m){const g=m.d;if(g!=null&&(T=b[g],v=C[g]=i.writeCursor()),A.has(m)){const M=ve(m);if(!M.invert)throw Error(`Cannot invert subtype ${M.name}`);_(v,M,M.invert(f(m)))}}let I=0,k=0;const G=i.advancer(T,(g,M)=>O(M)?I-g-1:g-I,(g,M)=>{O(M)&&I++});for(const g of p)if(typeof g=="number"){const M=g-k,re=G(M),te=M+I;v.descend(te),$(re,p,v),o(p.getComponent())&&k++,v.ascend()}else v.descend(g),$(G(g),p,v),v.ascend();G.end()}(u.clone(),u,y),C.length&&(y.reset(),u.traverse(y,($,T)=>{const p=$.p;if(p!=null){const v=C[p];v&&v.get(),v&&T.mergeTree(v.get())}}))),y.get()}const ge=(r,u)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?ge(y,u):u(y)));function De(r,u){if(r==null||!ge(r,p=>{var v;return p.r!==void 0||((v=ve(p))===null||v===void 0?void 0:v.makeInvertible)!=null}))return r;const y=new i.ReadCursor(r),A=new i.WriteCursor;let b=!1;const C=[],$=[],T=(p,v,m)=>{const I=p.getComponent();let k=!1;if(I){I.d!=null&&v.write("d",I.d),I.i!==void 0&&v.write("i",I.i);const g=I.p;if(g!=null&&(C[g]=p.clone(),l(m!==void 0,"Operation picks up at an invalid key"),$[g]=m,v.write("p",I.p)),I.r!==void 0&&m===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const M=ve(I);M&&(M.makeInvertible?b=!0:_(v,M,f(I),!0))}let G=0;for(const g of p){v.descend(g);const M=typeof g=="number"?g-G:g,re=Y(m,M),te=T(p,v,re);re!==te&&(k||(k=!0,m=W(m)),te===void 0?(m=c(m,M),typeof g=="number"&&G++):m[M]=te),v.ascend()}return I&&(I.r!==void 0?(v.write("r",s.default(m)),m=void 0):I.p!=null&&(m=void 0)),m};return T(y,A,u),A.get(),b&&(A.reset(),function p(v,m,I,k,G){const g=m.getComponent();if(g){g.i!==void 0?(k=g.i,G=!0):g.d!=null&&(k=$[g.d],v=C[g.d],G=!1,g.d);let K=ve(g);if(K&&K.makeInvertible){const se=f(g);_(I,K,K.makeInvertible(se,k),!0)}}let M=0,re=0;const te=i.advancer(v,(K,se)=>O(se)?M-K-1:K-M,(K,se)=>{O(se)&&M++});for(const K of m)if(typeof K=="number"){const se=K-re,ke=te(se),be=se+M,_e=Y(k,G?se:be);I.descend(K),p(ke,m,I,_e,G),o(m.getComponent())&&re++,I.ascend()}else{const se=Y(k,K);I.descend(K),p(te(K),m,I,se,G),I.ascend()}te.end()}(y.clone(),y,A,u,!1)),A.get()}function Rt(r,u){return ae(De(r,u))}const rt=r=>{if(r==null)return null;const u=r.slice();for(let y=0;y<r.length;y++){const A=u[y];Array.isArray(A)&&(u[y]=rt(A))}return u};function it(r,u,y){l(y==="left"||y==="right","Direction must be left or right");const A=y==="left"?0:1;if(u==null)return{ok:!0,result:r};z(r),z(u);let b=null;const C=[],$=[],T=[],p=[],v=[],m=[],I=[],k=[],G=[],g=[],M=[],re=[],te=[],K=[],se=[];let ke=0;const be=i.readCursor(r),_e=i.readCursor(u),oe=i.writeCursor();if(function Q(S,B=null,U){const D=a(B);D&&(D.r!==void 0?U=B.clone():D.p!=null&&(U=null,m[D.p]=S.clone()));const N=S.getComponent();let X;N&&(X=N.p)!=null&&(v[X]=B?B.clone():null,T[X]=S.clone(),U&&(g[X]=!0,G[X]=U),D&&D.p!=null&&(K[X]=D.p));const Z=i.advancer(B);for(const ee of S)Q(S,Z(ee),U);Z.end()}(_e,be,null),function Q(S,B,U,D,N){const X=U.getComponent();let Z,ee=!1;X&&((Z=X.d)!=null?(p[Z]=U.clone(),D!=null&&(se[D]==null&&(se[D]=[]),se[D].push(Z)),S=v[Z]||null,B=T[Z]||null,g[Z]?(N&&(M[Z]=!0),N=G[Z]||null):!N||A!==1&&K[Z]!=null||b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.moveOp(B.getPath(),U.getPath())}),ee=!0):X.i!==void 0&&(S=B=null,ee=!0,N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.insertOp(U.getPath(),X.i)})));const fe=a(S);fe&&(fe.r!==void 0?N=S.clone():fe.p!=null&&(fe.p,D=fe.p,N=null));const de=ve(X);de&&N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.editOp(U.getPath(),de,f(X),!0)});let le=0,ye=0;const q=i.advancer(B,(x,he)=>O(he)?le-x-1:x-le,(x,he)=>{O(he)&&le++}),P=i.advancer(S);for(const x of U)if(typeof x=="number"){const he=x-ye,me=q(he);ye+=+Q(P(he+le),me,U,D,N)}else{const he=q(x);Q(P(x),he,U,D,N)}return q.end(),P.end(),ee}(be,_e,_e.clone(),null,null),p.map(Q=>Q&&Q.get()),b)return{ok:!1,conflict:b};M.map(Q=>!!Q);const Pe=[];let Ue=null;(function Q(S,B,U,D,N){let X=!1;const Z=a(B);if(O(Z)){const q=Z.p;q!=null?(U=p[q],D=re[q]=i.writeCursor(),X=!0,N=null):(U=null,N=B.clone())}else o(a(U))&&(U=null);const ee=S.getComponent();if(ee){const q=ee.p;q!=null?(N&&(k[q]=N),Pe[q]=N||A===1&&X?null:D.getComponent(),C[q]=S.clone(),U&&(I[q]=U.clone())):ee.r!==void 0&&(N||D.write("r",!0),(N||X)&&(Ue==null&&(Ue=new Set),Ue.add(ee)))}let fe=0,de=0;const le=i.advancer(B,void 0,(q,P)=>{O(P)&&fe++}),ye=i.advancer(U,(q,P)=>o(P)?~(q-de):q-de,(q,P)=>{o(P)&&de++});if(S)for(const q of S)if(typeof q=="string"){const P=le(q),x=ye(q);D.descend(q),Q(S,P,x,D,N),D.ascend()}else{const P=le(q),x=q-fe,he=O(a(P))?null:ye(x),me=x+de;l(me>=0),D.descend(me),Q(S,P,he,D,N),D.ascend()}le.end(),ye.end()})(be,_e,_e.clone(),oe,null),oe.reset();let Le=[];if(function Q(S,B,U,D,N,X){l(B);const Z=B.getComponent();let ee=a(D),fe=!1;const de=(R,ie,Oe)=>R?n.moveOp(R.getPath(),ie.getPath()):n.insertOp(ie.getPath(),Oe.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=B.clone());const ie=R!=null?Pe[R]:null;let Oe=!1;if(Z.i!==void 0||R!=null&&ie){let ce;ee&&(ee.i!==void 0||(ce=ee.d)!=null&&!g[ce])&&(Oe=ce!=null?R!=null&&R===K[ce]:t.default(ee.i,Z.i),Oe||ce!=null&&A!==1&&K[ce]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:de(R!=null?C[R]:null,B,Z),op2:de(ce!=null?T[ce]:null,D,ee)})),Oe||(X?b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:de(R!=null?C[R]:null,B,Z),op2:n.removeOp(X.getPath())}):(R!=null?(Le[ke]=R,N.write("d",ie.p=ke++)):N.write("i",s.default(Z.i)),fe=!0))}else if(R!=null&&!ie){const ce=k[R];ce&&(X=ce.clone())}R!=null?(S=C[R],U=m[R],D=I[R]):Z.i!==void 0&&(S=U=null,Oe||(D=null))}else O(a(S))&&(S=U=D=null);const le=a(S),ye=a(U);if(O(ye)){const R=ye.p;ye.r!==void 0&&(!le||le.r===void 0)||g[R]?(D=null,X=U.clone()):R!=null&&(D=p[R],A!==1&&K[R]!=null||((N=te[R])||(N=te[R]=i.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(ee)&&(D=null);ee=D!=null?D.getComponent():null;const q=ve(Z);if(q){const R=f(Z);if(X)b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.editOp(B.getPath(),q,R,!0),op2:n.removeOp(X.getPath())});else{const ie=ve(ee);let Oe;if(ie){if(q!==ie)throw Error("Transforming incompatible types");const ce=f(ee);Oe=q.transform(R,ce,y)}else Oe=s.default(R);_(N,q,Oe)}}let P=0,x=0,he=0,me=0,We=0,He=0,Me=S!=null&&S.descendFirst(),Ye=Me;const ze=i.advancer(U,void 0,(R,ie)=>{O(ie)&&he++});let Re=D!=null&&D.descendFirst(),Te=Re;for(const R of B)if(typeof R=="number"){let ie;const Oe=o(B.getComponent()),ce=R-x;{let Be;for(;Me&&typeof(Be=S.getKey())=="number";){Be+=P;const je=S.getComponent(),Xe=O(je);if(Be>ce||Be===ce&&(!Xe||A===0&&Oe))break;if(Xe){P--;const Ke=je.p;K.includes(Ke),je.d,a(te[je.d]),O(a(te[je.d])),(je.r===void 0||Ue&&Ue.has(je))&&(Ke==null||!Pe[Ke]||A!==1&&K.includes(Ke))||We--}Me=S.nextSibling()}ie=Me&&Be===ce?S:null}const Ne=ce-P;let Ge=ze(Ne);const st=Ne-he;let et=null;{let Be,je;for(;Re&&typeof(Be=D.getKey())=="number";){je=Be-me;const Xe=D.getComponent(),Ke=o(Xe);if(je>st)break;if(je===st){if(!Ke){et=D;break}{if(A===0&&Oe){et=D;break}const Fe=Ge&&O(Ge.getComponent());if(A===0&&Fe)break}}if(Ke){const Fe=Xe.d;K[Fe],Xe.i===void 0&&(g[Fe]||K[Fe]!=null&&A!==1)?(g[Fe]||K[Fe]!=null&&A===0)&&(me++,He--):me++}Re=D.nextSibling()}}const yt=st+me+We+He;l(yt>=0,"trying to descend to a negative index"),N.descend(yt),Oe&&(ie=Ge=et=null,x++),Q(ie,B,Ge,et,N,X)&&He++,N.ascend()}else{let ie;for(;Me&&(ie=S.getKey(),typeof ie!="string"||!(ie>R||ie===R));)Me=S.nextSibling();const Oe=Me&&ie===R?S:null,ce=ze(R);let Ne;for(;Re&&(Ne=D.getKey(),typeof Ne!="string"||!(Ne>R||Ne===R));)Re=D.nextSibling();const Ge=Re&&Ne===R?D:null;N.descend(R),Q(Oe,B,ce,Ge,N,X),N.ascend()}return ze.end(),Ye&&S.ascend(),Te&&D.ascend(),fe}(be,be.clone(),_e,_e.clone(),oe,null),b)return{ok:!1,conflict:b};oe.reset();const Se=(Q,S,B)=>Q.traverse(S,(U,D)=>{U.d!=null&&B(U.d,Q,D)});(g.length||re.length)&&(Se(_e,oe,(Q,S,B)=>{g[Q]&&!M[Q]&&B.write("r",!0),re[Q]&&B.mergeTree(re[Q].get())}),oe.reset());const Ee=[],$e=[];if((te.length||g.length)&&!b){const Q=i.readCursor(rt(oe.get()));if(Se(Q,null,(S,B)=>{Ee[S]=B.clone()}),te.forEach(S=>{S&&Se(i.readCursor(S.get()),null,(B,U)=>{Ee[B]=U.clone()})}),function S(B,U,D,N,X,Z){const ee=a(U);if(ee&&O(ee))if(ee.p!=null){const P=ee.p;Ee[P].getPath(),D=Ee[P],N=$e[P]=i.writeCursor()}else ee.r!==void 0&&(D=null);else o(a(D))&&(D=null);const fe=B.getComponent();if(fe){let P;if((P=fe.d)!=null){const x=te[P];x&&(x.get(),N.mergeTree(x.get()),D=i.readCursor(x.get()))}}let de=0,le=0;const ye=i.advancer(U,void 0,(P,x)=>{O(x)&&de--}),q=i.advancer(D,(P,x)=>o(x)?-(P-le)-1:P-le,(P,x)=>{o(x)&&le++});for(const P of B)if(typeof P=="number"){const x=ye(P),he=P+de,me=q(he),We=he+le;N.descend(We),S(B,x,me,N),N.ascend()}else N.descend(P),S(B,ye(P),q(P),N),N.ascend();ye.end(),q.end()}(_e,Q,Q.clone(),oe),oe.reset(),b)return{ok:!1,conflict:b};if(oe.get(),$e.length){const S=$e.map(U=>U?U.get():null),B=i.readCursor(rt(oe.get()));if(Se(B,oe,(U,D,N)=>{const X=S[U];X&&(N.mergeTree(X),S[U]=null)}),S.find(U=>U)){const U=i.writeCursor(),D=i.writeCursor();let N=0,X=0;S.forEach(Z=>{Z!=null&&Se(i.readCursor(Z),null,ee=>{const fe=Le[ee];U.writeMove(C[fe].getPath(),$[fe].getPath(),N++);const de=se[fe];de&&de.forEach(le=>{g[le]||A!==1&&K[le]!=null||D.writeMove(T[le].getPath(),p[le].getPath(),X++)})})}),b={type:d.ConflictType.BLACKHOLE,op1:U.get(),op2:D.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:oe.get()}}const Ot=r=>{const u=new Error("Transform detected write conflict");throw u.conflict=r,u.type=u.name="writeConflict",u};function Tt(r,u,y){const A=it(r,u,y);if(A.ok)return A.result;Ot(A.conflict)}const qe=r=>{const u=i.writeCursor();return i.readCursor(r).traverse(u,(y,A)=>{(o(y)||ve(y))&&A.write("r",!0)}),u.get()},kt=(r,u)=>{const{type:y,op1:A,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return u==="left"?[null,qe(b)]:[qe(A),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return i.readCursor(A).traverse(null,$=>{$.r!==void 0&&(C=!0)}),C?[null,qe(b)]:[qe(A),null];case d.ConflictType.BLACKHOLE:return[qe(A),qe(b)];default:throw Error("Unrecognised conflict: "+y)}};function vt(r,u,y,A){let b=null;for(;;){const C=it(u,y,A);if(C.ok)return ne(b,C.result);{const{conflict:$}=C;r($)||Ot($);const[T,p]=kt($,A);u=ne(H(u),T),y=ne(H(y),p),b=ne(b,p)}}}})(At);(function(n){var e=Ce&&Ce.__createBinding||(Object.create?function(d,l,a,E){E===void 0&&(E=a),Object.defineProperty(d,E,{enumerable:!0,get:function(){return l[a]}})}:function(d,l,a,E){E===void 0&&(E=a),d[E]=l[a]}),t=Ce&&Ce.__exportStar||function(d,l){for(var a in d)a!=="default"&&!l.hasOwnProperty(a)&&e(l,d,a)};Object.defineProperty(n,"__esModule",{value:!0}),t(At,n);var s=pt;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var i=gt;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})})(V);class Dt{constructor(){F(this,"drawingManagerData",{});F(this,"_oldDrawingManagerData",{});F(this,"_focusDrawings",[]);F(this,"_remove$",new we.Subject);F(this,"remove$",this._remove$.asObservable());F(this,"_add$",new we.Subject);F(this,"add$",this._add$.asObservable());F(this,"_update$",new we.Subject);F(this,"update$",this._update$.asObservable());F(this,"_order$",new we.Subject);F(this,"order$",this._order$.asObservable());F(this,"_group$",new we.Subject);F(this,"group$",this._group$.asObservable());F(this,"_ungroup$",new we.Subject);F(this,"ungroup$",this._ungroup$.asObservable());F(this,"_refreshTransform$",new we.Subject);F(this,"refreshTransform$",this._refreshTransform$.asObservable());F(this,"_visible$",new we.Subject);F(this,"visible$",this._visible$.asObservable());F(this,"_focus$",new we.Subject);F(this,"focus$",this._focus$.asObservable());F(this,"_featurePluginUpdate$",new we.Subject);F(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());F(this,"_featurePluginAdd$",new we.Subject);F(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());F(this,"_featurePluginRemove$",new we.Subject);F(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());F(this,"_featurePluginOrderUpdate$",new we.Subject);F(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());F(this,"_featurePluginGroupUpdate$",new we.Subject);F(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());F(this,"_featurePluginUngroupUpdate$",new we.Subject);F(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());F(this,"_visible",!0);F(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(t=>{if(this.getDrawingByParam(t)==null)return;const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]}removeDrawingDataForUnit(e){const t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];const s=[];Object.keys(t).forEach(i=>{const d=t[i];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(l=>{s.push({unitId:e,subUnitId:i,drawingId:l})})}),s.length>0&&this.removeNotification(s)}registerDrawingData(e,t){this.drawingManagerData[e]=t;const s=[];Object.keys(t).forEach(i=>{this._establishDrawingMap(e,i);const d=t[i];Object.keys(d.data).forEach(l=>{const a=d.data[l];s.push(a)})}),s.length>0&&this.addNotification(s)}getDrawingData(e,t){return this._getDrawingData(e,t)}getBatchAddOp(e){const t=[],s=[],i=[];e.forEach(W=>{const{op:O,invertOp:o}=this._addByParam(W);t.push({unitId:W.unitId,subUnitId:W.subUnitId,drawingId:W.drawingId}),s.push(O),i.push(o)});const d=s.reduce(V.type.compose,null),l=i.reduce(V.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],s=[];e.forEach(E=>{const{op:W,invertOp:O}=this._removeByParam(E);t.push(W),s.push(O)});const i=t.reduce(V.type.compose,null),d=s.reduce(V.type.compose,null),{unitId:l,subUnitId:a}=e[0];return{undo:d,redo:i,unitId:l,subUnitId:a,objects:e}}getBatchUpdateOp(e){const t=[],s=[],i=[];e.forEach(W=>{const{op:O,invertOp:o}=this._updateByParam(W);t.push({unitId:W.unitId,subUnitId:W.subUnitId,drawingId:W.drawingId}),s.push(O),i.push(o)});const d=s.reduce(V.type.compose,null),l=i.reduce(V.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getGroupDrawingOp(a))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getUngroupDrawingOp(a))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:s,drawingId:i}=e;if(this.getDrawingByParam({unitId:t,subUnitId:s,drawingId:i})==null)return[];const l=this._getDrawingData(t,s),a=[];return Object.keys(l).forEach(E=>{const W=l[E];W.groupId===i&&a.push(W)}),a}_getGroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];a.push(V.insertOp([i,d,"data",l],t));let E=Number.NEGATIVE_INFINITY;return s.forEach(W=>{const{unitId:O,subUnitId:o,drawingId:c}=W,h=this._hasDrawingOrder({unitId:O,subUnitId:o,drawingId:c});E=Math.max(E,h),a.push(...this._getUpdateParamCompareOp(W,this.getDrawingByParam({unitId:O,subUnitId:o,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(i,d).length),a.push(V.insertOp([i,d,"order",E],l)),a.reduce(V.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];return s.forEach(E=>{const{unitId:W,subUnitId:O,drawingId:o}=E;a.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:W,subUnitId:O,drawingId:o})))}),a.push(V.removeOp([i,d,"data",l],!0)),a.push(V.removeOp([i,d,"order",this._getDrawingOrder(i,d).indexOf(l)],!0)),a.reduce(V.type.compose,null)}applyJson1(e,t,s){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=V.type.apply(this.drawingManagerData,s)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[t,s,i]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:s,drawingId:i})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(s=>{var E;const{unitId:i,subUnitId:d,drawingId:l}=s,a=(E=this._getDrawingData(i,d))==null?void 0:E[l];a!=null&&t.push(a)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var a;const{unitId:s,subUnitId:i,drawingId:d}=t,l=(a=this._getDrawingData(s,i))==null?void 0:a[d];l!=null&&e.push(l)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(O=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:O});if(o===-1||o===l.length-1)return;const c=V.moveOp([t,s,"order",o],[t,s,"order",o+1]);d.push(c),a.includes(l[o+1])||a.push(l[o+1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(O=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:O});if(o===-1||o===0)return;const c=V.moveOp([t,s,"order",o],[t,s,"order",o-1]);d.push(c),a.includes(l[o-1])||a.push(l[o-1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:c}=o,h=this._getDrawingCount(t,s)-1,j=V.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(c)],[t,s,"order",h]);E.push(j),l.includes(a[h])||l.push(a[h])});const W=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(W,this.drawingManagerData),redo:W,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i,!0),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:c}=o,h=V.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(c)],[t,s,"order",0]);E.push(h),l.includes(a[0])||l.push(a[0])});const W=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(W,this.drawingManagerData),redo:W,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,s,i=!1){return s.map(d=>{const l=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:l}}).sort(i===!1?Qe.sortRules:Qe.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:s,drawingId:i}=e;return this._establishDrawingMap(t,s),this._getDrawingOrder(t,s).indexOf(i)}_getCurrentBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this.drawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_getOldBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this._oldDrawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_establishDrawingMap(e,t,s){var i;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),s==null?null:(i=this.drawingManagerData[e][t].data)==null?void 0:i[s]}_addByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e;this._establishDrawingMap(t,s,i);const d=V.insertOp([t,s,"data",i],e),l=V.insertOp([t,s,"order",this._getDrawingOrder(t,s).length],i),a=[d,l].reduce(V.type.compose,null),E=V.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:s,drawingId:i}=e;if(this._establishDrawingMap(t,s,i)==null)return{op:[],invertOp:[]};const l=V.removeOp([t,s,"data",i],!0),a=V.removeOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(i)],!0),E=[l,a].reduce(V.type.compose,null),W=V.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:W}}_updateByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e,d=this._establishDrawingMap(t,s,i);if(d==null)return{op:[],invertOp:[]};const a=this._getUpdateParamCompareOp(e,d).reduce(V.type.compose,null),E=V.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:s,subUnitId:i,drawingId:d}=e,l=[];return Object.keys(e).forEach(a=>{const E=e[a],W=t[a];W!==E&&l.push(V.replaceOp([s,i,"data",d,a],W,E))}),l}_getDrawingData(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.data)||{}}_getDrawingOrder(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Pt extends Dt{}function Vt(n){const{unitId:e,subUnitId:t,drawingId:s}=n;return`${e}#-#${t}#-#${s}`}const qt=async n=>new Promise((e,t)=>{const s=new Image;s.src=n,s.onload=()=>{e({width:s.width,height:s.height,image:s})},s.onerror=i=>{t(i)}});var Je=(n=>(n.URL="URL",n.UUID="UUID",n.BASE64="BASE64",n))(Je||{}),Ze=(n=>(n.SUCCUSS="0",n.ERROR_EXCEED_SIZE="1",n.ERROR_IMAGE_TYPE="2",n.ERROR_UPLOAD_COUNT_LIMIT="3",n.ERROR_IMAGE="4",n))(Ze||{});const St=nt.createIdentifier("core.image-io.service");class Ut{constructor(){F(this,"_waitCount",0);F(this,"_change$",new we.Subject);F(this,"change$",this._change$);F(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Je.BASE64){const s=new Image;return s.src=e,s}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,s){t===Je.BASE64||s==null||this._imageSourceCache.set(e,s)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,s)=>{if(!Et.includes(e.type)){s(new Error(Ze.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>Ct){s(new Error(Ze.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const i=new FileReader;i.readAsDataURL(e),i.onload=d=>{var E;const l=(E=d.target)==null?void 0:E.result;if(l==null){s(new Error(Ze.ERROR_IMAGE)),this._decreaseWaiting();return}const a=Qe.Tools.generateRandomId(6);t({imageId:a,imageSourceType:Je.BASE64,source:l,base64Cache:l,status:Ze.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const zt="__default_document_sub_component_id20231101__";var Mt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Mt||{}),Nt=(n=>(n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n[n.DRAWING_IMAGE=0]="DRAWING_IMAGE",n[n.DRAWING_SHAPE=1]="DRAWING_SHAPE",n[n.DRAWING_CHART=2]="DRAWING_CHART",n[n.DRAWING_TABLE=3]="DRAWING_TABLE",n[n.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",n[n.DRAWING_VIDEO=5]="DRAWING_VIDEO",n[n.DRAWING_GROUP=6]="DRAWING_GROUP",n[n.DRAWING_UNIT=7]="DRAWING_UNIT",n[n.DRAWING_DOM=8]="DRAWING_DOM",n))(Nt||{});const jt=nt.createIdentifier("univer.drawing-manager.service");var Xt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Yt=(n,e,t,s)=>{for(var i=s>1?void 0:s?Zt(e,t):e,d=n.length-1,l;d>=0;d--)(l=n[d])&&(i=(s?l(e,t,i):l(i))||i);return s&&i&&Xt(e,t,i),i},Jt=(n,e)=>(t,s)=>e(t,s,n);const Qt="DRAWING_PLUGIN";var at;exports.UniverDrawingPlugin=(at=class extends Qe.Plugin{constructor(e,t){super(),this._config=e,this._injector=t}onStarting(e){this._initDependencies(e)}_initDependencies(e){var i;const t=[[St,{useClass:Ut}],[jt,{useClass:Pt}]];Qe.mergeOverrideWithDependencies(t,(i=this._config)==null?void 0:i.override).forEach(d=>e.add(d))}},F(at,"pluginName",Qt),at);exports.UniverDrawingPlugin=Yt([Jt(1,nt.Inject(nt.Injector))],exports.UniverDrawingPlugin);exports.ArrangeTypeEnum=Mt;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=zt;exports.DRAWING_IMAGE_ALLOW_IMAGE_LIST=Et;exports.DRAWING_IMAGE_ALLOW_SIZE=Ct;exports.DRAWING_IMAGE_COUNT_LIMIT=xt;exports.DRAWING_IMAGE_HEIGHT_LIMIT=Bt;exports.DRAWING_IMAGE_WIDTH_LIMIT=Gt;exports.DrawingManagerService=Pt;exports.DrawingTypeEnum=Nt;exports.IDrawingManagerService=jt;exports.IImageIoService=St;exports.ImageIoService=Ut;exports.ImageSourceType=Je;exports.ImageUploadStatusType=Ze;exports.UnitDrawingService=Dt;exports.getDrawingShapeKeyByDrawingSearch=Vt;exports.getImageSize=qt;
|
|
1
|
+
"use strict";var $t=Object.defineProperty;var Wt=(n,e,t)=>e in n?$t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var F=(n,e,t)=>Wt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("rxjs"),Qe=require("@univerjs/core"),nt=require("@wendellhu/redi"),Gt=500,Bt=500,xt=10,Ct=5*1024*1024,Et=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V={},Dt={},dt={};Object.defineProperty(dt,"__esModule",{value:!0});function Lt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!ft(n[t],e[t]))return!1;for(let t in e)if(n[t]===void 0)return!1;return!0}function Ht(n,e){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!ft(n[t],e[t]))return!1;return!0}function ft(n,e){return n===e?!0:n===null||e===null||typeof n!="object"||typeof e!="object"?!1:Array.isArray(n)?Ht(n,e):Lt(n,e)}dt.default=ft;var ht={};Object.defineProperty(ht,"__esModule",{value:!0});function ct(n){if(n===null)return null;if(Array.isArray(n))return n.map(ct);if(typeof n=="object"){const e={};for(let t in n)e[t]=ct(n[t]);return e}else return n}ht.default=ct;var pt={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.eachChildOf=n.advancer=n.readCursor=n.writeCursor=n.WriteCursor=n.ReadCursor=n.isValidPathItem=void 0;function e(O,o){if(!O)throw new Error(o)}const t=O=>O!=null&&typeof O=="object"&&!Array.isArray(O),s=(O,o)=>typeof O==typeof o?O>o:typeof O=="string"&&typeof o=="number";function i(O,o){for(let c in O){const h=c;o.write(h,O[h])}}n.isValidPathItem=O=>typeof O=="number"||typeof O=="string"&&O!=="__proto__";class d{constructor(o=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=o}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,t(this.container[this.idx])&&this.idx--)}getPath(){const o=[];let c=this.container,h=this.parents.length-1,j=this.idx;for(;j>=0;)o.unshift(c[j]),j===0?(j=this.indexes[h*2],c=this.parents[h--]):j-=t(c[j-1])?2:1;return o}}class l extends d{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let o;return this.container&&this.container.length>this.idx+1&&t(o=this.container[this.idx+1])?o:null}descendFirst(){let o=this.idx+1;if(!this.container||o>=this.container.length||t(this.container[o])&&o+1>=this.container.length)return!1;t(this.container[o])&&o++;const c=this.container[o];return Array.isArray(c)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(o),this.idx=0,this.container=c):this.idx=o,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const o=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return o>=c.length?!1:(e(!isNaN(o)),this.indexes[this.indexes.length-1]=o,this.container=c[o],!0)}_init(o,c,h,j){this.container=o,this.idx=c,this.parents=h.slice(),this.indexes=j.slice()}clone(){const o=new l;return o._init(this.container,this.idx,this.parents,this.indexes),o}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(o,c){const h=this.getComponent();h&&c(h,o);for(const j of this)o&&o.descend(j),this.traverse(o,c),o&&o.ascend()}eachPick(o,c){this.traverse(o,(h,j)=>{h.p!=null&&c(h.p,j)})}eachDrop(o,c){this.traverse(o,(h,j)=>{h.d!=null&&c(h.d,j)})}}n.ReadCursor=l;class a extends d{constructor(o=null){super(o),this.pendingDescent=[],this._op=o}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let o=0;o<this.pendingDescent.length;o++){const c=this.pendingDescent[o];let h=this.idx+1;if(h<this.container.length&&t(this.container[h])&&h++,e(h===this.container.length||!t(this.container[h])),h===this.container.length)this.container.push(c),this.idx=h;else if(this.container[h]===c)this.idx=h;else{if(!Array.isArray(this.container[h])){const j=this.container.splice(h,this.container.length-h);this.container.push(j),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(s(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&s(c,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===c)this.container=this.container[h];else{const j=[c];this.container.splice(h,0,j),this.container=j}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const o=this.idx+1;if(o<this.container.length&&t(this.container[o]))return this.container[o];{const c={};return this.container.splice(o,0,c),c}}write(o,c){const h=this.getComponent();e(h[o]==null||h[o]===c,"Internal consistency error: Overwritten component. File a bug"),h[o]=c}get(){return this._op}descend(o){if(!n.isValidPathItem(o))throw Error("Invalid JSON key");this.pendingDescent.push(o)}descendPath(o){return this.pendingDescent.push(...o),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(o,c=i){if(o===null)return;if(e(Array.isArray(o)),o===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,j=this.parents.length;let Y=0;for(let pe=0;pe<o.length;pe++){const J=o[pe];typeof J=="string"||typeof J=="number"?(Y++,this.descend(J)):Array.isArray(J)?this.mergeTree(J,c):typeof J=="object"&&c(J,this)}for(;Y--;)this.ascend();this.lcIdx=this.parents.length===j?h:-1}at(o,c){this.descendPath(o),c(this);for(let h=0;h<o.length;h++)this.ascend();return this}writeAtPath(o,c,h){return this.at(o,()=>this.write(c,h)),this.reset(),this}writeMove(o,c,h=0){return this.writeAtPath(o,"p",h).writeAtPath(c,"d",h)}getPath(){const o=super.getPath();return o.push(...this.pendingDescent),o}}n.WriteCursor=a,n.writeCursor=()=>new a,n.readCursor=O=>new l(O);function E(O,o,c){let h,j;j=h=O?O.descendFirst():!1;function Y(pe){let J;for(;j;){const Ie=J=O.getKey();if(pe!=null){let xe=!1;if(o&&typeof Ie=="number"&&(J=o(Ie,O.getComponent()),J<0&&(J=~J,xe=!0)),s(J,pe))return null;if(J===pe&&!xe)return O}c&&typeof J=="number"&&c(J,O.getComponent()),j=O.nextSibling()}return null}return Y.end=()=>{h&&O.ascend()},Y}n.advancer=E;function W(O,o,c){let h,j,Y,pe;for(h=j=O&&O.descendFirst(),Y=pe=o&&o.descendFirst();h||Y;){let J=h?O.getKey():null,Ie=Y?o.getKey():null;J!==null&&Ie!==null&&(s(Ie,J)?Ie=null:J!==Ie&&(J=null)),c(J==null?Ie:J,J!=null?O:null,Ie!=null?o:null),J!=null&&h&&(h=O.nextSibling()),Ie!=null&&Y&&(Y=o.nextSibling())}j&&O.ascend(),pe&&o.ascend()}n.eachChildOf=W})(pt);var gt={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(n.ConflictType||(n.ConflictType={}))})(gt);var ot={},Ve={},bt;function _t(){return bt||(bt=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.uniToStrPos=Ve.strPosToUni=void 0,Ve.strPosToUni=(n,e=n.length)=>{let t=0,s=0;for(;s<e;s++){const i=n.charCodeAt(s);i>=55296&&i<=57343&&(t++,s++)}if(s!==e)throw Error("Invalid offset - splits unicode bytes");return s-t},Ve.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const s=n.charCodeAt(t);t+=s>=55296&&s<=57343?2:1}return t}),Ve}var lt={},mt;function ut(){return mt||(mt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=_t(),t=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let _=null;for(let w=0;w<f.length;w++){const L=f[w];switch(typeof L){case"object":if(typeof L.d!="number"&&typeof L.d!="string")throw Error("Delete must be number or string");if(n.dlen(L.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(L.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(L>0))throw Error("Skip components must be >0");if(typeof _=="number")throw Error("Adjacent skip components should be combined");break}_=L}if(typeof _=="number")throw Error("Op has a trailing skip")};function s(f,_){let w=0,L=0;for(let z=0;z<f.length;z++){const H=f[z];switch(_(H,w,L),typeof H){case"object":w+=n.dlen(H.d);break;case"string":L+=e.strPosToUni(H);break;case"number":w+=H,L+=H;break}}}n.eachOp=s;function i(f,_){const w=[],L=a(w);return s(f,(z,H,De)=>{L(_(z,H,De))}),o(w)}const d=f=>f,l=f=>i(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const a=f=>_=>{if(!(!_||_.d===0||_.d===""))if(f.length===0)f.push(_);else if(typeof _==typeof f[f.length-1])if(typeof _=="object"){const w=f[f.length-1];w.d=typeof w.d=="string"&&typeof _.d=="string"?w.d+_.d:n.dlen(w.d)+n.dlen(_.d)}else f[f.length-1]+=_;else f.push(_)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);n.uniSlice=(f,_,w)=>{const L=e.uniToStrPos(f,_),z=w==null?1/0:e.uniToStrPos(f,w);return f.slice(L,z)};const W=(f,_,w)=>typeof f=="number"?w==null?f-_:Math.min(f,w)-_:n.uniSlice(f,_,w),O=f=>{let _=0,w=0;return{take:(H,De)=>{if(_===f.length)return H===-1?null:H;const ue=f[_];let ne;if(typeof ue=="number")return H===-1||ue-w<=H?(ne=ue-w,++_,w=0,ne):(w+=H,H);if(typeof ue=="string"){if(H===-1||De==="i"||e.strPosToUni(ue.slice(w))<=H)return ne=ue.slice(w),++_,w=0,ne;{const ae=w+e.uniToStrPos(ue.slice(w),H);return ne=ue.slice(w,ae),w=ae,ne}}else{if(H===-1||De==="d"||n.dlen(ue.d)-w<=H)return ne={d:W(ue.d,w)},++_,w=0,ne;{let ae=W(ue.d,w,w+H);return w+=H,{d:ae}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,_,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");t(f),t(_);const L=[],z=a(L),{take:H,peek:De}=O(f);for(let ne=0;ne<_.length;ne++){const ae=_[ne];let ge,Ae;switch(typeof ae){case"number":for(ge=ae;ge>0;)Ae=H(ge,"i"),z(Ae),typeof Ae!="string"&&(ge-=E(Ae));break;case"string":w==="left"&&typeof De()=="string"&&z(H(-1)),z(e.strPosToUni(ae));break;case"object":for(ge=n.dlen(ae.d);ge>0;)switch(Ae=H(ge,"i"),typeof Ae){case"number":ge-=Ae;break;case"string":z(Ae);break;case"object":ge-=n.dlen(Ae.d)}break}}let ue;for(;ue=H(-1);)z(ue);return o(L)}function h(f,_){t(f),t(_);const w=[],L=a(w),{take:z}=O(f);for(let De=0;De<_.length;De++){const ue=_[De];let ne,ae;switch(typeof ue){case"number":for(ne=ue;ne>0;)ae=z(ne,"d"),L(ae),typeof ae!="object"&&(ne-=E(ae));break;case"string":L(ue);break;case"object":ne=n.dlen(ue.d);let ge=0;for(;ge<ne;)switch(ae=z(ne-ge,"d"),typeof ae){case"number":L({d:W(ue.d,ge,ge+ae)}),ge+=ae;break;case"string":ge+=e.strPosToUni(ae);break;case"object":L(ae)}break}}let H;for(;H=z(-1);)L(H);return o(w)}const j=(f,_)=>{let w=0;for(let L=0;L<_.length&&f>w;L++){const z=_[L];switch(typeof z){case"number":{w+=z;break}case"string":const H=e.strPosToUni(z);w+=H,f+=H;break;case"object":f-=Math.min(n.dlen(z.d),f-w);break}}return f},Y=(f,_)=>typeof f=="number"?j(f,_):f.map(w=>j(w,_));function pe(f,_,w){return i(f,(L,z)=>typeof L=="object"&&typeof L.d=="number"?{d:w.slice(_,z,z+L.d)}:L)}function J(f){return i(f,_=>{switch(typeof _){case"object":if(typeof _.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return _.d;case"string":return{d:_};case"number":return _}})}function Ie(f){return i(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function xe(f){let _=!0;return s(f,w=>{typeof w=="object"&&typeof w.d=="number"&&(_=!1)}),_}function ve(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:l,checkOp:t,create(_=""){if(typeof _!="string")throw Error("Initial data must be a string");return f.create(_)},apply(_,w){t(w);const L=f.builder(_);for(let z=0;z<w.length;z++){const H=w[z];switch(typeof H){case"number":L.skip(H);break;case"string":L.append(H);break;case"object":L.del(n.dlen(H.d));break}}return L.build()},transform:c,compose:h,transformPosition:j,transformSelection:Y,isInvertible:xe,makeInvertible(_,w){return pe(_,w,f)},stripInvertible:Ie,invert:J,invertWithDoc(_,w){return J(pe(_,w,f))},isNoop:_=>_.length===0}}n.default=ve}(lt)),lt}var tt={},wt;function Kt(){if(wt)return tt;wt=1,Object.defineProperty(tt,"__esModule",{value:!0});const n=ut(),e=_t();function t(s,i){return{get:s,getLength(){return s().length},insert(d,l,a){const E=e.strPosToUni(s(),d);return i([E,l],a)},remove(d,l,a){const E=e.strPosToUni(s(),d);return i([E,{d:l}],a)},_onOp(d){n.eachOp(d,(l,a,E)=>{switch(typeof l){case"string":this.onInsert&&this.onInsert(E,l);break;case"object":const W=n.dlen(l.d);this.onRemove&&this.onRemove(E,W)}})},onInsert:null,onRemove:null}}return tt.default=t,t.provides={text:!0},tt}var It;function Ft(){return It||(It=1,function(n){var e=Ce&&Ce.__createBinding||(Object.create?function(c,h,j,Y){Y===void 0&&(Y=j),Object.defineProperty(c,Y,{enumerable:!0,get:function(){return h[j]}})}:function(c,h,j,Y){Y===void 0&&(Y=j),c[Y]=h[j]}),t=Ce&&Ce.__setModuleDefault||(Object.create?function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}:function(c,h){c.default=h}),s=Ce&&Ce.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var j in c)Object.hasOwnProperty.call(c,j)&&e(h,c,j);return t(h,c),h},i=Ce&&Ce.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(n,"__esModule",{value:!0}),n.type=n.remove=n.insert=void 0;const d=_t(),l=s(ut()),a=i(Kt()),E={create(c){return c},toString(c){return c},builder(c){if(typeof c!="string")throw Error("Invalid document snapshot: "+c);const h=[];return{skip(j){let Y=d.uniToStrPos(c,j);if(Y>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,Y)),c=c.slice(Y)},append(j){h.push(j)},del(j){c=c.slice(d.uniToStrPos(c,j))},build(){return h.join("")+c}}},slice:l.uniSlice},W=l.default(E),O=Object.assign(Object.assign({},W),{api:a.default});n.type=O,n.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],n.remove=(c,h)=>l.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var o=ut();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ot)),ot}(function(n){var e=Ce&&Ce.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(n,"__esModule",{value:!0}),n.editOp=n.replaceOp=n.insertOp=n.moveOp=n.removeOp=n.type=void 0;const t=e(dt),s=e(ht),i=pt,d=gt;function l(r,u){if(!r)throw new Error(u)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:i.readCursor,writeCursor:i.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:J,checkValidOp:z,normalize:H,apply:De,transformPosition:ue,compose:ne,tryTransform:it,transform:Tt,makeInvertible:Ae,invert:ae,invertWithDoc:Rt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,u,y)=>vt(()=>!0,r,u,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(u,y,D)=>vt(r,u,y,D)})};const a=r=>r?r.getComponent():null;function E(r){return r&&typeof r=="object"&&!Array.isArray(r)}const W=r=>Array.isArray(r)?r.slice():r!==null&&typeof r=="object"?Object.assign({},r):r,O=r=>r&&(r.p!=null||r.r!==void 0),o=r=>r&&(r.d!=null||r.i!==void 0);function c(r,u){return l(r!=null),typeof u=="number"?(l(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(u,1)):(l(E(r),"Invalid key - child is not an object"),delete(r=Object.assign({},r))[u]),r}function h(r,u,y){return typeof u=="number"?(l(r!=null,"Container is missing for key"),l(Array.isArray(r),"Cannot use numerical key for object container"),l(r.length>=u,"Cannot insert into out of bounds index"),r.splice(u,0,y)):(l(E(r),"Cannot insert into missing item"),l(r[u]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),r[u]=y),y}n.removeOp=(r,u=!0)=>i.writeCursor().writeAtPath(r,"r",u).get(),n.moveOp=(r,u)=>i.writeCursor().writeMove(r,u).get(),n.insertOp=(r,u)=>i.writeCursor().writeAtPath(r,"i",u).get(),n.replaceOp=(r,u,y)=>i.writeCursor().at(r,D=>{D.write("r",u),D.write("i",y)}).get(),n.editOp=(r,u,y,D=!1)=>i.writeCursor().at(r,b=>_(b,u,y,D)).get();const j=(r,u)=>r!=null&&(typeof u=="number"?Array.isArray(r):typeof r=="object"),Y=(r,u)=>j(r,u)?r[u]:void 0,pe={};function J(r){let u=r.type?r.type:r;u.name&&(pe[u.name]=u),u.uri&&(pe[u.uri]=u)}const Ie=r=>{const u=pe[r];if(u)return u;throw Error("Missing type: "+r)};J(Ft());const xe=(r,u)=>r+u;J({name:"number",apply:xe,compose:xe,invert:r=>-r,transform:r=>r});const ve=r=>r==null?null:r.et?Ie(r.et):r.es?pe["text-unicode"]:r.ena!=null?pe.number:null,f=r=>r.es?r.es:r.ena!=null?r.ena:r.e,_=(r,u,y,D=!1)=>{const[b,C]=typeof u=="string"?[Ie(u),u]:[u,u.name];!D&&b.isNoop&&b.isNoop(y)||(C==="number"?r.write("ena",y):C==="text-unicode"?r.write("es",y):(r.write("et",C),r.write("e",y)))};function w(r){l(typeof r=="number"),l(r>=0),l(r===(0|r))}function L(r){typeof r=="number"?w(r):l(typeof r=="string")}function z(r){if(r===null)return;const u=new Set,y=new Set,D=C=>{let $=!0,T=!1;for(let p in C){const v=C[p];if($=!1,l(p==="p"||p==="r"||p==="d"||p==="i"||p==="e"||p==="es"||p==="ena"||p==="et","Invalid component item '"+p+"'"),p==="p")w(v),l(!u.has(v)),u.add(v),l(C.r===void 0);else if(p==="d")w(v),l(!y.has(v)),y.add(v),l(C.i===void 0);else if(p==="e"||p==="es"||p==="ena"){l(!T),T=!0;const m=ve(C);l(m,"Missing type in edit"),m.checkValidOp&&m.checkValidOp(f(C))}}l(!$)},b=(C,$,T)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");$||L(C[0]);let p=1,v=0,m=0;for(let I=0;I<C.length;I++){const k=C[I];if(l(k!=null),Array.isArray(k)){const G=b(k,!1);if(v){const g=typeof m,M=typeof G;g===M?l(m<G,"descent keys are not in order"):l(g==="number"&&M==="string")}m=G,v++,p=3}else typeof k=="object"?(l(p===1,`Prev not scalar - instead ${p}`),D(k),p=2):(l(p!==3),L(k),l(i.isValidPathItem(k),"Invalid path key"),p=1)}return l(v!==1,"Operation makes multiple descents. Remove some []"),l(p===2||p===3),C[0]};b(r,!0),l(u.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<u.size;C++)l(u.has(C)),l(y.has(C))}function H(r){let u=0,y=[];const D=i.writeCursor();return D.mergeTree(r,(b,C)=>{const $=ve(b);if($){const p=f(b);_(C,$,$.normalize?$.normalize(p):p)}for(const p of["r","p","i","d"])if(b[p]!==void 0){const v=p==="p"||p==="d"?(T=b[p],y[T]==null&&(y[T]=u++),y[T]):b[p];C.write(p,v)}var T}),D.get()}function De(r,u){if(z(u),u===null)return r;const y=[];return function D(b,C){let $=b,T=0,p={root:b},v=0,m=p,I="root";function k(){for(;v<T;v++){let G=C[v];typeof G!="object"&&(l(j(m,I)),m=m[I]=W(m[I]),I=G)}}for(;T<C.length;T++){const G=C[T];if(Array.isArray(G)){const g=D($,G);g!==$&&g!==void 0&&(k(),$=m[I]=g)}else if(typeof G=="object"){G.d!=null?(k(),$=h(m,I,y[G.d])):G.i!==void 0&&(k(),$=h(m,I,G.i));const g=ve(G);if(g)k(),$=m[I]=g.apply($,f(G));else if(G.e!==void 0)throw Error("Subtype "+G.et+" undefined")}else $=Y($,G)}return p.root}(r=function D(b,C){const $=[];let T=0;for(;T<C.length;T++){const I=C[T];if(Array.isArray(I))break;typeof I!="object"&&($.push(b),b=Y(b,I))}for(let I=C.length-1;I>=T;I--)b=D(b,C[I]);for(--T;T>=0;T--){const I=C[T];if(typeof I!="object"){const k=$.pop();b=b===Y(k,I)?k:b===void 0?c(k,I):(v=I,m=b,(p=W(p=k))[v]=m,p)}else O(I)&&(l(b!==void 0,"Cannot pick up or remove undefined"),I.p!=null&&(y[I.p]=b),b=void 0)}var p,v,m;return b}(r,u),u)}function ue(r,u){r=r.slice(),z(u);const y=i.readCursor(u);let D,b,C=!1;const $=[];for(let p=0;;p++){const v=r[p],m=y.getComponent();if(m&&(m.r!==void 0?C=!0:m.p!=null&&(C=!1,D=m.p,b=p)),p>=r.length)break;let I=0;const k=i.advancer(y,void 0,(g,M)=>{O(M)&&I++});$.unshift(k);const G=k(v);if(typeof v=="number"&&(r[p]-=I),!G)break}if($.forEach(p=>p.end()),C)return null;const T=()=>{let p=0;if(D!=null){const v=y.getPath();p=v.length,r=v.concat(r.slice(b))}for(;p<r.length;p++){const v=r[p],m=a(y),I=ve(m);if(I){const g=f(m);I.transformPosition&&(r[p]=I.transformPosition(r[p],g));break}let k=0;const G=i.advancer(y,(g,M)=>o(M)?~(g-k):g-k,(g,M)=>{o(M)&&k++})(v);if(typeof v=="number"&&(r[p]+=k),!G)break}};return D!=null?y.eachDrop(null,p=>{p===D&&T()}):T(),r}function ne(r,u){if(z(r),z(u),r==null)return u;if(u==null)return r;let y=0;const D=i.readCursor(r),b=i.readCursor(u),C=i.writeCursor(),$=[],T=[],p=[],v=[],m=[],I=[],k=new Set;D.traverse(null,g=>{g.p!=null&&(p[g.p]=D.clone())}),b.traverse(null,g=>{g.d!=null&&(v[g.d]=b.clone())});const G=i.writeCursor();return function g(M,re,te,K,se,ke,be,_e){l(re||te);const oe=a(re),Pe=a(te),Ue=!!Pe&&Pe.r!==void 0,Le=!!oe&&oe.i!==void 0,Se=oe?oe.d:null,Ee=Pe?Pe.p:null,$e=(ke||Ue)&&Ee==null;if(Ee!=null)K=v[Ee],be=T[Ee]=new i.WriteCursor;else if(Pe&&Pe.r!==void 0)K=null;else{const P=a(K);P&&P.d!=null&&(K=null)}const Q=a(K);if(Se!=null)if(M=p[Se],_e=$[Se]=new i.WriteCursor,$e)ke&&!Ue&&_e.write("r",!0);else{const P=m[Se]=y++;be.write("d",P)}else if(oe&&oe.i!==void 0)M=null;else{const P=a(M);P&&P.p!=null&&(M=null)}let S;Le?(l(se===void 0),S=oe.i):S=se;const B=(Ee==null?!Le||ke||Ue:S===void 0)?null:be.getComponent();if(Ee!=null){if(!(se!==void 0||Le)){const P=Se!=null?m[Se]:y++;I[Ee]=P,_e.write("p",P)}}else Ue&&(Le||se!==void 0||(Pe.r,_e.write("r",Pe.r)));const U=$e?null:ve(oe),A=ve(Q);if((U||A)&&(U&&U.name,A&&A.name),U&&A){l(U===A);const P=f(oe),x=f(Q),he=U.compose(P,x);_(be,U,he),k.add(Q)}else U?_(be,U,f(oe)):A&&(_(be,A,f(Q)),k.add(Q));const N=typeof S=="object"&&S!=null;let X=!1,Z=0,ee=0,fe=0,de=0,le=0;const ye=i.advancer(K,(P,x)=>o(x)?de-P-1:P-de,(P,x)=>{o(x)&&de++}),q=i.advancer(M,(P,x)=>O(x)?Z-P-1:P-Z,(P,x)=>{O(x)&&Z++});if(i.eachChildOf(re,te,(P,x,he)=>{let me,We,He=P,Me=P,Ye=P;if(typeof P=="number"){let Oe=P+fe;We=ye(Oe),Me=Oe+de;let ce=P+ee;me=q(ce),o(a(We))&&(me=null),He=ce+Z,Ye=P+le,l(He>=0,"p1PickKey is negative"),l(Me>=0,"p2DropKey is negative");const Ne=o(a(x)),Ge=O(a(he));(Ne||Ge&&!$e)&&le--,Ne&&ee--,Ge&&fe--}else me=q(P),We=ye(P);_e.descend(He),be.descend(Me);const ze=N&&!o(a(x))?S[Ye]:void 0,Re=g(me,x,he,We,ze,$e,be,_e);var Te,R,ie;N&&!$e?ze!==Re&&(X||(S=Array.isArray(S)?S.slice():Object.assign({},S),X=!0),Te=S,ie=Re,typeof(R=Ye)=="number"?(l(Array.isArray(Te)),l(R<Te.length)):(l(!Array.isArray(Te)),l(Te[R]!==void 0)),ie===void 0?typeof R=="number"?Te.splice(R,1):delete Te[R]:Te[R]=ie):l(Re===void 0),be.ascend(),_e.ascend()}),q.end(),ye.end(),B!=null)B.i=S;else if(!ke&&!Ue&&Ee==null)return S}(D,D.clone(),b,b.clone(),void 0,!1,C,G),C.reset(),C.mergeTree(G.get()),C.reset(),C.get(),$.map(g=>g.get()),T.map(g=>g.get()),D.traverse(C,(g,M)=>{const re=g.p;if(re!=null){const te=m[re];te!=null&&M.write("p",te);const K=$[re];K&&K.get(),K&&M.mergeTree(K.get())}else g.r!==void 0&&M.write("r",g.r)}),C.reset(),C.get(),b.traverse(C,(g,M)=>{const re=g.d;if(re!=null){const K=I[re];K!=null&&M.write("d",K);const se=T[re];se&&M.mergeTree(se.get())}else g.i!==void 0&&M.write("i",g.i);const te=ve(g);te&&!k.has(g)&&_(M,te,f(g))}),C.get()}function ae(r){if(r==null)return null;const u=new i.ReadCursor(r),y=new i.WriteCursor;let D;const b=[],C=[];return function $(T,p,v){const m=T.getComponent();let I,k=!1;if(m){m.p!=null&&(p.write("d",m.p),b[m.p]=T.clone()),m.r!==void 0&&p.write("i",m.r),m.d!=null&&(p.write("p",m.d),v=void 0),m.i!==void 0&&(v=I=m.i);const g=ve(m);g&&(v===void 0?(D||(D=new Set),D.add(m)):(f(m),v=g.apply(v,f(m)),k=!0))}let G=0;for(const g of T){p.descend(g);const M=typeof g=="number"?g-G:g,re=Y(v,M);o(T.getComponent())&&G++;const te=$(T,p,re);if(v!==void 0&&te!==void 0){if(k||(k=!0,v=W(v)),!j(v,M))throw Error("Cannot modify child - invalid operation");v[M]=te}p.ascend()}if(I===void 0)return k?v:void 0;p.write("r",v)}(u,y,void 0),D&&(y.reset(),function $(T,p,v){const m=p.getComponent();if(m){const g=m.d;if(g!=null&&(T=b[g],v=C[g]=i.writeCursor()),D.has(m)){const M=ve(m);if(!M.invert)throw Error(`Cannot invert subtype ${M.name}`);_(v,M,M.invert(f(m)))}}let I=0,k=0;const G=i.advancer(T,(g,M)=>O(M)?I-g-1:g-I,(g,M)=>{O(M)&&I++});for(const g of p)if(typeof g=="number"){const M=g-k,re=G(M),te=M+I;v.descend(te),$(re,p,v),o(p.getComponent())&&k++,v.ascend()}else v.descend(g),$(G(g),p,v),v.ascend();G.end()}(u.clone(),u,y),C.length&&(y.reset(),u.traverse(y,($,T)=>{const p=$.p;if(p!=null){const v=C[p];v&&v.get(),v&&T.mergeTree(v.get())}}))),y.get()}const ge=(r,u)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?ge(y,u):u(y)));function Ae(r,u){if(r==null||!ge(r,p=>{var v;return p.r!==void 0||((v=ve(p))===null||v===void 0?void 0:v.makeInvertible)!=null}))return r;const y=new i.ReadCursor(r),D=new i.WriteCursor;let b=!1;const C=[],$=[],T=(p,v,m)=>{const I=p.getComponent();let k=!1;if(I){I.d!=null&&v.write("d",I.d),I.i!==void 0&&v.write("i",I.i);const g=I.p;if(g!=null&&(C[g]=p.clone(),l(m!==void 0,"Operation picks up at an invalid key"),$[g]=m,v.write("p",I.p)),I.r!==void 0&&m===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const M=ve(I);M&&(M.makeInvertible?b=!0:_(v,M,f(I),!0))}let G=0;for(const g of p){v.descend(g);const M=typeof g=="number"?g-G:g,re=Y(m,M),te=T(p,v,re);re!==te&&(k||(k=!0,m=W(m)),te===void 0?(m=c(m,M),typeof g=="number"&&G++):m[M]=te),v.ascend()}return I&&(I.r!==void 0?(v.write("r",s.default(m)),m=void 0):I.p!=null&&(m=void 0)),m};return T(y,D,u),D.get(),b&&(D.reset(),function p(v,m,I,k,G){const g=m.getComponent();if(g){g.i!==void 0?(k=g.i,G=!0):g.d!=null&&(k=$[g.d],v=C[g.d],G=!1,g.d);let K=ve(g);if(K&&K.makeInvertible){const se=f(g);_(I,K,K.makeInvertible(se,k),!0)}}let M=0,re=0;const te=i.advancer(v,(K,se)=>O(se)?M-K-1:K-M,(K,se)=>{O(se)&&M++});for(const K of m)if(typeof K=="number"){const se=K-re,ke=te(se),be=se+M,_e=Y(k,G?se:be);I.descend(K),p(ke,m,I,_e,G),o(m.getComponent())&&re++,I.ascend()}else{const se=Y(k,K);I.descend(K),p(te(K),m,I,se,G),I.ascend()}te.end()}(y.clone(),y,D,u,!1)),D.get()}function Rt(r,u){return ae(Ae(r,u))}const rt=r=>{if(r==null)return null;const u=r.slice();for(let y=0;y<r.length;y++){const D=u[y];Array.isArray(D)&&(u[y]=rt(D))}return u};function it(r,u,y){l(y==="left"||y==="right","Direction must be left or right");const D=y==="left"?0:1;if(u==null)return{ok:!0,result:r};z(r),z(u);let b=null;const C=[],$=[],T=[],p=[],v=[],m=[],I=[],k=[],G=[],g=[],M=[],re=[],te=[],K=[],se=[];let ke=0;const be=i.readCursor(r),_e=i.readCursor(u),oe=i.writeCursor();if(function Q(S,B=null,U){const A=a(B);A&&(A.r!==void 0?U=B.clone():A.p!=null&&(U=null,m[A.p]=S.clone()));const N=S.getComponent();let X;N&&(X=N.p)!=null&&(v[X]=B?B.clone():null,T[X]=S.clone(),U&&(g[X]=!0,G[X]=U),A&&A.p!=null&&(K[X]=A.p));const Z=i.advancer(B);for(const ee of S)Q(S,Z(ee),U);Z.end()}(_e,be,null),function Q(S,B,U,A,N){const X=U.getComponent();let Z,ee=!1;X&&((Z=X.d)!=null?(p[Z]=U.clone(),A!=null&&(se[A]==null&&(se[A]=[]),se[A].push(Z)),S=v[Z]||null,B=T[Z]||null,g[Z]?(N&&(M[Z]=!0),N=G[Z]||null):!N||D!==1&&K[Z]!=null||b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.moveOp(B.getPath(),U.getPath())}),ee=!0):X.i!==void 0&&(S=B=null,ee=!0,N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.insertOp(U.getPath(),X.i)})));const fe=a(S);fe&&(fe.r!==void 0?N=S.clone():fe.p!=null&&(fe.p,A=fe.p,N=null));const de=ve(X);de&&N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.editOp(U.getPath(),de,f(X),!0)});let le=0,ye=0;const q=i.advancer(B,(x,he)=>O(he)?le-x-1:x-le,(x,he)=>{O(he)&&le++}),P=i.advancer(S);for(const x of U)if(typeof x=="number"){const he=x-ye,me=q(he);ye+=+Q(P(he+le),me,U,A,N)}else{const he=q(x);Q(P(x),he,U,A,N)}return q.end(),P.end(),ee}(be,_e,_e.clone(),null,null),p.map(Q=>Q&&Q.get()),b)return{ok:!1,conflict:b};M.map(Q=>!!Q);const Pe=[];let Ue=null;(function Q(S,B,U,A,N){let X=!1;const Z=a(B);if(O(Z)){const q=Z.p;q!=null?(U=p[q],A=re[q]=i.writeCursor(),X=!0,N=null):(U=null,N=B.clone())}else o(a(U))&&(U=null);const ee=S.getComponent();if(ee){const q=ee.p;q!=null?(N&&(k[q]=N),Pe[q]=N||D===1&&X?null:A.getComponent(),C[q]=S.clone(),U&&(I[q]=U.clone())):ee.r!==void 0&&(N||A.write("r",!0),(N||X)&&(Ue==null&&(Ue=new Set),Ue.add(ee)))}let fe=0,de=0;const le=i.advancer(B,void 0,(q,P)=>{O(P)&&fe++}),ye=i.advancer(U,(q,P)=>o(P)?~(q-de):q-de,(q,P)=>{o(P)&&de++});if(S)for(const q of S)if(typeof q=="string"){const P=le(q),x=ye(q);A.descend(q),Q(S,P,x,A,N),A.ascend()}else{const P=le(q),x=q-fe,he=O(a(P))?null:ye(x),me=x+de;l(me>=0),A.descend(me),Q(S,P,he,A,N),A.ascend()}le.end(),ye.end()})(be,_e,_e.clone(),oe,null),oe.reset();let Le=[];if(function Q(S,B,U,A,N,X){l(B);const Z=B.getComponent();let ee=a(A),fe=!1;const de=(R,ie,Oe)=>R?n.moveOp(R.getPath(),ie.getPath()):n.insertOp(ie.getPath(),Oe.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=B.clone());const ie=R!=null?Pe[R]:null;let Oe=!1;if(Z.i!==void 0||R!=null&&ie){let ce;ee&&(ee.i!==void 0||(ce=ee.d)!=null&&!g[ce])&&(Oe=ce!=null?R!=null&&R===K[ce]:t.default(ee.i,Z.i),Oe||ce!=null&&D!==1&&K[ce]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:de(R!=null?C[R]:null,B,Z),op2:de(ce!=null?T[ce]:null,A,ee)})),Oe||(X?b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:de(R!=null?C[R]:null,B,Z),op2:n.removeOp(X.getPath())}):(R!=null?(Le[ke]=R,N.write("d",ie.p=ke++)):N.write("i",s.default(Z.i)),fe=!0))}else if(R!=null&&!ie){const ce=k[R];ce&&(X=ce.clone())}R!=null?(S=C[R],U=m[R],A=I[R]):Z.i!==void 0&&(S=U=null,Oe||(A=null))}else O(a(S))&&(S=U=A=null);const le=a(S),ye=a(U);if(O(ye)){const R=ye.p;ye.r!==void 0&&(!le||le.r===void 0)||g[R]?(A=null,X=U.clone()):R!=null&&(A=p[R],D!==1&&K[R]!=null||((N=te[R])||(N=te[R]=i.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(ee)&&(A=null);ee=A!=null?A.getComponent():null;const q=ve(Z);if(q){const R=f(Z);if(X)b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.editOp(B.getPath(),q,R,!0),op2:n.removeOp(X.getPath())});else{const ie=ve(ee);let Oe;if(ie){if(q!==ie)throw Error("Transforming incompatible types");const ce=f(ee);Oe=q.transform(R,ce,y)}else Oe=s.default(R);_(N,q,Oe)}}let P=0,x=0,he=0,me=0,We=0,He=0,Me=S!=null&&S.descendFirst(),Ye=Me;const ze=i.advancer(U,void 0,(R,ie)=>{O(ie)&&he++});let Re=A!=null&&A.descendFirst(),Te=Re;for(const R of B)if(typeof R=="number"){let ie;const Oe=o(B.getComponent()),ce=R-x;{let Be;for(;Me&&typeof(Be=S.getKey())=="number";){Be+=P;const je=S.getComponent(),Xe=O(je);if(Be>ce||Be===ce&&(!Xe||D===0&&Oe))break;if(Xe){P--;const Ke=je.p;K.includes(Ke),je.d,a(te[je.d]),O(a(te[je.d])),(je.r===void 0||Ue&&Ue.has(je))&&(Ke==null||!Pe[Ke]||D!==1&&K.includes(Ke))||We--}Me=S.nextSibling()}ie=Me&&Be===ce?S:null}const Ne=ce-P;let Ge=ze(Ne);const st=Ne-he;let et=null;{let Be,je;for(;Re&&typeof(Be=A.getKey())=="number";){je=Be-me;const Xe=A.getComponent(),Ke=o(Xe);if(je>st)break;if(je===st){if(!Ke){et=A;break}{if(D===0&&Oe){et=A;break}const Fe=Ge&&O(Ge.getComponent());if(D===0&&Fe)break}}if(Ke){const Fe=Xe.d;K[Fe],Xe.i===void 0&&(g[Fe]||K[Fe]!=null&&D!==1)?(g[Fe]||K[Fe]!=null&&D===0)&&(me++,He--):me++}Re=A.nextSibling()}}const yt=st+me+We+He;l(yt>=0,"trying to descend to a negative index"),N.descend(yt),Oe&&(ie=Ge=et=null,x++),Q(ie,B,Ge,et,N,X)&&He++,N.ascend()}else{let ie;for(;Me&&(ie=S.getKey(),typeof ie!="string"||!(ie>R||ie===R));)Me=S.nextSibling();const Oe=Me&&ie===R?S:null,ce=ze(R);let Ne;for(;Re&&(Ne=A.getKey(),typeof Ne!="string"||!(Ne>R||Ne===R));)Re=A.nextSibling();const Ge=Re&&Ne===R?A:null;N.descend(R),Q(Oe,B,ce,Ge,N,X),N.ascend()}return ze.end(),Ye&&S.ascend(),Te&&A.ascend(),fe}(be,be.clone(),_e,_e.clone(),oe,null),b)return{ok:!1,conflict:b};oe.reset();const Se=(Q,S,B)=>Q.traverse(S,(U,A)=>{U.d!=null&&B(U.d,Q,A)});(g.length||re.length)&&(Se(_e,oe,(Q,S,B)=>{g[Q]&&!M[Q]&&B.write("r",!0),re[Q]&&B.mergeTree(re[Q].get())}),oe.reset());const Ee=[],$e=[];if((te.length||g.length)&&!b){const Q=i.readCursor(rt(oe.get()));if(Se(Q,null,(S,B)=>{Ee[S]=B.clone()}),te.forEach(S=>{S&&Se(i.readCursor(S.get()),null,(B,U)=>{Ee[B]=U.clone()})}),function S(B,U,A,N,X,Z){const ee=a(U);if(ee&&O(ee))if(ee.p!=null){const P=ee.p;Ee[P].getPath(),A=Ee[P],N=$e[P]=i.writeCursor()}else ee.r!==void 0&&(A=null);else o(a(A))&&(A=null);const fe=B.getComponent();if(fe){let P;if((P=fe.d)!=null){const x=te[P];x&&(x.get(),N.mergeTree(x.get()),A=i.readCursor(x.get()))}}let de=0,le=0;const ye=i.advancer(U,void 0,(P,x)=>{O(x)&&de--}),q=i.advancer(A,(P,x)=>o(x)?-(P-le)-1:P-le,(P,x)=>{o(x)&&le++});for(const P of B)if(typeof P=="number"){const x=ye(P),he=P+de,me=q(he),We=he+le;N.descend(We),S(B,x,me,N),N.ascend()}else N.descend(P),S(B,ye(P),q(P),N),N.ascend();ye.end(),q.end()}(_e,Q,Q.clone(),oe),oe.reset(),b)return{ok:!1,conflict:b};if(oe.get(),$e.length){const S=$e.map(U=>U?U.get():null),B=i.readCursor(rt(oe.get()));if(Se(B,oe,(U,A,N)=>{const X=S[U];X&&(N.mergeTree(X),S[U]=null)}),S.find(U=>U)){const U=i.writeCursor(),A=i.writeCursor();let N=0,X=0;S.forEach(Z=>{Z!=null&&Se(i.readCursor(Z),null,ee=>{const fe=Le[ee];U.writeMove(C[fe].getPath(),$[fe].getPath(),N++);const de=se[fe];de&&de.forEach(le=>{g[le]||D!==1&&K[le]!=null||A.writeMove(T[le].getPath(),p[le].getPath(),X++)})})}),b={type:d.ConflictType.BLACKHOLE,op1:U.get(),op2:A.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:oe.get()}}const Ot=r=>{const u=new Error("Transform detected write conflict");throw u.conflict=r,u.type=u.name="writeConflict",u};function Tt(r,u,y){const D=it(r,u,y);if(D.ok)return D.result;Ot(D.conflict)}const qe=r=>{const u=i.writeCursor();return i.readCursor(r).traverse(u,(y,D)=>{(o(y)||ve(y))&&D.write("r",!0)}),u.get()},kt=(r,u)=>{const{type:y,op1:D,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return u==="left"?[null,qe(b)]:[qe(D),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return i.readCursor(D).traverse(null,$=>{$.r!==void 0&&(C=!0)}),C?[null,qe(b)]:[qe(D),null];case d.ConflictType.BLACKHOLE:return[qe(D),qe(b)];default:throw Error("Unrecognised conflict: "+y)}};function vt(r,u,y,D){let b=null;for(;;){const C=it(u,y,D);if(C.ok)return ne(b,C.result);{const{conflict:$}=C;r($)||Ot($);const[T,p]=kt($,D);u=ne(H(u),T),y=ne(H(y),p),b=ne(b,p)}}}})(Dt);(function(n){var e=Ce&&Ce.__createBinding||(Object.create?function(d,l,a,E){E===void 0&&(E=a),Object.defineProperty(d,E,{enumerable:!0,get:function(){return l[a]}})}:function(d,l,a,E){E===void 0&&(E=a),d[E]=l[a]}),t=Ce&&Ce.__exportStar||function(d,l){for(var a in d)a!=="default"&&!l.hasOwnProperty(a)&&e(l,d,a)};Object.defineProperty(n,"__esModule",{value:!0}),t(Dt,n);var s=pt;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var i=gt;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})})(V);class At{constructor(){F(this,"drawingManagerData",{});F(this,"_oldDrawingManagerData",{});F(this,"_focusDrawings",[]);F(this,"_remove$",new we.Subject);F(this,"remove$",this._remove$.asObservable());F(this,"_add$",new we.Subject);F(this,"add$",this._add$.asObservable());F(this,"_update$",new we.Subject);F(this,"update$",this._update$.asObservable());F(this,"_order$",new we.Subject);F(this,"order$",this._order$.asObservable());F(this,"_group$",new we.Subject);F(this,"group$",this._group$.asObservable());F(this,"_ungroup$",new we.Subject);F(this,"ungroup$",this._ungroup$.asObservable());F(this,"_refreshTransform$",new we.Subject);F(this,"refreshTransform$",this._refreshTransform$.asObservable());F(this,"_visible$",new we.Subject);F(this,"visible$",this._visible$.asObservable());F(this,"_focus$",new we.Subject);F(this,"focus$",this._focus$.asObservable());F(this,"_featurePluginUpdate$",new we.Subject);F(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());F(this,"_featurePluginAdd$",new we.Subject);F(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());F(this,"_featurePluginRemove$",new we.Subject);F(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());F(this,"_featurePluginOrderUpdate$",new we.Subject);F(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());F(this,"_featurePluginGroupUpdate$",new we.Subject);F(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());F(this,"_featurePluginUngroupUpdate$",new we.Subject);F(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());F(this,"_visible",!0);F(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(t=>{if(this.getDrawingByParam(t)==null)return;const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]}removeDrawingDataForUnit(e){const t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];const s=[];Object.keys(t).forEach(i=>{const d=t[i];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(l=>{s.push({unitId:e,subUnitId:i,drawingId:l})})}),s.length>0&&this.removeNotification(s)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){const t=[],s=this.drawingManagerData[e];s!=null&&(Object.keys(s).forEach(i=>{this._establishDrawingMap(e,i);const d=s[i];Object.keys(d.data).forEach(l=>{const a=d.data[l];a.unitId=e,a.subUnitId=i,t.push(a)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}getBatchAddOp(e){const t=[],s=[],i=[];e.forEach(W=>{const{op:O,invertOp:o}=this._addByParam(W);t.push({unitId:W.unitId,subUnitId:W.subUnitId,drawingId:W.drawingId}),s.push(O),i.push(o)});const d=s.reduce(V.type.compose,null),l=i.reduce(V.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],s=[];e.forEach(E=>{const{op:W,invertOp:O}=this._removeByParam(E);t.push(W),s.push(O)});const i=t.reduce(V.type.compose,null),d=s.reduce(V.type.compose,null),{unitId:l,subUnitId:a}=e[0];return{undo:d,redo:i,unitId:l,subUnitId:a,objects:e}}getBatchUpdateOp(e){const t=[],s=[],i=[];e.forEach(W=>{const{op:O,invertOp:o}=this._updateByParam(W);t.push({unitId:W.unitId,subUnitId:W.subUnitId,drawingId:W.drawingId}),s.push(O),i.push(o)});const d=s.reduce(V.type.compose,null),l=i.reduce(V.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getGroupDrawingOp(a))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getUngroupDrawingOp(a))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:s,drawingId:i}=e;if(this.getDrawingByParam({unitId:t,subUnitId:s,drawingId:i})==null)return[];const l=this._getDrawingData(t,s),a=[];return Object.keys(l).forEach(E=>{const W=l[E];W.groupId===i&&a.push(W)}),a}_getGroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];a.push(V.insertOp([i,d,"data",l],t));let E=Number.NEGATIVE_INFINITY;return s.forEach(W=>{const{unitId:O,subUnitId:o,drawingId:c}=W,h=this._hasDrawingOrder({unitId:O,subUnitId:o,drawingId:c});E=Math.max(E,h),a.push(...this._getUpdateParamCompareOp(W,this.getDrawingByParam({unitId:O,subUnitId:o,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(i,d).length),a.push(V.insertOp([i,d,"order",E],l)),a.reduce(V.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];return s.forEach(E=>{const{unitId:W,subUnitId:O,drawingId:o}=E;a.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:W,subUnitId:O,drawingId:o})))}),a.push(V.removeOp([i,d,"data",l],!0)),a.push(V.removeOp([i,d,"order",this._getDrawingOrder(i,d).indexOf(l)],!0)),a.reduce(V.type.compose,null)}applyJson1(e,t,s){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=V.type.apply(this.drawingManagerData,s)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[t,s,i]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:s,drawingId:i})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(s=>{var E;const{unitId:i,subUnitId:d,drawingId:l}=s,a=(E=this._getDrawingData(i,d))==null?void 0:E[l];a!=null&&t.push(a)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var a;const{unitId:s,subUnitId:i,drawingId:d}=t,l=(a=this._getDrawingData(s,i))==null?void 0:a[d];l!=null&&e.push(l)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(O=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:O});if(o===-1||o===l.length-1)return;const c=V.moveOp([t,s,"order",o],[t,s,"order",o+1]);d.push(c),a.includes(l[o+1])||a.push(l[o+1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(O=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:O});if(o===-1||o===0)return;const c=V.moveOp([t,s,"order",o],[t,s,"order",o-1]);d.push(c),a.includes(l[o-1])||a.push(l[o-1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:c}=o,h=this._getDrawingCount(t,s)-1,j=V.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(c)],[t,s,"order",h]);E.push(j),l.includes(a[h])||l.push(a[h])});const W=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(W,this.drawingManagerData),redo:W,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i,!0),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:c}=o,h=V.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(c)],[t,s,"order",0]);E.push(h),l.includes(a[0])||l.push(a[0])});const W=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(W,this.drawingManagerData),redo:W,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,s,i=!1){return s.map(d=>{const l=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:l}}).sort(i===!1?Qe.sortRules:Qe.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:s,drawingId:i}=e;return this._establishDrawingMap(t,s),this._getDrawingOrder(t,s).indexOf(i)}_getCurrentBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this.drawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_getOldBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this._oldDrawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_establishDrawingMap(e,t,s){var i;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),s==null?null:(i=this.drawingManagerData[e][t].data)==null?void 0:i[s]}_addByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e;this._establishDrawingMap(t,s,i);const d=V.insertOp([t,s,"data",i],e),l=V.insertOp([t,s,"order",this._getDrawingOrder(t,s).length],i),a=[d,l].reduce(V.type.compose,null),E=V.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:s,drawingId:i}=e;if(this._establishDrawingMap(t,s,i)==null)return{op:[],invertOp:[]};const l=V.removeOp([t,s,"data",i],!0),a=V.removeOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(i)],!0),E=[l,a].reduce(V.type.compose,null),W=V.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:W}}_updateByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e,d=this._establishDrawingMap(t,s,i);if(d==null)return{op:[],invertOp:[]};const a=this._getUpdateParamCompareOp(e,d).reduce(V.type.compose,null),E=V.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:s,subUnitId:i,drawingId:d}=e,l=[];return Object.keys(e).forEach(a=>{const E=e[a],W=t[a];W!==E&&l.push(V.replaceOp([s,i,"data",d,a],W,E))}),l}_getDrawingData(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.data)||{}}_getDrawingOrder(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Pt extends At{}function Vt(n){const{unitId:e,subUnitId:t,drawingId:s}=n;return`${e}#-#${t}#-#${s}`}const qt=async n=>new Promise((e,t)=>{const s=new Image;s.src=n,s.onload=()=>{e({width:s.width,height:s.height,image:s})},s.onerror=i=>{t(i)}});var Je=(n=>(n.URL="URL",n.UUID="UUID",n.BASE64="BASE64",n))(Je||{}),Ze=(n=>(n.SUCCUSS="0",n.ERROR_EXCEED_SIZE="1",n.ERROR_IMAGE_TYPE="2",n.ERROR_UPLOAD_COUNT_LIMIT="3",n.ERROR_IMAGE="4",n))(Ze||{});const St=nt.createIdentifier("core.image-io.service");class Ut{constructor(){F(this,"_waitCount",0);F(this,"_change$",new we.Subject);F(this,"change$",this._change$);F(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Je.BASE64){const s=new Image;return s.src=e,s}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,s){t===Je.BASE64||s==null||this._imageSourceCache.set(e,s)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,s)=>{if(!Et.includes(e.type)){s(new Error(Ze.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>Ct){s(new Error(Ze.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const i=new FileReader;i.readAsDataURL(e),i.onload=d=>{var E;const l=(E=d.target)==null?void 0:E.result;if(l==null){s(new Error(Ze.ERROR_IMAGE)),this._decreaseWaiting();return}const a=Qe.Tools.generateRandomId(6);t({imageId:a,imageSourceType:Je.BASE64,source:l,base64Cache:l,status:Ze.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const zt="__default_document_sub_component_id20231101__";var Mt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Mt||{}),Nt=(n=>(n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n[n.DRAWING_IMAGE=0]="DRAWING_IMAGE",n[n.DRAWING_SHAPE=1]="DRAWING_SHAPE",n[n.DRAWING_CHART=2]="DRAWING_CHART",n[n.DRAWING_TABLE=3]="DRAWING_TABLE",n[n.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",n[n.DRAWING_VIDEO=5]="DRAWING_VIDEO",n[n.DRAWING_GROUP=6]="DRAWING_GROUP",n[n.DRAWING_UNIT=7]="DRAWING_UNIT",n[n.DRAWING_DOM=8]="DRAWING_DOM",n))(Nt||{});const jt=nt.createIdentifier("univer.drawing-manager.service");var Xt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Yt=(n,e,t,s)=>{for(var i=s>1?void 0:s?Zt(e,t):e,d=n.length-1,l;d>=0;d--)(l=n[d])&&(i=(s?l(e,t,i):l(i))||i);return s&&i&&Xt(e,t,i),i},Jt=(n,e)=>(t,s)=>e(t,s,n);const Qt="DRAWING_PLUGIN";var at;exports.UniverDrawingPlugin=(at=class extends Qe.Plugin{constructor(e,t){super(),this._config=e,this._injector=t}onStarting(e){this._initDependencies(e)}_initDependencies(e){var i;const t=[[St,{useClass:Ut}],[jt,{useClass:Pt}]];Qe.mergeOverrideWithDependencies(t,(i=this._config)==null?void 0:i.override).forEach(d=>e.add(d))}},F(at,"pluginName",Qt),at);exports.UniverDrawingPlugin=Yt([Jt(1,nt.Inject(nt.Injector))],exports.UniverDrawingPlugin);exports.ArrangeTypeEnum=Mt;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=zt;exports.DRAWING_IMAGE_ALLOW_IMAGE_LIST=Et;exports.DRAWING_IMAGE_ALLOW_SIZE=Ct;exports.DRAWING_IMAGE_COUNT_LIMIT=xt;exports.DRAWING_IMAGE_HEIGHT_LIMIT=Bt;exports.DRAWING_IMAGE_WIDTH_LIMIT=Gt;exports.DrawingManagerService=Pt;exports.DrawingTypeEnum=Nt;exports.IDrawingManagerService=jt;exports.IImageIoService=St;exports.ImageIoService=Ut;exports.ImageSourceType=Je;exports.ImageUploadStatusType=Ze;exports.UnitDrawingService=At;exports.getDrawingShapeKeyByDrawingSearch=Vt;exports.getImageSize=qt;
|
package/lib/es/index.js
CHANGED
|
@@ -334,8 +334,8 @@ function at() {
|
|
|
334
334
|
};
|
|
335
335
|
function s(f, _) {
|
|
336
336
|
let w = 0, L = 0;
|
|
337
|
-
for (let
|
|
338
|
-
const H = f[
|
|
337
|
+
for (let z = 0; z < f.length; z++) {
|
|
338
|
+
const H = f[z];
|
|
339
339
|
switch (_(H, w, L), typeof H) {
|
|
340
340
|
case "object":
|
|
341
341
|
w += t.dlen(H.d);
|
|
@@ -352,8 +352,8 @@ function at() {
|
|
|
352
352
|
t.eachOp = s;
|
|
353
353
|
function i(f, _) {
|
|
354
354
|
const w = [], L = a(w);
|
|
355
|
-
return s(f, (
|
|
356
|
-
L(_(
|
|
355
|
+
return s(f, (z, H, Ae) => {
|
|
356
|
+
L(_(z, H, Ae));
|
|
357
357
|
}), o(w);
|
|
358
358
|
}
|
|
359
359
|
const d = (f) => f, l = (f) => i(f, d);
|
|
@@ -371,8 +371,8 @@ function at() {
|
|
|
371
371
|
f.push(_);
|
|
372
372
|
}, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d);
|
|
373
373
|
t.uniSlice = (f, _, w) => {
|
|
374
|
-
const L = e.uniToStrPos(f, _),
|
|
375
|
-
return f.slice(L,
|
|
374
|
+
const L = e.uniToStrPos(f, _), z = w == null ? 1 / 0 : e.uniToStrPos(f, w);
|
|
375
|
+
return f.slice(L, z);
|
|
376
376
|
};
|
|
377
377
|
const W = (f, _, w) => typeof f == "number" ? w == null ? f - _ : Math.min(f, w) - _ : t.uniSlice(f, _, w), O = (f) => {
|
|
378
378
|
let _ = 0, w = 0;
|
|
@@ -404,17 +404,17 @@ function at() {
|
|
|
404
404
|
if (w !== "left" && w !== "right")
|
|
405
405
|
throw Error("side (" + w + ") must be 'left' or 'right'");
|
|
406
406
|
n(f), n(_);
|
|
407
|
-
const L = [],
|
|
407
|
+
const L = [], z = a(L), { take: H, peek: Ae } = O(f);
|
|
408
408
|
for (let ne = 0; ne < _.length; ne++) {
|
|
409
409
|
const ae = _[ne];
|
|
410
410
|
let ge, Pe;
|
|
411
411
|
switch (typeof ae) {
|
|
412
412
|
case "number":
|
|
413
413
|
for (ge = ae; ge > 0; )
|
|
414
|
-
Pe = H(ge, "i"),
|
|
414
|
+
Pe = H(ge, "i"), z(Pe), typeof Pe != "string" && (ge -= E(Pe));
|
|
415
415
|
break;
|
|
416
416
|
case "string":
|
|
417
|
-
w === "left" && typeof Ae() == "string" &&
|
|
417
|
+
w === "left" && typeof Ae() == "string" && z(H(-1)), z(e.strPosToUni(ae));
|
|
418
418
|
break;
|
|
419
419
|
case "object":
|
|
420
420
|
for (ge = t.dlen(ae.d); ge > 0; )
|
|
@@ -423,7 +423,7 @@ function at() {
|
|
|
423
423
|
ge -= Pe;
|
|
424
424
|
break;
|
|
425
425
|
case "string":
|
|
426
|
-
|
|
426
|
+
z(Pe);
|
|
427
427
|
break;
|
|
428
428
|
case "object":
|
|
429
429
|
ge -= t.dlen(Pe.d);
|
|
@@ -433,19 +433,19 @@ function at() {
|
|
|
433
433
|
}
|
|
434
434
|
let ue;
|
|
435
435
|
for (; ue = H(-1); )
|
|
436
|
-
|
|
436
|
+
z(ue);
|
|
437
437
|
return o(L);
|
|
438
438
|
}
|
|
439
439
|
function h(f, _) {
|
|
440
440
|
n(f), n(_);
|
|
441
|
-
const w = [], L = a(w), { take:
|
|
441
|
+
const w = [], L = a(w), { take: z } = O(f);
|
|
442
442
|
for (let Ae = 0; Ae < _.length; Ae++) {
|
|
443
443
|
const ue = _[Ae];
|
|
444
444
|
let ne, ae;
|
|
445
445
|
switch (typeof ue) {
|
|
446
446
|
case "number":
|
|
447
447
|
for (ne = ue; ne > 0; )
|
|
448
|
-
ae =
|
|
448
|
+
ae = z(ne, "d"), L(ae), typeof ae != "object" && (ne -= E(ae));
|
|
449
449
|
break;
|
|
450
450
|
case "string":
|
|
451
451
|
L(ue);
|
|
@@ -454,7 +454,7 @@ function at() {
|
|
|
454
454
|
ne = t.dlen(ue.d);
|
|
455
455
|
let ge = 0;
|
|
456
456
|
for (; ge < ne; )
|
|
457
|
-
switch (ae =
|
|
457
|
+
switch (ae = z(ne - ge, "d"), typeof ae) {
|
|
458
458
|
case "number":
|
|
459
459
|
L({ d: W(ue.d, ge, ge + ae) }), ge += ae;
|
|
460
460
|
break;
|
|
@@ -468,32 +468,32 @@ function at() {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
let H;
|
|
471
|
-
for (; H =
|
|
471
|
+
for (; H = z(-1); )
|
|
472
472
|
L(H);
|
|
473
473
|
return o(w);
|
|
474
474
|
}
|
|
475
475
|
const R = (f, _) => {
|
|
476
476
|
let w = 0;
|
|
477
477
|
for (let L = 0; L < _.length && f > w; L++) {
|
|
478
|
-
const
|
|
479
|
-
switch (typeof
|
|
478
|
+
const z = _[L];
|
|
479
|
+
switch (typeof z) {
|
|
480
480
|
case "number": {
|
|
481
|
-
w +=
|
|
481
|
+
w += z;
|
|
482
482
|
break;
|
|
483
483
|
}
|
|
484
484
|
case "string":
|
|
485
|
-
const H = e.strPosToUni(
|
|
485
|
+
const H = e.strPosToUni(z);
|
|
486
486
|
w += H, f += H;
|
|
487
487
|
break;
|
|
488
488
|
case "object":
|
|
489
|
-
f -= Math.min(t.dlen(
|
|
489
|
+
f -= Math.min(t.dlen(z.d), f - w);
|
|
490
490
|
break;
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
return f;
|
|
494
494
|
}, Z = (f, _) => typeof f == "number" ? R(f, _) : f.map((w) => R(w, _));
|
|
495
495
|
function pe(f, _, w) {
|
|
496
|
-
return i(f, (L,
|
|
496
|
+
return i(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: w.slice(_, z, z + L.d) } : L);
|
|
497
497
|
}
|
|
498
498
|
function J(f) {
|
|
499
499
|
return i(f, (_) => {
|
|
@@ -540,8 +540,8 @@ function at() {
|
|
|
540
540
|
apply(_, w) {
|
|
541
541
|
n(w);
|
|
542
542
|
const L = f.builder(_);
|
|
543
|
-
for (let
|
|
544
|
-
const H = w[
|
|
543
|
+
for (let z = 0; z < w.length; z++) {
|
|
544
|
+
const H = w[z];
|
|
545
545
|
switch (typeof H) {
|
|
546
546
|
case "number":
|
|
547
547
|
L.skip(H);
|
|
@@ -702,7 +702,7 @@ function Lt() {
|
|
|
702
702
|
setDebug(r) {
|
|
703
703
|
},
|
|
704
704
|
registerSubtype: J,
|
|
705
|
-
checkValidOp:
|
|
705
|
+
checkValidOp: z,
|
|
706
706
|
normalize: H,
|
|
707
707
|
apply: Ae,
|
|
708
708
|
transformPosition: ue,
|
|
@@ -763,7 +763,7 @@ function Lt() {
|
|
|
763
763
|
function L(r) {
|
|
764
764
|
typeof r == "number" ? w(r) : l(typeof r == "string");
|
|
765
765
|
}
|
|
766
|
-
function
|
|
766
|
+
function z(r) {
|
|
767
767
|
if (r === null) return;
|
|
768
768
|
const u = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), A = (C) => {
|
|
769
769
|
let $ = !0, j = !1;
|
|
@@ -816,7 +816,7 @@ function Lt() {
|
|
|
816
816
|
}), A.get();
|
|
817
817
|
}
|
|
818
818
|
function Ae(r, u) {
|
|
819
|
-
if (
|
|
819
|
+
if (z(u), u === null) return r;
|
|
820
820
|
const y = [];
|
|
821
821
|
return function A(b, C) {
|
|
822
822
|
let $ = b, j = 0, p = {
|
|
@@ -862,7 +862,7 @@ function Lt() {
|
|
|
862
862
|
}(r, u), u);
|
|
863
863
|
}
|
|
864
864
|
function ue(r, u) {
|
|
865
|
-
r = r.slice(),
|
|
865
|
+
r = r.slice(), z(u);
|
|
866
866
|
const y = i.readCursor(u);
|
|
867
867
|
let A, b, C = !1;
|
|
868
868
|
const $ = [];
|
|
@@ -903,7 +903,7 @@ function Lt() {
|
|
|
903
903
|
}) : j(), r;
|
|
904
904
|
}
|
|
905
905
|
function ne(r, u) {
|
|
906
|
-
if (
|
|
906
|
+
if (z(r), z(u), r == null) return u;
|
|
907
907
|
if (u == null) return r;
|
|
908
908
|
let y = 0;
|
|
909
909
|
const A = i.readCursor(r), b = i.readCursor(u), C = i.writeCursor(), $ = [], j = [], p = [], v = [], m = [], I = [], T = /* @__PURE__ */ new Set();
|
|
@@ -949,7 +949,7 @@ function Lt() {
|
|
|
949
949
|
_(be, M, he), T.add(Q);
|
|
950
950
|
} else M ? _(be, M, f(oe)) : P && (_(be, P, f(Q)), T.add(Q));
|
|
951
951
|
const k = typeof U == "object" && U != null;
|
|
952
|
-
let
|
|
952
|
+
let X = !1, Y = 0, ee = 0, fe = 0, de = 0, le = 0;
|
|
953
953
|
const ye = i.advancer(K, (D, x) => o(x) ? de - D - 1 : D - de, (D, x) => {
|
|
954
954
|
o(x) && de++;
|
|
955
955
|
}), q = i.advancer(N, (D, x) => O(x) ? Y - D - 1 : D - Y, (D, x) => {
|
|
@@ -966,9 +966,9 @@ function Lt() {
|
|
|
966
966
|
(ke || Ge && !$e) && le--, ke && ee--, Ge && fe--;
|
|
967
967
|
} else me = q(D), We = ye(D);
|
|
968
968
|
_e.descend(He), be.descend(Ne);
|
|
969
|
-
const
|
|
969
|
+
const ze = k && !o(a(x)) ? U[Ye] : void 0, Se = g(me, x, he, We, ze, $e, be, _e);
|
|
970
970
|
var je, S, ie;
|
|
971
|
-
k && !$e ?
|
|
971
|
+
k && !$e ? ze !== Se && (X || (U = Array.isArray(U) ? U.slice() : Object.assign({}, U), X = !0), je = U, ie = Se, typeof (S = Ye) == "number" ? (l(Array.isArray(je)), l(S < je.length)) : (l(!Array.isArray(je)), l(je[S] !== void 0)), ie === void 0 ? typeof S == "number" ? je.splice(S, 1) : delete je[S] : je[S] = ie) : l(Se === void 0), be.ascend(), _e.ascend();
|
|
972
972
|
}), q.end(), ye.end(), B != null) B.i = U;
|
|
973
973
|
else if (!Te && !Me && Ee == null) return U;
|
|
974
974
|
}(A, A.clone(), b, b.clone(), void 0, !1, C, G), C.reset(), C.mergeTree(G.get()), C.reset(), C.get(), $.map((g) => g.get()), j.map((g) => g.get()), A.traverse(C, (g, N) => {
|
|
@@ -1114,7 +1114,7 @@ function Lt() {
|
|
|
1114
1114
|
ok: !0,
|
|
1115
1115
|
result: r
|
|
1116
1116
|
};
|
|
1117
|
-
|
|
1117
|
+
z(r), z(u);
|
|
1118
1118
|
let b = null;
|
|
1119
1119
|
const C = [], $ = [], j = [], p = [], v = [], m = [], I = [], T = [], G = [], g = [], N = [], re = [], te = [], K = [], se = [];
|
|
1120
1120
|
let Te = 0;
|
|
@@ -1123,30 +1123,30 @@ function Lt() {
|
|
|
1123
1123
|
const P = a(B);
|
|
1124
1124
|
P && (P.r !== void 0 ? M = B.clone() : P.p != null && (M = null, m[P.p] = U.clone()));
|
|
1125
1125
|
const k = U.getComponent();
|
|
1126
|
-
let
|
|
1127
|
-
k && (
|
|
1126
|
+
let X;
|
|
1127
|
+
k && (X = k.p) != null && (v[X] = B ? B.clone() : null, j[X] = U.clone(), M && (g[X] = !0, G[X] = M), P && P.p != null && (K[X] = P.p));
|
|
1128
1128
|
const Y = i.advancer(B);
|
|
1129
1129
|
for (const ee of U) Q(U, Y(ee), M);
|
|
1130
1130
|
Y.end();
|
|
1131
1131
|
}(_e, be, null), function Q(U, B, M, P, k) {
|
|
1132
|
-
const
|
|
1132
|
+
const X = M.getComponent();
|
|
1133
1133
|
let Y, ee = !1;
|
|
1134
|
-
|
|
1134
|
+
X && ((Y = X.d) != null ? (p[Y] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(Y)), U = v[Y] || null, B = j[Y] || null, g[Y] ? (k && (N[Y] = !0), k = G[Y] || null) : !k || A !== 1 && K[Y] != null || b == null && (b = {
|
|
1135
1135
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1136
1136
|
op1: t.removeOp(k.getPath()),
|
|
1137
1137
|
op2: t.moveOp(B.getPath(), M.getPath())
|
|
1138
|
-
}), ee = !0) :
|
|
1138
|
+
}), ee = !0) : X.i !== void 0 && (U = B = null, ee = !0, k && b == null && (b = {
|
|
1139
1139
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1140
1140
|
op1: t.removeOp(k.getPath()),
|
|
1141
|
-
op2: t.insertOp(M.getPath(),
|
|
1141
|
+
op2: t.insertOp(M.getPath(), X.i)
|
|
1142
1142
|
})));
|
|
1143
1143
|
const fe = a(U);
|
|
1144
1144
|
fe && (fe.r !== void 0 ? k = U.clone() : fe.p != null && (fe.p, P = fe.p, k = null));
|
|
1145
|
-
const de = ve(
|
|
1145
|
+
const de = ve(X);
|
|
1146
1146
|
de && k && b == null && (b = {
|
|
1147
1147
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1148
1148
|
op1: t.removeOp(k.getPath()),
|
|
1149
|
-
op2: t.editOp(M.getPath(), de, f(
|
|
1149
|
+
op2: t.editOp(M.getPath(), de, f(X), !0)
|
|
1150
1150
|
});
|
|
1151
1151
|
let le = 0, ye = 0;
|
|
1152
1152
|
const q = i.advancer(B, (x, he) => O(he) ? le - x - 1 : x - le, (x, he) => {
|
|
@@ -1168,16 +1168,16 @@ function Lt() {
|
|
|
1168
1168
|
const De = [];
|
|
1169
1169
|
let Me = null;
|
|
1170
1170
|
(function Q(U, B, M, P, k) {
|
|
1171
|
-
let
|
|
1171
|
+
let X = !1;
|
|
1172
1172
|
const Y = a(B);
|
|
1173
1173
|
if (O(Y)) {
|
|
1174
1174
|
const q = Y.p;
|
|
1175
|
-
q != null ? (M = p[q], P = re[q] = i.writeCursor(),
|
|
1175
|
+
q != null ? (M = p[q], P = re[q] = i.writeCursor(), X = !0, k = null) : (M = null, k = B.clone());
|
|
1176
1176
|
} else o(a(M)) && (M = null);
|
|
1177
1177
|
const ee = U.getComponent();
|
|
1178
1178
|
if (ee) {
|
|
1179
1179
|
const q = ee.p;
|
|
1180
|
-
q != null ? (k && (T[q] = k), De[q] = k || A === 1 &&
|
|
1180
|
+
q != null ? (k && (T[q] = k), De[q] = k || A === 1 && X ? null : P.getComponent(), C[q] = U.clone(), M && (I[q] = M.clone())) : ee.r !== void 0 && (k || P.write("r", !0), (k || X) && (Me == null && (Me = /* @__PURE__ */ new Set()), Me.add(ee)));
|
|
1181
1181
|
}
|
|
1182
1182
|
let fe = 0, de = 0;
|
|
1183
1183
|
const le = i.advancer(B, void 0, (q, D) => {
|
|
@@ -1195,7 +1195,7 @@ function Lt() {
|
|
|
1195
1195
|
le.end(), ye.end();
|
|
1196
1196
|
})(be, _e, _e.clone(), oe, null), oe.reset();
|
|
1197
1197
|
let Le = [];
|
|
1198
|
-
if (function Q(U, B, M, P, k,
|
|
1198
|
+
if (function Q(U, B, M, P, k, X) {
|
|
1199
1199
|
l(B);
|
|
1200
1200
|
const Y = B.getComponent();
|
|
1201
1201
|
let ee = a(P), fe = !1;
|
|
@@ -1211,30 +1211,30 @@ function Lt() {
|
|
|
1211
1211
|
type: d.ConflictType.DROP_COLLISION,
|
|
1212
1212
|
op1: de(S != null ? C[S] : null, B, Y),
|
|
1213
1213
|
op2: de(ce != null ? j[ce] : null, P, ee)
|
|
1214
|
-
})), Oe || (
|
|
1214
|
+
})), Oe || (X ? b == null && (b = {
|
|
1215
1215
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1216
1216
|
op1: de(S != null ? C[S] : null, B, Y),
|
|
1217
|
-
op2: t.removeOp(
|
|
1217
|
+
op2: t.removeOp(X.getPath())
|
|
1218
1218
|
}) : (S != null ? (Le[Te] = S, k.write("d", ie.p = Te++)) : k.write("i", s.default(Y.i)), fe = !0));
|
|
1219
1219
|
} else if (S != null && !ie) {
|
|
1220
1220
|
const ce = T[S];
|
|
1221
|
-
ce && (
|
|
1221
|
+
ce && (X = ce.clone());
|
|
1222
1222
|
}
|
|
1223
1223
|
S != null ? (U = C[S], M = m[S], P = I[S]) : Y.i !== void 0 && (U = M = null, Oe || (P = null));
|
|
1224
1224
|
} else O(a(U)) && (U = M = P = null);
|
|
1225
1225
|
const le = a(U), ye = a(M);
|
|
1226
1226
|
if (O(ye)) {
|
|
1227
1227
|
const S = ye.p;
|
|
1228
|
-
ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (P = null,
|
|
1228
|
+
ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (P = null, X = M.clone()) : S != null && (P = p[S], A !== 1 && K[S] != null || ((k = te[S]) || (k = te[S] = i.writeCursor()), k.reset(), X = null));
|
|
1229
1229
|
} else !o(Y) && o(ee) && (P = null);
|
|
1230
1230
|
ee = P != null ? P.getComponent() : null;
|
|
1231
1231
|
const q = ve(Y);
|
|
1232
1232
|
if (q) {
|
|
1233
1233
|
const S = f(Y);
|
|
1234
|
-
if (
|
|
1234
|
+
if (X) b == null && (b = {
|
|
1235
1235
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1236
1236
|
op1: t.editOp(B.getPath(), q, S, !0),
|
|
1237
|
-
op2: t.removeOp(
|
|
1237
|
+
op2: t.removeOp(X.getPath())
|
|
1238
1238
|
});
|
|
1239
1239
|
else {
|
|
1240
1240
|
const ie = ve(ee);
|
|
@@ -1248,7 +1248,7 @@ function Lt() {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
}
|
|
1250
1250
|
let D = 0, x = 0, he = 0, me = 0, We = 0, He = 0, Ne = U != null && U.descendFirst(), Ye = Ne;
|
|
1251
|
-
const
|
|
1251
|
+
const ze = i.advancer(M, void 0, (S, ie) => {
|
|
1252
1252
|
O(ie) && he++;
|
|
1253
1253
|
});
|
|
1254
1254
|
let Se = P != null && P.descendFirst(), je = Se;
|
|
@@ -1259,9 +1259,9 @@ function Lt() {
|
|
|
1259
1259
|
let Be;
|
|
1260
1260
|
for (; Ne && typeof (Be = U.getKey()) == "number"; ) {
|
|
1261
1261
|
Be += D;
|
|
1262
|
-
const Re = U.getComponent(),
|
|
1263
|
-
if (Be > ce || Be === ce && (!
|
|
1264
|
-
if (
|
|
1262
|
+
const Re = U.getComponent(), Xe = O(Re);
|
|
1263
|
+
if (Be > ce || Be === ce && (!Xe || A === 0 && Oe)) break;
|
|
1264
|
+
if (Xe) {
|
|
1265
1265
|
D--;
|
|
1266
1266
|
const Ke = Re.p;
|
|
1267
1267
|
K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 || Me && Me.has(Re)) && (Ke == null || !De[Ke] || A !== 1 && K.includes(Ke)) || We--;
|
|
@@ -1271,14 +1271,14 @@ function Lt() {
|
|
|
1271
1271
|
ie = Ne && Be === ce ? U : null;
|
|
1272
1272
|
}
|
|
1273
1273
|
const ke = ce - D;
|
|
1274
|
-
let Ge =
|
|
1274
|
+
let Ge = ze(ke);
|
|
1275
1275
|
const rt = ke - he;
|
|
1276
1276
|
let Je = null;
|
|
1277
1277
|
{
|
|
1278
1278
|
let Be, Re;
|
|
1279
1279
|
for (; Se && typeof (Be = P.getKey()) == "number"; ) {
|
|
1280
1280
|
Re = Be - me;
|
|
1281
|
-
const
|
|
1281
|
+
const Xe = P.getComponent(), Ke = o(Xe);
|
|
1282
1282
|
if (Re > rt) break;
|
|
1283
1283
|
if (Re === rt) {
|
|
1284
1284
|
if (!Ke) {
|
|
@@ -1295,24 +1295,24 @@ function Lt() {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
1297
|
if (Ke) {
|
|
1298
|
-
const Ve =
|
|
1299
|
-
K[Ve],
|
|
1298
|
+
const Ve = Xe.d;
|
|
1299
|
+
K[Ve], Xe.i === void 0 && (g[Ve] || K[Ve] != null && A !== 1) ? (g[Ve] || K[Ve] != null && A === 0) && (me++, He--) : me++;
|
|
1300
1300
|
}
|
|
1301
1301
|
Se = P.nextSibling();
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
1304
|
const Ot = rt + me + We + He;
|
|
1305
|
-
l(Ot >= 0, "trying to descend to a negative index"), k.descend(Ot), Oe && (ie = Ge = Je = null, x++), Q(ie, B, Ge, Je, k,
|
|
1305
|
+
l(Ot >= 0, "trying to descend to a negative index"), k.descend(Ot), Oe && (ie = Ge = Je = null, x++), Q(ie, B, Ge, Je, k, X) && He++, k.ascend();
|
|
1306
1306
|
} else {
|
|
1307
1307
|
let ie;
|
|
1308
1308
|
for (; Ne && (ie = U.getKey(), typeof ie != "string" || !(ie > S || ie === S)); ) Ne = U.nextSibling();
|
|
1309
|
-
const Oe = Ne && ie === S ? U : null, ce =
|
|
1309
|
+
const Oe = Ne && ie === S ? U : null, ce = ze(S);
|
|
1310
1310
|
let ke;
|
|
1311
1311
|
for (; Se && (ke = P.getKey(), typeof ke != "string" || !(ke > S || ke === S)); ) Se = P.nextSibling();
|
|
1312
1312
|
const Ge = Se && ke === S ? P : null;
|
|
1313
|
-
k.descend(S), Q(Oe, B, ce, Ge, k,
|
|
1313
|
+
k.descend(S), Q(Oe, B, ce, Ge, k, X), k.ascend();
|
|
1314
1314
|
}
|
|
1315
|
-
return
|
|
1315
|
+
return ze.end(), Ye && U.ascend(), je && P.ascend(), fe;
|
|
1316
1316
|
}(be, be.clone(), _e, _e.clone(), oe, null), b) return {
|
|
1317
1317
|
ok: !1,
|
|
1318
1318
|
conflict: b
|
|
@@ -1333,7 +1333,7 @@ function Lt() {
|
|
|
1333
1333
|
U && Ue(i.readCursor(U.get()), null, (B, M) => {
|
|
1334
1334
|
Ee[B] = M.clone();
|
|
1335
1335
|
});
|
|
1336
|
-
}), function U(B, M, P, k,
|
|
1336
|
+
}), function U(B, M, P, k, X, Y) {
|
|
1337
1337
|
const ee = a(M);
|
|
1338
1338
|
if (ee && O(ee)) if (ee.p != null) {
|
|
1339
1339
|
const D = ee.p;
|
|
@@ -1366,18 +1366,18 @@ function Lt() {
|
|
|
1366
1366
|
if (oe.get(), $e.length) {
|
|
1367
1367
|
const U = $e.map((M) => M ? M.get() : null), B = i.readCursor(tt(oe.get()));
|
|
1368
1368
|
if (Ue(B, oe, (M, P, k) => {
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1369
|
+
const X = U[M];
|
|
1370
|
+
X && (k.mergeTree(X), U[M] = null);
|
|
1371
1371
|
}), U.find((M) => M)) {
|
|
1372
1372
|
const M = i.writeCursor(), P = i.writeCursor();
|
|
1373
|
-
let k = 0,
|
|
1373
|
+
let k = 0, X = 0;
|
|
1374
1374
|
U.forEach((Y) => {
|
|
1375
1375
|
Y != null && Ue(i.readCursor(Y), null, (ee) => {
|
|
1376
1376
|
const fe = Le[ee];
|
|
1377
1377
|
M.writeMove(C[fe].getPath(), $[fe].getPath(), k++);
|
|
1378
1378
|
const de = se[fe];
|
|
1379
1379
|
de && de.forEach((le) => {
|
|
1380
|
-
g[le] || A !== 1 && K[le] != null || P.writeMove(j[le].getPath(), p[le].getPath(),
|
|
1380
|
+
g[le] || A !== 1 && K[le] != null || P.writeMove(j[le].getPath(), p[le].getPath(), X++);
|
|
1381
1381
|
});
|
|
1382
1382
|
});
|
|
1383
1383
|
}), b = {
|
|
@@ -1534,15 +1534,17 @@ class Ht {
|
|
|
1534
1534
|
}
|
|
1535
1535
|
registerDrawingData(e, n) {
|
|
1536
1536
|
this.drawingManagerData[e] = n;
|
|
1537
|
-
|
|
1538
|
-
|
|
1537
|
+
}
|
|
1538
|
+
initializeNotification(e) {
|
|
1539
|
+
const n = [], s = this.drawingManagerData[e];
|
|
1540
|
+
s != null && (Object.keys(s).forEach((i) => {
|
|
1539
1541
|
this._establishDrawingMap(e, i);
|
|
1540
|
-
const d =
|
|
1542
|
+
const d = s[i];
|
|
1541
1543
|
Object.keys(d.data).forEach((l) => {
|
|
1542
1544
|
const a = d.data[l];
|
|
1543
|
-
|
|
1545
|
+
a.unitId = e, a.subUnitId = i, n.push(a);
|
|
1544
1546
|
});
|
|
1545
|
-
}),
|
|
1547
|
+
}), n.length > 0 && this.addNotification(n));
|
|
1546
1548
|
}
|
|
1547
1549
|
getDrawingData(e, n) {
|
|
1548
1550
|
return this._getDrawingData(e, n);
|
|
@@ -1940,8 +1942,8 @@ class Ft {
|
|
|
1940
1942
|
}
|
|
1941
1943
|
}
|
|
1942
1944
|
const dn = "__default_document_sub_component_id20231101__";
|
|
1943
|
-
var qt = /* @__PURE__ */ ((t) => (t[t.forward = 0] = "forward", t[t.backward = 1] = "backward", t[t.front = 2] = "front", t[t.back = 3] = "back", t))(qt || {}),
|
|
1944
|
-
const
|
|
1945
|
+
var qt = /* @__PURE__ */ ((t) => (t[t.forward = 0] = "forward", t[t.backward = 1] = "backward", t[t.front = 2] = "front", t[t.back = 3] = "back", t))(qt || {}), zt = /* @__PURE__ */ ((t) => (t[t.UNRECOGNIZED = -1] = "UNRECOGNIZED", t[t.DRAWING_IMAGE = 0] = "DRAWING_IMAGE", t[t.DRAWING_SHAPE = 1] = "DRAWING_SHAPE", t[t.DRAWING_CHART = 2] = "DRAWING_CHART", t[t.DRAWING_TABLE = 3] = "DRAWING_TABLE", t[t.DRAWING_SMART_ART = 4] = "DRAWING_SMART_ART", t[t.DRAWING_VIDEO = 5] = "DRAWING_VIDEO", t[t.DRAWING_GROUP = 6] = "DRAWING_GROUP", t[t.DRAWING_UNIT = 7] = "DRAWING_UNIT", t[t.DRAWING_DOM = 8] = "DRAWING_DOM", t))(zt || {});
|
|
1946
|
+
const Xt = It("univer.drawing-manager.service");
|
|
1945
1947
|
var Yt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Jt = (t, e, n, s) => {
|
|
1946
1948
|
for (var i = s > 1 ? void 0 : s ? Zt(e, n) : e, d = t.length - 1, l; d >= 0; d--)
|
|
1947
1949
|
(l = t[d]) && (i = (s ? l(e, n, i) : l(i)) || i);
|
|
@@ -1960,7 +1962,7 @@ let wt = (ot = class extends Rt {
|
|
|
1960
1962
|
var s;
|
|
1961
1963
|
St([
|
|
1962
1964
|
[Vt, { useClass: Ft }],
|
|
1963
|
-
[
|
|
1965
|
+
[Xt, { useClass: Kt }]
|
|
1964
1966
|
], (s = this._config) == null ? void 0 : s.override).forEach((i) => t.add(i));
|
|
1965
1967
|
}
|
|
1966
1968
|
}, V(ot, "pluginName", en), ot);
|
|
@@ -1976,8 +1978,8 @@ export {
|
|
|
1976
1978
|
ln as DRAWING_IMAGE_HEIGHT_LIMIT,
|
|
1977
1979
|
on as DRAWING_IMAGE_WIDTH_LIMIT,
|
|
1978
1980
|
Kt as DrawingManagerService,
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
+
zt as DrawingTypeEnum,
|
|
1982
|
+
Xt as IDrawingManagerService,
|
|
1981
1983
|
Vt as IImageIoService,
|
|
1982
1984
|
Ft as ImageIoService,
|
|
1983
1985
|
et as ImageSourceType,
|
package/lib/types/index.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export { UniverDrawingPlugin } from './plugin';
|
|
|
21
21
|
export { type IImageData } from './models/image-model-interface';
|
|
22
22
|
export { IImageIoService, type IImageIoServiceParam, ImageSourceType, ImageUploadStatusType } from './services/image-io.service';
|
|
23
23
|
export { ImageIoService } from './services/image-io-impl.service';
|
|
24
|
-
export type { ITransformState, IRotationSkewFlipTransform
|
|
24
|
+
export type { ITransformState, IRotationSkewFlipTransform } from './services/interface';
|
|
25
25
|
export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID, type DrawingType, DrawingTypeEnum, type IDrawingSearch, type IDrawingSpace, type IDrawingParam, IDrawingManagerService, type IDrawingOrderUpdateParam, type IUnitDrawingService, type IDrawingMap, type IDrawingSubunitMap, type IDrawingOrderMapParam, type IDrawingGroupUpdateParam, type IDrawingVisibleParam, type IDrawingMapItemData, type IDrawingMapItem, ArrangeTypeEnum, } from './services/drawing-manager.service';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Nullable, PresetGeometryType } from '@univerjs/core';
|
|
1
|
+
import { ISrcRect, Nullable, PresetGeometryType } from '@univerjs/core';
|
|
2
2
|
import { IDrawingParam } from '../services/drawing-manager.service';
|
|
3
3
|
import { ImageSourceType } from '../services/image-io.service';
|
|
4
|
-
import { ISrcRect } from '../services/interface';
|
|
5
4
|
|
|
6
5
|
export interface IImageData extends IDrawingParam {
|
|
7
6
|
imageSourceType: ImageSourceType;
|
|
@@ -61,6 +61,7 @@ export declare class UnitDrawingService<T extends IDrawingParam> implements IUni
|
|
|
61
61
|
getDrawingDataForUnit(unitId: string): IDrawingSubunitMap<T>;
|
|
62
62
|
removeDrawingDataForUnit(unitId: string): void;
|
|
63
63
|
registerDrawingData(unitId: string, data: IDrawingSubunitMap<T>): void;
|
|
64
|
+
initializeNotification(unitId: string): void;
|
|
64
65
|
getDrawingData(unitId: string, subUnitId: string): import('./drawing-manager.service').IDrawingMapItemData<T>;
|
|
65
66
|
getBatchAddOp(insertParams: T[]): IDrawingJsonUndo1;
|
|
66
67
|
getBatchRemoveOp(removeParams: IDrawingSearch[]): IDrawingJsonUndo1;
|
|
@@ -130,6 +130,7 @@ export interface IUnitDrawingService<T extends IDrawingParam> extends IUnitNorma
|
|
|
130
130
|
getDrawingDataForUnit(unitId: string): IDrawingSubunitMap<T>;
|
|
131
131
|
removeDrawingDataForUnit(unitId: string): void;
|
|
132
132
|
registerDrawingData(unitId: string, data: IDrawingSubunitMap<T>): void;
|
|
133
|
+
initializeNotification(unitId: string): void;
|
|
133
134
|
getDrawingData(unitId: string, subUnitId: string): IDrawingMapItemData<T>;
|
|
134
135
|
getDrawingByParam(param: Nullable<IDrawingSearch>): Nullable<T>;
|
|
135
136
|
getOldDrawingByParam(param: Nullable<IDrawingSearch>): Nullable<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAbsoluteTransform
|
|
1
|
+
import { IAbsoluteTransform } from '@univerjs/core';
|
|
2
2
|
|
|
3
3
|
export interface IRotationSkewFlipTransform {
|
|
4
4
|
angle?: number;
|
|
@@ -7,9 +7,5 @@ export interface IRotationSkewFlipTransform {
|
|
|
7
7
|
flipX?: boolean;
|
|
8
8
|
flipY?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export interface ISrcRect extends IOffset {
|
|
11
|
-
right?: number;
|
|
12
|
-
bottom?: number;
|
|
13
|
-
}
|
|
14
10
|
export interface ITransformState extends IAbsoluteTransform, IRotationSkewFlipTransform {
|
|
15
11
|
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(Y,re){typeof exports=="object"&&typeof module<"u"?re(exports,require("rxjs"),require("@univerjs/core"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","@univerjs/core","@wendellhu/redi"],re):(Y=typeof globalThis<"u"?globalThis:Y||self,re(Y.UniverDrawing={},Y.rxjs,Y.UniverCore,Y["@wendellhu/redi"]))})(this,function(Y,re,ke,tt){"use strict";var Xt=Object.defineProperty;var Zt=(Y,re,ke)=>re in Y?Xt(Y,re,{enumerable:!0,configurable:!0,writable:!0,value:ke}):Y[re]=ke;var V=(Y,re,ke)=>Zt(Y,typeof re!="symbol"?re+"":re,ke);var gt;const Ot=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},yt={},it={};Object.defineProperty(it,"__esModule",{value:!0});function Rt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!st(n[t],e[t]))return!1;for(let t in e)if(n[t]===void 0)return!1;return!0}function kt(n,e){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!st(n[t],e[t]))return!1;return!0}function st(n,e){return n===e?!0:n===null||e===null||typeof n!="object"||typeof e!="object"?!1:Array.isArray(n)?kt(n,e):Rt(n,e)}it.default=st;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});function lt(n){if(n===null)return null;if(Array.isArray(n))return n.map(lt);if(typeof n=="object"){const e={};for(let t in n)e[t]=lt(n[t]);return e}else return n}ot.default=lt;var at={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.eachChildOf=n.advancer=n.readCursor=n.writeCursor=n.WriteCursor=n.ReadCursor=n.isValidPathItem=void 0;function e(v,o){if(!v)throw new Error(o)}const t=v=>v!=null&&typeof v=="object"&&!Array.isArray(v),s=(v,o)=>typeof v==typeof o?v>o:typeof v=="string"&&typeof o=="number";function i(v,o){for(let u in v){const h=u;o.write(h,v[h])}}n.isValidPathItem=v=>typeof v=="number"||typeof v=="string"&&v!=="__proto__";class d{constructor(o=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=o}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,t(this.container[this.idx])&&this.idx--)}getPath(){const o=[];let u=this.container,h=this.parents.length-1,T=this.idx;for(;T>=0;)o.unshift(u[T]),T===0?(T=this.indexes[h*2],u=this.parents[h--]):T-=t(u[T-1])?2:1;return o}}class l extends d{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let o;return this.container&&this.container.length>this.idx+1&&t(o=this.container[this.idx+1])?o:null}descendFirst(){let o=this.idx+1;if(!this.container||o>=this.container.length||t(this.container[o])&&o+1>=this.container.length)return!1;t(this.container[o])&&o++;const u=this.container[o];return Array.isArray(u)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(o),this.idx=0,this.container=u):this.idx=o,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const o=this.indexes[this.indexes.length-1]+1,u=this.parents[this.parents.length-1];return o>=u.length?!1:(e(!isNaN(o)),this.indexes[this.indexes.length-1]=o,this.container=u[o],!0)}_init(o,u,h,T){this.container=o,this.idx=u,this.parents=h.slice(),this.indexes=T.slice()}clone(){const o=new l;return o._init(this.container,this.idx,this.parents,this.indexes),o}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(o,u){const h=this.getComponent();h&&u(h,o);for(const T of this)o&&o.descend(T),this.traverse(o,u),o&&o.ascend()}eachPick(o,u){this.traverse(o,(h,T)=>{h.p!=null&&u(h.p,T)})}eachDrop(o,u){this.traverse(o,(h,T)=>{h.d!=null&&u(h.d,T)})}}n.ReadCursor=l;class a extends d{constructor(o=null){super(o),this.pendingDescent=[],this._op=o}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let o=0;o<this.pendingDescent.length;o++){const u=this.pendingDescent[o];let h=this.idx+1;if(h<this.container.length&&t(this.container[h])&&h++,e(h===this.container.length||!t(this.container[h])),h===this.container.length)this.container.push(u),this.idx=h;else if(this.container[h]===u)this.idx=h;else{if(!Array.isArray(this.container[h])){const T=this.container.splice(h,this.container.length-h);this.container.push(T),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(s(u,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&s(u,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===u)this.container=this.container[h];else{const T=[u];this.container.splice(h,0,T),this.container=T}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const o=this.idx+1;if(o<this.container.length&&t(this.container[o]))return this.container[o];{const u={};return this.container.splice(o,0,u),u}}write(o,u){const h=this.getComponent();e(h[o]==null||h[o]===u,"Internal consistency error: Overwritten component. File a bug"),h[o]=u}get(){return this._op}descend(o){if(!n.isValidPathItem(o))throw Error("Invalid JSON key");this.pendingDescent.push(o)}descendPath(o){return this.pendingDescent.push(...o),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(o,u=i){if(o===null)return;if(e(Array.isArray(o)),o===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,T=this.parents.length;let J=0;for(let _e=0;_e<o.length;_e++){const Q=o[_e];typeof Q=="string"||typeof Q=="number"?(J++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,u):typeof Q=="object"&&u(Q,this)}for(;J--;)this.ascend();this.lcIdx=this.parents.length===T?h:-1}at(o,u){this.descendPath(o),u(this);for(let h=0;h<o.length;h++)this.ascend();return this}writeAtPath(o,u,h){return this.at(o,()=>this.write(u,h)),this.reset(),this}writeMove(o,u,h=0){return this.writeAtPath(o,"p",h).writeAtPath(u,"d",h)}getPath(){const o=super.getPath();return o.push(...this.pendingDescent),o}}n.WriteCursor=a,n.writeCursor=()=>new a,n.readCursor=v=>new l(v);function E(v,o,u){let h,T;T=h=v?v.descendFirst():!1;function J(_e){let Q;for(;T;){const Ce=Q=v.getKey();if(_e!=null){let Ke=!1;if(o&&typeof Ce=="number"&&(Q=o(Ce,v.getComponent()),Q<0&&(Q=~Q,Ke=!0)),s(Q,_e))return null;if(Q===_e&&!Ke)return v}u&&typeof Q=="number"&&u(Q,v.getComponent()),T=v.nextSibling()}return null}return J.end=()=>{h&&v.ascend()},J}n.advancer=E;function G(v,o,u){let h,T,J,_e;for(h=T=v&&v.descendFirst(),J=_e=o&&o.descendFirst();h||J;){let Q=h?v.getKey():null,Ce=J?o.getKey():null;Q!==null&&Ce!==null&&(s(Ce,Q)?Ce=null:Q!==Ce&&(Q=null)),u(Q==null?Ce:Q,Q!=null?v:null,Ce!=null?o:null),Q!=null&&h&&(h=v.nextSibling()),Ce!=null&&J&&(J=o.nextSibling())}T&&v.ascend(),_e&&o.ascend()}n.eachChildOf=G})(at);var ut={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(n.ConflictType||(n.ConflictType={}))})(ut);var ct={},xe={},bt;function dt(){return bt||(bt=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.uniToStrPos=xe.strPosToUni=void 0,xe.strPosToUni=(n,e=n.length)=>{let t=0,s=0;for(;s<e;s++){const i=n.charCodeAt(s);i>=55296&&i<=57343&&(t++,s++)}if(s!==e)throw Error("Invalid offset - splits unicode bytes");return s-t},xe.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const s=n.charCodeAt(t);t+=s>=55296&&s<=57343?2:1}return t}),xe}var ft={},It;function ht(){return It||(It=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=dt(),t=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let _=null;for(let m=0;m<f.length;m++){const H=f[m];switch(typeof H){case"object":if(typeof H.d!="number"&&typeof H.d!="string")throw Error("Delete must be number or string");if(n.dlen(H.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(H.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(H>0))throw Error("Skip components must be >0");if(typeof _=="number")throw Error("Adjacent skip components should be combined");break}_=H}if(typeof _=="number")throw Error("Op has a trailing skip")};function s(f,_){let m=0,H=0;for(let z=0;z<f.length;z++){const x=f[z];switch(_(x,m,H),typeof x){case"object":m+=n.dlen(x.d);break;case"string":H+=e.strPosToUni(x);break;case"number":m+=x,H+=x;break}}}n.eachOp=s;function i(f,_){const m=[],H=a(m);return s(f,(z,x,De)=>{H(_(z,x,De))}),o(m)}const d=f=>f,l=f=>i(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const a=f=>_=>{if(!(!_||_.d===0||_.d===""))if(f.length===0)f.push(_);else if(typeof _==typeof f[f.length-1])if(typeof _=="object"){const m=f[f.length-1];m.d=typeof m.d=="string"&&typeof _.d=="string"?m.d+_.d:n.dlen(m.d)+n.dlen(_.d)}else f[f.length-1]+=_;else f.push(_)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);n.uniSlice=(f,_,m)=>{const H=e.uniToStrPos(f,_),z=m==null?1/0:e.uniToStrPos(f,m);return f.slice(H,z)};const G=(f,_,m)=>typeof f=="number"?m==null?f-_:Math.min(f,m)-_:n.uniSlice(f,_,m),v=f=>{let _=0,m=0;return{take:(x,De)=>{if(_===f.length)return x===-1?null:x;const fe=f[_];let ie;if(typeof fe=="number")return x===-1||fe-m<=x?(ie=fe-m,++_,m=0,ie):(m+=x,x);if(typeof fe=="string"){if(x===-1||De==="i"||e.strPosToUni(fe.slice(m))<=x)return ie=fe.slice(m),++_,m=0,ie;{const ce=m+e.uniToStrPos(fe.slice(m),x);return ie=fe.slice(m,ce),m=ce,ie}}else{if(x===-1||De==="d"||n.dlen(fe.d)-m<=x)return ie={d:G(fe.d,m)},++_,m=0,ie;{let ce=G(fe.d,m,m+x);return m+=x,{d:ce}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function u(f,_,m){if(m!=="left"&&m!=="right")throw Error("side ("+m+") must be 'left' or 'right'");t(f),t(_);const H=[],z=a(H),{take:x,peek:De}=v(f);for(let ie=0;ie<_.length;ie++){const ce=_[ie];let ve,Pe;switch(typeof ce){case"number":for(ve=ce;ve>0;)Pe=x(ve,"i"),z(Pe),typeof Pe!="string"&&(ve-=E(Pe));break;case"string":m==="left"&&typeof De()=="string"&&z(x(-1)),z(e.strPosToUni(ce));break;case"object":for(ve=n.dlen(ce.d);ve>0;)switch(Pe=x(ve,"i"),typeof Pe){case"number":ve-=Pe;break;case"string":z(Pe);break;case"object":ve-=n.dlen(Pe.d)}break}}let fe;for(;fe=x(-1);)z(fe);return o(H)}function h(f,_){t(f),t(_);const m=[],H=a(m),{take:z}=v(f);for(let De=0;De<_.length;De++){const fe=_[De];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=z(ie,"d"),H(ce),typeof ce!="object"&&(ie-=E(ce));break;case"string":H(fe);break;case"object":ie=n.dlen(fe.d);let ve=0;for(;ve<ie;)switch(ce=z(ie-ve,"d"),typeof ce){case"number":H({d:G(fe.d,ve,ve+ce)}),ve+=ce;break;case"string":ve+=e.strPosToUni(ce);break;case"object":H(ce)}break}}let x;for(;x=z(-1);)H(x);return o(m)}const T=(f,_)=>{let m=0;for(let H=0;H<_.length&&f>m;H++){const z=_[H];switch(typeof z){case"number":{m+=z;break}case"string":const x=e.strPosToUni(z);m+=x,f+=x;break;case"object":f-=Math.min(n.dlen(z.d),f-m);break}}return f},J=(f,_)=>typeof f=="number"?T(f,_):f.map(m=>T(m,_));function _e(f,_,m){return i(f,(H,z)=>typeof H=="object"&&typeof H.d=="number"?{d:m.slice(_,z,z+H.d)}:H)}function Q(f){return i(f,_=>{switch(typeof _){case"object":if(typeof _.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return _.d;case"string":return{d:_};case"number":return _}})}function Ce(f){return i(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function Ke(f){let _=!0;return s(f,m=>{typeof m=="object"&&typeof m.d=="number"&&(_=!1)}),_}function be(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:l,checkOp:t,create(_=""){if(typeof _!="string")throw Error("Initial data must be a string");return f.create(_)},apply(_,m){t(m);const H=f.builder(_);for(let z=0;z<m.length;z++){const x=m[z];switch(typeof x){case"number":H.skip(x);break;case"string":H.append(x);break;case"object":H.del(n.dlen(x.d));break}}return H.build()},transform:u,compose:h,transformPosition:T,transformSelection:J,isInvertible:Ke,makeInvertible(_,m){return _e(_,m,f)},stripInvertible:Ce,invert:Q,invertWithDoc(_,m){return Q(_e(_,m,f))},isNoop:_=>_.length===0}}n.default=be}(ft)),ft}var nt={},mt;function jt(){if(mt)return nt;mt=1,Object.defineProperty(nt,"__esModule",{value:!0});const n=ht(),e=dt();function t(s,i){return{get:s,getLength(){return s().length},insert(d,l,a){const E=e.strPosToUni(s(),d);return i([E,l],a)},remove(d,l,a){const E=e.strPosToUni(s(),d);return i([E,{d:l}],a)},_onOp(d){n.eachOp(d,(l,a,E)=>{switch(typeof l){case"string":this.onInsert&&this.onInsert(E,l);break;case"object":const G=n.dlen(l.d);this.onRemove&&this.onRemove(E,G)}})},onInsert:null,onRemove:null}}return nt.default=t,t.provides={text:!0},nt}var wt;function $t(){return wt||(wt=1,function(n){var e=Ee&&Ee.__createBinding||(Object.create?function(u,h,T,J){J===void 0&&(J=T),Object.defineProperty(u,J,{enumerable:!0,get:function(){return h[T]}})}:function(u,h,T,J){J===void 0&&(J=T),u[J]=h[T]}),t=Ee&&Ee.__setModuleDefault||(Object.create?function(u,h){Object.defineProperty(u,"default",{enumerable:!0,value:h})}:function(u,h){u.default=h}),s=Ee&&Ee.__importStar||function(u){if(u&&u.__esModule)return u;var h={};if(u!=null)for(var T in u)Object.hasOwnProperty.call(u,T)&&e(h,u,T);return t(h,u),h},i=Ee&&Ee.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(n,"__esModule",{value:!0}),n.type=n.remove=n.insert=void 0;const d=dt(),l=s(ht()),a=i(jt()),E={create(u){return u},toString(u){return u},builder(u){if(typeof u!="string")throw Error("Invalid document snapshot: "+u);const h=[];return{skip(T){let J=d.uniToStrPos(u,T);if(J>u.length)throw Error("The op is too long for this document");h.push(u.slice(0,J)),u=u.slice(J)},append(T){h.push(T)},del(T){u=u.slice(d.uniToStrPos(u,T))},build(){return h.join("")+u}}},slice:l.uniSlice},G=l.default(E),v=Object.assign(Object.assign({},G),{api:a.default});n.type=v,n.insert=(u,h)=>h.length===0?[]:u===0?[h]:[u,h],n.remove=(u,h)=>l.dlen(h)===0?[]:u===0?[{d:h}]:[u,{d:h}];var o=ht();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ct)),ct}(function(n){var e=Ee&&Ee.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(n,"__esModule",{value:!0}),n.editOp=n.replaceOp=n.insertOp=n.moveOp=n.removeOp=n.type=void 0;const t=e(it),s=e(ot),i=at,d=ut;function l(r,c){if(!r)throw new Error(c)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:i.readCursor,writeCursor:i.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:Q,checkValidOp:z,normalize:x,apply:De,transformPosition:fe,compose:ie,tryTransform:_t,transform:qt,makeInvertible:Pe,invert:ce,invertWithDoc:Vt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,c,y)=>Nt(()=>!0,r,c,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(c,y,A)=>Nt(r,c,y,A)})};const a=r=>r?r.getComponent():null;function E(r){return r&&typeof r=="object"&&!Array.isArray(r)}const G=r=>Array.isArray(r)?r.slice():r!==null&&typeof r=="object"?Object.assign({},r):r,v=r=>r&&(r.p!=null||r.r!==void 0),o=r=>r&&(r.d!=null||r.i!==void 0);function u(r,c){return l(r!=null),typeof c=="number"?(l(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(c,1)):(l(E(r),"Invalid key - child is not an object"),delete(r=Object.assign({},r))[c]),r}function h(r,c,y){return typeof c=="number"?(l(r!=null,"Container is missing for key"),l(Array.isArray(r),"Cannot use numerical key for object container"),l(r.length>=c,"Cannot insert into out of bounds index"),r.splice(c,0,y)):(l(E(r),"Cannot insert into missing item"),l(r[c]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),r[c]=y),y}n.removeOp=(r,c=!0)=>i.writeCursor().writeAtPath(r,"r",c).get(),n.moveOp=(r,c)=>i.writeCursor().writeMove(r,c).get(),n.insertOp=(r,c)=>i.writeCursor().writeAtPath(r,"i",c).get(),n.replaceOp=(r,c,y)=>i.writeCursor().at(r,A=>{A.write("r",c),A.write("i",y)}).get(),n.editOp=(r,c,y,A=!1)=>i.writeCursor().at(r,b=>_(b,c,y,A)).get();const T=(r,c)=>r!=null&&(typeof c=="number"?Array.isArray(r):typeof r=="object"),J=(r,c)=>T(r,c)?r[c]:void 0,_e={};function Q(r){let c=r.type?r.type:r;c.name&&(_e[c.name]=c),c.uri&&(_e[c.uri]=c)}const Ce=r=>{const c=_e[r];if(c)return c;throw Error("Missing type: "+r)};Q($t());const Ke=(r,c)=>r+c;Q({name:"number",apply:Ke,compose:Ke,invert:r=>-r,transform:r=>r});const be=r=>r==null?null:r.et?Ce(r.et):r.es?_e["text-unicode"]:r.ena!=null?_e.number:null,f=r=>r.es?r.es:r.ena!=null?r.ena:r.e,_=(r,c,y,A=!1)=>{const[b,C]=typeof c=="string"?[Ce(c),c]:[c,c.name];!A&&b.isNoop&&b.isNoop(y)||(C==="number"?r.write("ena",y):C==="text-unicode"?r.write("es",y):(r.write("et",C),r.write("e",y)))};function m(r){l(typeof r=="number"),l(r>=0),l(r===(0|r))}function H(r){typeof r=="number"?m(r):l(typeof r=="string")}function z(r){if(r===null)return;const c=new Set,y=new Set,A=C=>{let $=!0,k=!1;for(let g in C){const O=C[g];if($=!1,l(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")m(O),l(!c.has(O)),c.add(O),l(C.r===void 0);else if(g==="d")m(O),l(!y.has(O)),y.add(O),l(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){l(!k),k=!0;const I=be(C);l(I,"Missing type in edit"),I.checkValidOp&&I.checkValidOp(f(C))}}l(!$)},b=(C,$,k)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");$||H(C[0]);let g=1,O=0,I=0;for(let w=0;w<C.length;w++){const j=C[w];if(l(j!=null),Array.isArray(j)){const W=b(j,!1);if(O){const p=typeof I,U=typeof W;p===U?l(I<W,"descent keys are not in order"):l(p==="number"&&U==="string")}I=W,O++,g=3}else typeof j=="object"?(l(g===1,`Prev not scalar - instead ${g}`),A(j),g=2):(l(g!==3),H(j),l(i.isValidPathItem(j),"Invalid path key"),g=1)}return l(O!==1,"Operation makes multiple descents. Remove some []"),l(g===2||g===3),C[0]};b(r,!0),l(c.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<c.size;C++)l(c.has(C)),l(y.has(C))}function x(r){let c=0,y=[];const A=i.writeCursor();return A.mergeTree(r,(b,C)=>{const $=be(b);if($){const g=f(b);_(C,$,$.normalize?$.normalize(g):g)}for(const g of["r","p","i","d"])if(b[g]!==void 0){const O=g==="p"||g==="d"?(k=b[g],y[k]==null&&(y[k]=c++),y[k]):b[g];C.write(g,O)}var k}),A.get()}function De(r,c){if(z(c),c===null)return r;const y=[];return function A(b,C){let $=b,k=0,g={root:b},O=0,I=g,w="root";function j(){for(;O<k;O++){let W=C[O];typeof W!="object"&&(l(T(I,w)),I=I[w]=G(I[w]),w=W)}}for(;k<C.length;k++){const W=C[k];if(Array.isArray(W)){const p=A($,W);p!==$&&p!==void 0&&(j(),$=I[w]=p)}else if(typeof W=="object"){W.d!=null?(j(),$=h(I,w,y[W.d])):W.i!==void 0&&(j(),$=h(I,w,W.i));const p=be(W);if(p)j(),$=I[w]=p.apply($,f(W));else if(W.e!==void 0)throw Error("Subtype "+W.et+" undefined")}else $=J($,W)}return g.root}(r=function A(b,C){const $=[];let k=0;for(;k<C.length;k++){const w=C[k];if(Array.isArray(w))break;typeof w!="object"&&($.push(b),b=J(b,w))}for(let w=C.length-1;w>=k;w--)b=A(b,C[w]);for(--k;k>=0;k--){const w=C[k];if(typeof w!="object"){const j=$.pop();b=b===J(j,w)?j:b===void 0?u(j,w):(O=w,I=b,(g=G(g=j))[O]=I,g)}else v(w)&&(l(b!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(y[w.p]=b),b=void 0)}var g,O,I;return b}(r,c),c)}function fe(r,c){r=r.slice(),z(c);const y=i.readCursor(c);let A,b,C=!1;const $=[];for(let g=0;;g++){const O=r[g],I=y.getComponent();if(I&&(I.r!==void 0?C=!0:I.p!=null&&(C=!1,A=I.p,b=g)),g>=r.length)break;let w=0;const j=i.advancer(y,void 0,(p,U)=>{v(U)&&w++});$.unshift(j);const W=j(O);if(typeof O=="number"&&(r[g]-=w),!W)break}if($.forEach(g=>g.end()),C)return null;const k=()=>{let g=0;if(A!=null){const O=y.getPath();g=O.length,r=O.concat(r.slice(b))}for(;g<r.length;g++){const O=r[g],I=a(y),w=be(I);if(w){const p=f(I);w.transformPosition&&(r[g]=w.transformPosition(r[g],p));break}let j=0;const W=i.advancer(y,(p,U)=>o(U)?~(p-j):p-j,(p,U)=>{o(U)&&j++})(O);if(typeof O=="number"&&(r[g]+=j),!W)break}};return A!=null?y.eachDrop(null,g=>{g===A&&k()}):k(),r}function ie(r,c){if(z(r),z(c),r==null)return c;if(c==null)return r;let y=0;const A=i.readCursor(r),b=i.readCursor(c),C=i.writeCursor(),$=[],k=[],g=[],O=[],I=[],w=[],j=new Set;A.traverse(null,p=>{p.p!=null&&(g[p.p]=A.clone())}),b.traverse(null,p=>{p.d!=null&&(O[p.d]=b.clone())});const W=i.writeCursor();return function p(U,se,ne,K,le,Ge,me,Oe){l(se||ne);const ae=a(se),Me=a(ne),Ue=!!Me&&Me.r!==void 0,Fe=!!ae&&ae.i!==void 0,Se=ae?ae.d:null,Ae=Me?Me.p:null,We=(Ge||Ue)&&Ae==null;if(Ae!=null)K=O[Ae],me=k[Ae]=new i.WriteCursor;else if(Me&&Me.r!==void 0)K=null;else{const P=a(K);P&&P.d!=null&&(K=null)}const ee=a(K);if(Se!=null)if(U=g[Se],Oe=$[Se]=new i.WriteCursor,We)Ge&&!Ue&&Oe.write("r",!0);else{const P=I[Se]=y++;me.write("d",P)}else if(ae&&ae.i!==void 0)U=null;else{const P=a(U);P&&P.p!=null&&(U=null)}let M;Fe?(l(le===void 0),M=ae.i):M=le;const L=(Ae==null?!Fe||Ge||Ue:M===void 0)?null:me.getComponent();if(Ae!=null){if(!(le!==void 0||Fe)){const P=Se!=null?I[Se]:y++;w[Ae]=P,Oe.write("p",P)}}else Ue&&(Fe||le!==void 0||(Me.r,Oe.write("r",Me.r)));const S=We?null:be(ae),D=be(ee);if((S||D)&&(S&&S.name,D&&D.name),S&&D){l(S===D);const P=f(ae),B=f(ee),pe=S.compose(P,B);_(me,S,pe),j.add(ee)}else S?_(me,S,f(ae)):D&&(_(me,D,f(ee)),j.add(ee));const N=typeof M=="object"&&M!=null;let X=!1,Z=0,te=0,ge=0,he=0,ue=0;const Ie=i.advancer(K,(P,B)=>o(B)?he-P-1:P-he,(P,B)=>{o(B)&&he++}),q=i.advancer(U,(P,B)=>v(B)?Z-P-1:P-Z,(P,B)=>{v(B)&&Z++});if(i.eachChildOf(se,ne,(P,B,pe)=>{let we,Le,Ve=P,Ne=P,et=P;if(typeof P=="number"){let ye=P+ge;Le=Ie(ye),Ne=ye+he;let de=P+te;we=q(de),o(a(Le))&&(we=null),Ve=de+Z,et=P+ue,l(Ve>=0,"p1PickKey is negative"),l(Ne>=0,"p2DropKey is negative");const Te=o(a(B)),Be=v(a(pe));(Te||Be&&!We)&&ue--,Te&&te--,Be&&ge--}else we=q(P),Le=Ie(P);Oe.descend(Ve),me.descend(Ne);const Ye=N&&!o(a(B))?M[et]:void 0,je=p(we,B,pe,Le,Ye,We,me,Oe);var $e,R,oe;N&&!We?Ye!==je&&(X||(M=Array.isArray(M)?M.slice():Object.assign({},M),X=!0),$e=M,oe=je,typeof(R=et)=="number"?(l(Array.isArray($e)),l(R<$e.length)):(l(!Array.isArray($e)),l($e[R]!==void 0)),oe===void 0?typeof R=="number"?$e.splice(R,1):delete $e[R]:$e[R]=oe):l(je===void 0),me.ascend(),Oe.ascend()}),q.end(),Ie.end(),L!=null)L.i=M;else if(!Ge&&!Ue&&Ae==null)return M}(A,A.clone(),b,b.clone(),void 0,!1,C,W),C.reset(),C.mergeTree(W.get()),C.reset(),C.get(),$.map(p=>p.get()),k.map(p=>p.get()),A.traverse(C,(p,U)=>{const se=p.p;if(se!=null){const ne=I[se];ne!=null&&U.write("p",ne);const K=$[se];K&&K.get(),K&&U.mergeTree(K.get())}else p.r!==void 0&&U.write("r",p.r)}),C.reset(),C.get(),b.traverse(C,(p,U)=>{const se=p.d;if(se!=null){const K=w[se];K!=null&&U.write("d",K);const le=k[se];le&&U.mergeTree(le.get())}else p.i!==void 0&&U.write("i",p.i);const ne=be(p);ne&&!j.has(p)&&_(U,ne,f(p))}),C.get()}function ce(r){if(r==null)return null;const c=new i.ReadCursor(r),y=new i.WriteCursor;let A;const b=[],C=[];return function $(k,g,O){const I=k.getComponent();let w,j=!1;if(I){I.p!=null&&(g.write("d",I.p),b[I.p]=k.clone()),I.r!==void 0&&g.write("i",I.r),I.d!=null&&(g.write("p",I.d),O=void 0),I.i!==void 0&&(O=w=I.i);const p=be(I);p&&(O===void 0?(A||(A=new Set),A.add(I)):(f(I),O=p.apply(O,f(I)),j=!0))}let W=0;for(const p of k){g.descend(p);const U=typeof p=="number"?p-W:p,se=J(O,U);o(k.getComponent())&&W++;const ne=$(k,g,se);if(O!==void 0&&ne!==void 0){if(j||(j=!0,O=G(O)),!T(O,U))throw Error("Cannot modify child - invalid operation");O[U]=ne}g.ascend()}if(w===void 0)return j?O:void 0;g.write("r",O)}(c,y,void 0),A&&(y.reset(),function $(k,g,O){const I=g.getComponent();if(I){const p=I.d;if(p!=null&&(k=b[p],O=C[p]=i.writeCursor()),A.has(I)){const U=be(I);if(!U.invert)throw Error(`Cannot invert subtype ${U.name}`);_(O,U,U.invert(f(I)))}}let w=0,j=0;const W=i.advancer(k,(p,U)=>v(U)?w-p-1:p-w,(p,U)=>{v(U)&&w++});for(const p of g)if(typeof p=="number"){const U=p-j,se=W(U),ne=U+w;O.descend(ne),$(se,g,O),o(g.getComponent())&&j++,O.ascend()}else O.descend(p),$(W(p),g,O),O.ascend();W.end()}(c.clone(),c,y),C.length&&(y.reset(),c.traverse(y,($,k)=>{const g=$.p;if(g!=null){const O=C[g];O&&O.get(),O&&k.mergeTree(O.get())}}))),y.get()}const ve=(r,c)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?ve(y,c):c(y)));function Pe(r,c){if(r==null||!ve(r,g=>{var O;return g.r!==void 0||((O=be(g))===null||O===void 0?void 0:O.makeInvertible)!=null}))return r;const y=new i.ReadCursor(r),A=new i.WriteCursor;let b=!1;const C=[],$=[],k=(g,O,I)=>{const w=g.getComponent();let j=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const p=w.p;if(p!=null&&(C[p]=g.clone(),l(I!==void 0,"Operation picks up at an invalid key"),$[p]=I,O.write("p",w.p)),w.r!==void 0&&I===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const U=be(w);U&&(U.makeInvertible?b=!0:_(O,U,f(w),!0))}let W=0;for(const p of g){O.descend(p);const U=typeof p=="number"?p-W:p,se=J(I,U),ne=k(g,O,se);se!==ne&&(j||(j=!0,I=G(I)),ne===void 0?(I=u(I,U),typeof p=="number"&&W++):I[U]=ne),O.ascend()}return w&&(w.r!==void 0?(O.write("r",s.default(I)),I=void 0):w.p!=null&&(I=void 0)),I};return k(y,A,c),A.get(),b&&(A.reset(),function g(O,I,w,j,W){const p=I.getComponent();if(p){p.i!==void 0?(j=p.i,W=!0):p.d!=null&&(j=$[p.d],O=C[p.d],W=!1,p.d);let K=be(p);if(K&&K.makeInvertible){const le=f(p);_(w,K,K.makeInvertible(le,j),!0)}}let U=0,se=0;const ne=i.advancer(O,(K,le)=>v(le)?U-K-1:K-U,(K,le)=>{v(le)&&U++});for(const K of I)if(typeof K=="number"){const le=K-se,Ge=ne(le),me=le+U,Oe=J(j,W?le:me);w.descend(K),g(Ge,I,w,Oe,W),o(I.getComponent())&&se++,w.ascend()}else{const le=J(j,K);w.descend(K),g(ne(K),I,w,le,W),w.ascend()}ne.end()}(y.clone(),y,A,c,!1)),A.get()}function Vt(r,c){return ce(Pe(r,c))}const pt=r=>{if(r==null)return null;const c=r.slice();for(let y=0;y<r.length;y++){const A=c[y];Array.isArray(A)&&(c[y]=pt(A))}return c};function _t(r,c,y){l(y==="left"||y==="right","Direction must be left or right");const A=y==="left"?0:1;if(c==null)return{ok:!0,result:r};z(r),z(c);let b=null;const C=[],$=[],k=[],g=[],O=[],I=[],w=[],j=[],W=[],p=[],U=[],se=[],ne=[],K=[],le=[];let Ge=0;const me=i.readCursor(r),Oe=i.readCursor(c),ae=i.writeCursor();if(function ee(M,L=null,S){const D=a(L);D&&(D.r!==void 0?S=L.clone():D.p!=null&&(S=null,I[D.p]=M.clone()));const N=M.getComponent();let X;N&&(X=N.p)!=null&&(O[X]=L?L.clone():null,k[X]=M.clone(),S&&(p[X]=!0,W[X]=S),D&&D.p!=null&&(K[X]=D.p));const Z=i.advancer(L);for(const te of M)ee(M,Z(te),S);Z.end()}(Oe,me,null),function ee(M,L,S,D,N){const X=S.getComponent();let Z,te=!1;X&&((Z=X.d)!=null?(g[Z]=S.clone(),D!=null&&(le[D]==null&&(le[D]=[]),le[D].push(Z)),M=O[Z]||null,L=k[Z]||null,p[Z]?(N&&(U[Z]=!0),N=W[Z]||null):!N||A!==1&&K[Z]!=null||b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.moveOp(L.getPath(),S.getPath())}),te=!0):X.i!==void 0&&(M=L=null,te=!0,N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.insertOp(S.getPath(),X.i)})));const ge=a(M);ge&&(ge.r!==void 0?N=M.clone():ge.p!=null&&(ge.p,D=ge.p,N=null));const he=be(X);he&&N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.editOp(S.getPath(),he,f(X),!0)});let ue=0,Ie=0;const q=i.advancer(L,(B,pe)=>v(pe)?ue-B-1:B-ue,(B,pe)=>{v(pe)&&ue++}),P=i.advancer(M);for(const B of S)if(typeof B=="number"){const pe=B-Ie,we=q(pe);Ie+=+ee(P(pe+ue),we,S,D,N)}else{const pe=q(B);ee(P(B),pe,S,D,N)}return q.end(),P.end(),te}(me,Oe,Oe.clone(),null,null),g.map(ee=>ee&&ee.get()),b)return{ok:!1,conflict:b};U.map(ee=>!!ee);const Me=[];let Ue=null;(function ee(M,L,S,D,N){let X=!1;const Z=a(L);if(v(Z)){const q=Z.p;q!=null?(S=g[q],D=se[q]=i.writeCursor(),X=!0,N=null):(S=null,N=L.clone())}else o(a(S))&&(S=null);const te=M.getComponent();if(te){const q=te.p;q!=null?(N&&(j[q]=N),Me[q]=N||A===1&&X?null:D.getComponent(),C[q]=M.clone(),S&&(w[q]=S.clone())):te.r!==void 0&&(N||D.write("r",!0),(N||X)&&(Ue==null&&(Ue=new Set),Ue.add(te)))}let ge=0,he=0;const ue=i.advancer(L,void 0,(q,P)=>{v(P)&&ge++}),Ie=i.advancer(S,(q,P)=>o(P)?~(q-he):q-he,(q,P)=>{o(P)&&he++});if(M)for(const q of M)if(typeof q=="string"){const P=ue(q),B=Ie(q);D.descend(q),ee(M,P,B,D,N),D.ascend()}else{const P=ue(q),B=q-ge,pe=v(a(P))?null:Ie(B),we=B+he;l(we>=0),D.descend(we),ee(M,P,pe,D,N),D.ascend()}ue.end(),Ie.end()})(me,Oe,Oe.clone(),ae,null),ae.reset();let Fe=[];if(function ee(M,L,S,D,N,X){l(L);const Z=L.getComponent();let te=a(D),ge=!1;const he=(R,oe,ye)=>R?n.moveOp(R.getPath(),oe.getPath()):n.insertOp(oe.getPath(),ye.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=L.clone());const oe=R!=null?Me[R]:null;let ye=!1;if(Z.i!==void 0||R!=null&&oe){let de;te&&(te.i!==void 0||(de=te.d)!=null&&!p[de])&&(ye=de!=null?R!=null&&R===K[de]:t.default(te.i,Z.i),ye||de!=null&&A!==1&&K[de]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:he(R!=null?C[R]:null,L,Z),op2:he(de!=null?k[de]:null,D,te)})),ye||(X?b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(R!=null?C[R]:null,L,Z),op2:n.removeOp(X.getPath())}):(R!=null?(Fe[Ge]=R,N.write("d",oe.p=Ge++)):N.write("i",s.default(Z.i)),ge=!0))}else if(R!=null&&!oe){const de=j[R];de&&(X=de.clone())}R!=null?(M=C[R],S=I[R],D=w[R]):Z.i!==void 0&&(M=S=null,ye||(D=null))}else v(a(M))&&(M=S=D=null);const ue=a(M),Ie=a(S);if(v(Ie)){const R=Ie.p;Ie.r!==void 0&&(!ue||ue.r===void 0)||p[R]?(D=null,X=S.clone()):R!=null&&(D=g[R],A!==1&&K[R]!=null||((N=ne[R])||(N=ne[R]=i.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(te)&&(D=null);te=D!=null?D.getComponent():null;const q=be(Z);if(q){const R=f(Z);if(X)b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.editOp(L.getPath(),q,R,!0),op2:n.removeOp(X.getPath())});else{const oe=be(te);let ye;if(oe){if(q!==oe)throw Error("Transforming incompatible types");const de=f(te);ye=q.transform(R,de,y)}else ye=s.default(R);_(N,q,ye)}}let P=0,B=0,pe=0,we=0,Le=0,Ve=0,Ne=M!=null&&M.descendFirst(),et=Ne;const Ye=i.advancer(S,void 0,(R,oe)=>{v(oe)&&pe++});let je=D!=null&&D.descendFirst(),$e=je;for(const R of L)if(typeof R=="number"){let oe;const ye=o(L.getComponent()),de=R-B;{let He;for(;Ne&&typeof(He=M.getKey())=="number";){He+=P;const Re=M.getComponent(),Je=v(Re);if(He>de||He===de&&(!Je||A===0&&ye))break;if(Je){P--;const qe=Re.p;K.includes(qe),Re.d,a(ne[Re.d]),v(a(ne[Re.d])),(Re.r===void 0||Ue&&Ue.has(Re))&&(qe==null||!Me[qe]||A!==1&&K.includes(qe))||Le--}Ne=M.nextSibling()}oe=Ne&&He===de?M:null}const Te=de-P;let Be=Ye(Te);const vt=Te-pe;let rt=null;{let He,Re;for(;je&&typeof(He=D.getKey())=="number";){Re=He-we;const Je=D.getComponent(),qe=o(Je);if(Re>vt)break;if(Re===vt){if(!qe){rt=D;break}{if(A===0&&ye){rt=D;break}const ze=Be&&v(Be.getComponent());if(A===0&&ze)break}}if(qe){const ze=Je.d;K[ze],Je.i===void 0&&(p[ze]||K[ze]!=null&&A!==1)?(p[ze]||K[ze]!=null&&A===0)&&(we++,Ve--):we++}je=D.nextSibling()}}const Tt=vt+we+Le+Ve;l(Tt>=0,"trying to descend to a negative index"),N.descend(Tt),ye&&(oe=Be=rt=null,B++),ee(oe,L,Be,rt,N,X)&&Ve++,N.ascend()}else{let oe;for(;Ne&&(oe=M.getKey(),typeof oe!="string"||!(oe>R||oe===R));)Ne=M.nextSibling();const ye=Ne&&oe===R?M:null,de=Ye(R);let Te;for(;je&&(Te=D.getKey(),typeof Te!="string"||!(Te>R||Te===R));)je=D.nextSibling();const Be=je&&Te===R?D:null;N.descend(R),ee(ye,L,de,Be,N,X),N.ascend()}return Ye.end(),et&&M.ascend(),$e&&D.ascend(),ge}(me,me.clone(),Oe,Oe.clone(),ae,null),b)return{ok:!1,conflict:b};ae.reset();const Se=(ee,M,L)=>ee.traverse(M,(S,D)=>{S.d!=null&&L(S.d,ee,D)});(p.length||se.length)&&(Se(Oe,ae,(ee,M,L)=>{p[ee]&&!U[ee]&&L.write("r",!0),se[ee]&&L.mergeTree(se[ee].get())}),ae.reset());const Ae=[],We=[];if((ne.length||p.length)&&!b){const ee=i.readCursor(pt(ae.get()));if(Se(ee,null,(M,L)=>{Ae[M]=L.clone()}),ne.forEach(M=>{M&&Se(i.readCursor(M.get()),null,(L,S)=>{Ae[L]=S.clone()})}),function M(L,S,D,N,X,Z){const te=a(S);if(te&&v(te))if(te.p!=null){const P=te.p;Ae[P].getPath(),D=Ae[P],N=We[P]=i.writeCursor()}else te.r!==void 0&&(D=null);else o(a(D))&&(D=null);const ge=L.getComponent();if(ge){let P;if((P=ge.d)!=null){const B=ne[P];B&&(B.get(),N.mergeTree(B.get()),D=i.readCursor(B.get()))}}let he=0,ue=0;const Ie=i.advancer(S,void 0,(P,B)=>{v(B)&&he--}),q=i.advancer(D,(P,B)=>o(B)?-(P-ue)-1:P-ue,(P,B)=>{o(B)&&ue++});for(const P of L)if(typeof P=="number"){const B=Ie(P),pe=P+he,we=q(pe),Le=pe+ue;N.descend(Le),M(L,B,we,N),N.ascend()}else N.descend(P),M(L,Ie(P),q(P),N),N.ascend();Ie.end(),q.end()}(Oe,ee,ee.clone(),ae),ae.reset(),b)return{ok:!1,conflict:b};if(ae.get(),We.length){const M=We.map(S=>S?S.get():null),L=i.readCursor(pt(ae.get()));if(Se(L,ae,(S,D,N)=>{const X=M[S];X&&(N.mergeTree(X),M[S]=null)}),M.find(S=>S)){const S=i.writeCursor(),D=i.writeCursor();let N=0,X=0;M.forEach(Z=>{Z!=null&&Se(i.readCursor(Z),null,te=>{const ge=Fe[te];S.writeMove(C[ge].getPath(),$[ge].getPath(),N++);const he=le[ge];he&&he.forEach(ue=>{p[ue]||A!==1&&K[ue]!=null||D.writeMove(k[ue].getPath(),g[ue].getPath(),X++)})})}),b={type:d.ConflictType.BLACKHOLE,op1:S.get(),op2:D.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:ae.get()}}const Ut=r=>{const c=new Error("Transform detected write conflict");throw c.conflict=r,c.type=c.name="writeConflict",c};function qt(r,c,y){const A=_t(r,c,y);if(A.ok)return A.result;Ut(A.conflict)}const Ze=r=>{const c=i.writeCursor();return i.readCursor(r).traverse(c,(y,A)=>{(o(y)||be(y))&&A.write("r",!0)}),c.get()},zt=(r,c)=>{const{type:y,op1:A,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return c==="left"?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return i.readCursor(A).traverse(null,$=>{$.r!==void 0&&(C=!0)}),C?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.BLACKHOLE:return[Ze(A),Ze(b)];default:throw Error("Unrecognised conflict: "+y)}};function Nt(r,c,y,A){let b=null;for(;;){const C=_t(c,y,A);if(C.ok)return ie(b,C.result);{const{conflict:$}=C;r($)||Ut($);const[k,g]=zt($,A);c=ie(x(c),k),y=ie(x(y),g),b=ie(b,g)}}}})(yt),function(n){var e=Ee&&Ee.__createBinding||(Object.create?function(d,l,a,E){E===void 0&&(E=a),Object.defineProperty(d,E,{enumerable:!0,get:function(){return l[a]}})}:function(d,l,a,E){E===void 0&&(E=a),d[E]=l[a]}),t=Ee&&Ee.__exportStar||function(d,l){for(var a in d)a!=="default"&&!l.hasOwnProperty(a)&&e(l,d,a)};Object.defineProperty(n,"__esModule",{value:!0}),t(yt,n);var s=at;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var i=ut;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})}(F);class Ct{constructor(){V(this,"drawingManagerData",{});V(this,"_oldDrawingManagerData",{});V(this,"_focusDrawings",[]);V(this,"_remove$",new re.Subject);V(this,"remove$",this._remove$.asObservable());V(this,"_add$",new re.Subject);V(this,"add$",this._add$.asObservable());V(this,"_update$",new re.Subject);V(this,"update$",this._update$.asObservable());V(this,"_order$",new re.Subject);V(this,"order$",this._order$.asObservable());V(this,"_group$",new re.Subject);V(this,"group$",this._group$.asObservable());V(this,"_ungroup$",new re.Subject);V(this,"ungroup$",this._ungroup$.asObservable());V(this,"_refreshTransform$",new re.Subject);V(this,"refreshTransform$",this._refreshTransform$.asObservable());V(this,"_visible$",new re.Subject);V(this,"visible$",this._visible$.asObservable());V(this,"_focus$",new re.Subject);V(this,"focus$",this._focus$.asObservable());V(this,"_featurePluginUpdate$",new re.Subject);V(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());V(this,"_featurePluginAdd$",new re.Subject);V(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());V(this,"_featurePluginRemove$",new re.Subject);V(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());V(this,"_featurePluginOrderUpdate$",new re.Subject);V(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());V(this,"_featurePluginGroupUpdate$",new re.Subject);V(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());V(this,"_featurePluginUngroupUpdate$",new re.Subject);V(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());V(this,"_visible",!0);V(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(t=>{if(this.getDrawingByParam(t)==null)return;const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]}removeDrawingDataForUnit(e){const t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];const s=[];Object.keys(t).forEach(i=>{const d=t[i];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(l=>{s.push({unitId:e,subUnitId:i,drawingId:l})})}),s.length>0&&this.removeNotification(s)}registerDrawingData(e,t){this.drawingManagerData[e]=t;const s=[];Object.keys(t).forEach(i=>{this._establishDrawingMap(e,i);const d=t[i];Object.keys(d.data).forEach(l=>{const a=d.data[l];s.push(a)})}),s.length>0&&this.addNotification(s)}getDrawingData(e,t){return this._getDrawingData(e,t)}getBatchAddOp(e){const t=[],s=[],i=[];e.forEach(G=>{const{op:v,invertOp:o}=this._addByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),s.push(v),i.push(o)});const d=s.reduce(F.type.compose,null),l=i.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],s=[];e.forEach(E=>{const{op:G,invertOp:v}=this._removeByParam(E);t.push(G),s.push(v)});const i=t.reduce(F.type.compose,null),d=s.reduce(F.type.compose,null),{unitId:l,subUnitId:a}=e[0];return{undo:d,redo:i,unitId:l,subUnitId:a,objects:e}}getBatchUpdateOp(e){const t=[],s=[],i=[];e.forEach(G=>{const{op:v,invertOp:o}=this._updateByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),s.push(v),i.push(o)});const d=s.reduce(F.type.compose,null),l=i.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getGroupDrawingOp(a))});const d=t.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getUngroupDrawingOp(a))});const d=t.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:s,drawingId:i}=e;if(this.getDrawingByParam({unitId:t,subUnitId:s,drawingId:i})==null)return[];const l=this._getDrawingData(t,s),a=[];return Object.keys(l).forEach(E=>{const G=l[E];G.groupId===i&&a.push(G)}),a}_getGroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];a.push(F.insertOp([i,d,"data",l],t));let E=Number.NEGATIVE_INFINITY;return s.forEach(G=>{const{unitId:v,subUnitId:o,drawingId:u}=G,h=this._hasDrawingOrder({unitId:v,subUnitId:o,drawingId:u});E=Math.max(E,h),a.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:v,subUnitId:o,drawingId:u})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(i,d).length),a.push(F.insertOp([i,d,"order",E],l)),a.reduce(F.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];return s.forEach(E=>{const{unitId:G,subUnitId:v,drawingId:o}=E;a.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:G,subUnitId:v,drawingId:o})))}),a.push(F.removeOp([i,d,"data",l],!0)),a.push(F.removeOp([i,d,"order",this._getDrawingOrder(i,d).indexOf(l)],!0)),a.reduce(F.type.compose,null)}applyJson1(e,t,s){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=F.type.apply(this.drawingManagerData,s)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[t,s,i]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:s,drawingId:i})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(s=>{var E;const{unitId:i,subUnitId:d,drawingId:l}=s,a=(E=this._getDrawingData(i,d))==null?void 0:E[l];a!=null&&t.push(a)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var a;const{unitId:s,subUnitId:i,drawingId:d}=t,l=(a=this._getDrawingData(s,i))==null?void 0:a[d];l!=null&&e.push(l)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:v});if(o===-1||o===l.length-1)return;const u=F.moveOp([t,s,"order",o],[t,s,"order",o+1]);d.push(u),a.includes(l[o+1])||a.push(l[o+1])});const E=d.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:v});if(o===-1||o===0)return;const u=F.moveOp([t,s,"order",o],[t,s,"order",o-1]);d.push(u),a.includes(l[o-1])||a.push(l[o-1])});const E=d.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:u}=o,h=this._getDrawingCount(t,s)-1,T=F.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(u)],[t,s,"order",h]);E.push(T),l.includes(a[h])||l.push(a[h])});const G=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i,!0),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:u}=o,h=F.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(u)],[t,s,"order",0]);E.push(h),l.includes(a[0])||l.push(a[0])});const G=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,s,i=!1){return s.map(d=>{const l=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:l}}).sort(i===!1?ke.sortRules:ke.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:s,drawingId:i}=e;return this._establishDrawingMap(t,s),this._getDrawingOrder(t,s).indexOf(i)}_getCurrentBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this.drawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_getOldBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this._oldDrawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_establishDrawingMap(e,t,s){var i;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),s==null?null:(i=this.drawingManagerData[e][t].data)==null?void 0:i[s]}_addByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e;this._establishDrawingMap(t,s,i);const d=F.insertOp([t,s,"data",i],e),l=F.insertOp([t,s,"order",this._getDrawingOrder(t,s).length],i),a=[d,l].reduce(F.type.compose,null),E=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:s,drawingId:i}=e;if(this._establishDrawingMap(t,s,i)==null)return{op:[],invertOp:[]};const l=F.removeOp([t,s,"data",i],!0),a=F.removeOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(i)],!0),E=[l,a].reduce(F.type.compose,null),G=F.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:G}}_updateByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e,d=this._establishDrawingMap(t,s,i);if(d==null)return{op:[],invertOp:[]};const a=this._getUpdateParamCompareOp(e,d).reduce(F.type.compose,null),E=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:s,subUnitId:i,drawingId:d}=e,l=[];return Object.keys(e).forEach(a=>{const E=e[a],G=t[a];G!==E&&l.push(F.replaceOp([s,i,"data",d,a],G,E))}),l}_getDrawingData(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.data)||{}}_getDrawingOrder(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Et extends Ct{}function Gt(n){const{unitId:e,subUnitId:t,drawingId:s}=n;return`${e}#-#${t}#-#${s}`}const Wt=async n=>new Promise((e,t)=>{const s=new Image;s.src=n,s.onload=()=>{e({width:s.width,height:s.height,image:s})},s.onerror=i=>{t(i)}});var Qe=(n=>(n.URL="URL",n.UUID="UUID",n.BASE64="BASE64",n))(Qe||{}),Xe=(n=>(n.SUCCUSS="0",n.ERROR_EXCEED_SIZE="1",n.ERROR_IMAGE_TYPE="2",n.ERROR_UPLOAD_COUNT_LIMIT="3",n.ERROR_IMAGE="4",n))(Xe||{});const At=tt.createIdentifier("core.image-io.service");class Dt{constructor(){V(this,"_waitCount",0);V(this,"_change$",new re.Subject);V(this,"change$",this._change$);V(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Qe.BASE64){const s=new Image;return s.src=e,s}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,s){t===Qe.BASE64||s==null||this._imageSourceCache.set(e,s)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,s)=>{if(!Ot.includes(e.type)){s(new Error(Xe.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){s(new Error(Xe.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const i=new FileReader;i.readAsDataURL(e),i.onload=d=>{var E;const l=(E=d.target)==null?void 0:E.result;if(l==null){s(new Error(Xe.ERROR_IMAGE)),this._decreaseWaiting();return}const a=ke.Tools.generateRandomId(6);t({imageId:a,imageSourceType:Qe.BASE64,source:l,base64Cache:l,status:Xe.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const Lt="__default_document_sub_component_id20231101__";var Pt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Pt||{}),Mt=(n=>(n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n[n.DRAWING_IMAGE=0]="DRAWING_IMAGE",n[n.DRAWING_SHAPE=1]="DRAWING_SHAPE",n[n.DRAWING_CHART=2]="DRAWING_CHART",n[n.DRAWING_TABLE=3]="DRAWING_TABLE",n[n.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",n[n.DRAWING_VIDEO=5]="DRAWING_VIDEO",n[n.DRAWING_GROUP=6]="DRAWING_GROUP",n[n.DRAWING_UNIT=7]="DRAWING_UNIT",n[n.DRAWING_DOM=8]="DRAWING_DOM",n))(Mt||{});const St=tt.createIdentifier("univer.drawing-manager.service");var Bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,xt=(n,e,t,s)=>{for(var i=s>1?void 0:s?Ht(e,t):e,d=n.length-1,l;d>=0;d--)(l=n[d])&&(i=(s?l(e,t,i):l(i))||i);return s&&i&&Bt(e,t,i),i},Kt=(n,e)=>(t,s)=>e(t,s,n);const Ft="DRAWING_PLUGIN";Y.UniverDrawingPlugin=(gt=class extends ke.Plugin{constructor(e,t){super(),this._config=e,this._injector=t}onStarting(e){this._initDependencies(e)}_initDependencies(e){var i;const t=[[At,{useClass:Dt}],[St,{useClass:Et}]];ke.mergeOverrideWithDependencies(t,(i=this._config)==null?void 0:i.override).forEach(d=>e.add(d))}},V(gt,"pluginName",Ft),gt),Y.UniverDrawingPlugin=xt([Kt(1,tt.Inject(tt.Injector))],Y.UniverDrawingPlugin),Y.ArrangeTypeEnum=Pt,Y.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Lt,Y.DRAWING_IMAGE_ALLOW_IMAGE_LIST=Ot,Y.DRAWING_IMAGE_ALLOW_SIZE=5242880,Y.DRAWING_IMAGE_COUNT_LIMIT=10,Y.DRAWING_IMAGE_HEIGHT_LIMIT=500,Y.DRAWING_IMAGE_WIDTH_LIMIT=500,Y.DrawingManagerService=Et,Y.DrawingTypeEnum=Mt,Y.IDrawingManagerService=St,Y.IImageIoService=At,Y.ImageIoService=Dt,Y.ImageSourceType=Qe,Y.ImageUploadStatusType=Xe,Y.UnitDrawingService=Ct,Y.getDrawingShapeKeyByDrawingSearch=Gt,Y.getImageSize=Wt,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(Y,re){typeof exports=="object"&&typeof module<"u"?re(exports,require("rxjs"),require("@univerjs/core"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","@univerjs/core","@wendellhu/redi"],re):(Y=typeof globalThis<"u"?globalThis:Y||self,re(Y.UniverDrawing={},Y.rxjs,Y.UniverCore,Y["@wendellhu/redi"]))})(this,function(Y,re,ke,tt){"use strict";var Xt=Object.defineProperty;var Zt=(Y,re,ke)=>re in Y?Xt(Y,re,{enumerable:!0,configurable:!0,writable:!0,value:ke}):Y[re]=ke;var V=(Y,re,ke)=>Zt(Y,typeof re!="symbol"?re+"":re,ke);var gt;const Ot=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},yt={},it={};Object.defineProperty(it,"__esModule",{value:!0});function Rt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!st(n[t],e[t]))return!1;for(let t in e)if(n[t]===void 0)return!1;return!0}function kt(n,e){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!st(n[t],e[t]))return!1;return!0}function st(n,e){return n===e?!0:n===null||e===null||typeof n!="object"||typeof e!="object"?!1:Array.isArray(n)?kt(n,e):Rt(n,e)}it.default=st;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});function lt(n){if(n===null)return null;if(Array.isArray(n))return n.map(lt);if(typeof n=="object"){const e={};for(let t in n)e[t]=lt(n[t]);return e}else return n}ot.default=lt;var at={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.eachChildOf=n.advancer=n.readCursor=n.writeCursor=n.WriteCursor=n.ReadCursor=n.isValidPathItem=void 0;function e(v,o){if(!v)throw new Error(o)}const t=v=>v!=null&&typeof v=="object"&&!Array.isArray(v),s=(v,o)=>typeof v==typeof o?v>o:typeof v=="string"&&typeof o=="number";function i(v,o){for(let u in v){const h=u;o.write(h,v[h])}}n.isValidPathItem=v=>typeof v=="number"||typeof v=="string"&&v!=="__proto__";class d{constructor(o=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=o}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,t(this.container[this.idx])&&this.idx--)}getPath(){const o=[];let u=this.container,h=this.parents.length-1,T=this.idx;for(;T>=0;)o.unshift(u[T]),T===0?(T=this.indexes[h*2],u=this.parents[h--]):T-=t(u[T-1])?2:1;return o}}class l extends d{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let o;return this.container&&this.container.length>this.idx+1&&t(o=this.container[this.idx+1])?o:null}descendFirst(){let o=this.idx+1;if(!this.container||o>=this.container.length||t(this.container[o])&&o+1>=this.container.length)return!1;t(this.container[o])&&o++;const u=this.container[o];return Array.isArray(u)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(o),this.idx=0,this.container=u):this.idx=o,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const o=this.indexes[this.indexes.length-1]+1,u=this.parents[this.parents.length-1];return o>=u.length?!1:(e(!isNaN(o)),this.indexes[this.indexes.length-1]=o,this.container=u[o],!0)}_init(o,u,h,T){this.container=o,this.idx=u,this.parents=h.slice(),this.indexes=T.slice()}clone(){const o=new l;return o._init(this.container,this.idx,this.parents,this.indexes),o}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(o,u){const h=this.getComponent();h&&u(h,o);for(const T of this)o&&o.descend(T),this.traverse(o,u),o&&o.ascend()}eachPick(o,u){this.traverse(o,(h,T)=>{h.p!=null&&u(h.p,T)})}eachDrop(o,u){this.traverse(o,(h,T)=>{h.d!=null&&u(h.d,T)})}}n.ReadCursor=l;class a extends d{constructor(o=null){super(o),this.pendingDescent=[],this._op=o}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let o=0;o<this.pendingDescent.length;o++){const u=this.pendingDescent[o];let h=this.idx+1;if(h<this.container.length&&t(this.container[h])&&h++,e(h===this.container.length||!t(this.container[h])),h===this.container.length)this.container.push(u),this.idx=h;else if(this.container[h]===u)this.idx=h;else{if(!Array.isArray(this.container[h])){const T=this.container.splice(h,this.container.length-h);this.container.push(T),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(s(u,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&s(u,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===u)this.container=this.container[h];else{const T=[u];this.container.splice(h,0,T),this.container=T}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const o=this.idx+1;if(o<this.container.length&&t(this.container[o]))return this.container[o];{const u={};return this.container.splice(o,0,u),u}}write(o,u){const h=this.getComponent();e(h[o]==null||h[o]===u,"Internal consistency error: Overwritten component. File a bug"),h[o]=u}get(){return this._op}descend(o){if(!n.isValidPathItem(o))throw Error("Invalid JSON key");this.pendingDescent.push(o)}descendPath(o){return this.pendingDescent.push(...o),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(o,u=i){if(o===null)return;if(e(Array.isArray(o)),o===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,T=this.parents.length;let J=0;for(let _e=0;_e<o.length;_e++){const Q=o[_e];typeof Q=="string"||typeof Q=="number"?(J++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,u):typeof Q=="object"&&u(Q,this)}for(;J--;)this.ascend();this.lcIdx=this.parents.length===T?h:-1}at(o,u){this.descendPath(o),u(this);for(let h=0;h<o.length;h++)this.ascend();return this}writeAtPath(o,u,h){return this.at(o,()=>this.write(u,h)),this.reset(),this}writeMove(o,u,h=0){return this.writeAtPath(o,"p",h).writeAtPath(u,"d",h)}getPath(){const o=super.getPath();return o.push(...this.pendingDescent),o}}n.WriteCursor=a,n.writeCursor=()=>new a,n.readCursor=v=>new l(v);function E(v,o,u){let h,T;T=h=v?v.descendFirst():!1;function J(_e){let Q;for(;T;){const Ce=Q=v.getKey();if(_e!=null){let Ke=!1;if(o&&typeof Ce=="number"&&(Q=o(Ce,v.getComponent()),Q<0&&(Q=~Q,Ke=!0)),s(Q,_e))return null;if(Q===_e&&!Ke)return v}u&&typeof Q=="number"&&u(Q,v.getComponent()),T=v.nextSibling()}return null}return J.end=()=>{h&&v.ascend()},J}n.advancer=E;function G(v,o,u){let h,T,J,_e;for(h=T=v&&v.descendFirst(),J=_e=o&&o.descendFirst();h||J;){let Q=h?v.getKey():null,Ce=J?o.getKey():null;Q!==null&&Ce!==null&&(s(Ce,Q)?Ce=null:Q!==Ce&&(Q=null)),u(Q==null?Ce:Q,Q!=null?v:null,Ce!=null?o:null),Q!=null&&h&&(h=v.nextSibling()),Ce!=null&&J&&(J=o.nextSibling())}T&&v.ascend(),_e&&o.ascend()}n.eachChildOf=G})(at);var ut={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(n.ConflictType||(n.ConflictType={}))})(ut);var ct={},xe={},bt;function dt(){return bt||(bt=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.uniToStrPos=xe.strPosToUni=void 0,xe.strPosToUni=(n,e=n.length)=>{let t=0,s=0;for(;s<e;s++){const i=n.charCodeAt(s);i>=55296&&i<=57343&&(t++,s++)}if(s!==e)throw Error("Invalid offset - splits unicode bytes");return s-t},xe.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const s=n.charCodeAt(t);t+=s>=55296&&s<=57343?2:1}return t}),xe}var ft={},It;function ht(){return It||(It=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=dt(),t=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let _=null;for(let m=0;m<f.length;m++){const H=f[m];switch(typeof H){case"object":if(typeof H.d!="number"&&typeof H.d!="string")throw Error("Delete must be number or string");if(n.dlen(H.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(H.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(H>0))throw Error("Skip components must be >0");if(typeof _=="number")throw Error("Adjacent skip components should be combined");break}_=H}if(typeof _=="number")throw Error("Op has a trailing skip")};function s(f,_){let m=0,H=0;for(let z=0;z<f.length;z++){const x=f[z];switch(_(x,m,H),typeof x){case"object":m+=n.dlen(x.d);break;case"string":H+=e.strPosToUni(x);break;case"number":m+=x,H+=x;break}}}n.eachOp=s;function i(f,_){const m=[],H=a(m);return s(f,(z,x,De)=>{H(_(z,x,De))}),o(m)}const d=f=>f,l=f=>i(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const a=f=>_=>{if(!(!_||_.d===0||_.d===""))if(f.length===0)f.push(_);else if(typeof _==typeof f[f.length-1])if(typeof _=="object"){const m=f[f.length-1];m.d=typeof m.d=="string"&&typeof _.d=="string"?m.d+_.d:n.dlen(m.d)+n.dlen(_.d)}else f[f.length-1]+=_;else f.push(_)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);n.uniSlice=(f,_,m)=>{const H=e.uniToStrPos(f,_),z=m==null?1/0:e.uniToStrPos(f,m);return f.slice(H,z)};const G=(f,_,m)=>typeof f=="number"?m==null?f-_:Math.min(f,m)-_:n.uniSlice(f,_,m),v=f=>{let _=0,m=0;return{take:(x,De)=>{if(_===f.length)return x===-1?null:x;const fe=f[_];let ie;if(typeof fe=="number")return x===-1||fe-m<=x?(ie=fe-m,++_,m=0,ie):(m+=x,x);if(typeof fe=="string"){if(x===-1||De==="i"||e.strPosToUni(fe.slice(m))<=x)return ie=fe.slice(m),++_,m=0,ie;{const ce=m+e.uniToStrPos(fe.slice(m),x);return ie=fe.slice(m,ce),m=ce,ie}}else{if(x===-1||De==="d"||n.dlen(fe.d)-m<=x)return ie={d:G(fe.d,m)},++_,m=0,ie;{let ce=G(fe.d,m,m+x);return m+=x,{d:ce}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function u(f,_,m){if(m!=="left"&&m!=="right")throw Error("side ("+m+") must be 'left' or 'right'");t(f),t(_);const H=[],z=a(H),{take:x,peek:De}=v(f);for(let ie=0;ie<_.length;ie++){const ce=_[ie];let ve,Pe;switch(typeof ce){case"number":for(ve=ce;ve>0;)Pe=x(ve,"i"),z(Pe),typeof Pe!="string"&&(ve-=E(Pe));break;case"string":m==="left"&&typeof De()=="string"&&z(x(-1)),z(e.strPosToUni(ce));break;case"object":for(ve=n.dlen(ce.d);ve>0;)switch(Pe=x(ve,"i"),typeof Pe){case"number":ve-=Pe;break;case"string":z(Pe);break;case"object":ve-=n.dlen(Pe.d)}break}}let fe;for(;fe=x(-1);)z(fe);return o(H)}function h(f,_){t(f),t(_);const m=[],H=a(m),{take:z}=v(f);for(let De=0;De<_.length;De++){const fe=_[De];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=z(ie,"d"),H(ce),typeof ce!="object"&&(ie-=E(ce));break;case"string":H(fe);break;case"object":ie=n.dlen(fe.d);let ve=0;for(;ve<ie;)switch(ce=z(ie-ve,"d"),typeof ce){case"number":H({d:G(fe.d,ve,ve+ce)}),ve+=ce;break;case"string":ve+=e.strPosToUni(ce);break;case"object":H(ce)}break}}let x;for(;x=z(-1);)H(x);return o(m)}const T=(f,_)=>{let m=0;for(let H=0;H<_.length&&f>m;H++){const z=_[H];switch(typeof z){case"number":{m+=z;break}case"string":const x=e.strPosToUni(z);m+=x,f+=x;break;case"object":f-=Math.min(n.dlen(z.d),f-m);break}}return f},J=(f,_)=>typeof f=="number"?T(f,_):f.map(m=>T(m,_));function _e(f,_,m){return i(f,(H,z)=>typeof H=="object"&&typeof H.d=="number"?{d:m.slice(_,z,z+H.d)}:H)}function Q(f){return i(f,_=>{switch(typeof _){case"object":if(typeof _.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return _.d;case"string":return{d:_};case"number":return _}})}function Ce(f){return i(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function Ke(f){let _=!0;return s(f,m=>{typeof m=="object"&&typeof m.d=="number"&&(_=!1)}),_}function be(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:l,checkOp:t,create(_=""){if(typeof _!="string")throw Error("Initial data must be a string");return f.create(_)},apply(_,m){t(m);const H=f.builder(_);for(let z=0;z<m.length;z++){const x=m[z];switch(typeof x){case"number":H.skip(x);break;case"string":H.append(x);break;case"object":H.del(n.dlen(x.d));break}}return H.build()},transform:u,compose:h,transformPosition:T,transformSelection:J,isInvertible:Ke,makeInvertible(_,m){return _e(_,m,f)},stripInvertible:Ce,invert:Q,invertWithDoc(_,m){return Q(_e(_,m,f))},isNoop:_=>_.length===0}}n.default=be}(ft)),ft}var nt={},mt;function jt(){if(mt)return nt;mt=1,Object.defineProperty(nt,"__esModule",{value:!0});const n=ht(),e=dt();function t(s,i){return{get:s,getLength(){return s().length},insert(d,l,a){const E=e.strPosToUni(s(),d);return i([E,l],a)},remove(d,l,a){const E=e.strPosToUni(s(),d);return i([E,{d:l}],a)},_onOp(d){n.eachOp(d,(l,a,E)=>{switch(typeof l){case"string":this.onInsert&&this.onInsert(E,l);break;case"object":const G=n.dlen(l.d);this.onRemove&&this.onRemove(E,G)}})},onInsert:null,onRemove:null}}return nt.default=t,t.provides={text:!0},nt}var wt;function $t(){return wt||(wt=1,function(n){var e=Ee&&Ee.__createBinding||(Object.create?function(u,h,T,J){J===void 0&&(J=T),Object.defineProperty(u,J,{enumerable:!0,get:function(){return h[T]}})}:function(u,h,T,J){J===void 0&&(J=T),u[J]=h[T]}),t=Ee&&Ee.__setModuleDefault||(Object.create?function(u,h){Object.defineProperty(u,"default",{enumerable:!0,value:h})}:function(u,h){u.default=h}),s=Ee&&Ee.__importStar||function(u){if(u&&u.__esModule)return u;var h={};if(u!=null)for(var T in u)Object.hasOwnProperty.call(u,T)&&e(h,u,T);return t(h,u),h},i=Ee&&Ee.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(n,"__esModule",{value:!0}),n.type=n.remove=n.insert=void 0;const d=dt(),l=s(ht()),a=i(jt()),E={create(u){return u},toString(u){return u},builder(u){if(typeof u!="string")throw Error("Invalid document snapshot: "+u);const h=[];return{skip(T){let J=d.uniToStrPos(u,T);if(J>u.length)throw Error("The op is too long for this document");h.push(u.slice(0,J)),u=u.slice(J)},append(T){h.push(T)},del(T){u=u.slice(d.uniToStrPos(u,T))},build(){return h.join("")+u}}},slice:l.uniSlice},G=l.default(E),v=Object.assign(Object.assign({},G),{api:a.default});n.type=v,n.insert=(u,h)=>h.length===0?[]:u===0?[h]:[u,h],n.remove=(u,h)=>l.dlen(h)===0?[]:u===0?[{d:h}]:[u,{d:h}];var o=ht();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ct)),ct}(function(n){var e=Ee&&Ee.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(n,"__esModule",{value:!0}),n.editOp=n.replaceOp=n.insertOp=n.moveOp=n.removeOp=n.type=void 0;const t=e(it),s=e(ot),i=at,d=ut;function l(r,c){if(!r)throw new Error(c)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:i.readCursor,writeCursor:i.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:Q,checkValidOp:z,normalize:x,apply:De,transformPosition:fe,compose:ie,tryTransform:_t,transform:qt,makeInvertible:Pe,invert:ce,invertWithDoc:Vt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,c,y)=>Nt(()=>!0,r,c,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(c,y,A)=>Nt(r,c,y,A)})};const a=r=>r?r.getComponent():null;function E(r){return r&&typeof r=="object"&&!Array.isArray(r)}const G=r=>Array.isArray(r)?r.slice():r!==null&&typeof r=="object"?Object.assign({},r):r,v=r=>r&&(r.p!=null||r.r!==void 0),o=r=>r&&(r.d!=null||r.i!==void 0);function u(r,c){return l(r!=null),typeof c=="number"?(l(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(c,1)):(l(E(r),"Invalid key - child is not an object"),delete(r=Object.assign({},r))[c]),r}function h(r,c,y){return typeof c=="number"?(l(r!=null,"Container is missing for key"),l(Array.isArray(r),"Cannot use numerical key for object container"),l(r.length>=c,"Cannot insert into out of bounds index"),r.splice(c,0,y)):(l(E(r),"Cannot insert into missing item"),l(r[c]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),r[c]=y),y}n.removeOp=(r,c=!0)=>i.writeCursor().writeAtPath(r,"r",c).get(),n.moveOp=(r,c)=>i.writeCursor().writeMove(r,c).get(),n.insertOp=(r,c)=>i.writeCursor().writeAtPath(r,"i",c).get(),n.replaceOp=(r,c,y)=>i.writeCursor().at(r,A=>{A.write("r",c),A.write("i",y)}).get(),n.editOp=(r,c,y,A=!1)=>i.writeCursor().at(r,b=>_(b,c,y,A)).get();const T=(r,c)=>r!=null&&(typeof c=="number"?Array.isArray(r):typeof r=="object"),J=(r,c)=>T(r,c)?r[c]:void 0,_e={};function Q(r){let c=r.type?r.type:r;c.name&&(_e[c.name]=c),c.uri&&(_e[c.uri]=c)}const Ce=r=>{const c=_e[r];if(c)return c;throw Error("Missing type: "+r)};Q($t());const Ke=(r,c)=>r+c;Q({name:"number",apply:Ke,compose:Ke,invert:r=>-r,transform:r=>r});const be=r=>r==null?null:r.et?Ce(r.et):r.es?_e["text-unicode"]:r.ena!=null?_e.number:null,f=r=>r.es?r.es:r.ena!=null?r.ena:r.e,_=(r,c,y,A=!1)=>{const[b,C]=typeof c=="string"?[Ce(c),c]:[c,c.name];!A&&b.isNoop&&b.isNoop(y)||(C==="number"?r.write("ena",y):C==="text-unicode"?r.write("es",y):(r.write("et",C),r.write("e",y)))};function m(r){l(typeof r=="number"),l(r>=0),l(r===(0|r))}function H(r){typeof r=="number"?m(r):l(typeof r=="string")}function z(r){if(r===null)return;const c=new Set,y=new Set,A=C=>{let $=!0,k=!1;for(let g in C){const O=C[g];if($=!1,l(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")m(O),l(!c.has(O)),c.add(O),l(C.r===void 0);else if(g==="d")m(O),l(!y.has(O)),y.add(O),l(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){l(!k),k=!0;const I=be(C);l(I,"Missing type in edit"),I.checkValidOp&&I.checkValidOp(f(C))}}l(!$)},b=(C,$,k)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");$||H(C[0]);let g=1,O=0,I=0;for(let w=0;w<C.length;w++){const j=C[w];if(l(j!=null),Array.isArray(j)){const W=b(j,!1);if(O){const p=typeof I,U=typeof W;p===U?l(I<W,"descent keys are not in order"):l(p==="number"&&U==="string")}I=W,O++,g=3}else typeof j=="object"?(l(g===1,`Prev not scalar - instead ${g}`),A(j),g=2):(l(g!==3),H(j),l(i.isValidPathItem(j),"Invalid path key"),g=1)}return l(O!==1,"Operation makes multiple descents. Remove some []"),l(g===2||g===3),C[0]};b(r,!0),l(c.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<c.size;C++)l(c.has(C)),l(y.has(C))}function x(r){let c=0,y=[];const A=i.writeCursor();return A.mergeTree(r,(b,C)=>{const $=be(b);if($){const g=f(b);_(C,$,$.normalize?$.normalize(g):g)}for(const g of["r","p","i","d"])if(b[g]!==void 0){const O=g==="p"||g==="d"?(k=b[g],y[k]==null&&(y[k]=c++),y[k]):b[g];C.write(g,O)}var k}),A.get()}function De(r,c){if(z(c),c===null)return r;const y=[];return function A(b,C){let $=b,k=0,g={root:b},O=0,I=g,w="root";function j(){for(;O<k;O++){let W=C[O];typeof W!="object"&&(l(T(I,w)),I=I[w]=G(I[w]),w=W)}}for(;k<C.length;k++){const W=C[k];if(Array.isArray(W)){const p=A($,W);p!==$&&p!==void 0&&(j(),$=I[w]=p)}else if(typeof W=="object"){W.d!=null?(j(),$=h(I,w,y[W.d])):W.i!==void 0&&(j(),$=h(I,w,W.i));const p=be(W);if(p)j(),$=I[w]=p.apply($,f(W));else if(W.e!==void 0)throw Error("Subtype "+W.et+" undefined")}else $=J($,W)}return g.root}(r=function A(b,C){const $=[];let k=0;for(;k<C.length;k++){const w=C[k];if(Array.isArray(w))break;typeof w!="object"&&($.push(b),b=J(b,w))}for(let w=C.length-1;w>=k;w--)b=A(b,C[w]);for(--k;k>=0;k--){const w=C[k];if(typeof w!="object"){const j=$.pop();b=b===J(j,w)?j:b===void 0?u(j,w):(O=w,I=b,(g=G(g=j))[O]=I,g)}else v(w)&&(l(b!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(y[w.p]=b),b=void 0)}var g,O,I;return b}(r,c),c)}function fe(r,c){r=r.slice(),z(c);const y=i.readCursor(c);let A,b,C=!1;const $=[];for(let g=0;;g++){const O=r[g],I=y.getComponent();if(I&&(I.r!==void 0?C=!0:I.p!=null&&(C=!1,A=I.p,b=g)),g>=r.length)break;let w=0;const j=i.advancer(y,void 0,(p,U)=>{v(U)&&w++});$.unshift(j);const W=j(O);if(typeof O=="number"&&(r[g]-=w),!W)break}if($.forEach(g=>g.end()),C)return null;const k=()=>{let g=0;if(A!=null){const O=y.getPath();g=O.length,r=O.concat(r.slice(b))}for(;g<r.length;g++){const O=r[g],I=a(y),w=be(I);if(w){const p=f(I);w.transformPosition&&(r[g]=w.transformPosition(r[g],p));break}let j=0;const W=i.advancer(y,(p,U)=>o(U)?~(p-j):p-j,(p,U)=>{o(U)&&j++})(O);if(typeof O=="number"&&(r[g]+=j),!W)break}};return A!=null?y.eachDrop(null,g=>{g===A&&k()}):k(),r}function ie(r,c){if(z(r),z(c),r==null)return c;if(c==null)return r;let y=0;const A=i.readCursor(r),b=i.readCursor(c),C=i.writeCursor(),$=[],k=[],g=[],O=[],I=[],w=[],j=new Set;A.traverse(null,p=>{p.p!=null&&(g[p.p]=A.clone())}),b.traverse(null,p=>{p.d!=null&&(O[p.d]=b.clone())});const W=i.writeCursor();return function p(U,se,ne,K,le,Ge,me,Oe){l(se||ne);const ae=a(se),Me=a(ne),Ue=!!Me&&Me.r!==void 0,Fe=!!ae&&ae.i!==void 0,Se=ae?ae.d:null,Ae=Me?Me.p:null,We=(Ge||Ue)&&Ae==null;if(Ae!=null)K=O[Ae],me=k[Ae]=new i.WriteCursor;else if(Me&&Me.r!==void 0)K=null;else{const P=a(K);P&&P.d!=null&&(K=null)}const ee=a(K);if(Se!=null)if(U=g[Se],Oe=$[Se]=new i.WriteCursor,We)Ge&&!Ue&&Oe.write("r",!0);else{const P=I[Se]=y++;me.write("d",P)}else if(ae&&ae.i!==void 0)U=null;else{const P=a(U);P&&P.p!=null&&(U=null)}let M;Fe?(l(le===void 0),M=ae.i):M=le;const L=(Ae==null?!Fe||Ge||Ue:M===void 0)?null:me.getComponent();if(Ae!=null){if(!(le!==void 0||Fe)){const P=Se!=null?I[Se]:y++;w[Ae]=P,Oe.write("p",P)}}else Ue&&(Fe||le!==void 0||(Me.r,Oe.write("r",Me.r)));const S=We?null:be(ae),D=be(ee);if((S||D)&&(S&&S.name,D&&D.name),S&&D){l(S===D);const P=f(ae),B=f(ee),pe=S.compose(P,B);_(me,S,pe),j.add(ee)}else S?_(me,S,f(ae)):D&&(_(me,D,f(ee)),j.add(ee));const N=typeof M=="object"&&M!=null;let X=!1,Z=0,te=0,ge=0,he=0,ue=0;const Ie=i.advancer(K,(P,B)=>o(B)?he-P-1:P-he,(P,B)=>{o(B)&&he++}),q=i.advancer(U,(P,B)=>v(B)?Z-P-1:P-Z,(P,B)=>{v(B)&&Z++});if(i.eachChildOf(se,ne,(P,B,pe)=>{let we,Le,Ve=P,Ne=P,et=P;if(typeof P=="number"){let ye=P+ge;Le=Ie(ye),Ne=ye+he;let de=P+te;we=q(de),o(a(Le))&&(we=null),Ve=de+Z,et=P+ue,l(Ve>=0,"p1PickKey is negative"),l(Ne>=0,"p2DropKey is negative");const Te=o(a(B)),Be=v(a(pe));(Te||Be&&!We)&&ue--,Te&&te--,Be&&ge--}else we=q(P),Le=Ie(P);Oe.descend(Ve),me.descend(Ne);const Ye=N&&!o(a(B))?M[et]:void 0,je=p(we,B,pe,Le,Ye,We,me,Oe);var $e,R,oe;N&&!We?Ye!==je&&(X||(M=Array.isArray(M)?M.slice():Object.assign({},M),X=!0),$e=M,oe=je,typeof(R=et)=="number"?(l(Array.isArray($e)),l(R<$e.length)):(l(!Array.isArray($e)),l($e[R]!==void 0)),oe===void 0?typeof R=="number"?$e.splice(R,1):delete $e[R]:$e[R]=oe):l(je===void 0),me.ascend(),Oe.ascend()}),q.end(),Ie.end(),L!=null)L.i=M;else if(!Ge&&!Ue&&Ae==null)return M}(A,A.clone(),b,b.clone(),void 0,!1,C,W),C.reset(),C.mergeTree(W.get()),C.reset(),C.get(),$.map(p=>p.get()),k.map(p=>p.get()),A.traverse(C,(p,U)=>{const se=p.p;if(se!=null){const ne=I[se];ne!=null&&U.write("p",ne);const K=$[se];K&&K.get(),K&&U.mergeTree(K.get())}else p.r!==void 0&&U.write("r",p.r)}),C.reset(),C.get(),b.traverse(C,(p,U)=>{const se=p.d;if(se!=null){const K=w[se];K!=null&&U.write("d",K);const le=k[se];le&&U.mergeTree(le.get())}else p.i!==void 0&&U.write("i",p.i);const ne=be(p);ne&&!j.has(p)&&_(U,ne,f(p))}),C.get()}function ce(r){if(r==null)return null;const c=new i.ReadCursor(r),y=new i.WriteCursor;let A;const b=[],C=[];return function $(k,g,O){const I=k.getComponent();let w,j=!1;if(I){I.p!=null&&(g.write("d",I.p),b[I.p]=k.clone()),I.r!==void 0&&g.write("i",I.r),I.d!=null&&(g.write("p",I.d),O=void 0),I.i!==void 0&&(O=w=I.i);const p=be(I);p&&(O===void 0?(A||(A=new Set),A.add(I)):(f(I),O=p.apply(O,f(I)),j=!0))}let W=0;for(const p of k){g.descend(p);const U=typeof p=="number"?p-W:p,se=J(O,U);o(k.getComponent())&&W++;const ne=$(k,g,se);if(O!==void 0&&ne!==void 0){if(j||(j=!0,O=G(O)),!T(O,U))throw Error("Cannot modify child - invalid operation");O[U]=ne}g.ascend()}if(w===void 0)return j?O:void 0;g.write("r",O)}(c,y,void 0),A&&(y.reset(),function $(k,g,O){const I=g.getComponent();if(I){const p=I.d;if(p!=null&&(k=b[p],O=C[p]=i.writeCursor()),A.has(I)){const U=be(I);if(!U.invert)throw Error(`Cannot invert subtype ${U.name}`);_(O,U,U.invert(f(I)))}}let w=0,j=0;const W=i.advancer(k,(p,U)=>v(U)?w-p-1:p-w,(p,U)=>{v(U)&&w++});for(const p of g)if(typeof p=="number"){const U=p-j,se=W(U),ne=U+w;O.descend(ne),$(se,g,O),o(g.getComponent())&&j++,O.ascend()}else O.descend(p),$(W(p),g,O),O.ascend();W.end()}(c.clone(),c,y),C.length&&(y.reset(),c.traverse(y,($,k)=>{const g=$.p;if(g!=null){const O=C[g];O&&O.get(),O&&k.mergeTree(O.get())}}))),y.get()}const ve=(r,c)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?ve(y,c):c(y)));function Pe(r,c){if(r==null||!ve(r,g=>{var O;return g.r!==void 0||((O=be(g))===null||O===void 0?void 0:O.makeInvertible)!=null}))return r;const y=new i.ReadCursor(r),A=new i.WriteCursor;let b=!1;const C=[],$=[],k=(g,O,I)=>{const w=g.getComponent();let j=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const p=w.p;if(p!=null&&(C[p]=g.clone(),l(I!==void 0,"Operation picks up at an invalid key"),$[p]=I,O.write("p",w.p)),w.r!==void 0&&I===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const U=be(w);U&&(U.makeInvertible?b=!0:_(O,U,f(w),!0))}let W=0;for(const p of g){O.descend(p);const U=typeof p=="number"?p-W:p,se=J(I,U),ne=k(g,O,se);se!==ne&&(j||(j=!0,I=G(I)),ne===void 0?(I=u(I,U),typeof p=="number"&&W++):I[U]=ne),O.ascend()}return w&&(w.r!==void 0?(O.write("r",s.default(I)),I=void 0):w.p!=null&&(I=void 0)),I};return k(y,A,c),A.get(),b&&(A.reset(),function g(O,I,w,j,W){const p=I.getComponent();if(p){p.i!==void 0?(j=p.i,W=!0):p.d!=null&&(j=$[p.d],O=C[p.d],W=!1,p.d);let K=be(p);if(K&&K.makeInvertible){const le=f(p);_(w,K,K.makeInvertible(le,j),!0)}}let U=0,se=0;const ne=i.advancer(O,(K,le)=>v(le)?U-K-1:K-U,(K,le)=>{v(le)&&U++});for(const K of I)if(typeof K=="number"){const le=K-se,Ge=ne(le),me=le+U,Oe=J(j,W?le:me);w.descend(K),g(Ge,I,w,Oe,W),o(I.getComponent())&&se++,w.ascend()}else{const le=J(j,K);w.descend(K),g(ne(K),I,w,le,W),w.ascend()}ne.end()}(y.clone(),y,A,c,!1)),A.get()}function Vt(r,c){return ce(Pe(r,c))}const pt=r=>{if(r==null)return null;const c=r.slice();for(let y=0;y<r.length;y++){const A=c[y];Array.isArray(A)&&(c[y]=pt(A))}return c};function _t(r,c,y){l(y==="left"||y==="right","Direction must be left or right");const A=y==="left"?0:1;if(c==null)return{ok:!0,result:r};z(r),z(c);let b=null;const C=[],$=[],k=[],g=[],O=[],I=[],w=[],j=[],W=[],p=[],U=[],se=[],ne=[],K=[],le=[];let Ge=0;const me=i.readCursor(r),Oe=i.readCursor(c),ae=i.writeCursor();if(function ee(M,L=null,S){const D=a(L);D&&(D.r!==void 0?S=L.clone():D.p!=null&&(S=null,I[D.p]=M.clone()));const N=M.getComponent();let X;N&&(X=N.p)!=null&&(O[X]=L?L.clone():null,k[X]=M.clone(),S&&(p[X]=!0,W[X]=S),D&&D.p!=null&&(K[X]=D.p));const Z=i.advancer(L);for(const te of M)ee(M,Z(te),S);Z.end()}(Oe,me,null),function ee(M,L,S,D,N){const X=S.getComponent();let Z,te=!1;X&&((Z=X.d)!=null?(g[Z]=S.clone(),D!=null&&(le[D]==null&&(le[D]=[]),le[D].push(Z)),M=O[Z]||null,L=k[Z]||null,p[Z]?(N&&(U[Z]=!0),N=W[Z]||null):!N||A!==1&&K[Z]!=null||b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.moveOp(L.getPath(),S.getPath())}),te=!0):X.i!==void 0&&(M=L=null,te=!0,N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.insertOp(S.getPath(),X.i)})));const ge=a(M);ge&&(ge.r!==void 0?N=M.clone():ge.p!=null&&(ge.p,D=ge.p,N=null));const he=be(X);he&&N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.editOp(S.getPath(),he,f(X),!0)});let ue=0,Ie=0;const q=i.advancer(L,(B,pe)=>v(pe)?ue-B-1:B-ue,(B,pe)=>{v(pe)&&ue++}),P=i.advancer(M);for(const B of S)if(typeof B=="number"){const pe=B-Ie,we=q(pe);Ie+=+ee(P(pe+ue),we,S,D,N)}else{const pe=q(B);ee(P(B),pe,S,D,N)}return q.end(),P.end(),te}(me,Oe,Oe.clone(),null,null),g.map(ee=>ee&&ee.get()),b)return{ok:!1,conflict:b};U.map(ee=>!!ee);const Me=[];let Ue=null;(function ee(M,L,S,D,N){let X=!1;const Z=a(L);if(v(Z)){const q=Z.p;q!=null?(S=g[q],D=se[q]=i.writeCursor(),X=!0,N=null):(S=null,N=L.clone())}else o(a(S))&&(S=null);const te=M.getComponent();if(te){const q=te.p;q!=null?(N&&(j[q]=N),Me[q]=N||A===1&&X?null:D.getComponent(),C[q]=M.clone(),S&&(w[q]=S.clone())):te.r!==void 0&&(N||D.write("r",!0),(N||X)&&(Ue==null&&(Ue=new Set),Ue.add(te)))}let ge=0,he=0;const ue=i.advancer(L,void 0,(q,P)=>{v(P)&&ge++}),Ie=i.advancer(S,(q,P)=>o(P)?~(q-he):q-he,(q,P)=>{o(P)&&he++});if(M)for(const q of M)if(typeof q=="string"){const P=ue(q),B=Ie(q);D.descend(q),ee(M,P,B,D,N),D.ascend()}else{const P=ue(q),B=q-ge,pe=v(a(P))?null:Ie(B),we=B+he;l(we>=0),D.descend(we),ee(M,P,pe,D,N),D.ascend()}ue.end(),Ie.end()})(me,Oe,Oe.clone(),ae,null),ae.reset();let Fe=[];if(function ee(M,L,S,D,N,X){l(L);const Z=L.getComponent();let te=a(D),ge=!1;const he=(R,oe,ye)=>R?n.moveOp(R.getPath(),oe.getPath()):n.insertOp(oe.getPath(),ye.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=L.clone());const oe=R!=null?Me[R]:null;let ye=!1;if(Z.i!==void 0||R!=null&&oe){let de;te&&(te.i!==void 0||(de=te.d)!=null&&!p[de])&&(ye=de!=null?R!=null&&R===K[de]:t.default(te.i,Z.i),ye||de!=null&&A!==1&&K[de]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:he(R!=null?C[R]:null,L,Z),op2:he(de!=null?k[de]:null,D,te)})),ye||(X?b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(R!=null?C[R]:null,L,Z),op2:n.removeOp(X.getPath())}):(R!=null?(Fe[Ge]=R,N.write("d",oe.p=Ge++)):N.write("i",s.default(Z.i)),ge=!0))}else if(R!=null&&!oe){const de=j[R];de&&(X=de.clone())}R!=null?(M=C[R],S=I[R],D=w[R]):Z.i!==void 0&&(M=S=null,ye||(D=null))}else v(a(M))&&(M=S=D=null);const ue=a(M),Ie=a(S);if(v(Ie)){const R=Ie.p;Ie.r!==void 0&&(!ue||ue.r===void 0)||p[R]?(D=null,X=S.clone()):R!=null&&(D=g[R],A!==1&&K[R]!=null||((N=ne[R])||(N=ne[R]=i.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(te)&&(D=null);te=D!=null?D.getComponent():null;const q=be(Z);if(q){const R=f(Z);if(X)b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.editOp(L.getPath(),q,R,!0),op2:n.removeOp(X.getPath())});else{const oe=be(te);let ye;if(oe){if(q!==oe)throw Error("Transforming incompatible types");const de=f(te);ye=q.transform(R,de,y)}else ye=s.default(R);_(N,q,ye)}}let P=0,B=0,pe=0,we=0,Le=0,Ve=0,Ne=M!=null&&M.descendFirst(),et=Ne;const Ye=i.advancer(S,void 0,(R,oe)=>{v(oe)&&pe++});let je=D!=null&&D.descendFirst(),$e=je;for(const R of L)if(typeof R=="number"){let oe;const ye=o(L.getComponent()),de=R-B;{let He;for(;Ne&&typeof(He=M.getKey())=="number";){He+=P;const Re=M.getComponent(),Je=v(Re);if(He>de||He===de&&(!Je||A===0&&ye))break;if(Je){P--;const qe=Re.p;K.includes(qe),Re.d,a(ne[Re.d]),v(a(ne[Re.d])),(Re.r===void 0||Ue&&Ue.has(Re))&&(qe==null||!Me[qe]||A!==1&&K.includes(qe))||Le--}Ne=M.nextSibling()}oe=Ne&&He===de?M:null}const Te=de-P;let Be=Ye(Te);const vt=Te-pe;let rt=null;{let He,Re;for(;je&&typeof(He=D.getKey())=="number";){Re=He-we;const Je=D.getComponent(),qe=o(Je);if(Re>vt)break;if(Re===vt){if(!qe){rt=D;break}{if(A===0&&ye){rt=D;break}const ze=Be&&v(Be.getComponent());if(A===0&&ze)break}}if(qe){const ze=Je.d;K[ze],Je.i===void 0&&(p[ze]||K[ze]!=null&&A!==1)?(p[ze]||K[ze]!=null&&A===0)&&(we++,Ve--):we++}je=D.nextSibling()}}const Tt=vt+we+Le+Ve;l(Tt>=0,"trying to descend to a negative index"),N.descend(Tt),ye&&(oe=Be=rt=null,B++),ee(oe,L,Be,rt,N,X)&&Ve++,N.ascend()}else{let oe;for(;Ne&&(oe=M.getKey(),typeof oe!="string"||!(oe>R||oe===R));)Ne=M.nextSibling();const ye=Ne&&oe===R?M:null,de=Ye(R);let Te;for(;je&&(Te=D.getKey(),typeof Te!="string"||!(Te>R||Te===R));)je=D.nextSibling();const Be=je&&Te===R?D:null;N.descend(R),ee(ye,L,de,Be,N,X),N.ascend()}return Ye.end(),et&&M.ascend(),$e&&D.ascend(),ge}(me,me.clone(),Oe,Oe.clone(),ae,null),b)return{ok:!1,conflict:b};ae.reset();const Se=(ee,M,L)=>ee.traverse(M,(S,D)=>{S.d!=null&&L(S.d,ee,D)});(p.length||se.length)&&(Se(Oe,ae,(ee,M,L)=>{p[ee]&&!U[ee]&&L.write("r",!0),se[ee]&&L.mergeTree(se[ee].get())}),ae.reset());const Ae=[],We=[];if((ne.length||p.length)&&!b){const ee=i.readCursor(pt(ae.get()));if(Se(ee,null,(M,L)=>{Ae[M]=L.clone()}),ne.forEach(M=>{M&&Se(i.readCursor(M.get()),null,(L,S)=>{Ae[L]=S.clone()})}),function M(L,S,D,N,X,Z){const te=a(S);if(te&&v(te))if(te.p!=null){const P=te.p;Ae[P].getPath(),D=Ae[P],N=We[P]=i.writeCursor()}else te.r!==void 0&&(D=null);else o(a(D))&&(D=null);const ge=L.getComponent();if(ge){let P;if((P=ge.d)!=null){const B=ne[P];B&&(B.get(),N.mergeTree(B.get()),D=i.readCursor(B.get()))}}let he=0,ue=0;const Ie=i.advancer(S,void 0,(P,B)=>{v(B)&&he--}),q=i.advancer(D,(P,B)=>o(B)?-(P-ue)-1:P-ue,(P,B)=>{o(B)&&ue++});for(const P of L)if(typeof P=="number"){const B=Ie(P),pe=P+he,we=q(pe),Le=pe+ue;N.descend(Le),M(L,B,we,N),N.ascend()}else N.descend(P),M(L,Ie(P),q(P),N),N.ascend();Ie.end(),q.end()}(Oe,ee,ee.clone(),ae),ae.reset(),b)return{ok:!1,conflict:b};if(ae.get(),We.length){const M=We.map(S=>S?S.get():null),L=i.readCursor(pt(ae.get()));if(Se(L,ae,(S,D,N)=>{const X=M[S];X&&(N.mergeTree(X),M[S]=null)}),M.find(S=>S)){const S=i.writeCursor(),D=i.writeCursor();let N=0,X=0;M.forEach(Z=>{Z!=null&&Se(i.readCursor(Z),null,te=>{const ge=Fe[te];S.writeMove(C[ge].getPath(),$[ge].getPath(),N++);const he=le[ge];he&&he.forEach(ue=>{p[ue]||A!==1&&K[ue]!=null||D.writeMove(k[ue].getPath(),g[ue].getPath(),X++)})})}),b={type:d.ConflictType.BLACKHOLE,op1:S.get(),op2:D.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:ae.get()}}const Ut=r=>{const c=new Error("Transform detected write conflict");throw c.conflict=r,c.type=c.name="writeConflict",c};function qt(r,c,y){const A=_t(r,c,y);if(A.ok)return A.result;Ut(A.conflict)}const Ze=r=>{const c=i.writeCursor();return i.readCursor(r).traverse(c,(y,A)=>{(o(y)||be(y))&&A.write("r",!0)}),c.get()},zt=(r,c)=>{const{type:y,op1:A,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return c==="left"?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return i.readCursor(A).traverse(null,$=>{$.r!==void 0&&(C=!0)}),C?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.BLACKHOLE:return[Ze(A),Ze(b)];default:throw Error("Unrecognised conflict: "+y)}};function Nt(r,c,y,A){let b=null;for(;;){const C=_t(c,y,A);if(C.ok)return ie(b,C.result);{const{conflict:$}=C;r($)||Ut($);const[k,g]=zt($,A);c=ie(x(c),k),y=ie(x(y),g),b=ie(b,g)}}}})(yt),function(n){var e=Ee&&Ee.__createBinding||(Object.create?function(d,l,a,E){E===void 0&&(E=a),Object.defineProperty(d,E,{enumerable:!0,get:function(){return l[a]}})}:function(d,l,a,E){E===void 0&&(E=a),d[E]=l[a]}),t=Ee&&Ee.__exportStar||function(d,l){for(var a in d)a!=="default"&&!l.hasOwnProperty(a)&&e(l,d,a)};Object.defineProperty(n,"__esModule",{value:!0}),t(yt,n);var s=at;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var i=ut;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})}(F);class Ct{constructor(){V(this,"drawingManagerData",{});V(this,"_oldDrawingManagerData",{});V(this,"_focusDrawings",[]);V(this,"_remove$",new re.Subject);V(this,"remove$",this._remove$.asObservable());V(this,"_add$",new re.Subject);V(this,"add$",this._add$.asObservable());V(this,"_update$",new re.Subject);V(this,"update$",this._update$.asObservable());V(this,"_order$",new re.Subject);V(this,"order$",this._order$.asObservable());V(this,"_group$",new re.Subject);V(this,"group$",this._group$.asObservable());V(this,"_ungroup$",new re.Subject);V(this,"ungroup$",this._ungroup$.asObservable());V(this,"_refreshTransform$",new re.Subject);V(this,"refreshTransform$",this._refreshTransform$.asObservable());V(this,"_visible$",new re.Subject);V(this,"visible$",this._visible$.asObservable());V(this,"_focus$",new re.Subject);V(this,"focus$",this._focus$.asObservable());V(this,"_featurePluginUpdate$",new re.Subject);V(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());V(this,"_featurePluginAdd$",new re.Subject);V(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());V(this,"_featurePluginRemove$",new re.Subject);V(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());V(this,"_featurePluginOrderUpdate$",new re.Subject);V(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());V(this,"_featurePluginGroupUpdate$",new re.Subject);V(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());V(this,"_featurePluginUngroupUpdate$",new re.Subject);V(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());V(this,"_visible",!0);V(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(t=>{if(this.getDrawingByParam(t)==null)return;const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]}removeDrawingDataForUnit(e){const t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];const s=[];Object.keys(t).forEach(i=>{const d=t[i];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(l=>{s.push({unitId:e,subUnitId:i,drawingId:l})})}),s.length>0&&this.removeNotification(s)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){const t=[],s=this.drawingManagerData[e];s!=null&&(Object.keys(s).forEach(i=>{this._establishDrawingMap(e,i);const d=s[i];Object.keys(d.data).forEach(l=>{const a=d.data[l];a.unitId=e,a.subUnitId=i,t.push(a)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}getBatchAddOp(e){const t=[],s=[],i=[];e.forEach(G=>{const{op:v,invertOp:o}=this._addByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),s.push(v),i.push(o)});const d=s.reduce(F.type.compose,null),l=i.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],s=[];e.forEach(E=>{const{op:G,invertOp:v}=this._removeByParam(E);t.push(G),s.push(v)});const i=t.reduce(F.type.compose,null),d=s.reduce(F.type.compose,null),{unitId:l,subUnitId:a}=e[0];return{undo:d,redo:i,unitId:l,subUnitId:a,objects:e}}getBatchUpdateOp(e){const t=[],s=[],i=[];e.forEach(G=>{const{op:v,invertOp:o}=this._updateByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),s.push(v),i.push(o)});const d=s.reduce(F.type.compose,null),l=i.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:l,redo:d,unitId:a,subUnitId:E,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getGroupDrawingOp(a))});const d=t.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:s,subUnitId:i}=e[0].parent;e.forEach(a=>{t.push(this._getUngroupDrawingOp(a))});const d=t.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:s,subUnitId:i,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:s,drawingId:i}=e;if(this.getDrawingByParam({unitId:t,subUnitId:s,drawingId:i})==null)return[];const l=this._getDrawingData(t,s),a=[];return Object.keys(l).forEach(E=>{const G=l[E];G.groupId===i&&a.push(G)}),a}_getGroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];a.push(F.insertOp([i,d,"data",l],t));let E=Number.NEGATIVE_INFINITY;return s.forEach(G=>{const{unitId:v,subUnitId:o,drawingId:u}=G,h=this._hasDrawingOrder({unitId:v,subUnitId:o,drawingId:u});E=Math.max(E,h),a.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:v,subUnitId:o,drawingId:u})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(i,d).length),a.push(F.insertOp([i,d,"order",E],l)),a.reduce(F.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:s}=e,{unitId:i,subUnitId:d,drawingId:l}=t,a=[];return s.forEach(E=>{const{unitId:G,subUnitId:v,drawingId:o}=E;a.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:G,subUnitId:v,drawingId:o})))}),a.push(F.removeOp([i,d,"data",l],!0)),a.push(F.removeOp([i,d,"order",this._getDrawingOrder(i,d).indexOf(l)],!0)),a.reduce(F.type.compose,null)}applyJson1(e,t,s){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=F.type.apply(this.drawingManagerData,s)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[t,s,i]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:s,drawingId:i})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(s=>{var E;const{unitId:i,subUnitId:d,drawingId:l}=s,a=(E=this._getDrawingData(i,d))==null?void 0:E[l];a!=null&&t.push(a)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var a;const{unitId:s,subUnitId:i,drawingId:d}=t,l=(a=this._getDrawingData(s,i))==null?void 0:a[d];l!=null&&e.push(l)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:v});if(o===-1||o===l.length-1)return;const u=F.moveOp([t,s,"order",o],[t,s,"order",o+1]);d.push(u),a.includes(l[o+1])||a.push(l[o+1])});const E=d.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=[],l=this.getDrawingOrder(t,s),a=[...i];i.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:s,drawingId:v});if(o===-1||o===0)return;const u=F.moveOp([t,s,"order",o],[t,s,"order",o-1]);d.push(u),a.includes(l[o-1])||a.push(l[o-1])});const E=d.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:s,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:u}=o,h=this._getDrawingCount(t,s)-1,T=F.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(u)],[t,s,"order",h]);E.push(T),l.includes(a[h])||l.push(a[h])});const G=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:s,drawingIds:i}=e,d=this._getOrderFromSearchParams(t,s,i,!0),l=[...i],a=this.getDrawingOrder(t,s),E=[];d.forEach(o=>{const{drawingId:u}=o,h=F.moveOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(u)],[t,s,"order",0]);E.push(h),l.includes(a[0])||l.push(a[0])});const G=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:s,objects:{...e,drawingIds:l}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,s,i=!1){return s.map(d=>{const l=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:l}}).sort(i===!1?ke.sortRules:ke.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:s,drawingId:i}=e;return this._establishDrawingMap(t,s),this._getDrawingOrder(t,s).indexOf(i)}_getCurrentBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this.drawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_getOldBySearch(e){var d,l,a;if(e==null)return;const{unitId:t,subUnitId:s,drawingId:i}=e;return(a=(l=(d=this._oldDrawingManagerData[t])==null?void 0:d[s])==null?void 0:l.data)==null?void 0:a[i]}_establishDrawingMap(e,t,s){var i;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),s==null?null:(i=this.drawingManagerData[e][t].data)==null?void 0:i[s]}_addByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e;this._establishDrawingMap(t,s,i);const d=F.insertOp([t,s,"data",i],e),l=F.insertOp([t,s,"order",this._getDrawingOrder(t,s).length],i),a=[d,l].reduce(F.type.compose,null),E=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:s,drawingId:i}=e;if(this._establishDrawingMap(t,s,i)==null)return{op:[],invertOp:[]};const l=F.removeOp([t,s,"data",i],!0),a=F.removeOp([t,s,"order",this._getDrawingOrder(t,s).indexOf(i)],!0),E=[l,a].reduce(F.type.compose,null),G=F.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:G}}_updateByParam(e){const{unitId:t,subUnitId:s,drawingId:i}=e,d=this._establishDrawingMap(t,s,i);if(d==null)return{op:[],invertOp:[]};const a=this._getUpdateParamCompareOp(e,d).reduce(F.type.compose,null),E=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:s,subUnitId:i,drawingId:d}=e,l=[];return Object.keys(e).forEach(a=>{const E=e[a],G=t[a];G!==E&&l.push(F.replaceOp([s,i,"data",d,a],G,E))}),l}_getDrawingData(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.data)||{}}_getDrawingOrder(e,t){var s,i;return((i=(s=this.drawingManagerData[e])==null?void 0:s[t])==null?void 0:i.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Et extends Ct{}function Gt(n){const{unitId:e,subUnitId:t,drawingId:s}=n;return`${e}#-#${t}#-#${s}`}const Wt=async n=>new Promise((e,t)=>{const s=new Image;s.src=n,s.onload=()=>{e({width:s.width,height:s.height,image:s})},s.onerror=i=>{t(i)}});var Qe=(n=>(n.URL="URL",n.UUID="UUID",n.BASE64="BASE64",n))(Qe||{}),Xe=(n=>(n.SUCCUSS="0",n.ERROR_EXCEED_SIZE="1",n.ERROR_IMAGE_TYPE="2",n.ERROR_UPLOAD_COUNT_LIMIT="3",n.ERROR_IMAGE="4",n))(Xe||{});const At=tt.createIdentifier("core.image-io.service");class Dt{constructor(){V(this,"_waitCount",0);V(this,"_change$",new re.Subject);V(this,"change$",this._change$);V(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Qe.BASE64){const s=new Image;return s.src=e,s}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,s){t===Qe.BASE64||s==null||this._imageSourceCache.set(e,s)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,s)=>{if(!Ot.includes(e.type)){s(new Error(Xe.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){s(new Error(Xe.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const i=new FileReader;i.readAsDataURL(e),i.onload=d=>{var E;const l=(E=d.target)==null?void 0:E.result;if(l==null){s(new Error(Xe.ERROR_IMAGE)),this._decreaseWaiting();return}const a=ke.Tools.generateRandomId(6);t({imageId:a,imageSourceType:Qe.BASE64,source:l,base64Cache:l,status:Xe.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const Lt="__default_document_sub_component_id20231101__";var Pt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Pt||{}),Mt=(n=>(n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n[n.DRAWING_IMAGE=0]="DRAWING_IMAGE",n[n.DRAWING_SHAPE=1]="DRAWING_SHAPE",n[n.DRAWING_CHART=2]="DRAWING_CHART",n[n.DRAWING_TABLE=3]="DRAWING_TABLE",n[n.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",n[n.DRAWING_VIDEO=5]="DRAWING_VIDEO",n[n.DRAWING_GROUP=6]="DRAWING_GROUP",n[n.DRAWING_UNIT=7]="DRAWING_UNIT",n[n.DRAWING_DOM=8]="DRAWING_DOM",n))(Mt||{});const St=tt.createIdentifier("univer.drawing-manager.service");var Bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,xt=(n,e,t,s)=>{for(var i=s>1?void 0:s?Ht(e,t):e,d=n.length-1,l;d>=0;d--)(l=n[d])&&(i=(s?l(e,t,i):l(i))||i);return s&&i&&Bt(e,t,i),i},Kt=(n,e)=>(t,s)=>e(t,s,n);const Ft="DRAWING_PLUGIN";Y.UniverDrawingPlugin=(gt=class extends ke.Plugin{constructor(e,t){super(),this._config=e,this._injector=t}onStarting(e){this._initDependencies(e)}_initDependencies(e){var i;const t=[[At,{useClass:Dt}],[St,{useClass:Et}]];ke.mergeOverrideWithDependencies(t,(i=this._config)==null?void 0:i.override).forEach(d=>e.add(d))}},V(gt,"pluginName",Ft),gt),Y.UniverDrawingPlugin=xt([Kt(1,tt.Inject(tt.Injector))],Y.UniverDrawingPlugin),Y.ArrangeTypeEnum=Pt,Y.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Lt,Y.DRAWING_IMAGE_ALLOW_IMAGE_LIST=Ot,Y.DRAWING_IMAGE_ALLOW_SIZE=5242880,Y.DRAWING_IMAGE_COUNT_LIMIT=10,Y.DRAWING_IMAGE_HEIGHT_LIMIT=500,Y.DRAWING_IMAGE_WIDTH_LIMIT=500,Y.DrawingManagerService=Et,Y.DrawingTypeEnum=Mt,Y.IDrawingManagerService=St,Y.IImageIoService=At,Y.ImageIoService=Dt,Y.ImageSourceType=Qe,Y.ImageUploadStatusType=Xe,Y.UnitDrawingService=Ct,Y.getDrawingShapeKeyByDrawingSearch=Gt,Y.getImageSize=Wt,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/drawing",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"lib"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@wendellhu/redi": "0.15.
|
|
47
|
+
"@wendellhu/redi": "0.15.5",
|
|
48
48
|
"rxjs": ">=7.0.0",
|
|
49
|
-
"@univerjs/core": "0.1
|
|
49
|
+
"@univerjs/core": "0.2.1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@univerjs/icons": "^0.1.
|
|
52
|
+
"@univerjs/icons": "^0.1.58",
|
|
53
53
|
"ot-json1": "^1.0.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@wendellhu/redi": "0.15.
|
|
56
|
+
"@wendellhu/redi": "0.15.5",
|
|
57
57
|
"less": "^4.2.0",
|
|
58
58
|
"rxjs": "^7.8.1",
|
|
59
|
-
"typescript": "^5.
|
|
60
|
-
"vite": "^5.3.
|
|
59
|
+
"typescript": "^5.5.3",
|
|
60
|
+
"vite": "^5.3.3",
|
|
61
61
|
"vitest": "^1.6.0",
|
|
62
|
-
"@univerjs/core": "0.1
|
|
63
|
-
"@univerjs/shared": "0.1
|
|
62
|
+
"@univerjs/core": "0.2.1",
|
|
63
|
+
"@univerjs/shared": "0.2.1"
|
|
64
64
|
},
|
|
65
65
|
"univerSpace": {
|
|
66
66
|
".": {
|