import BaseDrawing from"../../../common/documents/drawing.mjs";import ServerDocumentMixin from"../backend/server-document.mjs";import{setProperty}from"../../../common/utils/_module.mjs";export default class Drawing extends(ServerDocumentMixin(BaseDrawing)){static _migrationRegistry=[...super._migrationRegistry,{fn:migrateV10Fields,version:12},{fn:migrateNullValues,version:12},{fn:migrateInvisible,version:12},{fn:migrateInterface,version:"12.317"},{fn:migrateInvisible,version:"13.351"}]}function migrateV10Fields(e){const t={t:"r",f:"p"},r=Drawing._addDataFieldMigration(e,"type","shape.type",(e=>t[e.type]??e.type)),i=Drawing._addDataFieldMigration(e,"width","shape.width"),n=Drawing._addDataFieldMigration(e,"height","shape.height"),o=Drawing._addDataFieldMigration(e,"points","shape.points",(e=>Array.isArray(e.points)?e.points.flat():e.points));return r||i||n||o}function migrateNullValues(e){let t=!1;return null===e.fillColor&&(e.fillColor="#ffffff",t=!0),null===e.fontSize&&(e.fontSize=48,t=!0),null===e.strokeColor&&(e.strokeColor="#ffffff",t=!0),null===e.strokeWidth&&(e.strokeWidth=0,t=!0),null===e.textColor&&(e.textColor="#ffffff",t=!0),t}function migrateInvisible(e){let t=!1,{text:r,textAlpha:i,fillType:n,fillAlpha:o,strokeWidth:s,strokeAlpha:a}=e;r??="",i??=1,n??=CONST.DRAWING_FILL_TYPES.NONE,o??=1,s??=8,a??=1;const l=""!==r&&i>0,f=n!==CONST.DRAWING_FILL_TYPES.NONE&&o>0;l||f||s>0&&a>0||(e.strokeWidth=s=8,e.strokeColor="#ffffff",e.strokeAlpha=1,t=!0);let{type:p,width:h,height:d,radius:g,points:u}=e.shape??{};switch(p??="r",h??=null,d??=null,g??=null,u??=[],p){case"r":case"e":h<=s&&(h=s+1,setProperty(e,"shape.width",s+1),t=!0),d<=s&&(setProperty(e,"shape.height",s+1),t=!0);break;case"p":if(0===h&&0===d&&(h=1,setProperty(e,"shape.width",h),t=!0),u.length<2)setProperty(e,"shape.points",[0,0,1,0]),t=!0;else if(u.length<4){const[r,i]=u;setProperty(e,"shape.points",[r,i,r+1,i]),t=!0}break;case"c":g<=s/2&&(setProperty(e,"shape.radius",s/2+1),t=!0)}return t}function migrateInterface(e){return e.interface=!!e.text,!0}