@imgly/plugin-background-removal-web 1.86.0-nightly.20261102 → 1.87.0-nightly.20261104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +150 -5
- package/dist/index.mjs +12 -29
- package/dist/index.mjs.map +1 -7
- package/package.json +7 -8
- package/dist/.tsbuildinfo +0 -1
- package/dist/fillProcessingBackgroundRemoval.d.ts +0 -5
- package/dist/findOptiomalSource.d.ts +0 -4
- package/dist/plugin.d.ts +0 -10
- package/dist/processBackgroundRemoval.d.ts +0 -32
- package/dist/types.d.ts +0 -4
- package/dist/uploadBlob.d.ts +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,152 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config } from "@imgly/background-removal";
|
|
2
|
+
import { Source } from "@cesdk/cesdk-js";
|
|
3
|
+
/**
|
|
4
|
+
* A wrapper around a plain canvas
|
|
5
|
+
*
|
|
6
|
+
* The idea is to shield the user from the weird semantics of changing width
|
|
7
|
+
* and height of a canvas by making this a opaque block element instead and
|
|
8
|
+
* managing the internal render resolution of the canvas dynamically
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
interface HTMLCreativeEngineCanvasElement extends HTMLElement {
|
|
13
|
+
/** @internal */
|
|
14
|
+
getInternalCanvas(): HTMLCanvasElement;
|
|
15
|
+
/**
|
|
16
|
+
* Removes the internal canvas
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
dispose(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Clear the canvas
|
|
22
|
+
*
|
|
23
|
+
* This is useful when mounting the canvas into a new position in the DOM.
|
|
24
|
+
* If the canvas is not cleared, it will appear in the new DOM position, with
|
|
25
|
+
* its contents stretched to the new size. It will re-render correctly during
|
|
26
|
+
* the next animation frame, but for a brief moment the canvas contents can
|
|
27
|
+
* flash distorted.
|
|
28
|
+
*
|
|
29
|
+
* Call `clear()` before mounting into the DOM to avoid this. This will cause
|
|
30
|
+
* the canvas to be cleared until rendering the next frame.
|
|
31
|
+
*/
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'cesdk-canvas': HTMLCreativeEngineCanvasElement;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface Window {
|
|
41
|
+
Cypress?: unknown;
|
|
42
|
+
IS_PLAYWRIGHT?: boolean;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
declare global {
|
|
46
|
+
/**
|
|
47
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
48
|
+
* from the exportVideo task
|
|
49
|
+
*/
|
|
50
|
+
var ubq_browserTabHidden: boolean;
|
|
51
|
+
}
|
|
52
|
+
declare global {
|
|
53
|
+
/**
|
|
54
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
55
|
+
* from the exportVideo task
|
|
56
|
+
*/
|
|
57
|
+
var ubq_browserTabHidden: boolean;
|
|
58
|
+
}
|
|
59
|
+
declare global {
|
|
60
|
+
/**
|
|
61
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
62
|
+
* from the exportVideo task
|
|
63
|
+
*/
|
|
64
|
+
var ubq_browserTabHidden: boolean;
|
|
65
|
+
}
|
|
66
|
+
declare global {
|
|
67
|
+
/**
|
|
68
|
+
* Used to communicate the status to C++ in emscripten/CodecBackendWebCodecs.cpp
|
|
69
|
+
* from the exportAudio task
|
|
70
|
+
*/
|
|
71
|
+
var ubq_browserTabHidden: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Dispatched on the engine canvas when the text input has been blurred.
|
|
75
|
+
* Call `preventDefault()` to disallow this and refocus the engine text input.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
interface BlurEvent extends CustomEvent<EventTarget | null> {
|
|
79
|
+
readonly type: 'cesdk-blur';
|
|
80
|
+
/** Contains the element that has received focus during the blur, or null */
|
|
81
|
+
readonly detail: EventTarget | null;
|
|
82
|
+
/** Force focus back to the engine input */
|
|
83
|
+
preventDefault(): void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Dispatched on the engine canvas right before the engine will refocus its text
|
|
87
|
+
* input after a blur. Call `preventDefault()` to prevent the refocusing.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
interface RefocusEvent extends CustomEvent<EventTarget | null> {
|
|
91
|
+
readonly type: 'cesdk-refocus';
|
|
92
|
+
/** Contains the element that has received focus during the blur, or null */
|
|
93
|
+
readonly detail: EventTarget | null;
|
|
94
|
+
/** Prevent refocusing the engine input */
|
|
95
|
+
preventDefault(): void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Dispatched on the engine canvas when the text input has been blurred.
|
|
99
|
+
* Call `preventDefault()` to disallow this and refocus the engine text input.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
interface CursorEvent extends CustomEvent<string> {
|
|
103
|
+
readonly type: 'cesdk-cursor';
|
|
104
|
+
/** Contains the cursor style */
|
|
105
|
+
readonly detail: string;
|
|
106
|
+
/** If default is prevented, the Creative Engine won't apply the cursor style to itself. */
|
|
107
|
+
preventDefault(): void;
|
|
108
|
+
}
|
|
109
|
+
declare global {
|
|
110
|
+
interface GlobalEventHandlersEventMap {
|
|
111
|
+
'cesdk-blur': BlurEvent;
|
|
112
|
+
'cesdk-refocus': RefocusEvent;
|
|
113
|
+
'cesdk-cursor': CursorEvent;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
interface IMGLYBackgroundRemovalProviderClientSide {
|
|
117
|
+
type: '@imgly/background-removal';
|
|
118
|
+
configuration?: Config;
|
|
119
|
+
}
|
|
120
|
+
interface CustomBackgroundRemovalProvider {
|
|
121
|
+
type: 'custom';
|
|
122
|
+
/**
|
|
123
|
+
* Process the image file URI and return the processed image file URI with
|
|
124
|
+
* the background removed.
|
|
125
|
+
*
|
|
126
|
+
* @param imageFileURI - The URI of the image file to process
|
|
127
|
+
* @returns The processed image file URI
|
|
128
|
+
*/
|
|
129
|
+
processImageFileURI: (imageFileURI: string) => Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Process the source set and return a new source set as the input source set.
|
|
132
|
+
*
|
|
133
|
+
* @param sourceSet - The source set to process. It is sorted so that the highest resolution image uri is first
|
|
134
|
+
* @returns the new source set with backgrounds removed
|
|
135
|
+
*/
|
|
136
|
+
processSourceSet: (sourceSet: Source[]) => Promise<Source[]>;
|
|
137
|
+
}
|
|
138
|
+
type BackgroundRemovalProvider = IMGLYBackgroundRemovalProviderClientSide | CustomBackgroundRemovalProvider;
|
|
139
|
+
type Location = 'inspectorBar' | 'navigationBar' | 'canvasBarTop' | 'canvasBarBottom' | 'canvasMenu' | 'dock';
|
|
140
|
+
interface UserInterfaceConfiguration {
|
|
141
|
+
locations?: Location | Location[];
|
|
142
|
+
}
|
|
143
|
+
interface PluginConfiguration {
|
|
144
|
+
ui?: UserInterfaceConfiguration;
|
|
145
|
+
provider?: BackgroundRemovalProvider;
|
|
146
|
+
}
|
|
2
147
|
declare const Plugin: (pluginConfiguration?: PluginConfiguration) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
148
|
+
initialize: (context: import("@cesdk/cesdk-js").EditorPluginContext) => void | Promise<void>;
|
|
149
|
+
name: string;
|
|
150
|
+
version: string;
|
|
6
151
|
};
|
|
7
|
-
export default
|
|
152
|
+
export { Plugin as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ct=class{constructor(e,t){this.engine=e,this.key=t}hasData(e){return this.engine.block.isValid(e)&&this.engine.block.hasMetadata(e,this.key)}get(e){if(this.hasData(e))return JSON.parse(this.engine.block.getMetadata(e,this.key))}set(e,t){this.engine.block.setMetadata(e,this.key,JSON.stringify(t))}clear(e){this.engine.block.hasMetadata(e,this.key)&&this.engine.block.removeMetadata(e,this.key)}},Pt=Ct,At=typeof global=="object"&&global&&global.Object===Object&&global,ze=At,jt=typeof self=="object"&&self&&self.Object===Object&&self,Et=ze||jt||Function("return this")(),A=Et,_t=A.Symbol,B=_t,Ge=Object.prototype,Ot=Ge.hasOwnProperty,kt=Ge.toString,T=B?B.toStringTag:void 0;function Rt(e){var t=Ot.call(e,T),r=e[T];try{e[T]=void 0;var a=!0}catch{}var i=kt.call(e);return a&&(t?e[T]=r:delete e[T]),i}var Ft=Rt,Bt=Object.prototype,Lt=Bt.toString;function Nt(e){return Lt.call(e)}var Vt=Nt,Mt="[object Null]",Dt="[object Undefined]",we=B?B.toStringTag:void 0;function Ut(e){return e==null?e===void 0?Dt:Mt:we&&we in Object(e)?Ft(e):Vt(e)}var W=Ut;function Tt(e){return e!=null&&typeof e=="object"}var z=Tt,Ht=Array.isArray,J=Ht;function zt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var $e=zt,Gt="[object AsyncFunction]",$t="[object Function]",Wt="[object GeneratorFunction]",Zt="[object Proxy]";function Kt(e){if(!$e(e))return!1;var t=W(e);return t==$t||t==Wt||t==Gt||t==Zt}var We=Kt,qt=A["__core-js_shared__"],ie=qt,Ie=function(){var e=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Jt(e){return!!Ie&&Ie in e}var Yt=Jt,Xt=Function.prototype,Qt=Xt.toString;function er(e){if(e!=null){try{return Qt.call(e)}catch{}try{return e+""}catch{}}return""}var O=er,tr=/[\\^$.*+?()[\]{}|]/g,rr=/^\[object .+?Constructor\]$/,ar=Function.prototype,or=Object.prototype,ir=ar.toString,sr=or.hasOwnProperty,nr=RegExp("^"+ir.call(sr).replace(tr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lr(e){if(!$e(e)||Yt(e))return!1;var t=We(e)?nr:rr;return t.test(O(e))}var fr=lr;function ur(e,t){return e?.[t]}var dr=ur;function cr(e,t){var r=dr(e,t);return fr(r)?r:void 0}var L=cr,pr=L(A,"WeakMap"),fe=pr,mr=9007199254740991,gr=/^(?:0|[1-9]\d*)$/;function hr(e,t){var r=typeof e;return t=t??mr,!!t&&(r=="number"||r!="symbol"&&gr.test(e))&&e>-1&&e%1==0&&e<t}var br=hr;function xr(e,t){return e===t||e!==e&&t!==t}var Ze=xr,vr=9007199254740991;function yr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=vr}var Ke=yr;function Sr(e){return e!=null&&Ke(e.length)&&!We(e)}var wr=Sr,Ir=Object.prototype;function Cr(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Ir;return e===r}var Pr=Cr;function Ar(e,t){for(var r=-1,a=Array(e);++r<e;)a[r]=t(r);return a}var jr=Ar,Er="[object Arguments]";function _r(e){return z(e)&&W(e)==Er}var Ce=_r,qe=Object.prototype,Or=qe.hasOwnProperty,kr=qe.propertyIsEnumerable,Rr=Ce(function(){return arguments}())?Ce:function(e){return z(e)&&Or.call(e,"callee")&&!kr.call(e,"callee")},Fr=Rr;function Br(){return!1}var Lr=Br,Je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pe=Je&&typeof module=="object"&&module&&!module.nodeType&&module,Nr=Pe&&Pe.exports===Je,Ae=Nr?A.Buffer:void 0,Vr=Ae?Ae.isBuffer:void 0,Mr=Vr||Lr,ue=Mr,Dr="[object Arguments]",Ur="[object Array]",Tr="[object Boolean]",Hr="[object Date]",zr="[object Error]",Gr="[object Function]",$r="[object Map]",Wr="[object Number]",Zr="[object Object]",Kr="[object RegExp]",qr="[object Set]",Jr="[object String]",Yr="[object WeakMap]",Xr="[object ArrayBuffer]",Qr="[object DataView]",ea="[object Float32Array]",ta="[object Float64Array]",ra="[object Int8Array]",aa="[object Int16Array]",oa="[object Int32Array]",ia="[object Uint8Array]",sa="[object Uint8ClampedArray]",na="[object Uint16Array]",la="[object Uint32Array]",m={};m[ea]=m[ta]=m[ra]=m[aa]=m[oa]=m[ia]=m[sa]=m[na]=m[la]=!0;m[Dr]=m[Ur]=m[Xr]=m[Tr]=m[Qr]=m[Hr]=m[zr]=m[Gr]=m[$r]=m[Wr]=m[Zr]=m[Kr]=m[qr]=m[Jr]=m[Yr]=!1;function fa(e){return z(e)&&Ke(e.length)&&!!m[W(e)]}var ua=fa;function da(e){return function(t){return e(t)}}var ca=da,Ye=typeof exports=="object"&&exports&&!exports.nodeType&&exports,H=Ye&&typeof module=="object"&&module&&!module.nodeType&&module,pa=H&&H.exports===Ye,se=pa&&ze.process,ma=function(){try{var e=H&&H.require&&H.require("util").types;return e||se&&se.binding&&se.binding("util")}catch{}}(),je=ma,Ee=je&&je.isTypedArray,ga=Ee?ca(Ee):ua,Xe=ga,ha=Object.prototype,ba=ha.hasOwnProperty;function xa(e,t){var r=J(e),a=!r&&Fr(e),i=!r&&!a&&ue(e),o=!r&&!a&&!i&&Xe(e),n=r||a||i||o,s=n?jr(e.length,String):[],l=s.length;for(var f in e)(t||ba.call(e,f))&&!(n&&(f=="length"||i&&(f=="offset"||f=="parent")||o&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||br(f,l)))&&s.push(f);return s}var va=xa;function ya(e,t){return function(r){return e(t(r))}}var Sa=ya,wa=Sa(Object.keys,Object),Ia=wa,Ca=Object.prototype,Pa=Ca.hasOwnProperty;function Aa(e){if(!Pr(e))return Ia(e);var t=[];for(var r in Object(e))Pa.call(e,r)&&r!="constructor"&&t.push(r);return t}var ja=Aa;function Ea(e){return wr(e)?va(e):ja(e)}var _a=Ea,Oa=L(Object,"create"),G=Oa;function ka(){this.__data__=G?G(null):{},this.size=0}var Ra=ka;function Fa(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ba=Fa,La="__lodash_hash_undefined__",Na=Object.prototype,Va=Na.hasOwnProperty;function Ma(e){var t=this.__data__;if(G){var r=t[e];return r===La?void 0:r}return Va.call(t,e)?t[e]:void 0}var Da=Ma,Ua=Object.prototype,Ta=Ua.hasOwnProperty;function Ha(e){var t=this.__data__;return G?t[e]!==void 0:Ta.call(t,e)}var za=Ha,Ga="__lodash_hash_undefined__";function $a(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=G&&t===void 0?Ga:t,this}var Wa=$a;function N(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}N.prototype.clear=Ra;N.prototype.delete=Ba;N.prototype.get=Da;N.prototype.has=za;N.prototype.set=Wa;var _e=N;function Za(){this.__data__=[],this.size=0}var Ka=Za;function qa(e,t){for(var r=e.length;r--;)if(Ze(e[r][0],t))return r;return-1}var X=qa,Ja=Array.prototype,Ya=Ja.splice;function Xa(e){var t=this.__data__,r=X(t,e);if(r<0)return!1;var a=t.length-1;return r==a?t.pop():Ya.call(t,r,1),--this.size,!0}var Qa=Xa;function eo(e){var t=this.__data__,r=X(t,e);return r<0?void 0:t[r][1]}var to=eo;function ro(e){return X(this.__data__,e)>-1}var ao=ro;function oo(e,t){var r=this.__data__,a=X(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var io=oo;function V(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}V.prototype.clear=Ka;V.prototype.delete=Qa;V.prototype.get=to;V.prototype.has=ao;V.prototype.set=io;var Q=V,so=L(A,"Map"),$=so;function no(){this.size=0,this.__data__={hash:new _e,map:new($||Q),string:new _e}}var lo=no;function fo(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var uo=fo;function co(e,t){var r=e.__data__;return uo(t)?r[typeof t=="string"?"string":"hash"]:r.map}var ee=co;function po(e){var t=ee(this,e).delete(e);return this.size-=t?1:0,t}var mo=po;function go(e){return ee(this,e).get(e)}var ho=go;function bo(e){return ee(this,e).has(e)}var xo=bo;function vo(e,t){var r=ee(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var yo=vo;function M(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}M.prototype.clear=lo;M.prototype.delete=mo;M.prototype.get=ho;M.prototype.has=xo;M.prototype.set=yo;var Qe=M;function So(e,t){for(var r=-1,a=t.length,i=e.length;++r<a;)e[i+r]=t[r];return e}var wo=So;function Io(){this.__data__=new Q,this.size=0}var Co=Io;function Po(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Ao=Po;function jo(e){return this.__data__.get(e)}var Eo=jo;function _o(e){return this.__data__.has(e)}var Oo=_o,ko=200;function Ro(e,t){var r=this.__data__;if(r instanceof Q){var a=r.__data__;if(!$||a.length<ko-1)return a.push([e,t]),this.size=++r.size,this;r=this.__data__=new Qe(a)}return r.set(e,t),this.size=r.size,this}var Fo=Ro;function D(e){var t=this.__data__=new Q(e);this.size=t.size}D.prototype.clear=Co;D.prototype.delete=Ao;D.prototype.get=Eo;D.prototype.has=Oo;D.prototype.set=Fo;var ne=D;function Bo(e,t){for(var r=-1,a=e==null?0:e.length,i=0,o=[];++r<a;){var n=e[r];t(n,r,e)&&(o[i++]=n)}return o}var Lo=Bo;function No(){return[]}var Vo=No,Mo=Object.prototype,Do=Mo.propertyIsEnumerable,Oe=Object.getOwnPropertySymbols,Uo=Oe?function(e){return e==null?[]:(e=Object(e),Lo(Oe(e),function(t){return Do.call(e,t)}))}:Vo,To=Uo;function Ho(e,t,r){var a=t(e);return J(e)?a:wo(a,r(e))}var zo=Ho;function Go(e){return zo(e,_a,To)}var ke=Go,$o=L(A,"DataView"),de=$o,Wo=L(A,"Promise"),ce=Wo,Zo=L(A,"Set"),pe=Zo,Re="[object Map]",Ko="[object Object]",Fe="[object Promise]",Be="[object Set]",Le="[object WeakMap]",Ne="[object DataView]",qo=O(de),Jo=O($),Yo=O(ce),Xo=O(pe),Qo=O(fe),_=W;(de&&_(new de(new ArrayBuffer(1)))!=Ne||$&&_(new $)!=Re||ce&&_(ce.resolve())!=Fe||pe&&_(new pe)!=Be||fe&&_(new fe)!=Le)&&(_=function(e){var t=W(e),r=t==Ko?e.constructor:void 0,a=r?O(r):"";if(a)switch(a){case qo:return Ne;case Jo:return Re;case Yo:return Fe;case Xo:return Be;case Qo:return Le}return t});var Ve=_,ei=A.Uint8Array,Me=ei,ti="__lodash_hash_undefined__";function ri(e){return this.__data__.set(e,ti),this}var ai=ri;function oi(e){return this.__data__.has(e)}var ii=oi;function Y(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Qe;++t<r;)this.add(e[t])}Y.prototype.add=Y.prototype.push=ai;Y.prototype.has=ii;var si=Y;function ni(e,t){for(var r=-1,a=e==null?0:e.length;++r<a;)if(t(e[r],r,e))return!0;return!1}var li=ni;function fi(e,t){return e.has(t)}var ui=fi,di=1,ci=2;function pi(e,t,r,a,i,o){var n=r&di,s=e.length,l=t.length;if(s!=l&&!(n&&l>s))return!1;var f=o.get(e),u=o.get(t);if(f&&u)return f==t&&u==e;var d=-1,c=!0,g=r&ci?new si:void 0;for(o.set(e,t),o.set(t,e);++d<s;){var h=e[d],y=t[d];if(a)var w=n?a(y,h,d,t,e,o):a(h,y,d,e,t,o);if(w!==void 0){if(w)continue;c=!1;break}if(g){if(!li(t,function(S,I){if(!ui(g,I)&&(h===S||i(h,S,r,a,o)))return g.push(I)})){c=!1;break}}else if(!(h===y||i(h,y,r,a,o))){c=!1;break}}return o.delete(e),o.delete(t),c}var et=pi;function mi(e){var t=-1,r=Array(e.size);return e.forEach(function(a,i){r[++t]=[i,a]}),r}var gi=mi;function hi(e){var t=-1,r=Array(e.size);return e.forEach(function(a){r[++t]=a}),r}var bi=hi,xi=1,vi=2,yi="[object Boolean]",Si="[object Date]",wi="[object Error]",Ii="[object Map]",Ci="[object Number]",Pi="[object RegExp]",Ai="[object Set]",ji="[object String]",Ei="[object Symbol]",_i="[object ArrayBuffer]",Oi="[object DataView]",De=B?B.prototype:void 0,le=De?De.valueOf:void 0;function ki(e,t,r,a,i,o,n){switch(r){case Oi:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case _i:return!(e.byteLength!=t.byteLength||!o(new Me(e),new Me(t)));case yi:case Si:case Ci:return Ze(+e,+t);case wi:return e.name==t.name&&e.message==t.message;case Pi:case ji:return e==t+"";case Ii:var s=gi;case Ai:var l=aξif(s||(s=bi),e.size!=t.size&&!l)return!1;var f=n.get(e);if(f)return f==t;a|=vi,n.set(e,t);var u=et(s(e),s(t),a,i,o,n);return n.delete(e),u;case Ei:if(le)return le.call(e)==le.call(t)}return!1}var Ri=ki,Fi=1,Bi=Object.prototype,Li=Bi.hasOwnProperty;function Ni(e,t,r,a,i,o){var n=r&Fi,s=ke(e),l=s.length,f=ke(t),u=f.length;if(l!=u&&!n)return!1;for(var d=l;d--;){var c=s[d];if(!(n?c in t:Li.call(t,c)))return!1}var g=o.get(e),h=o.get(t);if(g&&h)return g==t&&h==e;var y=!0;o.set(e,t),o.set(t,e);for(var w=n;++d<l;){c=s[d];var S=e[c],I=t[c];if(a)var j=n?a(I,S,c,t,e,o):a(S,I,c,e,t,o);if(!(j===void 0?S===I||i(S,I,r,a,o):j)){y=!1;break}w||(w=c=="constructor")}if(y&&!w){var P=e.constructor,C=t.constructor;P!=C&&"constructor"in e&&"constructor"in t&&!(typeof P=="function"&&P instanceof P&&typeof C=="function"&&C instanceof C)&&(y=!1)}return o.delete(e),o.delete(t),y}var Vi=Ni,Mi=1,Ue="[object Arguments]",Te="[object Array]",q="[object Object]",Di=Object.prototype,He=Di.hasOwnProperty;function Ui(e,t,r,a,i,o){var n=J(e),s=J(t),l=n?Te:Ve(e),f=s?Te:Ve(t);l=l==Ue?q:l,f=f==Ue?q:f;var u=l==q,d=f==q,c=l==f;if(c&&ue(e)){if(!ue(t))return!1;n=!0,u=!1}if(c&&!u)return o||(o=new ne),n||Xe(e)?et(e,t,r,a,i,o):Ri(e,t,l,r,a,i,o);if(!(r&Mi)){var g=u&&He.call(e,"__wrapped__"),h=d&&He.call(t,"__wrapped__");if(g||h){var y=g?e.value():e,w=h?t.value():t;return o||(o=new ne),i(y,w,r,a,o)}}return c?(o||(o=new ne),Vi(e,t,r,a,i,o)):!1}var Ti=Ui;function tt(e,t,r,a,i){return e===t?!0:e==null||t==null||!z(e)&&!z(t)?e!==e&&t!==t:Ti(e,t,r,a,tt,i)}var Hi=tt;function zi(e,t){return Hi(e,t)}var Gi=zi,$i=class extends Pt{get(e){return super.get(e)??{status:"IDLE"}}isDuplicate(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status==="IDLE"||t.status==="PENDING"||t.status==="ERROR"||!this.engine.block.hasFill(e))return!1;let r=this.engine.block.getFill(e);return!(t.blockId===e||t.fillId===r)}fixDuplicate(e){let t=this.engine.block.getFill(e),r=this.get(e);r.status==="IDLE"||r.status==="PENDING"||r.status==="ERROR"||(this.set(e,{...r,blockId:e,fillId:t}),r.status==="PROCESSING"&&(this.recoverInitialImageData(e),this.clear(e)))}isConsistent(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status==="IDLE"||t.status==="PENDING")return!0;if(!this.engine.block.hasFill(e))return!1;let r=this.engine.block.getFill(e);if(r==null||e!==t.blockId||r!==t.fillId)return!1;let a=this.engine.block.getSourceSet(r,"fill/image/sourceSet"),i=this.engine.block.getString(r,"fill/image/imageFileURI");if(a.length===0&&!i&&t.status==="PROCESSING")return!0;if(a?.length>0){let o=t.initialSourceSet;if(t.status!=="PROCESSED"&&!Gi(a,o))return!1}else if(t.status!=="PROCESSED"&&i!==t.initialImageFileURI)return!1;return!0}recoverInitialImageData(e){if(!this.engine.block.hasFill(e))return;let t=this.get(e);if(t.status==="PENDING"||t.status==="IDLE")return;let r=t.initialSourceSet,a=t.initialImageFileURI,i=t.initialPreviewFileURI,o=this.getValidFill(e,t);o!=null&&(a&&this.engine.block.setString(o,"fill/image/imageFileURI",a),i&&this.engine.block.setString(o,"fill/image/previewFileURI",i),r.length>0&&this.engine.block.setSourceSet(o,"fill/image/sourceSet",r))}getValidFill(e,t){if(!this.engine.block.isValid(e)||!this.engine.block.hasFill(e)||e!==t.blockId)return;let r=this.engine.block.getFill(e);if(r===t.fillId)return r}},rt=$i;async function Wi(e,t,r,a,i){let o=t.engine.block;if(!o.hasFill(e))throw new Error("Block does not support fill");let n=o.getFill(e),s=o.getSourceSet(n,"fill/image/sourceSet"),l=o.getString(n,"fill/image/imageFileURI"),f=o.getString(n,"fill/image/previewFileURI");try{t.engine.block.setState(n,{type:"Pending",progress:0});let u={...r.get(e),version:i,initialSourceSet:s,initialImageFileURI:l,initialPreviewFileURI:f,blockId:e,fillId:n,status:"PROCESSING"};r.set(e,u);let d=await a.processFill(u);if(r.get(e).status!=="PROCESSING"||!r.isConsistent(e)||r.get(e).status!=="PROCESSING"||!r.isConsistent(e)||d==null)return;let c={version:i,initialSourceSet:s,initialImageFileURI:l,initialPreviewFileURI:f,blockId:e,fillId:n,status:"PROCESSED"},g=a.commitProcessing(d,c);(g==null||g===e)&&r.set(e,c),t.engine.editor.addUndoStep()}catch(u){if(t.engine.block.isValid(e)&&(r.set(e,{version:i,initialSourceSet:s,initialImageFileURI:l,initialPreviewFileURI:f,blockId:e,fillId:n,status:"ERROR"}),r.recoverInitialImageData(e)),u!=null&&typeof u=="object"&&"message"in u&&typeof u.message=="string"){let d=u.message==="signal timed out"?"Processing canceled due to timeout":u.message;t.ui.showNotification({type:"error",message:d})}console.log(u)}finally{t.engine.block.isValid(n)&&t.engine.block.setState(n,{type:"Ready"})}}var me=Wi;function at(e){return`${e}.fillProcessing.feature`}function Zi(e){return[`${e}.canvasMenu`,`${e}.fillProcessing.canvasMenu`]}function Ki(e){return[`${e}.dock`,`${e}.fillProcessing.dock`]}function qi(e){return[`${e}.inspectorBar`,`${e}.fillProcessing.inspectorBar`]}function Ji(e){return[`${e}.navigationBar`,`${e}.fillProcessing.navigationBar`]}function Yi(e){return[`${e}.canvasBar`,`${e}.fillProcessing.canvasBar`]}function Xi(e){return`plugin.${e}.fillProcessing.canvasMenu.button.label`}function Qi(e){return`plugin.${e}.fillProcessing.dock.button.label`}function es(e){return`plugin.${e}.fillProcessing.inspectorBar.button.label`}function ts(e){return`plugin.${e}.fillProcessing.navigationBar.button.label`}function rs(e){return`plugin.${e}.fillProcessing.canvasBar.button.label`}function ot(e,{pluginId:t,process:r}){let a=at(t),i=new rt(e.engine,t);return as(e,i,a),e.engine.event.subscribe([],async o=>{o.forEach(n=>{let s=n.block;if(!(!e.engine.block.isValid(s)||!i.hasData(s))){if(n.type==="Created")i.isDuplicate(s)&&i.fixDuplicate(s);else if(n.type==="Updated")switch(i.get(s).status){case"PENDING":{e.feature.isEnabled(a,{engine:e.engine})&&e.engine.block.isAllowedByScope(s,"fill/change")&&e.engine.block.getState(s).type!=="Pending"&&r(s,i);break}case"PROCESSING":case"PROCESSED":{i.isConsistent(s)||i.clear(s);break}default:}}})}),{featureId:a}}function as(e,t,r){e.feature.enable(r,({engine:a})=>{let i=a.block.findAllSelected();if(i.length!==1)return!1;let[o]=i;if(!e.engine.block.isVisible(o))return!1;if(e.engine.block.hasFill(o)){if(e.engine.block.getKind(o)==="sticker")return!1;let n=e.engine.block.getFill(o);if(e.engine.block.getType(n)!=="//ly.img.ubq/fill/image")return!1;let s=a.block.getString(n,"fill/image/imageFileURI");return a.block.getSourceSet(n,"fill/image/sourceSet").length>0||s!==""?!0:t.get(o).status==="PROCESSING"}return!1})}function it(e,t){let{pluginId:r,locations:a}=t,i=new rt(e.engine,r),o=Xi(r),n=Zi(r),s=n[0],l=Qi(r),f=Ki(r),u=f[0],d=es(r),c=qi(r),g=c[0],h=ts(r),y=Ji(r),w=y[0],S=rs(r),I=Yi(r),j=I[0],P=at(r);return a?.includes("inspectorBar")&&e.ui.setInspectorBarOrder([g,...e.ui.getInspectorBarOrder()]),a?.includes("navigationBar")&&e.ui.setNavigationBarOrder([w,...e.ui.getNavigationBarOrder()]),a?.includes("canvasBarTop")&&e.ui.setCanvasBarOrder([j,...e.ui.getCanvasBarOrder("top")],"top"),a?.includes("canvasBarBottom")&&e.ui.setCanvasBarOrder([j,...e.ui.getCanvasBarOrder("bottom")],"bottom"),a?.includes("canvasMenu")&&e.ui.setCanvasMenuOrder([s,...e.ui.getCanvasMenuOrder()]),a?.includes("dock")&&e.ui.setDockOrder([...e.ui.getDockOrder(),u]),e.ui.registerComponent(f,({builder:{Button:C},engine:p})=>{let[v]=p.block.findAllSelected(),x=!1,E=!1,R;if(v==null&&(x=!0),!x&&!e.feature.isEnabled(P,{engine:p})&&(x=!0),!x&&!e.engine.block.isAllowedByScope(v,"fill/change")&&(x=!0),!x&&p.block.getState(v)?.type==="Pending"&&(x=!0),!x){let b=i.get(v);if(E=b.status==="PROCESSING",x=b.status==="PENDING"||b.status==="PROCESSING",b.status==="PROCESSING"&&b.progress){let{current:K,total:oe}=b.progress;R=K/oe*100}}let F=`${u}.button`;C(F,{label:l,icon:t.icon,isLoading:E,isDisabled:x,loadingProgress:R,onClick:()=>{let b=i.get(v);(b.status==="IDLE"||b.status==="ERROR"||b.status==="PROCESSED")&&i.set(v,{status:"PENDING"})}})}),[{componentIds:c,variant:"plain",label:d},{componentIds:y,variant:"regular",label:h},{componentIds:I,variant:"regular",label:S},{componentIds:n,variant:"plain",label:o}].forEach(({componentIds:C,label:p,variant:v})=>{let x=C[0];e.ui.registerComponent(C,({builder:{Button:E},engine:R})=>{if(!e.feature.isEnabled(P,{engine:R}))return;let[F]=R.block.findAllSelected();if(!e.engine.block.isAllowedByScope(F,"fill/change"))return;let b=i.get(F),K=b.status==="PROCESSING",oe=b.status==="PENDING"||b.status==="PROCESSING"||R.block.getState(F)?.type==="Pending",Se;if(K&&b.progress){let{current:wt,total:It}=b.progress;Se=wt/It*100}let St=`${x}.button`;E(St,{icon:t.icon,label:p,variant:v,isLoading:K,isDisabled:oe,loadingProgress:Se,onClick:()=>{(b.status==="IDLE"||b.status==="ERROR"||b.status==="PROCESSED")&&i.set(F,{status:"PENDING"})}})})}),{canvasMenuComponentId:s,dockComponentId:u,translationsKeys:{inspectorBarLabel:d,navigationBarLabel:h,canvasBarLabel:S,canvasMenuLabel:o,dockLabel:l}}}var $s=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ws=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Zs=new RegExp(/[A-Fa-f0-9]{2}/,"g");var os=typeof global=="object"&&global&&global.Object===Object&&global,st=os;var is=typeof self=="object"&&self&&self.Object===Object&&self,ss=st||is||Function("return this")(),te=ss;var ns=te.Symbol,U=ns;var nt=Object.prototype,ls=nt.hasOwnProperty,fs=nt.toString,Z=U?U.toStringTag:void 0;function us(e){var t=ls.call(e,Z),r=e[Z];try{e[Z]=void 0;var a=!0}catch{}var i=fs.call(e);return a&&(t?e[Z]=r:delete e[Z]),i}var lt=us;var ds=Object.prototype,cs=ds.toString;function ps(e){return cs.call(e)}var ft=ps;var ms="[object Null]",gs="[object Undefined]",ut=U?U.toStringTag:void 0;function hs(e){return e==null?e===void 0?gs:ms:ut&&ut in Object(e)?lt(e):ft(e)}var dt=hs;function bs(e){return e!=null&&typeof e=="object"}var ct=bs;var xs="[object Symbol]";function vs(e){return typeof e=="symbol"||ct(e)&&dt(e)==xs}var pt=vs;var ys=/\s/;function Ss(e){for(var t=e.length;t--&&ys.test(e.charAt(t)););return t}var mt=Ss;var ws=/^\s+/;function Is(e){return e&&e.slice(0,mt(e)+1).replace(ws,"")}var gt=Is;function Cs(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var k=Cs;var ht=NaN,Ps=/^[-+]0x[0-9a-f]+$/i,As=/^0b[01]+$/i,js=/^0o[0-7]+$/i,Es=parseInt;function _s(e){if(typeof e=="number")return e;if(pt(e))return ht;if(k(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=k(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=gt(e);var r=As.test(e);return r||js.test(e)?Es(e.slice(2),r?2:8):Ps.test(e)?ht:+e}var ge=_s;var Os=function(){return te.Date.now()},re=Os;var ks="Expected a function",Rs=Math.max,Fs=Math.min;function Bs(e,t,r){var a,i,o,n,s,l,f=0,u=!1,d=!1,c=!0;if(typeof e!="function")throw new TypeError(ks);t=ge(t)||0,k(r)&&(u=!!r.leading,d="maxWait"in r,o=d?Rs(ge(r.maxWait)||0,t):o,c="trailing"in r?!!r.trailing:c);function g(p){var v=a,x=i;return a=i=void 0,f=p,n=e.apply(x,v),n}function h(p){return f=p,s=setTimeout(S,t),u?g(p):n}function y(p){var v=p-l,x=p-f,E=t-v;return d?Fs(E,o-x):E}function w(p){var v=p-l,x=p-f;return l===void 0||v>=t||v<0||d&&x>=o}function S(){var p=re();if(w(p))return I(p);s=setTimeout(S,y(p))}function I(p){return s=void 0,c&&a?g(p):(a=i=void 0,n)}function j(){s!==void 0&&clearTimeout(s),f=0,a=l=i=s=void 0}function P(){return s===void 0?n:I(re())}function C(){var p=re(),v=w(p);if(a=arguments,i=this,l=p,v){if(s===void 0)return h(l);if(d)return clearTimeout(s),s=setTimeout(S,t),g(l)}return s===void 0&&(s=setTimeout(S,t)),n}return C.cancel=j,C.flush=P,C}var bt=Bs;var Ls="Expected a function";function Ns(e,t,r){var a=!0,i=!0;if(typeof e!="function")throw new TypeError(Ls);return k(r)&&(a="leading"in r?!!r.leading:a,i="trailing"in r?!!r.trailing:i),bt(e,t,{leading:a,maxWait:t,trailing:i})}var he=Ns;import{applySegmentationMask as Ds,removeBackground as Us,segmentForeground as Ts}from"@imgly/background-removal";function Vs(e,t=1024){if(e.length===0)return;let[r,a]=e.reduce((i,o)=>(o.width>=t&&o.height>=t?i[0].push(o):i[1].push(o),i),[[],[]]);return r.length>0?r.sort((i,o)=>i.width*i.height-o.width*o.height)[0]:a.sort((i,o)=>o.width*o.height-i.width*i.height)[0]}var xt=Vs;async function Ms(e,t,r){let i=new URL(t).pathname.split("/"),o=i[i.length-1],s=(await r.unstable_upload(new File([e],o,{type:e.type}),()=>{})).meta?.uri;if(s==null)throw new Error("Could not upload processed fill");return s}var be=Ms;async function ve(e,t,r,a,i){return me(e,t,r,{processFill:i??(async o=>{let n=o.initialSourceSet,s=xt(n);if(s==null)throw new Error("No source found");let l=await xe(s.uri,t),f=await Ts(l,a);return await Promise.all(n.map(async d=>{let c=await Ds(await xe(d.uri,t),f,a),g=await be(c,d.uri,t);return{...d,uri:g}}))}),commitProcessing:(o,n)=>{let s=n.fillId;t.engine.block.setSourceSet(s,"fill/image/sourceSet",o);let l=[...o].sort((f,u)=>f.width*f.height-u.width*u.height)[0];l!=null&&t.engine.block.setString(s,"fill/image/previewFileURI",l.uri)}},"1.86.0-nightly.20261102")}async function ye(e,t,r,a,i){return me(e,t,r,{processFill:i??(async o=>{let n=o.initialImageFileURI,s=await Us(await xe(n,t),a);return await be(s,n,t)}),commitProcessing:(o,n)=>{let s=n.fillId;t.engine.block.setString(s,"fill/image/imageFileURI",o),t.engine.block.setString(s,"fill/image/previewFileURI","")}},"1.86.0-nightly.20261102")}async function xe(e,t){if(e.startsWith("buffer:")){let r=await t.engine.editor.getMimeType(e),a=t.engine.editor.getBufferLength(e),i=t.engine.editor.getBufferData(e,0,a),o=new Uint8Array(i);return new Blob([o],{type:r})}else return e}async function Hs(){if(typeof navigator>"u")return!1;let e=navigator.gpu;if(e==null)return!1;try{let t=await e.requestAdapter();return t==null?!1:t.features.has("shader-f16")}catch{return!1}}async function vt(e,t,r,a){let i=e.engine.block;if(!i.hasFill(t))throw new Error("Block does not support fill");let o=i.getFill(t),n=i.getSourceSet(o,"fill/image/sourceSet"),s=i.getString(o,"fill/image/imageFileURI");if(n.length===0&&s==="")throw new Error("No source or image file URI found");switch(a.type){case"@imgly/background-removal":{let l=a.configuration??{},u={device:l.device??(await Hs()?"gpu":"cpu"),...l,progress:he((d,c,g)=>{let h=r.get(t);h.status!=="PROCESSING"||!r.isConsistent(t)||(l.progress?.(d,c,g),r.set(t,{...h,progress:{key:d,current:c,total:g}}))},100)};n.length>0?ve(t,e,r,u):ye(t,e,r,u);break}case"custom":{n.length>0?ve(t,e,r,void 0,l=>a.processSourceSet(l.initialSourceSet)):ye(t,e,r,void 0,l=>a.processImageFileURI(l.initialImageFileURI));break}default:throw new Error("Unknown background removal provider")}}var ae="@imgly/plugin-background-removal-web",yt=(e={})=>({initialize({cesdk:t}){if(t==null)return;zs(t),ot(t,{pluginId:ae,process:(a,i)=>{vt(t,a,i,e.provider??{type:"@imgly/background-removal"})}});let{translationsKeys:r}=it(t,{pluginId:ae,icon:"@imgly/icons/BGRemove",locations:e.ui?.locations});t.setTranslations({en:{[r.inspectorBarLabel]:"BG Removal",[r.navigationBarLabel]:"BG Removal",[r.canvasBarLabel]:"BG Removal",[r.canvasMenuLabel]:"BG Removal",[r.dockLabel]:"BG Removal"}})}});function zs(e){e.ui.addIconSet("@imgly/plugin/background-removal",`
|
|
1
|
+
import{applySegmentationMask as e,removeBackground as t,segmentForeground as n}from"@imgly/background-removal";var r=class{constructor(e,t){this.engine=e,this.key=t}hasData(e){return this.engine.block.isValid(e)&&this.engine.block.hasMetadata(e,this.key)}get(e){if(this.hasData(e))return JSON.parse(this.engine.block.getMetadata(e,this.key))}set(e,t){this.engine.block.setMetadata(e,this.key,JSON.stringify(t))}clear(e){this.engine.block.hasMetadata(e,this.key)&&this.engine.block.removeMetadata(e,this.key)}},i=typeof global==`object`&&global&&global.Object===Object&&global,a=typeof self==`object`&&self&&self.Object===Object&&self,o=i||a||Function(`return this`)(),s=o.Symbol,c=Object.prototype,l=c.hasOwnProperty,u=c.toString,d=s?s.toStringTag:void 0;function f(e){var t=l.call(e,d),n=e[d];try{e[d]=void 0;var r=!0}catch{}var i=u.call(e);return r&&(t?e[d]=n:delete e[d]),i}var p=Object.prototype.toString;function m(e){return p.call(e)}var h=`[object Null]`,g=`[object Undefined]`,_=s?s.toStringTag:void 0;function v(e){return e==null?e===void 0?g:h:_&&_ in Object(e)?f(e):m(e)}function y(e){return typeof e==`object`&&!!e}var b=Array.isArray;function x(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var ee=`[object AsyncFunction]`,te=`[object Function]`,ne=`[object GeneratorFunction]`,re=`[object Proxy]`;function ie(e){if(!x(e))return!1;var t=v(e);return t==te||t==ne||t==ee||t==re}var S=o[`__core-js_shared__`],ae=function(){var e=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function oe(e){return!!ae&&ae in e}var se=Function.prototype.toString;function C(e){if(e!=null){try{return se.call(e)}catch{}try{return e+``}catch{}}return``}var ce=/[\\^$.*+?()[\]{}|]/g,le=/^\[object .+?Constructor\]$/,ue=Function.prototype,de=Object.prototype,fe=ue.toString,pe=de.hasOwnProperty,me=RegExp(`^`+fe.call(pe).replace(ce,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function he(e){return!x(e)||oe(e)?!1:(ie(e)?me:le).test(C(e))}function ge(e,t){return e?.[t]}function w(e,t){var n=ge(e,t);return he(n)?n:void 0}var T=w(o,`WeakMap`),_e=9007199254740991,ve=/^(?:0|[1-9]\d*)$/;function ye(e,t){var n=typeof e;return t??=_e,!!t&&(n==`number`||n!=`symbol`&&ve.test(e))&&e>-1&&e%1==0&&e<t}function be(e,t){return e===t||e!==e&&t!==t}var xe=9007199254740991;function Se(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=xe}function Ce(e){return e!=null&&Se(e.length)&&!ie(e)}var we=Object.prototype;function Te(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||we)}function Ee(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var De=`[object Arguments]`;function E(e){return y(e)&&v(e)==De}var D=Object.prototype,Oe=D.hasOwnProperty,ke=D.propertyIsEnumerable,Ae=E(function(){return arguments}())?E:function(e){return y(e)&&Oe.call(e,`callee`)&&!ke.call(e,`callee`)};function je(){return!1}var Me=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Ne=Me&&typeof module==`object`&&module&&!module.nodeType&&module,Pe=Ne&&Ne.exports===Me?o.Buffer:void 0,O=(Pe?Pe.isBuffer:void 0)||je,Fe=`[object Arguments]`,Ie=`[object Array]`,Le=`[object Boolean]`,Re=`[object Date]`,ze=`[object Error]`,Be=`[object Function]`,Ve=`[object Map]`,He=`[object Number]`,Ue=`[object Object]`,We=`[object RegExp]`,Ge=`[object Set]`,Ke=`[object String]`,qe=`[object WeakMap]`,Je=`[object ArrayBuffer]`,Ye=`[object DataView]`,Xe=`[object Float32Array]`,Ze=`[object Float64Array]`,Qe=`[object Int8Array]`,$e=`[object Int16Array]`,et=`[object Int32Array]`,tt=`[object Uint8Array]`,nt=`[object Uint8ClampedArray]`,rt=`[object Uint16Array]`,it=`[object Uint32Array]`,k={};k[Xe]=k[Ze]=k[Qe]=k[$e]=k[et]=k[tt]=k[nt]=k[rt]=k[it]=!0,k[Fe]=k[Ie]=k[Je]=k[Le]=k[Ye]=k[Re]=k[ze]=k[Be]=k[Ve]=k[He]=k[Ue]=k[We]=k[Ge]=k[Ke]=k[qe]=!1;function at(e){return y(e)&&Se(e.length)&&!!k[v(e)]}function ot(e){return function(t){return e(t)}}var st=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=st&&typeof module==`object`&&module&&!module.nodeType&&module,j=A&&A.exports===st&&i.process,ct=function(){try{return A&&A.require&&A.require(`util`).types||j&&j.binding&&j.binding(`util`)}catch{}}(),lt=ct&&ct.isTypedArray,ut=lt?ot(lt):at,dt=Object.prototype.hasOwnProperty;function ft(e,t){var n=b(e),r=!n&&Ae(e),i=!n&&!r&&O(e),a=!n&&!r&&!i&&ut(e),o=n||r||i||a,s=o?Ee(e.length,String):[],c=s.length;for(var l in e)(t||dt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||ye(l,c)))&&s.push(l);return s}function pt(e,t){return function(n){return e(t(n))}}var mt=pt(Object.keys,Object),ht=Object.prototype.hasOwnProperty;function gt(e){if(!Te(e))return mt(e);var t=[];for(var n in Object(e))ht.call(e,n)&&n!=`constructor`&&t.push(n);return t}function _t(e){return Ce(e)?ft(e):gt(e)}var M=w(Object,`create`);function vt(){this.__data__=M?M(null):{},this.size=0}function yt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var bt=`__lodash_hash_undefined__`,xt=Object.prototype.hasOwnProperty;function St(e){var t=this.__data__;if(M){var n=t[e];return n===bt?void 0:n}return xt.call(t,e)?t[e]:void 0}var Ct=Object.prototype.hasOwnProperty;function wt(e){var t=this.__data__;return M?t[e]!==void 0:Ct.call(t,e)}var Tt=`__lodash_hash_undefined__`;function Et(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=M&&t===void 0?Tt:t,this}function N(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}N.prototype.clear=vt,N.prototype.delete=yt,N.prototype.get=St,N.prototype.has=wt,N.prototype.set=Et;function Dt(){this.__data__=[],this.size=0}function P(e,t){for(var n=e.length;n--;)if(be(e[n][0],t))return n;return-1}var Ot=Array.prototype.splice;function kt(e){var t=this.__data__,n=P(t,e);return n<0?!1:(n==t.length-1?t.pop():Ot.call(t,n,1),--this.size,!0)}function At(e){var t=this.__data__,n=P(t,e);return n<0?void 0:t[n][1]}function jt(e){return P(this.__data__,e)>-1}function Mt(e,t){var n=this.__data__,r=P(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function F(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}F.prototype.clear=Dt,F.prototype.delete=kt,F.prototype.get=At,F.prototype.has=jt,F.prototype.set=Mt;var I=w(o,`Map`);function Nt(){this.size=0,this.__data__={hash:new N,map:new(I||F),string:new N}}function Pt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function L(e,t){var n=e.__data__;return Pt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Ft(e){var t=L(this,e).delete(e);return this.size-=+!!t,t}function It(e){return L(this,e).get(e)}function Lt(e){return L(this,e).has(e)}function Rt(e,t){var n=L(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function R(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}R.prototype.clear=Nt,R.prototype.delete=Ft,R.prototype.get=It,R.prototype.has=Lt,R.prototype.set=Rt;function zt(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Bt(){this.__data__=new F,this.size=0}function Vt(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Ht(e){return this.__data__.get(e)}function Ut(e){return this.__data__.has(e)}var Wt=200;function Gt(e,t){var n=this.__data__;if(n instanceof F){var r=n.__data__;if(!I||r.length<Wt-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new R(r)}return n.set(e,t),this.size=n.size,this}function z(e){var t=this.__data__=new F(e);this.size=t.size}z.prototype.clear=Bt,z.prototype.delete=Vt,z.prototype.get=Ht,z.prototype.has=Ut,z.prototype.set=Gt;function Kt(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function qt(){return[]}var Jt=Object.prototype.propertyIsEnumerable,Yt=Object.getOwnPropertySymbols,Xt=Yt?function(e){return e==null?[]:(e=Object(e),Kt(Yt(e),function(t){return Jt.call(e,t)}))}:qt;function Zt(e,t,n){var r=t(e);return b(e)?r:zt(r,n(e))}function Qt(e){return Zt(e,_t,Xt)}var B=w(o,`DataView`),V=w(o,`Promise`),H=w(o,`Set`),$t=`[object Map]`,en=`[object Object]`,tn=`[object Promise]`,nn=`[object Set]`,rn=`[object WeakMap]`,an=`[object DataView]`,on=C(B),sn=C(I),cn=C(V),ln=C(H),un=C(T),U=v;(B&&U(new B(/* @__PURE__ */ new ArrayBuffer(1)))!=an||I&&U(new I)!=$t||V&&U(V.resolve())!=tn||H&&U(new H)!=nn||T&&U(new T)!=rn)&&(U=function(e){var t=v(e),n=t==en?e.constructor:void 0,r=n?C(n):``;if(r)switch(r){case on:return an;case sn:return $t;case cn:return tn;case ln:return nn;case un:return rn}return t});var dn=U,fn=o.Uint8Array,pn=`__lodash_hash_undefined__`;function mn(e){return this.__data__.set(e,pn),this}function hn(e){return this.__data__.has(e)}function W(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new R;++t<n;)this.add(e[t])}W.prototype.add=W.prototype.push=mn,W.prototype.has=hn;function gn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function _n(e,t){return e.has(t)}var vn=1,yn=2;function bn(e,t,n,r,i,a){var o=n&vn,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&yn?new W:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!gn(t,function(e,t){if(!_n(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function xn(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Sn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Cn=1,wn=2,Tn=`[object Boolean]`,En=`[object Date]`,Dn=`[object Error]`,On=`[object Map]`,kn=`[object Number]`,An=`[object RegExp]`,jn=`[object Set]`,Mn=`[object String]`,Nn=`[object Symbol]`,Pn=`[object ArrayBuffer]`,Fn=`[object DataView]`,In=s?s.prototype:void 0,G=In?In.valueOf:void 0;function Ln(e,t,n,r,i,a,o){switch(n){case Fn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Pn:return!(e.byteLength!=t.byteLength||!a(new fn(e),new fn(t)));case Tn:case En:case kn:return be(+e,+t);case Dn:return e.name==t.name&&e.message==t.message;case An:case Mn:return e==t+``;case On:var s=xn;case jn:var c=r&Cn;if(s||=Sn,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=wn,o.set(e,t);var u=bn(s(e),s(t),r,i,a,o);return o.delete(e),u;case Nn:if(G)return G.call(e)==G.call(t)}return!1}var Rn=1,zn=Object.prototype.hasOwnProperty;function Bn(e,t,n,r,i,a){var o=n&Rn,s=Qt(e),c=s.length;if(c!=Qt(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:zn.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var Vn=1,Hn=`[object Arguments]`,Un=`[object Array]`,K=`[object Object]`,Wn=Object.prototype.hasOwnProperty;function Gn(e,t,n,r,i,a){var o=b(e),s=b(t),c=o?Un:dn(e),l=s?Un:dn(t);c=c==Hn?K:c,l=l==Hn?K:l;var u=c==K,d=l==K,f=c==l;if(f&&O(e)){if(!O(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new z,o||ut(e)?bn(e,t,n,r,i,a):Ln(e,t,c,n,r,i,a);if(!(n&Vn)){var p=u&&Wn.call(e,`__wrapped__`),m=d&&Wn.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new z,i(h,g,n,r,a)}}return f?(a||=new z,Bn(e,t,n,r,i,a)):!1}function Kn(e,t,n,r,i){return e===t?!0:e==null||t==null||!y(e)&&!y(t)?e!==e&&t!==t:Gn(e,t,n,r,Kn,i)}function qn(e,t){return Kn(e,t)}var Jn=class extends r{get(e){return super.get(e)??{status:`IDLE`}}isDuplicate(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status===`IDLE`||t.status===`PENDING`||t.status===`ERROR`||!this.engine.block.hasFill(e))return!1;let n=this.engine.block.getFill(e);return t.blockId!==e&&t.fillId!==n}fixDuplicate(e){let t=this.engine.block.getFill(e),n=this.get(e);n.status!==`IDLE`&&n.status!==`PENDING`&&n.status!==`ERROR`&&(this.set(e,{...n,blockId:e,fillId:t}),n.status===`PROCESSING`&&(this.recoverInitialImageData(e),this.clear(e)))}isConsistent(e){if(!this.engine.block.isValid(e))return!1;let t=this.get(e);if(t.status===`IDLE`||t.status===`PENDING`)return!0;if(!this.engine.block.hasFill(e))return!1;let n=this.engine.block.getFill(e);if(n==null||e!==t.blockId||n!==t.fillId)return!1;let r=this.engine.block.getSourceSet(n,`fill/image/sourceSet`),i=this.engine.block.getString(n,`fill/image/imageFileURI`);if(r.length===0&&!i&&t.status===`PROCESSING`)return!0;if(r?.length>0){let e=t.initialSourceSet;if(t.status!==`PROCESSED`&&!qn(r,e))return!1}else if(t.status!==`PROCESSED`&&i!==t.initialImageFileURI)return!1;return!0}recoverInitialImageData(e){if(!this.engine.block.hasFill(e))return;let t=this.get(e);if(t.status===`PENDING`||t.status===`IDLE`)return;let n=t.initialSourceSet,r=t.initialImageFileURI,i=t.initialPreviewFileURI,a=this.getValidFill(e,t);a!=null&&(r&&this.engine.block.setString(a,`fill/image/imageFileURI`,r),i&&this.engine.block.setString(a,`fill/image/previewFileURI`,i),n.length>0&&this.engine.block.setSourceSet(a,`fill/image/sourceSet`,n))}getValidFill(e,t){if(!this.engine.block.isValid(e)||!this.engine.block.hasFill(e)||e!==t.blockId)return;let n=this.engine.block.getFill(e);if(n===t.fillId)return n}};async function Yn(e,t,n,r,i){let a=t.engine.block;if(!a.hasFill(e))throw Error(`Block does not support fill`);let o=a.getFill(e),s=a.getSourceSet(o,`fill/image/sourceSet`),c=a.getString(o,`fill/image/imageFileURI`),l=a.getString(o,`fill/image/previewFileURI`);try{t.engine.block.setState(o,{type:`Pending`,progress:0});let a={...n.get(e),version:i,initialSourceSet:s,initialImageFileURI:c,initialPreviewFileURI:l,blockId:e,fillId:o,status:`PROCESSING`};n.set(e,a);let u=await r.processFill(a);if(n.get(e).status!==`PROCESSING`||!n.isConsistent(e)||n.get(e).status!==`PROCESSING`||!n.isConsistent(e)||u==null)return;let d={version:i,initialSourceSet:s,initialImageFileURI:c,initialPreviewFileURI:l,blockId:e,fillId:o,status:`PROCESSED`},f=r.commitProcessing(u,d);(f==null||f===e)&&n.set(e,d),t.engine.editor.addUndoStep()}catch(r){if(t.engine.block.isValid(e)&&(n.set(e,{version:i,initialSourceSet:s,initialImageFileURI:c,initialPreviewFileURI:l,blockId:e,fillId:o,status:`ERROR`}),n.recoverInitialImageData(e)),typeof r==`object`&&r&&`message`in r&&typeof r.message==`string`){let e=r.message===`signal timed out`?`Processing canceled due to timeout`:r.message;t.ui.showNotification({type:`error`,message:e})}console.log(r)}finally{t.engine.block.isValid(o)&&t.engine.block.setState(o,{type:`Ready`})}}function Xn(e){return`${e}.fillProcessing.feature`}function Zn(e){return[`${e}.canvasMenu`,`${e}.fillProcessing.canvasMenu`]}function Qn(e){return[`${e}.dock`,`${e}.fillProcessing.dock`]}function $n(e){return[`${e}.inspectorBar`,`${e}.fillProcessing.inspectorBar`]}function er(e){return[`${e}.navigationBar`,`${e}.fillProcessing.navigationBar`]}function tr(e){return[`${e}.canvasBar`,`${e}.fillProcessing.canvasBar`]}function nr(e){return`plugin.${e}.fillProcessing.canvasMenu.button.label`}function rr(e){return`plugin.${e}.fillProcessing.dock.button.label`}function ir(e){return`plugin.${e}.fillProcessing.inspectorBar.button.label`}function ar(e){return`plugin.${e}.fillProcessing.navigationBar.button.label`}function or(e){return`plugin.${e}.fillProcessing.canvasBar.button.label`}function sr(e,{pluginId:t,process:n}){let r=Xn(t),i=new Jn(e.engine,t);return cr(e,i,r),e.engine.event.subscribe([],async t=>{t.forEach(t=>{let a=t.block;if(e.engine.block.isValid(a)&&i.hasData(a)){if(t.type===`Created`)i.isDuplicate(a)&&i.fixDuplicate(a);else if(t.type===`Updated`)switch(i.get(a).status){case`PENDING`:e.feature.isEnabled(r,{engine:e.engine})&&e.engine.block.isAllowedByScope(a,`fill/change`)&&e.engine.block.getState(a).type!==`Pending`&&n(a,i);break;case`PROCESSING`:case`PROCESSED`:i.isConsistent(a)||i.clear(a)}}})}),{featureId:r}}function cr(e,t,n){e.feature.enable(n,({engine:n})=>{let r=n.block.findAllSelected();if(r.length!==1)return!1;let[i]=r;if(!e.engine.block.isVisible(i))return!1;if(e.engine.block.hasFill(i)){if(e.engine.block.getKind(i)===`sticker`)return!1;let r=e.engine.block.getFill(i);if(e.engine.block.getType(r)!==`//ly.img.ubq/fill/image`)return!1;let a=n.block.getString(r,`fill/image/imageFileURI`);return n.block.getSourceSet(r,`fill/image/sourceSet`).length>0||a!==``||t.get(i).status===`PROCESSING`}return!1})}function lr(e,t){let{pluginId:n,locations:r}=t,i=new Jn(e.engine,n),a=nr(n),o=Zn(n),s=o[0],c=rr(n),l=Qn(n),u=l[0],d=ir(n),f=$n(n),p=f[0],m=ar(n),h=er(n),g=h[0],_=or(n),v=tr(n),y=v[0],b=Xn(n);return r?.includes(`inspectorBar`)&&e.ui.setInspectorBarOrder([p,...e.ui.getInspectorBarOrder()]),r?.includes(`navigationBar`)&&e.ui.setNavigationBarOrder([g,...e.ui.getNavigationBarOrder()]),r?.includes(`canvasBarTop`)&&e.ui.setCanvasBarOrder([y,...e.ui.getCanvasBarOrder(`top`)],`top`),r?.includes(`canvasBarBottom`)&&e.ui.setCanvasBarOrder([y,...e.ui.getCanvasBarOrder(`bottom`)],`bottom`),r?.includes(`canvasMenu`)&&e.ui.setCanvasMenuOrder([s,...e.ui.getCanvasMenuOrder()]),r?.includes(`dock`)&&e.ui.setDockOrder([...e.ui.getDockOrder(),u]),e.ui.registerComponent(l,({builder:{Button:n},engine:r})=>{let[a]=r.block.findAllSelected(),o=!1,s=!1,l;if(a??(o=!0),!o&&!e.feature.isEnabled(b,{engine:r})&&(o=!0),!o&&!e.engine.block.isAllowedByScope(a,`fill/change`)&&(o=!0),!o&&r.block.getState(a)?.type===`Pending`&&(o=!0),!o){let e=i.get(a);if(s=e.status===`PROCESSING`,o=e.status===`PENDING`||e.status===`PROCESSING`,e.status===`PROCESSING`&&e.progress){let{current:t,total:n}=e.progress;l=t/n*100}}n(`${u}.button`,{label:c,icon:t.icon,isLoading:s,isDisabled:o,loadingProgress:l,onClick:()=>{let e=i.get(a);(e.status===`IDLE`||e.status===`ERROR`||e.status===`PROCESSED`)&&i.set(a,{status:`PENDING`})}})}),[{componentIds:f,variant:`plain`,label:d},{componentIds:h,variant:`regular`,label:m},{componentIds:v,variant:`regular`,label:_},{componentIds:o,variant:`plain`,label:a}].forEach(({componentIds:n,label:r,variant:a})=>{let o=n[0];e.ui.registerComponent(n,({builder:{Button:n},engine:s})=>{if(!e.feature.isEnabled(b,{engine:s}))return;let[c]=s.block.findAllSelected();if(!e.engine.block.isAllowedByScope(c,`fill/change`))return;let l=i.get(c),u=l.status===`PROCESSING`,d=l.status===`PENDING`||l.status===`PROCESSING`||s.block.getState(c)?.type===`Pending`,f;if(u&&l.progress){let{current:e,total:t}=l.progress;f=e/t*100}n(`${o}.button`,{icon:t.icon,label:r,variant:a,isLoading:u,isDisabled:d,loadingProgress:f,onClick:()=>{(l.status===`IDLE`||l.status===`ERROR`||l.status===`PROCESSED`)&&i.set(c,{status:`PENDING`})}})})}),{canvasMenuComponentId:s,dockComponentId:u,translationsKeys:{inspectorBarLabel:d,navigationBarLabel:m,canvasBarLabel:_,canvasMenuLabel:a,dockLabel:c}}}var ur=typeof global==`object`&&global&&global.Object===Object&&global,dr=typeof self==`object`&&self&&self.Object===Object&&self,fr=ur||dr||Function(`return this`)(),q=fr.Symbol,pr=Object.prototype,mr=pr.hasOwnProperty,hr=pr.toString,J=q?q.toStringTag:void 0;function gr(e){var t=mr.call(e,J),n=e[J];try{e[J]=void 0;var r=!0}catch{}var i=hr.call(e);return r&&(t?e[J]=n:delete e[J]),i}var _r=Object.prototype.toString;function vr(e){return _r.call(e)}var yr=`[object Null]`,br=`[object Undefined]`,Y=q?q.toStringTag:void 0;function xr(e){return e==null?e===void 0?br:yr:Y&&Y in Object(e)?gr(e):vr(e)}function Sr(e){return typeof e==`object`&&!!e}var Cr=`[object Symbol]`;function wr(e){return typeof e==`symbol`||Sr(e)&&xr(e)==Cr}var Tr=/\s/;function Er(e){for(var t=e.length;t--&&Tr.test(e.charAt(t)););return t}var Dr=/^\s+/;function Or(e){return e&&e.slice(0,Er(e)+1).replace(Dr,``)}function X(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var kr=NaN,Ar=/^[-+]0x[0-9a-f]+$/i,jr=/^0b[01]+$/i,Mr=/^0o[0-7]+$/i,Nr=parseInt;function Pr(e){if(typeof e==`number`)return e;if(wr(e))return kr;if(X(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=X(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Or(e);var n=jr.test(e);return n||Mr.test(e)?Nr(e.slice(2),n?2:8):Ar.test(e)?kr:+e}var Z=function(){return fr.Date.now()},Fr=`Expected a function`,Ir=Math.max,Lr=Math.min;function Rr(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Fr);t=Pr(t)||0,X(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Ir(Pr(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?Lr(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Z();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Z())}function x(){var e=Z(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}var zr=`Expected a function`;function Br(e,t,n){var r=!0,i=!0;if(typeof e!=`function`)throw TypeError(zr);return X(n)&&(r=`leading`in n?!!n.leading:r,i=`trailing`in n?!!n.trailing:i),Rr(e,t,{leading:r,maxWait:t,trailing:i})}function Vr(e,t=1024){if(e.length===0)return;let[n,r]=e.reduce((e,n)=>(n.width>=t&&n.height>=t?e[0].push(n):e[1].push(n),e),[[],[]]);return n.length>0?n.sort((e,t)=>e.width*e.height-t.width*t.height)[0]:r.sort((e,t)=>t.width*t.height-e.width*e.height)[0]}async function Hr(e,t,n){let r=new URL(t).pathname.split(`/`),i=r[r.length-1],a=(await n.unstable_upload(new File([e],i,{type:e.type}),()=>{})).meta?.uri;if(a==null)throw Error(`Could not upload processed fill`);return a}async function Ur(t,r,i,a,o){return Yn(t,r,i,{processFill:o??(async t=>{let i=t.initialSourceSet,o=Vr(i);if(o==null)throw Error(`No source found`);let s=await Q(o.uri,r),c=await n(s,a);return await Promise.all(i.map(async t=>{let n=await Hr(await e(await Q(t.uri,r),c,a),t.uri,r);return{...t,uri:n}}))}),commitProcessing:(e,t)=>{let n=t.fillId;r.engine.block.setSourceSet(n,`fill/image/sourceSet`,e);let i=[...e].sort((e,t)=>e.width*e.height-t.width*t.height)[0];i!=null&&r.engine.block.setString(n,`fill/image/previewFileURI`,i.uri)}},`1.87.0-nightly.20261104`)}async function Wr(e,n,r,i,a){return Yn(e,n,r,{processFill:a??(async e=>{let r=e.initialImageFileURI;return await Hr(await t(await Q(r,n),i),r,n)}),commitProcessing:(e,t)=>{let r=t.fillId;n.engine.block.setString(r,`fill/image/imageFileURI`,e),n.engine.block.setString(r,`fill/image/previewFileURI`,``)}},`1.87.0-nightly.20261104`)}async function Q(e,t){if(e.startsWith(`buffer:`)){let n=await t.engine.editor.getMimeType(e),r=t.engine.editor.getBufferLength(e),i=t.engine.editor.getBufferData(e,0,r),a=new Uint8Array(i);return new Blob([a],{type:n})}return e}async function Gr(){if(typeof navigator>`u`)return!1;let e=navigator.gpu;if(e==null)return!1;try{let t=await e.requestAdapter();return t!=null&&t.features.has(`shader-f16`)}catch{return!1}}async function Kr(e,t,n,r){let i=e.engine.block;if(!i.hasFill(t))throw Error(`Block does not support fill`);let a=i.getFill(t),o=i.getSourceSet(a,`fill/image/sourceSet`),s=i.getString(a,`fill/image/imageFileURI`);if(o.length===0&&s===``)throw Error(`No source or image file URI found`);switch(r.type){case`@imgly/background-removal`:{let i=r.configuration??{},a={device:i.device??(await Gr()?`gpu`:`cpu`),...i,progress:Br((e,r,a)=>{let o=n.get(t);o.status===`PROCESSING`&&n.isConsistent(t)&&(i.progress?.(e,r,a),n.set(t,{...o,progress:{key:e,current:r,total:a}}))},100)};o.length>0?Ur(t,e,n,a):Wr(t,e,n,a);break}case`custom`:o.length>0?Ur(t,e,n,void 0,e=>r.processSourceSet(e.initialSourceSet)):Wr(t,e,n,void 0,e=>r.processImageFileURI(e.initialImageFileURI));break;default:throw Error(`Unknown background removal provider`)}}const $=`@imgly/plugin-background-removal-web`;var qr=(e={})=>({initialize({cesdk:t}){if(t==null)return;Jr(t),sr(t,{pluginId:$,process:(n,r)=>{Kr(t,n,r,e.provider??{type:`@imgly/background-removal`})}});let{translationsKeys:n}=lr(t,{pluginId:$,icon:`@imgly/icons/BGRemove`,locations:e.ui?.locations});t.setTranslations({en:{[n.inspectorBarLabel]:`BG Removal`,[n.navigationBarLabel]:`BG Removal`,[n.canvasBarLabel]:`BG Removal`,[n.canvasMenuLabel]:`BG Removal`,[n.dockLabel]:`BG Removal`}})}});function Jr(e){e.ui.addIconSet(`@imgly/plugin/background-removal`,`
|
|
2
2
|
<svg>
|
|
3
3
|
<symbol
|
|
4
4
|
fill="none"
|
|
@@ -17,31 +17,14 @@ var Ct=class{constructor(e,t){this.engine=e,this.key=t}hasData(e){return this.en
|
|
|
17
17
|
<path d="M13.4317 13.1374C14.3663 12.6292 15.0007 11.6387 15.0007 10.5C15.0007 8.84315 13.6576 7.5 12.0007 7.5C10.3439 7.5 9.00074 8.84315 9.00074 10.5C9.00074 11.6387 9.63515 12.6292 10.5698 13.1374C9.94563 13.2733 9.38367 13.4801 8.9164 13.6917C7.98874 14.112 7.54792 15.1133 7.62602 16.1287L8.00074 21.0005H16.0007L16.3755 16.1287C16.4536 15.1133 16.0128 14.112 15.0851 13.6917C14.6178 13.4801 14.0559 13.2733 13.4317 13.1374Z" fill="currentColor"/>
|
|
18
18
|
</symbol>
|
|
19
19
|
</svg>
|
|
20
|
-
`)}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
lodash
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
32
|
-
*)
|
|
33
|
-
*/
|
|
34
|
-
/*! Bundled license information:
|
|
35
|
-
|
|
36
|
-
lodash-es/lodash.js:
|
|
37
|
-
(**
|
|
38
|
-
* @license
|
|
39
|
-
* Lodash (Custom Build) <https://lodash.com/>
|
|
40
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
41
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
42
|
-
* Released under MIT license <https://lodash.com/license>
|
|
43
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
44
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
45
|
-
*)
|
|
46
|
-
*/
|
|
47
|
-
//# sourceMappingURL=index.mjs.map
|
|
20
|
+
`)}const Yr=e=>({name:$,version:`1.87.0-nightly.20261104`,...qr(e)});export{Yr as default};
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
24
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
25
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
26
|
+
* Released under MIT license <https://lodash.com/license>
|
|
27
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
28
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
29
|
+
*/
|
|
30
|
+
//# sourceMappingURL=index.mjs.map
|