lt-ppt 1.0.26 → 1.0.27

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.
@@ -339,7 +339,7 @@ end`},HRe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r
339
339
  `);e.setDefaultAppearance(o)},Put=function(e,t){var n,r,a,o=Au(t),i=Au(e.acroField),s=t.getRectangle(),u=t.getAppearanceCharacteristics(),c=t.getBorderStyle(),f=(n=c==null?void 0:c.getWidth())!==null&&n!==void 0?n:0,d=Gp(u==null?void 0:u.getRotation()),h=L1(s,d),p=h.width,v=h.height,m=pm(On(On({},s),{rotation:d})),g=zr(0,0,0),y=(r=Fs(u==null?void 0:u.getBorderColor()))!==null&&r!==void 0?r:g,b=Fs(u==null?void 0:u.getBackgroundColor()),R=Fs(u==null?void 0:u.getBackgroundColor(),.8),A=(a=o??i)!==null&&a!==void 0?a:g;Ru(o?t:e.acroField,A);var S={x:0+f/2,y:0+f/2,width:p-f,height:v-f,thickness:1.5,borderWidth:f,borderColor:y,markColor:A};return{normal:{on:xr(m,XP(On(On({},S),{color:b,filled:!0}))),off:xr(m,XP(On(On({},S),{color:b,filled:!1})))},down:{on:xr(m,XP(On(On({},S),{color:R,filled:!0}))),off:xr(m,XP(On(On({},S),{color:R,filled:!1})))}}},_ut=function(e,t){var n,r,a,o=Au(t),i=Au(e.acroField),s=t.getRectangle(),u=t.getAppearanceCharacteristics(),c=t.getBorderStyle(),f=(n=c==null?void 0:c.getWidth())!==null&&n!==void 0?n:0,d=Gp(u==null?void 0:u.getRotation()),h=L1(s,d),p=h.width,v=h.height,m=pm(On(On({},s),{rotation:d})),g=zr(0,0,0),y=(r=Fs(u==null?void 0:u.getBorderColor()))!==null&&r!==void 0?r:g,b=Fs(u==null?void 0:u.getBackgroundColor()),R=Fs(u==null?void 0:u.getBackgroundColor(),.8),A=(a=o??i)!==null&&a!==void 0?a:g;Ru(o?t:e.acroField,A);var S={x:p/2,y:v/2,width:p-f,height:v-f,borderWidth:f,borderColor:y,dotColor:A};return{normal:{on:xr(m,UP(On(On({},S),{color:b,filled:!0}))),off:xr(m,UP(On(On({},S),{color:b,filled:!1})))},down:{on:xr(m,UP(On(On({},S),{color:R,filled:!0}))),off:xr(m,UP(On(On({},S),{color:R,filled:!1})))}}},Iut=function(e,t,n){var r,a,o,i,s,u=Au(t),c=Au(e.acroField),f=vm(t),d=vm(e.acroField),h=t.getRectangle(),p=t.getAppearanceCharacteristics(),v=t.getBorderStyle(),m=p==null?void 0:p.getCaptions(),g=(r=m==null?void 0:m.normal)!==null&&r!==void 0?r:"",y=(o=(a=m==null?void 0:m.down)!==null&&a!==void 0?a:g)!==null&&o!==void 0?o:"",b=(i=v==null?void 0:v.getWidth())!==null&&i!==void 0?i:0,R=Gp(p==null?void 0:p.getRotation()),A=L1(h,R),S=A.width,w=A.height,M=pm(On(On({},h),{rotation:R})),C=zr(0,0,0),N=Fs(p==null?void 0:p.getBorderColor()),T=Fs(p==null?void 0:p.getBackgroundColor()),k=Fs(p==null?void 0:p.getBackgroundColor(),.8),O={x:b,y:b,width:S-b*2,height:w-b*2},E=WP(g,{alignment:Bo.Center,fontSize:f??d,font:n,bounds:O}),P=WP(y,{alignment:Bo.Center,fontSize:f??d,font:n,bounds:O}),_=Math.min(E.fontSize,P.fontSize),I=(s=u??c)!==null&&s!==void 0?s:C;Ru(u||f!==void 0?t:e.acroField,I,n,_);var B={x:0+b/2,y:0+b/2,width:S-b,height:w-b,borderWidth:b,borderColor:N,textColor:I,font:n.name,fontSize:_};return{normal:xr(M,_xe(On(On({},B),{color:T,textLines:[E.line]}))),down:xr(M,_xe(On(On({},B),{color:k,textLines:[P.line]})))}},Fut=function(e,t,n){var r,a,o,i,s=Au(t),u=Au(e.acroField),c=vm(t),f=vm(e.acroField),d=t.getRectangle(),h=t.getAppearanceCharacteristics(),p=t.getBorderStyle(),v=(r=e.getText())!==null&&r!==void 0?r:"",m=(a=p==null?void 0:p.getWidth())!==null&&a!==void 0?a:0,g=Gp(h==null?void 0:h.getRotation()),y=L1(d,g),b=y.width,R=y.height,A=pm(On(On({},d),{rotation:g})),S=zr(0,0,0),w=Fs(h==null?void 0:h.getBorderColor()),M=Fs(h==null?void 0:h.getBackgroundColor()),C,N,T=e.isCombed()?0:1,k={x:m+T,y:m+T,width:b-(m+T)*2,height:R-(m+T)*2};if(e.isMultiline()){var O=Xxe(v,{alignment:e.getAlignment(),fontSize:c??f,font:n,bounds:k});C=O.lines,N=O.fontSize}else if(e.isCombed()){var O=kut(v,{fontSize:c??f,font:n,bounds:k,cellCount:(o=e.getMaxLength())!==null&&o!==void 0?o:0});C=O.cells,N=O.fontSize}else{var O=WP(v,{alignment:e.getAlignment(),fontSize:c??f,font:n,bounds:k});C=[O.line],N=O.fontSize}var E=(i=s??u)!==null&&i!==void 0?i:S;Ru(s||c!==void 0?t:e.acroField,E,n,N);var P={x:0+m/2,y:0+m/2,width:b-m,height:R-m,borderWidth:m??0,borderColor:w,textColor:E,font:n.name,fontSize:N,color:M,textLines:C,padding:T};return xr(A,Ixe(P))},Vut=function(e,t,n){var r,a,o,i=Au(t),s=Au(e.acroField),u=vm(t),c=vm(e.acroField),f=t.getRectangle(),d=t.getAppearanceCharacteristics(),h=t.getBorderStyle(),p=(r=e.getSelected()[0])!==null&&r!==void 0?r:"",v=(a=h==null?void 0:h.getWidth())!==null&&a!==void 0?a:0,m=Gp(d==null?void 0:d.getRotation()),g=L1(f,m),y=g.width,b=g.height,R=pm(On(On({},f),{rotation:m})),A=zr(0,0,0),S=Fs(d==null?void 0:d.getBorderColor()),w=Fs(d==null?void 0:d.getBackgroundColor()),M=1,C={x:v+M,y:v+M,width:y-(v+M)*2,height:b-(v+M)*2},N=WP(p,{alignment:Bo.Left,fontSize:u??c,font:n,bounds:C}),T=N.line,k=N.fontSize,O=(o=i??s)!==null&&o!==void 0?o:A;Ru(i||u!==void 0?t:e.acroField,O,n,k);var E={x:0+v/2,y:0+v/2,width:y-v,height:b-v,borderWidth:v??0,borderColor:S,textColor:O,font:n.name,fontSize:k,color:w,textLines:[T],padding:M};return xr(R,Ixe(E))},Dut=function(e,t,n){var r,a,o=Au(t),i=Au(e.acroField),s=vm(t),u=vm(e.acroField),c=t.getRectangle(),f=t.getAppearanceCharacteristics(),d=t.getBorderStyle(),h=(r=d==null?void 0:d.getWidth())!==null&&r!==void 0?r:0,p=Gp(f==null?void 0:f.getRotation()),v=L1(c,p),m=v.width,g=v.height,y=pm(On(On({},c),{rotation:p})),b=zr(0,0,0),R=Fs(f==null?void 0:f.getBorderColor()),A=Fs(f==null?void 0:f.getBackgroundColor()),S=e.getOptions(),w=e.getSelected();e.isSorted()&&S.sort();for(var M="",C=0,N=S.length;C<N;C++)M+=S[C],C<N-1&&(M+=`
340
340
  `);for(var T=1,k={x:h+T,y:h+T,width:m-(h+T)*2,height:g-(h+T)*2},O=Xxe(M,{alignment:Bo.Left,fontSize:s??u,font:n,bounds:k}),E=O.lines,P=O.fontSize,_=O.lineHeight,I=[],C=0,N=E.length;C<N;C++){var B=E[C];w.includes(B.text)&&I.push(C)}var Y=zr(153/255,193/255,218/255),W=(a=o??i)!==null&&a!==void 0?a:b;return Ru(o||s!==void 0?t:e.acroField,W,n,P),xr(y,mut({x:0+h/2,y:0+h/2,width:m-h,height:g-h,borderWidth:h??0,borderColor:R,textColor:W,font:n.name,fontSize:P,color:A,textLines:E,lineHeight:_,selectedColor:Y,selectedLines:I,padding:T}))},Uxe=function(){function e(t,n,r){this.alreadyEmbedded=!1,He(t,"ref",[[Kr,"PDFRef"]]),He(n,"doc",[[gm,"PDFDocument"]]),He(r,"embedder",[[nxe,"PDFPageEmbedder"]]),this.ref=t,this.doc=n,this.width=r.width,this.height=r.height,this.embedder=r}return e.prototype.scale=function(t){return He(t,"factor",["number"]),{width:this.width*t,height:this.height*t}},e.prototype.size=function(){return this.scale(1)},e.prototype.embed=function(){return Kn(this,void 0,void 0,function(){return Qn(this,function(t){switch(t.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:t.sent(),this.alreadyEmbedded=!0,t.label=2;case 2:return[2]}})})},e.of=function(t,n,r){return new e(t,n,r)},e}(),hc=function(){function e(t,n,r){this.modified=!0,He(t,"ref",[[Kr,"PDFRef"]]),He(n,"doc",[[gm,"PDFDocument"]]),He(r,"embedder",[[kj,"CustomFontEmbedder"],[vP,"StandardFontEmbedder"]]),this.ref=t,this.doc=n,this.name=r.fontName,this.embedder=r}return e.prototype.encodeText=function(t){return He(t,"text",["string"]),this.modified=!0,this.embedder.encodeText(t)},e.prototype.widthOfTextAtSize=function(t,n){return He(t,"text",["string"]),He(n,"size",["number"]),this.embedder.widthOfTextAtSize(t,n)},e.prototype.heightAtSize=function(t,n){var r;return He(t,"size",["number"]),Mt(n==null?void 0:n.descender,"options.descender",["boolean"]),this.embedder.heightOfFontAtSize(t,{descender:(r=n==null?void 0:n.descender)!==null&&r!==void 0?r:!0})},e.prototype.sizeAtHeight=function(t){return He(t,"height",["number"]),this.embedder.sizeOfFontAtHeight(t)},e.prototype.getCharacterSet=function(){return this.embedder instanceof vP?this.embedder.encoding.supportedCodePoints:this.embedder.font.characterSet},e.prototype.embed=function(){return Kn(this,void 0,void 0,function(){return Qn(this,function(t){switch(t.label){case 0:return this.modified?[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]:[3,2];case 1:t.sent(),this.modified=!1,t.label=2;case 2:return[2]}})})},e.of=function(t,n,r){return new e(t,n,r)},e}(),jj=function(){function e(t,n,r){He(t,"ref",[[Kr,"PDFRef"]]),He(n,"doc",[[gm,"PDFDocument"]]),He(r,"embedder",[[GRe,"JpegEmbedder"],[JRe,"PngEmbedder"]]),this.ref=t,this.doc=n,this.width=r.width,this.height=r.height,this.embedder=r}return e.prototype.scale=function(t){return He(t,"factor",["number"]),{width:this.width*t,height:this.height*t}},e.prototype.scaleToFit=function(t,n){He(t,"width",["number"]),He(n,"height",["number"]);var r=t/this.width,a=n/this.height,o=Math.min(r,a);return this.scale(o)},e.prototype.size=function(){return this.scale(1)},e.prototype.embed=function(){return Kn(this,void 0,void 0,function(){var t,n,r;return Qn(this,function(a){switch(a.label){case 0:return this.embedder?(this.embedTask||(t=this,n=t.doc,r=t.ref,this.embedTask=this.embedder.embedIntoContext(n.context,r)),[4,this.embedTask]):[2];case 1:return a.sent(),this.embedder=void 0,[2]}})})},e.of=function(t,n,r){return new e(t,n,r)},e}(),mm;(function(e){e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right"})(mm||(mm={}));var tx=function(e){Mt(e==null?void 0:e.x,"options.x",["number"]),Mt(e==null?void 0:e.y,"options.y",["number"]),Mt(e==null?void 0:e.width,"options.width",["number"]),Mt(e==null?void 0:e.height,"options.height",["number"]),Mt(e==null?void 0:e.textColor,"options.textColor",[[Object,"Color"]]),Mt(e==null?void 0:e.backgroundColor,"options.backgroundColor",[[Object,"Color"]]),Mt(e==null?void 0:e.borderColor,"options.borderColor",[[Object,"Color"]]),Mt(e==null?void 0:e.borderWidth,"options.borderWidth",["number"]),Mt(e==null?void 0:e.rotate,"options.rotate",[[Object,"Rotation"]])},P1=function(){function e(t,n,r){He(t,"acroField",[[JR,"PDFAcroTerminal"]]),He(n,"ref",[[Kr,"PDFRef"]]),He(r,"doc",[[gm,"PDFDocument"]]),this.acroField=t,this.ref=n,this.doc=r}return e.prototype.getName=function(){var t;return(t=this.acroField.getFullyQualifiedName())!==null&&t!==void 0?t:""},e.prototype.isReadOnly=function(){return this.acroField.hasFlag(Ff.ReadOnly)},e.prototype.enableReadOnly=function(){this.acroField.setFlagTo(Ff.ReadOnly,!0)},e.prototype.disableReadOnly=function(){this.acroField.setFlagTo(Ff.ReadOnly,!1)},e.prototype.isRequired=function(){return this.acroField.hasFlag(Ff.Required)},e.prototype.enableRequired=function(){this.acroField.setFlagTo(Ff.Required,!0)},e.prototype.disableRequired=function(){this.acroField.setFlagTo(Ff.Required,!1)},e.prototype.isExported=function(){return!this.acroField.hasFlag(Ff.NoExport)},e.prototype.enableExporting=function(){this.acroField.setFlagTo(Ff.NoExport,!1)},e.prototype.disableExporting=function(){this.acroField.setFlagTo(Ff.NoExport,!0)},e.prototype.needsAppearancesUpdate=function(){throw new mu(this.constructor.name,"needsAppearancesUpdate")},e.prototype.defaultUpdateAppearances=function(t){throw new mu(this.constructor.name,"defaultUpdateAppearances")},e.prototype.markAsDirty=function(){this.doc.getForm().markFieldAsDirty(this.ref)},e.prototype.markAsClean=function(){this.doc.getForm().markFieldAsClean(this.ref)},e.prototype.isDirty=function(){return this.doc.getForm().fieldIsDirty(this.ref)},e.prototype.createWidget=function(t){var n,r=t.textColor,a=t.backgroundColor,o=t.borderColor,i=t.borderWidth,s=mxe(t.rotate),u=t.caption,c=t.x,f=t.y,d=t.width+i,h=t.height+i,p=!!t.hidden,v=t.page;ERe(s,"degreesAngle",90);var m=_j.create(this.doc.context,this.ref),g=zct({x:c,y:f,width:d,height:h},i,s);m.setRectangle(g),v&&m.setP(v);var y=m.getOrCreateAppearanceCharacteristics();a&&y.setBackgroundColor(Lxe(a)),y.setRotation(s),u&&y.setCaptions({normal:u}),o&&y.setBorderColor(Lxe(o));var b=m.getOrCreateBorderStyle();if(i!==void 0&&b.setWidth(i),m.setFlagTo(O5.Print,!0),m.setFlagTo(O5.Hidden,p),m.setFlagTo(O5.Invisible,!1),r){var R=(n=this.acroField.getDefaultAppearance())!==null&&n!==void 0?n:"",A=R+`
341
341
  `+O1(r).toString();this.acroField.setDefaultAppearance(A)}return m},e.prototype.updateWidgetAppearanceWithFont=function(t,n,r){var a=r.normal,o=r.rollover,i=r.down;this.updateWidgetAppearances(t,{normal:this.createAppearanceStream(t,a,n),rollover:o&&this.createAppearanceStream(t,o,n),down:i&&this.createAppearanceStream(t,i,n)})},e.prototype.updateOnOffWidgetAppearance=function(t,n,r){var a=r.normal,o=r.rollover,i=r.down;this.updateWidgetAppearances(t,{normal:this.createAppearanceDict(t,a,n),rollover:o&&this.createAppearanceDict(t,o,n),down:i&&this.createAppearanceDict(t,i,n)})},e.prototype.updateWidgetAppearances=function(t,n){var r=n.normal,a=n.rollover,o=n.down;t.setNormalAppearance(r),a?t.setRolloverAppearance(a):t.removeRolloverAppearance(),o?t.setDownAppearance(o):t.removeDownAppearance()},e.prototype.createAppearanceStream=function(t,n,r){var a,o=this.acroField.dict.context,i=t.getRectangle(),s=i.width,u=i.height,c=r&&{Font:(a={},a[r.name]=r.ref,a)},f=o.formXObject(n,{Resources:c,BBox:o.obj([0,0,s,u]),Matrix:o.obj([1,0,0,1,0,0])}),d=o.register(f);return d},e.prototype.createImageAppearanceStream=function(t,n,r){var a,o,i=this.acroField.dict.context,s=t.getRectangle(),u=t.getAppearanceCharacteristics(),c=t.getBorderStyle(),f=(o=c==null?void 0:c.getWidth())!==null&&o!==void 0?o:0,d=Gp(u==null?void 0:u.getRotation()),h=pm(On(On({},s),{rotation:d})),p=L1(s,d),v=n.scaleToFit(p.width-f*2,p.height-f*2),m={x:f,y:f,width:v.width,height:v.height,rotate:bn(0),xSkew:bn(0),ySkew:bn(0)};r===mm.Center?(m.x+=(p.width-f*2)/2-v.width/2,m.y+=(p.height-f*2)/2-v.height/2):r===mm.Right&&(m.x=p.width-f-v.width,m.y=p.height-f-v.height);var g=this.doc.context.addRandomSuffix("Image",10),y=xr(h,Pxe(g,m)),b={XObject:(a={},a[g]=n.ref,a)},R=i.formXObject(y,{Resources:b,BBox:i.obj([0,0,s.width,s.height]),Matrix:i.obj([1,0,0,1,0,0])});return i.register(R)},e.prototype.createAppearanceDict=function(t,n,r){var a=this.acroField.dict.context,o=this.createAppearanceStream(t,n.on),i=this.createAppearanceStream(t,n.off),s=a.obj({});return s.set(r,o),s.set(Se.of("Off"),i),s},e}(),B5=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroCheckBox",[[bP,"PDFAcroCheckBox"]]),o.acroField=n,o}return t.prototype.check=function(){var n,r=(n=this.acroField.getOnValue())!==null&&n!==void 0?n:Se.of("Yes");this.markAsDirty(),this.acroField.setValue(r)},t.prototype.uncheck=function(){this.markAsDirty(),this.acroField.setValue(Se.of("Off"))},t.prototype.isChecked=function(){var n=this.acroField.getOnValue();return!!n&&n===this.acroField.getValue()},t.prototype.addToPage=function(n,r){var a,o,i,s,u,c;He(n,"page",[[xu,"PDFPage"]]),tx(r),r||(r={}),"textColor"in r||(r.textColor=zr(0,0,0)),"backgroundColor"in r||(r.backgroundColor=zr(1,1,1)),"borderColor"in r||(r.borderColor=zr(0,0,0)),"borderWidth"in r||(r.borderWidth=1);var f=this.createWidget({x:(a=r.x)!==null&&a!==void 0?a:0,y:(o=r.y)!==null&&o!==void 0?o:0,width:(i=r.width)!==null&&i!==void 0?i:50,height:(s=r.height)!==null&&s!==void 0?s:50,textColor:r.textColor,backgroundColor:r.backgroundColor,borderColor:r.borderColor,borderWidth:(u=r.borderWidth)!==null&&u!==void 0?u:0,rotate:(c=r.rotate)!==null&&c!==void 0?c:bn(0),hidden:r.hidden,page:n.ref}),d=this.doc.context.register(f.dict);this.acroField.addWidget(d),f.setAppearanceState(Se.of("Off")),this.updateWidgetAppearance(f,Se.of("Yes")),n.node.addAnnot(d)},t.prototype.needsAppearancesUpdate=function(){for(var n,r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=i.getAppearanceState(),u=(n=i.getAppearances())===null||n===void 0?void 0:n.normal;if(!(u instanceof Dn)||s&&!u.has(s))return!0}return!1},t.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},t.prototype.updateAppearances=function(n){var r;Mt(n,"provider",[Function]);for(var a=this.acroField.getWidgets(),o=0,i=a.length;o<i;o++){var s=a[o],u=(r=s.getOnValue())!==null&&r!==void 0?r:Se.of("Yes");u&&this.updateWidgetAppearance(s,u,n)}this.markAsClean()},t.prototype.updateWidgetAppearance=function(n,r,a){var o=a??Put,i=ex(o(this,n));this.updateOnOffWidgetAppearance(n,r,i)},t.of=function(n,r,a){return new t(n,r,a)},t}(P1),YP=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroComboBox",[[AP,"PDFAcroComboBox"]]),o.acroField=n,o}return t.prototype.getOptions=function(){for(var n=this.acroField.getOptions(),r=new Array(n.length),a=0,o=r.length;a<o;a++){var i=n[a],s=i.display,u=i.value;r[a]=(s??u).decodeText()}return r},t.prototype.getSelected=function(){for(var n=this.acroField.getValues(),r=new Array(n.length),a=0,o=n.length;a<o;a++)r[a]=n[a].decodeText();return r},t.prototype.setOptions=function(n){He(n,"options",[Array]);for(var r=new Array(n.length),a=0,o=n.length;a<o;a++)r[a]={value:vn.fromText(n[a])};this.acroField.setOptions(r)},t.prototype.addOptions=function(n){He(n,"options",["string",Array]);for(var r=Array.isArray(n)?n:[n],a=this.acroField.getOptions(),o=new Array(r.length),i=0,s=r.length;i<s;i++)o[i]={value:vn.fromText(r[i])};this.acroField.setOptions(a.concat(o))},t.prototype.select=function(n,r){r===void 0&&(r=!1),He(n,"options",["string",Array]),He(r,"merge",["boolean"]);var a=Array.isArray(n)?n:[n],o=this.getOptions(),i=a.find(function(d){return!o.includes(d)});i&&this.enableEditing(),this.markAsDirty(),(a.length>1||a.length===1&&r)&&this.enableMultiselect();for(var s=new Array(a.length),u=0,c=a.length;u<c;u++)s[u]=vn.fromText(a[u]);if(r){var f=this.acroField.getValues();this.acroField.setValues(f.concat(s))}else this.acroField.setValues(s)},t.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},t.prototype.setFontSize=function(n){uP(n,"fontSize"),this.acroField.setFontSize(n),this.markAsDirty()},t.prototype.isEditable=function(){return this.acroField.hasFlag(Hr.Edit)},t.prototype.enableEditing=function(){this.acroField.setFlagTo(Hr.Edit,!0)},t.prototype.disableEditing=function(){this.acroField.setFlagTo(Hr.Edit,!1)},t.prototype.isSorted=function(){return this.acroField.hasFlag(Hr.Sort)},t.prototype.enableSorting=function(){this.acroField.setFlagTo(Hr.Sort,!0)},t.prototype.disableSorting=function(){this.acroField.setFlagTo(Hr.Sort,!1)},t.prototype.isMultiselect=function(){return this.acroField.hasFlag(Hr.MultiSelect)},t.prototype.enableMultiselect=function(){this.acroField.setFlagTo(Hr.MultiSelect,!0)},t.prototype.disableMultiselect=function(){this.acroField.setFlagTo(Hr.MultiSelect,!1)},t.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(Hr.DoNotSpellCheck)},t.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(Hr.DoNotSpellCheck,!1)},t.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(Hr.DoNotSpellCheck,!0)},t.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(Hr.CommitOnSelChange)},t.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(Hr.CommitOnSelChange,!0)},t.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(Hr.CommitOnSelChange,!1)},t.prototype.addToPage=function(n,r){var a,o,i,s,u,c,f;He(n,"page",[[xu,"PDFPage"]]),tx(r),r||(r={}),"textColor"in r||(r.textColor=zr(0,0,0)),"backgroundColor"in r||(r.backgroundColor=zr(1,1,1)),"borderColor"in r||(r.borderColor=zr(0,0,0)),"borderWidth"in r||(r.borderWidth=1);var d=this.createWidget({x:(a=r.x)!==null&&a!==void 0?a:0,y:(o=r.y)!==null&&o!==void 0?o:0,width:(i=r.width)!==null&&i!==void 0?i:200,height:(s=r.height)!==null&&s!==void 0?s:50,textColor:r.textColor,backgroundColor:r.backgroundColor,borderColor:r.borderColor,borderWidth:(u=r.borderWidth)!==null&&u!==void 0?u:0,rotate:(c=r.rotate)!==null&&c!==void 0?c:bn(0),hidden:r.hidden,page:n.ref}),h=this.doc.context.register(d.dict);this.acroField.addWidget(h);var p=(f=r.font)!==null&&f!==void 0?f:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(d,p),n.node.addAnnot(h)},t.prototype.needsAppearancesUpdate=function(){var n;if(this.isDirty())return!0;for(var r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=((n=i.getAppearances())===null||n===void 0?void 0:n.normal)instanceof fc;if(!s)return!0}return!1},t.prototype.defaultUpdateAppearances=function(n){He(n,"font",[[hc,"PDFFont"]]),this.updateAppearances(n)},t.prototype.updateAppearances=function(n,r){He(n,"font",[[hc,"PDFFont"]]),Mt(r,"provider",[Function]);for(var a=this.acroField.getWidgets(),o=0,i=a.length;o<i;o++){var s=a[o];this.updateWidgetAppearance(s,n,r)}this.markAsClean()},t.prototype.updateWidgetAppearance=function(n,r,a){var o=a??Vut,i=ex(o(this,n,r));this.updateWidgetAppearanceWithFont(n,r,i)},t.of=function(n,r,a){return new t(n,r,a)},t}(P1),ZP=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroListBox",[[MP,"PDFAcroListBox"]]),o.acroField=n,o}return t.prototype.getOptions=function(){for(var n=this.acroField.getOptions(),r=new Array(n.length),a=0,o=r.length;a<o;a++){var i=n[a],s=i.display,u=i.value;r[a]=(s??u).decodeText()}return r},t.prototype.getSelected=function(){for(var n=this.acroField.getValues(),r=new Array(n.length),a=0,o=n.length;a<o;a++)r[a]=n[a].decodeText();return r},t.prototype.setOptions=function(n){He(n,"options",[Array]),this.markAsDirty();for(var r=new Array(n.length),a=0,o=n.length;a<o;a++)r[a]={value:vn.fromText(n[a])};this.acroField.setOptions(r)},t.prototype.addOptions=function(n){He(n,"options",["string",Array]),this.markAsDirty();for(var r=Array.isArray(n)?n:[n],a=this.acroField.getOptions(),o=new Array(r.length),i=0,s=r.length;i<s;i++)o[i]={value:vn.fromText(r[i])};this.acroField.setOptions(a.concat(o))},t.prototype.select=function(n,r){r===void 0&&(r=!1),He(n,"options",["string",Array]),He(r,"merge",["boolean"]);var a=Array.isArray(n)?n:[n],o=this.getOptions();Flt(a,"option",o),this.markAsDirty(),(a.length>1||a.length===1&&r)&&this.enableMultiselect();for(var i=new Array(a.length),s=0,u=a.length;s<u;s++)i[s]=vn.fromText(a[s]);if(r){var c=this.acroField.getValues();this.acroField.setValues(c.concat(i))}else this.acroField.setValues(i)},t.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},t.prototype.setFontSize=function(n){uP(n,"fontSize"),this.acroField.setFontSize(n),this.markAsDirty()},t.prototype.isSorted=function(){return this.acroField.hasFlag(Hr.Sort)},t.prototype.enableSorting=function(){this.acroField.setFlagTo(Hr.Sort,!0)},t.prototype.disableSorting=function(){this.acroField.setFlagTo(Hr.Sort,!1)},t.prototype.isMultiselect=function(){return this.acroField.hasFlag(Hr.MultiSelect)},t.prototype.enableMultiselect=function(){this.acroField.setFlagTo(Hr.MultiSelect,!0)},t.prototype.disableMultiselect=function(){this.acroField.setFlagTo(Hr.MultiSelect,!1)},t.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(Hr.CommitOnSelChange)},t.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(Hr.CommitOnSelChange,!0)},t.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(Hr.CommitOnSelChange,!1)},t.prototype.addToPage=function(n,r){var a,o,i,s,u,c,f;He(n,"page",[[xu,"PDFPage"]]),tx(r),r||(r={}),"textColor"in r||(r.textColor=zr(0,0,0)),"backgroundColor"in r||(r.backgroundColor=zr(1,1,1)),"borderColor"in r||(r.borderColor=zr(0,0,0)),"borderWidth"in r||(r.borderWidth=1);var d=this.createWidget({x:(a=r.x)!==null&&a!==void 0?a:0,y:(o=r.y)!==null&&o!==void 0?o:0,width:(i=r.width)!==null&&i!==void 0?i:200,height:(s=r.height)!==null&&s!==void 0?s:100,textColor:r.textColor,backgroundColor:r.backgroundColor,borderColor:r.borderColor,borderWidth:(u=r.borderWidth)!==null&&u!==void 0?u:0,rotate:(c=r.rotate)!==null&&c!==void 0?c:bn(0),hidden:r.hidden,page:n.ref}),h=this.doc.context.register(d.dict);this.acroField.addWidget(h);var p=(f=r.font)!==null&&f!==void 0?f:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(d,p),n.node.addAnnot(h)},t.prototype.needsAppearancesUpdate=function(){var n;if(this.isDirty())return!0;for(var r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=((n=i.getAppearances())===null||n===void 0?void 0:n.normal)instanceof fc;if(!s)return!0}return!1},t.prototype.defaultUpdateAppearances=function(n){He(n,"font",[[hc,"PDFFont"]]),this.updateAppearances(n)},t.prototype.updateAppearances=function(n,r){He(n,"font",[[hc,"PDFFont"]]),Mt(r,"provider",[Function]);for(var a=this.acroField.getWidgets(),o=0,i=a.length;o<i;o++){var s=a[o];this.updateWidgetAppearance(s,n,r)}this.markAsClean()},t.prototype.updateWidgetAppearance=function(n,r,a){var o=a??Dut,i=ex(o(this,n,r));this.updateWidgetAppearanceWithFont(n,r,i)},t.of=function(n,r,a){return new t(n,r,a)},t}(P1),X5=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroRadioButton",[[wP,"PDFAcroRadioButton"]]),o.acroField=n,o}return t.prototype.getOptions=function(){var n=this.acroField.getExportValues();if(n){for(var r=new Array(n.length),a=0,o=n.length;a<o;a++)r[a]=n[a].decodeText();return r}for(var i=this.acroField.getOnValues(),s=new Array(i.length),a=0,o=s.length;a<o;a++)s[a]=i[a].decodeText();return s},t.prototype.getSelected=function(){var n=this.acroField.getValue();if(n!==Se.of("Off")){var r=this.acroField.getExportValues();if(r){for(var a=this.acroField.getOnValues(),o=0,i=a.length;o<i;o++)if(a[o]===n)return r[o].decodeText()}return n.decodeText()}},t.prototype.select=function(n){He(n,"option",["string"]);var r=this.getOptions();cm(n,"option",r),this.markAsDirty();var a=this.acroField.getOnValues(),o=this.acroField.getExportValues();if(o)for(var i=0,s=o.length;i<s;i++)o[i].decodeText()===n&&this.acroField.setValue(a[i]);else for(var i=0,s=a.length;i<s;i++){var u=a[i];u.decodeText()===n&&this.acroField.setValue(u)}},t.prototype.clear=function(){this.markAsDirty(),this.acroField.setValue(Se.of("Off"))},t.prototype.isOffToggleable=function(){return!this.acroField.hasFlag(yu.NoToggleToOff)},t.prototype.enableOffToggling=function(){this.acroField.setFlagTo(yu.NoToggleToOff,!1)},t.prototype.disableOffToggling=function(){this.acroField.setFlagTo(yu.NoToggleToOff,!0)},t.prototype.isMutuallyExclusive=function(){return!this.acroField.hasFlag(yu.RadiosInUnison)},t.prototype.enableMutualExclusion=function(){this.acroField.setFlagTo(yu.RadiosInUnison,!1)},t.prototype.disableMutualExclusion=function(){this.acroField.setFlagTo(yu.RadiosInUnison,!0)},t.prototype.addOptionToPage=function(n,r,a){var o,i,s,u,c,f,d,h,p;He(n,"option",["string"]),He(r,"page",[[xu,"PDFPage"]]),tx(a);var v=this.createWidget({x:(o=a==null?void 0:a.x)!==null&&o!==void 0?o:0,y:(i=a==null?void 0:a.y)!==null&&i!==void 0?i:0,width:(s=a==null?void 0:a.width)!==null&&s!==void 0?s:50,height:(u=a==null?void 0:a.height)!==null&&u!==void 0?u:50,textColor:(c=a==null?void 0:a.textColor)!==null&&c!==void 0?c:zr(0,0,0),backgroundColor:(f=a==null?void 0:a.backgroundColor)!==null&&f!==void 0?f:zr(1,1,1),borderColor:(d=a==null?void 0:a.borderColor)!==null&&d!==void 0?d:zr(0,0,0),borderWidth:(h=a==null?void 0:a.borderWidth)!==null&&h!==void 0?h:1,rotate:(p=a==null?void 0:a.rotate)!==null&&p!==void 0?p:bn(0),hidden:a==null?void 0:a.hidden,page:r.ref}),m=this.doc.context.register(v.dict),g=this.acroField.addWidgetWithOpt(m,vn.fromText(n),!this.isMutuallyExclusive());v.setAppearanceState(Se.of("Off")),this.updateWidgetAppearance(v,g),r.node.addAnnot(m)},t.prototype.needsAppearancesUpdate=function(){for(var n,r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=i.getAppearanceState(),u=(n=i.getAppearances())===null||n===void 0?void 0:n.normal;if(!(u instanceof Dn)||s&&!u.has(s))return!0}return!1},t.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},t.prototype.updateAppearances=function(n){Mt(n,"provider",[Function]);for(var r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=i.getOnValue();s&&this.updateWidgetAppearance(i,s,n)}},t.prototype.updateWidgetAppearance=function(n,r,a){var o=a??_ut,i=ex(o(this,n));this.updateOnOffWidgetAppearance(n,r,i)},t.of=function(n,r,a){return new t(n,r,a)},t}(P1),qj=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroSignature",[[Fj,"PDFAcroSignature"]]),o.acroField=n,o}return t.prototype.needsAppearancesUpdate=function(){return!1},t.of=function(n,r,a){return new t(n,r,a)},t}(P1),KP=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroText",[[xP,"PDFAcroText"]]),o.acroField=n,o}return t.prototype.getText=function(){var n=this.acroField.getValue();if(!n&&this.isRichFormatted())throw new Sut(this.getName());return n==null?void 0:n.decodeText()},t.prototype.setText=function(n){Mt(n,"text",["string"]);var r=this.getMaxLength();if(r!==void 0&&n&&n.length>r)throw new Mut(n.length,r,this.getName());this.markAsDirty(),this.disableRichFormatting(),n?this.acroField.setValue(vn.fromText(n)):this.acroField.removeValue()},t.prototype.getAlignment=function(){var n=this.acroField.getQuadding();return n===0?Bo.Left:n===1?Bo.Center:n===2?Bo.Right:Bo.Left},t.prototype.setAlignment=function(n){cm(n,"alignment",Bo),this.markAsDirty(),this.acroField.setQuadding(n)},t.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},t.prototype.setMaxLength=function(n){if(If(n,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),n===void 0)this.acroField.removeMaxLength();else{var r=this.getText();if(r&&r.length>n)throw new Nut(r.length,n,this.getName());this.acroField.setMaxLength(n)}},t.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},t.prototype.setImage=function(n){for(var r=this.getAlignment(),a=r===Bo.Center?mm.Center:r===Bo.Right?mm.Right:mm.Left,o=this.acroField.getWidgets(),i=0,s=o.length;i<s;i++){var u=o[i],c=this.createImageAppearanceStream(u,n,a);this.updateWidgetAppearances(u,{normal:c})}this.markAsClean()},t.prototype.setFontSize=function(n){uP(n,"fontSize"),this.acroField.setFontSize(n),this.markAsDirty()},t.prototype.isMultiline=function(){return this.acroField.hasFlag(Za.Multiline)},t.prototype.enableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(Za.Multiline,!0)},t.prototype.disableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(Za.Multiline,!1)},t.prototype.isPassword=function(){return this.acroField.hasFlag(Za.Password)},t.prototype.enablePassword=function(){this.acroField.setFlagTo(Za.Password,!0)},t.prototype.disablePassword=function(){this.acroField.setFlagTo(Za.Password,!1)},t.prototype.isFileSelector=function(){return this.acroField.hasFlag(Za.FileSelect)},t.prototype.enableFileSelection=function(){this.acroField.setFlagTo(Za.FileSelect,!0)},t.prototype.disableFileSelection=function(){this.acroField.setFlagTo(Za.FileSelect,!1)},t.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(Za.DoNotSpellCheck)},t.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(Za.DoNotSpellCheck,!1)},t.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(Za.DoNotSpellCheck,!0)},t.prototype.isScrollable=function(){return!this.acroField.hasFlag(Za.DoNotScroll)},t.prototype.enableScrolling=function(){this.acroField.setFlagTo(Za.DoNotScroll,!1)},t.prototype.disableScrolling=function(){this.acroField.setFlagTo(Za.DoNotScroll,!0)},t.prototype.isCombed=function(){return this.acroField.hasFlag(Za.Comb)&&!this.isMultiline()&&!this.isPassword()&&!this.isFileSelector()&&this.getMaxLength()!==void 0},t.prototype.enableCombing=function(){if(this.getMaxLength()===void 0){var n="PDFTextFields must have a max length in order to be combed";console.warn(n)}this.markAsDirty(),this.disableMultiline(),this.disablePassword(),this.disableFileSelection(),this.acroField.setFlagTo(Za.Comb,!0)},t.prototype.disableCombing=function(){this.markAsDirty(),this.acroField.setFlagTo(Za.Comb,!1)},t.prototype.isRichFormatted=function(){return this.acroField.hasFlag(Za.RichText)},t.prototype.enableRichFormatting=function(){this.acroField.setFlagTo(Za.RichText,!0)},t.prototype.disableRichFormatting=function(){this.acroField.setFlagTo(Za.RichText,!1)},t.prototype.addToPage=function(n,r){var a,o,i,s,u,c,f;He(n,"page",[[xu,"PDFPage"]]),tx(r),r||(r={}),"textColor"in r||(r.textColor=zr(0,0,0)),"backgroundColor"in r||(r.backgroundColor=zr(1,1,1)),"borderColor"in r||(r.borderColor=zr(0,0,0)),"borderWidth"in r||(r.borderWidth=1);var d=this.createWidget({x:(a=r.x)!==null&&a!==void 0?a:0,y:(o=r.y)!==null&&o!==void 0?o:0,width:(i=r.width)!==null&&i!==void 0?i:200,height:(s=r.height)!==null&&s!==void 0?s:50,textColor:r.textColor,backgroundColor:r.backgroundColor,borderColor:r.borderColor,borderWidth:(u=r.borderWidth)!==null&&u!==void 0?u:0,rotate:(c=r.rotate)!==null&&c!==void 0?c:bn(0),hidden:r.hidden,page:n.ref}),h=this.doc.context.register(d.dict);this.acroField.addWidget(h);var p=(f=r.font)!==null&&f!==void 0?f:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(d,p),n.node.addAnnot(h)},t.prototype.needsAppearancesUpdate=function(){var n;if(this.isDirty())return!0;for(var r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=((n=i.getAppearances())===null||n===void 0?void 0:n.normal)instanceof fc;if(!s)return!0}return!1},t.prototype.defaultUpdateAppearances=function(n){He(n,"font",[[hc,"PDFFont"]]),this.updateAppearances(n)},t.prototype.updateAppearances=function(n,r){He(n,"font",[[hc,"PDFFont"]]),Mt(r,"provider",[Function]);for(var a=this.acroField.getWidgets(),o=0,i=a.length;o<i;o++){var s=a[o];this.updateWidgetAppearance(s,n,r)}this.markAsClean()},t.prototype.updateWidgetAppearance=function(n,r,a){var o=a??Fut,i=ex(o(this,n,r));this.updateWidgetAppearanceWithFont(n,r,i)},t.of=function(n,r,a){return new t(n,r,a)},t}(P1),QP;(function(e){e.Courier="Courier",e.CourierBold="Courier-Bold",e.CourierOblique="Courier-Oblique",e.CourierBoldOblique="Courier-BoldOblique",e.Helvetica="Helvetica",e.HelveticaBold="Helvetica-Bold",e.HelveticaOblique="Helvetica-Oblique",e.HelveticaBoldOblique="Helvetica-BoldOblique",e.TimesRoman="Times-Roman",e.TimesRomanBold="Times-Bold",e.TimesRomanItalic="Times-Italic",e.TimesRomanBoldItalic="Times-BoldItalic",e.Symbol="Symbol",e.ZapfDingbats="ZapfDingbats"})(QP||(QP={}));var But=function(){function e(t,n){var r=this;this.embedDefaultFont=function(){return r.doc.embedStandardFont(QP.Helvetica)},He(t,"acroForm",[[NP,"PDFAcroForm"]]),He(n,"doc",[[gm,"PDFDocument"]]),this.acroForm=t,this.doc=n,this.dirtyFields=new Set,this.defaultFontCache=Qp.populatedBy(this.embedDefaultFont)}return e.prototype.hasXFA=function(){return this.acroForm.dict.has(Se.of("XFA"))},e.prototype.deleteXFA=function(){this.acroForm.dict.delete(Se.of("XFA"))},e.prototype.getFields=function(){for(var t=this.acroForm.getAllFields(),n=[],r=0,a=t.length;r<a;r++){var o=t[r],i=o[0],s=o[1],u=Xut(i,s,this.doc);u&&n.push(u)}return n},e.prototype.getFieldMaybe=function(t){He(t,"name",["string"]);for(var n=this.getFields(),r=0,a=n.length;r<a;r++){var o=n[r];if(o.getName()===t)return o}},e.prototype.getField=function(t){He(t,"name",["string"]);var n=this.getFieldMaybe(t);if(n)return n;throw new Rut(t)},e.prototype.getButton=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof HP)return n;throw new E1(t,HP,n)},e.prototype.getCheckBox=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof B5)return n;throw new E1(t,B5,n)},e.prototype.getDropdown=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof YP)return n;throw new E1(t,YP,n)},e.prototype.getOptionList=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof ZP)return n;throw new E1(t,ZP,n)},e.prototype.getRadioGroup=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof X5)return n;throw new E1(t,X5,n)},e.prototype.getSignature=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof qj)return n;throw new E1(t,qj,n)},e.prototype.getTextField=function(t){He(t,"name",["string"]);var n=this.getField(t);if(n instanceof KP)return n;throw new E1(t,KP,n)},e.prototype.createButton=function(t){He(t,"name",["string"]);var n=nx(t),r=this.findOrCreateNonTerminals(n.nonTerminal),a=SP.create(this.doc.context);return a.setPartialName(n.terminal),rx(r,[a,a.ref],n.terminal),HP.of(a,a.ref,this.doc)},e.prototype.createCheckBox=function(t){He(t,"name",["string"]);var n=nx(t),r=this.findOrCreateNonTerminals(n.nonTerminal),a=bP.create(this.doc.context);return a.setPartialName(n.terminal),rx(r,[a,a.ref],n.terminal),B5.of(a,a.ref,this.doc)},e.prototype.createDropdown=function(t){He(t,"name",["string"]);var n=nx(t),r=this.findOrCreateNonTerminals(n.nonTerminal),a=AP.create(this.doc.context);return a.setPartialName(n.terminal),rx(r,[a,a.ref],n.terminal),YP.of(a,a.ref,this.doc)},e.prototype.createOptionList=function(t){He(t,"name",["string"]);var n=nx(t),r=this.findOrCreateNonTerminals(n.nonTerminal),a=MP.create(this.doc.context);return a.setPartialName(n.terminal),rx(r,[a,a.ref],n.terminal),ZP.of(a,a.ref,this.doc)},e.prototype.createRadioGroup=function(t){He(t,"name",["string"]);var n=nx(t),r=this.findOrCreateNonTerminals(n.nonTerminal),a=wP.create(this.doc.context);return a.setPartialName(n.terminal),rx(r,[a,a.ref],n.terminal),X5.of(a,a.ref,this.doc)},e.prototype.createTextField=function(t){He(t,"name",["string"]);var n=nx(t),r=this.findOrCreateNonTerminals(n.nonTerminal),a=xP.create(this.doc.context);return a.setPartialName(n.terminal),rx(r,[a,a.ref],n.terminal),KP.of(a,a.ref,this.doc)},e.prototype.flatten=function(t){t===void 0&&(t={updateFieldAppearances:!0}),t.updateFieldAppearances&&this.updateFieldAppearances();for(var n=this.getFields(),r=0,a=n.length;r<a;r++){for(var o=n[r],i=o.acroField.getWidgets(),s=0,u=i.length;s<u;s++){var c=i[s],f=this.findWidgetPage(c),d=this.findWidgetAppearanceRef(o,c),h=f.node.newXObject("FlatWidget",d),p=c.getRectangle(),v=xr([Vo(),bu(p.x,p.y)],pm(On(On({},p),{rotation:0})),[Kj(h),Do()]).filter(Boolean);f.pushOperators.apply(f,v)}this.removeField(o)}},e.prototype.removeField=function(t){for(var n=t.acroField.getWidgets(),r=new Set,a=0,o=n.length;a<o;a++){var i=n[a],s=this.findWidgetAppearanceRef(t,i),u=this.findWidgetPage(i);r.add(u),u.node.removeAnnot(s)}r.forEach(function(p){return p.node.removeAnnot(t.ref)}),this.acroForm.removeField(t.acroField);for(var c=t.acroField.normalizedEntries().Kids,f=c.size(),d=0;d<f;d++){var h=c.get(d);h instanceof Kr&&this.doc.context.delete(h)}this.doc.context.delete(t.ref)},e.prototype.updateFieldAppearances=function(t){Mt(t,"font",[[hc,"PDFFont"]]),t=t??this.getDefaultFont();for(var n=this.getFields(),r=0,a=n.length;r<a;r++){var o=n[r];o.needsAppearancesUpdate()&&o.defaultUpdateAppearances(t)}},e.prototype.markFieldAsDirty=function(t){Mt(t,"fieldRef",[[Kr,"PDFRef"]]),this.dirtyFields.add(t)},e.prototype.markFieldAsClean=function(t){Mt(t,"fieldRef",[[Kr,"PDFRef"]]),this.dirtyFields.delete(t)},e.prototype.fieldIsDirty=function(t){return Mt(t,"fieldRef",[[Kr,"PDFRef"]]),this.dirtyFields.has(t)},e.prototype.getDefaultFont=function(){return this.defaultFontCache.access()},e.prototype.findWidgetPage=function(t){var n=t.P(),r=this.doc.getPages().find(function(o){return o.ref===n});if(r===void 0){var a=this.doc.context.getObjectRef(t.dict);if(a===void 0)throw new Error("Could not find PDFRef for PDFObject");if(r=this.doc.findPageForAnnotationRef(a),r===void 0)throw new Error("Could not find page for PDFRef "+a)}return r},e.prototype.findWidgetAppearanceRef=function(t,n){var r,a=n.getNormalAppearance();if(a instanceof Dn&&(t instanceof B5||t instanceof X5)){var o=t.acroField.getValue(),i=(r=a.get(o))!==null&&r!==void 0?r:a.get(Se.of("Off"));i instanceof Kr&&(a=i)}if(!(a instanceof Kr)){var s=t.getName();throw new Error("Failed to extract appearance ref for: "+s)}return a},e.prototype.findOrCreateNonTerminals=function(t){for(var n=[this.acroForm],r=0,a=t.length;r<a;r++){var o=t[r];if(!o)throw new xut(o);var i=n[0],s=n[1],u=this.findNonTerminal(o,i);if(u)n=u;else{var c=RP.create(this.doc.context);c.setPartialName(o),c.setParent(s);var f=this.doc.context.register(c.dict);i.addField(f),n=[c,f]}}return n},e.prototype.findNonTerminal=function(t,n){for(var r=n instanceof NP?this.acroForm.getFields():Vj(n.Kids()),a=0,o=r.length;a<o;a++){var i=r[a],s=i[0],u=i[1];if(s.getPartialName()===t){if(s instanceof RP)return[s,u];throw new Fxe(t)}}},e.of=function(t,n){return new e(t,n)},e}(),Xut=function(e,t,n){if(e instanceof SP)return HP.of(e,t,n);if(e instanceof bP)return B5.of(e,t,n);if(e instanceof AP)return YP.of(e,t,n);if(e instanceof MP)return ZP.of(e,t,n);if(e instanceof xP)return KP.of(e,t,n);if(e instanceof wP)return X5.of(e,t,n);if(e instanceof Fj)return qj.of(e,t,n)},nx=function(e){if(e.length===0)throw new Error("PDF field names must not be empty strings");for(var t=e.split("."),n=0,r=t.length;n<r;n++)if(t[n]==="")throw new Error('Periods in PDF field names must be separated by at least one character: "'+e+'"');return t.length===1?{nonTerminal:[],terminal:t[0]}:{nonTerminal:t.slice(0,t.length-1),terminal:t[t.length-1]}},rx=function(e,t,n){for(var r=e[0],a=e[1],o=t[0],i=t[1],s=r.normalizedEntries(),u=Vj("Kids"in s?s.Kids:s.Fields),c=0,f=u.length;c<f;c++)if(u[c][0].getPartialName()===n)throw new Fxe(n);r.addField(i),o.setParent(a)},Uut={A4:[595.28,841.89]},$j;(function(e){e[e.Fastest=1/0]="Fastest",e[e.Fast=1500]="Fast",e[e.Medium=500]="Medium",e[e.Slow=100]="Slow"})($j||($j={}));var Wut=function(){function e(t,n,r){this.alreadyEmbedded=!1,this.ref=t,this.doc=n,this.embedder=r}return e.prototype.embed=function(){return Kn(this,void 0,void 0,function(){var t,n,r,a,o;return Qn(this,function(i){switch(i.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:t=i.sent(),this.doc.catalog.has(Se.of("Names"))||this.doc.catalog.set(Se.of("Names"),this.doc.context.obj({})),n=this.doc.catalog.lookup(Se.of("Names"),Dn),n.has(Se.of("EmbeddedFiles"))||n.set(Se.of("EmbeddedFiles"),this.doc.context.obj({})),r=n.lookup(Se.of("EmbeddedFiles"),Dn),r.has(Se.of("Names"))||r.set(Se.of("Names"),this.doc.context.obj([])),a=r.lookup(Se.of("Names"),Pr),a.push(vn.fromText(this.embedder.fileName)),a.push(t),this.doc.catalog.has(Se.of("AF"))||this.doc.catalog.set(Se.of("AF"),this.doc.context.obj([])),o=this.doc.catalog.lookup(Se.of("AF"),Pr),o.push(t),this.alreadyEmbedded=!0,i.label=2;case 2:return[2]}})})},e.of=function(t,n,r){return new e(t,n,r)},e}(),Yut=function(){function e(t,n,r){this.alreadyEmbedded=!1,this.ref=t,this.doc=n,this.embedder=r}return e.prototype.embed=function(){return Kn(this,void 0,void 0,function(){var t,n,r,a,o,i,s;return Qn(this,function(u){switch(u.label){case 0:return this.alreadyEmbedded?[3,2]:(t=this.doc,n=t.catalog,r=t.context,[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]);case 1:a=u.sent(),n.has(Se.of("Names"))||n.set(Se.of("Names"),r.obj({})),o=n.lookup(Se.of("Names"),Dn),o.has(Se.of("JavaScript"))||o.set(Se.of("JavaScript"),r.obj({})),i=o.lookup(Se.of("JavaScript"),Dn),i.has(Se.of("Names"))||i.set(Se.of("Names"),r.obj([])),s=i.lookup(Se.of("Names"),Pr),s.push(vn.fromText(this.embedder.scriptName)),s.push(a),this.alreadyEmbedded=!0,u.label=2;case 2:return[2]}})})},e.of=function(t,n,r){return new e(t,n,r)},e}(),Zut=function(){function e(t,n){this.script=t,this.scriptName=n}return e.for=function(t,n){return new e(t,n)},e.prototype.embedIntoContext=function(t,n){return Kn(this,void 0,void 0,function(){var r;return Qn(this,function(a){return r=t.obj({Type:"Action",S:"JavaScript",JS:vn.fromText(this.script)}),n?(t.assign(n,r),[2,n]):[2,t.register(r)]})})},e}(),gm=function(){function e(t,n,r){var a=this;if(this.defaultWordBreaks=[" "],this.computePages=function(){var o=[];return a.catalog.Pages().traverse(function(i,s){if(i instanceof zp){var u=a.pageMap.get(i);u||(u=xu.of(i,s,a),a.pageMap.set(i,u)),o.push(u)}}),o},this.getOrCreateForm=function(){var o=a.catalog.getOrCreateAcroForm();return But.of(o,a)},He(t,"context",[[Cj,"PDFContext"]]),He(n,"ignoreEncryption",["boolean"]),this.context=t,this.catalog=t.lookup(t.trailerInfo.Root),this.isEncrypted=!!t.lookup(t.trailerInfo.Encrypt),this.pageCache=Qp.populatedBy(this.computePages),this.pageMap=new Map,this.formCache=Qp.populatedBy(this.getOrCreateForm),this.fonts=[],this.images=[],this.embeddedPages=[],this.embeddedFiles=[],this.javaScripts=[],!n&&this.isEncrypted)throw new gut;r&&this.updateInfoDict()}return e.load=function(t,n){return n===void 0&&(n={}),Kn(this,void 0,void 0,function(){var r,a,o,i,s,u,c,f,d,h,p,v;return Qn(this,function(m){switch(m.label){case 0:return r=n.ignoreEncryption,a=r===void 0?!1:r,o=n.parseSpeed,i=o===void 0?$j.Slow:o,s=n.throwOnInvalidObject,u=s===void 0?!1:s,c=n.updateMetadata,f=c===void 0?!0:c,d=n.capNumbers,h=d===void 0?!1:d,He(t,"pdf",["string",Uint8Array,ArrayBuffer]),He(a,"ignoreEncryption",["boolean"]),He(i,"parseSpeed",["number"]),He(u,"throwOnInvalidObject",["boolean"]),p=qM(t),[4,Qct.forBytesWithOptions(p,i,u,h).parseDocument()];case 1:return v=m.sent(),[2,new e(v,a,f)]}})})},e.create=function(t){return t===void 0&&(t={}),Kn(this,void 0,void 0,function(){var n,r,a,o,i,s;return Qn(this,function(u){return n=t.updateMetadata,r=n===void 0?!0:n,a=Cj.create(),o=cxe.withContext(a),i=a.register(o),s=lxe.withContextAndPages(a,i),a.trailerInfo.Root=a.register(s),[2,new e(a,!1,r)]})})},e.prototype.registerFontkit=function(t){this.fontkit=t},e.prototype.getForm=function(){var t=this.formCache.access();return t.hasXFA()&&(console.warn("Removing XFA form data as pdf-lib does not support reading or writing XFA"),t.deleteXFA()),t},e.prototype.getTitle=function(){var t=this.getInfoDict().lookup(Se.Title);if(t)return ym(t),t.decodeText()},e.prototype.getAuthor=function(){var t=this.getInfoDict().lookup(Se.Author);if(t)return ym(t),t.decodeText()},e.prototype.getSubject=function(){var t=this.getInfoDict().lookup(Se.Subject);if(t)return ym(t),t.decodeText()},e.prototype.getKeywords=function(){var t=this.getInfoDict().lookup(Se.Keywords);if(t)return ym(t),t.decodeText()},e.prototype.getCreator=function(){var t=this.getInfoDict().lookup(Se.Creator);if(t)return ym(t),t.decodeText()},e.prototype.getProducer=function(){var t=this.getInfoDict().lookup(Se.Producer);if(t)return ym(t),t.decodeText()},e.prototype.getCreationDate=function(){var t=this.getInfoDict().lookup(Se.CreationDate);if(t)return ym(t),t.decodeDate()},e.prototype.getModificationDate=function(){var t=this.getInfoDict().lookup(Se.ModDate);if(t)return ym(t),t.decodeDate()},e.prototype.setTitle=function(t,n){He(t,"title",["string"]);var r=Se.of("Title");if(this.getInfoDict().set(r,vn.fromText(t)),n!=null&&n.showInWindowTitleBar){var a=this.catalog.getOrCreateViewerPreferences();a.setDisplayDocTitle(!0)}},e.prototype.setAuthor=function(t){He(t,"author",["string"]);var n=Se.of("Author");this.getInfoDict().set(n,vn.fromText(t))},e.prototype.setSubject=function(t){He(t,"author",["string"]);var n=Se.of("Subject");this.getInfoDict().set(n,vn.fromText(t))},e.prototype.setKeywords=function(t){He(t,"keywords",[Array]);var n=Se.of("Keywords");this.getInfoDict().set(n,vn.fromText(t.join(" ")))},e.prototype.setCreator=function(t){He(t,"creator",["string"]);var n=Se.of("Creator");this.getInfoDict().set(n,vn.fromText(t))},e.prototype.setProducer=function(t){He(t,"creator",["string"]);var n=Se.of("Producer");this.getInfoDict().set(n,vn.fromText(t))},e.prototype.setLanguage=function(t){He(t,"language",["string"]);var n=Se.of("Lang");this.catalog.set(n,Qr.of(t))},e.prototype.setCreationDate=function(t){He(t,"creationDate",[[Date,"Date"]]);var n=Se.of("CreationDate");this.getInfoDict().set(n,Qr.fromDate(t))},e.prototype.setModificationDate=function(t){He(t,"modificationDate",[[Date,"Date"]]);var n=Se.of("ModDate");this.getInfoDict().set(n,Qr.fromDate(t))},e.prototype.getPageCount=function(){return this.pageCount===void 0&&(this.pageCount=this.getPages().length),this.pageCount},e.prototype.getPages=function(){return this.pageCache.access()},e.prototype.getPage=function(t){var n=this.getPages();return uc(t,"index",0,n.length-1),n[t]},e.prototype.getPageIndices=function(){return Nit(0,this.getPageCount())},e.prototype.removePage=function(t){var n=this.getPageCount();if(this.pageCount===0)throw new Aut;uc(t,"index",0,n-1),this.catalog.removeLeafNode(t),this.pageCount=n-1},e.prototype.addPage=function(t){return He(t,"page",["undefined",[xu,"PDFPage"],Array]),this.insertPage(this.getPageCount(),t)},e.prototype.insertPage=function(t,n){var r=this.getPageCount();if(uc(t,"index",0,r),He(n,"page",["undefined",[xu,"PDFPage"],Array]),!n||Array.isArray(n)){var a=Array.isArray(n)?n:Uut.A4;n=xu.create(this),n.setSize.apply(n,a)}else if(n.doc!==this)throw new but;var o=this.catalog.insertLeafNode(n.ref,t);return n.node.setParent(o),this.pageMap.set(n.node,n),this.pageCache.invalidate(),this.pageCount=r+1,n},e.prototype.copyPages=function(t,n){return Kn(this,void 0,void 0,function(){var r,a,o,i,s,u,c,f;return Qn(this,function(d){switch(d.label){case 0:return He(t,"srcDoc",[[e,"PDFDocument"]]),He(n,"indices",[Array]),[4,t.flush()];case 1:for(d.sent(),r=WRe.for(t.context,this.context),a=t.getPages(),o=new Array(n.length),i=0,s=n.length;i<s;i++)u=a[n[i]],c=r.copy(u.node),f=this.context.register(c),o[i]=xu.of(c,f,this);return[2,o]}})})},e.prototype.copy=function(){return Kn(this,void 0,void 0,function(){var t,n,r,a;return Qn(this,function(o){switch(o.label){case 0:return[4,e.create()];case 1:return t=o.sent(),[4,t.copyPages(this,this.getPageIndices())];case 2:for(n=o.sent(),r=0,a=n.length;r<a;r++)t.addPage(n[r]);return this.getAuthor()!==void 0&&t.setAuthor(this.getAuthor()),this.getCreationDate()!==void 0&&t.setCreationDate(this.getCreationDate()),this.getCreator()!==void 0&&t.setCreator(this.getCreator()),this.getModificationDate()!==void 0&&t.setModificationDate(this.getModificationDate()),this.getProducer()!==void 0&&t.setProducer(this.getProducer()),this.getSubject()!==void 0&&t.setSubject(this.getSubject()),this.getTitle()!==void 0&&t.setTitle(this.getTitle()),t.defaultWordBreaks=this.defaultWordBreaks,[2,t]}})})},e.prototype.addJavaScript=function(t,n){He(t,"name",["string"]),He(n,"script",["string"]);var r=Zut.for(n,t),a=this.context.nextRef(),o=Yut.of(a,this,r);this.javaScripts.push(o)},e.prototype.attach=function(t,n,r){return r===void 0&&(r={}),Kn(this,void 0,void 0,function(){var a,o,i,s;return Qn(this,function(u){return He(t,"attachment",["string",Uint8Array,ArrayBuffer]),He(n,"name",["string"]),Mt(r.mimeType,"mimeType",["string"]),Mt(r.description,"description",["string"]),Mt(r.creationDate,"options.creationDate",[Date]),Mt(r.modificationDate,"options.modificationDate",[Date]),vu(r.afRelationship,"options.afRelationship",Oj),a=qM(t),o=yct.for(a,n,r),i=this.context.nextRef(),s=Wut.of(i,this,o),this.embeddedFiles.push(s),[2]})})},e.prototype.embedFont=function(t,n){return n===void 0&&(n={}),Kn(this,void 0,void 0,function(){var r,a,o,i,s,u,c,f,d,h;return Qn(this,function(p){switch(p.label){case 0:return r=n.subset,a=r===void 0?!1:r,o=n.customName,i=n.features,He(t,"font",["string",Uint8Array,ArrayBuffer]),He(a,"subset",["boolean"]),LRe(t)?(s=vP.for(t,o),[3,7]):[3,1];case 1:return Cit(t)?(u=qM(t),c=this.assertFontkit(),a?[4,gct.for(c,u,o,i)]:[3,3]):[3,6];case 2:return f=p.sent(),[3,5];case 3:return[4,kj.for(c,u,o,i)];case 4:f=p.sent(),p.label=5;case 5:return s=f,[3,7];case 6:throw new TypeError("`font` must be one of `StandardFonts | string | Uint8Array | ArrayBuffer`");case 7:return d=this.context.nextRef(),h=hc.of(d,this,s),this.fonts.push(h),[2,h]}})})},e.prototype.embedStandardFont=function(t,n){if(He(t,"font",["string"]),!LRe(t))throw new TypeError("`font` must be one of type `StandardFonts`");var r=vP.for(t,n),a=this.context.nextRef(),o=hc.of(a,this,r);return this.fonts.push(o),o},e.prototype.embedJpg=function(t){return Kn(this,void 0,void 0,function(){var n,r,a,o;return Qn(this,function(i){switch(i.label){case 0:return He(t,"jpg",["string",Uint8Array,ArrayBuffer]),n=qM(t),[4,GRe.for(n)];case 1:return r=i.sent(),a=this.context.nextRef(),o=jj.of(a,this,r),this.images.push(o),[2,o]}})})},e.prototype.embedPng=function(t){return Kn(this,void 0,void 0,function(){var n,r,a,o;return Qn(this,function(i){switch(i.label){case 0:return He(t,"png",["string",Uint8Array,ArrayBuffer]),n=qM(t),[4,JRe.for(n)];case 1:return r=i.sent(),a=this.context.nextRef(),o=jj.of(a,this,r),this.images.push(o),[2,o]}})})},e.prototype.embedPdf=function(t,n){return n===void 0&&(n=[0]),Kn(this,void 0,void 0,function(){var r,a,o;return Qn(this,function(i){switch(i.label){case 0:return He(t,"pdf",["string",Uint8Array,ArrayBuffer,[e,"PDFDocument"]]),He(n,"indices",[Array]),t instanceof e?(a=t,[3,3]):[3,1];case 1:return[4,e.load(t)];case 2:a=i.sent(),i.label=3;case 3:return r=a,o=Tit(r.getPages(),n),[2,this.embedPages(o)]}})})},e.prototype.embedPage=function(t,n,r){return Kn(this,void 0,void 0,function(){var a;return Qn(this,function(o){switch(o.label){case 0:return He(t,"page",[[xu,"PDFPage"]]),[4,this.embedPages([t],[n],[r])];case 1:return a=o.sent()[0],[2,a]}})})},e.prototype.embedPages=function(t,n,r){return n===void 0&&(n=[]),r===void 0&&(r=[]),Kn(this,void 0,void 0,function(){var c,f,a,o,i,s,u,c,f,d,h,p,v,m,g;return Qn(this,function(y){switch(y.label){case 0:if(t.length===0)return[2,[]];for(c=0,f=t.length-1;c<f;c++)if(a=t[c],o=t[c+1],a.node.context!==o.node.context)throw new Zlt;i=t[0].node.context,s=i===this.context?function(b){return b}:WRe.for(i,this.context).copy,u=new Array(t.length),c=0,f=t.length,y.label=1;case 1:return c<f?(d=s(t[c].node),h=n[c],p=r[c],[4,nxe.for(d,h,p)]):[3,4];case 2:v=y.sent(),m=this.context.nextRef(),u[c]=Uxe.of(m,this,v),y.label=3;case 3:return c++,[3,1];case 4:return(g=this.embeddedPages).push.apply(g,u),[2,u]}})})},e.prototype.flush=function(){return Kn(this,void 0,void 0,function(){return Qn(this,function(t){switch(t.label){case 0:return[4,this.embedAll(this.fonts)];case 1:return t.sent(),[4,this.embedAll(this.images)];case 2:return t.sent(),[4,this.embedAll(this.embeddedPages)];case 3:return t.sent(),[4,this.embedAll(this.embeddedFiles)];case 4:return t.sent(),[4,this.embedAll(this.javaScripts)];case 5:return t.sent(),[2]}})})},e.prototype.save=function(t){return t===void 0&&(t={}),Kn(this,void 0,void 0,function(){var n,r,a,o,i,s,u,c,f,d;return Qn(this,function(h){switch(h.label){case 0:return n=t.useObjectStreams,r=n===void 0?!0:n,a=t.addDefaultPage,o=a===void 0?!0:a,i=t.objectsPerTick,s=i===void 0?50:i,u=t.updateFieldAppearances,c=u===void 0?!0:u,He(r,"useObjectStreams",["boolean"]),He(o,"addDefaultPage",["boolean"]),He(s,"objectsPerTick",["number"]),He(c,"updateFieldAppearances",["boolean"]),o&&this.getPageCount()===0&&this.addPage(),c&&(f=this.formCache.getValue(),f&&f.updateFieldAppearances()),[4,this.flush()];case 1:return h.sent(),d=r?fct:KRe,[2,d.forContext(this.context,s).serializeToBuffer()]}})})},e.prototype.saveAsBase64=function(t){return t===void 0&&(t={}),Kn(this,void 0,void 0,function(){var n,r,a,o,i;return Qn(this,function(s){switch(s.label){case 0:return n=t.dataUri,r=n===void 0?!1:n,a=cit(t,["dataUri"]),He(r,"dataUri",["boolean"]),[4,this.save(a)];case 1:return o=s.sent(),i=uit(o),[2,r?"data:application/pdf;base64,"+i:i]}})})},e.prototype.findPageForAnnotationRef=function(t){for(var n=this.getPages(),r=0,a=n.length;r<a;r++){var o=n[r],i=o.node.Annots();if((i==null?void 0:i.indexOf(t))!==void 0)return o}},e.prototype.embedAll=function(t){return Kn(this,void 0,void 0,function(){var n,r;return Qn(this,function(a){switch(a.label){case 0:n=0,r=t.length,a.label=1;case 1:return n<r?[4,t[n].embed()]:[3,4];case 2:a.sent(),a.label=3;case 3:return n++,[3,1];case 4:return[2]}})})},e.prototype.updateInfoDict=function(){var t="pdf-lib (https://github.com/Hopding/pdf-lib)",n=new Date,r=this.getInfoDict();this.setProducer(t),this.setModificationDate(n),r.get(Se.of("Creator"))||this.setCreator(t),r.get(Se.of("CreationDate"))||this.setCreationDate(n)},e.prototype.getInfoDict=function(){var t=this.context.lookup(this.context.trailerInfo.Info);if(t instanceof Dn)return t;var n=this.context.obj({});return this.context.trailerInfo.Info=this.context.register(n),n},e.prototype.assertFontkit=function(){if(!this.fontkit)throw new yut;return this.fontkit},e}();function ym(e){if(!(e instanceof vn)&&!(e instanceof Qr))throw new dP([vn,Qr],e)}var Jp;(function(e){e.Normal="Normal",e.Multiply="Multiply",e.Screen="Screen",e.Overlay="Overlay",e.Darken="Darken",e.Lighten="Lighten",e.ColorDodge="ColorDodge",e.ColorBurn="ColorBurn",e.HardLight="HardLight",e.SoftLight="SoftLight",e.Difference="Difference",e.Exclusion="Exclusion"})(Jp||(Jp={}));var xu=function(){function e(t,n,r){this.fontSize=24,this.fontColor=zr(0,0,0),this.lineHeight=24,this.x=0,this.y=0,He(t,"leafNode",[[zp,"PDFPageLeaf"]]),He(n,"ref",[[Kr,"PDFRef"]]),He(r,"doc",[[gm,"PDFDocument"]]),this.node=t,this.ref=n,this.doc=r}return e.prototype.setRotation=function(t){var n=mxe(t);ERe(n,"degreesAngle",90),this.node.set(Se.of("Rotate"),this.doc.context.obj(n))},e.prototype.getRotation=function(){var t=this.node.Rotate();return bn(t?t.asNumber():0)},e.prototype.setSize=function(t,n){He(t,"width",["number"]),He(n,"height",["number"]);var r=this.getMediaBox();this.setMediaBox(r.x,r.y,t,n);var a=this.getCropBox(),o=this.getBleedBox(),i=this.getTrimBox(),s=this.getArtBox(),u=this.node.CropBox(),c=this.node.BleedBox(),f=this.node.TrimBox(),d=this.node.ArtBox();u&&cP(a,r)&&this.setCropBox(r.x,r.y,t,n),c&&cP(o,r)&&this.setBleedBox(r.x,r.y,t,n),f&&cP(i,r)&&this.setTrimBox(r.x,r.y,t,n),d&&cP(s,r)&&this.setArtBox(r.x,r.y,t,n)},e.prototype.setWidth=function(t){He(t,"width",["number"]),this.setSize(t,this.getSize().height)},e.prototype.setHeight=function(t){He(t,"height",["number"]),this.setSize(this.getSize().width,t)},e.prototype.setMediaBox=function(t,n,r,a){He(t,"x",["number"]),He(n,"y",["number"]),He(r,"width",["number"]),He(a,"height",["number"]);var o=this.doc.context.obj([t,n,t+r,n+a]);this.node.set(Se.MediaBox,o)},e.prototype.setCropBox=function(t,n,r,a){He(t,"x",["number"]),He(n,"y",["number"]),He(r,"width",["number"]),He(a,"height",["number"]);var o=this.doc.context.obj([t,n,t+r,n+a]);this.node.set(Se.CropBox,o)},e.prototype.setBleedBox=function(t,n,r,a){He(t,"x",["number"]),He(n,"y",["number"]),He(r,"width",["number"]),He(a,"height",["number"]);var o=this.doc.context.obj([t,n,t+r,n+a]);this.node.set(Se.BleedBox,o)},e.prototype.setTrimBox=function(t,n,r,a){He(t,"x",["number"]),He(n,"y",["number"]),He(r,"width",["number"]),He(a,"height",["number"]);var o=this.doc.context.obj([t,n,t+r,n+a]);this.node.set(Se.TrimBox,o)},e.prototype.setArtBox=function(t,n,r,a){He(t,"x",["number"]),He(n,"y",["number"]),He(r,"width",["number"]),He(a,"height",["number"]);var o=this.doc.context.obj([t,n,t+r,n+a]);this.node.set(Se.ArtBox,o)},e.prototype.getSize=function(){var t=this.getMediaBox(),n=t.width,r=t.height;return{width:n,height:r}},e.prototype.getWidth=function(){return this.getSize().width},e.prototype.getHeight=function(){return this.getSize().height},e.prototype.getMediaBox=function(){var t=this.node.MediaBox();return t.asRectangle()},e.prototype.getCropBox=function(){var t,n=this.node.CropBox();return(t=n==null?void 0:n.asRectangle())!==null&&t!==void 0?t:this.getMediaBox()},e.prototype.getBleedBox=function(){var t,n=this.node.BleedBox();return(t=n==null?void 0:n.asRectangle())!==null&&t!==void 0?t:this.getCropBox()},e.prototype.getTrimBox=function(){var t,n=this.node.TrimBox();return(t=n==null?void 0:n.asRectangle())!==null&&t!==void 0?t:this.getCropBox()},e.prototype.getArtBox=function(){var t,n=this.node.ArtBox();return(t=n==null?void 0:n.asRectangle())!==null&&t!==void 0?t:this.getCropBox()},e.prototype.translateContent=function(t,n){He(t,"x",["number"]),He(n,"y",["number"]),this.node.normalize(),this.getContentStream();var r=this.createContentStream(Vo(),bu(t,n)),a=this.doc.context.register(r),o=this.createContentStream(Do()),i=this.doc.context.register(o);this.node.wrapContentStreams(a,i)},e.prototype.scale=function(t,n){He(t,"x",["number"]),He(n,"y",["number"]),this.setSize(this.getWidth()*t,this.getHeight()*n),this.scaleContent(t,n),this.scaleAnnotations(t,n)},e.prototype.scaleContent=function(t,n){He(t,"x",["number"]),He(n,"y",["number"]),this.node.normalize(),this.getContentStream();var r=this.createContentStream(Vo(),P5(t,n)),a=this.doc.context.register(r),o=this.createContentStream(Do()),i=this.doc.context.register(o);this.node.wrapContentStreams(a,i)},e.prototype.scaleAnnotations=function(t,n){He(t,"x",["number"]),He(n,"y",["number"]);var r=this.node.Annots();if(r)for(var a=0;a<r.size();a++){var o=r.lookup(a);o instanceof Dn&&this.scaleAnnot(o,t,n)}},e.prototype.resetPosition=function(){this.getContentStream(!1),this.x=0,this.y=0},e.prototype.setFont=function(t){He(t,"font",[[hc,"PDFFont"]]),this.font=t,this.fontKey=this.node.newFontDictionary(this.font.name,this.font.ref)},e.prototype.setFontSize=function(t){He(t,"fontSize",["number"]),this.fontSize=t},e.prototype.setFontColor=function(t){He(t,"fontColor",[[Object,"Color"]]),this.fontColor=t},e.prototype.setLineHeight=function(t){He(t,"lineHeight",["number"]),this.lineHeight=t},e.prototype.getPosition=function(){return{x:this.x,y:this.y}},e.prototype.getX=function(){return this.x},e.prototype.getY=function(){return this.y},e.prototype.moveTo=function(t,n){He(t,"x",["number"]),He(n,"y",["number"]),this.x=t,this.y=n},e.prototype.moveDown=function(t){He(t,"yDecrease",["number"]),this.y-=t},e.prototype.moveUp=function(t){He(t,"yIncrease",["number"]),this.y+=t},e.prototype.moveLeft=function(t){He(t,"xDecrease",["number"]),this.x-=t},e.prototype.moveRight=function(t){He(t,"xIncrease",["number"]),this.x+=t},e.prototype.pushOperators=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];ORe(t,"operator",[[hr,"PDFOperator"]]);var r=this.getContentStream();r.push.apply(r,t)},e.prototype.drawText=function(t,n){var r,a,o,i,s,u,c;n===void 0&&(n={}),He(t,"text",["string"]),Mt(n.color,"options.color",[[Object,"Color"]]),If(n.opacity,"opacity.opacity",0,1),Mt(n.font,"options.font",[[hc,"PDFFont"]]),Mt(n.size,"options.size",["number"]),Mt(n.rotate,"options.rotate",[[Object,"Rotation"]]),Mt(n.xSkew,"options.xSkew",[[Object,"Rotation"]]),Mt(n.ySkew,"options.ySkew",[[Object,"Rotation"]]),Mt(n.x,"options.x",["number"]),Mt(n.y,"options.y",["number"]),Mt(n.lineHeight,"options.lineHeight",["number"]),Mt(n.maxWidth,"options.maxWidth",["number"]),Mt(n.wordBreaks,"options.wordBreaks",[Array]),vu(n.blendMode,"options.blendMode",Jp);for(var f=this.setOrEmbedFont(n.font),d=f.oldFont,h=f.newFont,p=f.newFontKey,v=n.size||this.fontSize,m=n.wordBreaks||this.doc.defaultWordBreaks,g=function(M){return h.widthOfTextAtSize(M,v)},y=n.maxWidth===void 0?Dbe(jM(t)):bit(t,m,n.maxWidth,g),b=new Array(y.length),R=0,A=y.length;R<A;R++)b[R]=h.encodeText(y[R]);var S=this.maybeEmbedGraphicsState({opacity:n.opacity,blendMode:n.blendMode}),w=this.getContentStream();w.push.apply(w,cut(b,{color:(r=n.color)!==null&&r!==void 0?r:this.fontColor,font:p,size:v,rotate:(a=n.rotate)!==null&&a!==void 0?a:bn(0),xSkew:(o=n.xSkew)!==null&&o!==void 0?o:bn(0),ySkew:(i=n.ySkew)!==null&&i!==void 0?i:bn(0),x:(s=n.x)!==null&&s!==void 0?s:this.x,y:(u=n.y)!==null&&u!==void 0?u:this.y,lineHeight:(c=n.lineHeight)!==null&&c!==void 0?c:this.lineHeight,graphicsState:S})),n.font&&(d?this.setFont(d):this.resetFont())},e.prototype.drawImage=function(t,n){var r,a,o,i,s,u,c;n===void 0&&(n={}),He(t,"image",[[jj,"PDFImage"]]),Mt(n.x,"options.x",["number"]),Mt(n.y,"options.y",["number"]),Mt(n.width,"options.width",["number"]),Mt(n.height,"options.height",["number"]),Mt(n.rotate,"options.rotate",[[Object,"Rotation"]]),Mt(n.xSkew,"options.xSkew",[[Object,"Rotation"]]),Mt(n.ySkew,"options.ySkew",[[Object,"Rotation"]]),If(n.opacity,"opacity.opacity",0,1),vu(n.blendMode,"options.blendMode",Jp);var f=this.node.newXObject("Image",t.ref),d=this.maybeEmbedGraphicsState({opacity:n.opacity,blendMode:n.blendMode}),h=this.getContentStream();h.push.apply(h,Pxe(f,{x:(r=n.x)!==null&&r!==void 0?r:this.x,y:(a=n.y)!==null&&a!==void 0?a:this.y,width:(o=n.width)!==null&&o!==void 0?o:t.size().width,height:(i=n.height)!==null&&i!==void 0?i:t.size().height,rotate:(s=n.rotate)!==null&&s!==void 0?s:bn(0),xSkew:(u=n.xSkew)!==null&&u!==void 0?u:bn(0),ySkew:(c=n.ySkew)!==null&&c!==void 0?c:bn(0),graphicsState:d}))},e.prototype.drawPage=function(t,n){var r,a,o,i,s;n===void 0&&(n={}),He(t,"embeddedPage",[[Uxe,"PDFEmbeddedPage"]]),Mt(n.x,"options.x",["number"]),Mt(n.y,"options.y",["number"]),Mt(n.xScale,"options.xScale",["number"]),Mt(n.yScale,"options.yScale",["number"]),Mt(n.width,"options.width",["number"]),Mt(n.height,"options.height",["number"]),Mt(n.rotate,"options.rotate",[[Object,"Rotation"]]),Mt(n.xSkew,"options.xSkew",[[Object,"Rotation"]]),Mt(n.ySkew,"options.ySkew",[[Object,"Rotation"]]),If(n.opacity,"opacity.opacity",0,1),vu(n.blendMode,"options.blendMode",Jp);var u=this.node.newXObject("EmbeddedPdfPage",t.ref),c=this.maybeEmbedGraphicsState({opacity:n.opacity,blendMode:n.blendMode}),f=n.width!==void 0?n.width/t.width:n.xScale!==void 0?n.xScale:1,d=n.height!==void 0?n.height/t.height:n.yScale!==void 0?n.yScale:1,h=this.getContentStream();h.push.apply(h,uut(u,{x:(r=n.x)!==null&&r!==void 0?r:this.x,y:(a=n.y)!==null&&a!==void 0?a:this.y,xScale:f,yScale:d,rotate:(o=n.rotate)!==null&&o!==void 0?o:bn(0),xSkew:(i=n.xSkew)!==null&&i!==void 0?i:bn(0),ySkew:(s=n.ySkew)!==null&&s!==void 0?s:bn(0),graphicsState:c}))},e.prototype.drawSvgPath=function(t,n){var r,a,o,i,s,u,c,f,d;n===void 0&&(n={}),He(t,"path",["string"]),Mt(n.x,"options.x",["number"]),Mt(n.y,"options.y",["number"]),Mt(n.scale,"options.scale",["number"]),Mt(n.rotate,"options.rotate",[[Object,"Rotation"]]),Mt(n.borderWidth,"options.borderWidth",["number"]),Mt(n.color,"options.color",[[Object,"Color"]]),If(n.opacity,"opacity.opacity",0,1),Mt(n.borderColor,"options.borderColor",[[Object,"Color"]]),Mt(n.borderDashArray,"options.borderDashArray",[Array]),Mt(n.borderDashPhase,"options.borderDashPhase",["number"]),vu(n.borderLineCap,"options.borderLineCap",qR),If(n.borderOpacity,"options.borderOpacity",0,1),vu(n.blendMode,"options.blendMode",Jp);var h=this.maybeEmbedGraphicsState({opacity:n.opacity,borderOpacity:n.borderOpacity,blendMode:n.blendMode});!("color"in n)&&!("borderColor"in n)&&(n.borderColor=zr(0,0,0));var p=this.getContentStream();p.push.apply(p,put(t,{x:(r=n.x)!==null&&r!==void 0?r:this.x,y:(a=n.y)!==null&&a!==void 0?a:this.y,scale:n.scale,rotate:(o=n.rotate)!==null&&o!==void 0?o:bn(0),color:(i=n.color)!==null&&i!==void 0?i:void 0,borderColor:(s=n.borderColor)!==null&&s!==void 0?s:void 0,borderWidth:(u=n.borderWidth)!==null&&u!==void 0?u:0,borderDashArray:(c=n.borderDashArray)!==null&&c!==void 0?c:void 0,borderDashPhase:(f=n.borderDashPhase)!==null&&f!==void 0?f:void 0,borderLineCap:(d=n.borderLineCap)!==null&&d!==void 0?d:void 0,graphicsState:h}))},e.prototype.drawLine=function(t){var n,r,a,o,i;He(t.start,"options.start",[[Object,"{ x: number, y: number }"]]),He(t.end,"options.end",[[Object,"{ x: number, y: number }"]]),He(t.start.x,"options.start.x",["number"]),He(t.start.y,"options.start.y",["number"]),He(t.end.x,"options.end.x",["number"]),He(t.end.y,"options.end.y",["number"]),Mt(t.thickness,"options.thickness",["number"]),Mt(t.color,"options.color",[[Object,"Color"]]),Mt(t.dashArray,"options.dashArray",[Array]),Mt(t.dashPhase,"options.dashPhase",["number"]),vu(t.lineCap,"options.lineCap",qR),If(t.opacity,"opacity.opacity",0,1),vu(t.blendMode,"options.blendMode",Jp);var s=this.maybeEmbedGraphicsState({borderOpacity:t.opacity,blendMode:t.blendMode});"color"in t||(t.color=zr(0,0,0));var u=this.getContentStream();u.push.apply(u,fut({start:t.start,end:t.end,thickness:(n=t.thickness)!==null&&n!==void 0?n:1,color:(r=t.color)!==null&&r!==void 0?r:void 0,dashArray:(a=t.dashArray)!==null&&a!==void 0?a:void 0,dashPhase:(o=t.dashPhase)!==null&&o!==void 0?o:void 0,lineCap:(i=t.lineCap)!==null&&i!==void 0?i:void 0,graphicsState:s}))},e.prototype.drawRectangle=function(t){var n,r,a,o,i,s,u,c,f,d,h,p,v;t===void 0&&(t={}),Mt(t.x,"options.x",["number"]),Mt(t.y,"options.y",["number"]),Mt(t.width,"options.width",["number"]),Mt(t.height,"options.height",["number"]),Mt(t.rotate,"options.rotate",[[Object,"Rotation"]]),Mt(t.xSkew,"options.xSkew",[[Object,"Rotation"]]),Mt(t.ySkew,"options.ySkew",[[Object,"Rotation"]]),Mt(t.borderWidth,"options.borderWidth",["number"]),Mt(t.color,"options.color",[[Object,"Color"]]),If(t.opacity,"opacity.opacity",0,1),Mt(t.borderColor,"options.borderColor",[[Object,"Color"]]),Mt(t.borderDashArray,"options.borderDashArray",[Array]),Mt(t.borderDashPhase,"options.borderDashPhase",["number"]),vu(t.borderLineCap,"options.borderLineCap",qR),If(t.borderOpacity,"options.borderOpacity",0,1),vu(t.blendMode,"options.blendMode",Jp);var m=this.maybeEmbedGraphicsState({opacity:t.opacity,borderOpacity:t.borderOpacity,blendMode:t.blendMode});!("color"in t)&&!("borderColor"in t)&&(t.color=zr(0,0,0));var g=this.getContentStream();g.push.apply(g,$R({x:(n=t.x)!==null&&n!==void 0?n:this.x,y:(r=t.y)!==null&&r!==void 0?r:this.y,width:(a=t.width)!==null&&a!==void 0?a:150,height:(o=t.height)!==null&&o!==void 0?o:100,rotate:(i=t.rotate)!==null&&i!==void 0?i:bn(0),xSkew:(s=t.xSkew)!==null&&s!==void 0?s:bn(0),ySkew:(u=t.ySkew)!==null&&u!==void 0?u:bn(0),borderWidth:(c=t.borderWidth)!==null&&c!==void 0?c:0,color:(f=t.color)!==null&&f!==void 0?f:void 0,borderColor:(d=t.borderColor)!==null&&d!==void 0?d:void 0,borderDashArray:(h=t.borderDashArray)!==null&&h!==void 0?h:void 0,borderDashPhase:(p=t.borderDashPhase)!==null&&p!==void 0?p:void 0,graphicsState:m,borderLineCap:(v=t.borderLineCap)!==null&&v!==void 0?v:void 0}))},e.prototype.drawSquare=function(t){t===void 0&&(t={});var n=t.size;Mt(n,"size",["number"]),this.drawRectangle(On(On({},t),{width:n,height:n}))},e.prototype.drawEllipse=function(t){var n,r,a,o,i,s,u,c,f,d,h;t===void 0&&(t={}),Mt(t.x,"options.x",["number"]),Mt(t.y,"options.y",["number"]),Mt(t.xScale,"options.xScale",["number"]),Mt(t.yScale,"options.yScale",["number"]),Mt(t.rotate,"options.rotate",[[Object,"Rotation"]]),Mt(t.color,"options.color",[[Object,"Color"]]),If(t.opacity,"opacity.opacity",0,1),Mt(t.borderColor,"options.borderColor",[[Object,"Color"]]),If(t.borderOpacity,"options.borderOpacity",0,1),Mt(t.borderWidth,"options.borderWidth",["number"]),Mt(t.borderDashArray,"options.borderDashArray",[Array]),Mt(t.borderDashPhase,"options.borderDashPhase",["number"]),vu(t.borderLineCap,"options.borderLineCap",qR),vu(t.blendMode,"options.blendMode",Jp);var p=this.maybeEmbedGraphicsState({opacity:t.opacity,borderOpacity:t.borderOpacity,blendMode:t.blendMode});!("color"in t)&&!("borderColor"in t)&&(t.color=zr(0,0,0));var v=this.getContentStream();v.push.apply(v,Gj({x:(n=t.x)!==null&&n!==void 0?n:this.x,y:(r=t.y)!==null&&r!==void 0?r:this.y,xScale:(a=t.xScale)!==null&&a!==void 0?a:100,yScale:(o=t.yScale)!==null&&o!==void 0?o:100,rotate:(i=t.rotate)!==null&&i!==void 0?i:void 0,color:(s=t.color)!==null&&s!==void 0?s:void 0,borderColor:(u=t.borderColor)!==null&&u!==void 0?u:void 0,borderWidth:(c=t.borderWidth)!==null&&c!==void 0?c:0,borderDashArray:(f=t.borderDashArray)!==null&&f!==void 0?f:void 0,borderDashPhase:(d=t.borderDashPhase)!==null&&d!==void 0?d:void 0,borderLineCap:(h=t.borderLineCap)!==null&&h!==void 0?h:void 0,graphicsState:p}))},e.prototype.drawCircle=function(t){t===void 0&&(t={});var n=t.size,r=n===void 0?100:n;Mt(r,"size",["number"]),this.drawEllipse(On(On({},t),{xScale:r,yScale:r}))},e.prototype.setOrEmbedFont=function(t){var n=this.font,r=this.fontKey;t?this.setFont(t):this.getFont();var a=this.font,o=this.fontKey;return{oldFont:n,oldFontKey:r,newFont:a,newFontKey:o}},e.prototype.getFont=function(){if(!this.font||!this.fontKey){var t=this.doc.embedStandardFont(QP.Helvetica);this.setFont(t)}return[this.font,this.fontKey]},e.prototype.resetFont=function(){this.font=void 0,this.fontKey=void 0},e.prototype.getContentStream=function(t){return t===void 0&&(t=!0),t&&this.contentStream?this.contentStream:(this.contentStream=this.createContentStream(),this.contentStreamRef=this.doc.context.register(this.contentStream),this.node.addContentStream(this.contentStreamRef),this.contentStream)},e.prototype.createContentStream=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this.doc.context.obj({}),a=x5.of(r,t);return a},e.prototype.maybeEmbedGraphicsState=function(t){var n=t.opacity,r=t.borderOpacity,a=t.blendMode;if(!(n===void 0&&r===void 0&&a===void 0)){var o=this.doc.context.obj({Type:"ExtGState",ca:n,CA:r,BM:a}),i=this.node.newExtGState("GS",o);return i}},e.prototype.scaleAnnot=function(t,n,r){for(var a=["RD","CL","Vertices","QuadPoints","L","Rect"],o=0,i=a.length;o<i;o++){var s=t.lookup(Se.of(a[o]));s instanceof Pr&&s.scalePDFNumbers(n,r)}var u=t.lookup(Se.of("InkList"));if(u instanceof Pr)for(var o=0,i=u.size();o<i;o++){var c=u.lookup(o);c instanceof Pr&&c.scalePDFNumbers(n,r)}},e.of=function(t,n,r){return new e(t,n,r)},e.create=function(t){He(t,"doc",[[gm,"PDFDocument"]]);var n=Kr.of(-1),r=zp.withContextAndParent(t.context,n),a=t.context.register(r);return new e(r,a,t)},e}(),HP=function(e){Nt(t,e);function t(n,r,a){var o=e.call(this,n,r,a)||this;return He(n,"acroButton",[[SP,"PDFAcroPushButton"]]),o.acroField=n,o}return t.prototype.setImage=function(n,r){r===void 0&&(r=mm.Center);for(var a=this.acroField.getWidgets(),o=0,i=a.length;o<i;o++){var s=a[o],u=this.createImageAppearanceStream(s,n,r);this.updateWidgetAppearances(s,{normal:u})}this.markAsClean()},t.prototype.setFontSize=function(n){uP(n,"fontSize"),this.acroField.setFontSize(n),this.markAsDirty()},t.prototype.addToPage=function(n,r,a){var o,i,s,u,c,f,d,h,p,v,m;Mt(n,"text",["string"]),Mt(r,"page",[[xu,"PDFPage"]]),tx(a);var g=this.createWidget({x:((o=a==null?void 0:a.x)!==null&&o!==void 0?o:0)-((i=a==null?void 0:a.borderWidth)!==null&&i!==void 0?i:0)/2,y:((s=a==null?void 0:a.y)!==null&&s!==void 0?s:0)-((u=a==null?void 0:a.borderWidth)!==null&&u!==void 0?u:0)/2,width:(c=a==null?void 0:a.width)!==null&&c!==void 0?c:100,height:(f=a==null?void 0:a.height)!==null&&f!==void 0?f:50,textColor:(d=a==null?void 0:a.textColor)!==null&&d!==void 0?d:zr(0,0,0),backgroundColor:(h=a==null?void 0:a.backgroundColor)!==null&&h!==void 0?h:zr(.75,.75,.75),borderColor:a==null?void 0:a.borderColor,borderWidth:(p=a==null?void 0:a.borderWidth)!==null&&p!==void 0?p:0,rotate:(v=a==null?void 0:a.rotate)!==null&&v!==void 0?v:bn(0),caption:n,hidden:a==null?void 0:a.hidden,page:r.ref}),y=this.doc.context.register(g.dict);this.acroField.addWidget(y);var b=(m=a==null?void 0:a.font)!==null&&m!==void 0?m:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(g,b),r.node.addAnnot(y)},t.prototype.needsAppearancesUpdate=function(){var n;if(this.isDirty())return!0;for(var r=this.acroField.getWidgets(),a=0,o=r.length;a<o;a++){var i=r[a],s=((n=i.getAppearances())===null||n===void 0?void 0:n.normal)instanceof fc;if(!s)return!0}return!1},t.prototype.defaultUpdateAppearances=function(n){He(n,"font",[[hc,"PDFFont"]]),this.updateAppearances(n)},t.prototype.updateAppearances=function(n,r){He(n,"font",[[hc,"PDFFont"]]),Mt(r,"provider",[Function]);for(var a=this.acroField.getWidgets(),o=0,i=a.length;o<i;o++){var s=a[o];this.updateWidgetAppearance(s,n,r)}},t.prototype.updateWidgetAppearance=function(n,r,a){var o=a??Iut,i=ex(o(this,n,r));this.updateWidgetAppearanceWithFont(n,r,i)},t.of=function(n,r,a){return new t(n,r,a)},t}(P1);const ax=()=>{const e=pt(),{slides:t,theme:n,viewportRatio:r,title:a,viewportSize:o}=Ze(e),i=16,s=l.computed(()=>96*(o.value/960)),u=l.computed(()=>96/72*(o.value/960)),c=l.ref(!1),f=(N,T,k,O=!0)=>{c.value=!0;const E=T==="png"?KYe:sk;N.querySelectorAll("foreignObject [xmlns]").forEach(_=>_.removeAttribute("xmlns")),setTimeout(()=>{const _={quality:k,width:1600};O&&(_.fontEmbedCSS=""),E(N,_).then(I=>{c.value=!1,SJ.saveAs(I,`${a.value}.${T}`)}).catch(()=>{c.value=!1,nn.error("导出图片失败")})},200)},d=(N,T,k,O=!1)=>(c.value=!0,new Promise((E,P)=>{setTimeout(async()=>{const _=await gm.create(),I={quality:T,width:1600};k&&(I.fontEmbedCSS="");const B=[];for(const Y of N){Y.querySelectorAll("foreignObject [xmlns]").forEach(F=>F.removeAttribute("xmlns"));const G=()=>sk(Y,I);B.push(G)}Promise.all(B.map(Y=>Y())).then(async Y=>{for(const Q of Y){const{width:ee,height:te}=await OK(Q),oe=_.addPage([ee,te]),ue=await oe.doc.embedJpg(Q);oe.drawImage(ue,{x:0,y:0,width:ee,height:te})}_.getPageCount()===0&&_.addPage([800,600]);const W=await _.save({useObjectStreams:!1,addDefaultPage:!1}),G=W.buffer.slice(W.byteOffset,W.byteOffset+W.byteLength),F=new Blob([G],{type:"application/pdf"}),U=`${a.value||`pdf_${+new Date}`}`,K=new File([F],`${U}.pdf`,{type:"application/pdf"});if(c.value=!1,O)E(K);else{const Q=URL.createObjectURL(F);tWe(Q,`${U}.pdf`),E(null)}}).catch(()=>{c.value=!1,nn.error("导出失败"),P(null)})},200)})),h=N=>{c.value=!0,setTimeout(()=>{const T=new Lbe,k={quality:1,width:1600},O=[];for(const E of N){E.querySelectorAll("foreignObject [xmlns]").forEach(I=>I.removeAttribute("xmlns"));const _=()=>sk(E,k);O.push(_)}Promise.all(O.map(E=>E())).then(E=>{for(const P of E)T.addSlide().addImage({data:P,x:0,y:0,w:o.value/s.value,h:o.value*r.value/s.value});T.writeFile({fileName:`${a.value}.pptx`}).then(()=>c.value=!1)}).catch(()=>{c.value=!1,nn.error("导出失败")})},200)},p=N=>{const T={title:a.value,width:o.value,height:o.value*r.value,theme:n.value,slides:N},k=new Blob([xK(JSON.stringify(T))],{type:""});SJ.saveAs(k,`${a.value}.pptist`)},v=()=>{const N={title:a.value,width:o.value,height:o.value*r.value,theme:n.value,slides:t.value},T=new Blob([JSON.stringify(N)],{type:""});SJ.saveAs(T,`${a.value}.json`)},m=N=>{if(!N)return{alpha:0,color:"#000000"};const T=yt(N),k=T.getAlpha(),O=k===0?"#ffffff":T.setAlpha(1).toHexString();return{alpha:k,color:O}},g=N=>{const T=oit(N);let k=!1,O=0;const E=[],P=(_,I={})=>{for(const B of _){if("tagName"in B&&["div","li","p"].includes(B.tagName)&&E.length){const F=E[E.length-1];F.options||(F.options={}),F.options.breakLine=!0}const W={...I},G="attributes"in B?B.attributes.find(F=>F.key==="style"):null;if(G&&G.value){const F=G.value.split(";");for(const U of F){const K=U.match(/([^:]+):\s*(.+)/);if(K){const[Q,ee]=[K[1].trim(),K[2].trim()];Q&&ee&&(W[Q]=ee)}}}if("tagName"in B){if(B.tagName==="em"&&(W["font-style"]="italic"),B.tagName==="strong"&&(W["font-weight"]="bold"),B.tagName==="sup"&&(W["vertical-align"]="super"),B.tagName==="sub"&&(W["vertical-align"]="sub"),B.tagName==="a"){const F=B.attributes.find(U=>U.key==="href");W.href=(F==null?void 0:F.value)||""}if(B.tagName==="ul"&&(W["list-type"]="ul"),B.tagName==="ol"&&(W["list-type"]="ol"),B.tagName==="li"&&(k=!0),B.tagName==="p"&&"attributes"in B){const F=B.attributes.find(U=>U.key==="data-indent");F&&F.value&&(O=+F.value)}}if("tagName"in B&&B.tagName==="br")E.push({text:"",options:{breakLine:!0}});else if("content"in B){const F=B.content.replace(/&nbsp;/g," ").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&").replace(/\n/g,""),U={};W["font-size"]&&(U.fontSize=parseInt(W["font-size"])/u.value),W.color&&(U.color=m(W.color).color),W["background-color"]&&(U.highlight=m(W["background-color"]).color),W["text-decoration-line"]&&(W["text-decoration-line"].indexOf("underline")!==-1&&(U.underline={color:U.color||"#000000",style:"sng"}),W["text-decoration-line"].indexOf("line-through")!==-1&&(U.strike="sngStrike")),W["text-decoration"]&&(W["text-decoration"].indexOf("underline")!==-1&&(U.underline={color:U.color||"#000000",style:"sng"}),W["text-decoration"].indexOf("line-through")!==-1&&(U.strike="sngStrike")),W["vertical-align"]&&(W["vertical-align"]==="super"&&(U.superscript=!0),W["vertical-align"]==="sub"&&(U.subscript=!0)),W["text-align"]&&(U.align=W["text-align"]),W["font-weight"]&&(U.bold=W["font-weight"]==="bold"),W["font-style"]&&(U.italic=W["font-style"]==="italic"),W["font-family"]&&(U.fontFace=W["font-family"]),W.href&&(U.hyperlink={url:W.href}),k&&W["list-type"]==="ol"&&(U.bullet={type:"number",indent:(U.fontSize||i)*1.25},U.paraSpaceBefore=.1,k=!1),k&&W["list-type"]==="ul"&&(U.bullet={indent:(U.fontSize||i)*1.25},U.paraSpaceBefore=.1,k=!1),O&&(U.indentLevel=O,O=0),E.push({text:F,options:U})}else"children"in B&&P(B.children,W)}};return P(T),E},y=(N,T={x:1,y:1})=>N.map(k=>{if(k.close!==void 0)return{close:!0};if(k.type==="M")return{x:k.x/s.value*T.x,y:k.y/s.value*T.y,moveTo:!0};if(k.curve){if(k.curve.type==="cubic")return{x:k.x/s.value*T.x,y:k.y/s.value*T.y,curve:{type:"cubic",x1:k.curve.x1/s.value*T.x,y1:k.curve.y1/s.value*T.y,x2:k.curve.x2/s.value*T.x,y2:k.curve.y2/s.value*T.y}};if(k.curve.type==="quadratic")return{x:k.x/s.value*T.x,y:k.y/s.value*T.y,curve:{type:"quadratic",x1:k.curve.x1/s.value*T.x,y1:k.curve.y1/s.value*T.y}}}return{x:k.x/s.value*T.x,y:k.y/s.value*T.y}}),b=N=>{const T=m(N.color),{h:k,v:O}=N;let E=4,P=45;return k===0&&O===0?(E=4,P=45):k===0?O>0?(E=O,P=90):(E=-O,P=270):O===0?k>0?(E=k,P=1):(E=-k,P=180):k>0&&O>0?(E=Math.max(k,O),P=45):k>0&&O<0?(E=Math.max(k,-O),P=315):k<0&&O>0?(E=Math.max(-k,O),P=135):k<0&&O<0&&(E=Math.max(-k,-O),P=225),{type:"outer",color:T.color.replace("#",""),opacity:T.alpha,blur:N.blur/u.value,offset:E,angle:P}},R={solid:"solid",dashed:"dash",dotted:"sysDot"},A=N=>{const T=m((N==null?void 0:N.color)||"#000000");return{color:T.color,transparency:(1-T.alpha)*100,width:(N.width||1)/u.value,dashType:N.style?R[N.style]:"solid"}},S=N=>{const{type:T,target:k}=N;if(T==="web")return{url:k};if(T==="slide"){const O=t.value.findIndex(E=>E.id===k);if(O!==-1)return{slide:O+1}}return null},w=N=>{const T=/^data:image\/[^;]+;base64,/;return N.match(T)!==null},M=N=>{const T=/^data:image\/svg\+xml;base64,/.test(N),k=/\.svg$/.test(N);return T||k};return{exporting:c,exportImage:f,exportImagePPTX:h,exportImagePDF:d,exportJSON:v,exportSpecificFile:p,exportPPTX:(N,T,k,O=!1)=>{var P,_,I,B,Y,W,G,F,U,K,Q,ee,te,oe,ue,we;c.value=!0;const E=new Lbe;if(r.value===.625?E.layout="LAYOUT_16x10":r.value===.75?E.layout="LAYOUT_4x3":r.value===.70710678?(E.defineLayout({name:"A3",width:10,height:7.0710678}),E.layout="A3"):r.value===1.41421356?(E.defineLayout({name:"A3_V",width:10,height:14.1421356}),E.layout="A3_V"):E.layout="LAYOUT_16x9",T){const{color:me,alpha:ae}=m(n.value.backgroundColor);E.defineSlideMaster({title:"PPTIST_MASTER",background:{color:me,transparency:(1-ae)*100}})}for(const me of N){const ae=E.addSlide();if(me.background){const H=me.background;if(H.type==="image"&&H.image)M(H.image.src)?ae.addImage({data:H.image.src,x:0,y:0,w:o.value/s.value,h:o.value*r.value/s.value}):w(H.image.src)?ae.background={data:H.image.src}:ae.background={path:H.image.src};else if(H.type==="solid"&&H.color){const ce=m(H.color);ae.background={color:ce.color,transparency:(1-ce.alpha)*100}}else if(H.type==="gradient"&&H.gradient){const ce=H.gradient.colors,Z=ce[0].color,ie=ce[ce.length-1].color,he=yt.mix(Z,ie).toHexString(),$=m(he);ae.background={color:$.color,transparency:(1-$.alpha)*100}}}if(me.remark){const ce=new DOMParser().parseFromString(me.remark,"text/html").body.querySelectorAll("p"),Z=[];for(const ie of ce){const he=ie.textContent;Z.push(he||"")}ae.addNotes(Z.join(`
342
- `))}if(me.elements){for(const H of me.elements)if(H.type==="text"){const ce=g(H.content),Z={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,fontSize:i/u.value,fontFace:"微软雅黑",color:"#000000",valign:"top",margin:10/u.value,paraSpaceBefore:5/u.value,lineSpacingMultiple:1.5/1.25,autoFit:!0};if(H.rotate&&(Z.rotate=H.rotate),H.wordSpace&&(Z.charSpacing=H.wordSpace/u.value),H.lineHeight&&(Z.lineSpacingMultiple=H.lineHeight/1.25),H.fill){const ie=m(H.fill),he=H.opacity===void 0?1:H.opacity;Z.fill={color:ie.color,transparency:(1-ie.alpha*he)*100}}H.defaultColor&&(Z.color=m(H.defaultColor).color),H.defaultFontName&&(Z.fontFace=H.defaultFontName),H.shadow&&(Z.shadow=b(H.shadow)),(P=H.outline)!=null&&P.width&&(Z.line=A(H.outline)),H.opacity!==void 0&&(Z.transparency=(1-H.opacity)*100),H.paragraphSpace!==void 0&&(Z.paraSpaceBefore=H.paragraphSpace/u.value),H.vertical&&(Z.vert="eaVert"),ae.addText(ce,Z)}else if(H.type==="image"){const ce={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(w(H.src)?ce.data=H.src:ce.path=H.src,H.flipH&&(ce.flipH=H.flipH),H.flipV&&(ce.flipV=H.flipV),H.rotate&&(ce.rotate=H.rotate),H.link){const Z=S(H.link);Z&&(ce.hyperlink=Z)}if((_=H.filters)!=null&&_.opacity&&(ce.transparency=100-parseInt((I=H.filters)==null?void 0:I.opacity)),H.clip){H.clip.shape==="ellipse"&&(ce.rounding=!0);const[Z,ie]=H.clip.range,[he,$]=Z,[se,de]=ie,xe=H.width/((se-he)/100),pe=H.height/((de-$)/100);ce.w=xe/s.value,ce.h=pe/s.value,ce.sizing={type:"crop",x:he/100*xe/s.value,y:$/100*pe/s.value,w:(se-he)/100*xe/s.value,h:(de-$)/100*pe/s.value}}ae.addImage(ce)}else if(H.type==="shape"){if(H.special){const ce=document.createElement("div"),Z=l.createVNode(yQ,{elementInfo:H},null);l.render(Z,ce);const ie=ce.querySelector("svg"),he=ie?Ibe(ie):"";if(l.render(null,ce),!he)continue;const $={data:he,x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(H.rotate&&($.rotate=H.rotate),H.flipH&&($.flipH=H.flipH),H.flipV&&($.flipV=H.flipV),H.link){const se=S(H.link);se&&($.hyperlink=se)}ae.addImage($)}else{const ce={x:H.width/H.viewBox[0],y:H.height/H.viewBox[1]},Z=y(kde(H.path),ce);let ie=m(H.fill);if(H.gradient){const se=H.gradient.colors,de=se[0].color,xe=se[se.length-1].color,pe=yt.mix(de,xe).toHexString();ie=m(pe)}H.pattern&&(ie=m("#00000000"));const he=H.opacity===void 0?1:H.opacity,$={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,fill:{color:ie.color,transparency:(1-ie.alpha*he)*100},points:Z};if(H.flipH&&($.flipH=H.flipH),H.flipV&&($.flipV=H.flipV),H.shadow&&($.shadow=b(H.shadow)),(B=H.outline)!=null&&B.width&&($.line=A(H.outline)),H.rotate&&($.rotate=H.rotate),H.link){const se=S(H.link);se&&($.hyperlink=se)}ae.addShape("custGeom",$)}if(H.text){const ce=g(H.text.content),Z={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,fontSize:i/u.value,fontFace:"微软雅黑",color:"#000000",paraSpaceBefore:5/u.value,valign:H.text.align};H.rotate&&(Z.rotate=H.rotate),H.text.defaultColor&&(Z.color=m(H.text.defaultColor).color),H.text.defaultFontName&&(Z.fontFace=H.text.defaultFontName),ae.addText(ce,Z)}if(H.pattern){const ce={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(w(H.pattern)?ce.data=H.pattern:ce.path=H.pattern,H.flipH&&(ce.flipH=H.flipH),H.flipV&&(ce.flipV=H.flipV),H.rotate&&(ce.rotate=H.rotate),H.link){const Z=S(H.link);Z&&(ce.hyperlink=Z)}ae.addImage(ce)}}else if(H.type==="line"){const ce=TK(H),Z=y(kde(ce)),{minX:ie,maxX:he,minY:$,maxY:se}=zc(H),de=m(H.color),xe={x:H.left/s.value,y:H.top/s.value,w:(he-ie)/s.value,h:(se-$)/s.value,line:{color:de.color,transparency:(1-de.alpha)*100,width:H.width/u.value,dashType:R[H.style],beginArrowType:H.points[0]?"arrow":"none",endArrowType:H.points[1]?"arrow":"none"},points:Z};H.shadow&&(xe.shadow=b(H.shadow)),ae.addShape("custGeom",xe)}else if(H.type==="chart"){const ce=[];for(let de=0;de<H.data.series.length;de++){const xe=H.data.series[de];ce.push({name:`系列${de+1}`,labels:H.data.labels,values:xe})}let Z=[];if(H.themeColors.length===10)Z=H.themeColors.map(de=>m(de).color);else if(H.themeColors.length===1)Z=yt(H.themeColors[0]).analogous(10).map(de=>m(de.toHexString()).color);else{const de=H.themeColors.length,xe=yt(H.themeColors[de-1]).analogous(11-de).map(pe=>pe.toHexString());Z=[...H.themeColors.slice(0,de-1),...xe].map(pe=>m(pe).color)}const ie={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,chartColors:H.chartType==="pie"||H.chartType==="ring"?Z:Z.slice(0,H.data.series.length)},he=m(H.textColor||"#000000").color;ie.catAxisLabelColor=he,ie.valAxisLabelColor=he;const $=14/u.value;if(ie.catAxisLabelFontSize=$,ie.valAxisLabelFontSize=$,H.fill||H.outline){const de={};H.fill&&(de.fill={color:m(H.fill).color}),H.outline&&(de.border={pt:H.outline.width/u.value,color:m(H.outline.color).color}),ie.plotArea=de}(H.data.series.length>1&&H.chartType!=="scatter"||H.chartType==="pie"||H.chartType==="ring")&&(ie.showLegend=!0,ie.legendPos="b",ie.legendColor=he,ie.legendFontSize=$);let se=E.ChartType.bar;H.chartType==="bar"?(se=E.ChartType.bar,ie.barDir="col",(Y=H.options)!=null&&Y.stack&&(ie.barGrouping="stacked")):H.chartType==="column"?(se=E.ChartType.bar,ie.barDir="bar",(W=H.options)!=null&&W.stack&&(ie.barGrouping="stacked")):H.chartType==="line"?(se=E.ChartType.line,(G=H.options)!=null&&G.lineSmooth&&(ie.lineSmooth=!0)):H.chartType==="area"?se=E.ChartType.area:H.chartType==="radar"?se=E.ChartType.radar:H.chartType==="scatter"?(se=E.ChartType.scatter,ie.lineSize=0):H.chartType==="pie"?se=E.ChartType.pie:H.chartType==="ring"&&(se=E.ChartType.doughnut,ie.holeSize=60),ae.addChart(se,ce,ie)}else if(H.type==="table"){const ce=[];for(let de=0;de<H.data.length;de++){const xe=H.data[de];for(let pe=0;pe<xe.length;pe++){const be=xe[pe];if(be.colspan>1||be.rowspan>1)for(let Ee=de;Ee<de+be.rowspan;Ee++)for(let Be=Ee===de?pe+1:pe;Be<pe+be.colspan;Be++)ce.push(`${Ee}_${Be}`)}}const Z=[],ie=H.theme;let he=null,$=[];ie&&(he=m(ie.color),$=dde(ie.color).map(de=>m(de)));for(let de=0;de<H.data.length;de++){const xe=H.data[de],pe=[];for(let be=0;be<xe.length;be++){const Ee=xe[be],Be={colspan:Ee.colspan,rowspan:Ee.rowspan,bold:((F=Ee.style)==null?void 0:F.bold)||!1,italic:((U=Ee.style)==null?void 0:U.em)||!1,underline:{style:(K=Ee.style)!=null&&K.underline?"sng":"none"},align:((Q=Ee.style)==null?void 0:Q.align)||"left",valign:"middle",fontFace:((ee=Ee.style)==null?void 0:ee.fontname)||"微软雅黑",fontSize:((te=Ee.style)!=null&&te.fontsize?parseInt((oe=Ee.style)==null?void 0:oe.fontsize):14)/u.value};if(ie&&he){let et;de%2===0?et=$[1]:et=$[0],(ie.rowHeader&&de===0||ie.rowFooter&&de===H.data.length-1||ie.colHeader&&be===0||ie.colFooter&&be===xe.length-1)&&(et=he),Be.fill={color:et.color,transparency:(1-et.alpha)*100}}if((ue=Ee.style)!=null&&ue.backcolor){const et=m(Ee.style.backcolor);Be.fill={color:et.color,transparency:(1-et.alpha)*100}}(we=Ee.style)!=null&&we.color&&(Be.color=m(Ee.style.color).color),ce.includes(`${de}_${be}`)||pe.push({text:Ee.text,options:Be})}pe.length&&Z.push(pe)}const se={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,colW:H.colWidths.map(de=>H.width*de/s.value)};H.theme&&(se.fill={color:"#ffffff"}),H.outline.width&&H.outline.color&&(se.border={type:H.outline.style==="solid"?"solid":"dash",pt:H.outline.width/u.value,color:m(H.outline.color).color}),ae.addTable(Z,se)}else if(H.type==="latex"){const ce=document.createElement("div"),Z=l.createVNode(xJ,{elementInfo:H},null);l.render(Z,ce);const ie=ce.querySelector("svg"),he=ie?Ibe(ie):"";if(l.render(null,ce),!he)continue;const $={data:he,x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(H.link){const se=S(H.link);se&&($.hyperlink=se)}ae.addImage($)}else if(!k&&(H.type==="video"||H.type==="audio")){const ce={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,path:H.src,type:H.type};H.type==="video"&&H.poster&&(ce.cover=H.poster);const Z=H.src.match(/\.([a-zA-Z0-9]+)(?:[\?#]|$)/);Z&&Z[1]?ce.extn=Z[1]:H.ext&&(ce.extn=H.ext);const ie=["avi","mp4","m4v","mov","wmv"],he=["mp3","m4a","mp4","wav","wma"];ce.extn&&[...ie,...he].includes(ce.extn)&&ae.addMedia(ce)}}}return new Promise((me,ae)=>{setTimeout(()=>{const H=`${a.value||`ppt_${+new Date}`}`;O?E.write({outputType:"blob"}).then(async ce=>{const Z=ce;c.value=!1;const ie=new File([Z],`${H}.pptx`,{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"});me(ie)}).catch(()=>{c.value=!1,nn.error("生成失败"),ae(null)}):E.writeFile({fileName:`${H}.pptx`}).then(()=>{c.value=!1,me(null)}).catch(()=>{c.value=!1,nn.error("导出失败"),ae(null)})},200)})}}},Kut={class:"editor-header"},Qut={class:"left"},Hut={class:"right"},zut=Je(l.defineComponent({__name:"index",setup(e){const t=wt(),n=pt(),{title:r,slides:a}=Ze(n),{enterScreening:o}=vv(),{exporting:i}=BK(),{resetSlides:s}=Pd(),{exportPPTX:u}=ax(),c=l.inject("onUploadFile"),f=l.inject("onSave"),d=l.inject("onReturn"),h=l.ref(!1),p=l.ref(!1);l.ref(!1),l.ref(""),l.shallowRef(null);const v=l.ref(null),m=l.ref(!1),g=w=>{t.setDialogForExport(w),h.value=!1},y=w=>/^data:.+;base64,/.test(w),b=w=>{var C,N;const M=[];for(const T of w){if(((C=T.background)==null?void 0:C.type)==="image"&&((N=T.background.image)!=null&&N.src)&&y(T.background.image.src)){const k=T.background.image;M.push({base64:k.src,setUrl:O=>{k.src=O}})}for(const k of T.elements||[]){if(k.type==="image"&&y(k.src)){const O=k;M.push({base64:O.src,setUrl:E=>{O.src=E}})}if(k.type==="video"&&k.poster&&y(k.poster)){const O=k;M.push({base64:O.poster,setUrl:E=>{O.poster=E}})}if(k.type==="shape"&&k.pattern&&y(k.pattern)){const O=k;M.push({base64:O.pattern,setUrl:E=>{O.pattern=E}})}}}return M},R=async()=>{m.value=!0;const[w,M]=await Promise.all([S(),A()]),C=await u(a.value,!0,!1,!0),N=C&&c?await c({file:C}):"";f&&await f({pptUrl:N,json:w,slideImages:M}),m.value=!1},A=async()=>{try{const w=v.value;if(!w)return[];const M=w.querySelectorAll(".thumbnail-slide");if(!M.length)return[];const C={quality:.9,width:800,pixelRatio:2,fontEmbedCSS:""},N=[];for(const T of M){T.querySelectorAll("foreignObject [xmlns]").forEach(P=>P.removeAttribute("xmlns"));const O=await sk(T,C),E=c?await c({base64:O}):O;N.push(E)}return N}catch{return[]}},S=async()=>{const{title:w,theme:M,slides:C,viewportSize:N,viewportRatio:T}=n.$state,k=JSON.parse(JSON.stringify(C)),O={title:w,theme:M,slides:k,width:N,height:N*T},E=b(O.slides);if(E.length){const P=new Map,_=[...new Set(E.map(B=>B.base64))];await Promise.all(_.map(async B=>{const Y=c?await c({base64:B}):B;P.set(B,Y)}));for(const B of E){const Y=P.get(B.base64);Y&&B.setUrl(Y)}const I=b(C);for(const B of I){const Y=P.get(B.base64);Y&&B.setUrl(Y)}}return O};return(w,M)=>{const C=Ide,N=jWe,T=zWe,k=KWe,O=wy,E=XWe,P=l.resolveDirective("tooltip");return l.openBlock(),l.createElementBlock("div",Kut,[l.createElementVNode("div",Qut,[l.unref(d)?l.withDirectives((l.openBlock(),l.createElementBlock("div",{key:0,class:"menu-item",onClick:M[0]||(M[0]=_=>l.unref(d)())},[l.createVNode(C,{class:"icon"})])),[[P,w.$t("header.back")]]):l.createCommentVNode("",!0),l.createVNode(In,{trigger:"click",placement:"bottom-start",value:h.value,"onUpdate:value":M[3]||(M[3]=_=>h.value=_)},{content:l.withCtx(()=>[l.createVNode(Rf,{class:"popover-menu-item",onClick:M[1]||(M[1]=_=>{l.unref(s)(),h.value=!1})},{default:l.withCtx(()=>[l.createVNode(N,{class:"icon"}),l.createTextVNode(" "+l.toDisplayString(w.$t("header.resetSlides")),1)]),_:1}),l.createVNode(Rf,{class:"popover-menu-item",onClick:M[2]||(M[2]=_=>{h.value=!1,p.value=!0})},{default:l.withCtx(()=>[l.createVNode(T,{class:"icon"}),l.createTextVNode(" "+l.toDisplayString(w.$t("header.shortcuts")),1)]),_:1})]),_:1},8,["value"])]),l.createElementVNode("div",Hut,[l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"menu-item",onClick:M[4]||(M[4]=_=>R())},[l.createVNode(k,{class:"icon"})])),[[P,w.$t("header.save")]]),l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"menu-item",onClick:M[5]||(M[5]=_=>g("pptx"))},[l.createVNode(O,{class:"icon"})])),[[P,w.$t("header.export")]]),l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"menu-item",onClick:M[6]||(M[6]=_=>l.unref(o)())},[l.createVNode(E,{class:"icon"})])),[[P,w.$t("header.slideshowF5")]])]),l.createVNode(aZe,{width:320,visible:p.value,"onUpdate:visible":M[7]||(M[7]=_=>p.value=_),placement:"right"},{title:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(w.$t("header.shortcuts")),1)]),default:l.withCtx(()=>[l.createVNode(jYe)]),_:1},8,["visible"]),l.createVNode(wA,{loading:l.unref(i),tip:w.$t("common.importing")},null,8,["loading","tip"]),l.createVNode(wA,{loading:m.value,tip:w.$t("common.saving")},null,8,["loading","tip"]),l.createElementVNode("div",{class:"offscreen-cover",ref_key:"offscreenCoverRef",ref:v},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(a),_=>(l.openBlock(),l.createBlock(yl,{key:_.id,slide:_,size:800},null,8,["slide"]))),128))],512)])}}}),[["__scopeId","data-v-cfe561ab"]]),Gut=()=>{const e=window.getSelection();e&&e.removeAllRanges()},Jut=e=>{const t=l.ref(0),n=l.ref(0),r=wt(),{canvasPercentage:a,canvasDragged:o}=Ze(r),{viewportRatio:i,viewportSize:s}=Ze(pt()),u=()=>{if(!e.value)return;const p=e.value.clientWidth,v=e.value.clientHeight;if(v/p>i.value){const m=p*(a.value/100);r.setCanvasScale(m/s.value),t.value=(p-m)/2,n.value=(v-m*i.value)/2}else{const m=v*(a.value/100);r.setCanvasScale(m/(s.value*i.value)),t.value=(p-m/i.value)/2,n.value=(v-m)/2}},c=(p,v)=>{if(!e.value)return;const m=e.value.clientWidth,g=e.value.clientHeight;if(g/m>i.value){const y=m*(p/100),b=m*(v/100),R=y*i.value,A=b*i.value;r.setCanvasScale(y/s.value),t.value=t.value-(y-b)/2,n.value=n.value-(R-A)/2}else{const y=g*(p/100),b=g*(v/100),R=y/i.value,A=b/i.value;r.setCanvasScale(y/(s.value*i.value)),t.value=t.value-(R-A)/2,n.value=n.value-(y-b)/2}};l.watch(a,c),l.watch(i,u),l.watch(s,u),l.watch(o,()=>{o.value||u()});const f=l.computed(()=>({width:s.value,height:s.value*i.value,left:t.value,top:n.value})),d=new ResizeObserver(u);return l.onMounted(()=>{e.value&&d.observe(e.value)}),l.onUnmounted(()=>{e.value&&d.unobserve(e.value)}),{viewportStyles:f,dragViewport:p=>{let v=!0;const m=p.pageX,g=p.pageY,y=t.value,b=n.value;document.onmousemove=R=>{if(!v)return;const A=R.pageX,S=R.pageY;t.value=y+(A-m),n.value=b+(S-g)},document.onmouseup=()=>{v=!1,document.onmousemove=null,document.onmouseup=null,r.setCanvasDragged(!0)}}}},jut=(e,t)=>{const n=wt(),{canvasScale:r,hiddenElementIdList:a}=Ze(n),{ctrlOrShiftKeyActive:o}=Ze(rl()),i=l.ref(!1),s=l.ref(1),u=l.ref({top:0,left:0,width:0,height:0});return{mouseSelection:u,mouseSelectionVisible:i,mouseSelectionQuadrant:s,updateMouseSelection:f=>{if(!t.value)return;let d=!0;const h=t.value.getBoundingClientRect(),p=5,v=f.pageX,m=f.pageY,g=(v-h.x)/r.value,y=(m-h.y)/r.value;u.value={top:y,left:g,width:0,height:0},i.value=!1,s.value=4,document.onmousemove=b=>{if(!d)return;const R=b.pageX,A=b.pageY,S=(R-v)/r.value,w=(A-m)/r.value,M=Math.abs(S),C=Math.abs(w);if(M<p||C<p)return;let N=0;S>0&&w>0?N=4:S<0&&w<0?N=2:S>0&&w<0?N=1:S<0&&w>0&&(N=3),u.value={...u.value,width:M,height:C},i.value=!0,s.value=N},document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null,d=!1;let b=[];for(let A=0;A<e.value.length;A++){const S=e.value[A],w=u.value.left,M=u.value.top,C=u.value.width,N=u.value.height,{minX:T,maxX:k,minY:O,maxY:E}=zc(S);let P=!1;o.value?s.value===4?P=k>w&&T<w+C&&E>M&&O<M+N:s.value===2?P=k>w-C&&T<w-C+C&&E>M-N&&O<M-N+N:s.value===1?P=k>w&&T<w+C&&E>M-N&&O<M-N+N:s.value===3&&(P=k>w-C&&T<w-C+C&&E>M&&O<M+N):s.value===4?P=T>w&&k<w+C&&O>M&&E<M+N:s.value===2?P=T>w-C&&k<w-C+C&&O>M-N&&E<M-N+N:s.value===1?P=T>w&&k<w+C&&O>M-N&&E<M-N+N:s.value===3&&(P=T>w-C&&k<w-C+C&&O>M&&E<M+N),P&&!S.lock&&!a.value.includes(S.id)&&b.push(S)}b=b.filter(A=>{if(A.groupId){const S=b.map(M=>M.id);return e.value.filter(M=>M.groupId===A.groupId).every(M=>S.includes(M.id))}return!0});const R=b.map(A=>A.id);n.setActiveElementIdList(R),i.value=!1}}}},qut=e=>{const{disableHotkeys:t}=Ze(wt()),{createTextElement:n}=xp(),{pasteDataTransfer:r}=_de(),a=o=>{if(!o.dataTransfer||o.dataTransfer.items.length===0)return;const{isFile:i,dataTransferFirstItem:s}=r(o.dataTransfer);i||s&&s.kind==="string"&&s.type==="text/plain"&&s.getAsString(u=>{if(t.value)return;const c=tk(u);n({left:0,top:0,width:600,height:50},{content:c})})};l.onMounted(()=>{e.value&&e.value.addEventListener("drop",a),document.ondragleave=o=>o.preventDefault(),document.ondrop=o=>o.preventDefault(),document.ondragenter=o=>o.preventDefault(),document.ondragover=o=>o.preventDefault()}),l.onUnmounted(()=>{e.value&&e.value.removeEventListener("drop",a),document.ondragleave=null,document.ondrop=null,document.ondragenter=null,document.ondragover=null})},$ut=(e,t)=>{const n=Math.atan2(e,t);return 180/Math.PI*n},Wxe=(e,t,n)=>{const r=pt(),{addHistorySnapshot:a}=Rn();return{rotateElement:(i,s)=>{const u=!(i instanceof MouseEvent);if(u&&(!i.changedTouches||!i.changedTouches[0]))return;let c=!0,f=0;const d=s.rotate||0,h=s.left,p=s.top,v=s.width,m=s.height,g=h+v/2,y=p+m/2;if(!t.value)return;const b=t.value.getBoundingClientRect(),R=S=>{if(!c)return;const w=S instanceof MouseEvent?S.pageX:S.changedTouches[0].pageX,M=S instanceof MouseEvent?S.pageY:S.changedTouches[0].pageY,C=(w-b.left)/n.value,N=(M-b.top)/n.value,T=C-g,k=y-N;f=$ut(T,k);const O=5;Math.abs(f)<=O?f=0:f>0&&Math.abs(f-45)<=O?f-=f-45:f<0&&Math.abs(f+45)<=O?f-=f+45:f>0&&Math.abs(f-90)<=O?f-=f-90:f<0&&Math.abs(f+90)<=O?f-=f+90:f>0&&Math.abs(f-135)<=O?f-=f-135:f<0&&Math.abs(f+135)<=O?f-=f+135:f>0&&Math.abs(f-180)<=O?f-=f-180:f<0&&Math.abs(f+180)<=O&&(f-=f+180),e.value=e.value.map(E=>s.id===E.id?{...E,rotate:f}:E)},A=()=>{c=!1,document.onmousemove=null,document.onmouseup=null,d!==f&&(r.updateSlide({elements:e.value}),a())};u?(document.ontouchmove=R,document.ontouchend=A):(document.onmousemove=R,document.onmouseup=A)}}},Yxe={text:40,image:20,shape:20,chart:200,table:30,video:250,audio:20,latex:20},Zxe=(e,t)=>{const{left:n,top:r,width:a,height:o}=e,i=Math.sqrt(Math.pow(a,2)+Math.pow(o,2))/2,s=Math.atan(o/a)*180/Math.PI,u=(180-t-s)*Math.PI/180,c=(s-t)*Math.PI/180,f=(90-t)*Math.PI/180,d=t*Math.PI/180,h=a/2,p=o/2,v=n+h,m=r+p,g={left:v+i*Math.cos(u),top:m-i*Math.sin(u)},y={left:v+p*Math.cos(f),top:m-p*Math.sin(f)},b={left:v+i*Math.cos(c),top:m-i*Math.sin(c)},R={left:v+h*Math.cos(d),top:m+h*Math.sin(d)},A={left:v-i*Math.cos(u),top:m+i*Math.sin(u)},S={left:v-p*Math.sin(d),top:m+p*Math.cos(d)},w={left:v-i*Math.cos(c),top:m+i*Math.sin(c)},M={left:v-h*Math.cos(d),top:m-h*Math.sin(d)};return{leftTopPoint:g,topPoint:y,rightTopPoint:b,rightPoint:R,rightBottomPoint:A,bottomPoint:S,leftBottomPoint:w,leftPoint:M}},Kxe=(e,t)=>({[Ft.RIGHT_BOTTOM]:t.leftTopPoint,[Ft.LEFT_BOTTOM]:t.rightTopPoint,[Ft.LEFT_TOP]:t.rightBottomPoint,[Ft.RIGHT_TOP]:t.leftBottomPoint,[Ft.TOP]:t.bottomPoint,[Ft.BOTTOM]:t.topPoint,[Ft.LEFT]:t.rightPoint,[Ft.RIGHT]:t.leftPoint})[e],Qxe=(e,t,n)=>{const r=wt(),a=pt(),{activeElementIdList:o,activeGroupElementId:i}=Ze(r),{viewportRatio:s,viewportSize:u}=Ze(a),{ctrlOrShiftKeyActive:c}=Ze(rl()),{addHistorySnapshot:f}=Rn();return{scaleElement:(p,v,m)=>{const g=!(p instanceof MouseEvent);if(g&&(!p.changedTouches||!p.changedTouches[0]))return;let y=!0;r.setScalingState(!0);const b=v.left,R=v.top,A=v.width,S=v.height,w=v.type==="table"?v.cellMinHeight:0,M="rotate"in v&&v.rotate?v.rotate:0,C=Math.PI*M/180,N=c.value||"fixedRatio"in v&&v.fixedRatio,T=A/S,k=g?p.changedTouches[0].pageX:p.pageX,O=g?p.changedTouches[0].pageY:p.pageY,E=Yxe[v.type]||20,P=(K,Q)=>{if(!N)return K<E?E:K;let ee=E,te=E;const oe=v.width/v.height;return oe<1&&(te=E/oe),oe>1&&(ee=E*oe),Q==="width"?K<ee?ee:K:K<te?te:K};let _,I=0,B=0,Y=[],W=[];if("rotate"in v&&v.rotate){const{left:K,top:Q,width:ee,height:te}=v;_=Zxe({left:K,top:Q,width:ee,height:te},M);const oe=Kxe(m,_);I=oe.left,B=oe.top}else{const K=u.value,Q=u.value*s.value,ee=v.id===i.value;for(const H of e.value){if("rotate"in H&&H.rotate||H.type==="line"||ee&&H.id===v.id||!ee&&o.value.includes(H.id))continue;const ce=H.left,Z=H.top,ie=H.width,he=H.height,$=ce+ie,se=Z+he,de={value:Z,range:[ce,$]},xe={value:se,range:[ce,$]},pe={value:ce,range:[Z,se]},be={value:$,range:[Z,se]};Y.push(de,xe),W.push(pe,be)}const te={value:0,range:[0,K]},oe={value:Q,range:[0,K]},ue={value:Q/2,range:[0,K]},we={value:0,range:[0,Q]},me={value:K,range:[0,Q]},ae={value:K/2,range:[0,Q]};Y.push(te,oe,ue),W.push(we,me,ae),Y=ek(Y),W=ek(W)}const G=(K,Q)=>{const te=[];let oe=!1,ue=!1;const we={offsetX:0,offsetY:0};if(Q||Q===0)for(let me=0;me<Y.length;me++){const{value:ae,range:H}=Y[me],ce=Math.min(...H,K||0),Z=Math.max(...H,K||0);Math.abs(Q-ae)<5&&!ue&&(we.offsetY=Q-ae,ue=!0,te.push({type:"horizontal",axis:{x:ce-50,y:ae},length:Z-ce+100}))}if(K||K===0)for(let me=0;me<W.length;me++){const{value:ae,range:H}=W[me],ce=Math.min(...H,Q||0),Z=Math.max(...H,Q||0);Math.abs(K-ae)<5&&!oe&&(we.offsetX=K-ae,oe=!0,te.push({type:"vertical",axis:{x:ae,y:ce-50},length:Z-ce+100}))}return t.value=te,we},F=K=>{if(!y)return;const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY,te=Q-k,oe=ee-O;let ue=A,we=S,me=b,ae=R;if(M){const H=(Math.cos(C)*te+Math.sin(C)*oe)/n.value;let ce=(Math.cos(C)*oe-Math.sin(C)*te)/n.value;N&&((m===Ft.RIGHT_BOTTOM||m===Ft.LEFT_TOP)&&(ce=H/T),(m===Ft.LEFT_BOTTOM||m===Ft.RIGHT_TOP)&&(ce=-H/T)),m===Ft.RIGHT_BOTTOM?(ue=P(A+H,"width"),we=P(S+ce,"height")):m===Ft.LEFT_BOTTOM?(ue=P(A-H,"width"),we=P(S+ce,"height"),me=b-(ue-A)):m===Ft.LEFT_TOP?(ue=P(A-H,"width"),we=P(S-ce,"height"),me=b-(ue-A),ae=R-(we-S)):m===Ft.RIGHT_TOP?(ue=P(A+H,"width"),we=P(S-ce,"height"),ae=R-(we-S)):m===Ft.TOP?(we=P(S-ce,"height"),ae=R-(we-S)):m===Ft.BOTTOM?we=P(S+ce,"height"):m===Ft.LEFT?(ue=P(A-H,"width"),me=b-(ue-A)):m===Ft.RIGHT&&(ue=P(A+H,"width"));const Z=Zxe({width:ue,height:we,left:me,top:ae},M),ie=Kxe(m,Z),he=ie.left,$=ie.top,se=he-I,de=$-B;me=me-se,ae=ae-de}else{let H=te/n.value,ce=oe/n.value;if(N&&((m===Ft.RIGHT_BOTTOM||m===Ft.LEFT_TOP)&&(ce=H/T),(m===Ft.LEFT_BOTTOM||m===Ft.RIGHT_TOP)&&(ce=-H/T)),m===Ft.RIGHT_BOTTOM){const{offsetX:Z,offsetY:ie}=G(b+A+H,R+S+ce);H=H-Z,ce=ce-ie,N&&(ie?H=ce*T:ce=H/T),ue=P(A+H,"width"),we=P(S+ce,"height")}else if(m===Ft.LEFT_BOTTOM){const{offsetX:Z,offsetY:ie}=G(b+H,R+S+ce);H=H-Z,ce=ce-ie,N&&(ie?H=-ce*T:ce=-H/T),ue=P(A-H,"width"),we=P(S+ce,"height"),me=b-(ue-A)}else if(m===Ft.LEFT_TOP){const{offsetX:Z,offsetY:ie}=G(b+H,R+ce);H=H-Z,ce=ce-ie,N&&(ie?H=ce*T:ce=H/T),ue=P(A-H,"width"),we=P(S-ce,"height"),me=b-(ue-A),ae=R-(we-S)}else if(m===Ft.RIGHT_TOP){const{offsetX:Z,offsetY:ie}=G(b+A+H,R+ce);H=H-Z,ce=ce-ie,N&&(ie?H=-ce*T:ce=-H/T),ue=P(A+H,"width"),we=P(S-ce,"height"),ae=R-(we-S)}else if(m===Ft.LEFT){const{offsetX:Z}=G(b+H,null);H=H-Z,ue=P(A-H,"width"),me=b-(ue-A)}else if(m===Ft.RIGHT){const{offsetX:Z}=G(b+A+H,null);H=H-Z,ue=P(A+H,"width")}else if(m===Ft.TOP){const{offsetY:Z}=G(null,R+ce);ce=ce-Z,we=P(S-ce,"height"),ae=R-(we-S)}else if(m===Ft.BOTTOM){const{offsetY:Z}=G(null,R+S+ce);ce=ce-Z,we=P(S+ce,"height")}}e.value=e.value.map(H=>{if(v.id!==H.id)return H;if(H.type==="shape"&&"pathFormula"in H&&H.pathFormula){const ce=xy[H.pathFormula];let Z="";return"editable"in ce?Z=ce.formula(ue,we,H.keypoints):Z=ce.formula(ue,we),{...H,left:me,top:ae,width:ue,height:we,viewBox:[ue,we],path:Z}}if(H.type==="table"){let ce=w+(we-S)/H.data.length;return ce=ce<36?36:ce,ce===w?{...H,left:me,width:ue}:{...H,left:me,top:ae,width:ue,height:we,cellMinHeight:ce<36?36:ce}}return{...H,left:me,top:ae,width:ue,height:we}})},U=K=>{y=!1,document.ontouchmove=null,document.ontouchend=null,document.onmousemove=null,document.onmouseup=null,t.value=[];const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY;k===Q&&O===ee||(a.updateSlide({elements:e.value}),r.setScalingState(!1),f())};g?(document.ontouchmove=F,document.ontouchend=U):(document.onmousemove=F,document.onmouseup=U)},scaleMultiElement:(p,v,m)=>{let g=!0;const{minX:y,maxX:b,minY:R,maxY:A}=v,S=b-y,w=A-R,M=S/w,C=p.pageX,N=p.pageY,T=JSON.parse(JSON.stringify(e.value));document.onmousemove=k=>{if(!g)return;const O=k.pageX,E=k.pageY,P=(O-C)/n.value;let _=(E-N)/n.value;c.value&&((m===Ft.RIGHT_BOTTOM||m===Ft.LEFT_TOP)&&(_=P/M),(m===Ft.LEFT_BOTTOM||m===Ft.RIGHT_TOP)&&(_=-P/M));let I=y,B=b,Y=R,W=A;m===Ft.RIGHT_BOTTOM?(B=b+P,W=A+_):m===Ft.LEFT_BOTTOM?(I=y+P,W=A+_):m===Ft.LEFT_TOP?(I=y+P,Y=R+_):m===Ft.RIGHT_TOP?(B=b+P,Y=R+_):m===Ft.TOP?Y=R+_:m===Ft.BOTTOM?W=A+_:m===Ft.LEFT?I=y+P:m===Ft.RIGHT&&(B=b+P);const G=B-I,F=W-Y;let U=G/S,K=F/w;U<=0&&(U=0),K<=0&&(K=0),e.value=e.value.map(Q=>{if((Q.type==="image"||Q.type==="shape")&&o.value.includes(Q.id)){const ee=T.find(te=>te.id===Q.id);return{...Q,width:ee.width*U,height:ee.height*K,left:I+(ee.left-y)*U,top:Y+(ee.top-R)*K}}return Q})},document.onmouseup=k=>{g=!1,document.onmousemove=null,document.onmouseup=null,!(C===k.pageX&&N===k.pageY)&&(a.updateSlide({elements:e.value}),f())}}}},eft=(e,t)=>{const n=wt(),{activeElementIdList:r,activeGroupElementId:a,handleElementId:o,editorAreaFocus:i}=Ze(n),{ctrlOrShiftKeyActive:s}=Ze(rl());return{selectElement:(c,f,d=!0)=>{if(i.value||n.setEditorareaFocus(!0),r.value.includes(f.id)){if(s.value){let h=[];if(f.groupId){const p=[];e.value.forEach(v=>{v.groupId===f.groupId&&p.push(v.id)}),h=r.value.filter(v=>!p.includes(v))}else h=r.value.filter(p=>p!==f.id);h.length>0&&n.setActiveElementIdList(h)}else if(o.value!==f.id)n.setHandleElementId(f.id);else if(a.value!==f.id){const h=c instanceof MouseEvent?c.pageX:c.changedTouches[0].pageX,p=c instanceof MouseEvent?c.pageY:c.changedTouches[0].pageY;c.target.onmouseup=v=>{const m=v.pageX,g=v.pageY;h===m&&p===g&&(n.setActiveGroupElementId(f.id),v.target.onmouseup=null)}}}else{let h=[];if(s.value?h=[...r.value,f.id]:h=[f.id],f.groupId){const p=[];e.value.forEach(v=>{v.groupId===f.groupId&&p.push(v.id)}),h=[...h,...p]}n.setActiveElementIdList($r.uniq(h)),n.setHandleElementId(f.id)}d&&t(c,f)}}},Hxe=(e,t,n)=>{const r=pt(),{activeElementIdList:a,activeGroupElementId:o}=Ze(wt()),{shiftKeyState:i}=Ze(rl()),{viewportRatio:s,viewportSize:u}=Ze(r),{addHistorySnapshot:c}=Rn();return{dragElement:(d,h)=>{const p=!(d instanceof MouseEvent);if(p&&(!d.changedTouches||!d.changedTouches[0])||!a.value.includes(h.id))return;let v=!0;const m=u.value,g=u.value*s.value,y=5,R=JSON.parse(JSON.stringify(e.value)).filter(K=>a.value.includes(K.id)),A=h.left,S=h.top,w=h.width,M="height"in h&&h.height?h.height:0,C="rotate"in h&&h.rotate?h.rotate:0,N=p?d.changedTouches[0].pageX:d.pageX,T=p?d.changedTouches[0].pageY:d.pageY;let k=null;const O=h.id===o.value;let E=[],P=[];for(const K of e.value){if(K.type==="line"||O&&K.id===h.id||!O&&a.value.includes(K.id))continue;let Q,ee,te,oe;if("rotate"in K&&K.rotate){const{xRange:se,yRange:de}=bA({left:K.left,top:K.top,width:K.width,height:K.height,rotate:K.rotate});Q=se[0],ee=de[0],te=se[1]-se[0],oe=de[1]-de[0]}else Q=K.left,ee=K.top,te=K.width,oe=K.height;const ue=Q+te,we=ee+oe,me=ee+oe/2,ae=Q+te/2,H={value:ee,range:[Q,ue]},ce={value:we,range:[Q,ue]},Z={value:me,range:[Q,ue]},ie={value:Q,range:[ee,we]},he={value:ue,range:[ee,we]},$={value:ae,range:[ee,we]};E.push(H,ce,Z),P.push(ie,he,$)}const _={value:0,range:[0,m]},I={value:g,range:[0,m]},B={value:g/2,range:[0,m]},Y={value:0,range:[0,g]},W={value:m,range:[0,g]},G={value:m/2,range:[0,g]};E.push(_,I,B),P.push(Y,W,G),E=ek(E),P=ek(P);const F=K=>{const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY;if(k!==!1&&(k=Math.abs(N-Q)<y&&Math.abs(T-ee)<y),!v||k)return;let te=(Q-N)/n.value,oe=(ee-T)/n.value;i.value&&(Math.abs(te)>Math.abs(oe)&&(oe=0),Math.abs(te)<Math.abs(oe)&&(te=0));let ue=A+te,we=S+oe,me,ae,H,ce;if(a.value.length===1||O)if(C){const{xRange:de,yRange:xe}=bA({left:ue,top:we,width:w,height:M,rotate:C});me=de[0],ae=de[1],H=xe[0],ce=xe[1]}else h.type==="line"?(me=ue,ae=ue+Math.max(h.start[0],h.end[0]),H=we,ce=we+Math.max(h.start[1],h.end[1])):(me=ue,ae=ue+w,H=we,ce=we+M);else{const de=[],xe=[],pe=[],be=[];for(let Ee=0;Ee<R.length;Ee++){const Be=R[Ee],et=Be.left+te,ut=Be.top+oe,Vt=Be.width,Yt="height"in Be&&Be.height?Be.height:0,Ve="rotate"in Be&&Be.rotate?Be.rotate:0;if("rotate"in Be&&Be.rotate){const{xRange:De,yRange:Ke}=bA({left:et,top:ut,width:Vt,height:Yt,rotate:Ve});de.push(De[0]),xe.push(Ke[0]),pe.push(De[1]),be.push(Ke[1])}else Be.type==="line"?(de.push(et),xe.push(ut),pe.push(et+Math.max(Be.start[0],Be.end[0])),be.push(ut+Math.max(Be.start[1],Be.end[1]))):(de.push(et),xe.push(ut),pe.push(et+Vt),be.push(ut+Yt))}me=Math.min(...de),ae=Math.max(...pe),H=Math.min(...xe),ce=Math.max(...be)}const Z=me+(ae-me)/2,ie=H+(ce-H)/2,he=[];let $=!1,se=!1;for(let de=0;de<E.length;de++){const{value:xe,range:pe}=E[de],be=Math.min(...pe,me,ae),Ee=Math.max(...pe,me,ae);Math.abs(H-xe)<y&&!se&&(we=we-(H-xe),se=!0,he.push({type:"horizontal",axis:{x:be-50,y:xe},length:Ee-be+100})),Math.abs(ce-xe)<y&&!se&&(we=we-(ce-xe),se=!0,he.push({type:"horizontal",axis:{x:be-50,y:xe},length:Ee-be+100})),Math.abs(ie-xe)<y&&!se&&(we=we-(ie-xe),se=!0,he.push({type:"horizontal",axis:{x:be-50,y:xe},length:Ee-be+100}))}for(let de=0;de<P.length;de++){const{value:xe,range:pe}=P[de],be=Math.min(...pe,H,ce),Ee=Math.max(...pe,H,ce);Math.abs(me-xe)<y&&!$&&(ue=ue-(me-xe),$=!0,he.push({type:"vertical",axis:{x:xe,y:be-50},length:Ee-be+100})),Math.abs(ae-xe)<y&&!$&&(ue=ue-(ae-xe),$=!0,he.push({type:"vertical",axis:{x:xe,y:be-50},length:Ee-be+100})),Math.abs(Z-xe)<y&&!$&&(ue=ue-(Z-xe),$=!0,he.push({type:"vertical",axis:{x:xe,y:be-50},length:Ee-be+100}))}if(t.value=he,a.value.length===1||O)e.value=e.value.map(de=>de.id===h.id?{...de,left:ue,top:we}:de);else{const de=e.value.find(xe=>xe.id===h.id);if(!de)return;e.value=e.value.map(xe=>a.value.includes(xe.id)?xe.id===h.id?{...xe,left:ue,top:we}:{...xe,left:xe.left+(ue-de.left),top:xe.top+(we-de.top)}:xe)}},U=K=>{v=!1,document.ontouchmove=null,document.ontouchend=null,document.onmousemove=null,document.onmouseup=null,t.value=[];const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY;N===Q&&T===ee||(r.updateSlide({elements:e.value}),c())};p?(document.ontouchmove=F,document.ontouchend=U):(document.onmousemove=F,document.onmouseup=U)}}},tft=e=>{const t=pt(),{canvasScale:n}=Ze(wt()),{ctrlOrShiftKeyActive:r}=Ze(rl()),{addHistorySnapshot:a}=Rn();return{dragLineElement:(i,s,u)=>{let c=!0;const f=8,d=i.pageX,h=i.pageY,p=[];for(let v=0;v<e.value.length;v++){const m=e.value[v];if(m.type==="line"||m.rotate)continue;const g=m.left,y=m.top,b=m.width,R=m.height,A=g+b,S=y+R,w=y+R/2,M=g+b/2,C={x:M,y},N={x:M,y:S},T={x:g,y:w},k={x:A,y:w},O={x:g,y},E={x:A,y},P={x:g,y:S},_={x:A,y:S};p.push(C,N,T,k,O,E,P,_)}document.onmousemove=v=>{if(!c)return;const m=v.pageX,g=v.pageY,y=(m-d)/n.value,b=(g-h)/n.value;let R=s.left+s.start[0],A=s.top+s.start[1],S=s.left+s.end[0],w=s.top+s.end[1];const M=s.broken||s.broken2||s.curve||[0,0];let C=s.left+M[0],N=s.top+M[1];const[T,k]=s.cubic||[[0,0],[0,0]];let O=s.left+T[0],E=s.top+T[1],P=s.left+k[0],_=s.top+k[1];if(u===sl.START){R=R+y,A=A+b,Math.abs(R-S)<f&&(R=S),Math.abs(A-w)<f&&(A=w);for(const U of p){const{x:K,y:Q}=U;if(Math.abs(K-R)<f&&Math.abs(Q-A)<f){R=K,A=Q;break}}}else if(u===sl.END){S=S+y,w=w+b,Math.abs(R-S)<f&&(S=R),Math.abs(A-w)<f&&(w=A);for(const U of p){const{x:K,y:Q}=U;if(Math.abs(K-S)<f&&Math.abs(Q-w)<f){S=K,w=Q;break}}}else u===sl.C?(C=C+y,N=N+b,Math.abs(C-R)<f&&(C=R),Math.abs(N-A)<f&&(N=A),Math.abs(C-S)<f&&(C=S),Math.abs(N-w)<f&&(N=w),Math.abs(C-(R+S)/2)<f&&Math.abs(N-(A+w)/2)<f&&(C=(R+S)/2,N=(A+w)/2)):u===sl.C1?(O=O+y,E=E+b,Math.abs(O-R)<f&&(O=R),Math.abs(E-A)<f&&(E=A),Math.abs(O-S)<f&&(O=S),Math.abs(E-w)<f&&(E=w)):u===sl.C2&&(P=P+y,_=_+b,Math.abs(P-R)<f&&(P=R),Math.abs(_-A)<f&&(_=A),Math.abs(P-S)<f&&(P=S),Math.abs(_-w)<f&&(_=w));const I=Math.min(R,S),B=Math.min(A,w),Y=Math.max(R,S),W=Math.max(A,w),G=[0,0],F=[Y-I,W-B];R>S&&(G[0]=Y-I,F[0]=0),A>w&&(G[1]=W-B,F[1]=0),e.value=e.value.map(U=>{if(U.id===s.id){const K={...U,left:I,top:B,start:G,end:F};return u===sl.START||u===sl.END?(r.value?(s.broken&&(K.broken=[C-I,N-B]),s.curve&&(K.curve=[C-I,N-B]),s.cubic&&(K.cubic=[[O-I,E-B],[P-I,_-B]])):(s.broken&&(K.broken=[(G[0]+F[0])/2,(G[1]+F[1])/2]),s.curve&&(K.curve=[(G[0]+F[0])/2,(G[1]+F[1])/2]),s.cubic&&(K.cubic=[[(G[0]+F[0])/2,(G[1]+F[1])/2],[(G[0]+F[0])/2,(G[1]+F[1])/2]])),s.broken2&&(K.broken2=[(G[0]+F[0])/2,(G[1]+F[1])/2])):u===sl.C?(s.broken&&(K.broken=[C-I,N-B]),s.curve&&(K.curve=[C-I,N-B]),s.broken2&&(Y-I>=W-B?K.broken2=[C-I,K.broken2[1]]:K.broken2=[K.broken2[0],N-B])):s.cubic&&(K.cubic=[[O-I,E-B],[P-I,_-B]]),K}return U})},document.onmouseup=v=>{c=!1,document.onmousemove=null,document.onmouseup=null;const m=v.pageX,g=v.pageY;d===m&&h===g||(t.updateSlide({elements:e.value}),a())}}}},nft=(e,t)=>{const n=pt(),{addHistorySnapshot:r}=Rn();return{moveShapeKeypoint:(o,i,s=0)=>{const u=!(o instanceof MouseEvent);if(u&&(!o.changedTouches||!o.changedTouches[0]))return;let c=!0;const f=u?o.changedTouches[0].pageX:o.pageX,d=u?o.changedTouches[0].pageY:o.pageY,h=i.keypoints,p=xy[i.pathFormula];let v=null;if("editable"in p&&p.editable){const y=p.getBaseSize[s],b=p.range[s],R=p.relative[s],A=h[s],S=y(i.width,i.height),w=S*A,[M,C]=b;v={baseSize:S,originPos:w,min:M,max:C,relative:R}}const m=y=>{if(!c)return;const b=y instanceof MouseEvent?y.pageX:y.changedTouches[0].pageX,R=y instanceof MouseEvent?y.pageY:y.changedTouches[0].pageY,A=(b-f)/t.value,S=(R-d)/t.value;e.value=e.value.map(w=>{if(w.id===i.id&&v){const{baseSize:M,originPos:C,min:N,max:T,relative:k}=v,O=w;let E=0;k==="center"?E=(C-A*2)/M:k==="left"?E=(C+A)/M:k==="right"?E=(C-A)/M:k==="top"?E=(C+S)/M:k==="bottom"?E=(C-S)/M:k==="left_bottom"?E=(C+A)/M:k==="right_bottom"?E=(C-A)/M:k==="top_right"?E=(C+S)/M:k==="bottom_right"&&(E=(C-S)/M),E<N&&(E=N),E>T&&(E=T);let P=[];return Array.isArray(h)?(P=[...h],P[s]=E):P=[E],{...w,keypoints:P,path:p.formula(O.width,O.height,P)}}return w})},g=y=>{c=!1,document.ontouchmove=null,document.ontouchend=null,document.onmousemove=null,document.onmouseup=null;const b=y instanceof MouseEvent?y.pageX:y.changedTouches[0].pageX,R=y instanceof MouseEvent?y.pageY:y.changedTouches[0].pageY;f===b&&d===R||(n.updateSlide({elements:e.value}),r())};u?(document.ontouchmove=m,document.ontouchend=g):(document.onmousemove=m,document.onmouseup=g)}}},rft=e=>{const t=wt(),{canvasScale:n,creatingElement:r}=Ze(t),a=f=>{const{start:d,end:h}=f;if(!e.value)return;const p=e.value.getBoundingClientRect(),[v,m]=d,[g,y]=h,b=Math.min(v,g),R=Math.max(v,g),A=Math.min(m,y),S=Math.max(m,y),w=(b-p.x)/n.value,M=(A-p.y)/n.value,C=(R-b)/n.value,N=(S-A)/n.value;return{left:w,top:M,width:C,height:N}},o=f=>{const{start:d,end:h}=f;if(!e.value)return;const p=e.value.getBoundingClientRect(),[v,m]=d,[g,y]=h,b=Math.min(v,g),R=Math.max(v,g),A=Math.min(m,y),S=Math.max(m,y),w=(b-p.x)/n.value,M=(A-p.y)/n.value,C=(R-b)/n.value,N=(S-A)/n.value;return{left:w,top:M,start:[v===b?0:C,m===A?0:N],end:[g===b?0:C,y===A?0:N]}},{createTextElement:i,createShapeElement:s,createLineElement:u}=xp();return{formatCreateSelection:a,insertElementFromCreateSelection:f=>{if(!r.value)return;const d=r.value.type;if(d==="text"){const h=a(f);h&&i(h,{vertical:r.value.vertical})}else if(d==="shape"){const h=a(f);h&&s(h,r.value.data)}else if(d==="line"){const h=o(f);h&&u(h,r.value.data)}t.setCreatingElement(null)}}},zP=()=>{const e=pt(),{activeElementIdList:t,activeElementList:n}=Ze(wt()),{currentSlide:r,viewportRatio:a,viewportSize:o}=Ze(e),{addHistorySnapshot:i}=Rn();return{alignElementToCanvas:u=>{const c=o.value,f=o.value*a.value,{minX:d,maxX:h,minY:p,maxY:v}=Rp(n.value),m=JSON.parse(JSON.stringify(r.value.elements));for(const g of m)if(t.value.includes(g.id)){if(u===Gn.CENTER){const y=p+(v-p)/2-f/2,b=d+(h-d)/2-c/2;g.top=g.top-y,g.left=g.left-b}if(u===Gn.TOP){const y=p-0;g.top=g.top-y}else if(u===Gn.VERTICAL){const y=p+(v-p)/2-f/2;g.top=g.top-y}else if(u===Gn.BOTTOM){const y=v-f;g.top=g.top-y}else if(u===Gn.LEFT){const y=d-0;g.left=g.left-y}else if(u===Gn.HORIZONTAL){const y=d+(h-d)/2-c/2;g.left=g.left-y}else if(u===Gn.RIGHT){const y=h-c;g.left=g.left-y}}e.updateSlide({elements:m}),i()}}},aft=["src"],oft=["src"],ift=["onMousedown"],sft=["onMousedown"],lft=Je(l.defineComponent({__name:"ImageClipHandler",props:{src:{},clipPath:{},width:{},height:{},top:{},left:{},rotate:{},clipData:{}},emits:["clip"],setup(e,{emit:t}){const n=e,r=t,{canvasScale:a}=Ze(wt()),{ctrlOrShiftKeyActive:o}=Ze(rl()),i=l.ref({top:"0",left:"0"}),s=l.ref(!1),u=l.ref(null),c=()=>{const[C,N]=n.clipData?n.clipData.range:[[0,0],[100,100]],T=(N[0]-C[0])/100,k=(N[1]-C[1])/100,O=C[0]/T,E=C[1]/k;return{widthScale:T,heightScale:k,left:O,top:E}},f=l.computed(()=>{const{widthScale:C,heightScale:N,left:T,top:k}=c();return{left:-T,top:-k,width:100/C,height:100/N}}),d=l.computed(()=>({top:f.value.top+"%",left:f.value.left+"%",width:f.value.width+"%",height:f.value.height+"%"})),h=l.ref({top:0,left:0,width:0,height:0}),p=l.computed(()=>{const{top:C,left:N,width:T,height:k}=h.value;return{top:C+"%",left:N+"%",width:T+"%",height:k+"%"}}),v=l.computed(()=>{const C=f.value.width,N=f.value.height,{top:T,left:k,width:O,height:E}=h.value;return{left:-k*(100/O)+"%",top:-T*(100/E)+"%",width:C/O*100+"%",height:N/E*100+"%"}}),m=()=>{const{left:C,top:N}=c();h.value={left:C,top:N,width:100,height:100},i.value={top:-N+"%",left:-C+"%"}},g=()=>{if(s.value)return;if(!u.value){r("clip",null);return}const{left:C,top:N}=c(),T={left:(h.value.left-C)/100*n.width,top:(h.value.top-N)/100*n.height,width:(h.value.width-100)/100*n.width,height:(h.value.height-100)/100*n.height},k={range:u.value,position:T};r("clip",k)},y=C=>{C.key.toUpperCase()===_t.ENTER&&g()};l.onMounted(()=>{m(),document.addEventListener("keydown",y)}),l.onUnmounted(()=>{document.removeEventListener("keydown",y)});const b=()=>{const C={left:parseInt(v.value.left),top:parseInt(v.value.top),width:parseInt(v.value.width),height:parseInt(v.value.height)},N=100/C.width,T=100/C.height,k=[-C.left*N,-C.top*T],O=[N*100+k[0],T*100+k[1]];u.value=[k,O]},R=C=>{s.value=!0;let N=!0;const T=C.pageX,k=C.pageY,O=f.value,E={...h.value};document.onmousemove=P=>{if(!N)return;const _=P.pageX,I=P.pageY,B=(_-T)/a.value,Y=(I-k)/a.value,W=Math.sqrt(B*B+Y*Y),F=Math.atan2(Y,B)-n.rotate/180*Math.PI,U=W*Math.cos(F)/n.width*100,K=W*Math.sin(F)/n.height*100;let Q=E.left+U,ee=E.top+K;Q<0?Q=0:Q+E.width>O.width&&(Q=O.width-E.width),ee<0?ee=0:ee+E.height>O.height&&(ee=O.height-E.height),h.value={...h.value,left:Q,top:ee}},document.onmouseup=()=>{N=!1,document.onmousemove=null,document.onmouseup=null,b(),setTimeout(()=>{s.value=!1},0)}},A=(C,N)=>{s.value=!0;let T=!0;const k=50/n.width*100,O=50/n.height*100,E=C.pageX,P=C.pageY,_=f.value,I={...h.value},B=h.value.width/h.value.height;document.onmousemove=Y=>{if(!T)return;const W=Y.pageX,G=Y.pageY,F=(W-E)/a.value,U=(G-P)/a.value,K=Math.sqrt(F*F+U*U),ee=Math.atan2(U,F)-n.rotate/180*Math.PI;let te=K*Math.cos(ee)/n.width*100,oe=K*Math.sin(ee)/n.height*100;o.value&&((N===Ft.RIGHT_BOTTOM||N===Ft.LEFT_TOP)&&(oe=te/B),(N===Ft.LEFT_BOTTOM||N===Ft.RIGHT_TOP)&&(oe=-te/B));let ue,we,me,ae;N===Ft.LEFT_TOP?(I.left+te<0&&(te=-I.left),I.top+oe<0&&(oe=-I.top),I.width-te<k&&(te=I.width-k),I.height-oe<O&&(oe=I.height-O),me=I.width-te,ae=I.height-oe,ue=I.left+te,we=I.top+oe):N===Ft.RIGHT_TOP?(I.left+I.width+te>_.width&&(te=_.width-(I.left+I.width)),I.top+oe<0&&(oe=-I.top),I.width+te<k&&(te=k-I.width),I.height-oe<O&&(oe=I.height-O),me=I.width+te,ae=I.height-oe,ue=I.left,we=I.top+oe):N===Ft.LEFT_BOTTOM?(I.left+te<0&&(te=-I.left),I.top+I.height+oe>_.height&&(oe=_.height-(I.top+I.height)),I.width-te<k&&(te=I.width-k),I.height+oe<O&&(oe=O-I.height),me=I.width-te,ae=I.height+oe,ue=I.left+te,we=I.top):N===Ft.RIGHT_BOTTOM?(I.left+I.width+te>_.width&&(te=_.width-(I.left+I.width)),I.top+I.height+oe>_.height&&(oe=_.height-(I.top+I.height)),I.width+te<k&&(te=k-I.width),I.height+oe<O&&(oe=O-I.height),me=I.width+te,ae=I.height+oe,ue=I.left,we=I.top):N===Ft.TOP?(I.top+oe<0&&(oe=-I.top),I.height-oe<O&&(oe=I.height-O),me=I.width,ae=I.height-oe,ue=I.left,we=I.top+oe):N===Ft.BOTTOM?(I.top+I.height+oe>_.height&&(oe=_.height-(I.top+I.height)),I.height+oe<O&&(oe=O-I.height),me=I.width,ae=I.height+oe,ue=I.left,we=I.top):N===Ft.LEFT?(I.left+te<0&&(te=-I.left),I.width-te<k&&(te=I.width-k),me=I.width-te,ae=I.height,ue=I.left+te,we=I.top):(I.left+I.width+te>_.width&&(te=_.width-(I.left+I.width)),I.width+te<k&&(te=k-I.width),ae=I.height,me=I.width+te,ue=I.left,we=I.top),h.value={left:ue,top:we,width:me,height:ae}},document.onmouseup=()=>{T=!1,document.onmousemove=null,document.onmouseup=null,b(),setTimeout(()=>s.value=!1,0)}},S=l.computed(()=>{const C="rotate-",N=n.rotate;return N>-22.5&&N<=22.5?C+0:N>22.5&&N<=67.5?C+45:N>67.5&&N<=112.5?C+90:N>112.5&&N<=157.5?C+135:N>157.5||N<=-157.5?C+0:N>-157.5&&N<=-112.5?C+45:N>-112.5&&N<=-67.5?C+90:N>-67.5&&N<=-22.5?C+135:C+0}),w=[Ft.LEFT_TOP,Ft.RIGHT_TOP,Ft.LEFT_BOTTOM,Ft.RIGHT_BOTTOM],M=[Ft.TOP,Ft.BOTTOM,Ft.LEFT,Ft.RIGHT];return(C,N)=>{const T=l.resolveDirective("click-outside");return l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"image-clip-handler",style:l.normalizeStyle(i.value)},[l.createElementVNode("img",{class:"bottom-img",src:e.src,draggable:!1,alt:"",style:l.normalizeStyle(d.value)},null,12,aft),l.createElementVNode("div",{class:"top-image-content",style:l.normalizeStyle({...p.value,clipPath:e.clipPath})},[l.createElementVNode("img",{class:"top-img",src:e.src,draggable:!1,alt:"",style:l.normalizeStyle(v.value)},null,12,oft)],4),l.createElementVNode("div",{class:"operate",style:l.normalizeStyle(p.value),onMousedown:N[0]||(N[0]=l.withModifiers(k=>R(k),["stop"]))},[(l.openBlock(),l.createElementBlock(l.Fragment,null,l.renderList(w,k=>l.createElementVNode("div",{class:l.normalizeClass(["clip-point",k,S.value]),key:k,onMousedown:l.withModifiers(O=>A(O,k),["stop"])},[...N[1]||(N[1]=[l.createElementVNode("svg",{width:"16",height:"16",fill:"#fff",stroke:"#333"},[l.createElementVNode("path",{"stroke-width":"0.3","shape-rendering":"crispEdges",d:"M 16 0 L 0 0 L 0 16 L 4 16 L 4 4 L 16 4 L 16 0 Z"})],-1)])],42,ift)),64)),(l.openBlock(),l.createElementBlock(l.Fragment,null,l.renderList(M,k=>l.createElementVNode("div",{class:l.normalizeClass(["clip-point",k,S.value]),key:k,onMousedown:l.withModifiers(O=>A(O,k),["stop"])},[...N[2]||(N[2]=[l.createElementVNode("svg",{width:"16",height:"16",fill:"#fff",stroke:"#333"},[l.createElementVNode("path",{"stroke-width":"0.3","shape-rendering":"crispEdges",d:"M 16 0 L 0 0 L 0 4 L 16 4 Z"})],-1)])],42,sft)),64))],36)],4)),[[T,g]])}}}),[["__scopeId","data-v-31b3b0f9"]]),cft=["src"],zxe=Je(l.defineComponent({__name:"index",props:{elementInfo:{},selectElement:{type:Function},contextmenus:{type:Function}},setup(e){const t=e,n=wt(),r=pt(),{clipingImageElementId:a}=Ze(n),o=l.computed(()=>a.value===t.elementInfo.id),{addHistorySnapshot:i}=Rn(),s=l.computed(()=>t.elementInfo.shadow),{shadowStyle:u}=bv(s),c=l.computed(()=>t.elementInfo.flipH),f=l.computed(()=>t.elementInfo.flipV),{flipStyle:d}=vk(c,f),h=l.computed(()=>t.elementInfo),{clipShape:p,imgPosition:v}=gQ(h),m=l.computed(()=>t.elementInfo.filters),{filter:g}=Xhe(m),y=R=>{t.elementInfo.lock||(R.stopPropagation(),t.selectElement(R,t.elementInfo))},b=R=>{if(n.setClipingImageElementId(""),!R)return;const{range:A,position:S}=R,w=t.elementInfo.clip||{shape:"rect",range:[[0,0],[100,100]]},M=t.elementInfo.left+S.left,C=t.elementInfo.top+S.top,N=t.elementInfo.width+S.width,T=t.elementInfo.height+S.height;let k=0,O=0;if(t.elementInfo.rotate){const P=M+N/2-(t.elementInfo.left+t.elementInfo.width/2),_=-(C+T/2-(t.elementInfo.top+t.elementInfo.height/2)),I=-t.elementInfo.rotate*Math.PI/180,B=P*Math.cos(I)-_*Math.sin(I),Y=P*Math.sin(I)+_*Math.cos(I);k=B-P,O=-(Y-_)}const E={clip:{...w,range:A},left:M+k,top:C+O,width:N,height:T};r.updateElement({id:t.elementInfo.id,props:E}),i()};return(R,A)=>{const S=l.resolveDirective("contextmenu");return l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["editable-element-image",{lock:e.elementInfo.lock}]),style:l.normalizeStyle({top:e.elementInfo.top+"px",left:e.elementInfo.left+"px",width:e.elementInfo.width+"px",height:e.elementInfo.height+"px"})},[l.createElementVNode("div",{class:"rotate-wrapper",style:l.normalizeStyle({transform:`rotate(${e.elementInfo.rotate}deg)`})},[o.value?(l.openBlock(),l.createBlock(lft,{key:0,src:e.elementInfo.src,clipData:e.elementInfo.clip,width:e.elementInfo.width,height:e.elementInfo.height,top:e.elementInfo.top,left:e.elementInfo.left,rotate:e.elementInfo.rotate,clipPath:l.unref(p).style,onClip:A[0]||(A[0]=w=>b(w))},null,8,["src","clipData","width","height","top","left","rotate","clipPath"])):l.withDirectives((l.openBlock(),l.createElementBlock("div",{key:1,class:"element-content",style:l.normalizeStyle({filter:l.unref(u)?`drop-shadow(${l.unref(u)})`:"",transform:l.unref(d)}),onMousedown:A[2]||(A[2]=w=>y(w)),onTouchstart:A[3]||(A[3]=w=>y(w))},[l.createVNode(Uhe,{elementInfo:e.elementInfo},null,8,["elementInfo"]),l.createElementVNode("div",{class:"image-content",style:l.normalizeStyle({clipPath:l.unref(p).style})},[l.createElementVNode("img",{src:e.elementInfo.src,draggable:!1,style:l.normalizeStyle({top:l.unref(v).top,left:l.unref(v).left,width:l.unref(v).width,height:l.unref(v).height,filter:l.unref(g)}),onDragstart:A[1]||(A[1]=l.withModifiers(()=>{},["prevent"])),alt:""},null,44,cft),e.elementInfo.colorMask?(l.openBlock(),l.createElementBlock("div",{key:0,class:"color-mask",style:l.normalizeStyle({backgroundColor:e.elementInfo.colorMask})},null,4)):l.createCommentVNode("",!0)],4)],36)),[[S,e.contextmenus]])],4)],6)}}}),[["__scopeId","data-v-3d37318b"]]),Pi=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ox=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let eq=null;const jp=function(e,t,n){let r=eq||(eq=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},uft=function(){eq=null},_1=function(e,t,n,r){return n&&(Gxe(e,t,n,r,-1)||Gxe(e,t,n,r,1))},fft=/^(img|br|input|textarea|hr)$/i;function Gxe(e,t,n,r,a){for(var o;;){if(e==n&&t==r)return!0;if(t==(a<0?0:Su(e))){let i=e.parentNode;if(!i||i.nodeType!=1||U5(e)||fft.test(e.nodeName)||e.contentEditable=="false")return!1;t=Pi(e)+(a<0?0:1),e=i}else if(e.nodeType==1){let i=e.childNodes[t+(a<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)t+=a;else return!1;else e=i,t=a<0?Su(e):0}else return!1}}function Su(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function dft(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Su(e)}else if(e.parentNode&&!U5(e))t=Pi(e),e=e.parentNode;else return null}}function hft(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!U5(e))t=Pi(e)+1,e=e.parentNode;else return null}}function pft(e,t,n){for(let r=t==0,a=t==Su(e);r||a;){if(e==n)return!0;let o=Pi(e);if(e=e.parentNode,!e)return!1;r=r&&o==0,a=a&&o==Su(e)}}function U5(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const GP=function(e){return e.focusNode&&_1(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function I1(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function vft(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function mft(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Su(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Su(r.startContainer),r.startOffset)}}}const lh=typeof navigator<"u"?navigator:null,Jxe=typeof document<"u"?document:null,bm=lh&&lh.userAgent||"",tq=/Edge\/(\d+)/.exec(bm),jxe=/MSIE \d/.exec(bm),nq=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bm),xl=!!(jxe||nq||tq),Am=jxe?document.documentMode:nq?+nq[1]:tq?+tq[1]:0,wu=!xl&&/gecko\/(\d+)/i.test(bm);wu&&+(/Firefox\/(\d+)/.exec(bm)||[0,0])[1];const rq=!xl&&/Chrome\/(\d+)/.exec(bm),_i=!!rq,qxe=rq?+rq[1]:0,ns=!xl&&!!lh&&/Apple Computer/.test(lh.vendor),ix=ns&&(/Mobile\/\w+/.test(bm)||!!lh&&lh.maxTouchPoints>2),Mu=ix||(lh?/Mac/.test(lh.platform):!1),$xe=lh?/Win/.test(lh.platform):!1,qp=/Android \d/.test(bm),W5=!!Jxe&&"webkitFontSmoothing"in Jxe.documentElement.style,gft=W5?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yft(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function $p(e,t){return typeof e=="number"?e:e[t]}function bft(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function eSe(e,t,n){let r=e.someProp("scrollThreshold")||0,a=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let i=n||e.dom;i;){if(i.nodeType!=1){i=ox(i);continue}let s=i,u=s==o.body,c=u?yft(o):bft(s),f=0,d=0;if(t.top<c.top+$p(r,"top")?d=-(c.top-t.top+$p(a,"top")):t.bottom>c.bottom-$p(r,"bottom")&&(d=t.bottom-t.top>c.bottom-c.top?t.top+$p(a,"top")-c.top:t.bottom-c.bottom+$p(a,"bottom")),t.left<c.left+$p(r,"left")?f=-(c.left-t.left+$p(a,"left")):t.right>c.right-$p(r,"right")&&(f=t.right-c.right+$p(a,"right")),f||d)if(u)o.defaultView.scrollBy(f,d);else{let p=s.scrollLeft,v=s.scrollTop;d&&(s.scrollTop+=d),f&&(s.scrollLeft+=f);let m=s.scrollLeft-p,g=s.scrollTop-v;t={left:t.left-m,top:t.top-g,right:t.right-m,bottom:t.bottom-g}}let h=u?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(h))break;i=h=="absolute"?i.offsetParent:ox(i)}}function Aft(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,a;for(let o=(t.left+t.right)/2,i=n+1;i<Math.min(innerHeight,t.bottom);i+=5){let s=e.root.elementFromPoint(o,i);if(!s||s==e.dom||!e.dom.contains(s))continue;let u=s.getBoundingClientRect();if(u.top>=n-20){r=s,a=u.top;break}}return{refDOM:r,refTop:a,stack:tSe(e.dom)}}function tSe(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=ox(r));return t}function Rft({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;nSe(n,r==0?0:r-t)}function nSe(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:a,left:o}=e[n];r.scrollTop!=a+t&&(r.scrollTop=a+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let sx=null;function xft(e){if(e.setActive)return e.setActive();if(sx)return e.focus(sx);let t=tSe(e);e.focus(sx==null?{get preventScroll(){return sx={preventScroll:!0},!0}}:void 0),sx||(sx=!1,nSe(t,0))}function rSe(e,t){let n,r=2e8,a,o=0,i=t.top,s=t.top,u,c;for(let f=e.firstChild,d=0;f;f=f.nextSibling,d++){let h;if(f.nodeType==1)h=f.getClientRects();else if(f.nodeType==3)h=jp(f).getClientRects();else continue;for(let p=0;p<h.length;p++){let v=h[p];if(v.top<=i&&v.bottom>=s){i=Math.max(v.bottom,i),s=Math.min(v.top,s);let m=v.left>t.left?v.left-t.left:v.right<t.left?t.left-v.right:0;if(m<r){n=f,r=m,a=m&&n.nodeType==3?{left:v.right<t.left?v.right:v.left,top:t.top}:t,f.nodeType==1&&m&&(o=d+(t.left>=(v.left+v.right)/2?1:0));continue}}else v.top>t.top&&!u&&v.left<=t.left&&v.right>=t.left&&(u=f,c={left:Math.max(v.left,Math.min(v.right,t.left)),top:v.top});!n&&(t.left>=v.right&&t.top>=v.top||t.left>=v.left&&t.top>=v.bottom)&&(o=d+1)}}return!n&&u&&(n=u,a=c,r=0),n&&n.nodeType==3?Sft(n,a):!n||r&&n.nodeType==1?{node:e,offset:o}:rSe(n,a)}function Sft(e,t){let n=e.nodeValue.length,r=document.createRange(),a;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let i=Rm(r,1);if(i.top!=i.bottom&&aq(t,i)){a={node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),a||{node:e,offset:0}}function aq(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function wft(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Mft(e,t,n){let{node:r,offset:a}=rSe(t,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return e.docView.posFromDOM(r,a,o)}function Nft(e,t,n,r){let a=-1;for(let o=t,i=!1;o!=e.dom;){let s=e.docView.nearestDesc(o,!0),u;if(!s)return null;if(s.dom.nodeType==1&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((u=s.dom.getBoundingClientRect()).width||u.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&u.left>r.left||u.top>r.top?a=s.posBefore:(!i&&u.right<r.left||u.bottom<r.top)&&(a=s.posAfter),i=!0),!s.contentDOM&&a<0&&!s.node.isText))return(s.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?s.posBefore:s.posAfter;o=s.dom.parentNode}return a>-1?a:e.docView.posFromDOM(t,n,-1)}function aSe(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let a=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=a;;){let i=e.childNodes[o];if(i.nodeType==1){let s=i.getClientRects();for(let u=0;u<s.length;u++){let c=s[u];if(aq(t,c))return aSe(i,t,c)}}if((o=(o+1)%r)==a)break}return e}function Tft(e,t){let n=e.dom.ownerDocument,r,a=0,o=mft(n,t.left,t.top);o&&({node:r,offset:a}=o);let i=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!i||!e.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=e.dom.getBoundingClientRect();if(!aq(t,c)||(i=aSe(e.dom,t,c),!i))return null}if(ns)for(let c=i;r&&c;c=ox(c))c.draggable&&(r=void 0);if(i=wft(i,t),r){if(wu&&r.nodeType==1&&(a=Math.min(a,r.childNodes.length),a<r.childNodes.length)){let f=r.childNodes[a],d;f.nodeName=="IMG"&&(d=f.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&a++}let c;W5&&a&&r.nodeType==1&&(c=r.childNodes[a-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&a--,r==e.dom&&a==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(a==0||r.nodeType!=1||r.childNodes[a-1].nodeName!="BR")&&(s=Nft(e,r,a,t))}s==null&&(s=Mft(e,i,t));let u=e.docView.nearestDesc(i,!0);return{pos:s,inside:u?u.posAtStart-u.border:-1}}function oSe(e){return e.top<e.bottom||e.left<e.right}function Rm(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(oSe(r))return r}return Array.prototype.find.call(n,oSe)||e.getBoundingClientRect()}const Cft=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function iSe(e,t,n){let{node:r,offset:a,atom:o}=e.docView.domFromPos(t,n<0?-1:1),i=W5||wu;if(r.nodeType==3)if(i&&(Cft.test(r.nodeValue)||(n<0?!a:a==r.nodeValue.length))){let u=Rm(jp(r,a,a),n);if(wu&&a&&/\s/.test(r.nodeValue[a-1])&&a<r.nodeValue.length){let c=Rm(jp(r,a-1,a-1),-1);if(c.top==u.top){let f=Rm(jp(r,a,a+1),-1);if(f.top!=u.top)return Y5(f,f.left<c.left)}}return u}else{let u=a,c=a,f=n<0?1:-1;return n<0&&!a?(c++,f=-1):n>=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:c++,Y5(Rm(jp(r,u,c),f),f<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(o==null&&a&&(n<0||a==Su(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return oq(u.getBoundingClientRect(),!1)}if(o==null&&a<Su(r)){let u=r.childNodes[a];if(u.nodeType==1)return oq(u.getBoundingClientRect(),!0)}return oq(r.getBoundingClientRect(),n>=0)}if(o==null&&a&&(n<0||a==Su(r))){let u=r.childNodes[a-1],c=u.nodeType==3?jp(u,Su(u)-(i?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(c)return Y5(Rm(c,1),!1)}if(o==null&&a<Su(r)){let u=r.childNodes[a];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let c=u?u.nodeType==3?jp(u,0,i?0:1):u.nodeType==1?u:null:null;if(c)return Y5(Rm(c,-1),!0)}return Y5(Rm(r.nodeType==3?jp(r):r,-n),n>=0)}function Y5(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function oq(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function sSe(e,t,n){let r=e.state,a=e.root.activeElement;r!=t&&e.updateState(t),a!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),a!=e.dom&&a&&a.focus()}}function Lft(e,t,n){let r=t.selection,a=n=="up"?r.$from:r.$to;return sSe(e,t,()=>{let{node:o}=e.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let s=e.docView.nearestDesc(o,!0);if(!s)break;if(s.node.isBlock){o=s.contentDOM||s.dom;break}o=s.dom.parentNode}let i=iSe(e,a.pos,1);for(let s=o.firstChild;s;s=s.nextSibling){let u;if(s.nodeType==1)u=s.getClientRects();else if(s.nodeType==3)u=jp(s,0,s.nodeValue.length).getClientRects();else continue;for(let c=0;c<u.length;c++){let f=u[c];if(f.bottom>f.top+1&&(n=="up"?i.top-f.top>(f.bottom-i.top)*2:f.bottom-i.bottom>(i.bottom-f.top)*2))return!1}}return!0})}const kft=/[\u0590-\u08ac]/;function Oft(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let a=r.parentOffset,o=!a,i=a==r.parent.content.size,s=e.domSelection();return s?!kft.test(r.parent.textContent)||!s.modify?n=="left"||n=="backward"?o:i:sSe(e,t,()=>{let{focusNode:u,focusOffset:c,anchorNode:f,anchorOffset:d}=e.domSelectionRange(),h=s.caretBidiLevel;s.modify("move",n,"character");let p=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:v,focusOffset:m}=e.domSelectionRange(),g=v&&!p.contains(v.nodeType==1?v:v.parentNode)||u==v&&c==m;try{s.collapse(f,d),u&&(u!=f||c!=d)&&s.extend&&s.extend(u,c)}catch{}return h!=null&&(s.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let lSe=null,cSe=null,uSe=!1;function Eft(e,t,n){return lSe==t&&cSe==n?uSe:(lSe=t,cSe=n,uSe=n=="up"||n=="down"?Lft(e,t,n):Oft(e,t,n))}const Nu=0,fSe=1,F1=2,ch=3;class Z5{constructor(t,n,r,a){this.parent=t,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=Nu,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,r){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,r=this.posAtStart;;n++){let a=this.children[n];if(a==t)return r;r+=a.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,n,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode))if(r<0){let o,i;if(t==this.contentDOM)o=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(t==this.contentDOM)o=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let a;if(t==this.dom&&this.contentDOM)a=n>Pi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=t;;o=o.parentNode){if(o==this.dom){a=!1;break}if(o.previousSibling)break}if(a==null&&n==t.childNodes.length)for(let o=t;;o=o.parentNode){if(o==this.dom){a=!0;break}if(o.nextSibling)break}}return a??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let r=!0,a=t;a;a=a.parentNode){let o=this.getDesc(a),i;if(o&&(!n||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(t.nodeType==1?t:t.parentNode):i==t))r=!1;else return o}}getDesc(t){let n=t.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(t,n,r){for(let a=t;a;a=a.parentNode){let o=this.getDesc(a);if(o)return o.localPosFromDOM(t,n,r)}return-1}descAt(t){for(let n=0,r=0;n<this.children.length;n++){let a=this.children[n],o=r+a.size;if(r==t&&o!=r){for(;!a.border&&a.children.length;)for(let i=0;i<a.children.length;i++){let s=a.children[i];if(s.size){a=s;break}}return a}if(t<o)return a.descAt(t-r-a.border);r=o}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,a=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],s=o+i.size;if(s>t||i instanceof pSe){a=t-o;break}o=s}if(a)return this.children[r].domFromPos(a-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof dSe&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Pi(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?Pi(o.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let a=-1,o=-1;for(let i=r,s=0;;s++){let u=this.children[s],c=i+u.size;if(a==-1&&t<=c){let f=i+u.border;if(t>=f&&n<=c-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(t,n,f);t=i;for(let d=s;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){a=Pi(h.dom)+1;break}t-=h.size}a==-1&&(a=0)}if(a>-1&&(c>n||s==this.children.length-1)){n=c;for(let f=s+1;f<this.children.length;f++){let d=this.children[f];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=Pi(d.dom);break}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:n,fromOffset:a,toOffset:o}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:r}=this.domFromPos(t,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]}setSelection(t,n,r,a=!1){let o=Math.min(t,n),i=Math.max(t,n);for(let p=0,v=0;p<this.children.length;p++){let m=this.children[p],g=v+m.size;if(o>v&&i<g)return m.setSelection(t-v-m.border,n-v-m.border,r,a);v=g}let s=this.domFromPos(t,t?-1:1),u=n==t?s:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),f=r.domSelectionRange(),d=!1;if((wu||ns)&&t==n){let{node:p,offset:v}=s;if(p.nodeType==3){if(d=!!(v&&p.nodeValue[v-1]==`
342
+ `))}if(me.elements){for(const H of me.elements)if(H.type==="text"){const ce=g(H.content),Z={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,fontSize:i/u.value,fontFace:"微软雅黑",color:"#000000",valign:"top",margin:10/u.value,paraSpaceBefore:5/u.value,lineSpacingMultiple:1.5/1.25,autoFit:!0};if(H.rotate&&(Z.rotate=H.rotate),H.wordSpace&&(Z.charSpacing=H.wordSpace/u.value),H.lineHeight&&(Z.lineSpacingMultiple=H.lineHeight/1.25),H.fill){const ie=m(H.fill),he=H.opacity===void 0?1:H.opacity;Z.fill={color:ie.color,transparency:(1-ie.alpha*he)*100}}H.defaultColor&&(Z.color=m(H.defaultColor).color),H.defaultFontName&&(Z.fontFace=H.defaultFontName),H.shadow&&(Z.shadow=b(H.shadow)),(P=H.outline)!=null&&P.width&&(Z.line=A(H.outline)),H.opacity!==void 0&&(Z.transparency=(1-H.opacity)*100),H.paragraphSpace!==void 0&&(Z.paraSpaceBefore=H.paragraphSpace/u.value),H.vertical&&(Z.vert="eaVert"),ae.addText(ce,Z)}else if(H.type==="image"){const ce={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(w(H.src)?ce.data=H.src:ce.path=H.src,H.flipH&&(ce.flipH=H.flipH),H.flipV&&(ce.flipV=H.flipV),H.rotate&&(ce.rotate=H.rotate),H.link){const Z=S(H.link);Z&&(ce.hyperlink=Z)}if((_=H.filters)!=null&&_.opacity&&(ce.transparency=100-parseInt((I=H.filters)==null?void 0:I.opacity)),H.clip){H.clip.shape==="ellipse"&&(ce.rounding=!0);const[Z,ie]=H.clip.range,[he,$]=Z,[se,de]=ie,xe=H.width/((se-he)/100),pe=H.height/((de-$)/100);ce.w=xe/s.value,ce.h=pe/s.value,ce.sizing={type:"crop",x:he/100*xe/s.value,y:$/100*pe/s.value,w:(se-he)/100*xe/s.value,h:(de-$)/100*pe/s.value}}ae.addImage(ce)}else if(H.type==="shape"){if(H.special){const ce=document.createElement("div"),Z=l.createVNode(yQ,{elementInfo:H},null);l.render(Z,ce);const ie=ce.querySelector("svg"),he=ie?Ibe(ie):"";if(l.render(null,ce),!he)continue;const $={data:he,x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(H.rotate&&($.rotate=H.rotate),H.flipH&&($.flipH=H.flipH),H.flipV&&($.flipV=H.flipV),H.link){const se=S(H.link);se&&($.hyperlink=se)}ae.addImage($)}else{const ce={x:H.width/H.viewBox[0],y:H.height/H.viewBox[1]},Z=y(kde(H.path),ce);let ie=m(H.fill);if(H.gradient){const se=H.gradient.colors,de=se[0].color,xe=se[se.length-1].color,pe=yt.mix(de,xe).toHexString();ie=m(pe)}H.pattern&&(ie=m("#00000000"));const he=H.opacity===void 0?1:H.opacity,$={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,fill:{color:ie.color,transparency:(1-ie.alpha*he)*100},points:Z};if(H.flipH&&($.flipH=H.flipH),H.flipV&&($.flipV=H.flipV),H.shadow&&($.shadow=b(H.shadow)),(B=H.outline)!=null&&B.width&&($.line=A(H.outline)),H.rotate&&($.rotate=H.rotate),H.link){const se=S(H.link);se&&($.hyperlink=se)}ae.addShape("custGeom",$)}if(H.text){const ce=g(H.text.content),Z={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,fontSize:i/u.value,fontFace:"微软雅黑",color:"#000000",paraSpaceBefore:5/u.value,valign:H.text.align};H.rotate&&(Z.rotate=H.rotate),H.text.defaultColor&&(Z.color=m(H.text.defaultColor).color),H.text.defaultFontName&&(Z.fontFace=H.text.defaultFontName),ae.addText(ce,Z)}if(H.pattern){const ce={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(w(H.pattern)?ce.data=H.pattern:ce.path=H.pattern,H.flipH&&(ce.flipH=H.flipH),H.flipV&&(ce.flipV=H.flipV),H.rotate&&(ce.rotate=H.rotate),H.link){const Z=S(H.link);Z&&(ce.hyperlink=Z)}ae.addImage(ce)}}else if(H.type==="line"){const ce=TK(H),Z=y(kde(ce)),{minX:ie,maxX:he,minY:$,maxY:se}=zc(H),de=m(H.color),xe={x:H.left/s.value,y:H.top/s.value,w:(he-ie)/s.value,h:(se-$)/s.value,line:{color:de.color,transparency:(1-de.alpha)*100,width:H.width/u.value,dashType:R[H.style],beginArrowType:H.points[0]?"arrow":"none",endArrowType:H.points[1]?"arrow":"none"},points:Z};H.shadow&&(xe.shadow=b(H.shadow)),ae.addShape("custGeom",xe)}else if(H.type==="chart"){const ce=[];for(let de=0;de<H.data.series.length;de++){const xe=H.data.series[de];ce.push({name:`系列${de+1}`,labels:H.data.labels,values:xe})}let Z=[];if(H.themeColors.length===10)Z=H.themeColors.map(de=>m(de).color);else if(H.themeColors.length===1)Z=yt(H.themeColors[0]).analogous(10).map(de=>m(de.toHexString()).color);else{const de=H.themeColors.length,xe=yt(H.themeColors[de-1]).analogous(11-de).map(pe=>pe.toHexString());Z=[...H.themeColors.slice(0,de-1),...xe].map(pe=>m(pe).color)}const ie={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,chartColors:H.chartType==="pie"||H.chartType==="ring"?Z:Z.slice(0,H.data.series.length)},he=m(H.textColor||"#000000").color;ie.catAxisLabelColor=he,ie.valAxisLabelColor=he;const $=14/u.value;if(ie.catAxisLabelFontSize=$,ie.valAxisLabelFontSize=$,H.fill||H.outline){const de={};H.fill&&(de.fill={color:m(H.fill).color}),H.outline&&(de.border={pt:H.outline.width/u.value,color:m(H.outline.color).color}),ie.plotArea=de}(H.data.series.length>1&&H.chartType!=="scatter"||H.chartType==="pie"||H.chartType==="ring")&&(ie.showLegend=!0,ie.legendPos="b",ie.legendColor=he,ie.legendFontSize=$);let se=E.ChartType.bar;H.chartType==="bar"?(se=E.ChartType.bar,ie.barDir="col",(Y=H.options)!=null&&Y.stack&&(ie.barGrouping="stacked")):H.chartType==="column"?(se=E.ChartType.bar,ie.barDir="bar",(W=H.options)!=null&&W.stack&&(ie.barGrouping="stacked")):H.chartType==="line"?(se=E.ChartType.line,(G=H.options)!=null&&G.lineSmooth&&(ie.lineSmooth=!0)):H.chartType==="area"?se=E.ChartType.area:H.chartType==="radar"?se=E.ChartType.radar:H.chartType==="scatter"?(se=E.ChartType.scatter,ie.lineSize=0):H.chartType==="pie"?se=E.ChartType.pie:H.chartType==="ring"&&(se=E.ChartType.doughnut,ie.holeSize=60),ae.addChart(se,ce,ie)}else if(H.type==="table"){const ce=[];for(let de=0;de<H.data.length;de++){const xe=H.data[de];for(let pe=0;pe<xe.length;pe++){const be=xe[pe];if(be.colspan>1||be.rowspan>1)for(let Ee=de;Ee<de+be.rowspan;Ee++)for(let Be=Ee===de?pe+1:pe;Be<pe+be.colspan;Be++)ce.push(`${Ee}_${Be}`)}}const Z=[],ie=H.theme;let he=null,$=[];ie&&(he=m(ie.color),$=dde(ie.color).map(de=>m(de)));for(let de=0;de<H.data.length;de++){const xe=H.data[de],pe=[];for(let be=0;be<xe.length;be++){const Ee=xe[be],Be={colspan:Ee.colspan,rowspan:Ee.rowspan,bold:((F=Ee.style)==null?void 0:F.bold)||!1,italic:((U=Ee.style)==null?void 0:U.em)||!1,underline:{style:(K=Ee.style)!=null&&K.underline?"sng":"none"},align:((Q=Ee.style)==null?void 0:Q.align)||"left",valign:"middle",fontFace:((ee=Ee.style)==null?void 0:ee.fontname)||"微软雅黑",fontSize:((te=Ee.style)!=null&&te.fontsize?parseInt((oe=Ee.style)==null?void 0:oe.fontsize):14)/u.value};if(ie&&he){let et;de%2===0?et=$[1]:et=$[0],(ie.rowHeader&&de===0||ie.rowFooter&&de===H.data.length-1||ie.colHeader&&be===0||ie.colFooter&&be===xe.length-1)&&(et=he),Be.fill={color:et.color,transparency:(1-et.alpha)*100}}if((ue=Ee.style)!=null&&ue.backcolor){const et=m(Ee.style.backcolor);Be.fill={color:et.color,transparency:(1-et.alpha)*100}}(we=Ee.style)!=null&&we.color&&(Be.color=m(Ee.style.color).color),ce.includes(`${de}_${be}`)||pe.push({text:Ee.text,options:Be})}pe.length&&Z.push(pe)}const se={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,colW:H.colWidths.map(de=>H.width*de/s.value)};H.theme&&(se.fill={color:"#ffffff"}),H.outline.width&&H.outline.color&&(se.border={type:H.outline.style==="solid"?"solid":"dash",pt:H.outline.width/u.value,color:m(H.outline.color).color}),ae.addTable(Z,se)}else if(H.type==="latex"){const ce=document.createElement("div"),Z=l.createVNode(xJ,{elementInfo:H},null);l.render(Z,ce);const ie=ce.querySelector("svg"),he=ie?Ibe(ie):"";if(l.render(null,ce),!he)continue;const $={data:he,x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value};if(H.link){const se=S(H.link);se&&($.hyperlink=se)}ae.addImage($)}else if(!k&&(H.type==="video"||H.type==="audio")){const ce={x:H.left/s.value,y:H.top/s.value,w:H.width/s.value,h:H.height/s.value,path:H.src,type:H.type};H.type==="video"&&H.poster&&(ce.cover=H.poster);const Z=H.src.match(/\.([a-zA-Z0-9]+)(?:[\?#]|$)/);Z&&Z[1]?ce.extn=Z[1]:H.ext&&(ce.extn=H.ext);const ie=["avi","mp4","m4v","mov","wmv"],he=["mp3","m4a","mp4","wav","wma"];ce.extn&&[...ie,...he].includes(ce.extn)&&ae.addMedia(ce)}}}return new Promise((me,ae)=>{setTimeout(()=>{const H=`${a.value||`ppt_${+new Date}`}`;O?E.write({outputType:"blob"}).then(async ce=>{const Z=ce;c.value=!1;const ie=new File([Z],`${H}.pptx`,{type:"application/vnd.openxmlformats-officedocument.presentationml.presentation"});me(ie)}).catch(()=>{c.value=!1,nn.error("生成失败"),ae(null)}):E.writeFile({fileName:`${H}.pptx`}).then(()=>{c.value=!1,me(null)}).catch(()=>{c.value=!1,nn.error("导出失败"),ae(null)})},200)})}}},Kut={class:"editor-header"},Qut={class:"left"},Hut={class:"right"},zut=Je(l.defineComponent({__name:"index",setup(e){const t=wt(),n=pt(),{title:r,slides:a}=Ze(n),{enterScreening:o}=vv(),{exporting:i}=BK(),{resetSlides:s}=Pd(),{exportPPTX:u}=ax(),c=l.inject("onUploadFile"),f=l.inject("onSave"),d=l.inject("onReturn"),h=l.ref(!1),p=l.ref(!1);l.ref(!1),l.ref(""),l.shallowRef(null);const v=l.ref(null),m=l.ref(!1),g=w=>{t.setDialogForExport(w),h.value=!1},y=w=>/^data:.+;base64,/.test(w),b=w=>{var C,N;const M=[];for(const T of w){if(((C=T.background)==null?void 0:C.type)==="image"&&((N=T.background.image)!=null&&N.src)&&y(T.background.image.src)){const k=T.background.image;M.push({base64:k.src,setUrl:O=>{k.src=O}})}for(const k of T.elements||[]){if(k.type==="image"&&y(k.src)){const O=k;M.push({base64:O.src,setUrl:E=>{O.src=E}})}if(k.type==="video"&&k.poster&&y(k.poster)){const O=k;M.push({base64:O.poster,setUrl:E=>{O.poster=E}})}if(k.type==="shape"&&k.pattern&&y(k.pattern)){const O=k;M.push({base64:O.pattern,setUrl:E=>{O.pattern=E}})}}}return M},R=async()=>{m.value=!0;const[w,M]=await Promise.all([S(),A()]),C=await u(a.value,!0,!1,!0),N=C&&c?await c({file:C}):"";f&&await f({pptUrl:N,json:w,slideImages:M}),m.value=!1},A=async()=>{try{const w=v.value;if(!w)return[];const M=w.querySelectorAll(".thumbnail-slide");if(!M.length)return[];const C={quality:.9,width:800,pixelRatio:2,fontEmbedCSS:""},N=[];for(const T of M){T.querySelectorAll("foreignObject [xmlns]").forEach(P=>P.removeAttribute("xmlns"));const O=await sk(T,C),E=c?await c({base64:O}):O;N.push(E)}return N}catch{return[]}},S=async()=>{const{title:w,theme:M,slides:C,viewportSize:N,viewportRatio:T}=n.$state,k=JSON.parse(JSON.stringify(C)),O={title:w,theme:M,slides:k,width:N,height:N*T},E=b(O.slides);if(E.length){const P=new Map,_=[...new Set(E.map(B=>B.base64))];await Promise.all(_.map(async B=>{const Y=c?await c({base64:B}):B;P.set(B,Y)}));for(const B of E){const Y=P.get(B.base64);Y&&B.setUrl(Y)}const I=b(C);for(const B of I){const Y=P.get(B.base64);Y&&B.setUrl(Y)}}return O};return(w,M)=>{const C=Ide,N=jWe,T=zWe,k=KWe,O=wy,E=XWe,P=l.resolveDirective("tooltip");return l.openBlock(),l.createElementBlock("div",Kut,[l.createElementVNode("div",Qut,[l.unref(d)?l.withDirectives((l.openBlock(),l.createElementBlock("div",{key:0,class:"menu-item",onClick:M[0]||(M[0]=_=>l.unref(d)())},[l.createVNode(C,{class:"icon"})])),[[P,w.$t("header.back")]]):l.createCommentVNode("",!0),l.createVNode(In,{trigger:"click",placement:"bottom-start",value:h.value,"onUpdate:value":M[3]||(M[3]=_=>h.value=_)},{content:l.withCtx(()=>[l.createVNode(Rf,{class:"popover-menu-item",onClick:M[1]||(M[1]=_=>{l.unref(s)(),h.value=!1})},{default:l.withCtx(()=>[l.createVNode(N,{class:"icon"}),l.createTextVNode(" "+l.toDisplayString(w.$t("header.resetSlides")),1)]),_:1}),l.createVNode(Rf,{class:"popover-menu-item",onClick:M[2]||(M[2]=_=>{h.value=!1,p.value=!0})},{default:l.withCtx(()=>[l.createVNode(T,{class:"icon"}),l.createTextVNode(" "+l.toDisplayString(w.$t("header.shortcuts")),1)]),_:1})]),_:1},8,["value"])]),l.createElementVNode("div",Hut,[l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"menu-item",onClick:M[4]||(M[4]=_=>R())},[l.createVNode(k,{class:"icon"})])),[[P,w.$t("header.save")]]),l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"menu-item",onClick:M[5]||(M[5]=_=>g("pptx"))},[l.createVNode(O,{class:"icon"})])),[[P,w.$t("header.export")]]),l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"menu-item",onClick:M[6]||(M[6]=_=>l.unref(o)())},[l.createVNode(E,{class:"icon"})])),[[P,w.$t("header.slideshowF5")]])]),l.createVNode(aZe,{width:320,visible:p.value,"onUpdate:visible":M[7]||(M[7]=_=>p.value=_),placement:"right"},{title:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(w.$t("header.shortcuts")),1)]),default:l.withCtx(()=>[l.createVNode(jYe)]),_:1},8,["visible"]),l.createVNode(wA,{loading:l.unref(i),tip:w.$t("common.importing")},null,8,["loading","tip"]),l.createVNode(wA,{loading:m.value,tip:w.$t("common.saving")},null,8,["loading","tip"]),l.createElementVNode("div",{class:"offscreen-cover",ref_key:"offscreenCoverRef",ref:v},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(a),_=>(l.openBlock(),l.createBlock(yl,{key:_.id,slide:_,size:800},null,8,["slide"]))),128))],512)])}}}),[["__scopeId","data-v-cfe561ab"]]),Gut=()=>{const e=window.getSelection();e&&e.removeAllRanges()},Jut=e=>{const t=l.ref(0),n=l.ref(0),r=wt(),{canvasPercentage:a,canvasDragged:o}=Ze(r),{viewportRatio:i,viewportSize:s}=Ze(pt()),u=()=>{if(!e.value)return;const p=e.value.clientWidth,v=e.value.clientHeight;if(v/p>i.value){const m=p*(a.value/100);r.setCanvasScale(m/s.value),t.value=(p-m)/2,n.value=(v-m*i.value)/2}else{const m=v*(a.value/100);r.setCanvasScale(m/(s.value*i.value)),t.value=(p-m/i.value)/2,n.value=(v-m)/2}},c=(p,v)=>{if(!e.value)return;const m=e.value.clientWidth,g=e.value.clientHeight;if(g/m>i.value){const y=m*(p/100),b=m*(v/100),R=y*i.value,A=b*i.value;r.setCanvasScale(y/s.value),t.value=t.value-(y-b)/2,n.value=n.value-(R-A)/2}else{const y=g*(p/100),b=g*(v/100),R=y/i.value,A=b/i.value;r.setCanvasScale(y/(s.value*i.value)),t.value=t.value-(R-A)/2,n.value=n.value-(y-b)/2}};l.watch(a,c),l.watch(i,u),l.watch(s,u),l.watch(o,()=>{o.value||u()});const f=l.computed(()=>({width:s.value,height:s.value*i.value,left:t.value,top:n.value})),d=new ResizeObserver(u);return l.onMounted(()=>{e.value&&d.observe(e.value)}),l.onUnmounted(()=>{e.value&&d.unobserve(e.value)}),{viewportStyles:f,dragViewport:p=>{let v=!0;const m=p.pageX,g=p.pageY,y=t.value,b=n.value;document.onmousemove=R=>{if(!v)return;const A=R.pageX,S=R.pageY;t.value=y+(A-m),n.value=b+(S-g)},document.onmouseup=()=>{v=!1,document.onmousemove=null,document.onmouseup=null,r.setCanvasDragged(!0)}}}},jut=(e,t)=>{const n=wt(),{canvasScale:r,hiddenElementIdList:a}=Ze(n),{ctrlOrShiftKeyActive:o}=Ze(rl()),i=l.ref(!1),s=l.ref(1),u=l.ref({top:0,left:0,width:0,height:0});return{mouseSelection:u,mouseSelectionVisible:i,mouseSelectionQuadrant:s,updateMouseSelection:f=>{if(!t.value)return;let d=!0;const h=t.value.getBoundingClientRect(),p=5,v=f.pageX,m=f.pageY,g=(v-h.x)/r.value,y=(m-h.y)/r.value;u.value={top:y,left:g,width:0,height:0},i.value=!1,s.value=4,document.onmousemove=b=>{if(!d)return;const R=b.pageX,A=b.pageY,S=(R-v)/r.value,w=(A-m)/r.value,M=Math.abs(S),C=Math.abs(w);if(M<p||C<p)return;let N=0;S>0&&w>0?N=4:S<0&&w<0?N=2:S>0&&w<0?N=1:S<0&&w>0&&(N=3),u.value={...u.value,width:M,height:C},i.value=!0,s.value=N},document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null,d=!1;let b=[];for(let A=0;A<e.value.length;A++){const S=e.value[A],w=u.value.left,M=u.value.top,C=u.value.width,N=u.value.height,{minX:T,maxX:k,minY:O,maxY:E}=zc(S);let P=!1;o.value?s.value===4?P=k>w&&T<w+C&&E>M&&O<M+N:s.value===2?P=k>w-C&&T<w-C+C&&E>M-N&&O<M-N+N:s.value===1?P=k>w&&T<w+C&&E>M-N&&O<M-N+N:s.value===3&&(P=k>w-C&&T<w-C+C&&E>M&&O<M+N):s.value===4?P=T>w&&k<w+C&&O>M&&E<M+N:s.value===2?P=T>w-C&&k<w-C+C&&O>M-N&&E<M-N+N:s.value===1?P=T>w&&k<w+C&&O>M-N&&E<M-N+N:s.value===3&&(P=T>w-C&&k<w-C+C&&O>M&&E<M+N),P&&!S.lock&&!a.value.includes(S.id)&&b.push(S)}b=b.filter(A=>{if(A.groupId){const S=b.map(M=>M.id);return e.value.filter(M=>M.groupId===A.groupId).every(M=>S.includes(M.id))}return!0});const R=b.map(A=>A.id);n.setActiveElementIdList(R),i.value=!1}}}},qut=e=>{const{disableHotkeys:t}=Ze(wt()),{createTextElement:n}=xp(),{pasteDataTransfer:r}=_de(),a=o=>{if(!o.dataTransfer||o.dataTransfer.items.length===0)return;const{isFile:i,dataTransferFirstItem:s}=r(o.dataTransfer);i||s&&s.kind==="string"&&s.type==="text/plain"&&s.getAsString(u=>{if(t.value)return;const c=tk(u);n({left:0,top:0,width:600,height:50},{content:c})})};l.onMounted(()=>{e.value&&e.value.addEventListener("drop",a),document.ondragleave=o=>o.preventDefault(),document.ondrop=o=>o.preventDefault(),document.ondragenter=o=>o.preventDefault(),document.ondragover=o=>o.preventDefault()}),l.onUnmounted(()=>{e.value&&e.value.removeEventListener("drop",a),document.ondragleave=null,document.ondrop=null,document.ondragenter=null,document.ondragover=null})},$ut=(e,t)=>{const n=Math.atan2(e,t);return 180/Math.PI*n},Wxe=(e,t,n)=>{const r=pt(),{addHistorySnapshot:a}=Rn();return{rotateElement:(i,s)=>{const u=!(i instanceof MouseEvent);if(u&&(!i.changedTouches||!i.changedTouches[0]))return;let c=!0,f=0;const d=s.rotate||0,h=s.left,p=s.top,v=s.width,m=s.height,g=h+v/2,y=p+m/2;if(!t.value)return;const b=t.value.getBoundingClientRect(),R=S=>{if(!c)return;const w=S instanceof MouseEvent?S.pageX:S.changedTouches[0].pageX,M=S instanceof MouseEvent?S.pageY:S.changedTouches[0].pageY,C=(w-b.left)/n.value,N=(M-b.top)/n.value,T=C-g,k=y-N;f=$ut(T,k);const O=5;Math.abs(f)<=O?f=0:f>0&&Math.abs(f-45)<=O?f-=f-45:f<0&&Math.abs(f+45)<=O?f-=f+45:f>0&&Math.abs(f-90)<=O?f-=f-90:f<0&&Math.abs(f+90)<=O?f-=f+90:f>0&&Math.abs(f-135)<=O?f-=f-135:f<0&&Math.abs(f+135)<=O?f-=f+135:f>0&&Math.abs(f-180)<=O?f-=f-180:f<0&&Math.abs(f+180)<=O&&(f-=f+180),e.value=e.value.map(E=>s.id===E.id?{...E,rotate:f}:E)},A=()=>{c=!1,document.onmousemove=null,document.onmouseup=null,d!==f&&(r.updateSlide({elements:e.value}),a())};u?(document.ontouchmove=R,document.ontouchend=A):(document.onmousemove=R,document.onmouseup=A)}}},Yxe={text:40,image:20,shape:20,chart:200,table:30,video:250,audio:20,latex:20},Zxe=(e,t)=>{const{left:n,top:r,width:a,height:o}=e,i=Math.sqrt(Math.pow(a,2)+Math.pow(o,2))/2,s=Math.atan(o/a)*180/Math.PI,u=(180-t-s)*Math.PI/180,c=(s-t)*Math.PI/180,f=(90-t)*Math.PI/180,d=t*Math.PI/180,h=a/2,p=o/2,v=n+h,m=r+p,g={left:v+i*Math.cos(u),top:m-i*Math.sin(u)},y={left:v+p*Math.cos(f),top:m-p*Math.sin(f)},b={left:v+i*Math.cos(c),top:m-i*Math.sin(c)},R={left:v+h*Math.cos(d),top:m+h*Math.sin(d)},A={left:v-i*Math.cos(u),top:m+i*Math.sin(u)},S={left:v-p*Math.sin(d),top:m+p*Math.cos(d)},w={left:v-i*Math.cos(c),top:m+i*Math.sin(c)},M={left:v-h*Math.cos(d),top:m-h*Math.sin(d)};return{leftTopPoint:g,topPoint:y,rightTopPoint:b,rightPoint:R,rightBottomPoint:A,bottomPoint:S,leftBottomPoint:w,leftPoint:M}},Kxe=(e,t)=>({[Ft.RIGHT_BOTTOM]:t.leftTopPoint,[Ft.LEFT_BOTTOM]:t.rightTopPoint,[Ft.LEFT_TOP]:t.rightBottomPoint,[Ft.RIGHT_TOP]:t.leftBottomPoint,[Ft.TOP]:t.bottomPoint,[Ft.BOTTOM]:t.topPoint,[Ft.LEFT]:t.rightPoint,[Ft.RIGHT]:t.leftPoint})[e],Qxe=(e,t,n)=>{const r=wt(),a=pt(),{activeElementIdList:o,activeGroupElementId:i}=Ze(r),{viewportRatio:s,viewportSize:u}=Ze(a),{ctrlOrShiftKeyActive:c}=Ze(rl()),{addHistorySnapshot:f}=Rn();return{scaleElement:(p,v,m)=>{const g=!(p instanceof MouseEvent);if(g&&(!p.changedTouches||!p.changedTouches[0]))return;let y=!0;r.setScalingState(!0);const b=v.left,R=v.top,A=v.width,S=v.height,w=v.type==="table"?v.cellMinHeight:0,M="rotate"in v&&v.rotate?v.rotate:0,C=Math.PI*M/180,N=c.value||"fixedRatio"in v&&v.fixedRatio,T=A/S,k=g?p.changedTouches[0].pageX:p.pageX,O=g?p.changedTouches[0].pageY:p.pageY,E=Yxe[v.type]||20,P=(K,Q)=>{if(!N)return K<E?E:K;let ee=E,te=E;const oe=v.width/v.height;return oe<1&&(te=E/oe),oe>1&&(ee=E*oe),Q==="width"?K<ee?ee:K:K<te?te:K};let _,I=0,B=0,Y=[],W=[];if("rotate"in v&&v.rotate){const{left:K,top:Q,width:ee,height:te}=v;_=Zxe({left:K,top:Q,width:ee,height:te},M);const oe=Kxe(m,_);I=oe.left,B=oe.top}else{const K=u.value,Q=u.value*s.value,ee=v.id===i.value;for(const H of e.value){if("rotate"in H&&H.rotate||H.type==="line"||ee&&H.id===v.id||!ee&&o.value.includes(H.id))continue;const ce=H.left,Z=H.top,ie=H.width,he=H.height,$=ce+ie,se=Z+he,de={value:Z,range:[ce,$]},xe={value:se,range:[ce,$]},pe={value:ce,range:[Z,se]},be={value:$,range:[Z,se]};Y.push(de,xe),W.push(pe,be)}const te={value:0,range:[0,K]},oe={value:Q,range:[0,K]},ue={value:Q/2,range:[0,K]},we={value:0,range:[0,Q]},me={value:K,range:[0,Q]},ae={value:K/2,range:[0,Q]};Y.push(te,oe,ue),W.push(we,me,ae),Y=ek(Y),W=ek(W)}const G=(K,Q)=>{const te=[];let oe=!1,ue=!1;const we={offsetX:0,offsetY:0};if(Q||Q===0)for(let me=0;me<Y.length;me++){const{value:ae,range:H}=Y[me],ce=Math.min(...H,K||0),Z=Math.max(...H,K||0);Math.abs(Q-ae)<5&&!ue&&(we.offsetY=Q-ae,ue=!0,te.push({type:"horizontal",axis:{x:ce-50,y:ae},length:Z-ce+100}))}if(K||K===0)for(let me=0;me<W.length;me++){const{value:ae,range:H}=W[me],ce=Math.min(...H,Q||0),Z=Math.max(...H,Q||0);Math.abs(K-ae)<5&&!oe&&(we.offsetX=K-ae,oe=!0,te.push({type:"vertical",axis:{x:ae,y:ce-50},length:Z-ce+100}))}return t.value=te,we},F=K=>{if(!y)return;const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY,te=Q-k,oe=ee-O;let ue=A,we=S,me=b,ae=R;if(M){const H=(Math.cos(C)*te+Math.sin(C)*oe)/n.value;let ce=(Math.cos(C)*oe-Math.sin(C)*te)/n.value;N&&((m===Ft.RIGHT_BOTTOM||m===Ft.LEFT_TOP)&&(ce=H/T),(m===Ft.LEFT_BOTTOM||m===Ft.RIGHT_TOP)&&(ce=-H/T)),m===Ft.RIGHT_BOTTOM?(ue=P(A+H,"width"),we=P(S+ce,"height")):m===Ft.LEFT_BOTTOM?(ue=P(A-H,"width"),we=P(S+ce,"height"),me=b-(ue-A)):m===Ft.LEFT_TOP?(ue=P(A-H,"width"),we=P(S-ce,"height"),me=b-(ue-A),ae=R-(we-S)):m===Ft.RIGHT_TOP?(ue=P(A+H,"width"),we=P(S-ce,"height"),ae=R-(we-S)):m===Ft.TOP?(we=P(S-ce,"height"),ae=R-(we-S)):m===Ft.BOTTOM?we=P(S+ce,"height"):m===Ft.LEFT?(ue=P(A-H,"width"),me=b-(ue-A)):m===Ft.RIGHT&&(ue=P(A+H,"width"));const Z=Zxe({width:ue,height:we,left:me,top:ae},M),ie=Kxe(m,Z),he=ie.left,$=ie.top,se=he-I,de=$-B;me=me-se,ae=ae-de}else{let H=te/n.value,ce=oe/n.value;if(N&&((m===Ft.RIGHT_BOTTOM||m===Ft.LEFT_TOP)&&(ce=H/T),(m===Ft.LEFT_BOTTOM||m===Ft.RIGHT_TOP)&&(ce=-H/T)),m===Ft.RIGHT_BOTTOM){const{offsetX:Z,offsetY:ie}=G(b+A+H,R+S+ce);H=H-Z,ce=ce-ie,N&&(ie?H=ce*T:ce=H/T),ue=P(A+H,"width"),we=P(S+ce,"height")}else if(m===Ft.LEFT_BOTTOM){const{offsetX:Z,offsetY:ie}=G(b+H,R+S+ce);H=H-Z,ce=ce-ie,N&&(ie?H=-ce*T:ce=-H/T),ue=P(A-H,"width"),we=P(S+ce,"height"),me=b-(ue-A)}else if(m===Ft.LEFT_TOP){const{offsetX:Z,offsetY:ie}=G(b+H,R+ce);H=H-Z,ce=ce-ie,N&&(ie?H=ce*T:ce=H/T),ue=P(A-H,"width"),we=P(S-ce,"height"),me=b-(ue-A),ae=R-(we-S)}else if(m===Ft.RIGHT_TOP){const{offsetX:Z,offsetY:ie}=G(b+A+H,R+ce);H=H-Z,ce=ce-ie,N&&(ie?H=-ce*T:ce=-H/T),ue=P(A+H,"width"),we=P(S-ce,"height"),ae=R-(we-S)}else if(m===Ft.LEFT){const{offsetX:Z}=G(b+H,null);H=H-Z,ue=P(A-H,"width"),me=b-(ue-A)}else if(m===Ft.RIGHT){const{offsetX:Z}=G(b+A+H,null);H=H-Z,ue=P(A+H,"width")}else if(m===Ft.TOP){const{offsetY:Z}=G(null,R+ce);ce=ce-Z,we=P(S-ce,"height"),ae=R-(we-S)}else if(m===Ft.BOTTOM){const{offsetY:Z}=G(null,R+S+ce);ce=ce-Z,we=P(S+ce,"height")}}e.value=e.value.map(H=>{if(v.id!==H.id)return H;if(H.type==="shape"&&"pathFormula"in H&&H.pathFormula){const ce=xy[H.pathFormula];let Z="";return"editable"in ce?Z=ce.formula(ue,we,H.keypoints):Z=ce.formula(ue,we),{...H,left:me,top:ae,width:ue,height:we,viewBox:[ue,we],path:Z}}if(H.type==="table"){let ce=w+(we-S)/H.data.length;return ce=ce<36?36:ce,ce===w?{...H,left:me,width:ue}:{...H,left:me,top:ae,width:ue,height:we,cellMinHeight:ce<36?36:ce}}return{...H,left:me,top:ae,width:ue,height:we}})},U=K=>{y=!1,document.ontouchmove=null,document.ontouchend=null,document.onmousemove=null,document.onmouseup=null,t.value=[];const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY;k===Q&&O===ee||(a.updateSlide({elements:e.value}),r.setScalingState(!1),f())};g?(document.ontouchmove=F,document.ontouchend=U):(document.onmousemove=F,document.onmouseup=U)},scaleMultiElement:(p,v,m)=>{let g=!0;const{minX:y,maxX:b,minY:R,maxY:A}=v,S=b-y,w=A-R,M=S/w,C=p.pageX,N=p.pageY,T=JSON.parse(JSON.stringify(e.value));document.onmousemove=k=>{if(!g)return;const O=k.pageX,E=k.pageY,P=(O-C)/n.value;let _=(E-N)/n.value;c.value&&((m===Ft.RIGHT_BOTTOM||m===Ft.LEFT_TOP)&&(_=P/M),(m===Ft.LEFT_BOTTOM||m===Ft.RIGHT_TOP)&&(_=-P/M));let I=y,B=b,Y=R,W=A;m===Ft.RIGHT_BOTTOM?(B=b+P,W=A+_):m===Ft.LEFT_BOTTOM?(I=y+P,W=A+_):m===Ft.LEFT_TOP?(I=y+P,Y=R+_):m===Ft.RIGHT_TOP?(B=b+P,Y=R+_):m===Ft.TOP?Y=R+_:m===Ft.BOTTOM?W=A+_:m===Ft.LEFT?I=y+P:m===Ft.RIGHT&&(B=b+P);const G=B-I,F=W-Y;let U=G/S,K=F/w;U<=0&&(U=0),K<=0&&(K=0),e.value=e.value.map(Q=>{if((Q.type==="image"||Q.type==="shape")&&o.value.includes(Q.id)){const ee=T.find(te=>te.id===Q.id);return{...Q,width:ee.width*U,height:ee.height*K,left:I+(ee.left-y)*U,top:Y+(ee.top-R)*K}}return Q})},document.onmouseup=k=>{g=!1,document.onmousemove=null,document.onmouseup=null,!(C===k.pageX&&N===k.pageY)&&(a.updateSlide({elements:e.value}),f())}}}},eft=(e,t)=>{const n=wt(),{activeElementIdList:r,activeGroupElementId:a,handleElementId:o,editorAreaFocus:i}=Ze(n),{ctrlOrShiftKeyActive:s}=Ze(rl());return{selectElement:(c,f,d=!0)=>{if(i.value||n.setEditorareaFocus(!0),r.value.includes(f.id)){if(s.value){let h=[];if(f.groupId){const p=[];e.value.forEach(v=>{v.groupId===f.groupId&&p.push(v.id)}),h=r.value.filter(v=>!p.includes(v))}else h=r.value.filter(p=>p!==f.id);h.length>0&&n.setActiveElementIdList(h)}else if(o.value!==f.id)n.setHandleElementId(f.id);else if(a.value!==f.id){const h=c instanceof MouseEvent?c.pageX:c.changedTouches[0].pageX,p=c instanceof MouseEvent?c.pageY:c.changedTouches[0].pageY;c.target.onmouseup=v=>{const m=v.pageX,g=v.pageY;h===m&&p===g&&(n.setActiveGroupElementId(f.id),v.target.onmouseup=null)}}}else{let h=[];if(s.value?h=[...r.value,f.id]:h=[f.id],f.groupId){const p=[];e.value.forEach(v=>{v.groupId===f.groupId&&p.push(v.id)}),h=[...h,...p]}n.setActiveElementIdList($r.uniq(h)),n.setHandleElementId(f.id)}d&&t(c,f)}}},Hxe=(e,t,n)=>{const r=pt(),{activeElementIdList:a,activeGroupElementId:o}=Ze(wt()),{shiftKeyState:i}=Ze(rl()),{viewportRatio:s,viewportSize:u}=Ze(r),{addHistorySnapshot:c}=Rn();return{dragElement:(d,h)=>{const p=!(d instanceof MouseEvent);if(p&&(!d.changedTouches||!d.changedTouches[0])||!a.value.includes(h.id))return;let v=!0;const m=u.value,g=u.value*s.value,y=5,R=JSON.parse(JSON.stringify(e.value)).filter(K=>a.value.includes(K.id)),A=h.left,S=h.top,w=h.width,M="height"in h&&h.height?h.height:0,C="rotate"in h&&h.rotate?h.rotate:0,N=p?d.changedTouches[0].pageX:d.pageX,T=p?d.changedTouches[0].pageY:d.pageY;let k=null;const O=h.id===o.value;let E=[],P=[];for(const K of e.value){if(K.type==="line"||O&&K.id===h.id||!O&&a.value.includes(K.id))continue;let Q,ee,te,oe;if("rotate"in K&&K.rotate){const{xRange:se,yRange:de}=bA({left:K.left,top:K.top,width:K.width,height:K.height,rotate:K.rotate});Q=se[0],ee=de[0],te=se[1]-se[0],oe=de[1]-de[0]}else Q=K.left,ee=K.top,te=K.width,oe=K.height;const ue=Q+te,we=ee+oe,me=ee+oe/2,ae=Q+te/2,H={value:ee,range:[Q,ue]},ce={value:we,range:[Q,ue]},Z={value:me,range:[Q,ue]},ie={value:Q,range:[ee,we]},he={value:ue,range:[ee,we]},$={value:ae,range:[ee,we]};E.push(H,ce,Z),P.push(ie,he,$)}const _={value:0,range:[0,m]},I={value:g,range:[0,m]},B={value:g/2,range:[0,m]},Y={value:0,range:[0,g]},W={value:m,range:[0,g]},G={value:m/2,range:[0,g]};E.push(_,I,B),P.push(Y,W,G),E=ek(E),P=ek(P);const F=K=>{const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY;if(k!==!1&&(k=Math.abs(N-Q)<y&&Math.abs(T-ee)<y),!v||k)return;let te=(Q-N)/n.value,oe=(ee-T)/n.value;i.value&&(Math.abs(te)>Math.abs(oe)&&(oe=0),Math.abs(te)<Math.abs(oe)&&(te=0));let ue=A+te,we=S+oe,me,ae,H,ce;if(a.value.length===1||O)if(C){const{xRange:de,yRange:xe}=bA({left:ue,top:we,width:w,height:M,rotate:C});me=de[0],ae=de[1],H=xe[0],ce=xe[1]}else h.type==="line"?(me=ue,ae=ue+Math.max(h.start[0],h.end[0]),H=we,ce=we+Math.max(h.start[1],h.end[1])):(me=ue,ae=ue+w,H=we,ce=we+M);else{const de=[],xe=[],pe=[],be=[];for(let Ee=0;Ee<R.length;Ee++){const Be=R[Ee],et=Be.left+te,ut=Be.top+oe,Vt=Be.width,Yt="height"in Be&&Be.height?Be.height:0,Ve="rotate"in Be&&Be.rotate?Be.rotate:0;if("rotate"in Be&&Be.rotate){const{xRange:De,yRange:Ke}=bA({left:et,top:ut,width:Vt,height:Yt,rotate:Ve});de.push(De[0]),xe.push(Ke[0]),pe.push(De[1]),be.push(Ke[1])}else Be.type==="line"?(de.push(et),xe.push(ut),pe.push(et+Math.max(Be.start[0],Be.end[0])),be.push(ut+Math.max(Be.start[1],Be.end[1]))):(de.push(et),xe.push(ut),pe.push(et+Vt),be.push(ut+Yt))}me=Math.min(...de),ae=Math.max(...pe),H=Math.min(...xe),ce=Math.max(...be)}const Z=me+(ae-me)/2,ie=H+(ce-H)/2,he=[];let $=!1,se=!1;for(let de=0;de<E.length;de++){const{value:xe,range:pe}=E[de],be=Math.min(...pe,me,ae),Ee=Math.max(...pe,me,ae);Math.abs(H-xe)<y&&!se&&(we=we-(H-xe),se=!0,he.push({type:"horizontal",axis:{x:be-50,y:xe},length:Ee-be+100})),Math.abs(ce-xe)<y&&!se&&(we=we-(ce-xe),se=!0,he.push({type:"horizontal",axis:{x:be-50,y:xe},length:Ee-be+100})),Math.abs(ie-xe)<y&&!se&&(we=we-(ie-xe),se=!0,he.push({type:"horizontal",axis:{x:be-50,y:xe},length:Ee-be+100}))}for(let de=0;de<P.length;de++){const{value:xe,range:pe}=P[de],be=Math.min(...pe,H,ce),Ee=Math.max(...pe,H,ce);Math.abs(me-xe)<y&&!$&&(ue=ue-(me-xe),$=!0,he.push({type:"vertical",axis:{x:xe,y:be-50},length:Ee-be+100})),Math.abs(ae-xe)<y&&!$&&(ue=ue-(ae-xe),$=!0,he.push({type:"vertical",axis:{x:xe,y:be-50},length:Ee-be+100})),Math.abs(Z-xe)<y&&!$&&(ue=ue-(Z-xe),$=!0,he.push({type:"vertical",axis:{x:xe,y:be-50},length:Ee-be+100}))}if(t.value=he,a.value.length===1||O)e.value=e.value.map(de=>de.id===h.id?{...de,left:ue,top:we}:de);else{const de=e.value.find(xe=>xe.id===h.id);if(!de)return;e.value=e.value.map(xe=>a.value.includes(xe.id)?xe.id===h.id?{...xe,left:ue,top:we}:{...xe,left:xe.left+(ue-de.left),top:xe.top+(we-de.top)}:xe)}},U=K=>{v=!1,document.ontouchmove=null,document.ontouchend=null,document.onmousemove=null,document.onmouseup=null,t.value=[];const Q=K instanceof MouseEvent?K.pageX:K.changedTouches[0].pageX,ee=K instanceof MouseEvent?K.pageY:K.changedTouches[0].pageY;N===Q&&T===ee||(r.updateSlide({elements:e.value}),c())};p?(document.ontouchmove=F,document.ontouchend=U):(document.onmousemove=F,document.onmouseup=U)}}},tft=e=>{const t=pt(),{canvasScale:n}=Ze(wt()),{ctrlOrShiftKeyActive:r}=Ze(rl()),{addHistorySnapshot:a}=Rn();return{dragLineElement:(i,s,u)=>{let c=!0;const f=8,d=i.pageX,h=i.pageY,p=[];for(let v=0;v<e.value.length;v++){const m=e.value[v];if(m.type==="line"||m.rotate)continue;const g=m.left,y=m.top,b=m.width,R=m.height,A=g+b,S=y+R,w=y+R/2,M=g+b/2,C={x:M,y},N={x:M,y:S},T={x:g,y:w},k={x:A,y:w},O={x:g,y},E={x:A,y},P={x:g,y:S},_={x:A,y:S};p.push(C,N,T,k,O,E,P,_)}document.onmousemove=v=>{if(!c)return;const m=v.pageX,g=v.pageY,y=(m-d)/n.value,b=(g-h)/n.value;let R=s.left+s.start[0],A=s.top+s.start[1],S=s.left+s.end[0],w=s.top+s.end[1];const M=s.broken||s.broken2||s.curve||[0,0];let C=s.left+M[0],N=s.top+M[1];const[T,k]=s.cubic||[[0,0],[0,0]];let O=s.left+T[0],E=s.top+T[1],P=s.left+k[0],_=s.top+k[1];if(u===sl.START){R=R+y,A=A+b,Math.abs(R-S)<f&&(R=S),Math.abs(A-w)<f&&(A=w);for(const U of p){const{x:K,y:Q}=U;if(Math.abs(K-R)<f&&Math.abs(Q-A)<f){R=K,A=Q;break}}}else if(u===sl.END){S=S+y,w=w+b,Math.abs(R-S)<f&&(S=R),Math.abs(A-w)<f&&(w=A);for(const U of p){const{x:K,y:Q}=U;if(Math.abs(K-S)<f&&Math.abs(Q-w)<f){S=K,w=Q;break}}}else u===sl.C?(C=C+y,N=N+b,Math.abs(C-R)<f&&(C=R),Math.abs(N-A)<f&&(N=A),Math.abs(C-S)<f&&(C=S),Math.abs(N-w)<f&&(N=w),Math.abs(C-(R+S)/2)<f&&Math.abs(N-(A+w)/2)<f&&(C=(R+S)/2,N=(A+w)/2)):u===sl.C1?(O=O+y,E=E+b,Math.abs(O-R)<f&&(O=R),Math.abs(E-A)<f&&(E=A),Math.abs(O-S)<f&&(O=S),Math.abs(E-w)<f&&(E=w)):u===sl.C2&&(P=P+y,_=_+b,Math.abs(P-R)<f&&(P=R),Math.abs(_-A)<f&&(_=A),Math.abs(P-S)<f&&(P=S),Math.abs(_-w)<f&&(_=w));const I=Math.min(R,S),B=Math.min(A,w),Y=Math.max(R,S),W=Math.max(A,w),G=[0,0],F=[Y-I,W-B];R>S&&(G[0]=Y-I,F[0]=0),A>w&&(G[1]=W-B,F[1]=0),e.value=e.value.map(U=>{if(U.id===s.id){const K={...U,left:I,top:B,start:G,end:F};return u===sl.START||u===sl.END?(r.value?(s.broken&&(K.broken=[C-I,N-B]),s.curve&&(K.curve=[C-I,N-B]),s.cubic&&(K.cubic=[[O-I,E-B],[P-I,_-B]])):(s.broken&&(K.broken=[(G[0]+F[0])/2,(G[1]+F[1])/2]),s.curve&&(K.curve=[(G[0]+F[0])/2,(G[1]+F[1])/2]),s.cubic&&(K.cubic=[[(G[0]+F[0])/2,(G[1]+F[1])/2],[(G[0]+F[0])/2,(G[1]+F[1])/2]])),s.broken2&&(K.broken2=[(G[0]+F[0])/2,(G[1]+F[1])/2])):u===sl.C?(s.broken&&(K.broken=[C-I,N-B]),s.curve&&(K.curve=[C-I,N-B]),s.broken2&&(Y-I>=W-B?K.broken2=[C-I,K.broken2[1]]:K.broken2=[K.broken2[0],N-B])):s.cubic&&(K.cubic=[[O-I,E-B],[P-I,_-B]]),K}return U})},document.onmouseup=v=>{c=!1,document.onmousemove=null,document.onmouseup=null;const m=v.pageX,g=v.pageY;d===m&&h===g||(t.updateSlide({elements:e.value}),a())}}}},nft=(e,t)=>{const n=pt(),{addHistorySnapshot:r}=Rn();return{moveShapeKeypoint:(o,i,s=0)=>{const u=!(o instanceof MouseEvent);if(u&&(!o.changedTouches||!o.changedTouches[0]))return;let c=!0;const f=u?o.changedTouches[0].pageX:o.pageX,d=u?o.changedTouches[0].pageY:o.pageY,h=i.keypoints,p=xy[i.pathFormula];let v=null;if("editable"in p&&p.editable){const y=p.getBaseSize[s],b=p.range[s],R=p.relative[s],A=h[s],S=y(i.width,i.height),w=S*A,[M,C]=b;v={baseSize:S,originPos:w,min:M,max:C,relative:R}}const m=y=>{if(!c)return;const b=y instanceof MouseEvent?y.pageX:y.changedTouches[0].pageX,R=y instanceof MouseEvent?y.pageY:y.changedTouches[0].pageY,A=(b-f)/t.value,S=(R-d)/t.value;e.value=e.value.map(w=>{if(w.id===i.id&&v){const{baseSize:M,originPos:C,min:N,max:T,relative:k}=v,O=w;let E=0;k==="center"?E=(C-A*2)/M:k==="left"?E=(C+A)/M:k==="right"?E=(C-A)/M:k==="top"?E=(C+S)/M:k==="bottom"?E=(C-S)/M:k==="left_bottom"?E=(C+A)/M:k==="right_bottom"?E=(C-A)/M:k==="top_right"?E=(C+S)/M:k==="bottom_right"&&(E=(C-S)/M),E<N&&(E=N),E>T&&(E=T);let P=[];return Array.isArray(h)?(P=[...h],P[s]=E):P=[E],{...w,keypoints:P,path:p.formula(O.width,O.height,P)}}return w})},g=y=>{c=!1,document.ontouchmove=null,document.ontouchend=null,document.onmousemove=null,document.onmouseup=null;const b=y instanceof MouseEvent?y.pageX:y.changedTouches[0].pageX,R=y instanceof MouseEvent?y.pageY:y.changedTouches[0].pageY;f===b&&d===R||(n.updateSlide({elements:e.value}),r())};u?(document.ontouchmove=m,document.ontouchend=g):(document.onmousemove=m,document.onmouseup=g)}}},rft=e=>{const t=wt(),{canvasScale:n,creatingElement:r}=Ze(t),a=f=>{const{start:d,end:h}=f;if(!e.value)return;const p=e.value.getBoundingClientRect(),[v,m]=d,[g,y]=h,b=Math.min(v,g),R=Math.max(v,g),A=Math.min(m,y),S=Math.max(m,y),w=(b-p.x)/n.value,M=(A-p.y)/n.value,C=(R-b)/n.value,N=(S-A)/n.value;return{left:w,top:M,width:C,height:N}},o=f=>{const{start:d,end:h}=f;if(!e.value)return;const p=e.value.getBoundingClientRect(),[v,m]=d,[g,y]=h,b=Math.min(v,g),R=Math.max(v,g),A=Math.min(m,y),S=Math.max(m,y),w=(b-p.x)/n.value,M=(A-p.y)/n.value,C=(R-b)/n.value,N=(S-A)/n.value;return{left:w,top:M,start:[v===b?0:C,m===A?0:N],end:[g===b?0:C,y===A?0:N]}},{createTextElement:i,createShapeElement:s,createLineElement:u}=xp();return{formatCreateSelection:a,insertElementFromCreateSelection:f=>{if(!r.value)return;const d=r.value.type;if(d==="text"){const h=a(f);h&&i(h,{vertical:r.value.vertical})}else if(d==="shape"){const h=a(f);h&&s(h,r.value.data)}else if(d==="line"){const h=o(f);h&&u(h,r.value.data)}t.setCreatingElement(null)}}},zP=()=>{const e=pt(),{activeElementIdList:t,activeElementList:n}=Ze(wt()),{currentSlide:r,viewportRatio:a,viewportSize:o}=Ze(e),{addHistorySnapshot:i}=Rn();return{alignElementToCanvas:u=>{const c=o.value,f=o.value*a.value,{minX:d,maxX:h,minY:p,maxY:v}=Rp(n.value),m=JSON.parse(JSON.stringify(r.value.elements));for(const g of m)if(t.value.includes(g.id)){if(u===Gn.CENTER){const y=p+(v-p)/2-f/2,b=d+(h-d)/2-c/2;g.top=g.top-y,g.left=g.left-b}if(u===Gn.TOP){const y=p-0;g.top=g.top-y}else if(u===Gn.VERTICAL){const y=p+(v-p)/2-f/2;g.top=g.top-y}else if(u===Gn.BOTTOM){const y=v-f;g.top=g.top-y}else if(u===Gn.LEFT){const y=d-0;g.left=g.left-y}else if(u===Gn.HORIZONTAL){const y=d+(h-d)/2-c/2;g.left=g.left-y}else if(u===Gn.RIGHT){const y=h-c;g.left=g.left-y}}e.updateSlide({elements:m}),i()}}},aft=["src"],oft=["src"],ift=["onMousedown"],sft=["onMousedown"],lft=Je(l.defineComponent({__name:"ImageClipHandler",props:{src:{},clipPath:{},width:{},height:{},top:{},left:{},rotate:{},clipData:{}},emits:["clip"],setup(e,{emit:t}){const n=e,r=t,{canvasScale:a}=Ze(wt()),{ctrlOrShiftKeyActive:o}=Ze(rl()),i=l.ref({top:"0",left:"0"}),s=l.ref(!1),u=l.ref(null),c=()=>{const[C,N]=n.clipData?n.clipData.range:[[0,0],[100,100]],T=(N[0]-C[0])/100,k=(N[1]-C[1])/100,O=C[0]/T,E=C[1]/k;return{widthScale:T,heightScale:k,left:O,top:E}},f=l.computed(()=>{const{widthScale:C,heightScale:N,left:T,top:k}=c();return{left:-T,top:-k,width:100/C,height:100/N}}),d=l.computed(()=>({top:f.value.top+"%",left:f.value.left+"%",width:f.value.width+"%",height:f.value.height+"%"})),h=l.ref({top:0,left:0,width:0,height:0}),p=l.computed(()=>{const{top:C,left:N,width:T,height:k}=h.value;return{top:C+"%",left:N+"%",width:T+"%",height:k+"%"}}),v=l.computed(()=>{const C=f.value.width,N=f.value.height,{top:T,left:k,width:O,height:E}=h.value;return{left:-k*(100/O)+"%",top:-T*(100/E)+"%",width:C/O*100+"%",height:N/E*100+"%"}}),m=()=>{const{left:C,top:N}=c();h.value={left:C,top:N,width:100,height:100},i.value={top:-N+"%",left:-C+"%"}},g=()=>{if(s.value)return;if(!u.value){r("clip",null);return}const{left:C,top:N}=c(),T={left:(h.value.left-C)/100*n.width,top:(h.value.top-N)/100*n.height,width:(h.value.width-100)/100*n.width,height:(h.value.height-100)/100*n.height},k={range:u.value,position:T};r("clip",k)},y=C=>{C.key.toUpperCase()===_t.ENTER&&g()};l.onMounted(()=>{m(),document.addEventListener("keydown",y)}),l.onUnmounted(()=>{document.removeEventListener("keydown",y)});const b=()=>{const C={left:parseInt(v.value.left),top:parseInt(v.value.top),width:parseInt(v.value.width),height:parseInt(v.value.height)},N=100/C.width,T=100/C.height,k=[-C.left*N,-C.top*T],O=[N*100+k[0],T*100+k[1]];u.value=[k,O]},R=C=>{s.value=!0;let N=!0;const T=C.pageX,k=C.pageY,O=f.value,E={...h.value};document.onmousemove=P=>{if(!N)return;const _=P.pageX,I=P.pageY,B=(_-T)/a.value,Y=(I-k)/a.value,W=Math.sqrt(B*B+Y*Y),F=Math.atan2(Y,B)-n.rotate/180*Math.PI,U=W*Math.cos(F)/n.width*100,K=W*Math.sin(F)/n.height*100;let Q=E.left+U,ee=E.top+K;Q<0?Q=0:Q+E.width>O.width&&(Q=O.width-E.width),ee<0?ee=0:ee+E.height>O.height&&(ee=O.height-E.height),h.value={...h.value,left:Q,top:ee}},document.onmouseup=()=>{N=!1,document.onmousemove=null,document.onmouseup=null,b(),setTimeout(()=>{s.value=!1},0)}},A=(C,N)=>{s.value=!0;let T=!0;const k=50/n.width*100,O=50/n.height*100,E=C.pageX,P=C.pageY,_=f.value,I={...h.value},B=h.value.width/h.value.height;document.onmousemove=Y=>{if(!T)return;const W=Y.pageX,G=Y.pageY,F=(W-E)/a.value,U=(G-P)/a.value,K=Math.sqrt(F*F+U*U),ee=Math.atan2(U,F)-n.rotate/180*Math.PI;let te=K*Math.cos(ee)/n.width*100,oe=K*Math.sin(ee)/n.height*100;o.value&&((N===Ft.RIGHT_BOTTOM||N===Ft.LEFT_TOP)&&(oe=te/B),(N===Ft.LEFT_BOTTOM||N===Ft.RIGHT_TOP)&&(oe=-te/B));let ue,we,me,ae;N===Ft.LEFT_TOP?(I.left+te<0&&(te=-I.left),I.top+oe<0&&(oe=-I.top),I.width-te<k&&(te=I.width-k),I.height-oe<O&&(oe=I.height-O),me=I.width-te,ae=I.height-oe,ue=I.left+te,we=I.top+oe):N===Ft.RIGHT_TOP?(I.left+I.width+te>_.width&&(te=_.width-(I.left+I.width)),I.top+oe<0&&(oe=-I.top),I.width+te<k&&(te=k-I.width),I.height-oe<O&&(oe=I.height-O),me=I.width+te,ae=I.height-oe,ue=I.left,we=I.top+oe):N===Ft.LEFT_BOTTOM?(I.left+te<0&&(te=-I.left),I.top+I.height+oe>_.height&&(oe=_.height-(I.top+I.height)),I.width-te<k&&(te=I.width-k),I.height+oe<O&&(oe=O-I.height),me=I.width-te,ae=I.height+oe,ue=I.left+te,we=I.top):N===Ft.RIGHT_BOTTOM?(I.left+I.width+te>_.width&&(te=_.width-(I.left+I.width)),I.top+I.height+oe>_.height&&(oe=_.height-(I.top+I.height)),I.width+te<k&&(te=k-I.width),I.height+oe<O&&(oe=O-I.height),me=I.width+te,ae=I.height+oe,ue=I.left,we=I.top):N===Ft.TOP?(I.top+oe<0&&(oe=-I.top),I.height-oe<O&&(oe=I.height-O),me=I.width,ae=I.height-oe,ue=I.left,we=I.top+oe):N===Ft.BOTTOM?(I.top+I.height+oe>_.height&&(oe=_.height-(I.top+I.height)),I.height+oe<O&&(oe=O-I.height),me=I.width,ae=I.height+oe,ue=I.left,we=I.top):N===Ft.LEFT?(I.left+te<0&&(te=-I.left),I.width-te<k&&(te=I.width-k),me=I.width-te,ae=I.height,ue=I.left+te,we=I.top):(I.left+I.width+te>_.width&&(te=_.width-(I.left+I.width)),I.width+te<k&&(te=k-I.width),ae=I.height,me=I.width+te,ue=I.left,we=I.top),h.value={left:ue,top:we,width:me,height:ae}},document.onmouseup=()=>{T=!1,document.onmousemove=null,document.onmouseup=null,b(),setTimeout(()=>s.value=!1,0)}},S=l.computed(()=>{const C="rotate-",N=n.rotate;return N>-22.5&&N<=22.5?C+0:N>22.5&&N<=67.5?C+45:N>67.5&&N<=112.5?C+90:N>112.5&&N<=157.5?C+135:N>157.5||N<=-157.5?C+0:N>-157.5&&N<=-112.5?C+45:N>-112.5&&N<=-67.5?C+90:N>-67.5&&N<=-22.5?C+135:C+0}),w=[Ft.LEFT_TOP,Ft.RIGHT_TOP,Ft.LEFT_BOTTOM,Ft.RIGHT_BOTTOM],M=[Ft.TOP,Ft.BOTTOM,Ft.LEFT,Ft.RIGHT];return(C,N)=>{const T=l.resolveDirective("click-outside");return l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"image-clip-handler",style:l.normalizeStyle(i.value)},[l.createElementVNode("img",{class:"bottom-img",src:e.src,draggable:!1,alt:"",style:l.normalizeStyle(d.value)},null,12,aft),l.createElementVNode("div",{class:"top-image-content",style:l.normalizeStyle({...p.value,clipPath:e.clipPath})},[l.createElementVNode("img",{class:"top-img",src:e.src,draggable:!1,alt:"",style:l.normalizeStyle(v.value)},null,12,oft)],4),l.createElementVNode("div",{class:"operate",style:l.normalizeStyle(p.value),onMousedown:N[0]||(N[0]=l.withModifiers(k=>R(k),["stop"]))},[(l.openBlock(),l.createElementBlock(l.Fragment,null,l.renderList(w,k=>l.createElementVNode("div",{class:l.normalizeClass(["clip-point",k,S.value]),key:k,onMousedown:l.withModifiers(O=>A(O,k),["stop"])},[...N[1]||(N[1]=[l.createElementVNode("svg",{width:"16",height:"16",fill:"#fff",stroke:"#333"},[l.createElementVNode("path",{"stroke-width":"0.3","shape-rendering":"crispEdges",d:"M 16 0 L 0 0 L 0 16 L 4 16 L 4 4 L 16 4 L 16 0 Z"})],-1)])],42,ift)),64)),(l.openBlock(),l.createElementBlock(l.Fragment,null,l.renderList(M,k=>l.createElementVNode("div",{class:l.normalizeClass(["clip-point",k,S.value]),key:k,onMousedown:l.withModifiers(O=>A(O,k),["stop"])},[...N[2]||(N[2]=[l.createElementVNode("svg",{width:"16",height:"16",fill:"#fff",stroke:"#333"},[l.createElementVNode("path",{"stroke-width":"0.3","shape-rendering":"crispEdges",d:"M 16 0 L 0 0 L 0 4 L 16 4 Z"})],-1)])],42,sft)),64))],36)],4)),[[T,g]])}}}),[["__scopeId","data-v-f0e9a2f9"]]),cft=["src"],zxe=Je(l.defineComponent({__name:"index",props:{elementInfo:{},selectElement:{type:Function},contextmenus:{type:Function}},setup(e){const t=e,n=wt(),r=pt(),{clipingImageElementId:a}=Ze(n),o=l.computed(()=>a.value===t.elementInfo.id),{addHistorySnapshot:i}=Rn(),s=l.computed(()=>t.elementInfo.shadow),{shadowStyle:u}=bv(s),c=l.computed(()=>t.elementInfo.flipH),f=l.computed(()=>t.elementInfo.flipV),{flipStyle:d}=vk(c,f),h=l.computed(()=>t.elementInfo),{clipShape:p,imgPosition:v}=gQ(h),m=l.computed(()=>t.elementInfo.filters),{filter:g}=Xhe(m),y=R=>{t.elementInfo.lock||(R.stopPropagation(),t.selectElement(R,t.elementInfo))},b=R=>{if(n.setClipingImageElementId(""),!R)return;const{range:A,position:S}=R,w=t.elementInfo.clip||{shape:"rect",range:[[0,0],[100,100]]},M=t.elementInfo.left+S.left,C=t.elementInfo.top+S.top,N=t.elementInfo.width+S.width,T=t.elementInfo.height+S.height;let k=0,O=0;if(t.elementInfo.rotate){const P=M+N/2-(t.elementInfo.left+t.elementInfo.width/2),_=-(C+T/2-(t.elementInfo.top+t.elementInfo.height/2)),I=-t.elementInfo.rotate*Math.PI/180,B=P*Math.cos(I)-_*Math.sin(I),Y=P*Math.sin(I)+_*Math.cos(I);k=B-P,O=-(Y-_)}const E={clip:{...w,range:A},left:M+k,top:C+O,width:N,height:T};r.updateElement({id:t.elementInfo.id,props:E}),i()};return(R,A)=>{const S=l.resolveDirective("contextmenu");return l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["editable-element-image",{lock:e.elementInfo.lock}]),style:l.normalizeStyle({top:e.elementInfo.top+"px",left:e.elementInfo.left+"px",width:e.elementInfo.width+"px",height:e.elementInfo.height+"px"})},[l.createElementVNode("div",{class:"rotate-wrapper",style:l.normalizeStyle({transform:`rotate(${e.elementInfo.rotate}deg)`})},[o.value?(l.openBlock(),l.createBlock(lft,{key:0,src:e.elementInfo.src,clipData:e.elementInfo.clip,width:e.elementInfo.width,height:e.elementInfo.height,top:e.elementInfo.top,left:e.elementInfo.left,rotate:e.elementInfo.rotate,clipPath:l.unref(p).style,onClip:A[0]||(A[0]=w=>b(w))},null,8,["src","clipData","width","height","top","left","rotate","clipPath"])):l.withDirectives((l.openBlock(),l.createElementBlock("div",{key:1,class:"element-content",style:l.normalizeStyle({filter:l.unref(u)?`drop-shadow(${l.unref(u)})`:"",transform:l.unref(d)}),onMousedown:A[2]||(A[2]=w=>y(w)),onTouchstart:A[3]||(A[3]=w=>y(w))},[l.createVNode(Uhe,{elementInfo:e.elementInfo},null,8,["elementInfo"]),l.createElementVNode("div",{class:"image-content",style:l.normalizeStyle({clipPath:l.unref(p).style})},[l.createElementVNode("img",{src:e.elementInfo.src,draggable:!1,style:l.normalizeStyle({top:l.unref(v).top,left:l.unref(v).left,width:l.unref(v).width,height:l.unref(v).height,filter:l.unref(g)}),onDragstart:A[1]||(A[1]=l.withModifiers(()=>{},["prevent"])),alt:""},null,44,cft),e.elementInfo.colorMask?(l.openBlock(),l.createElementBlock("div",{key:0,class:"color-mask",style:l.normalizeStyle({backgroundColor:e.elementInfo.colorMask})},null,4)):l.createCommentVNode("",!0)],4)],36)),[[S,e.contextmenus]])],4)],6)}}}),[["__scopeId","data-v-3d37318b"]]),Pi=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ox=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let eq=null;const jp=function(e,t,n){let r=eq||(eq=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},uft=function(){eq=null},_1=function(e,t,n,r){return n&&(Gxe(e,t,n,r,-1)||Gxe(e,t,n,r,1))},fft=/^(img|br|input|textarea|hr)$/i;function Gxe(e,t,n,r,a){for(var o;;){if(e==n&&t==r)return!0;if(t==(a<0?0:Su(e))){let i=e.parentNode;if(!i||i.nodeType!=1||U5(e)||fft.test(e.nodeName)||e.contentEditable=="false")return!1;t=Pi(e)+(a<0?0:1),e=i}else if(e.nodeType==1){let i=e.childNodes[t+(a<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)t+=a;else return!1;else e=i,t=a<0?Su(e):0}else return!1}}function Su(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function dft(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Su(e)}else if(e.parentNode&&!U5(e))t=Pi(e),e=e.parentNode;else return null}}function hft(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!U5(e))t=Pi(e)+1,e=e.parentNode;else return null}}function pft(e,t,n){for(let r=t==0,a=t==Su(e);r||a;){if(e==n)return!0;let o=Pi(e);if(e=e.parentNode,!e)return!1;r=r&&o==0,a=a&&o==Su(e)}}function U5(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const GP=function(e){return e.focusNode&&_1(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function I1(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function vft(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function mft(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Su(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Su(r.startContainer),r.startOffset)}}}const lh=typeof navigator<"u"?navigator:null,Jxe=typeof document<"u"?document:null,bm=lh&&lh.userAgent||"",tq=/Edge\/(\d+)/.exec(bm),jxe=/MSIE \d/.exec(bm),nq=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bm),xl=!!(jxe||nq||tq),Am=jxe?document.documentMode:nq?+nq[1]:tq?+tq[1]:0,wu=!xl&&/gecko\/(\d+)/i.test(bm);wu&&+(/Firefox\/(\d+)/.exec(bm)||[0,0])[1];const rq=!xl&&/Chrome\/(\d+)/.exec(bm),_i=!!rq,qxe=rq?+rq[1]:0,ns=!xl&&!!lh&&/Apple Computer/.test(lh.vendor),ix=ns&&(/Mobile\/\w+/.test(bm)||!!lh&&lh.maxTouchPoints>2),Mu=ix||(lh?/Mac/.test(lh.platform):!1),$xe=lh?/Win/.test(lh.platform):!1,qp=/Android \d/.test(bm),W5=!!Jxe&&"webkitFontSmoothing"in Jxe.documentElement.style,gft=W5?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yft(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function $p(e,t){return typeof e=="number"?e:e[t]}function bft(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function eSe(e,t,n){let r=e.someProp("scrollThreshold")||0,a=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let i=n||e.dom;i;){if(i.nodeType!=1){i=ox(i);continue}let s=i,u=s==o.body,c=u?yft(o):bft(s),f=0,d=0;if(t.top<c.top+$p(r,"top")?d=-(c.top-t.top+$p(a,"top")):t.bottom>c.bottom-$p(r,"bottom")&&(d=t.bottom-t.top>c.bottom-c.top?t.top+$p(a,"top")-c.top:t.bottom-c.bottom+$p(a,"bottom")),t.left<c.left+$p(r,"left")?f=-(c.left-t.left+$p(a,"left")):t.right>c.right-$p(r,"right")&&(f=t.right-c.right+$p(a,"right")),f||d)if(u)o.defaultView.scrollBy(f,d);else{let p=s.scrollLeft,v=s.scrollTop;d&&(s.scrollTop+=d),f&&(s.scrollLeft+=f);let m=s.scrollLeft-p,g=s.scrollTop-v;t={left:t.left-m,top:t.top-g,right:t.right-m,bottom:t.bottom-g}}let h=u?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(h))break;i=h=="absolute"?i.offsetParent:ox(i)}}function Aft(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,a;for(let o=(t.left+t.right)/2,i=n+1;i<Math.min(innerHeight,t.bottom);i+=5){let s=e.root.elementFromPoint(o,i);if(!s||s==e.dom||!e.dom.contains(s))continue;let u=s.getBoundingClientRect();if(u.top>=n-20){r=s,a=u.top;break}}return{refDOM:r,refTop:a,stack:tSe(e.dom)}}function tSe(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=ox(r));return t}function Rft({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;nSe(n,r==0?0:r-t)}function nSe(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:a,left:o}=e[n];r.scrollTop!=a+t&&(r.scrollTop=a+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let sx=null;function xft(e){if(e.setActive)return e.setActive();if(sx)return e.focus(sx);let t=tSe(e);e.focus(sx==null?{get preventScroll(){return sx={preventScroll:!0},!0}}:void 0),sx||(sx=!1,nSe(t,0))}function rSe(e,t){let n,r=2e8,a,o=0,i=t.top,s=t.top,u,c;for(let f=e.firstChild,d=0;f;f=f.nextSibling,d++){let h;if(f.nodeType==1)h=f.getClientRects();else if(f.nodeType==3)h=jp(f).getClientRects();else continue;for(let p=0;p<h.length;p++){let v=h[p];if(v.top<=i&&v.bottom>=s){i=Math.max(v.bottom,i),s=Math.min(v.top,s);let m=v.left>t.left?v.left-t.left:v.right<t.left?t.left-v.right:0;if(m<r){n=f,r=m,a=m&&n.nodeType==3?{left:v.right<t.left?v.right:v.left,top:t.top}:t,f.nodeType==1&&m&&(o=d+(t.left>=(v.left+v.right)/2?1:0));continue}}else v.top>t.top&&!u&&v.left<=t.left&&v.right>=t.left&&(u=f,c={left:Math.max(v.left,Math.min(v.right,t.left)),top:v.top});!n&&(t.left>=v.right&&t.top>=v.top||t.left>=v.left&&t.top>=v.bottom)&&(o=d+1)}}return!n&&u&&(n=u,a=c,r=0),n&&n.nodeType==3?Sft(n,a):!n||r&&n.nodeType==1?{node:e,offset:o}:rSe(n,a)}function Sft(e,t){let n=e.nodeValue.length,r=document.createRange(),a;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let i=Rm(r,1);if(i.top!=i.bottom&&aq(t,i)){a={node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),a||{node:e,offset:0}}function aq(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function wft(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Mft(e,t,n){let{node:r,offset:a}=rSe(t,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return e.docView.posFromDOM(r,a,o)}function Nft(e,t,n,r){let a=-1;for(let o=t,i=!1;o!=e.dom;){let s=e.docView.nearestDesc(o,!0),u;if(!s)return null;if(s.dom.nodeType==1&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((u=s.dom.getBoundingClientRect()).width||u.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&u.left>r.left||u.top>r.top?a=s.posBefore:(!i&&u.right<r.left||u.bottom<r.top)&&(a=s.posAfter),i=!0),!s.contentDOM&&a<0&&!s.node.isText))return(s.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?s.posBefore:s.posAfter;o=s.dom.parentNode}return a>-1?a:e.docView.posFromDOM(t,n,-1)}function aSe(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let a=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=a;;){let i=e.childNodes[o];if(i.nodeType==1){let s=i.getClientRects();for(let u=0;u<s.length;u++){let c=s[u];if(aq(t,c))return aSe(i,t,c)}}if((o=(o+1)%r)==a)break}return e}function Tft(e,t){let n=e.dom.ownerDocument,r,a=0,o=mft(n,t.left,t.top);o&&({node:r,offset:a}=o);let i=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!i||!e.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=e.dom.getBoundingClientRect();if(!aq(t,c)||(i=aSe(e.dom,t,c),!i))return null}if(ns)for(let c=i;r&&c;c=ox(c))c.draggable&&(r=void 0);if(i=wft(i,t),r){if(wu&&r.nodeType==1&&(a=Math.min(a,r.childNodes.length),a<r.childNodes.length)){let f=r.childNodes[a],d;f.nodeName=="IMG"&&(d=f.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&a++}let c;W5&&a&&r.nodeType==1&&(c=r.childNodes[a-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&a--,r==e.dom&&a==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(a==0||r.nodeType!=1||r.childNodes[a-1].nodeName!="BR")&&(s=Nft(e,r,a,t))}s==null&&(s=Mft(e,i,t));let u=e.docView.nearestDesc(i,!0);return{pos:s,inside:u?u.posAtStart-u.border:-1}}function oSe(e){return e.top<e.bottom||e.left<e.right}function Rm(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(oSe(r))return r}return Array.prototype.find.call(n,oSe)||e.getBoundingClientRect()}const Cft=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function iSe(e,t,n){let{node:r,offset:a,atom:o}=e.docView.domFromPos(t,n<0?-1:1),i=W5||wu;if(r.nodeType==3)if(i&&(Cft.test(r.nodeValue)||(n<0?!a:a==r.nodeValue.length))){let u=Rm(jp(r,a,a),n);if(wu&&a&&/\s/.test(r.nodeValue[a-1])&&a<r.nodeValue.length){let c=Rm(jp(r,a-1,a-1),-1);if(c.top==u.top){let f=Rm(jp(r,a,a+1),-1);if(f.top!=u.top)return Y5(f,f.left<c.left)}}return u}else{let u=a,c=a,f=n<0?1:-1;return n<0&&!a?(c++,f=-1):n>=0&&a==r.nodeValue.length?(u--,f=1):n<0?u--:c++,Y5(Rm(jp(r,u,c),f),f<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(o==null&&a&&(n<0||a==Su(r))){let u=r.childNodes[a-1];if(u.nodeType==1)return oq(u.getBoundingClientRect(),!1)}if(o==null&&a<Su(r)){let u=r.childNodes[a];if(u.nodeType==1)return oq(u.getBoundingClientRect(),!0)}return oq(r.getBoundingClientRect(),n>=0)}if(o==null&&a&&(n<0||a==Su(r))){let u=r.childNodes[a-1],c=u.nodeType==3?jp(u,Su(u)-(i?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(c)return Y5(Rm(c,1),!1)}if(o==null&&a<Su(r)){let u=r.childNodes[a];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let c=u?u.nodeType==3?jp(u,0,i?0:1):u.nodeType==1?u:null:null;if(c)return Y5(Rm(c,-1),!0)}return Y5(Rm(r.nodeType==3?jp(r):r,-n),n>=0)}function Y5(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function oq(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function sSe(e,t,n){let r=e.state,a=e.root.activeElement;r!=t&&e.updateState(t),a!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),a!=e.dom&&a&&a.focus()}}function Lft(e,t,n){let r=t.selection,a=n=="up"?r.$from:r.$to;return sSe(e,t,()=>{let{node:o}=e.docView.domFromPos(a.pos,n=="up"?-1:1);for(;;){let s=e.docView.nearestDesc(o,!0);if(!s)break;if(s.node.isBlock){o=s.contentDOM||s.dom;break}o=s.dom.parentNode}let i=iSe(e,a.pos,1);for(let s=o.firstChild;s;s=s.nextSibling){let u;if(s.nodeType==1)u=s.getClientRects();else if(s.nodeType==3)u=jp(s,0,s.nodeValue.length).getClientRects();else continue;for(let c=0;c<u.length;c++){let f=u[c];if(f.bottom>f.top+1&&(n=="up"?i.top-f.top>(f.bottom-i.top)*2:f.bottom-i.bottom>(i.bottom-f.top)*2))return!1}}return!0})}const kft=/[\u0590-\u08ac]/;function Oft(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let a=r.parentOffset,o=!a,i=a==r.parent.content.size,s=e.domSelection();return s?!kft.test(r.parent.textContent)||!s.modify?n=="left"||n=="backward"?o:i:sSe(e,t,()=>{let{focusNode:u,focusOffset:c,anchorNode:f,anchorOffset:d}=e.domSelectionRange(),h=s.caretBidiLevel;s.modify("move",n,"character");let p=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:v,focusOffset:m}=e.domSelectionRange(),g=v&&!p.contains(v.nodeType==1?v:v.parentNode)||u==v&&c==m;try{s.collapse(f,d),u&&(u!=f||c!=d)&&s.extend&&s.extend(u,c)}catch{}return h!=null&&(s.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let lSe=null,cSe=null,uSe=!1;function Eft(e,t,n){return lSe==t&&cSe==n?uSe:(lSe=t,cSe=n,uSe=n=="up"||n=="down"?Lft(e,t,n):Oft(e,t,n))}const Nu=0,fSe=1,F1=2,ch=3;class Z5{constructor(t,n,r,a){this.parent=t,this.children=n,this.dom=r,this.contentDOM=a,this.dirty=Nu,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,r){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,r=this.posAtStart;;n++){let a=this.children[n];if(a==t)return r;r+=a.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,n,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode))if(r<0){let o,i;if(t==this.contentDOM)o=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(t==this.contentDOM)o=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let a;if(t==this.dom&&this.contentDOM)a=n>Pi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=t;;o=o.parentNode){if(o==this.dom){a=!1;break}if(o.previousSibling)break}if(a==null&&n==t.childNodes.length)for(let o=t;;o=o.parentNode){if(o==this.dom){a=!0;break}if(o.nextSibling)break}}return a??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let r=!0,a=t;a;a=a.parentNode){let o=this.getDesc(a),i;if(o&&(!n||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(t.nodeType==1?t:t.parentNode):i==t))r=!1;else return o}}getDesc(t){let n=t.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(t,n,r){for(let a=t;a;a=a.parentNode){let o=this.getDesc(a);if(o)return o.localPosFromDOM(t,n,r)}return-1}descAt(t){for(let n=0,r=0;n<this.children.length;n++){let a=this.children[n],o=r+a.size;if(r==t&&o!=r){for(;!a.border&&a.children.length;)for(let i=0;i<a.children.length;i++){let s=a.children[i];if(s.size){a=s;break}}return a}if(t<o)return a.descAt(t-r-a.border);r=o}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,a=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],s=o+i.size;if(s>t||i instanceof pSe){a=t-o;break}o=s}if(a)return this.children[r].domFromPos(a-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof dSe&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Pi(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?Pi(o.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let a=-1,o=-1;for(let i=r,s=0;;s++){let u=this.children[s],c=i+u.size;if(a==-1&&t<=c){let f=i+u.border;if(t>=f&&n<=c-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(t,n,f);t=i;for(let d=s;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){a=Pi(h.dom)+1;break}t-=h.size}a==-1&&(a=0)}if(a>-1&&(c>n||s==this.children.length-1)){n=c;for(let f=s+1;f<this.children.length;f++){let d=this.children[f];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=Pi(d.dom);break}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:n,fromOffset:a,toOffset:o}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:r}=this.domFromPos(t,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]}setSelection(t,n,r,a=!1){let o=Math.min(t,n),i=Math.max(t,n);for(let p=0,v=0;p<this.children.length;p++){let m=this.children[p],g=v+m.size;if(o>v&&i<g)return m.setSelection(t-v-m.border,n-v-m.border,r,a);v=g}let s=this.domFromPos(t,t?-1:1),u=n==t?s:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),f=r.domSelectionRange(),d=!1;if((wu||ns)&&t==n){let{node:p,offset:v}=s;if(p.nodeType==3){if(d=!!(v&&p.nodeValue[v-1]==`
343
343
  `),d&&v==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(s=u={node:g.parentNode,offset:Pi(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=p.childNodes[v-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(wu&&f.focusNode&&f.focusNode!=u.node&&f.focusNode.nodeType==1){let p=f.focusNode.childNodes[f.focusOffset];p&&p.contentEditable=="false"&&(a=!0)}if(!(a||d&&ns)&&_1(s.node,s.offset,f.anchorNode,f.anchorOffset)&&_1(u.node,u.offset,f.focusNode,f.focusOffset))return;let h=!1;if((c.extend||t==n)&&!(d&&wu)){c.collapse(s.node,s.offset);try{t!=n&&c.extend(u.node,u.offset),h=!0}catch{}}if(!h){if(t>n){let v=s;s=u,u=v}let p=document.createRange();p.setEnd(u.node,u.offset),p.setStart(s.node,s.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,n){for(let r=0,a=0;a<this.children.length;a++){let o=this.children[a],i=r+o.size;if(r==i?t<=i&&n>=r:t<i&&n>r){let s=r+o.border,u=i-o.border;if(t>=s&&n<=u){this.dirty=t==r||n==i?F1:fSe,t==s&&n==u&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ch:o.markDirty(t-s,n-s);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?F1:ch}r=i}this.dirty=F1}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?F1:fSe;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class dSe extends Z5{constructor(t,n,r,a){let o,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return a;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(i.nodeType!=1){let s=document.createElement("span");s.appendChild(i),i=s}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=n,this.widget=n,o=this}matchesWidget(t){return this.dirty==Nu&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Pft extends Z5{constructor(t,n,r,a){super(t,[],n,null),this.textDOM=r,this.text=a}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class V1 extends Z5{constructor(t,n,r,a,o){super(t,[],r,a),this.mark=n,this.spec=o}static create(t,n,r,a){let o=a.nodeViews[n.type.name],i=o&&o(n,a,r);return(!i||!i.dom)&&(i=Ub.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new V1(t,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ch||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=ch&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=Nu){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Nu}}slice(t,n,r){let a=V1.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=sq(o,n,i,r)),t>0&&(o=sq(o,0,t,r));for(let s=0;s<o.length;s++)o[s].parent=a;return a.children=o,a}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class xm extends Z5{constructor(t,n,r,a,o,i,s,u,c){super(t,[],o,i),this.node=n,this.outerDeco=r,this.innerDeco=a,this.nodeDOM=s}static create(t,n,r,a,o,i){let s=o.nodeViews[n.type.name],u,c=s&&s(n,o,()=>{if(!u)return i;if(u.parent)return u.parent.posBeforeChild(u)},r,a),f=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:d}=Ub.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let h=f;return f=gSe(f,r,n),c?u=new _ft(t,n,r,a,f,d||null,h,c,o,i+1):n.isText?new JP(t,n,r,a,f,h,o):new xm(t,n,r,a,f,d||null,h,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=()=>xt.empty)}return t}matchesNode(t,n,r){return this.dirty==Nu&&t.eq(this.node)&&jP(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let r=this.node.inlineContent,a=n,o=t.composing?this.localCompositionInfo(t,n):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,u=new Fft(this,i&&i.node,t);Bft(this.node,this.innerDeco,(c,f,d)=>{c.spec.marks?u.syncToMarks(c.spec.marks,r,t,f):c.type.side>=0&&!d&&u.syncToMarks(f==this.node.childCount?Jr.none:this.node.child(f).marks,r,t,f),u.placeWidget(c,t,a)},(c,f,d,h)=>{u.syncToMarks(c.marks,r,t,h);let p;u.findNodeMatch(c,f,d,h)||s&&t.state.selection.from>a&&t.state.selection.to<a+c.nodeSize&&(p=u.findIndexWithChild(o.node))>-1&&u.updateNodeAt(c,f,d,p,t)||u.updateNextNode(c,f,d,t,h,a)||u.addNode(c,f,d,t,a),a+=c.nodeSize}),u.syncToMarks([],r,t,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==F1)&&(i&&this.protectLocalComposition(t,i),vSe(this.contentDOM,this.children,t),ix&&Xft(this.dom))}localCompositionInfo(t,n){let{from:r,to:a}=t.state.selection;if(!(t.state.selection instanceof Wr)||r<n||a>n+this.node.content.size)return null;let o=t.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,s=Uft(this.node.content,i,r-n,a-n);return s<0?null:{node:o,pos:s,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:r,text:a}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Pft(this,o,n,a);t.input.compositionNodes.push(i),this.children=sq(this.children,r,r+a.length,t,i)}update(t,n,r,a){return this.dirty==ch||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,r,a),!0)}updateInner(t,n,r,a){this.updateOuterDeco(n),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Nu}updateOuterDeco(t){if(jP(t,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=mSe(this.dom,this.nodeDOM,iq(this.outerDeco,this.node,n),iq(t,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function hSe(e,t,n,r,a){gSe(r,t,e);let o=new xm(void 0,e,t,n,r,r,r,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class JP extends xm{constructor(t,n,r,a,o,i,s){super(t,n,r,a,o,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,r,a){return this.dirty==ch||this.dirty!=Nu&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Nu||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=t,this.dirty=Nu,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,r){let a=this.node.cut(t,n),o=document.createTextNode(a.text);return new JP(this.parent,a,this.outerDeco,this.innerDeco,o,o,r)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ch)}get domAtom(){return!1}isText(t){return this.node.text==t}}class pSe extends Z5{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==Nu&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class _ft extends xm{constructor(t,n,r,a,o,i,s,u,c,f){super(t,n,r,a,o,i,s,c,f),this.spec=u}update(t,n,r,a){if(this.dirty==ch)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let o=this.spec.update(t,n,r);return o&&this.updateInner(t,n,r,a),o}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,r,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,r,a){this.spec.setSelection?this.spec.setSelection(t,n,r.root):super.setSelection(t,n,r,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function vSe(e,t,n){let r=e.firstChild,a=!1;for(let o=0;o<t.length;o++){let i=t[o],s=i.dom;if(s.parentNode==e){for(;s!=r;)r=ySe(r),a=!0;r=r.nextSibling}else a=!0,e.insertBefore(s,r);if(i instanceof V1){let u=r?r.previousSibling:e.lastChild;vSe(i.contentDOM,i.children,n),r=u?u.nextSibling:e.firstChild}}for(;r;)r=ySe(r),a=!0;a&&n.trackWrites==e&&(n.trackWrites=null)}const K5=function(e){e&&(this.nodeName=e)};K5.prototype=Object.create(null);const D1=[new K5];function iq(e,t,n){if(e.length==0)return D1;let r=n?D1[0]:new K5,a=[r];for(let o=0;o<e.length;o++){let i=e[o].type.attrs;if(i){i.nodeName&&a.push(r=new K5(i.nodeName));for(let s in i){let u=i[s];u!=null&&(n&&a.length==1&&a.push(r=new K5(t.isInline?"span":"div")),s=="class"?r.class=(r.class?r.class+" ":"")+u:s=="style"?r.style=(r.style?r.style+";":"")+u:s!="nodeName"&&(r[s]=u))}}}return a}function mSe(e,t,n,r){if(n==D1&&r==D1)return t;let a=t;for(let o=0;o<r.length;o++){let i=r[o],s=n[o];if(o){let u;s&&s.nodeName==i.nodeName&&a!=e&&(u=a.parentNode)&&u.nodeName.toLowerCase()==i.nodeName||(u=document.createElement(i.nodeName),u.pmIsDeco=!0,u.appendChild(a),s=D1[0]),a=u}Ift(a,s||D1[0],i)}return a}function Ift(e,t,n){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],a=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)a.indexOf(r[o])==-1&&e.classList.remove(r[o]);for(let o=0;o<a.length;o++)r.indexOf(a[o])==-1&&e.classList.add(a[o]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,a;for(;a=r.exec(t.style);)e.style.removeProperty(a[1])}n.style&&(e.style.cssText+=n.style)}}function gSe(e,t,n){return mSe(e,e,D1,iq(t,n,e.nodeType!=1))}function jP(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ySe(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Fft{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=Vft(t.node.content,t)}destroyBetween(t,n){if(t!=n){for(let r=t;r<n;r++)this.top.children[r].destroy();this.top.children.splice(t,n-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,n,r,a){let o=0,i=this.stack.length>>1,s=Math.min(i,t.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&t[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=Nu,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<t.length;){this.stack.push(this.top,this.index+1);let u=-1,c=this.top.children.length;a<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let f=this.index;f<c;f++){let d=this.top.children[f];if(d.matchesMark(t[i])&&!this.isLocked(d.dom)){u=f;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=V1.create(this.top,t[i],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,i++}}findNodeMatch(t,n,r,a){let o=-1,i;if(a>=this.preMatch.index&&(i=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&i.matchesNode(t,n,r))o=this.top.children.indexOf(i,this.index);else for(let s=this.index,u=Math.min(this.top.children.length,s+5);s<u;s++){let c=this.top.children[s];if(c.matchesNode(t,n,r)&&!this.preMatch.matched.has(c)){o=s;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(t,n,r,a,o){let i=this.top.children[a];return i.dirty==ch&&i.dom==i.contentDOM&&(i.dirty=F1),i.update(t,n,r,o)?(this.destroyBetween(this.index,a),this.index++,!0):!1}findIndexWithChild(t){for(;;){let n=t.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=t.pmViewDesc;if(r){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==r)return a}return-1}t=n}}updateNextNode(t,n,r,a,o,i){for(let s=this.index;s<this.top.children.length;s++){let u=this.top.children[s];if(u instanceof xm){let c=this.preMatch.matched.get(u);if(c!=null&&c!=o)return!1;let f=u.dom,d,h=this.isLocked(f)&&!(t.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==t.text&&u.dirty!=ch&&jP(n,u.outerDeco));if(!h&&u.update(t,n,r,a))return this.destroyBetween(this.index,s),u.dom!=f&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(u,t,n,r,a,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=F1,d.updateChildren(a,i+1),d.dirty=Nu),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,n,r,a,o,i){if(t.dirty||n.isAtom||!t.children.length||!t.node.content.eq(n.content)||!jP(r,t.outerDeco)||!a.eq(t.innerDeco))return null;let s=xm.create(this.top,n,r,a,o,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let u of s.children)u.parent=s}return t.destroy(),s}addNode(t,n,r,a,o){let i=xm.create(this.top,t,n,r,a,o);i.contentDOM&&i.updateChildren(a,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,n,r){let a=this.index<this.top.children.length?this.top.children[this.index]:null;if(a&&a.matchesWidget(t)&&(t==a.widget||!a.widget.type.toDOM.parentNode))this.index++;else{let o=new dSe(this.top,t,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],n=this.top;for(;t instanceof V1;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof JP)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((ns||_i)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(t,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(t))this.index++;else{let r=document.createElement(t);t=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),t=="BR"&&(r.className="ProseMirror-trailingBreak");let a=new pSe(this.top,[],r,null);n!=this.top?n.children.push(a):n.children.splice(this.index++,0,a),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Vft(e,t){let n=t,r=n.children.length,a=e.childCount,o=new Map,i=[];e:for(;a>0;){let s;for(;;)if(r){let c=n.children[r-1];if(c instanceof V1)n=c,r=c.children.length;else{s=c,r--;break}}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=s.node;if(u){if(u!=e.child(a-1))break;--a,o.set(s,a),i.push(s)}}return{index:a,matched:o,matches:i.reverse()}}function Dft(e,t){return e.type.side-t.type.side}function Bft(e,t,n,r){let a=t.locals(e),o=0;if(a.length==0){for(let c=0;c<e.childCount;c++){let f=e.child(c);r(f,a,t.forChild(o,f),c),o+=f.nodeSize}return}let i=0,s=[],u=null;for(let c=0;;){let f,d;for(;i<a.length&&a[i].to==o;){let g=a[i++];g.widget&&(f?(d||(d=[f])).push(g):f=g)}if(f)if(d){d.sort(Dft);for(let g=0;g<d.length;g++)n(d[g],c,!!u)}else n(f,c,!!u);let h,p;if(u)p=-1,h=u,u=null;else if(c<e.childCount)p=c,h=e.child(c++);else break;for(let g=0;g<s.length;g++)s[g].to<=o&&s.splice(g--,1);for(;i<a.length&&a[i].from<=o&&a[i].to>o;)s.push(a[i++]);let v=o+h.nodeSize;if(h.isText){let g=v;i<a.length&&a[i].from<g&&(g=a[i].from);for(let y=0;y<s.length;y++)s[y].to<g&&(g=s[y].to);g<v&&(u=h.cut(g-o),h=h.cut(0,g-o),v=g,p=-1)}else for(;i<a.length&&a[i].to<v;)i++;let m=h.isInline&&!h.isLeaf?s.filter(g=>!g.inline):s.slice();r(h,m,t.forChild(o,h),p),o=v}}function Xft(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function Uft(e,t,n,r){for(let a=0,o=0;a<e.childCount&&o<=r;){let i=e.child(a++),s=o;if(o+=i.nodeSize,!i.isText)continue;let u=i.text;for(;a<e.childCount;){let c=e.child(a++);if(o+=c.nodeSize,!c.isText)break;u+=c.text}if(o>=n){if(o>=r&&u.slice(r-t.length-s,r-s)==t)return r-t.length;let c=s<r?u.lastIndexOf(t,r-s-1):-1;if(c>=0&&c+t.length+s>=n)return s+c;if(n==r&&u.length>=r+t.length-s&&u.slice(r-s,r-s+t.length)==t)return r}}return-1}function sq(e,t,n,r,a){let o=[];for(let i=0,s=0;i<e.length;i++){let u=e[i],c=s,f=s+=u.size;c>=n||f<=t?o.push(u):(c<t&&o.push(u.slice(0,t-c,r)),a&&(o.push(a),a=void 0),f>n&&o.push(u.slice(n-c,u.size,r)))}return o}function lq(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let a=e.docView.nearestDesc(n.focusNode),o=a&&a.size==0,i=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let s=r.resolve(i),u,c;if(GP(n)){for(u=i;a&&!a.node;)a=a.parent;let d=a.node;if(a&&d.isAtom&&yn.isSelectable(d)&&a.parent&&!(d.isInline&&pft(n.focusNode,n.focusOffset,a.dom))){let h=a.posBefore;c=new yn(i==h?s:r.resolve(h))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,h=i;for(let p=0;p<n.rangeCount;p++){let v=n.getRangeAt(p);d=Math.min(d,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),h=Math.max(h,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(d<0)return null;[u,i]=h==e.state.selection.anchor?[h,d]:[d,h],s=r.resolve(i)}else u=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let f=r.resolve(u);if(!c){let d=t=="pointer"||e.state.selection.head<s.pos&&!o?1:-1;c=uq(e,f,s,d)}return c}function bSe(e){return e.editable?e.hasFocus():NSe(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function e0(e,t=!1){let n=e.state.selection;if(SSe(e,n),!!bSe(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&_i){let r=e.domSelectionRange(),a=e.domObserver.currentSelection;if(r.anchorNode&&a.anchorNode&&_1(r.anchorNode,r.anchorOffset,a.anchorNode,a.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Yft(e);else{let{anchor:r,head:a}=n,o,i;ASe&&!(n instanceof Wr)&&(n.$from.parent.inlineContent||(o=RSe(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=RSe(e,n.to))),e.docView.setSelection(r,a,e,t),ASe&&(o&&xSe(o),i&&xSe(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Wft(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const ASe=ns||_i&&qxe<63;function RSe(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),a=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(ns&&a&&a.contentEditable=="false")return cq(a);if((!a||a.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(a)return cq(a);if(o)return cq(o)}}function cq(e){return e.contentEditable="true",ns&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function xSe(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Wft(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,a=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=a)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!bSe(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Yft(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,Pi(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&xl&&Am<=11&&(n.disabled=!0,n.disabled=!1)}function SSe(e,t){if(t instanceof yn){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(wSe(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else wSe(e)}function wSe(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function uq(e,t,n,r){return e.someProp("createSelectionBetween",a=>a(e,t,n))||Wr.between(t,n,r)}function MSe(e){return e.editable&&!e.hasFocus()?!1:NSe(e)}function NSe(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Zft(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return _1(t.node,t.offset,n.anchorNode,n.anchorOffset)}function fq(e,t){let{$anchor:n,$head:r}=e.selection,a=t>0?n.max(r):n.min(r),o=a.parent.inlineContent?a.depth?e.doc.resolve(t>0?a.after():a.before()):null:a;return o&&Tr.findFrom(o,t)}function Sm(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function TSe(e,t,n){let r=e.state.selection;if(r instanceof Wr)if(n.indexOf("s")>-1){let{$head:a}=r,o=a.textOffset?null:t<0?a.nodeBefore:a.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(a.pos+o.nodeSize*(t<0?-1:1));return Sm(e,new Wr(r.$anchor,i))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let a=fq(e.state,t);return a&&a instanceof yn?Sm(e,a):!1}else if(!(Mu&&n.indexOf("m")>-1)){let a=r.$head,o=a.textOffset?null:t<0?a.nodeBefore:a.nodeAfter,i;if(!o||o.isText)return!1;let s=t<0?a.pos-o.nodeSize:a.pos;return o.isAtom||(i=e.docView.descAt(s))&&!i.contentDOM?yn.isSelectable(o)?Sm(e,new yn(t<0?e.state.doc.resolve(a.pos-o.nodeSize):a)):W5?Sm(e,new Wr(e.state.doc.resolve(t<0?s:s+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof yn&&r.node.isInline)return Sm(e,new Wr(t>0?r.$to:r.$from));{let a=fq(e.state,t);return a?Sm(e,a):!1}}}function qP(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Q5(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function lx(e,t){return t<0?Kft(e):Qft(e)}function Kft(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let a,o,i=!1;for(wu&&n.nodeType==1&&r<qP(n)&&Q5(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let s=n.childNodes[r-1];if(Q5(s,-1))a=n,o=--r;else if(s.nodeType==3)n=s,r=n.nodeValue.length;else break}}else{if(CSe(n))break;{let s=n.previousSibling;for(;s&&Q5(s,-1);)a=n.parentNode,o=Pi(s),s=s.previousSibling;if(s)n=s,r=qP(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}i?dq(e,n,r):a&&dq(e,a,o)}function Qft(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let a=qP(n),o,i;for(;;)if(r<a){if(n.nodeType!=1)break;let s=n.childNodes[r];if(Q5(s,1))o=n,i=++r;else break}else{if(CSe(n))break;{let s=n.nextSibling;for(;s&&Q5(s,1);)o=s.parentNode,i=Pi(s)+1,s=s.nextSibling;if(s)n=s,r=0,a=qP(n);else{if(n=n.parentNode,n==e.dom)break;r=a=0}}}o&&dq(e,o,i)}function CSe(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Hft(e,t){for(;e&&t==e.childNodes.length&&!U5(e);)t=Pi(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function zft(e,t){for(;e&&!t&&!U5(e);)t=Pi(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function dq(e,t,n){if(t.nodeType!=3){let o,i;(i=Hft(t,n))?(t=i,n=0):(o=zft(t,n))&&(t=o,n=o.nodeValue.length)}let r=e.domSelection();if(!r)return;if(GP(r)){let o=document.createRange();o.setEnd(t,n),o.setStart(t,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:a}=e;setTimeout(()=>{e.state==a&&e0(e)},50)}function LSe(e,t){let n=e.state.doc.resolve(t);if(!(_i||$xe)&&n.parent.inlineContent){let a=e.coordsAtPos(t);if(t>n.start()){let o=e.coordsAtPos(t-1),i=(o.top+o.bottom)/2;if(i>a.top&&i<a.bottom&&Math.abs(o.left-a.left)>1)return o.left<a.left?"ltr":"rtl"}if(t<n.end()){let o=e.coordsAtPos(t+1),i=(o.top+o.bottom)/2;if(i>a.top&&i<a.bottom&&Math.abs(o.left-a.left)>1)return o.left>a.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function kSe(e,t,n){let r=e.state.selection;if(r instanceof Wr&&!r.empty||n.indexOf("s")>-1||Mu&&n.indexOf("m")>-1)return!1;let{$from:a,$to:o}=r;if(!a.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=fq(e.state,t);if(i&&i instanceof yn)return Sm(e,i)}if(!a.parent.inlineContent){let i=t<0?a:o,s=r instanceof tl?Tr.near(i,t):Tr.findFrom(i,t);return s?Sm(e,s):!1}return!1}function OSe(e,t){if(!(e.state.selection instanceof Wr))return!0;let{$head:n,$anchor:r,empty:a}=e.state.selection;if(!n.sameParent(r))return!0;if(!a)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=e.state.tr;return t<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),e.dispatch(i),!0}return!1}function ESe(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Gft(e){if(!ns||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;ESe(e,r,"true"),setTimeout(()=>ESe(e,r,"false"),20)}return!1}function Jft(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function jft(e,t){let n=t.keyCode,r=Jft(t);if(n==8||Mu&&n==72&&r=="c")return OSe(e,-1)||lx(e,-1);if(n==46&&!t.shiftKey||Mu&&n==68&&r=="c")return OSe(e,1)||lx(e,1);if(n==13||n==27)return!0;if(n==37||Mu&&n==66&&r=="c"){let a=n==37?LSe(e,e.state.selection.from)=="ltr"?-1:1:-1;return TSe(e,a,r)||lx(e,a)}else if(n==39||Mu&&n==70&&r=="c"){let a=n==39?LSe(e,e.state.selection.from)=="ltr"?1:-1:1;return TSe(e,a,r)||lx(e,a)}else{if(n==38||Mu&&n==80&&r=="c")return kSe(e,-1,r)||lx(e,-1);if(n==40||Mu&&n==78&&r=="c")return Gft(e)||kSe(e,1,r)||lx(e,1);if(r==(Mu?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function hq(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:a,openEnd:o}=t;for(;a>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){a--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=e.someProp("clipboardSerializer")||Ub.fromSchema(e.state.schema),s=XSe(),u=s.createElement("div");u.appendChild(i.serializeFragment(r,{document:s}));let c=u.firstChild,f,d=0;for(;c&&c.nodeType==1&&(f=DSe[c.nodeName.toLowerCase()]);){for(let p=f.length-1;p>=0;p--){let v=s.createElement(f[p]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),d++}c=u.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${a} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
344
344
 
345
345
  `);return{dom:u,text:h,slice:t}}function PSe(e,t,n,r,a){let o=a.parent.type.spec.code,i,s;if(!n&&!t)return null;let u=!!t&&(r||o||!n);if(u){if(e.someProp("transformPastedText",h=>{t=h(t,o||r,e)}),o)return s=new Wt(xt.from(e.state.schema.text(t.replace(/\r\n?/g,`