UNPKG

photoeditorsdk

Version:

The most comprehensive photo editor SDK for HTML5

2 lines (1 loc) 23.3 kB
import{Ma as v,Oa as b,Qa as u,lb as h}from"./chunk-UDNMGV4K.js";var I=(y="image/png")=>`data:${y};base64,`;var d=class{constructor(e){this.version="3.12.0";this.spriteOrder=0;this.mapRelativeCropPointToImageSpace=e=>{const i=h.relativeToAbsolutePoint(e,this.cropSpace,false);return h.pointFromSpaceToSpace(i,this.cropSpace,this.imageSpace,false)};this.mapRelativeCropSizeToScaledImageSize=e=>{return e*Math.min(this.outputSize.height*this.outputScale.x,this.outputSize.width*this.outputScale.y)};this.mapRelativeCropSizeToUnscaledImageSize=e=>{return e*Math.min(this.outputSize.height,this.outputSize.width)};this.editor=e}static deserializeFilter(e){return{intensity:e.intensity,identifier:e.identifier}}static deserializeAdjustments(e){return{...e}}static deserializeOverlay(e){return{identifier:e.identifier,opacity:e.intensity,blendMode:e.blendMode.replace(/([ _][a-z])/g,i=>i.toUpperCase().replace(" ","").replace("_",""))}}static initializeEmptyTransform(){return{outputRotation:0,flipHorizontally:false,flipVertically:false,start:{x:0,y:0},end:{x:1,y:1},rotation:0}}static deserialzeColor(e){if(e){if(e.rgba){return e.rgba}}return[0,0,0,0]}validateVersion(e){return this.version===e}static checkIfPlatformHTML(e){return e==="html5"}static deserializeStickers(e){return{identifier:e.identifier,opacity:e.alpha||0,tintMode:e.tintMode||"none",tintColor:d.deserialzeColor(e.tintColor)}}checkIsSerialisationValid(e){if(typeof e!=="string"&&this.validateVersion(e.version))return true;if(typeof e==="string"){throw new Error("Invalid input of type string, please provide an object")}return false}deserializeImage(e){const i={};if(e.image){i.image={width:e.image.width,height:e.image.height,data:e.image.data?e.image.data.replace(I(),""):""};i.image.data=i.image.data?I()+i.image.data:""}return i}deserializeTransformation(e){const i={};const a=e.operations.find(o=>o.type==="orientation");const r=e.operations.find(o=>o.type==="transform");const[n]=this.editor.engine.getRootContainers();this.previewPosition=this.editor.transformToolStore.defaultCropMaskPosition;this.previewSize=this.editor.transformToolStore.maxCropMaskSize;this.imageSpace=n;i.transform=d.initializeEmptyTransform();if(a!=null){i.transform.outputRotation=a.options.rotation;i.transform.flipHorizontally=a.options.flipHorizontally||false;i.transform.flipVertically=a.options.flipVertically||false}if(r){i.transform.start=r.options.start;i.transform.end=r.options.end;i.transform.rotation=r.options.rotation||0;i.transform.identifier=r.options.meta?r.options.meta.identifier:""}return i}deserialize(e){var n,o;const i={};if(e.meta?!d.checkIfPlatformHTML(e.meta.platform):false){console.warn("Read serialisation from another Platform")}const a=this.editor.engineMediator.output.container.getResolution();const{size:r}=this.editor.engineMediator.image.container.getBounds();this.outputSize=a;this.imageSize=r;this.cropSpace=this.editor.engine.getOutputContainer();this.outputScale=this.cropSpace.getScale();e.operations.forEach(p=>{switch(p.type){case"filter":i.filter=d.deserializeFilter(p.options);break;case"adjustments":i.adjustment=d.deserializeAdjustments(p.options);break;case"focus":i.focus=this.deserializeFocus(p.options);break;case"sprite":const{sprites:z}=p.options;z.forEach(t=>{switch(t.type){case"frame":i.frame=this.deserializeFrame(t.options);break;case"overlay":i.overlay=d.deserializeOverlay(t.options);break;case"brush":if(!i.brush){i.brush=this.deserializeBrush(t.options)}else{i.brush.strokes.push(...this.deserializeBrush(t.options).strokes)}break;case"sticker":case"text":case"textdesign":if(!i.sprite){i.sprite={spriteIdList:[],sticker:{},text:{},textdesign:{},common:{}}}const s=b();i.sprite.spriteIdList.push(s);i.sprite.common[s]={order:this.spriteOrder,position:this.mapRelativeCropPointToImageSpace(t.options.position),tool:"sticker",rotation:t.options.rotation||0,flipHorizontally:t.options.flipHorizontally,flipVertically:t.options.flipVertically};this.spriteOrder+=1;if(t.type==="sticker"){i.sprite.common[s].tool="sticker";i.sprite.common[s].size={width:this.mapRelativeCropSizeToScaledImageSize(t.options.dimensions.x),height:this.mapRelativeCropSizeToScaledImageSize(t.options.dimensions.y)};i.sprite.sticker[s]=d.deserializeStickers(t.options)}else if(t.type==="text"){i.sprite.common[s].tool="text";i.sprite.text[s]=this.deserializeTexts(t.options)}else if(t.type==="textdesign"){i.sprite.common[s].tool="textdesign";i.sprite.textdesign[s]=this.deserializeTextDesign(t.options)}break;default:break}});break;default:break}});if(e.assetLibrary){i.customStickers=((o=(n=e.assetLibrary)==null?void 0:n.assets)==null?void 0:o.stickers)||[]}return i}deserializeFrame(e){return{identifier:e.identifier,opacity:e.alpha,width:this.mapRelativeCropSizeToUnscaledImageSize(e.size),color:d.deserialzeColor(e.tintColor)}}deserializeFocus(e){switch(e.type){case"linear":return{identifier:"linear",linear:this.deserializeLinearFocus(e.options)};case"gaussian":return{identifier:"gaussian",gaussian:this.deserializeGaussianFocus(e.options)};case"radial":return{identifier:"radial",radial:this.deserializeRadialFocus(e.options)};case"mirrored":return{identifier:"mirrored",mirrored:this.deserializeMirroredFocus(e.options)};default:break}return void 0}deserializeRadialFocus(e){return{center:this.mapRelativeCropPointToImageSpace(e.start),radius:new u(this.mapRelativeCropPointToImageSpace(e.start)).subtract(new u(this.mapRelativeCropPointToImageSpace(e.end))).magnitude,blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeLinearFocus(e){return{start:this.mapRelativeCropPointToImageSpace(e.start),end:this.mapRelativeCropPointToImageSpace(e.end),blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeGaussianFocus(e){return{blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeMirroredFocus(e){const i=new u(this.mapRelativeCropPointToImageSpace(e.start)).subtract(new u(this.mapRelativeCropPointToImageSpace(e.end)));return{origin:new u(this.mapRelativeCropPointToImageSpace(e.start)).add(new u(this.mapRelativeCropPointToImageSpace(e.end))).divide(2),rotation:Math.atan2(i.y,i.x),size:this.mapRelativeCropSizeToScaledImageSize(e.size),blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeTexts(e){return{identifier:v(e.fontIdentifier),fontSize:this.mapRelativeCropSizeToScaledImageSize(e.fontSize),width:this.mapRelativeCropSizeToScaledImageSize(e.maxWidth),alignment:e.alignment,textColor:d.deserialzeColor(e.color),backgroundColor:d.deserialzeColor(e.backgroundColor),lineHeight:e.lineHeight,text:e.text}}deserializeTextDesign(e){return{identifier:e.identifier,width:this.mapRelativeCropSizeToScaledImageSize(e.width),padding:this.mapRelativeCropSizeToScaledImageSize(e.padding),color:d.deserialzeColor(e.color),seed:e.seed,text:e.text,isInverted:e.inverted}}deserializeBrush(e){return{strokes:e.paths.map(i=>{return{path:{controlPoints:i.points.map(this.mapRelativeCropPointToImageSpace)},brush:{id:"imgly_brush_radial",color:d.deserialzeColor(i.brush.color),size:i.brush.size,hardness:i.brush.hardness}}})}}};var k=(y="image/png")=>`data:${y};base64,`;var c=class{constructor(e){this.version="3.9.0";this.spriteOrder=0;this.mapRelativeCropPointToImageSpace=e=>{const i=h.relativeToAbsolutePoint(e,this.cropSpace,false);return h.pointFromSpaceToSpace(i,this.cropSpace,this.imageSpace,false)};this.mapRelativeCropSizeToScaledImageSize=e=>{return e*Math.min(this.outputSize.height*this.outputScale.x,this.outputSize.width*this.outputScale.y)};this.mapRelativeCropSizeToUnscaledImageSize=e=>{return e*Math.min(this.outputSize.height,this.outputSize.width)};this.editor=e}static deserializeFilter(e){return{intensity:e.intensity,identifier:e.identifier}}static deserializeAdjustments(e){return{...e}}static deserializeOverlay(e){return{identifier:e.identifier,opacity:e.intensity,blendMode:e.blendMode.replace(/([ _][a-z])/g,i=>i.toUpperCase().replace(" ","").replace("_",""))}}static initializeEmptyTransform(){return{outputRotation:0,flipHorizontally:false,flipVertically:false,start:{x:0,y:0},end:{x:1,y:1},rotation:0}}static deserialzeColor(e){if(e){if(e.rgba){return e.rgba}}return[0,0,0,0]}validateVersion(e){return this.version===e}static checkIfPlatformHTML(e){return e==="html5"}static deserializeStickers(e){return{identifier:e.identifier,opacity:e.alpha||0,tintMode:e.tintMode||"none",tintColor:c.deserialzeColor(e.tintColor)}}checkIsSerialisationValid(e){if(typeof e!=="string"&&this.validateVersion(e.version))return true;if(typeof e==="string"){throw new Error("Invalid input of type string, please provide an object")}return false}deserializeImage(e){const i={};if(e.image){i.image={width:e.image.width,height:e.image.height,data:e.image.data?e.image.data.replace(k(),""):""};i.image.data=i.image.data?k()+i.image.data:""}return i}deserializeTransformation(e){const i={};const a=e.operations.find(o=>o.type==="orientation");const r=e.operations.find(o=>o.type==="transform");const[n]=this.editor.engine.getRootContainers();this.previewPosition=this.editor.transformToolStore.defaultCropMaskPosition;this.previewSize=this.editor.transformToolStore.maxCropMaskSize;this.imageSpace=n;i.transform=c.initializeEmptyTransform();if(a!=null){i.transform.outputRotation=a.options.rotation;i.transform.flipHorizontally=a.options.flipHorizontally||false;i.transform.flipVertically=a.options.flipVertically||false}if(r){i.transform.start=r.options.start;i.transform.end=r.options.end;i.transform.rotation=r.options.rotation||0;i.transform.identifier=r.options.meta?r.options.meta.identifier:""}return i}deserialize(e){var n,o;const i={};if(e.meta?!c.checkIfPlatformHTML(e.meta.platform):false){console.warn("Read serialisation from another Platform")}const a=this.editor.engineMediator.output.container.getResolution();const{size:r}=this.editor.engineMediator.image.container.getBounds();this.outputSize=a;this.imageSize=r;this.cropSpace=this.editor.engine.getOutputContainer();this.outputScale=this.cropSpace.getScale();e.operations.forEach(p=>{switch(p.type){case"filter":i.filter=c.deserializeFilter(p.options);break;case"adjustments":i.adjustment=c.deserializeAdjustments(p.options);break;case"focus":i.focus=this.deserializeFocus(p.options);break;case"sprite":const{sprites:z}=p.options;z.forEach(t=>{switch(t.type){case"frame":i.frame=this.deserializeFrame(t.options);break;case"overlay":i.overlay=c.deserializeOverlay(t.options);break;case"brush":if(!i.brush){i.brush=this.deserializeBrush(t.options)}else{i.brush.strokes.push(...this.deserializeBrush(t.options).strokes)}break;case"sticker":case"text":case"textdesign":if(!i.sprite){i.sprite={spriteIdList:[],sticker:{},text:{},textdesign:{},common:{}}}const s=b();i.sprite.spriteIdList.push(s);i.sprite.common[s]={order:this.spriteOrder,position:this.mapRelativeCropPointToImageSpace(t.options.position),tool:"sticker",rotation:t.options.rotation||0,flipHorizontally:t.options.flipHorizontally,flipVertically:t.options.flipVertically};this.spriteOrder+=1;if(t.type==="sticker"){i.sprite.common[s].tool="sticker";i.sprite.common[s].size={width:this.mapRelativeCropSizeToScaledImageSize(t.options.dimensions.x),height:this.mapRelativeCropSizeToScaledImageSize(t.options.dimensions.y)};i.sprite.sticker[s]=c.deserializeStickers(t.options)}else if(t.type==="text"){i.sprite.common[s].tool="text";i.sprite.text[s]=this.deserializeTexts(t.options)}else if(t.type==="textdesign"){i.sprite.common[s].tool="textdesign";i.sprite.textdesign[s]=this.deserializeTextDesign(t.options)}break;default:break}});break;default:break}});if(e.assetLibrary){i.customStickers=((o=(n=e.assetLibrary)==null?void 0:n.assets)==null?void 0:o.stickers)||[]}return i}deserializeFrame(e){return{identifier:e.identifier,opacity:e.alpha,width:this.mapRelativeCropSizeToUnscaledImageSize(e.size),color:c.deserialzeColor(e.tintColor)}}deserializeFocus(e){switch(e.type){case"linear":return{identifier:"linear",linear:this.deserializeLinearFocus(e.options)};case"gaussian":return{identifier:"gaussian",gaussian:this.deserializeGaussianFocus(e.options)};case"radial":return{identifier:"radial",radial:this.deserializeRadialFocus(e.options)};case"mirrored":return{identifier:"mirrored",mirrored:this.deserializeMirroredFocus(e.options)};default:return void 0}}deserializeRadialFocus(e){return{center:this.mapRelativeCropPointToImageSpace(e.start),radius:new u(this.mapRelativeCropPointToImageSpace(e.start)).subtract(new u(this.mapRelativeCropPointToImageSpace(e.end))).magnitude,blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeLinearFocus(e){return{start:this.mapRelativeCropPointToImageSpace(e.start),end:this.mapRelativeCropPointToImageSpace(e.end),blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeGaussianFocus(e){return{blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeMirroredFocus(e){const i=new u(this.mapRelativeCropPointToImageSpace(e.start)).subtract(new u(this.mapRelativeCropPointToImageSpace(e.end)));return{origin:new u(this.mapRelativeCropPointToImageSpace(e.start)).add(new u(this.mapRelativeCropPointToImageSpace(e.end))).divide(2),rotation:Math.atan2(i.y,i.x),size:this.mapRelativeCropSizeToScaledImageSize(e.size),blurRadius:this.mapRelativeCropSizeToScaledImageSize(e.blurRadius)}}deserializeTexts(e){return{identifier:v(e.fontIdentifier),fontSize:this.mapRelativeCropSizeToScaledImageSize(e.fontSize),width:this.mapRelativeCropSizeToScaledImageSize(e.maxWidth),alignment:e.alignment,textColor:c.deserialzeColor(e.color),backgroundColor:c.deserialzeColor(e.backgroundColor),lineHeight:e.lineHeight,text:e.text}}deserializeTextDesign(e){return{identifier:e.identifier,width:this.mapRelativeCropSizeToScaledImageSize(e.width),padding:this.mapRelativeCropSizeToScaledImageSize(e.padding),color:c.deserialzeColor(e.color),seed:e.seed,text:e.text,isInverted:e.inverted}}deserializeBrush(e){return{strokes:e.paths.map(i=>{return{path:{controlPoints:i.points.map(this.mapRelativeCropPointToImageSpace)},brush:{id:"imgly_brush_radial",color:c.deserialzeColor(i.brush.color),size:i.brush.size,hardness:i.brush.hardness}}})}}};var E="@photoeditorsdk/root";var j="5.19.3";var A="The most comprehensive photo editor SDK for HTML5";var H="http://github.com/imgly/pesdk-html5";var L="PhotoEditorSDK (img.ly GmbH) <contact@img.ly>";var V="SEE LICENSE IN LICENSE.md";var B=true;var G={};var U={start:"yarn workspace @example/react start",build:"yarn sdk-script build","build:rollup":"yarn sdk-script build rollup","package:release":"cd dist/photoeditorsdk && npm publish","package:pre-release":"cd dist/photoeditorsdk && npm publish --tag next","lint:css":"stylelint './packages/**/*.tsx'","lint:ts":"eslint ./packages/**/*.{ts,tsx}","lint:ts-engine":"eslint ./engine/**/*.ts","lint:types":"tsc --noEmit -p tsconfig.json --skipLibCheck","lint:types-engine":"tsc --noEmit -p engine/tsconfig.json --skipLibCheck",lint:"run-p lint:*",test:"$(npm bin)/jest",e2e:"cypress open","e2e:server":"sdk-script ui -P 3000 -D build","e2e:ci":"CYPRESS_RETRIES=2 cypress run --browser chrome --headed",deploy:"yarn workspace examp run deploy:pages",docs:"rm -rf ./docs && typedoc",postinstall:"yarn sdk-script server:build"};var N={"@elv1n/cypress-plugin-snapshots":"1.4.4","@types/jest":"^24.0.11","@types/pixelmatch":"^5.2.2","@types/pngjs":"^3.4.2","@types/react":"^16.8.13","@types/react-dom":"^16.8.4","@types/styled-components":"4.4.0","@typescript-eslint/eslint-plugin":"4.6.0","@typescript-eslint/parser":"4.6.0",autoprefixer:"^9.7.4","cross-env":"^7.0.2",cypress:"6.6.0",eslint:"7.10.0","eslint-config-airbnb":"18.2.0","eslint-config-prettier":"6.12.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-cypress":"^2.11.2","eslint-plugin-import":"2.22.1","eslint-plugin-jsx-a11y":"6.3.1","eslint-plugin-no-only-tests":"^2.4.0","eslint-plugin-prettier":"3.1.4","eslint-plugin-react":"7.21.3",husky:"4.3.0",jest:"24.9.0",jsdoc:"^3.6.3","lint-staged":"10.4.0","lodash.defaults":"^4.2.0","mobx-react-devtools":"^6.1.1","native-url":"0.3.4","npm-run-all":"^4.1.5",prettier:"^2.0.5",react:"16.8.6","react-dom":"16.8.6","start-server-and-test":"1.11.5","styled-components":"4.4.1",stylelint:"^13.7.2","stylelint-config-recommended":"^3.0.0","stylelint-config-standard":"^20.0.0","stylelint-config-styled-components":"^0.1.1","stylelint-processor-styled-components":"^1.10.0","ts-jest":"24.3.0",typedoc:"^0.17.8",typescript:"3.8.3","utility-types":"^3.10.0"};var K={"@juggle/resize-observer":"3.2.0","@reach/portal":"^0.13.0","can-use-dom":"0.1.0","lodash.debounce":"4.0.8","lodash.memoize":"4.1.2","lodash.throttle":"4.1.1",mobx:"4.15.7","mobx-react":"6.3.1",photoeditorsdk:"1.0.0","react-app-polyfill":"1.0.6","react-transition-group":"^4.4.1"};var X={node:"10.x || 11.x || 12.x || 13.x || 14.x || 15.x"};var $={eslint:"7.10.0"};var W=["examples/server","examples/material-ui","examples/ssr","examples/react","packages/*","!packages/ui","packages/ui/*","!packages/ui/components","packages/ui/components/*","engine/*","test/*","scripts"];var q={hooks:{"pre-commit":"lint-staged","pre-push":"true"}};var F={name:E,version:j,description:A,repository:H,author:L,license:V,private:B,bin:G,scripts:U,devDependencies:N,dependencies:K,devEngines:X,resolutions:$,workspaces:W,husky:q};var f=class{constructor(e,i,a,r,n,o){this.version="3.12.0";this.mapImagePointToRelativeCropPoint=e=>{const i=h.pointFromSpaceToSpace(e,this.imageSpace,this.cropSpace,false);return h.absoluteToRelativePoint(i,this.cropSpace,false)};this.mapSizeToRelativeUnscaledCropSize=e=>{return e/Math.min(this.outputSize.height,this.outputSize.width)};this.mapSizeToRelativeScaledCropSize=e=>{return e/Math.min(this.outputSize.height*this.outputScale.x,this.outputSize.width*this.outputScale.y)};this.getPointInDirection=(e,i=0,a=3)=>{const r=Math.tan(i);const n=Math.sqrt(r**2+1);return{x:e.x+a/n,y:e.y+a*r/n}};this.previewPosition=e;this.previewSize=i;this.outputSize=a;this.imageSize=r;this.imageSpace=n;this.cropSpace=o;this.outputScale=o.getScale()}static serializeFilters(e){return{type:"filter",options:{intensity:e.intensity,identifier:e.identifier}}}static serializeAdjustments(e){return{type:"adjustments",options:e}}static serializeOverlay(e){return{type:"overlay",options:{identifier:e.identifier,intensity:e.opacity,blendMode:e.blendMode.replace(/[A-Z]/g,i=>` ${i.toLowerCase()}`)}}}static serializeMetaData(){return{platform:"html5",version:F.version,createdAt:new Date().toISOString()}}serialise(e,i,a){const r=f.serializeMetaData();const n={width:this.imageSize.width,height:this.imageSize.height};if(i){n.type=a;n.data=i}const o=[];const p=[];const{adjustment:z}=e;if(Object.keys(z).map(l=>z[l]).filter(Boolean).length){o.push(f.serializeAdjustments(z))}const{filter:t}=e;if(t.identifier!=="identity"){o.push(f.serializeFilters(t))}const{overlay:s}=e;if(s.identifier!=="identity"){p.push(f.serializeOverlay(s))}if(e.transform){const{transform:l,orientation:S}=this.serializeTransform(e.transform);const O=[l.options.start.x!==0,l.options.start.y!==0,l.options.end.x!==1,l.options.end.y!==1,l.options.rotation!==0];const T=[S.options.rotation!==0,S.options.flipVertically!==false,S.options.flipHorizontally!==false];if(O.some(g=>g)){o.push(l)}if(T.some(g=>g)){o.push(S)}}const{frame:C}=e;if(C.identifier!=="identity"){p.push(this.serialzeFrame(C))}const{focus:R}=e;if(R.identifier!=="identity"){o.push(this.serializeFocus(R))}if(e.sprite){e.sprite.spriteIdList.forEach(l=>{const S=e.sprite.common[l];switch(S.tool){case"sticker":const O=e.sprite.sticker[l];p.push(this.serializeSticker(O,S,e.transform));break;case"text":const T=e.sprite.text[l];p.push(this.serializeText(T,S));break;case"textdesign":const g=e.sprite.textdesign[l];p.push(this.serializeTextDesign(g,S));break;default:break}})}if(e.brush.strokes.length){p.push({type:"brush",options:{paths:e.brush.strokes.map(l=>{return{points:l.path.controlPoints.map(this.mapImagePointToRelativeCropPoint),brush:{color:{rgba:l.brush.color},size:l.brush.size,hardness:l.brush.hardness}}})}})}if(p.length){const l={type:"sprite",options:{sprites:p}};o.push(l)}const P=e.customStickers;const w={assets:{stickers:P}};return{version:this.version,meta:r,image:n,operations:o,assetLibrary:w}}serialzeFrame(e){return{type:"frame",options:{identifier:e.identifier,alpha:e.opacity,tintColor:{rgba:e.color},size:this.mapSizeToRelativeUnscaledCropSize(e.width)}}}serializeFocus(e){const i=Math.sqrt(this.previewSize.width**2+this.previewSize.height**2);switch(e.identifier){case"linear":return{type:"focus",options:{type:"linear",options:{start:this.mapImagePointToRelativeCropPoint(e.linear.start),end:this.mapImagePointToRelativeCropPoint(e.linear.end),blurRadius:this.mapSizeToRelativeScaledCropSize(e.linear.blurRadius)}}};case"radial":return{type:"focus",options:{type:"radial",options:{start:this.mapImagePointToRelativeCropPoint(e.radial.center),end:this.mapImagePointToRelativeCropPoint(this.getPointInDirection(e.radial.center,0,e.radial.radius)),blurRadius:this.mapSizeToRelativeScaledCropSize(e.radial.blurRadius),gradientRadius:.1}}};case"mirrored":const{mirrored:a}=e;return{type:"focus",options:{type:"mirrored",options:{start:this.mapImagePointToRelativeCropPoint(this.getPointInDirection(a.origin,a.rotation,i/2)),end:this.mapImagePointToRelativeCropPoint(this.getPointInDirection(a.origin,a.rotation,-i/2)),size:this.mapSizeToRelativeScaledCropSize(e.mirrored.size),blurRadius:this.mapSizeToRelativeScaledCropSize(e.mirrored.blurRadius),gradientSize:.1}}};default:return{type:"focus",options:{type:"gaussian",options:{blurRadius:this.mapSizeToRelativeScaledCropSize(e.gaussian.blurRadius)}}}}}serializeSticker(e,i,a){return{type:"sticker",options:{position:this.mapImagePointToRelativeCropPoint(i.position),dimensions:{x:this.mapSizeToRelativeScaledCropSize(i.size.width),y:this.mapSizeToRelativeScaledCropSize(i.size.height)},rotation:i.rotation,flipVertically:(i.flipVertically||false)!==(a.flipVertically||false),flipHorizontally:(i.flipHorizontally||false)!==(a.flipHorizontally||false),identifier:e.identifier,alpha:e.opacity,tintColor:{rgba:e.tintColor},tintMode:e.tintMode}}}serializeText(e,i){return{type:"text",options:{position:this.mapImagePointToRelativeCropPoint(i.position),rotation:i.rotation,flipVertically:false,flipHorizontally:false,fontIdentifier:e.identifier,fontSize:this.mapSizeToRelativeScaledCropSize(e.fontSize),maxWidth:this.mapSizeToRelativeScaledCropSize(e.width),text:e.text,lineHeight:e.lineHeight,color:{rgba:e.textColor},backgroundColor:{rgba:e.backgroundColor},alignment:e.alignment}}}serializeTextDesign(e,i){return{type:"textdesign",options:{position:this.mapImagePointToRelativeCropPoint(i.position),rotation:i.rotation,flipVertically:false,flipHorizontally:false,identifier:e.identifier,inverted:e.isInverted,text:e.text,seed:e.seed,width:this.mapSizeToRelativeScaledCropSize(e.width),padding:this.mapSizeToRelativeScaledCropSize(e.padding),color:{rgba:e.color}}}}serializeTransform(e){const{start:i,end:a}=e;const r={type:"transform",options:{start:i,end:a,rotation:e.rotation,meta:{identifier:e.identifier}}};const n={type:"orientation",options:{rotation:e.outputRotation,flipHorizontally:e.flipHorizontally,flipVertically:e.flipVertically}};return{transform:r,orientation:n}}};var Te={"3.9.0":c,"3.12.0":d};export{Te as Deserializers,f as Serializer};