@univerjs/drawing 0.4.2 → 0.5.0-alpha.0
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 +1484 -1529
- package/lib/umd/index.js +1 -1
- package/package.json +11 -12
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global2,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],factory):(global2=typeof globalThis<"u"?globalThis:global2||self,factory(global2.UniverDrawing={},global2.UniverCore,global2.rxjs))})(this,function(exports2,core,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a;const DRAWING_IMAGE_ALLOW_IMAGE_LIST=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},dist$1={},json1_release={},deepEqual$1={};Object.defineProperty(deepEqual$1,"__esModule",{value:!0});function eqObj(a,b){if(Array.isArray(b))return!1;for(let k in a)if(!deepEqual(a[k],b[k]))return!1;for(let k in b)if(a[k]===void 0)return!1;return!0}__name(eqObj,"eqObj");function eqArr(a,b){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let i=0;i<a.length;i++)if(!deepEqual(a[i],b[i]))return!1;return!0}__name(eqArr,"eqArr");function deepEqual(a,b){return a===b?!0:a===null||b===null||typeof a!="object"||typeof b!="object"?!1:Array.isArray(a)?eqArr(a,b):eqObj(a,b)}__name(deepEqual,"deepEqual"),deepEqual$1.default=deepEqual;var deepClone$1={};Object.defineProperty(deepClone$1,"__esModule",{value:!0});function deepClone(old){if(old===null)return null;if(Array.isArray(old))return old.map(deepClone);if(typeof old=="object"){const o={};for(let k in old)o[k]=deepClone(old[k]);return o}else return old}__name(deepClone,"deepClone"),deepClone$1.default=deepClone;var cursor={};(function(exports3){Object.defineProperty(exports3,"__esModule",{value:!0}),exports3.eachChildOf=exports3.advancer=exports3.readCursor=exports3.writeCursor=exports3.WriteCursor=exports3.ReadCursor=exports3.isValidPathItem=void 0;function assert(pred,msg){if(!pred)throw new Error(msg)}__name(assert,"assert");const isObject=__name(o=>o!=null&&typeof o=="object"&&!Array.isArray(o),"isObject"),isGreaterKey=__name((a,b)=>typeof a==typeof b?a>b:typeof a=="string"&&typeof b=="number","isGreaterKey");function copyAll(c,w){for(let _k in c){const k=_k;w.write(k,c[k])}}__name(copyAll,"copyAll"),exports3.isValidPathItem=k=>typeof k=="number"||typeof k=="string"&&k!=="__proto__";const _Cursor=class _Cursor{constructor(op=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=op}ascend(){assert(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):(assert(this.idx>0),this.idx--,isObject(this.container[this.idx])&&this.idx--)}getPath(){const path=[];let c=this.container,p=this.parents.length-1,i=this.idx;for(;i>=0;)path.unshift(c[i]),i===0?(i=this.indexes[p*2],c=this.parents[p--]):i-=isObject(c[i-1])?2:1;return path}};__name(_Cursor,"Cursor");let Cursor=_Cursor;const _ReadCursor=class _ReadCursor extends Cursor{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return assert(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let c;return this.container&&this.container.length>this.idx+1&&isObject(c=this.container[this.idx+1])?c:null}descendFirst(){let i=this.idx+1;if(!this.container||i>=this.container.length||isObject(this.container[i])&&i+1>=this.container.length)return!1;isObject(this.container[i])&&i++;const firstChild=this.container[i];return Array.isArray(firstChild)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(i),this.idx=0,this.container=firstChild):this.idx=i,!0}nextSibling(){if(assert(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const i=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return i>=c.length?!1:(assert(!isNaN(i)),this.indexes[this.indexes.length-1]=i,this.container=c[i],!0)}_init(_container,_idx,_parents,_indexes){this.container=_container,this.idx=_idx,this.parents=_parents.slice(),this.indexes=_indexes.slice()}clone(){const c=new _ReadCursor;return c._init(this.container,this.idx,this.parents,this.indexes),c}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(w,fn){const c=this.getComponent();c&&fn(c,w);for(const key of this)w&&w.descend(key),this.traverse(w,fn),w&&w.ascend()}eachPick(w,fn){this.traverse(w,(c,w2)=>{c.p!=null&&fn(c.p,w2)})}eachDrop(w,fn){this.traverse(w,(c,w2)=>{c.d!=null&&fn(c.d,w2)})}};__name(_ReadCursor,"ReadCursor");let ReadCursor=_ReadCursor;exports3.ReadCursor=ReadCursor;const _WriteCursor=class _WriteCursor extends Cursor{constructor(op=null){super(op),this.pendingDescent=[],this._op=op}flushDescent(){assert(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let j=0;j<this.pendingDescent.length;j++){const k=this.pendingDescent[j];let i=this.idx+1;if(i<this.container.length&&isObject(this.container[i])&&i++,assert(i===this.container.length||!isObject(this.container[i])),i===this.container.length)this.container.push(k),this.idx=i;else if(this.container[i]===k)this.idx=i;else{if(!Array.isArray(this.container[i])){const oldChild=this.container.splice(i,this.container.length-i);this.container.push(oldChild),this.lcIdx>-1&&(this.lcIdx=i)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(assert(isGreaterKey(k,this.container[this.lcIdx][0])),i=this.lcIdx+1,this.lcIdx=-1);i<this.container.length&&isGreaterKey(k,this.container[i][0]);)i++;if(this.indexes.push(i),this.idx=0,i<this.container.length&&this.container[i][0]===k)this.container=this.container[i];else{const child=[k];this.container.splice(i,0,child),this.container=child}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const i=this.idx+1;if(i<this.container.length&&isObject(this.container[i]))return this.container[i];{const component={};return this.container.splice(i,0,component),component}}write(key,value){const component=this.getComponent();assert(component[key]==null||component[key]===value,"Internal consistency error: Overwritten component. File a bug"),component[key]=value}get(){return this._op}descend(key){if(!exports3.isValidPathItem(key))throw Error("Invalid JSON key");this.pendingDescent.push(key)}descendPath(path){return this.pendingDescent.push(...path),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(data,mergeFn=copyAll){if(data===null)return;if(assert(Array.isArray(data)),data===this._op)throw Error("Cannot merge into my own tree");const _lcIdx=this.lcIdx,oldDepth=this.parents.length;let depth=0;for(let i=0;i<data.length;i++){const c=data[i];typeof c=="string"||typeof c=="number"?(depth++,this.descend(c)):Array.isArray(c)?this.mergeTree(c,mergeFn):typeof c=="object"&&mergeFn(c,this)}for(;depth--;)this.ascend();this.lcIdx=this.parents.length===oldDepth?_lcIdx:-1}at(path,fn){this.descendPath(path),fn(this);for(let i=0;i<path.length;i++)this.ascend();return this}writeAtPath(path,key,value){return this.at(path,()=>this.write(key,value)),this.reset(),this}writeMove(path1,path2,slot=0){return this.writeAtPath(path1,"p",slot).writeAtPath(path2,"d",slot)}getPath(){const path=super.getPath();return path.push(...this.pendingDescent),path}};__name(_WriteCursor,"WriteCursor");let WriteCursor=_WriteCursor;exports3.WriteCursor=WriteCursor,exports3.writeCursor=()=>new WriteCursor,exports3.readCursor=op=>new ReadCursor(op);function advancer(r,listMap,listAdv){let didDescend,valid;valid=didDescend=r?r.descendFirst():!1;function adv(ktarget){let k2_;for(;valid;){const k2=k2_=r.getKey();if(ktarget!=null){let skip=!1;if(listMap&&typeof k2=="number"&&(k2_=listMap(k2,r.getComponent()),k2_<0&&(k2_=~k2_,skip=!0)),isGreaterKey(k2_,ktarget))return null;if(k2_===ktarget&&!skip)return r}listAdv&&typeof k2_=="number"&&listAdv(k2_,r.getComponent()),valid=r.nextSibling()}return null}return __name(adv,"adv"),adv.end=()=>{didDescend&&r.ascend()},adv}__name(advancer,"advancer"),exports3.advancer=advancer;function eachChildOf(r1,r2,fn){let hasChild1,descended1,hasChild2,descended2;for(hasChild1=descended1=r1&&r1.descendFirst(),hasChild2=descended2=r2&&r2.descendFirst();hasChild1||hasChild2;){let k1=hasChild1?r1.getKey():null,k2=hasChild2?r2.getKey():null;k1!==null&&k2!==null&&(isGreaterKey(k2,k1)?k2=null:k1!==k2&&(k1=null)),fn(k1==null?k2:k1,k1!=null?r1:null,k2!=null?r2:null),k1!=null&&hasChild1&&(hasChild1=r1.nextSibling()),k2!=null&&hasChild2&&(hasChild2=r2.nextSibling())}descended1&&r1.ascend(),descended2&&r2.ascend()}__name(eachChildOf,"eachChildOf"),exports3.eachChildOf=eachChildOf})(cursor);var types={};(function(exports3){Object.defineProperty(exports3,"__esModule",{value:!0}),exports3.ConflictType=void 0,function(ConflictType){ConflictType[ConflictType.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",ConflictType[ConflictType.DROP_COLLISION=2]="DROP_COLLISION",ConflictType[ConflictType.BLACKHOLE=3]="BLACKHOLE"}(exports3.ConflictType||(exports3.ConflictType={}))})(types);var dist={},unicount={},hasRequiredUnicount;function requireUnicount(){return hasRequiredUnicount||(hasRequiredUnicount=1,Object.defineProperty(unicount,"__esModule",{value:!0}),unicount.uniToStrPos=unicount.strPosToUni=void 0,unicount.strPosToUni=(s,strOffset=s.length)=>{let pairs=0,i=0;for(;i<strOffset;i++){const code=s.charCodeAt(i);code>=55296&&code<=57343&&(pairs++,i++)}if(i!==strOffset)throw Error("Invalid offset - splits unicode bytes");return i-pairs},unicount.uniToStrPos=(s,uniOffset)=>{let pos=0;for(;uniOffset>0;uniOffset--){const code=s.charCodeAt(pos);pos+=code>=55296&&code<=57343?2:1}return pos}),unicount}__name(requireUnicount,"requireUnicount");var type={},hasRequiredType;function requireType(){return hasRequiredType||(hasRequiredType=1,function(exports3){Object.defineProperty(exports3,"__esModule",{value:!0}),exports3.uniSlice=exports3.dlen=exports3.eachOp=void 0;const unicount_1=requireUnicount(),checkOp=__name(op=>{if(!Array.isArray(op))throw Error("Op must be an array of components");let last=null;for(let i=0;i<op.length;i++){const c=op[i];switch(typeof c){case"object":if(typeof c.d!="number"&&typeof c.d!="string")throw Error("Delete must be number or string");if(exports3.dlen(c.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(c.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(c>0))throw Error("Skip components must be >0");if(typeof last=="number")throw Error("Adjacent skip components should be combined");break}last=c}if(typeof last=="number")throw Error("Op has a trailing skip")},"checkOp");function eachOp(op,fn){let prePos=0,postPos=0;for(let i=0;i<op.length;i++){const c=op[i];switch(fn(c,prePos,postPos),typeof c){case"object":prePos+=exports3.dlen(c.d);break;case"string":postPos+=unicount_1.strPosToUni(c);break;case"number":prePos+=c,postPos+=c;break}}}__name(eachOp,"eachOp"),exports3.eachOp=eachOp;function mapOp(op,fn){const newOp=[],append=makeAppend(newOp);return eachOp(op,(c,prePos,postPos)=>{append(fn(c,prePos,postPos))}),trim(newOp)}__name(mapOp,"mapOp");const id=__name(x=>x,"id"),normalize=__name(op=>mapOp(op,id),"normalize");exports3.dlen=d=>typeof d=="number"?d:unicount_1.strPosToUni(d);const makeAppend=__name(op=>component=>{if(!(!component||component.d===0||component.d===""))if(op.length===0)op.push(component);else if(typeof component==typeof op[op.length-1])if(typeof component=="object"){const last=op[op.length-1];last.d=typeof last.d=="string"&&typeof component.d=="string"?last.d+component.d:exports3.dlen(last.d)+exports3.dlen(component.d)}else op[op.length-1]+=component;else op.push(component)},"makeAppend"),componentLength=__name(c=>typeof c=="number"?c:typeof c=="string"?unicount_1.strPosToUni(c):typeof c.d=="number"?c.d:unicount_1.strPosToUni(c.d),"componentLength");exports3.uniSlice=(s,startUni,endUni)=>{const start=unicount_1.uniToStrPos(s,startUni),end=endUni==null?1/0:unicount_1.uniToStrPos(s,endUni);return s.slice(start,end)};const dslice=__name((d,start,end)=>typeof d=="number"?end==null?d-start:Math.min(d,end)-start:exports3.uniSlice(d,start,end),"dslice"),makeTake=__name(op=>{let idx=0,offset=0;return{take:__name((n,indivisableField)=>{if(idx===op.length)return n===-1?null:n;const c=op[idx];let part;if(typeof c=="number")return n===-1||c-offset<=n?(part=c-offset,++idx,offset=0,part):(offset+=n,n);if(typeof c=="string"){if(n===-1||indivisableField==="i"||unicount_1.strPosToUni(c.slice(offset))<=n)return part=c.slice(offset),++idx,offset=0,part;{const offset2=offset+unicount_1.uniToStrPos(c.slice(offset),n);return part=c.slice(offset,offset2),offset=offset2,part}}else{if(n===-1||indivisableField==="d"||exports3.dlen(c.d)-offset<=n)return part={d:dslice(c.d,offset)},++idx,offset=0,part;{let result=dslice(c.d,offset,offset+n);return offset+=n,{d:result}}}},"take"),peek:__name(()=>op[idx],"peek")}},"makeTake"),trim=__name(op=>(op.length>0&&typeof op[op.length-1]=="number"&&op.pop(),op),"trim");function transform(op1,op2,side){if(side!=="left"&&side!=="right")throw Error("side ("+side+") must be 'left' or 'right'");checkOp(op1),checkOp(op2);const newOp=[],append=makeAppend(newOp),{take,peek}=makeTake(op1);for(let i=0;i<op2.length;i++){const c2=op2[i];let length,c1;switch(typeof c2){case"number":for(length=c2;length>0;)c1=take(length,"i"),append(c1),typeof c1!="string"&&(length-=componentLength(c1));break;case"string":side==="left"&&typeof peek()=="string"&&append(take(-1)),append(unicount_1.strPosToUni(c2));break;case"object":for(length=exports3.dlen(c2.d);length>0;)switch(c1=take(length,"i"),typeof c1){case"number":length-=c1;break;case"string":append(c1);break;case"object":length-=exports3.dlen(c1.d)}break}}let c;for(;c=take(-1);)append(c);return trim(newOp)}__name(transform,"transform");function compose(op1,op2){checkOp(op1),checkOp(op2);const result=[],append=makeAppend(result),{take}=makeTake(op1);for(let i=0;i<op2.length;i++){const component=op2[i];let length,chunk;switch(typeof component){case"number":for(length=component;length>0;)chunk=take(length,"d"),append(chunk),typeof chunk!="object"&&(length-=componentLength(chunk));break;case"string":append(component);break;case"object":length=exports3.dlen(component.d);let offset=0;for(;offset<length;)switch(chunk=take(length-offset,"d"),typeof chunk){case"number":append({d:dslice(component.d,offset,offset+chunk)}),offset+=chunk;break;case"string":offset+=unicount_1.strPosToUni(chunk);break;case"object":append(chunk)}break}}let c;for(;c=take(-1);)append(c);return trim(result)}__name(compose,"compose");const transformPosition=__name((cursor2,op)=>{let pos=0;for(let i=0;i<op.length&&cursor2>pos;i++){const c=op[i];switch(typeof c){case"number":{pos+=c;break}case"string":const offset=unicount_1.strPosToUni(c);pos+=offset,cursor2+=offset;break;case"object":cursor2-=Math.min(exports3.dlen(c.d),cursor2-pos);break}}return cursor2},"transformPosition"),transformSelection=__name((selection,op)=>typeof selection=="number"?transformPosition(selection,op):selection.map(s=>transformPosition(s,op)),"transformSelection");function makeInvertible(op,doc,ropeImpl){return mapOp(op,(c,prePos)=>typeof c=="object"&&typeof c.d=="number"?{d:ropeImpl.slice(doc,prePos,prePos+c.d)}:c)}__name(makeInvertible,"makeInvertible");function invert(op){return mapOp(op,c=>{switch(typeof c){case"object":if(typeof c.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return c.d;case"string":return{d:c};case"number":return c}})}__name(invert,"invert");function stripInvertible(op){return mapOp(op,c=>typeof c=="object"&&typeof c.d=="string"?{d:unicount_1.strPosToUni(c.d)}:c)}__name(stripInvertible,"stripInvertible");function isInvertible(op){let invertible=!0;return eachOp(op,c=>{typeof c=="object"&&typeof c.d=="number"&&(invertible=!1)}),invertible}__name(isInvertible,"isInvertible");function makeType(ropeImpl){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim,normalize,checkOp,create(initial=""){if(typeof initial!="string")throw Error("Initial data must be a string");return ropeImpl.create(initial)},apply(str,op){checkOp(op);const builder=ropeImpl.builder(str);for(let i=0;i<op.length;i++){const component=op[i];switch(typeof component){case"number":builder.skip(component);break;case"string":builder.append(component);break;case"object":builder.del(exports3.dlen(component.d));break}}return builder.build()},transform,compose,transformPosition,transformSelection,isInvertible,makeInvertible(op,doc){return makeInvertible(op,doc,ropeImpl)},stripInvertible,invert,invertWithDoc(op,doc){return invert(makeInvertible(op,doc,ropeImpl))},isNoop:__name(op=>op.length===0,"isNoop")}}__name(makeType,"makeType"),exports3.default=makeType}(type)),type}__name(requireType,"requireType");var api={},hasRequiredApi;function requireApi(){if(hasRequiredApi)return api;hasRequiredApi=1,Object.defineProperty(api,"__esModule",{value:!0});const type_1=requireType(),unicount_1=requireUnicount();function api$1(getSnapshot,submitOp){return{get:getSnapshot,getLength(){return getSnapshot().length},insert(pos,text,callback){const uniPos=unicount_1.strPosToUni(getSnapshot(),pos);return submitOp([uniPos,text],callback)},remove(pos,lengthOrContent,callback){const uniPos=unicount_1.strPosToUni(getSnapshot(),pos);return submitOp([uniPos,{d:lengthOrContent}],callback)},_onOp(op){type_1.eachOp(op,(component,prePos,postPos)=>{switch(typeof component){case"string":this.onInsert&&this.onInsert(postPos,component);break;case"object":const dl=type_1.dlen(component.d);this.onRemove&&this.onRemove(postPos,dl)}})},onInsert:null,onRemove:null}}return __name(api$1,"api$1"),api.default=api$1,api$1.provides={text:!0},api}__name(requireApi,"requireApi");var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,function(exports3){var __createBinding=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(o,m,k,k2){k2===void 0&&(k2=k),Object.defineProperty(o,k2,{enumerable:!0,get:__name(function(){return m[k]},"get")})}:function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]}),__setModuleDefault=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=commonjsGlobal&&commonjsGlobal.__importStar||function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k in mod)Object.hasOwnProperty.call(mod,k)&&__createBinding(result,mod,k);return __setModuleDefault(result,mod),result},__importDefault=commonjsGlobal&&commonjsGlobal.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports3,"__esModule",{value:!0}),exports3.type=exports3.remove=exports3.insert=void 0;const unicount_1=requireUnicount(),type_1=__importStar(requireType()),api_1=__importDefault(requireApi()),ropeImplUnicodeString={create(s){return s},toString(s){return s},builder(oldDoc){if(typeof oldDoc!="string")throw Error("Invalid document snapshot: "+oldDoc);const newDoc=[];return{skip(n){let offset=unicount_1.uniToStrPos(oldDoc,n);if(offset>oldDoc.length)throw Error("The op is too long for this document");newDoc.push(oldDoc.slice(0,offset)),oldDoc=oldDoc.slice(offset)},append(s){newDoc.push(s)},del(n){oldDoc=oldDoc.slice(unicount_1.uniToStrPos(oldDoc,n))},build(){return newDoc.join("")+oldDoc}}},slice:type_1.uniSlice},textString=type_1.default(ropeImplUnicodeString),type2=Object.assign(Object.assign({},textString),{api:api_1.default});exports3.type=type2,exports3.insert=(pos,text)=>text.length===0?[]:pos===0?[text]:[pos,text],exports3.remove=(pos,textOrLen)=>type_1.dlen(textOrLen)===0?[]:pos===0?[{d:textOrLen}]:[pos,{d:textOrLen}];var type_2=requireType();Object.defineProperty(exports3,"makeType",{enumerable:!0,get:__name(function(){return type_2.default},"get")})}(dist)),dist}__name(requireDist,"requireDist"),function(exports3){var __importDefault=commonjsGlobal&&commonjsGlobal.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports3,"__esModule",{value:!0}),exports3.editOp=exports3.replaceOp=exports3.insertOp=exports3.moveOp=exports3.removeOp=exports3.type=void 0;const deepEqual_js_1=__importDefault(deepEqual$1),deepClone_js_1=__importDefault(deepClone$1),cursor_js_1=cursor,types_js_1=types;function assert(pred,msg){if(!pred)throw new Error(msg)}__name(assert,"assert"),exports3.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:cursor_js_1.readCursor,writeCursor:cursor_js_1.writeCursor,create:__name(data=>data,"create"),isNoop:__name(op=>op==null,"isNoop"),setDebug(val){},registerSubtype,checkValidOp,normalize,apply,transformPosition,compose,tryTransform,transform,makeInvertible,invert,invertWithDoc,RM_UNEXPECTED_CONTENT:types_js_1.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:types_js_1.ConflictType.DROP_COLLISION,BLACKHOLE:types_js_1.ConflictType.BLACKHOLE,transformNoConflict:__name((op1,op2,side)=>transformWithConflictsPred(()=>!0,op1,op2,side),"transformNoConflict"),typeAllowingConflictsPred:__name(allowConflict=>Object.assign(Object.assign({},exports3.type),{transform:__name((op1,op2,side)=>transformWithConflictsPred(allowConflict,op1,op2,side),"transform")}),"typeAllowingConflictsPred")};const getComponent=__name(r=>r?r.getComponent():null,"getComponent");function isObject(o){return o&&typeof o=="object"&&!Array.isArray(o)}__name(isObject,"isObject");const shallowClone=__name(obj=>Array.isArray(obj)?obj.slice():obj!==null&&typeof obj=="object"?Object.assign({},obj):obj,"shallowClone"),hasPick=__name(c=>c&&(c.p!=null||c.r!==void 0),"hasPick"),hasDrop=__name(c=>c&&(c.d!=null||c.i!==void 0),"hasDrop");function removeChild(container,key){return assert(container!=null),typeof key=="number"?(assert(Array.isArray(container),"Invalid key - child is not an array"),(container=container.slice()).splice(key,1)):(assert(isObject(container),"Invalid key - child is not an object"),delete(container=Object.assign({},container))[key]),container}__name(removeChild,"removeChild");function insertChildMut(container,key,value){return typeof key=="number"?(assert(container!=null,"Container is missing for key"),assert(Array.isArray(container),"Cannot use numerical key for object container"),assert(container.length>=key,"Cannot insert into out of bounds index"),container.splice(key,0,value)):(assert(isObject(container),"Cannot insert into missing item"),assert(container[key]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),container[key]=value),value}__name(insertChildMut,"insertChildMut"),exports3.removeOp=(path,value=!0)=>cursor_js_1.writeCursor().writeAtPath(path,"r",value).get(),exports3.moveOp=(from,to)=>cursor_js_1.writeCursor().writeMove(from,to).get(),exports3.insertOp=(path,value)=>cursor_js_1.writeCursor().writeAtPath(path,"i",value).get(),exports3.replaceOp=(path,oldVal,newVal)=>cursor_js_1.writeCursor().at(path,w=>{w.write("r",oldVal),w.write("i",newVal)}).get(),exports3.editOp=(path,type2,subOp,preserveNoop=!1)=>cursor_js_1.writeCursor().at(path,w=>writeEdit(w,type2,subOp,preserveNoop)).get();const isValidKey=__name((container,key)=>container!=null&&(typeof key=="number"?Array.isArray(container):typeof container=="object"),"isValidKey"),maybeGetChild=__name((container,key)=>isValidKey(container,key)?container[key]:void 0,"maybeGetChild"),subtypes={};function registerSubtype(subtype){let _subtype=subtype.type?subtype.type:subtype;_subtype.name&&(subtypes[_subtype.name]=_subtype),_subtype.uri&&(subtypes[_subtype.uri]=_subtype)}__name(registerSubtype,"registerSubtype");const typeOrThrow=__name(name=>{const type2=subtypes[name];if(type2)return type2;throw Error("Missing type: "+name)},"typeOrThrow");registerSubtype(requireDist());const add=__name((a,b)=>a+b,"add");registerSubtype({name:"number",apply:add,compose:add,invert:__name(n=>-n,"invert"),transform:__name(a=>a,"transform")});const getEditType=__name(c=>c==null?null:c.et?typeOrThrow(c.et):c.es?subtypes["text-unicode"]:c.ena!=null?subtypes.number:null,"getEditType"),getEdit=__name(c=>c.es?c.es:c.ena!=null?c.ena:c.e,"getEdit"),writeEdit=__name((w,typeOrName,edit,preserveNoop=!1)=>{const[type2,name]=typeof typeOrName=="string"?[typeOrThrow(typeOrName),typeOrName]:[typeOrName,typeOrName.name];!preserveNoop&&type2.isNoop&&type2.isNoop(edit)||(name==="number"?w.write("ena",edit):name==="text-unicode"?w.write("es",edit):(w.write("et",name),w.write("e",edit)))},"writeEdit");function checkNonNegInteger(n){assert(typeof n=="number"),assert(n>=0),assert(n===(0|n))}__name(checkNonNegInteger,"checkNonNegInteger");function checkScalar(s){typeof s=="number"?checkNonNegInteger(s):assert(typeof s=="string")}__name(checkScalar,"checkScalar");function checkValidOp(op){if(op===null)return;const pickedSlots=new Set,droppedSlots=new Set,checkComponent=__name(e=>{let empty=!0,hasEdit=!1;for(let k in e){const v=e[k];if(empty=!1,assert(k==="p"||k==="r"||k==="d"||k==="i"||k==="e"||k==="es"||k==="ena"||k==="et","Invalid component item '"+k+"'"),k==="p")checkNonNegInteger(v),assert(!pickedSlots.has(v)),pickedSlots.add(v),assert(e.r===void 0);else if(k==="d")checkNonNegInteger(v),assert(!droppedSlots.has(v)),droppedSlots.add(v),assert(e.i===void 0);else if(k==="e"||k==="es"||k==="ena"){assert(!hasEdit),hasEdit=!0;const t=getEditType(e);assert(t,"Missing type in edit"),t.checkValidOp&&t.checkValidOp(getEdit(e))}}assert(!empty)},"checkComponent"),checkDescent=__name((descent,isRoot,removed)=>{if(!Array.isArray(descent))throw Error("Op must be null or a list");if(descent.length===0)throw Error("Empty descent");isRoot||checkScalar(descent[0]);let last=1,numDescents=0,lastKey=0;for(let i=0;i<descent.length;i++){const d=descent[i];if(assert(d!=null),Array.isArray(d)){const key=checkDescent(d,!1);if(numDescents){const t1=typeof lastKey,t2=typeof key;t1===t2?assert(lastKey<key,"descent keys are not in order"):assert(t1==="number"&&t2==="string")}lastKey=key,numDescents++,last=3}else typeof d=="object"?(assert(last===1,`Prev not scalar - instead ${last}`),checkComponent(d),last=2):(assert(last!==3),checkScalar(d),assert(cursor_js_1.isValidPathItem(d),"Invalid path key"),last=1)}return assert(numDescents!==1,"Operation makes multiple descents. Remove some []"),assert(last===2||last===3),descent[0]},"checkDescent");checkDescent(op,!0),assert(pickedSlots.size===droppedSlots.size,"Mismatched picks and drops in op");for(let i=0;i<pickedSlots.size;i++)assert(pickedSlots.has(i)),assert(droppedSlots.has(i))}__name(checkValidOp,"checkValidOp");function normalize(op){let nextSlot=0,slotMap=[];const w=cursor_js_1.writeCursor();return w.mergeTree(op,(c,w2)=>{const t=getEditType(c);if(t){const op2=getEdit(c);writeEdit(w2,t,t.normalize?t.normalize(op2):op2)}for(const k of["r","p","i","d"])if(c[k]!==void 0){const r=k==="p"||k==="d"?(inSlot=c[k],slotMap[inSlot]==null&&(slotMap[inSlot]=nextSlot++),slotMap[inSlot]):c[k];w2.write(k,r)}var inSlot}),w.get()}__name(normalize,"normalize");function apply(snapshot,op){if(checkValidOp(op),op===null)return snapshot;const held=[];return __name(function drop(root,descent){let subDoc=root,i=0,rootContainer={root},m=0,container=rootContainer,key="root";function mut(){for(;m<i;m++){let d=descent[m];typeof d!="object"&&(assert(isValidKey(container,key)),container=container[key]=shallowClone(container[key]),key=d)}}for(__name(mut,"mut");i<descent.length;i++){const d=descent[i];if(Array.isArray(d)){const child=drop(subDoc,d);child!==subDoc&&child!==void 0&&(mut(),subDoc=container[key]=child)}else if(typeof d=="object"){d.d!=null?(mut(),subDoc=insertChildMut(container,key,held[d.d])):d.i!==void 0&&(mut(),subDoc=insertChildMut(container,key,d.i));const t=getEditType(d);if(t)mut(),subDoc=container[key]=t.apply(subDoc,getEdit(d));else if(d.e!==void 0)throw Error("Subtype "+d.et+" undefined")}else subDoc=maybeGetChild(subDoc,d)}return rootContainer.root},"drop")(snapshot=__name(function pick(subDoc,descent){const stack=[];let i=0;for(;i<descent.length;i++){const d=descent[i];if(Array.isArray(d))break;typeof d!="object"&&(stack.push(subDoc),subDoc=maybeGetChild(subDoc,d))}for(let j=descent.length-1;j>=i;j--)subDoc=pick(subDoc,descent[j]);for(--i;i>=0;i--){const d=descent[i];if(typeof d!="object"){const container=stack.pop();subDoc=subDoc===maybeGetChild(container,d)?container:subDoc===void 0?removeChild(container,d):(k=d,v=subDoc,(obj=shallowClone(obj=container))[k]=v,obj)}else hasPick(d)&&(assert(subDoc!==void 0,"Cannot pick up or remove undefined"),d.p!=null&&(held[d.p]=subDoc),subDoc=void 0)}var obj,k,v;return subDoc},"pick")(snapshot,op),op)}__name(apply,"apply");function transformPosition(path,op){path=path.slice(),checkValidOp(op);const r=cursor_js_1.readCursor(op);let pickedAtSlot,pickIndex,removed=!1;const advStack=[];for(let i=0;;i++){const k=path[i],c=r.getComponent();if(c&&(c.r!==void 0?removed=!0:c.p!=null&&(removed=!1,pickedAtSlot=c.p,pickIndex=i)),i>=path.length)break;let pickOffset=0;const pickAdv=cursor_js_1.advancer(r,void 0,(k2,c2)=>{hasPick(c2)&&pickOffset++});advStack.unshift(pickAdv);const hasNext=pickAdv(k);if(typeof k=="number"&&(path[i]-=pickOffset),!hasNext)break}if(advStack.forEach(pickAdv=>pickAdv.end()),removed)return null;const handleDrop=__name(()=>{let i=0;if(pickedAtSlot!=null){const rPath=r.getPath();i=rPath.length,path=rPath.concat(path.slice(pickIndex))}for(;i<path.length;i++){const k=path[i],c=getComponent(r),et=getEditType(c);if(et){const e=getEdit(c);et.transformPosition&&(path[i]=et.transformPosition(path[i],e));break}let dropOffset=0;const hasNext=cursor_js_1.advancer(r,(k2,c2)=>hasDrop(c2)?~(k2-dropOffset):k2-dropOffset,(k2,c2)=>{hasDrop(c2)&&dropOffset++})(k);if(typeof k=="number"&&(path[i]+=dropOffset),!hasNext)break}},"handleDrop");return pickedAtSlot!=null?r.eachDrop(null,slot=>{slot===pickedAtSlot&&handleDrop()}):handleDrop(),path}__name(transformPosition,"transformPosition");function compose(op1,op2){if(checkValidOp(op1),checkValidOp(op2),op1==null)return op2;if(op2==null)return op1;let nextSlot=0;const r1=cursor_js_1.readCursor(op1),r2=cursor_js_1.readCursor(op2),w=cursor_js_1.writeCursor(),heldPickWrites=[],heldDropWrites=[],held1Pick=[],held2Drop=[],p1SlotMap=[],p2SlotMap=[],visitedOp2EditCs=new Set;r1.traverse(null,c=>{c.p!=null&&(held1Pick[c.p]=r1.clone())}),r2.traverse(null,c=>{c.d!=null&&(held2Drop[c.d]=r2.clone())});const w2=cursor_js_1.writeCursor();return __name(function xfBoundary(r1Pick,r1Drop,r2Pick,r2Drop,litIn,rmParent,wd,wp){assert(r1Drop||r2Pick);const c1d=getComponent(r1Drop),c2p=getComponent(r2Pick),rmHere=!!c2p&&c2p.r!==void 0,insHere=!!c1d&&c1d.i!==void 0,drop1Slot=c1d?c1d.d:null,pick2Slot=c2p?c2p.p:null,rmChildren=(rmParent||rmHere)&&pick2Slot==null;if(pick2Slot!=null)r2Drop=held2Drop[pick2Slot],wd=heldDropWrites[pick2Slot]=new cursor_js_1.WriteCursor;else if(c2p&&c2p.r!==void 0)r2Drop=null;else{const c2d2=getComponent(r2Drop);c2d2&&c2d2.d!=null&&(r2Drop=null)}const c2d=getComponent(r2Drop);if(drop1Slot!=null)if(r1Pick=held1Pick[drop1Slot],wp=heldPickWrites[drop1Slot]=new cursor_js_1.WriteCursor,rmChildren)rmParent&&!rmHere&&wp.write("r",!0);else{const slot=p1SlotMap[drop1Slot]=nextSlot++;wd.write("d",slot)}else if(c1d&&c1d.i!==void 0)r1Pick=null;else{const c1p=getComponent(r1Pick);c1p&&c1p.p!=null&&(r1Pick=null)}let litOut;insHere?(assert(litIn===void 0),litOut=c1d.i):litOut=litIn;const insComponent=(pick2Slot==null?!insHere||rmParent||rmHere:litOut===void 0)?null:wd.getComponent();if(pick2Slot!=null){if(!(litIn!==void 0||insHere)){const slot=drop1Slot!=null?p1SlotMap[drop1Slot]:nextSlot++;p2SlotMap[pick2Slot]=slot,wp.write("p",slot)}}else rmHere&&(insHere||litIn!==void 0||(c2p.r,wp.write("r",c2p.r)));const type1=rmChildren?null:getEditType(c1d),type2=getEditType(c2d);if((type1||type2)&&(type1&&type1.name,type2&&type2.name),type1&&type2){assert(type1===type2);const e1=getEdit(c1d),e2=getEdit(c2d),r=type1.compose(e1,e2);writeEdit(wd,type1,r),visitedOp2EditCs.add(c2d)}else type1?writeEdit(wd,type1,getEdit(c1d)):type2&&(writeEdit(wd,type2,getEdit(c2d)),visitedOp2EditCs.add(c2d));const hasContainerLiteral=typeof litOut=="object"&&litOut!=null;let isCloned=!1,p1PickOff=0,p1DropOff=0,p2PickOff=0,p2DropOff=0,litOff=0;const p2DropAdv=cursor_js_1.advancer(r2Drop,(k,c)=>hasDrop(c)?p2DropOff-k-1:k-p2DropOff,(k,c)=>{hasDrop(c)&&p2DropOff++}),p1PickAdv=cursor_js_1.advancer(r1Pick,(k,c)=>hasPick(c)?p1PickOff-k-1:k-p1PickOff,(k,c)=>{hasPick(c)&&p1PickOff++});if(cursor_js_1.eachChildOf(r1Drop,r2Pick,(inKey,_p1Drop,_p2Pick)=>{let _p1Pick,_p2Drop,p1PickKey=inKey,p2DropKey=inKey,litKey=inKey;if(typeof inKey=="number"){let p2Mid=inKey+p2PickOff;_p2Drop=p2DropAdv(p2Mid),p2DropKey=p2Mid+p2DropOff;let p1Mid=inKey+p1DropOff;_p1Pick=p1PickAdv(p1Mid),hasDrop(getComponent(_p2Drop))&&(_p1Pick=null),p1PickKey=p1Mid+p1PickOff,litKey=inKey+litOff,assert(p1PickKey>=0,"p1PickKey is negative"),assert(p2DropKey>=0,"p2DropKey is negative");const hd1=hasDrop(getComponent(_p1Drop)),hp2=hasPick(getComponent(_p2Pick));(hd1||hp2&&!rmChildren)&&litOff--,hd1&&p1DropOff--,hp2&&p2PickOff--}else _p1Pick=p1PickAdv(inKey),_p2Drop=p2DropAdv(inKey);wp.descend(p1PickKey),wd.descend(p2DropKey);const _lit=hasContainerLiteral&&!hasDrop(getComponent(_p1Drop))?litOut[litKey]:void 0,_litResult=xfBoundary(_p1Pick,_p1Drop,_p2Pick,_p2Drop,_lit,rmChildren,wd,wp);var container,key,child;hasContainerLiteral&&!rmChildren?_lit!==_litResult&&(isCloned||(litOut=Array.isArray(litOut)?litOut.slice():Object.assign({},litOut),isCloned=!0),container=litOut,child=_litResult,typeof(key=litKey)=="number"?(assert(Array.isArray(container)),assert(key<container.length)):(assert(!Array.isArray(container)),assert(container[key]!==void 0)),child===void 0?typeof key=="number"?container.splice(key,1):delete container[key]:container[key]=child):assert(_litResult===void 0),wd.ascend(),wp.ascend()}),p1PickAdv.end(),p2DropAdv.end(),insComponent!=null)insComponent.i=litOut;else if(!rmParent&&!rmHere&&pick2Slot==null)return litOut},"xfBoundary")(r1,r1.clone(),r2,r2.clone(),void 0,!1,w,w2),w.reset(),w.mergeTree(w2.get()),w.reset(),w.get(),heldPickWrites.map(w3=>w3.get()),heldDropWrites.map(w3=>w3.get()),r1.traverse(w,(c,w3)=>{const slot1=c.p;if(slot1!=null){const slot=p1SlotMap[slot1];slot!=null&&w3.write("p",slot);const _w=heldPickWrites[slot1];_w&&_w.get(),_w&&w3.mergeTree(_w.get())}else c.r!==void 0&&w3.write("r",c.r)}),w.reset(),w.get(),r2.traverse(w,(c,w3)=>{const slot2=c.d;if(slot2!=null){const slot=p2SlotMap[slot2];slot!=null&&w3.write("d",slot);const _w=heldDropWrites[slot2];_w&&w3.mergeTree(_w.get())}else c.i!==void 0&&w3.write("i",c.i);const t=getEditType(c);t&&!visitedOp2EditCs.has(c)&&writeEdit(w3,t,getEdit(c))}),w.get()}__name(compose,"compose");function invert(op){if(op==null)return null;const r=new cursor_js_1.ReadCursor(op),w=new cursor_js_1.WriteCursor;let editsToTransform;const heldPick=[],heldWrites=[];return __name(function invertSimple(r2,w2,subDoc){const c=r2.getComponent();let insertHere,subdocModified=!1;if(c){c.p!=null&&(w2.write("d",c.p),heldPick[c.p]=r2.clone()),c.r!==void 0&&w2.write("i",c.r),c.d!=null&&(w2.write("p",c.d),subDoc=void 0),c.i!==void 0&&(subDoc=insertHere=c.i);const t=getEditType(c);t&&(subDoc===void 0?(editsToTransform||(editsToTransform=new Set),editsToTransform.add(c)):(getEdit(c),subDoc=t.apply(subDoc,getEdit(c)),subdocModified=!0))}let dropOff=0;for(const key of r2){w2.descend(key);const raw=typeof key=="number"?key-dropOff:key,childIn=maybeGetChild(subDoc,raw);hasDrop(r2.getComponent())&&dropOff++;const childOut=invertSimple(r2,w2,childIn);if(subDoc!==void 0&&childOut!==void 0){if(subdocModified||(subdocModified=!0,subDoc=shallowClone(subDoc)),!isValidKey(subDoc,raw))throw Error("Cannot modify child - invalid operation");subDoc[raw]=childOut}w2.ascend()}if(insertHere===void 0)return subdocModified?subDoc:void 0;w2.write("r",subDoc)},"invertSimple")(r,w,void 0),editsToTransform&&(w.reset(),__name(function transformEdits(rPick,rDrop,w2){const cd=rDrop.getComponent();if(cd){const dropSlot=cd.d;if(dropSlot!=null&&(rPick=heldPick[dropSlot],w2=heldWrites[dropSlot]=cursor_js_1.writeCursor()),editsToTransform.has(cd)){const t=getEditType(cd);if(!t.invert)throw Error(`Cannot invert subtype ${t.name}`);writeEdit(w2,t,t.invert(getEdit(cd)))}}let pickOff=0,dropOff=0;const ap=cursor_js_1.advancer(rPick,(k,c)=>hasPick(c)?pickOff-k-1:k-pickOff,(k,c)=>{hasPick(c)&&pickOff++});for(const key of rDrop)if(typeof key=="number"){const mid=key-dropOff,_rPick=ap(mid),raw=mid+pickOff;w2.descend(raw),transformEdits(_rPick,rDrop,w2),hasDrop(rDrop.getComponent())&&dropOff++,w2.ascend()}else w2.descend(key),transformEdits(ap(key),rDrop,w2),w2.ascend();ap.end()},"transformEdits")(r.clone(),r,w),heldWrites.length&&(w.reset(),r.traverse(w,(c,w2)=>{const slot=c.p;if(slot!=null){const _w=heldWrites[slot];_w&&_w.get(),_w&&w2.mergeTree(_w.get())}}))),w.get()}__name(invert,"invert");const anyComponent=__name((op,fn)=>op.some(c=>typeof c=="object"&&(Array.isArray(c)?anyComponent(c,fn):fn(c))),"anyComponent");function makeInvertible(op,doc){if(op==null||!anyComponent(op,c=>{var _a2;return c.r!==void 0||((_a2=getEditType(c))===null||_a2===void 0?void 0:_a2.makeInvertible)!=null}))return op;const r=new cursor_js_1.ReadCursor(op),w=new cursor_js_1.WriteCursor;let hasEdits=!1;const heldPick=[],heldDoc=[],traversePick=__name((r2,w2,subDoc)=>{const c=r2.getComponent();let modified=!1;if(c){c.d!=null&&w2.write("d",c.d),c.i!==void 0&&w2.write("i",c.i);const pickSlot=c.p;if(pickSlot!=null&&(heldPick[pickSlot]=r2.clone(),assert(subDoc!==void 0,"Operation picks up at an invalid key"),heldDoc[pickSlot]=subDoc,w2.write("p",c.p)),c.r!==void 0&&subDoc===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const t=getEditType(c);t&&(t.makeInvertible?hasEdits=!0:writeEdit(w2,t,getEdit(c),!0))}let listOff=0;for(const key of r2){w2.descend(key);const keyRaw=typeof key=="number"?key-listOff:key,childIn=maybeGetChild(subDoc,keyRaw),childOut=traversePick(r2,w2,childIn);childIn!==childOut&&(modified||(modified=!0,subDoc=shallowClone(subDoc)),childOut===void 0?(subDoc=removeChild(subDoc,keyRaw),typeof key=="number"&&listOff++):subDoc[keyRaw]=childOut),w2.ascend()}return c&&(c.r!==void 0?(w2.write("r",deepClone_js_1.default(subDoc)),subDoc=void 0):c.p!=null&&(subDoc=void 0)),subDoc},"traversePick");return traversePick(r,w,doc),w.get(),hasEdits&&(w.reset(),__name(function traverseDrop(rPick,rDrop,w2,subDoc,isLiteral){const c=rDrop.getComponent();if(c){c.i!==void 0?(subDoc=c.i,isLiteral=!0):c.d!=null&&(subDoc=heldDoc[c.d],rPick=heldPick[c.d],isLiteral=!1,c.d);let t=getEditType(c);if(t&&t.makeInvertible){const edit=getEdit(c);writeEdit(w2,t,t.makeInvertible(edit,subDoc),!0)}}let pickOff=0,dropOff=0;const ap=cursor_js_1.advancer(rPick,(k,c2)=>hasPick(c2)?pickOff-k-1:k-pickOff,(k,c2)=>{hasPick(c2)&&pickOff++});for(const key of rDrop)if(typeof key=="number"){const mid=key-dropOff,_rPick=ap(mid),raw=mid+pickOff,child=maybeGetChild(subDoc,isLiteral?mid:raw);w2.descend(key),traverseDrop(_rPick,rDrop,w2,child,isLiteral),hasDrop(rDrop.getComponent())&&dropOff++,w2.ascend()}else{const child=maybeGetChild(subDoc,key);w2.descend(key),traverseDrop(ap(key),rDrop,w2,child,isLiteral),w2.ascend()}ap.end()},"traverseDrop")(r.clone(),r,w,doc,!1)),w.get()}__name(makeInvertible,"makeInvertible");function invertWithDoc(op,doc){return invert(makeInvertible(op,doc))}__name(invertWithDoc,"invertWithDoc");const shallowCloneOp=__name(op=>{if(op==null)return null;const result=op.slice();for(let i=0;i<op.length;i++){const c=result[i];Array.isArray(c)&&(result[i]=shallowCloneOp(c))}return result},"shallowCloneOp");function tryTransform(op1,op2,direction){assert(direction==="left"||direction==="right","Direction must be left or right");const side=direction==="left"?0:1;if(op2==null)return{ok:!0,result:op1};checkValidOp(op1),checkValidOp(op2);let conflict=null;const heldOp1PickByOp1=[],heldOp1DropByOp1=[],heldOp2PickByOp2=[],heldOp2DropByOp2=[],heldOp1PickByOp2=[],heldOp2PickByOp1=[],heldOp2DropByOp1=[],heldOp2RmForOp1=[],heldOp1RmForOp2=[],cancelledOp2=[],discardedOp2Drop=[],heldPickWrites=[],heldDropWrites=[],op1PickAtOp2Pick=[],op1PicksOp2DropSlots=[];let nextSlot=0;const r1=cursor_js_1.readCursor(op1),r2=cursor_js_1.readCursor(op2),w=cursor_js_1.writeCursor();if(__name(function scanOp2Pick(r2Pick,r1Pick=null,removed1){const c1=getComponent(r1Pick);c1&&(c1.r!==void 0?removed1=r1Pick.clone():c1.p!=null&&(removed1=null,heldOp2PickByOp1[c1.p]=r2Pick.clone()));const c2=r2Pick.getComponent();let slot2;c2&&(slot2=c2.p)!=null&&(heldOp1PickByOp2[slot2]=r1Pick?r1Pick.clone():null,heldOp2PickByOp2[slot2]=r2Pick.clone(),removed1&&(cancelledOp2[slot2]=!0,heldOp1RmForOp2[slot2]=removed1),c1&&c1.p!=null&&(op1PickAtOp2Pick[slot2]=c1.p));const ap1=cursor_js_1.advancer(r1Pick);for(const key of r2Pick)scanOp2Pick(r2Pick,ap1(key),removed1);ap1.end()},"scanOp2Pick")(r2,r1,null),__name(function scanOp2Drop(r1Pick,r2Pick,r2Drop,pickSlot1,removed1){const c2d=r2Drop.getComponent();let slot2,droppedHere=!1;c2d&&((slot2=c2d.d)!=null?(heldOp2DropByOp2[slot2]=r2Drop.clone(),pickSlot1!=null&&(op1PicksOp2DropSlots[pickSlot1]==null&&(op1PicksOp2DropSlots[pickSlot1]=[]),op1PicksOp2DropSlots[pickSlot1].push(slot2)),r1Pick=heldOp1PickByOp2[slot2]||null,r2Pick=heldOp2PickByOp2[slot2]||null,cancelledOp2[slot2]?(removed1&&(discardedOp2Drop[slot2]=!0),removed1=heldOp1RmForOp2[slot2]||null):!removed1||side!==1&&op1PickAtOp2Pick[slot2]!=null||conflict==null&&(conflict={type:types_js_1.ConflictType.RM_UNEXPECTED_CONTENT,op1:exports3.removeOp(removed1.getPath()),op2:exports3.moveOp(r2Pick.getPath(),r2Drop.getPath())}),droppedHere=!0):c2d.i!==void 0&&(r1Pick=r2Pick=null,droppedHere=!0,removed1&&conflict==null&&(conflict={type:types_js_1.ConflictType.RM_UNEXPECTED_CONTENT,op1:exports3.removeOp(removed1.getPath()),op2:exports3.insertOp(r2Drop.getPath(),c2d.i)})));const c1p=getComponent(r1Pick);c1p&&(c1p.r!==void 0?removed1=r1Pick.clone():c1p.p!=null&&(c1p.p,pickSlot1=c1p.p,removed1=null));const t2=getEditType(c2d);t2&&removed1&&conflict==null&&(conflict={type:types_js_1.ConflictType.RM_UNEXPECTED_CONTENT,op1:exports3.removeOp(removed1.getPath()),op2:exports3.editOp(r2Drop.getPath(),t2,getEdit(c2d),!0)});let p2PickOff=0,p2DropOff=0;const ap2=cursor_js_1.advancer(r2Pick,(k,c)=>hasPick(c)?p2PickOff-k-1:k-p2PickOff,(k,c)=>{hasPick(c)&&p2PickOff++}),ap1=cursor_js_1.advancer(r1Pick);for(const key of r2Drop)if(typeof key=="number"){const p2Mid=key-p2DropOff,_p2Pick=ap2(p2Mid);p2DropOff+=+scanOp2Drop(ap1(p2Mid+p2PickOff),_p2Pick,r2Drop,pickSlot1,removed1)}else{const _p2Pick=ap2(key);scanOp2Drop(ap1(key),_p2Pick,r2Drop,pickSlot1,removed1)}return ap2.end(),ap1.end(),droppedHere},"scanOp2Drop")(r1,r2,r2.clone(),null,null),heldOp2DropByOp2.map(x=>x&&x.get()),conflict)return{ok:!1,conflict};discardedOp2Drop.map(x=>!!x);const pickComponents=[];let cancelledRemoves=null;__name(function writeOp1Pick(r1Pick,r2Pick,r2Drop,w2,removed2){let iAmMoved=!1;const c2p=getComponent(r2Pick);if(hasPick(c2p)){const slot2=c2p.p;slot2!=null?(r2Drop=heldOp2DropByOp2[slot2],w2=heldPickWrites[slot2]=cursor_js_1.writeCursor(),iAmMoved=!0,removed2=null):(r2Drop=null,removed2=r2Pick.clone())}else hasDrop(getComponent(r2Drop))&&(r2Drop=null);const c1=r1Pick.getComponent();if(c1){const slot1=c1.p;slot1!=null?(removed2&&(heldOp2RmForOp1[slot1]=removed2),pickComponents[slot1]=removed2||side===1&&iAmMoved?null:w2.getComponent(),heldOp1PickByOp1[slot1]=r1Pick.clone(),r2Drop&&(heldOp2DropByOp1[slot1]=r2Drop.clone())):c1.r!==void 0&&(removed2||w2.write("r",!0),(removed2||iAmMoved)&&(cancelledRemoves==null&&(cancelledRemoves=new Set),cancelledRemoves.add(c1)))}let p2PickOff=0,p2DropOff=0;const ap2Pick=cursor_js_1.advancer(r2Pick,void 0,(k,c)=>{hasPick(c)&&p2PickOff++}),ap2Drop=cursor_js_1.advancer(r2Drop,(k,c)=>hasDrop(c)?~(k-p2DropOff):k-p2DropOff,(k,c)=>{hasDrop(c)&&p2DropOff++});if(r1Pick)for(const key of r1Pick)if(typeof key=="string"){const p2Pick_=ap2Pick(key),p2Drop_=ap2Drop(key);w2.descend(key),writeOp1Pick(r1Pick,p2Pick_,p2Drop_,w2,removed2),w2.ascend()}else{const p2Pick_=ap2Pick(key),p2Mid=key-p2PickOff,p2Drop_=hasPick(getComponent(p2Pick_))?null:ap2Drop(p2Mid),finalKey=p2Mid+p2DropOff;assert(finalKey>=0),w2.descend(finalKey),writeOp1Pick(r1Pick,p2Pick_,p2Drop_,w2,removed2),w2.ascend()}ap2Pick.end(),ap2Drop.end()},"writeOp1Pick")(r1,r2,r2.clone(),w,null),w.reset();let outputSlotMap=[];if(__name(function writeOp1Drop(p1Pick,p1Drop,p2Pick,p2Drop,w2,removed2){assert(p1Drop);const c1d=p1Drop.getComponent();let c2d=getComponent(p2Drop),droppedHere=!1;const insOrMv=__name((r12,r22,c)=>r12?exports3.moveOp(r12.getPath(),r22.getPath()):exports3.insertOp(r22.getPath(),c.i),"insOrMv");if(hasDrop(c1d)){const slot1=c1d.d;slot1!=null&&(heldOp1DropByOp1[slot1]=p1Drop.clone());const pc=slot1!=null?pickComponents[slot1]:null;let identical=!1;if(c1d.i!==void 0||slot1!=null&&pc){let slot2;c2d&&(c2d.i!==void 0||(slot2=c2d.d)!=null&&!cancelledOp2[slot2])&&(identical=slot2!=null?slot1!=null&&slot1===op1PickAtOp2Pick[slot2]:deepEqual_js_1.default(c2d.i,c1d.i),identical||slot2!=null&&side!==1&&op1PickAtOp2Pick[slot2]!=null||conflict==null&&(conflict={type:types_js_1.ConflictType.DROP_COLLISION,op1:insOrMv(slot1!=null?heldOp1PickByOp1[slot1]:null,p1Drop,c1d),op2:insOrMv(slot2!=null?heldOp2PickByOp2[slot2]:null,p2Drop,c2d)})),identical||(removed2?conflict==null&&(conflict={type:types_js_1.ConflictType.RM_UNEXPECTED_CONTENT,op1:insOrMv(slot1!=null?heldOp1PickByOp1[slot1]:null,p1Drop,c1d),op2:exports3.removeOp(removed2.getPath())}):(slot1!=null?(outputSlotMap[nextSlot]=slot1,w2.write("d",pc.p=nextSlot++)):w2.write("i",deepClone_js_1.default(c1d.i)),droppedHere=!0))}else if(slot1!=null&&!pc){const h=heldOp2RmForOp1[slot1];h&&(removed2=h.clone())}slot1!=null?(p1Pick=heldOp1PickByOp1[slot1],p2Pick=heldOp2PickByOp1[slot1],p2Drop=heldOp2DropByOp1[slot1]):c1d.i!==void 0&&(p1Pick=p2Pick=null,identical||(p2Drop=null))}else hasPick(getComponent(p1Pick))&&(p1Pick=p2Pick=p2Drop=null);const c1p=getComponent(p1Pick),c2p=getComponent(p2Pick);if(hasPick(c2p)){const slot2=c2p.p;c2p.r!==void 0&&(!c1p||c1p.r===void 0)||cancelledOp2[slot2]?(p2Drop=null,removed2=p2Pick.clone()):slot2!=null&&(p2Drop=heldOp2DropByOp2[slot2],side!==1&&op1PickAtOp2Pick[slot2]!=null||((w2=heldDropWrites[slot2])||(w2=heldDropWrites[slot2]=cursor_js_1.writeCursor()),w2.reset(),removed2=null))}else!hasDrop(c1d)&&hasDrop(c2d)&&(p2Drop=null);c2d=p2Drop!=null?p2Drop.getComponent():null;const t1=getEditType(c1d);if(t1){const e1=getEdit(c1d);if(removed2)conflict==null&&(conflict={type:types_js_1.ConflictType.RM_UNEXPECTED_CONTENT,op1:exports3.editOp(p1Drop.getPath(),t1,e1,!0),op2:exports3.removeOp(removed2.getPath())});else{const t2=getEditType(c2d);let e;if(t2){if(t1!==t2)throw Error("Transforming incompatible types");const e2=getEdit(c2d);e=t1.transform(e1,e2,direction)}else e=deepClone_js_1.default(e1);writeEdit(w2,t1,e)}}let p1PickOff=0,p1DropOff=0,p2PickOff=0,p2DropOff=0,outPickOff=0,outDropOff=0,p1pValid=p1Pick!=null&&p1Pick.descendFirst(),p1pDidDescend=p1pValid;const ap2p=cursor_js_1.advancer(p2Pick,void 0,(k,c)=>{hasPick(c)&&p2PickOff++});let p2dValid=p2Drop!=null&&p2Drop.descendFirst(),p2dDidDescend=p2dValid;for(const key of p1Drop)if(typeof key=="number"){let _p1Pick;const hd1=hasDrop(p1Drop.getComponent()),k1Mid=key-p1DropOff;{let p1k;for(;p1pValid&&typeof(p1k=p1Pick.getKey())=="number";){p1k+=p1PickOff;const c=p1Pick.getComponent(),hp=hasPick(c);if(p1k>k1Mid||p1k===k1Mid&&(!hp||side===0&&hd1))break;if(hp){p1PickOff--;const slot1=c.p;op1PickAtOp2Pick.includes(slot1),c.d,getComponent(heldDropWrites[c.d]),hasPick(getComponent(heldDropWrites[c.d])),(c.r===void 0||cancelledRemoves&&cancelledRemoves.has(c))&&(slot1==null||!pickComponents[slot1]||side!==1&&op1PickAtOp2Pick.includes(slot1))||outPickOff--}p1pValid=p1Pick.nextSibling()}_p1Pick=p1pValid&&p1k===k1Mid?p1Pick:null}const raw=k1Mid-p1PickOff;let _p2Pick=ap2p(raw);const k2Mid=raw-p2PickOff;let _p2Drop=null;{let p2dk,op2Mid;for(;p2dValid&&typeof(p2dk=p2Drop.getKey())=="number";){op2Mid=p2dk-p2DropOff;const c=p2Drop.getComponent(),hd2=hasDrop(c);if(op2Mid>k2Mid)break;if(op2Mid===k2Mid){if(!hd2){_p2Drop=p2Drop;break}{if(side===0&&hd1){_p2Drop=p2Drop;break}const hp2=_p2Pick&&hasPick(_p2Pick.getComponent());if(side===0&&hp2)break}}if(hd2){const slot2=c.d;op1PickAtOp2Pick[slot2],c.i===void 0&&(cancelledOp2[slot2]||op1PickAtOp2Pick[slot2]!=null&&side!==1)?(cancelledOp2[slot2]||op1PickAtOp2Pick[slot2]!=null&&side===0)&&(p2DropOff++,outDropOff--):p2DropOff++}p2dValid=p2Drop.nextSibling()}}const descend=k2Mid+p2DropOff+outPickOff+outDropOff;assert(descend>=0,"trying to descend to a negative index"),w2.descend(descend),hd1&&(_p1Pick=_p2Pick=_p2Drop=null,p1DropOff++),writeOp1Drop(_p1Pick,p1Drop,_p2Pick,_p2Drop,w2,removed2)&&outDropOff++,w2.ascend()}else{let p1k;for(;p1pValid&&(p1k=p1Pick.getKey(),typeof p1k!="string"||!(p1k>key||p1k===key));)p1pValid=p1Pick.nextSibling();const _p1Pick=p1pValid&&p1k===key?p1Pick:null,_p2Pick=ap2p(key);let p2dk;for(;p2dValid&&(p2dk=p2Drop.getKey(),typeof p2dk!="string"||!(p2dk>key||p2dk===key));)p2dValid=p2Drop.nextSibling();const _p2Drop=p2dValid&&p2dk===key?p2Drop:null;w2.descend(key),writeOp1Drop(_p1Pick,p1Drop,_p2Pick,_p2Drop,w2,removed2),w2.ascend()}return ap2p.end(),p1pDidDescend&&p1Pick.ascend(),p2dDidDescend&&p2Drop.ascend(),droppedHere},"writeOp1Drop")(r1,r1.clone(),r2,r2.clone(),w,null),conflict)return{ok:!1,conflict};w.reset();const eachDrop=__name((r,w2,fn)=>r.traverse(w2,(c,w3)=>{c.d!=null&&fn(c.d,r,w3)}),"eachDrop");(cancelledOp2.length||heldPickWrites.length)&&(eachDrop(r2,w,(slot2,r,w2)=>{cancelledOp2[slot2]&&!discardedOp2Drop[slot2]&&w2.write("r",!0),heldPickWrites[slot2]&&w2.mergeTree(heldPickWrites[slot2].get())}),w.reset());const heldOutDropRead=[],heldOutDropWrites=[];if((heldDropWrites.length||cancelledOp2.length)&&!conflict){const rOut=cursor_js_1.readCursor(shallowCloneOp(w.get()));if(eachDrop(rOut,null,(slotOut,r)=>{heldOutDropRead[slotOut]=r.clone()}),heldDropWrites.forEach(hdw=>{hdw&&eachDrop(cursor_js_1.readCursor(hdw.get()),null,(slotOut,r)=>{heldOutDropRead[slotOut]=r.clone()})}),__name(function writeHeldOp2Drop(p2Drop,outPick,outDrop,w2,parentC,removedOut){const coutp=getComponent(outPick);if(coutp&&hasPick(coutp))if(coutp.p!=null){const slot=coutp.p;heldOutDropRead[slot].getPath(),outDrop=heldOutDropRead[slot],w2=heldOutDropWrites[slot]=cursor_js_1.writeCursor()}else coutp.r!==void 0&&(outDrop=null);else hasDrop(getComponent(outDrop))&&(outDrop=null);const c2=p2Drop.getComponent();if(c2){let slot2;if((slot2=c2.d)!=null){const _w=heldDropWrites[slot2];_w&&(_w.get(),w2.mergeTree(_w.get()),outDrop=cursor_js_1.readCursor(_w.get()))}}let outPickOff=0,outDropOff=0;const oPickAdv=cursor_js_1.advancer(outPick,void 0,(k,c)=>{hasPick(c)&&outPickOff--}),oDropAdv=cursor_js_1.advancer(outDrop,(k,c)=>hasDrop(c)?-(k-outDropOff)-1:k-outDropOff,(k,c)=>{hasDrop(c)&&outDropOff++});for(const o2dk of p2Drop)if(typeof o2dk=="number"){const _outPick=oPickAdv(o2dk),rmid=o2dk+outPickOff,_outDrop=oDropAdv(rmid),rfinal=rmid+outDropOff;w2.descend(rfinal),writeHeldOp2Drop(p2Drop,_outPick,_outDrop,w2),w2.ascend()}else w2.descend(o2dk),writeHeldOp2Drop(p2Drop,oPickAdv(o2dk),oDropAdv(o2dk),w2),w2.ascend();oPickAdv.end(),oDropAdv.end()},"writeHeldOp2Drop")(r2,rOut,rOut.clone(),w),w.reset(),conflict)return{ok:!1,conflict};if(w.get(),heldOutDropWrites.length){const heldOutDropContent=heldOutDropWrites.map(w2=>w2?w2.get():null),rOut2=cursor_js_1.readCursor(shallowCloneOp(w.get()));if(eachDrop(rOut2,w,(slotOut,r,w2)=>{const data=heldOutDropContent[slotOut];data&&(w2.mergeTree(data),heldOutDropContent[slotOut]=null)}),heldOutDropContent.find(x=>x)){const w1=cursor_js_1.writeCursor(),w2=cursor_js_1.writeCursor();let nextSlot1=0,nextSlot2=0;heldOutDropContent.forEach(data=>{data!=null&&eachDrop(cursor_js_1.readCursor(data),null,c=>{const slot1=outputSlotMap[c];w1.writeMove(heldOp1PickByOp1[slot1].getPath(),heldOp1DropByOp1[slot1].getPath(),nextSlot1++);const slot2s=op1PicksOp2DropSlots[slot1];slot2s&&slot2s.forEach(slot2=>{cancelledOp2[slot2]||side!==1&&op1PickAtOp2Pick[slot2]!=null||w2.writeMove(heldOp2PickByOp2[slot2].getPath(),heldOp2DropByOp2[slot2].getPath(),nextSlot2++)})})}),conflict={type:types_js_1.ConflictType.BLACKHOLE,op1:w1.get(),op2:w2.get()}}}}return conflict?{ok:!1,conflict}:{ok:!0,result:w.get()}}__name(tryTransform,"tryTransform");const throwConflictErr=__name(conflict=>{const err=new Error("Transform detected write conflict");throw err.conflict=conflict,err.type=err.name="writeConflict",err},"throwConflictErr");function transform(op1,op2,side){const res=tryTransform(op1,op2,side);if(res.ok)return res.result;throwConflictErr(res.conflict)}__name(transform,"transform");const opThatRemovesDE=__name(op=>{const w=cursor_js_1.writeCursor();return cursor_js_1.readCursor(op).traverse(w,(c,w2)=>{(hasDrop(c)||getEditType(c))&&w2.write("r",!0)}),w.get()},"opThatRemovesDE"),resolveConflict=__name((conflict,side)=>{const{type:type2,op1,op2}=conflict;switch(type2){case types_js_1.ConflictType.DROP_COLLISION:return side==="left"?[null,opThatRemovesDE(op2)]:[opThatRemovesDE(op1),null];case types_js_1.ConflictType.RM_UNEXPECTED_CONTENT:let op1HasRemove=!1;return cursor_js_1.readCursor(op1).traverse(null,c=>{c.r!==void 0&&(op1HasRemove=!0)}),op1HasRemove?[null,opThatRemovesDE(op2)]:[opThatRemovesDE(op1),null];case types_js_1.ConflictType.BLACKHOLE:return[opThatRemovesDE(op1),opThatRemovesDE(op2)];default:throw Error("Unrecognised conflict: "+type2)}},"resolveConflict");function transformWithConflictsPred(allowConflict,op1,op2,side){let r2Aggregate=null;for(;;){const res=tryTransform(op1,op2,side);if(res.ok)return compose(r2Aggregate,res.result);{const{conflict}=res;allowConflict(conflict)||throwConflictErr(conflict);const[r1,r2]=resolveConflict(conflict,side);op1=compose(normalize(op1),r1),op2=compose(normalize(op2),r2),r2Aggregate=compose(r2Aggregate,r2)}}}__name(transformWithConflictsPred,"transformWithConflictsPred")}(json1_release),function(exports3){var __createBinding=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(o,m,k,k2){k2===void 0&&(k2=k),Object.defineProperty(o,k2,{enumerable:!0,get:__name(function(){return m[k]},"get")})}:function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]}),__exportStar=commonjsGlobal&&commonjsGlobal.__exportStar||function(m,exports4){for(var p in m)p!=="default"&&!exports4.hasOwnProperty(p)&&__createBinding(exports4,m,p)};Object.defineProperty(exports3,"__esModule",{value:!0}),__exportStar(json1_release,exports3);var cursor_js_1=cursor;Object.defineProperty(exports3,"ReadCursor",{enumerable:!0,get:__name(function(){return cursor_js_1.ReadCursor},"get")}),Object.defineProperty(exports3,"WriteCursor",{enumerable:!0,get:__name(function(){return cursor_js_1.WriteCursor},"get")});var types_1=types;Object.defineProperty(exports3,"ConflictType",{enumerable:!0,get:__name(function(){return types_1.ConflictType},"get")})}(dist$1);const _UnitDrawingService=class _UnitDrawingService{constructor(){__publicField(this,"drawingManagerData",{});__publicField(this,"_oldDrawingManagerData",{});__publicField(this,"_focusDrawings",[]);__publicField(this,"_remove$",new rxjs.Subject);__publicField(this,"remove$",this._remove$.asObservable());__publicField(this,"_add$",new rxjs.Subject);__publicField(this,"add$",this._add$.asObservable());__publicField(this,"_update$",new rxjs.Subject);__publicField(this,"update$",this._update$.asObservable());__publicField(this,"_order$",new rxjs.Subject);__publicField(this,"order$",this._order$.asObservable());__publicField(this,"_group$",new rxjs.Subject);__publicField(this,"group$",this._group$.asObservable());__publicField(this,"_ungroup$",new rxjs.Subject);__publicField(this,"ungroup$",this._ungroup$.asObservable());__publicField(this,"_refreshTransform$",new rxjs.Subject);__publicField(this,"refreshTransform$",this._refreshTransform$.asObservable());__publicField(this,"_visible$",new rxjs.Subject);__publicField(this,"visible$",this._visible$.asObservable());__publicField(this,"_focus$",new rxjs.Subject);__publicField(this,"focus$",this._focus$.asObservable());__publicField(this,"_featurePluginUpdate$",new rxjs.Subject);__publicField(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());__publicField(this,"_featurePluginAdd$",new rxjs.Subject);__publicField(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());__publicField(this,"_featurePluginRemove$",new rxjs.Subject);__publicField(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());__publicField(this,"_featurePluginOrderUpdate$",new rxjs.Subject);__publicField(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());__publicField(this,"_featurePluginGroupUpdate$",new rxjs.Subject);__publicField(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());__publicField(this,"_featurePluginUngroupUpdate$",new rxjs.Subject);__publicField(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());__publicField(this,"_visible",!0);__publicField(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(visibleParams){this._visible$.next(visibleParams)}refreshTransform(updateParams){updateParams.forEach(updateParam=>{const param=this._getCurrentBySearch(updateParam);param!=null&&(param.transform=updateParam.transform,param.transforms=updateParam.transforms,param.isMultiTransform=updateParam.isMultiTransform)}),this.refreshTransformNotification(updateParams)}getDrawingDataForUnit(unitId){return this.drawingManagerData[unitId]||{}}removeDrawingDataForUnit(unitId){const subUnits=this.drawingManagerData[unitId];if(subUnits==null)return;delete this.drawingManagerData[unitId];const drawings=[];Object.keys(subUnits).forEach(subUnitId=>{const subUnit=subUnits[subUnitId];(subUnit==null?void 0:subUnit.data)!=null&&Object.keys(subUnit.data).forEach(drawingId=>{drawings.push({unitId,subUnitId,drawingId})})}),drawings.length>0&&this.removeNotification(drawings)}registerDrawingData(unitId,data){this.drawingManagerData[unitId]=data}initializeNotification(unitId){const drawings=[],data=this.drawingManagerData[unitId];data!=null&&(Object.keys(data).forEach(subUnitId=>{this._establishDrawingMap(unitId,subUnitId);const subUnitData=data[subUnitId];Object.keys(subUnitData.data).forEach(drawingId=>{const drawing=subUnitData.data[drawingId];drawing.unitId=unitId,drawing.subUnitId=subUnitId,drawings.push(drawing)})}),drawings.length>0&&this.addNotification(drawings))}getDrawingData(unitId,subUnitId){return this._getDrawingData(unitId,subUnitId)}setDrawingData(unitId,subUnitId,data){this.drawingManagerData[unitId][subUnitId].data=data}getBatchAddOp(insertParams){const objects=[],ops=[],invertOps=[];insertParams.forEach(insertParam=>{const{op:op2,invertOp:invertOp2}=this._addByParam(insertParam);objects.push({unitId:insertParam.unitId,subUnitId:insertParam.subUnitId,drawingId:insertParam.drawingId}),ops.push(op2),invertOps.push(invertOp2)});const op=ops.reduce(dist$1.type.compose,null),invertOp=invertOps.reduce(dist$1.type.compose,null),{unitId,subUnitId}=insertParams[0];return{undo:invertOp,redo:op,unitId,subUnitId,objects}}getBatchRemoveOp(removeParams){const ops=[],invertOps=[];removeParams.forEach(removeParam=>{const{op:op2,invertOp:invertOp2}=this._removeByParam(removeParam);ops.unshift(op2),invertOps.push(invertOp2)});const op=ops.reduce(dist$1.type.compose,null),invertOp=invertOps.reduce(dist$1.type.compose,null),{unitId,subUnitId}=removeParams[0];return{undo:invertOp,redo:op,unitId,subUnitId,objects:removeParams}}getBatchUpdateOp(updateParams){const objects=[],ops=[],invertOps=[];updateParams.forEach(updateParam=>{const{op:op2,invertOp:invertOp2}=this._updateByParam(updateParam);objects.push({unitId:updateParam.unitId,subUnitId:updateParam.subUnitId,drawingId:updateParam.drawingId}),ops.push(op2),invertOps.push(invertOp2)});const op=ops.reduce(dist$1.type.compose,null),invertOp=invertOps.reduce(dist$1.type.compose,null),{unitId,subUnitId}=updateParams[0];return{undo:invertOp,redo:op,unitId,subUnitId,objects}}removeNotification(removeParams){this._remove$.next(removeParams)}addNotification(insertParams){this._add$.next(insertParams)}updateNotification(updateParams){this._update$.next(updateParams)}orderNotification(orderParams){this._order$.next(orderParams)}groupUpdateNotification(groupParams){this._group$.next(groupParams)}ungroupUpdateNotification(groupParams){this._ungroup$.next(groupParams)}refreshTransformNotification(refreshParams){this._refreshTransform$.next(refreshParams)}getGroupDrawingOp(groupParams){const ops=[],{unitId,subUnitId}=groupParams[0].parent;groupParams.forEach(groupParam=>{ops.push(this._getGroupDrawingOp(groupParam))});const op=ops.reduce(dist$1.type.compose,null);return{undo:dist$1.type.invertWithDoc(op,this.drawingManagerData),redo:op,unitId,subUnitId,objects:groupParams}}getUngroupDrawingOp(groupParams){const ops=[],{unitId,subUnitId}=groupParams[0].parent;groupParams.forEach(groupParam=>{ops.push(this._getUngroupDrawingOp(groupParam))});const op=ops.reduce(dist$1.type.compose,null);return{undo:dist$1.type.invertWithDoc(op,this.drawingManagerData),redo:op,unitId,subUnitId,objects:groupParams}}getDrawingsByGroup(groupParam){const{unitId,subUnitId,drawingId}=groupParam;if(this.getDrawingByParam({unitId,subUnitId,drawingId})==null)return[];const drawings=this._getDrawingData(unitId,subUnitId),children=[];return Object.keys(drawings).forEach(key=>{const drawing=drawings[key];drawing.groupId===drawingId&&children.push(drawing)}),children}_getGroupDrawingOp(groupParam){const{parent,children}=groupParam,{unitId:groupUnitId,subUnitId:groupSubUnitId,drawingId:groupDrawingId}=parent,ops=[];ops.push(dist$1.insertOp([groupUnitId,groupSubUnitId,"data",groupDrawingId],parent));let maxChildIndex=Number.NEGATIVE_INFINITY;return children.forEach(child=>{const{unitId,subUnitId,drawingId}=child,index=this._hasDrawingOrder({unitId,subUnitId,drawingId});maxChildIndex=Math.max(maxChildIndex,index),ops.push(...this._getUpdateParamCompareOp(child,this.getDrawingByParam({unitId,subUnitId,drawingId})))}),maxChildIndex===Number.NEGATIVE_INFINITY&&(maxChildIndex=this._getDrawingOrder(groupUnitId,groupSubUnitId).length),ops.push(dist$1.insertOp([groupUnitId,groupSubUnitId,"order",maxChildIndex],groupDrawingId)),ops.reduce(dist$1.type.compose,null)}_getUngroupDrawingOp(groupParam){const{parent,children}=groupParam,{unitId:groupUnitId,subUnitId:groupSubUnitId,drawingId:groupDrawingId}=parent,ops=[];return children.forEach(child=>{const{unitId,subUnitId,drawingId}=child;ops.push(...this._getUpdateParamCompareOp(child,this.getDrawingByParam({unitId,subUnitId,drawingId})))}),ops.push(dist$1.removeOp([groupUnitId,groupSubUnitId,"data",groupDrawingId],!0)),ops.push(dist$1.removeOp([groupUnitId,groupSubUnitId,"order",this._getDrawingOrder(groupUnitId,groupSubUnitId).indexOf(groupDrawingId)],!0)),ops.reduce(dist$1.type.compose,null)}applyJson1(unitId,subUnitId,jsonOp){this._establishDrawingMap(unitId,subUnitId),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=dist$1.type.apply(this.drawingManagerData,jsonOp)}featurePluginUpdateNotification(updateParams){this._featurePluginUpdate$.next(updateParams)}featurePluginOrderUpdateNotification(drawingOrderUpdateParam){this._featurePluginOrderUpdate$.next(drawingOrderUpdateParam)}featurePluginAddNotification(insertParams){this._featurePluginAdd$.next(insertParams)}featurePluginRemoveNotification(removeParams){this._featurePluginRemove$.next(removeParams)}featurePluginGroupUpdateNotification(groupParams){this._featurePluginGroupUpdate$.next(groupParams)}featurePluginUngroupUpdateNotification(groupParams){this._featurePluginUngroupUpdate$.next(groupParams)}getDrawingByParam(param){return this._getCurrentBySearch(param)}getOldDrawingByParam(param){return this._getOldBySearch(param)}getDrawingOKey(oKey){const[unitId,subUnitId,drawingId]=oKey.split("#-#");return this._getCurrentBySearch({unitId,subUnitId,drawingId})}focusDrawing(params){if(params==null){this._focusDrawings=[],this._focus$.next([]);return}const drawingParams=[];params.forEach(param=>{var _a2;const{unitId,subUnitId,drawingId}=param,item=(_a2=this._getDrawingData(unitId,subUnitId))==null?void 0:_a2[drawingId];item!=null&&drawingParams.push(item)}),drawingParams.length>0&&(this._focusDrawings=drawingParams,this._focus$.next(drawingParams))}getFocusDrawings(){const drawingParams=[];return this._focusDrawings.forEach(param=>{var _a2;const{unitId,subUnitId,drawingId}=param,item=(_a2=this._getDrawingData(unitId,subUnitId))==null?void 0:_a2[drawingId];item!=null&&drawingParams.push(item)}),drawingParams}getDrawingOrder(unitId,subUnitId){return this._getDrawingOrder(unitId,subUnitId)}setDrawingOrder(unitId,subUnitId,order){this.drawingManagerData[unitId][subUnitId].order=order}orderUpdateNotification(orderParams){this._order$.next(orderParams)}getForwardDrawingsOp(orderParams){const{unitId,subUnitId,drawingIds}=orderParams,ops=[],orders=this.getDrawingOrder(unitId,subUnitId),newIds=[...drawingIds];drawingIds.forEach(drawingId=>{const index=this._hasDrawingOrder({unitId,subUnitId,drawingId});if(index===-1||index===orders.length-1)return;const op2=dist$1.moveOp([unitId,subUnitId,"order",index],[unitId,subUnitId,"order",index+1]);ops.push(op2),newIds.includes(orders[index+1])||newIds.push(orders[index+1])});const op=ops.reduce(dist$1.type.compose,null);return{undo:dist$1.type.invertWithDoc(op,this.drawingManagerData),redo:op,unitId,subUnitId,objects:{...orderParams,drawingIds:newIds}}}getBackwardDrawingOp(orderParams){const{unitId,subUnitId,drawingIds}=orderParams,ops=[],orders=this.getDrawingOrder(unitId,subUnitId),newIds=[...drawingIds];drawingIds.forEach(drawingId=>{const index=this._hasDrawingOrder({unitId,subUnitId,drawingId});if(index===-1||index===0)return;const op2=dist$1.moveOp([unitId,subUnitId,"order",index],[unitId,subUnitId,"order",index-1]);ops.push(op2),newIds.includes(orders[index-1])||newIds.push(orders[index-1])});const op=ops.reduce(dist$1.type.compose,null);return{undo:dist$1.type.invertWithDoc(op,this.drawingManagerData),redo:op,unitId,subUnitId,objects:{...orderParams,drawingIds:newIds}}}getFrontDrawingsOp(orderParams){const{unitId,subUnitId,drawingIds}=orderParams,orderDrawingIds=this._getOrderFromSearchParams(unitId,subUnitId,drawingIds),newIds=[...drawingIds],orders=this.getDrawingOrder(unitId,subUnitId),ops=[];orderDrawingIds.forEach(orderDrawingId=>{const{drawingId}=orderDrawingId,index=this._getDrawingCount(unitId,subUnitId)-1,op2=dist$1.moveOp([unitId,subUnitId,"order",this._getDrawingOrder(unitId,subUnitId).indexOf(drawingId)],[unitId,subUnitId,"order",index]);ops.push(op2),newIds.includes(orders[index])||newIds.push(orders[index])});const op=ops.reduce(dist$1.type.compose,null);return{undo:dist$1.type.invertWithDoc(op,this.drawingManagerData),redo:op,unitId,subUnitId,objects:{...orderParams,drawingIds:newIds}}}getBackDrawingsOp(orderParams){const{unitId,subUnitId,drawingIds}=orderParams,orderSearchParams=this._getOrderFromSearchParams(unitId,subUnitId,drawingIds,!0),newIds=[...drawingIds],orders=this.getDrawingOrder(unitId,subUnitId),ops=[];orderSearchParams.forEach(orderSearchParam=>{const{drawingId}=orderSearchParam,op2=dist$1.moveOp([unitId,subUnitId,"order",this._getDrawingOrder(unitId,subUnitId).indexOf(drawingId)],[unitId,subUnitId,"order",0]);ops.push(op2),newIds.includes(orders[0])||newIds.push(orders[0])});const op=ops.reduce(dist$1.type.compose,null);return{undo:dist$1.type.invertWithDoc(op,this.drawingManagerData),redo:op,unitId,subUnitId,objects:{...orderParams,drawingIds:newIds}}}_getDrawingCount(unitId,subUnitId){return this.getDrawingOrder(unitId,subUnitId).length||0}_getOrderFromSearchParams(unitId,subUnitId,drawingIds,isDesc=!1){return drawingIds.map(drawingId=>{const zIndex=this._hasDrawingOrder({unitId,subUnitId,drawingId});return{drawingId,zIndex}}).sort(isDesc===!1?core.sortRules:core.sortRulesByDesc)}_hasDrawingOrder(searchParam){if(searchParam==null)return-1;const{unitId,subUnitId,drawingId}=searchParam;return this._establishDrawingMap(unitId,subUnitId),this._getDrawingOrder(unitId,subUnitId).indexOf(drawingId)}_getCurrentBySearch(searchParam){var _a2,_b,_c;if(searchParam==null)return;const{unitId,subUnitId,drawingId}=searchParam;return(_c=(_b=(_a2=this.drawingManagerData[unitId])==null?void 0:_a2[subUnitId])==null?void 0:_b.data)==null?void 0:_c[drawingId]}_getOldBySearch(searchParam){var _a2,_b,_c;if(searchParam==null)return;const{unitId,subUnitId,drawingId}=searchParam;return(_c=(_b=(_a2=this._oldDrawingManagerData[unitId])==null?void 0:_a2[subUnitId])==null?void 0:_b.data)==null?void 0:_c[drawingId]}_establishDrawingMap(unitId,subUnitId,drawingId){var _a2;return this.drawingManagerData[unitId]||(this.drawingManagerData[unitId]={}),this.drawingManagerData[unitId][subUnitId]||(this.drawingManagerData[unitId][subUnitId]={data:{},order:[]}),drawingId==null?null:(_a2=this.drawingManagerData[unitId][subUnitId].data)==null?void 0:_a2[drawingId]}_addByParam(insertParam){const{unitId,subUnitId,drawingId}=insertParam;this._establishDrawingMap(unitId,subUnitId,drawingId);const op1=dist$1.insertOp([unitId,subUnitId,"data",drawingId],insertParam),op2=dist$1.insertOp([unitId,subUnitId,"order",this._getDrawingOrder(unitId,subUnitId).length],drawingId),op=[op1,op2].reduce(dist$1.type.compose,null),invertOp=dist$1.type.invertWithDoc(op,this.drawingManagerData);return{op,invertOp}}_removeByParam(searchParam){if(searchParam==null)return{op:[],invertOp:[]};const{unitId,subUnitId,drawingId}=searchParam;if(this._establishDrawingMap(unitId,subUnitId,drawingId)==null)return{op:[],invertOp:[]};const op1=dist$1.removeOp([unitId,subUnitId,"data",drawingId],!0),op2=dist$1.removeOp([unitId,subUnitId,"order",this._getDrawingOrder(unitId,subUnitId).indexOf(drawingId)],!0),op=[op1,op2].reduce(dist$1.type.compose,null),invertOp=dist$1.type.invertWithDoc(op,this.drawingManagerData);return{op,invertOp}}_updateByParam(updateParam){const{unitId,subUnitId,drawingId}=updateParam,object=this._establishDrawingMap(unitId,subUnitId,drawingId);if(object==null)return{op:[],invertOp:[]};const op=this._getUpdateParamCompareOp(updateParam,object).reduce(dist$1.type.compose,null),invertOp=dist$1.type.invertWithDoc(op,this.drawingManagerData);return{op,invertOp}}_getUpdateParamCompareOp(newParam,oldParam){const{unitId,subUnitId,drawingId}=newParam,ops=[];return Object.keys(newParam).forEach(key=>{const newVal=newParam[key],oldVal=oldParam[key];oldVal!==newVal&&ops.push(dist$1.replaceOp([unitId,subUnitId,"data",drawingId,key],oldVal,newVal))}),ops}_getDrawingData(unitId,subUnitId){var _a2,_b;return((_b=(_a2=this.drawingManagerData[unitId])==null?void 0:_a2[subUnitId])==null?void 0:_b.data)||{}}_getDrawingOrder(unitId,subUnitId){var _a2,_b;return((_b=(_a2=this.drawingManagerData[unitId])==null?void 0:_a2[subUnitId])==null?void 0:_b.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(visible){this._visible=visible}setDrawingEditable(editable){this._editable=editable}};__name(_UnitDrawingService,"UnitDrawingService");let UnitDrawingService=_UnitDrawingService;const _DrawingManagerService=class _DrawingManagerService extends UnitDrawingService{};__name(_DrawingManagerService,"DrawingManagerService");let DrawingManagerService=_DrawingManagerService;function getDrawingShapeKeyByDrawingSearch({unitId,subUnitId,drawingId},index){return typeof index=="number"?`${unitId}#-#${subUnitId}#-#${drawingId}#-#${index}`:`${unitId}#-#${subUnitId}#-#${drawingId}`}__name(getDrawingShapeKeyByDrawingSearch,"getDrawingShapeKeyByDrawingSearch");const getImageSize=__name(async src=>new Promise((resolve,reject)=>{const image=new Image;image.src=src,image.onload=()=>{resolve({width:image.width,height:image.height,image})},image.onerror=error=>{reject(error)}}),"getImageSize");var ImageSourceType=(ImageSourceType2=>(ImageSourceType2.URL="URL",ImageSourceType2.UUID="UUID",ImageSourceType2.BASE64="BASE64",ImageSourceType2))(ImageSourceType||{}),ImageUploadStatusType=(ImageUploadStatusType2=>(ImageUploadStatusType2.SUCCUSS="0",ImageUploadStatusType2.ERROR_EXCEED_SIZE="1",ImageUploadStatusType2.ERROR_IMAGE_TYPE="2",ImageUploadStatusType2.ERROR_UPLOAD_COUNT_LIMIT="3",ImageUploadStatusType2.ERROR_IMAGE="4",ImageUploadStatusType2))(ImageUploadStatusType||{});const IImageIoService=core.createIdentifier("core.image-io.service"),_ImageIoService=class _ImageIoService{constructor(){__publicField(this,"_waitCount",0);__publicField(this,"_change$",new rxjs.Subject);__publicField(this,"change$",this._change$);__publicField(this,"_imageSourceCache",new Map)}setWaitCount(count){this._waitCount=count,this._change$.next(count)}getImageSourceCache(source,imageSourceType){if(imageSourceType===ImageSourceType.BASE64){const image=new Image;return image.src=source,image}return this._imageSourceCache.get(source)}addImageSourceCache(source,imageSourceType,imageSource){imageSourceType===ImageSourceType.BASE64||imageSource==null||this._imageSourceCache.set(source,imageSource)}async getImage(imageId){return Promise.resolve(imageId)}async saveImage(imageFile){return new Promise((resolve,reject)=>{if(!DRAWING_IMAGE_ALLOW_IMAGE_LIST.includes(imageFile.type)){reject(new Error(ImageUploadStatusType.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(imageFile.size>5242880){reject(new Error(ImageUploadStatusType.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const reader=new FileReader;reader.readAsDataURL(imageFile),reader.onload=evt=>{var _a2;const replaceSrc=(_a2=evt.target)==null?void 0:_a2.result;if(replaceSrc==null){reject(new Error(ImageUploadStatusType.ERROR_IMAGE)),this._decreaseWaiting();return}const imageId=core.Tools.generateRandomId(6);resolve({imageId,imageSourceType:ImageSourceType.BASE64,source:replaceSrc,base64Cache:replaceSrc,status:ImageUploadStatusType.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}};__name(_ImageIoService,"ImageIoService");let ImageIoService=_ImageIoService;const DEFAULT_DOCUMENT_SUB_COMPONENT_ID="__default_document_sub_component_id20231101__";var ArrangeTypeEnum=(ArrangeTypeEnum2=>(ArrangeTypeEnum2[ArrangeTypeEnum2.forward=0]="forward",ArrangeTypeEnum2[ArrangeTypeEnum2.backward=1]="backward",ArrangeTypeEnum2[ArrangeTypeEnum2.front=2]="front",ArrangeTypeEnum2[ArrangeTypeEnum2.back=3]="back",ArrangeTypeEnum2))(ArrangeTypeEnum||{}),DrawingTypeEnum=(DrawingTypeEnum2=>(DrawingTypeEnum2[DrawingTypeEnum2.UNRECOGNIZED=-1]="UNRECOGNIZED",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_IMAGE=0]="DRAWING_IMAGE",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_SHAPE=1]="DRAWING_SHAPE",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_CHART=2]="DRAWING_CHART",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_TABLE=3]="DRAWING_TABLE",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_VIDEO=5]="DRAWING_VIDEO",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_GROUP=6]="DRAWING_GROUP",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_UNIT=7]="DRAWING_UNIT",DrawingTypeEnum2[DrawingTypeEnum2.DRAWING_DOM=8]="DRAWING_DOM",DrawingTypeEnum2))(DrawingTypeEnum||{});const IDrawingManagerService=core.createIdentifier("univer.drawing-manager.service"),PLUGIN_CONFIG_KEY="drawing.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const PLUGIN_NAME="UNIVER_DRAWING_PLUGIN";exports2.UniverDrawingPlugin=(_a=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){this._initDependencies()}_initDependencies(){var _a2;const dependencies=[[IImageIoService,{useClass:ImageIoService}],[IDrawingManagerService,{useClass:DrawingManagerService}]];core.mergeOverrideWithDependencies(dependencies,(_a2=this._config)==null?void 0:_a2.override).forEach(d=>this._injector.add(d))}},__name(_a,"UniverDrawingPlugin"),__publicField(_a,"pluginName",PLUGIN_NAME),_a),exports2.UniverDrawingPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverDrawingPlugin),exports2.ArrangeTypeEnum=ArrangeTypeEnum,exports2.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=DEFAULT_DOCUMENT_SUB_COMPONENT_ID,exports2.DRAWING_IMAGE_ALLOW_IMAGE_LIST=DRAWING_IMAGE_ALLOW_IMAGE_LIST,exports2.DRAWING_IMAGE_ALLOW_SIZE=5242880,exports2.DRAWING_IMAGE_COUNT_LIMIT=10,exports2.DRAWING_IMAGE_HEIGHT_LIMIT=500,exports2.DRAWING_IMAGE_WIDTH_LIMIT=500,exports2.DrawingManagerService=DrawingManagerService,exports2.DrawingTypeEnum=DrawingTypeEnum,exports2.IDrawingManagerService=IDrawingManagerService,exports2.IImageIoService=IImageIoService,exports2.ImageIoService=ImageIoService,exports2.ImageSourceType=ImageSourceType,exports2.ImageUploadStatusType=ImageUploadStatusType,exports2.UnitDrawingService=UnitDrawingService,exports2.getDrawingShapeKeyByDrawingSearch=getDrawingShapeKeyByDrawingSearch,exports2.getImageSize=getImageSize,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(Y,de){typeof exports=="object"&&typeof module<"u"?de(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],de):(Y=typeof globalThis<"u"?globalThis:Y||self,de(Y.UniverDrawing={},Y.UniverCore,Y.rxjs))})(this,function(Y,de,ge){"use strict";var Zt=Object.defineProperty;var Yt=(Y,de,ge)=>de in Y?Zt(Y,de,{enumerable:!0,configurable:!0,writable:!0,value:ge}):Y[de]=ge;var x=(Y,de,ge)=>Yt(Y,typeof de!="symbol"?de+"":de,ge);var ht;const vt=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V={},Ot={},it={};Object.defineProperty(it,"__esModule",{value:!0});function Rt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!rt(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(!rt(n[t],e[t]))return!1;return!0}function rt(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=rt;var st={};Object.defineProperty(st,"__esModule",{value:!0});function ot(n){if(n===null)return null;if(Array.isArray(n))return n.map(ot);if(typeof n=="object"){const e={};for(let t in n)e[t]=ot(n[t]);return e}else return n}st.default=ot;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),i=(v,o)=>typeof v==typeof o?v>o:typeof v=="string"&&typeof o=="number";function s(v,o){for(let c in v){const h=c;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 c=this.container,h=this.parents.length-1,T=this.idx;for(;T>=0;)o.unshift(c[T]),T===0?(T=this.indexes[h*2],c=this.parents[h--]):T-=t(c[T-1])?2:1;return o}}class a 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,T){this.container=o,this.idx=c,this.parents=h.slice(),this.indexes=T.slice()}clone(){const o=new a;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 T of this)o&&o.descend(T),this.traverse(o,c),o&&o.ascend()}eachPick(o,c){this.traverse(o,(h,T)=>{h.p!=null&&c(h.p,T)})}eachDrop(o,c){this.traverse(o,(h,T)=>{h.d!=null&&c(h.d,T)})}}n.ReadCursor=a;class l 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 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(i(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&i(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 T=[c];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 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=s){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 ve=0;ve<o.length;ve++){const Q=o[ve];typeof Q=="string"||typeof Q=="number"?(J++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,c):typeof Q=="object"&&c(Q,this)}for(;J--;)this.ascend();this.lcIdx=this.parents.length===T?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=l,n.writeCursor=()=>new l,n.readCursor=v=>new a(v);function E(v,o,c){let h,T;T=h=v?v.descendFirst():!1;function J(ve){let Q;for(;T;){const Ee=Q=v.getKey();if(ve!=null){let Fe=!1;if(o&&typeof Ee=="number"&&(Q=o(Ee,v.getComponent()),Q<0&&(Q=~Q,Fe=!0)),i(Q,ve))return null;if(Q===ve&&!Fe)return v}c&&typeof Q=="number"&&c(Q,v.getComponent()),T=v.nextSibling()}return null}return J.end=()=>{h&&v.ascend()},J}n.advancer=E;function G(v,o,c){let h,T,J,ve;for(h=T=v&&v.descendFirst(),J=ve=o&&o.descendFirst();h||J;){let Q=h?v.getKey():null,Ee=J?o.getKey():null;Q!==null&&Ee!==null&&(i(Ee,Q)?Ee=null:Q!==Ee&&(Q=null)),c(Q==null?Ee:Q,Q!=null?v:null,Ee!=null?o:null),Q!=null&&h&&(h=v.nextSibling()),Ee!=null&&J&&(J=o.nextSibling())}T&&v.ascend(),ve&&o.ascend()}n.eachChildOf=G})(at);var lt={};(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={}))})(lt);var ct={},Ke={},yt;function ut(){return yt||(yt=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.uniToStrPos=Ke.strPosToUni=void 0,Ke.strPosToUni=(n,e=n.length)=>{let t=0,i=0;for(;i<e;i++){const s=n.charCodeAt(i);s>=55296&&s<=57343&&(t++,i++)}if(i!==e)throw Error("Invalid offset - splits unicode bytes");return i-t},Ke.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const i=n.charCodeAt(t);t+=i>=55296&&i<=57343?2:1}return t}),Ke}var dt={},bt;function ft(){return bt||(bt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=ut(),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 i(f,_){let m=0,H=0;for(let z=0;z<f.length;z++){const K=f[z];switch(_(K,m,H),typeof K){case"object":m+=n.dlen(K.d);break;case"string":H+=e.strPosToUni(K);break;case"number":m+=K,H+=K;break}}}n.eachOp=i;function s(f,_){const m=[],H=l(m);return i(f,(z,K,Pe)=>{H(_(z,K,Pe))}),o(m)}const d=f=>f,a=f=>s(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const l=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:(K,Pe)=>{if(_===f.length)return K===-1?null:K;const fe=f[_];let ie;if(typeof fe=="number")return K===-1||fe-m<=K?(ie=fe-m,++_,m=0,ie):(m+=K,K);if(typeof fe=="string"){if(K===-1||Pe==="i"||e.strPosToUni(fe.slice(m))<=K)return ie=fe.slice(m),++_,m=0,ie;{const ce=m+e.uniToStrPos(fe.slice(m),K);return ie=fe.slice(m,ce),m=ce,ie}}else{if(K===-1||Pe==="d"||n.dlen(fe.d)-m<=K)return ie={d:G(fe.d,m)},++_,m=0,ie;{let ce=G(fe.d,m,m+K);return m+=K,{d:ce}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,_,m){if(m!=="left"&&m!=="right")throw Error("side ("+m+") must be 'left' or 'right'");t(f),t(_);const H=[],z=l(H),{take:K,peek:Pe}=v(f);for(let ie=0;ie<_.length;ie++){const ce=_[ie];let Oe,Me;switch(typeof ce){case"number":for(Oe=ce;Oe>0;)Me=K(Oe,"i"),z(Me),typeof Me!="string"&&(Oe-=E(Me));break;case"string":m==="left"&&typeof Pe()=="string"&&z(K(-1)),z(e.strPosToUni(ce));break;case"object":for(Oe=n.dlen(ce.d);Oe>0;)switch(Me=K(Oe,"i"),typeof Me){case"number":Oe-=Me;break;case"string":z(Me);break;case"object":Oe-=n.dlen(Me.d)}break}}let fe;for(;fe=K(-1);)z(fe);return o(H)}function h(f,_){t(f),t(_);const m=[],H=l(m),{take:z}=v(f);for(let Pe=0;Pe<_.length;Pe++){const fe=_[Pe];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 Oe=0;for(;Oe<ie;)switch(ce=z(ie-Oe,"d"),typeof ce){case"number":H({d:G(fe.d,Oe,Oe+ce)}),Oe+=ce;break;case"string":Oe+=e.strPosToUni(ce);break;case"object":H(ce)}break}}let K;for(;K=z(-1);)H(K);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 K=e.strPosToUni(z);m+=K,f+=K;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 ve(f,_,m){return s(f,(H,z)=>typeof H=="object"&&typeof H.d=="number"?{d:m.slice(_,z,z+H.d)}:H)}function Q(f){return s(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 Ee(f){return s(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function Fe(f){let _=!0;return i(f,m=>{typeof m=="object"&&typeof m.d=="number"&&(_=!1)}),_}function Ie(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:a,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 K=m[z];switch(typeof K){case"number":H.skip(K);break;case"string":H.append(K);break;case"object":H.del(n.dlen(K.d));break}}return H.build()},transform:c,compose:h,transformPosition:T,transformSelection:J,isInvertible:Fe,makeInvertible(_,m){return ve(_,m,f)},stripInvertible:Ee,invert:Q,invertWithDoc(_,m){return Q(ve(_,m,f))},isNoop:_=>_.length===0}}n.default=Ie}(dt)),dt}var tt={},It;function jt(){if(It)return tt;It=1,Object.defineProperty(tt,"__esModule",{value:!0});const n=ft(),e=ut();function t(i,s){return{get:i,getLength(){return i().length},insert(d,a,l){const E=e.strPosToUni(i(),d);return s([E,a],l)},remove(d,a,l){const E=e.strPosToUni(i(),d);return s([E,{d:a}],l)},_onOp(d){n.eachOp(d,(a,l,E)=>{switch(typeof a){case"string":this.onInsert&&this.onInsert(E,a);break;case"object":const G=n.dlen(a.d);this.onRemove&&this.onRemove(E,G)}})},onInsert:null,onRemove:null}}return tt.default=t,t.provides={text:!0},tt}var mt;function $t(){return mt||(mt=1,function(n){var e=Ae&&Ae.__createBinding||(Object.create?function(c,h,T,J){J===void 0&&(J=T),Object.defineProperty(c,J,{enumerable:!0,get:function(){return h[T]}})}:function(c,h,T,J){J===void 0&&(J=T),c[J]=h[T]}),t=Ae&&Ae.__setModuleDefault||(Object.create?function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}:function(c,h){c.default=h}),i=Ae&&Ae.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var T in c)Object.hasOwnProperty.call(c,T)&&e(h,c,T);return t(h,c),h},s=Ae&&Ae.__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=ut(),a=i(ft()),l=s(jt()),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(T){let J=d.uniToStrPos(c,T);if(J>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,J)),c=c.slice(J)},append(T){h.push(T)},del(T){c=c.slice(d.uniToStrPos(c,T))},build(){return h.join("")+c}}},slice:a.uniSlice},G=a.default(E),v=Object.assign(Object.assign({},G),{api:l.default});n.type=v,n.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],n.remove=(c,h)=>a.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var o=ft();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ct)),ct}(function(n){var e=Ae&&Ae.__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),i=e(st),s=at,d=lt;function a(r,u){if(!r)throw new Error(u)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:Q,checkValidOp:z,normalize:K,apply:Pe,transformPosition:fe,compose:ie,tryTransform:pt,transform:zt,makeInvertible:Me,invert:ce,invertWithDoc:qt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,u,y)=>Nt(()=>!0,r,u,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(u,y,A)=>Nt(r,u,y,A)})};const l=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 c(r,u){return a(r!=null),typeof u=="number"?(a(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(u,1)):(a(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"?(a(r!=null,"Container is missing for key"),a(Array.isArray(r),"Cannot use numerical key for object container"),a(r.length>=u,"Cannot insert into out of bounds index"),r.splice(u,0,y)):(a(E(r),"Cannot insert into missing item"),a(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)=>s.writeCursor().writeAtPath(r,"r",u).get(),n.moveOp=(r,u)=>s.writeCursor().writeMove(r,u).get(),n.insertOp=(r,u)=>s.writeCursor().writeAtPath(r,"i",u).get(),n.replaceOp=(r,u,y)=>s.writeCursor().at(r,A=>{A.write("r",u),A.write("i",y)}).get(),n.editOp=(r,u,y,A=!1)=>s.writeCursor().at(r,b=>_(b,u,y,A)).get();const T=(r,u)=>r!=null&&(typeof u=="number"?Array.isArray(r):typeof r=="object"),J=(r,u)=>T(r,u)?r[u]:void 0,ve={};function Q(r){let u=r.type?r.type:r;u.name&&(ve[u.name]=u),u.uri&&(ve[u.uri]=u)}const Ee=r=>{const u=ve[r];if(u)return u;throw Error("Missing type: "+r)};Q($t());const Fe=(r,u)=>r+u;Q({name:"number",apply:Fe,compose:Fe,invert:r=>-r,transform:r=>r});const Ie=r=>r==null?null:r.et?Ee(r.et):r.es?ve["text-unicode"]:r.ena!=null?ve.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"?[Ee(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 m(r){a(typeof r=="number"),a(r>=0),a(r===(0|r))}function H(r){typeof r=="number"?m(r):a(typeof r=="string")}function z(r){if(r===null)return;const u=new Set,y=new Set,A=C=>{let $=!0,k=!1;for(let g in C){const O=C[g];if($=!1,a(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")m(O),a(!u.has(O)),u.add(O),a(C.r===void 0);else if(g==="d")m(O),a(!y.has(O)),y.add(O),a(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){a(!k),k=!0;const I=Ie(C);a(I,"Missing type in edit"),I.checkValidOp&&I.checkValidOp(f(C))}}a(!$)},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(a(j!=null),Array.isArray(j)){const W=b(j,!1);if(O){const p=typeof I,U=typeof W;p===U?a(I<W,"descent keys are not in order"):a(p==="number"&&U==="string")}I=W,O++,g=3}else typeof j=="object"?(a(g===1,`Prev not scalar - instead ${g}`),A(j),g=2):(a(g!==3),H(j),a(s.isValidPathItem(j),"Invalid path key"),g=1)}return a(O!==1,"Operation makes multiple descents. Remove some []"),a(g===2||g===3),C[0]};b(r,!0),a(u.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<u.size;C++)a(u.has(C)),a(y.has(C))}function K(r){let u=0,y=[];const A=s.writeCursor();return A.mergeTree(r,(b,C)=>{const $=Ie(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]=u++),y[k]):b[g];C.write(g,O)}var k}),A.get()}function Pe(r,u){if(z(u),u===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"&&(a(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=Ie(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?c(j,w):(O=w,I=b,(g=G(g=j))[O]=I,g)}else v(w)&&(a(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,u),u)}function fe(r,u){r=r.slice(),z(u);const y=s.readCursor(u);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=s.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=l(y),w=Ie(I);if(w){const p=f(I);w.transformPosition&&(r[g]=w.transformPosition(r[g],p));break}let j=0;const W=s.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,u){if(z(r),z(u),r==null)return u;if(u==null)return r;let y=0;const A=s.readCursor(r),b=s.readCursor(u),C=s.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=s.writeCursor();return function p(U,re,ne,F,oe,Ge,we,ye){a(re||ne);const ae=l(re),Se=l(ne),Ne=!!Se&&Se.r!==void 0,Ve=!!ae&&ae.i!==void 0,Ue=ae?ae.d:null,De=Se?Se.p:null,We=(Ge||Ne)&&De==null;if(De!=null)F=O[De],we=k[De]=new s.WriteCursor;else if(Se&&Se.r!==void 0)F=null;else{const P=l(F);P&&P.d!=null&&(F=null)}const ee=l(F);if(Ue!=null)if(U=g[Ue],ye=$[Ue]=new s.WriteCursor,We)Ge&&!Ne&&ye.write("r",!0);else{const P=I[Ue]=y++;we.write("d",P)}else if(ae&&ae.i!==void 0)U=null;else{const P=l(U);P&&P.p!=null&&(U=null)}let M;Ve?(a(oe===void 0),M=ae.i):M=oe;const L=(De==null?!Ve||Ge||Ne:M===void 0)?null:we.getComponent();if(De!=null){if(!(oe!==void 0||Ve)){const P=Ue!=null?I[Ue]:y++;w[De]=P,ye.write("p",P)}}else Ne&&(Ve||oe!==void 0||(Se.r,ye.write("r",Se.r)));const S=We?null:Ie(ae),D=Ie(ee);if((S||D)&&(S&&S.name,D&&D.name),S&&D){a(S===D);const P=f(ae),B=f(ee),_e=S.compose(P,B);_(we,S,_e),j.add(ee)}else S?_(we,S,f(ae)):D&&(_(we,D,f(ee)),j.add(ee));const N=typeof M=="object"&&M!=null;let X=!1,Z=0,te=0,pe=0,he=0,le=0;const me=s.advancer(F,(P,B)=>o(B)?he-P-1:P-he,(P,B)=>{o(B)&&he++}),q=s.advancer(U,(P,B)=>v(B)?Z-P-1:P-Z,(P,B)=>{v(B)&&Z++});if(s.eachChildOf(re,ne,(P,B,_e)=>{let Ce,Le,xe=P,Te=P,et=P;if(typeof P=="number"){let be=P+pe;Le=me(be),Te=be+he;let ue=P+te;Ce=q(ue),o(l(Le))&&(Ce=null),xe=ue+Z,et=P+le,a(xe>=0,"p1PickKey is negative"),a(Te>=0,"p2DropKey is negative");const Re=o(l(B)),Be=v(l(_e));(Re||Be&&!We)&&le--,Re&&te--,Be&&pe--}else Ce=q(P),Le=me(P);ye.descend(xe),we.descend(Te);const Ye=N&&!o(l(B))?M[et]:void 0,je=p(Ce,B,_e,Le,Ye,We,we,ye);var $e,R,se;N&&!We?Ye!==je&&(X||(M=Array.isArray(M)?M.slice():Object.assign({},M),X=!0),$e=M,se=je,typeof(R=et)=="number"?(a(Array.isArray($e)),a(R<$e.length)):(a(!Array.isArray($e)),a($e[R]!==void 0)),se===void 0?typeof R=="number"?$e.splice(R,1):delete $e[R]:$e[R]=se):a(je===void 0),we.ascend(),ye.ascend()}),q.end(),me.end(),L!=null)L.i=M;else if(!Ge&&!Ne&&De==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 re=p.p;if(re!=null){const ne=I[re];ne!=null&&U.write("p",ne);const F=$[re];F&&F.get(),F&&U.mergeTree(F.get())}else p.r!==void 0&&U.write("r",p.r)}),C.reset(),C.get(),b.traverse(C,(p,U)=>{const re=p.d;if(re!=null){const F=w[re];F!=null&&U.write("d",F);const oe=k[re];oe&&U.mergeTree(oe.get())}else p.i!==void 0&&U.write("i",p.i);const ne=Ie(p);ne&&!j.has(p)&&_(U,ne,f(p))}),C.get()}function ce(r){if(r==null)return null;const u=new s.ReadCursor(r),y=new s.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=Ie(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,re=J(O,U);o(k.getComponent())&&W++;const ne=$(k,g,re);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)}(u,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]=s.writeCursor()),A.has(I)){const U=Ie(I);if(!U.invert)throw Error(`Cannot invert subtype ${U.name}`);_(O,U,U.invert(f(I)))}}let w=0,j=0;const W=s.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,re=W(U),ne=U+w;O.descend(ne),$(re,g,O),o(g.getComponent())&&j++,O.ascend()}else O.descend(p),$(W(p),g,O),O.ascend();W.end()}(u.clone(),u,y),C.length&&(y.reset(),u.traverse(y,($,k)=>{const g=$.p;if(g!=null){const O=C[g];O&&O.get(),O&&k.mergeTree(O.get())}}))),y.get()}const Oe=(r,u)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?Oe(y,u):u(y)));function Me(r,u){if(r==null||!Oe(r,g=>{var O;return g.r!==void 0||((O=Ie(g))===null||O===void 0?void 0:O.makeInvertible)!=null}))return r;const y=new s.ReadCursor(r),A=new s.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(),a(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=Ie(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,re=J(I,U),ne=k(g,O,re);re!==ne&&(j||(j=!0,I=G(I)),ne===void 0?(I=c(I,U),typeof p=="number"&&W++):I[U]=ne),O.ascend()}return w&&(w.r!==void 0?(O.write("r",i.default(I)),I=void 0):w.p!=null&&(I=void 0)),I};return k(y,A,u),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 F=Ie(p);if(F&&F.makeInvertible){const oe=f(p);_(w,F,F.makeInvertible(oe,j),!0)}}let U=0,re=0;const ne=s.advancer(O,(F,oe)=>v(oe)?U-F-1:F-U,(F,oe)=>{v(oe)&&U++});for(const F of I)if(typeof F=="number"){const oe=F-re,Ge=ne(oe),we=oe+U,ye=J(j,W?oe:we);w.descend(F),g(Ge,I,w,ye,W),o(I.getComponent())&&re++,w.ascend()}else{const oe=J(j,F);w.descend(F),g(ne(F),I,w,oe,W),w.ascend()}ne.end()}(y.clone(),y,A,u,!1)),A.get()}function qt(r,u){return ce(Me(r,u))}const gt=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]=gt(A))}return u};function pt(r,u,y){a(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=[],$=[],k=[],g=[],O=[],I=[],w=[],j=[],W=[],p=[],U=[],re=[],ne=[],F=[],oe=[];let Ge=0;const we=s.readCursor(r),ye=s.readCursor(u),ae=s.writeCursor();if(function ee(M,L=null,S){const D=l(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&&(F[X]=D.p));const Z=s.advancer(L);for(const te of M)ee(M,Z(te),S);Z.end()}(ye,we,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&&(oe[D]==null&&(oe[D]=[]),oe[D].push(Z)),M=O[Z]||null,L=k[Z]||null,p[Z]?(N&&(U[Z]=!0),N=W[Z]||null):!N||A!==1&&F[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 pe=l(M);pe&&(pe.r!==void 0?N=M.clone():pe.p!=null&&(pe.p,D=pe.p,N=null));const he=Ie(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 le=0,me=0;const q=s.advancer(L,(B,_e)=>v(_e)?le-B-1:B-le,(B,_e)=>{v(_e)&&le++}),P=s.advancer(M);for(const B of S)if(typeof B=="number"){const _e=B-me,Ce=q(_e);me+=+ee(P(_e+le),Ce,S,D,N)}else{const _e=q(B);ee(P(B),_e,S,D,N)}return q.end(),P.end(),te}(we,ye,ye.clone(),null,null),g.map(ee=>ee&&ee.get()),b)return{ok:!1,conflict:b};U.map(ee=>!!ee);const Se=[];let Ne=null;(function ee(M,L,S,D,N){let X=!1;const Z=l(L);if(v(Z)){const q=Z.p;q!=null?(S=g[q],D=re[q]=s.writeCursor(),X=!0,N=null):(S=null,N=L.clone())}else o(l(S))&&(S=null);const te=M.getComponent();if(te){const q=te.p;q!=null?(N&&(j[q]=N),Se[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)&&(Ne==null&&(Ne=new Set),Ne.add(te)))}let pe=0,he=0;const le=s.advancer(L,void 0,(q,P)=>{v(P)&&pe++}),me=s.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=le(q),B=me(q);D.descend(q),ee(M,P,B,D,N),D.ascend()}else{const P=le(q),B=q-pe,_e=v(l(P))?null:me(B),Ce=B+he;a(Ce>=0),D.descend(Ce),ee(M,P,_e,D,N),D.ascend()}le.end(),me.end()})(we,ye,ye.clone(),ae,null),ae.reset();let Ve=[];if(function ee(M,L,S,D,N,X){a(L);const Z=L.getComponent();let te=l(D),pe=!1;const he=(R,se,be)=>R?n.moveOp(R.getPath(),se.getPath()):n.insertOp(se.getPath(),be.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=L.clone());const se=R!=null?Se[R]:null;let be=!1;if(Z.i!==void 0||R!=null&&se){let ue;te&&(te.i!==void 0||(ue=te.d)!=null&&!p[ue])&&(be=ue!=null?R!=null&&R===F[ue]:t.default(te.i,Z.i),be||ue!=null&&A!==1&&F[ue]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:he(R!=null?C[R]:null,L,Z),op2:he(ue!=null?k[ue]:null,D,te)})),be||(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?(Ve[Ge]=R,N.write("d",se.p=Ge++)):N.write("i",i.default(Z.i)),pe=!0))}else if(R!=null&&!se){const ue=j[R];ue&&(X=ue.clone())}R!=null?(M=C[R],S=I[R],D=w[R]):Z.i!==void 0&&(M=S=null,be||(D=null))}else v(l(M))&&(M=S=D=null);const le=l(M),me=l(S);if(v(me)){const R=me.p;me.r!==void 0&&(!le||le.r===void 0)||p[R]?(D=null,X=S.clone()):R!=null&&(D=g[R],A!==1&&F[R]!=null||((N=ne[R])||(N=ne[R]=s.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(te)&&(D=null);te=D!=null?D.getComponent():null;const q=Ie(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 se=Ie(te);let be;if(se){if(q!==se)throw Error("Transforming incompatible types");const ue=f(te);be=q.transform(R,ue,y)}else be=i.default(R);_(N,q,be)}}let P=0,B=0,_e=0,Ce=0,Le=0,xe=0,Te=M!=null&&M.descendFirst(),et=Te;const Ye=s.advancer(S,void 0,(R,se)=>{v(se)&&_e++});let je=D!=null&&D.descendFirst(),$e=je;for(const R of L)if(typeof R=="number"){let se;const be=o(L.getComponent()),ue=R-B;{let He;for(;Te&&typeof(He=M.getKey())=="number";){He+=P;const ke=M.getComponent(),Je=v(ke);if(He>ue||He===ue&&(!Je||A===0&&be))break;if(Je){P--;const qe=ke.p;F.includes(qe),ke.d,l(ne[ke.d]),v(l(ne[ke.d])),(ke.r===void 0||Ne&&Ne.has(ke))&&(qe==null||!Se[qe]||A!==1&&F.includes(qe))||Le--}Te=M.nextSibling()}se=Te&&He===ue?M:null}const Re=ue-P;let Be=Ye(Re);const _t=Re-_e;let nt=null;{let He,ke;for(;je&&typeof(He=D.getKey())=="number";){ke=He-Ce;const Je=D.getComponent(),qe=o(Je);if(ke>_t)break;if(ke===_t){if(!qe){nt=D;break}{if(A===0&&be){nt=D;break}const ze=Be&&v(Be.getComponent());if(A===0&&ze)break}}if(qe){const ze=Je.d;F[ze],Je.i===void 0&&(p[ze]||F[ze]!=null&&A!==1)?(p[ze]||F[ze]!=null&&A===0)&&(Ce++,xe--):Ce++}je=D.nextSibling()}}const Tt=_t+Ce+Le+xe;a(Tt>=0,"trying to descend to a negative index"),N.descend(Tt),be&&(se=Be=nt=null,B++),ee(se,L,Be,nt,N,X)&&xe++,N.ascend()}else{let se;for(;Te&&(se=M.getKey(),typeof se!="string"||!(se>R||se===R));)Te=M.nextSibling();const be=Te&&se===R?M:null,ue=Ye(R);let Re;for(;je&&(Re=D.getKey(),typeof Re!="string"||!(Re>R||Re===R));)je=D.nextSibling();const Be=je&&Re===R?D:null;N.descend(R),ee(be,L,ue,Be,N,X),N.ascend()}return Ye.end(),et&&M.ascend(),$e&&D.ascend(),pe}(we,we.clone(),ye,ye.clone(),ae,null),b)return{ok:!1,conflict:b};ae.reset();const Ue=(ee,M,L)=>ee.traverse(M,(S,D)=>{S.d!=null&&L(S.d,ee,D)});(p.length||re.length)&&(Ue(ye,ae,(ee,M,L)=>{p[ee]&&!U[ee]&&L.write("r",!0),re[ee]&&L.mergeTree(re[ee].get())}),ae.reset());const De=[],We=[];if((ne.length||p.length)&&!b){const ee=s.readCursor(gt(ae.get()));if(Ue(ee,null,(M,L)=>{De[M]=L.clone()}),ne.forEach(M=>{M&&Ue(s.readCursor(M.get()),null,(L,S)=>{De[L]=S.clone()})}),function M(L,S,D,N,X,Z){const te=l(S);if(te&&v(te))if(te.p!=null){const P=te.p;De[P].getPath(),D=De[P],N=We[P]=s.writeCursor()}else te.r!==void 0&&(D=null);else o(l(D))&&(D=null);const pe=L.getComponent();if(pe){let P;if((P=pe.d)!=null){const B=ne[P];B&&(B.get(),N.mergeTree(B.get()),D=s.readCursor(B.get()))}}let he=0,le=0;const me=s.advancer(S,void 0,(P,B)=>{v(B)&&he--}),q=s.advancer(D,(P,B)=>o(B)?-(P-le)-1:P-le,(P,B)=>{o(B)&&le++});for(const P of L)if(typeof P=="number"){const B=me(P),_e=P+he,Ce=q(_e),Le=_e+le;N.descend(Le),M(L,B,Ce,N),N.ascend()}else N.descend(P),M(L,me(P),q(P),N),N.ascend();me.end(),q.end()}(ye,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=s.readCursor(gt(ae.get()));if(Ue(L,ae,(S,D,N)=>{const X=M[S];X&&(N.mergeTree(X),M[S]=null)}),M.find(S=>S)){const S=s.writeCursor(),D=s.writeCursor();let N=0,X=0;M.forEach(Z=>{Z!=null&&Ue(s.readCursor(Z),null,te=>{const pe=Ve[te];S.writeMove(C[pe].getPath(),$[pe].getPath(),N++);const he=oe[pe];he&&he.forEach(le=>{p[le]||A!==1&&F[le]!=null||D.writeMove(k[le].getPath(),g[le].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 u=new Error("Transform detected write conflict");throw u.conflict=r,u.type=u.name="writeConflict",u};function zt(r,u,y){const A=pt(r,u,y);if(A.ok)return A.result;Ut(A.conflict)}const Ze=r=>{const u=s.writeCursor();return s.readCursor(r).traverse(u,(y,A)=>{(o(y)||Ie(y))&&A.write("r",!0)}),u.get()},Xt=(r,u)=>{const{type:y,op1:A,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return u==="left"?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return s.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,u,y,A){let b=null;for(;;){const C=pt(u,y,A);if(C.ok)return ie(b,C.result);{const{conflict:$}=C;r($)||Ut($);const[k,g]=Xt($,A);u=ie(K(u),k),y=ie(K(y),g),b=ie(b,g)}}}})(Ot),function(n){var e=Ae&&Ae.__createBinding||(Object.create?function(d,a,l,E){E===void 0&&(E=l),Object.defineProperty(d,E,{enumerable:!0,get:function(){return a[l]}})}:function(d,a,l,E){E===void 0&&(E=l),d[E]=a[l]}),t=Ae&&Ae.__exportStar||function(d,a){for(var l in d)l!=="default"&&!a.hasOwnProperty(l)&&e(a,d,l)};Object.defineProperty(n,"__esModule",{value:!0}),t(Ot,n);var i=at;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return i.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return i.WriteCursor}});var s=lt;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(V);class wt{constructor(){x(this,"drawingManagerData",{});x(this,"_oldDrawingManagerData",{});x(this,"_focusDrawings",[]);x(this,"_remove$",new ge.Subject);x(this,"remove$",this._remove$.asObservable());x(this,"_add$",new ge.Subject);x(this,"add$",this._add$.asObservable());x(this,"_update$",new ge.Subject);x(this,"update$",this._update$.asObservable());x(this,"_order$",new ge.Subject);x(this,"order$",this._order$.asObservable());x(this,"_group$",new ge.Subject);x(this,"group$",this._group$.asObservable());x(this,"_ungroup$",new ge.Subject);x(this,"ungroup$",this._ungroup$.asObservable());x(this,"_refreshTransform$",new ge.Subject);x(this,"refreshTransform$",this._refreshTransform$.asObservable());x(this,"_visible$",new ge.Subject);x(this,"visible$",this._visible$.asObservable());x(this,"_focus$",new ge.Subject);x(this,"focus$",this._focus$.asObservable());x(this,"_featurePluginUpdate$",new ge.Subject);x(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());x(this,"_featurePluginAdd$",new ge.Subject);x(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());x(this,"_featurePluginRemove$",new ge.Subject);x(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());x(this,"_featurePluginOrderUpdate$",new ge.Subject);x(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());x(this,"_featurePluginGroupUpdate$",new ge.Subject);x(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());x(this,"_featurePluginUngroupUpdate$",new ge.Subject);x(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());x(this,"_visible",!0);x(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=>{const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform,i.transforms=t.transforms,i.isMultiTransform=t.isMultiTransform)}),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 i=[];Object.keys(t).forEach(s=>{const d=t[s];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(a=>{i.push({unitId:e,subUnitId:s,drawingId:a})})}),i.length>0&&this.removeNotification(i)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){const t=[],i=this.drawingManagerData[e];i!=null&&(Object.keys(i).forEach(s=>{this._establishDrawingMap(e,s);const d=i[s];Object.keys(d.data).forEach(a=>{const l=d.data[a];l.unitId=e,l.subUnitId=s,t.push(l)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}setDrawingData(e,t,i){this.drawingManagerData[e][t].data=i}getBatchAddOp(e){const t=[],i=[],s=[];e.forEach(G=>{const{op:v,invertOp:o}=this._addByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),i.push(v),s.push(o)});const d=i.reduce(V.type.compose,null),a=s.reduce(V.type.compose,null),{unitId:l,subUnitId:E}=e[0];return{undo:a,redo:d,unitId:l,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],i=[];e.forEach(E=>{const{op:G,invertOp:v}=this._removeByParam(E);t.unshift(G),i.push(v)});const s=t.reduce(V.type.compose,null),d=i.reduce(V.type.compose,null),{unitId:a,subUnitId:l}=e[0];return{undo:d,redo:s,unitId:a,subUnitId:l,objects:e}}getBatchUpdateOp(e){const t=[],i=[],s=[];e.forEach(G=>{const{op:v,invertOp:o}=this._updateByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),i.push(v),s.push(o)});const d=i.reduce(V.type.compose,null),a=s.reduce(V.type.compose,null),{unitId:l,subUnitId:E}=e[0];return{undo:a,redo:d,unitId:l,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:i,subUnitId:s}=e[0].parent;e.forEach(l=>{t.push(this._getGroupDrawingOp(l))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:i,subUnitId:s,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:i,subUnitId:s}=e[0].parent;e.forEach(l=>{t.push(this._getUngroupDrawingOp(l))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:i,subUnitId:s,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:i,drawingId:s}=e;if(this.getDrawingByParam({unitId:t,subUnitId:i,drawingId:s})==null)return[];const a=this._getDrawingData(t,i),l=[];return Object.keys(a).forEach(E=>{const G=a[E];G.groupId===s&&l.push(G)}),l}_getGroupDrawingOp(e){const{parent:t,children:i}=e,{unitId:s,subUnitId:d,drawingId:a}=t,l=[];l.push(V.insertOp([s,d,"data",a],t));let E=Number.NEGATIVE_INFINITY;return i.forEach(G=>{const{unitId:v,subUnitId:o,drawingId:c}=G,h=this._hasDrawingOrder({unitId:v,subUnitId:o,drawingId:c});E=Math.max(E,h),l.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:v,subUnitId:o,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(s,d).length),l.push(V.insertOp([s,d,"order",E],a)),l.reduce(V.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:i}=e,{unitId:s,subUnitId:d,drawingId:a}=t,l=[];return i.forEach(E=>{const{unitId:G,subUnitId:v,drawingId:o}=E;l.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:G,subUnitId:v,drawingId:o})))}),l.push(V.removeOp([s,d,"data",a],!0)),l.push(V.removeOp([s,d,"order",this._getDrawingOrder(s,d).indexOf(a)],!0)),l.reduce(V.type.compose,null)}applyJson1(e,t,i){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=V.type.apply(this.drawingManagerData,i)}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,i,s]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:i,drawingId:s})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(i=>{var E;const{unitId:s,subUnitId:d,drawingId:a}=i,l=(E=this._getDrawingData(s,d))==null?void 0:E[a];l!=null&&t.push(l)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var l;const{unitId:i,subUnitId:s,drawingId:d}=t,a=(l=this._getDrawingData(i,s))==null?void 0:l[d];a!=null&&e.push(a)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}setDrawingOrder(e,t,i){this.drawingManagerData[e][t].order=i}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=[],a=this.getDrawingOrder(t,i),l=[...s];s.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:i,drawingId:v});if(o===-1||o===a.length-1)return;const c=V.moveOp([t,i,"order",o],[t,i,"order",o+1]);d.push(c),l.includes(a[o+1])||l.push(a[o+1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:i,objects:{...e,drawingIds:l}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=[],a=this.getDrawingOrder(t,i),l=[...s];s.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:i,drawingId:v});if(o===-1||o===0)return;const c=V.moveOp([t,i,"order",o],[t,i,"order",o-1]);d.push(c),l.includes(a[o-1])||l.push(a[o-1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:i,objects:{...e,drawingIds:l}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=this._getOrderFromSearchParams(t,i,s),a=[...s],l=this.getDrawingOrder(t,i),E=[];d.forEach(o=>{const{drawingId:c}=o,h=this._getDrawingCount(t,i)-1,T=V.moveOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(c)],[t,i,"order",h]);E.push(T),a.includes(l[h])||a.push(l[h])});const G=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:i,objects:{...e,drawingIds:a}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=this._getOrderFromSearchParams(t,i,s,!0),a=[...s],l=this.getDrawingOrder(t,i),E=[];d.forEach(o=>{const{drawingId:c}=o,h=V.moveOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(c)],[t,i,"order",0]);E.push(h),a.includes(l[0])||a.push(l[0])});const G=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:i,objects:{...e,drawingIds:a}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,i,s=!1){return i.map(d=>{const a=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:a}}).sort(s===!1?de.sortRules:de.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:i,drawingId:s}=e;return this._establishDrawingMap(t,i),this._getDrawingOrder(t,i).indexOf(s)}_getCurrentBySearch(e){var d,a,l;if(e==null)return;const{unitId:t,subUnitId:i,drawingId:s}=e;return(l=(a=(d=this.drawingManagerData[t])==null?void 0:d[i])==null?void 0:a.data)==null?void 0:l[s]}_getOldBySearch(e){var d,a,l;if(e==null)return;const{unitId:t,subUnitId:i,drawingId:s}=e;return(l=(a=(d=this._oldDrawingManagerData[t])==null?void 0:d[i])==null?void 0:a.data)==null?void 0:l[s]}_establishDrawingMap(e,t,i){var s;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),i==null?null:(s=this.drawingManagerData[e][t].data)==null?void 0:s[i]}_addByParam(e){const{unitId:t,subUnitId:i,drawingId:s}=e;this._establishDrawingMap(t,i,s);const d=V.insertOp([t,i,"data",s],e),a=V.insertOp([t,i,"order",this._getDrawingOrder(t,i).length],s),l=[d,a].reduce(V.type.compose,null),E=V.type.invertWithDoc(l,this.drawingManagerData);return{op:l,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:i,drawingId:s}=e;if(this._establishDrawingMap(t,i,s)==null)return{op:[],invertOp:[]};const a=V.removeOp([t,i,"data",s],!0),l=V.removeOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(s)],!0),E=[a,l].reduce(V.type.compose,null),G=V.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:G}}_updateByParam(e){const{unitId:t,subUnitId:i,drawingId:s}=e,d=this._establishDrawingMap(t,i,s);if(d==null)return{op:[],invertOp:[]};const l=this._getUpdateParamCompareOp(e,d).reduce(V.type.compose,null),E=V.type.invertWithDoc(l,this.drawingManagerData);return{op:l,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:i,subUnitId:s,drawingId:d}=e,a=[];return Object.keys(e).forEach(l=>{const E=e[l],G=t[l];G!==E&&a.push(V.replaceOp([i,s,"data",d,l],G,E))}),a}_getDrawingData(e,t){var i,s;return((s=(i=this.drawingManagerData[e])==null?void 0:i[t])==null?void 0:s.data)||{}}_getDrawingOrder(e,t){var i,s;return((s=(i=this.drawingManagerData[e])==null?void 0:i[t])==null?void 0:s.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Ct extends wt{}function Gt({unitId:n,subUnitId:e,drawingId:t},i){return typeof i=="number"?`${n}#-#${e}#-#${t}#-#${i}`:`${n}#-#${e}#-#${t}`}const Wt=async n=>new Promise((e,t)=>{const i=new Image;i.src=n,i.onload=()=>{e({width:i.width,height:i.height,image:i})},i.onerror=s=>{t(s)}});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 Et=de.createIdentifier("core.image-io.service");class At{constructor(){x(this,"_waitCount",0);x(this,"_change$",new ge.Subject);x(this,"change$",this._change$);x(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Qe.BASE64){const i=new Image;return i.src=e,i}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,i){t===Qe.BASE64||i==null||this._imageSourceCache.set(e,i)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,i)=>{if(!vt.includes(e.type)){i(new Error(Xe.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){i(new Error(Xe.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const s=new FileReader;s.readAsDataURL(e),s.onload=d=>{var E;const a=(E=d.target)==null?void 0:E.result;if(a==null){i(new Error(Xe.ERROR_IMAGE)),this._decreaseWaiting();return}const l=de.Tools.generateRandomId(6);t({imageId:l,imageSourceType:Qe.BASE64,source:a,base64Cache:a,status:Xe.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const Lt="__default_document_sub_component_id20231101__";var Dt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Dt||{}),Pt=(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))(Pt||{});const Mt=de.createIdentifier("univer.drawing-manager.service"),Bt="drawing.config",Ht={};var Kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Vt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ft(e,t):e,d=n.length-1,a;d>=0;d--)(a=n[d])&&(s=(i?a(e,t,s):a(s))||s);return i&&s&&Kt(e,t,s),s},St=(n,e)=>(t,i)=>e(t,i,n);const xt="UNIVER_DRAWING_PLUGIN";Y.UniverDrawingPlugin=(ht=class extends de.Plugin{constructor(e=Ht,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...s}=this._config;this._configService.setConfig(Bt,s)}onStarting(){this._initDependencies()}_initDependencies(){var i;const e=[[Et,{useClass:At}],[Mt,{useClass:Ct}]];de.mergeOverrideWithDependencies(e,(i=this._config)==null?void 0:i.override).forEach(s=>this._injector.add(s))}},x(ht,"pluginName",xt),ht),Y.UniverDrawingPlugin=Vt([St(1,de.Inject(de.Injector)),St(2,de.IConfigService)],Y.UniverDrawingPlugin),Y.ArrangeTypeEnum=Dt,Y.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Lt,Y.DRAWING_IMAGE_ALLOW_IMAGE_LIST=vt,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=Ct,Y.DrawingTypeEnum=Pt,Y.IDrawingManagerService=Mt,Y.IImageIoService=Et,Y.ImageIoService=At,Y.ImageSourceType=Qe,Y.ImageUploadStatusType=Xe,Y.UnitDrawingService=wt,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.
|
|
3
|
+
"version": "0.5.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./lib/*": "./lib/*"
|
|
33
33
|
},
|
|
34
|
-
"main": "./lib/
|
|
35
|
-
"module": "./lib/es/index.js",
|
|
34
|
+
"main": "./lib/es/index.js",
|
|
36
35
|
"types": "./lib/types/index.d.ts",
|
|
37
36
|
"publishConfig": {
|
|
38
37
|
"access": "public"
|
|
@@ -47,19 +46,18 @@
|
|
|
47
46
|
"rxjs": ">=7.0.0"
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"@univerjs/icons": "^0.
|
|
49
|
+
"@univerjs/icons": "^0.2.5",
|
|
51
50
|
"ot-json1": "^1.0.2",
|
|
52
|
-
"@univerjs/core": "0.
|
|
51
|
+
"@univerjs/core": "0.5.0-alpha.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
|
-
"less": "^4.2.0",
|
|
56
54
|
"rxjs": "^7.8.1",
|
|
57
55
|
"typescript": "^5.6.3",
|
|
58
|
-
"vite": "^5.4.
|
|
59
|
-
"vitest": "^2.1.
|
|
60
|
-
"@univerjs-infra/shared": "0.
|
|
56
|
+
"vite": "^5.4.10",
|
|
57
|
+
"vitest": "^2.1.4",
|
|
58
|
+
"@univerjs-infra/shared": "0.5.0-alpha.0"
|
|
61
59
|
},
|
|
62
|
-
"
|
|
60
|
+
"space": {
|
|
63
61
|
".": {
|
|
64
62
|
"import": "./lib/es/index.js",
|
|
65
63
|
"require": "./lib/cjs/index.js",
|
|
@@ -77,6 +75,7 @@
|
|
|
77
75
|
"test:watch": "vitest",
|
|
78
76
|
"coverage": "vitest run --coverage",
|
|
79
77
|
"lint:types": "tsc --noEmit",
|
|
80
|
-
"build": "
|
|
81
|
-
}
|
|
78
|
+
"build": "tsx build.ts"
|
|
79
|
+
},
|
|
80
|
+
"module": "./lib/es/index.js"
|
|
82
81
|
}
|