@imgly/plugin-ai-image-generation-web 1.72.0-rc.1 → 1.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/bytedance/index.mjs +2 -2
- package/dist/bytedance/index.mjs.map +4 -4
- package/dist/eachlabs/index.mjs +3 -3
- package/dist/eachlabs/index.mjs.map +4 -4
- package/dist/fal-ai/index.mjs.map +4 -4
- package/dist/gateway/GatewayProvider.d.ts +32 -0
- package/dist/gateway/index.d.ts +9 -0
- package/dist/gateway/index.mjs +144 -0
- package/dist/gateway/index.mjs.map +7 -0
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +4 -4
- package/dist/open-ai/index.mjs +3 -3
- package/dist/open-ai/index.mjs.map +4 -4
- package/dist/runware/index.mjs +2 -2
- package/dist/runware/index.mjs.map +4 -4
- package/package.json +7 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
2
|
+
import { type Provider, type ImageOutput, type QuickActionsInput, type GatewayProviderConfiguration, type GatewayInput } from '@imgly/plugin-ai-generation-web';
|
|
3
|
+
/**
|
|
4
|
+
* Default quick actions for image-to-image gateway models.
|
|
5
|
+
*
|
|
6
|
+
* Maps the standard quick-action input (`uri`, `prompt`, `style`, `artist`)
|
|
7
|
+
* to the gateway convention (`image_urls`, `prompt`).
|
|
8
|
+
*
|
|
9
|
+
* Pass this as `quickActions` when creating an i2i `GatewayProvider`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const IMAGE_I2I_QUICK_ACTIONS: QuickActionsInput<GatewayInput>;
|
|
12
|
+
export interface GatewayImageProviderOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Quick actions supported by this provider.
|
|
15
|
+
*
|
|
16
|
+
* For image-to-image models, use the exported `IMAGE_I2I_QUICK_ACTIONS`
|
|
17
|
+
* constant which maps the standard quick-action input to `image_urls`.
|
|
18
|
+
*/
|
|
19
|
+
quickActions?: QuickActionsInput<GatewayInput>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates an image generation provider that talks to the IMG.LY gateway.
|
|
23
|
+
* Supports both text2image and image2image depending on the model's schema.
|
|
24
|
+
*
|
|
25
|
+
* @param modelId - The model identifier (e.g., 'fal-ai/flux/dev')
|
|
26
|
+
* @param modelName - Human-readable model name (e.g., 'FLUX Dev')
|
|
27
|
+
* @param config - Gateway connection configuration
|
|
28
|
+
* @param options - Image-specific provider options (e.g., quick actions)
|
|
29
|
+
*/
|
|
30
|
+
export declare function GatewayProvider(modelId: string, config: GatewayProviderConfiguration, options?: GatewayImageProviderOptions): (context: {
|
|
31
|
+
cesdk: CreativeEditorSDK;
|
|
32
|
+
}) => Promise<Provider<'image', GatewayInput, ImageOutput>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GatewayProvider, IMAGE_I2I_QUICK_ACTIONS } from './GatewayProvider';
|
|
2
|
+
declare const Gateway: {
|
|
3
|
+
GatewayProvider: typeof GatewayProvider;
|
|
4
|
+
IMAGE_I2I_QUICK_ACTIONS: import("@imgly/plugin-ai-generation-web").QuickActionsInput<import("@imgly/plugin-ai-generation-web").GatewayInput>;
|
|
5
|
+
};
|
|
6
|
+
export default Gateway;
|
|
7
|
+
export { GatewayProvider, IMAGE_I2I_QUICK_ACTIONS };
|
|
8
|
+
export type { GatewayImageProviderOptions } from './GatewayProvider';
|
|
9
|
+
export type { GatewayProviderConfiguration } from '@imgly/plugin-ai-generation-web';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var It=class{constructor(e,t=[],r){this.id=e,this.translateLabel=r?.translateLabel,this.assets=t.map(i=>{if(typeof i.label=="string"&&!(i.label&&typeof i.label=="object")){let n=i;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return i}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(e){let{page:t,perPage:r,locale:i="en",sortActiveFirst:n,query:s,tags:a,groups:u,excludeGroups:g,sortingOrder:d,sortKey:l}=e,o=[...this.assets];if(u&&u.length>0&&(o=o.filter(f=>f.groups&&u.some(h=>f.groups?.includes(h)))),g&&g.length>0&&(o=o.filter(f=>!f.groups||!g.some(h=>f.groups?.includes(h)))),s){let f=s.toLowerCase();o=o.filter(h=>{let b=h.label?.[i]?.toLowerCase(),w=h.tags?.[i]||[];return b&&b.includes(f)||w.some(kt=>kt.toLowerCase().includes(f))})}if(a&&a.length>0){let f=Array.isArray(a)?a:[a];o=o.filter(h=>{let b=h.tags?.[i]||[];return f.some(w=>b.includes(w))})}n&&o.sort((f,h)=>{let b=this.activeAssetIds.has(f.id),w=this.activeAssetIds.has(h.id);return b&&!w?-1:!b&&w?1:0}),l&&l!=="id"?o.sort((f,h)=>{let b=f.meta?.[l],w=h.meta?.[l];return b===void 0?1:w===void 0?-1:typeof b=="string"&&typeof w=="string"?d==="Descending"?w.localeCompare(b):b.localeCompare(w):typeof b=="number"&&typeof w=="number"?d==="Descending"?w-b:b-w:0}):l==="id"&&o.sort((f,h)=>d==="Descending"?h.id.localeCompare(f.id):f.id.localeCompare(h.id));let c=o.length,p=t*r,v=p+r,k=o.slice(p,v).map(f=>{let h=f.label?.[i]||"",b=this.translateLabel?this.translateLabel(f.id,h,i):h;return{id:f.id,groups:f.groups,meta:f.meta,payload:f.payload,locale:i,label:b,tags:f.tags?.[i],active:this.activeAssetIds.has(f.id)}}),S=v<c?t+1:void 0;return{assets:k,currentPage:t,nextPage:S,total:c}}updateLabel(e,t,r){this.assets.forEach(i=>{i.id===e&&(i.label=i.label||{},i.label[r]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:r})=>r===e);if(t){let r=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:r,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:r})=>r===e[0]);if(t){let r=this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||"";return{id:t.id,label:r,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:r})=>r===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||"",""):t.label?.en||""}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(r=>r.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(r=>r.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(r=>e.add(r))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var At=typeof global=="object"&&global&&global.Object===Object&&global,De=At,St=typeof self=="object"&&self&&self.Object===Object&&self,Ct=De||St||Function("return this")(),I=Ct,xt=I.Symbol,M=xt,ze=Object.prototype,Et=ze.hasOwnProperty,Mt=ze.toString,R=M?M.toStringTag:void 0;function jt(e){var t=Et.call(e,R),r=e[R];try{e[R]=void 0;var i=!0}catch{}var n=Mt.call(e);return i&&(t?e[R]=r:delete e[R]),n}var $t=jt,_t=Object.prototype,Tt=_t.toString;function Lt(e){return Tt.call(e)}var Pt=Lt,Ot="[object Null]",Nt="[object Undefined]",ke=M?M.toStringTag:void 0;function Dt(e){return e==null?e===void 0?Nt:Ot:ke&&ke in Object(e)?$t(e):Pt(e)}var B=Dt;function zt(e){return e!=null&&typeof e=="object"}var pe=zt,qs=Array.isArray;function Rt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Re=Rt,Ft="[object AsyncFunction]",Ut="[object Function]",Vt="[object GeneratorFunction]",Bt="[object Proxy]";function Gt(e){if(!Re(e))return!1;var t=B(e);return t==Ut||t==Vt||t==Ft||t==Bt}var Ht=Gt,qt=I["__core-js_shared__"],ie=qt,Ie=function(){var e=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Kt(e){return!!Ie&&Ie in e}var Zt=Kt,Yt=Function.prototype,Qt=Yt.toString;function Wt(e){if(e!=null){try{return Qt.call(e)}catch{}try{return e+""}catch{}}return""}var C=Wt,Jt=/[\\^$.*+?()[\]{}|]/g,Xt=/^\[object .+?Constructor\]$/,er=Function.prototype,tr=Object.prototype,rr=er.toString,ir=tr.hasOwnProperty,nr=RegExp("^"+rr.call(ir).replace(Jt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ar(e){if(!Re(e)||Zt(e))return!1;var t=Ht(e)?nr:Xt;return t.test(C(e))}var or=ar;function sr(e,t){return e?.[t]}var lr=sr;function ur(e,t){var r=lr(e,t);return or(r)?r:void 0}var j=ur,cr=j(I,"WeakMap"),oe=cr;function dr(e,t){return e===t||e!==e&&t!==t}var pr=dr,gr=9007199254740991;function fr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=gr}var mr=fr,Ks=Object.prototype,yr="[object Arguments]";function hr(e){return pe(e)&&B(e)==yr}var Ae=hr,Fe=Object.prototype,br=Fe.hasOwnProperty,vr=Fe.propertyIsEnumerable,Zs=Ae(function(){return arguments}())?Ae:function(e){return pe(e)&&br.call(e,"callee")&&!vr.call(e,"callee")},Ue=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=Ue&&typeof module=="object"&&module&&!module.nodeType&&module,wr=Se&&Se.exports===Ue,Ce=wr?I.Buffer:void 0,Ys=Ce?Ce.isBuffer:void 0,kr="[object Arguments]",Ir="[object Array]",Ar="[object Boolean]",Sr="[object Date]",Cr="[object Error]",xr="[object Function]",Er="[object Map]",Mr="[object Number]",jr="[object Object]",$r="[object RegExp]",_r="[object Set]",Tr="[object String]",Lr="[object WeakMap]",Pr="[object ArrayBuffer]",Or="[object DataView]",Nr="[object Float32Array]",Dr="[object Float64Array]",zr="[object Int8Array]",Rr="[object Int16Array]",Fr="[object Int32Array]",Ur="[object Uint8Array]",Vr="[object Uint8ClampedArray]",Br="[object Uint16Array]",Gr="[object Uint32Array]",m={};m[Nr]=m[Dr]=m[zr]=m[Rr]=m[Fr]=m[Ur]=m[Vr]=m[Br]=m[Gr]=!0;m[kr]=m[Ir]=m[Pr]=m[Ar]=m[Or]=m[Sr]=m[Cr]=m[xr]=m[Er]=m[Mr]=m[jr]=m[$r]=m[_r]=m[Tr]=m[Lr]=!1;function Hr(e){return pe(e)&&mr(e.length)&&!!m[B(e)]}var qr=Hr;function Kr(e){return function(t){return e(t)}}var Zr=Kr,Ve=typeof exports=="object"&&exports&&!exports.nodeType&&exports,F=Ve&&typeof module=="object"&&module&&!module.nodeType&&module,Yr=F&&F.exports===Ve,ne=Yr&&De.process,Qr=function(){try{var e=F&&F.require&&F.require("util").types;return e||ne&&ne.binding&&ne.binding("util")}catch{}}(),xe=Qr,Ee=xe&&xe.isTypedArray,Qs=Ee?Zr(Ee):qr,Wr=Object.prototype,Ws=Wr.hasOwnProperty;function Jr(e,t){return function(r){return e(t(r))}}var Xr=Jr,Js=Xr(Object.keys,Object),ei=Object.prototype,Xs=ei.hasOwnProperty,ti=j(Object,"create"),U=ti;function ri(){this.__data__=U?U(null):{},this.size=0}var ii=ri;function ni(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ai=ni,oi="__lodash_hash_undefined__",si=Object.prototype,li=si.hasOwnProperty;function ui(e){var t=this.__data__;if(U){var r=t[e];return r===oi?void 0:r}return li.call(t,e)?t[e]:void 0}var ci=ui,di=Object.prototype,pi=di.hasOwnProperty;function gi(e){var t=this.__data__;return U?t[e]!==void 0:pi.call(t,e)}var fi=gi,mi="__lodash_hash_undefined__";function yi(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=U&&t===void 0?mi:t,this}var hi=yi;function $(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}$.prototype.clear=ii;$.prototype.delete=ai;$.prototype.get=ci;$.prototype.has=fi;$.prototype.set=hi;var Me=$;function bi(){this.__data__=[],this.size=0}var vi=bi;function wi(e,t){for(var r=e.length;r--;)if(pr(e[r][0],t))return r;return-1}var W=wi,ki=Array.prototype,Ii=ki.splice;function Ai(e){var t=this.__data__,r=W(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Ii.call(t,r,1),--this.size,!0}var Si=Ai;function Ci(e){var t=this.__data__,r=W(t,e);return r<0?void 0:t[r][1]}var xi=Ci;function Ei(e){return W(this.__data__,e)>-1}var Mi=Ei;function ji(e,t){var r=this.__data__,i=W(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var $i=ji;function _(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}_.prototype.clear=vi;_.prototype.delete=Si;_.prototype.get=xi;_.prototype.has=Mi;_.prototype.set=$i;var J=_,_i=j(I,"Map"),V=_i;function Ti(){this.size=0,this.__data__={hash:new Me,map:new(V||J),string:new Me}}var Li=Ti;function Pi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Oi=Pi;function Ni(e,t){var r=e.__data__;return Oi(t)?r[typeof t=="string"?"string":"hash"]:r.map}var X=Ni;function Di(e){var t=X(this,e).delete(e);return this.size-=t?1:0,t}var zi=Di;function Ri(e){return X(this,e).get(e)}var Fi=Ri;function Ui(e){return X(this,e).has(e)}var Vi=Ui;function Bi(e,t){var r=X(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var Gi=Bi;function T(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}T.prototype.clear=Li;T.prototype.delete=zi;T.prototype.get=Fi;T.prototype.has=Vi;T.prototype.set=Gi;var Be=T;function Hi(){this.__data__=new J,this.size=0}var qi=Hi;function Ki(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Zi=Ki;function Yi(e){return this.__data__.get(e)}var Qi=Yi;function Wi(e){return this.__data__.has(e)}var Ji=Wi,Xi=200;function en(e,t){var r=this.__data__;if(r instanceof J){var i=r.__data__;if(!V||i.length<Xi-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new Be(i)}return r.set(e,t),this.size=r.size,this}var tn=en;function G(e){var t=this.__data__=new J(e);this.size=t.size}G.prototype.clear=qi;G.prototype.delete=Zi;G.prototype.get=Qi;G.prototype.has=Ji;G.prototype.set=tn;var rn=Object.prototype,el=rn.propertyIsEnumerable,nn=j(I,"DataView"),se=nn,an=j(I,"Promise"),le=an,on=j(I,"Set"),ue=on,je="[object Map]",sn="[object Object]",$e="[object Promise]",_e="[object Set]",Te="[object WeakMap]",Le="[object DataView]",ln=C(se),un=C(V),cn=C(le),dn=C(ue),pn=C(oe),E=B;(se&&E(new se(new ArrayBuffer(1)))!=Le||V&&E(new V)!=je||le&&E(le.resolve())!=$e||ue&&E(new ue)!=_e||oe&&E(new oe)!=Te)&&(E=function(e){var t=B(e),r=t==sn?e.constructor:void 0,i=r?C(r):"";if(i)switch(i){case ln:return Le;case un:return je;case cn:return $e;case dn:return _e;case pn:return Te}return t});var tl=I.Uint8Array,gn="__lodash_hash_undefined__";function fn(e){return this.__data__.set(e,gn),this}var mn=fn;function yn(e){return this.__data__.has(e)}var hn=yn;function ce(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Be;++t<r;)this.add(e[t])}ce.prototype.add=ce.prototype.push=mn;ce.prototype.has=hn;var Pe=M?M.prototype:void 0,rl=Pe?Pe.valueOf:void 0,bn=Object.prototype,il=bn.hasOwnProperty,vn=Object.prototype,nl=vn.hasOwnProperty,al=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),ol=new RegExp(/[A-Fa-f0-9]{1}/,"g"),sl=new RegExp(/[A-Fa-f0-9]{2}/,"g");function wn(e){return e!==void 0}var kn=wn;function In(e){return e?.version?e.version.localeCompare("1.59.0",void 0,{numeric:!0,sensitivity:"base"})>=0&&typeof e.i18n?.translate=="function":!1}function An(e){return typeof e?.translate=="function"}function Oe(e,t,r){return e&&In(e)&&An(e.i18n)?e.i18n.translate(t):r}function Ge(e,t){if(typeof e.i18n?.getTranslations!="function"){e.i18n.setTranslations(t);return}let r=Object.keys(t),i=e.i18n.getTranslations(r),n={};for(let s of r){let a=t[s];if(!a)continue;let u=i[s]??{},g={};for(let[d,l]of Object.entries(a))!(d in u)&&l!==void 0&&(g[d]=l);Object.keys(g).length>0&&(n[s]=g)}Object.keys(n).length>0&&e.i18n.setTranslations(n)}function Sn(e,t){let{cesdk:r}=t,i=t.propertyKey??"image_url",n=de(e);return Ge(r,{en:{[`panel.${n}`]:"Select Image To Change","ly.img.ai.imageSelection.selectImage.label":"Select Image","ly.img.ai.imageSelection.error.svg":"SVG images are not supported. Please choose a different image.","ly.img.ai.imageSelection.error.invalidType":"Only images are supported. Found '{mimeType}'. Please choose a different image."}}),Cn(e,r),{[i]:(s,a)=>{let{builder:u,experimental:{global:g},payload:d}=s,l,o=s.providerConfig,c=s.config,p=o?.properties?.[a.id]??c?.properties?.[a.id];p?.default&&(typeof p.default=="function"?l=p.default({}):l=p.default);let v=l??d?.url??t.defaultUrl,k=g(`${e}.${a.id}`,v);return u.MediaPreview(a.id,{preview:{type:"image",uri:k.value},action:{label:"ly.img.ai.imageSelection.selectImage.label",onClick:()=>{r?.ui.openPanel(n,{payload:{onSelect:S=>{S.meta?.uri!=null&&k.setValue(S.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:k.value})}}}function Cn(e,t){t?.ui.registerPanel(de(e),({builder:r,payload:i})=>{r.Library(`${e}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let s=n?.meta?.uri;if(s==null)return;let a=await t.engine.editor.getMimeType(s);a==="image/svg+xml"?t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.svg"}):a.startsWith("image/")?(i?.onSelect(n),t?.ui.closePanel(de(e))):t.ui.showNotification({type:"warning",message:"ly.img.ai.imageSelection.error.invalidType"})}})})}function de(e){return`ly.img.ai.${e}.imageSelection`}var xn=Sn;function En(e,t){let{cesdk:r}=t;if(r==null)return{};let i=t.propertyKey??"style",n=jn(e);Ge(r,{en:{[`panel.${n}`]:"Select Style",[`${e}.${i}`]:"Style","ly.img.ai.styleTransfer.none":"None","ly.img.ai.styleTransfer.anime":"Anime","ly.img.ai.styleTransfer.cyberpunk":"Cyberpunk","ly.img.ai.styleTransfer.kodak400":"Kodak 400","ly.img.ai.styleTransfer.watercolor":"Watercolor","ly.img.ai.styleTransfer.darkFantasy":"Dark Fantasy","ly.img.ai.styleTransfer.vaporwave":"Vaporwave","ly.img.ai.styleTransfer.vectorFlat":"Vector Flat","ly.img.ai.styleTransfer.3dAnimation":"3D Animation","ly.img.ai.styleTransfer.ukiyoe":"Ukiyo\u2011e","ly.img.ai.styleTransfer.surreal":"Surreal","ly.img.ai.styleTransfer.steampunk":"Steampunk","ly.img.ai.styleTransfer.nightBokeh":"Night Bokeh","ly.img.ai.styleTransfer.popArt":"Pop Art"}});let s=_n({baseURL:t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0,cesdk:r}),a=s;t.styles!=null&&(Array.isArray(t.styles)?a=t.styles:typeof t.styles=="function"&&(a=t.styles(s)));let u=Tn({cesdk:r,providerId:e,styles:a}),g=u.id;return Ln(u,{cesdk:r}),Mn({providerId:e,cesdk:r,panelId:n,entryId:g}),{[t.propertyKeyForPrompt??"prompt"]:(d,l)=>{let o=d.state("prompt","");return d.builder.TextArea(`${l.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??"prompt",placeholder:t.i18n?.prompt?.placeholder,...o}),()=>{let[c]=u.getActiveAssetIds(),p=u.getAsset(c);return{id:l.id,type:"string",value:p?.meta?.prompt==null?o.value:`${o.value}; ${p.meta.prompt}`}}},[i]:(d,l)=>{let{builder:o,state:c}=d;if(a.length>0){let p=c("style",a[0]);return o.Button(`${l.id}`,{inputLabel:`${e}.${l.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let v={onSelect:async k=>{u.clearActiveAssets(),u.setAssetActive(k.id),p.setValue({id:k.id,label:k.label??k.id}),r.ui.closePanel(n)}};r.ui.openPanel(n,{payload:v})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function Mn(e){let{providerId:t,cesdk:r,panelId:i,entryId:n}=e;r?.ui.registerPanel(i,({builder:s,payload:a})=>{a?.onSelect==null&&s.Section(`${t}.error`,{children:()=>{s.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),s.Library(`${t}.library.image`,{entries:[n],onSelect:async u=>{a?.onSelect?.(u)}})})}function jn(e){return`ly.img.ai.${e}.styleSelection`}var $n=[{id:"none",labelKey:"ly.img.ai.styleTransfer.none",prompt:""},{id:"anime-celshaded",labelKey:"ly.img.ai.styleTransfer.anime",prompt:"anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art "},{id:"cyberpunk-neon",labelKey:"ly.img.ai.styleTransfer.cyberpunk",prompt:"cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere"},{id:"kodak-portra-400",labelKey:"ly.img.ai.styleTransfer.kodak400",prompt:"shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo"},{id:"watercolor-storybook",labelKey:"ly.img.ai.styleTransfer.watercolor",prompt:"loose watercolor washes, gentle gradients, dreamy storybook feel"},{id:"dark-fantasy-realism",labelKey:"ly.img.ai.styleTransfer.darkFantasy",prompt:"dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures"},{id:"vaporwave-retrofuturism",labelKey:"ly.img.ai.styleTransfer.vaporwave",prompt:"retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines"},{id:"minimal-vector-flat",labelKey:"ly.img.ai.styleTransfer.vectorFlat",prompt:"minimalist flat vector illustration, bold geometry, two\u2011tone palette"},{id:"pixarstyle-3d-render",labelKey:"ly.img.ai.styleTransfer.3dAnimation",prompt:"Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting"},{id:"ukiyoe-woodblock",labelKey:"ly.img.ai.styleTransfer.ukiyoe",prompt:"ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink"},{id:"surreal-dreamscape",labelKey:"ly.img.ai.styleTransfer.surreal",prompt:"surreal dreamscape, floating objects, impossible architecture, vivid clouds"},{id:"steampunk-victorian",labelKey:"ly.img.ai.styleTransfer.steampunk",prompt:"Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog"},{id:"nightstreet-photo-bokeh",labelKey:"ly.img.ai.styleTransfer.nightBokeh",prompt:"night\u2011time street shot, large aperture bokeh lights, candid urban mood"},{id:"comicbook-pop-art",labelKey:"ly.img.ai.styleTransfer.popArt",prompt:"classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors"}];function _n(e){return $n.map(t=>t.id==="none"?e.includeNone?{id:t.id,label:Oe(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/None.svg`}:void 0:{id:t.id,label:Oe(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/${t.id}.jpeg`}).filter(kn)}var Tn=e=>{let t=e.styles.map(a=>({...a,meta:{prompt:a.prompt}})),r=e.cesdk.engine.asset.findAllSources(),i=`${e.providerId}/styles`;for(;r.includes(i);)i+=`-${Math.random().toString(36).substring(2,5)}`;let n=new It(i,t),s=e.styles[0];return n.setAssetActive(s.id),n},Ln=(e,t)=>{t.cesdk.engine.asset.addSource(e),t.cesdk.ui.addAssetLibraryEntry({id:e.id,sourceIds:[e.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:r})=>r,cardLabelPosition:()=>"below"})},Pn=En;function He(e,t,r){let i=`${t}.iconSetAdded`;e.ui.experimental.hasGlobalStateValue(i)||(e.ui.addIconSet(t,r),e.ui.experimental.setGlobalStateValue(i,!0))}function qe(e,t){let r={...e};if(!t)return r;for(let[i,n]of Object.entries(t))n===!1||n===null||n===void 0?delete r[i]:n===!0?i in e||(r[i]=!0):r[i]=n;return r}var ae="@imgly/plugin-ai-generation",ll=`
|
|
2
|
+
<svg>
|
|
3
|
+
<symbol
|
|
4
|
+
fill="none"
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
id="@imgly/Sparkle"
|
|
8
|
+
>
|
|
9
|
+
<path d="M5.35545 2.06745C5.24149 1.72556 4.7579 1.72556 4.64394 2.06745L4.05898 3.82232C4.02166 3.93429 3.9338 4.02215 3.82184 4.05948L2.06694 4.64459C1.72506 4.75858 1.72509 5.24217 2.06699 5.3561L3.82179 5.9409C3.93378 5.97822 4.02166 6.06609 4.05899 6.17808L4.64394 7.93291C4.7579 8.2748 5.24149 8.2748 5.35545 7.93291L5.9404 6.17806C5.97773 6.06608 6.06559 5.97821 6.17757 5.94089L7.93242 5.35594C8.27431 5.24198 8.27431 4.75839 7.93242 4.64442L6.17757 4.05947C6.06559 4.02215 5.97773 3.93428 5.9404 3.8223L5.35545 2.06745Z" fill="currentColor"/>
|
|
10
|
+
<path d="M17.9632 3.23614C17.8026 2.80788 17.1968 2.80788 17.0362 3.23614L16.0787 5.78951C16.0285 5.92337 15.9229 6.02899 15.789 6.07918L13.2356 7.0367C12.8074 7.19729 12.8074 7.80307 13.2356 7.96366L15.789 8.92118C15.9229 8.97138 16.0285 9.077 16.0787 9.21085L17.0362 11.7642C17.1968 12.1925 17.8026 12.1925 17.9632 11.7642L18.9207 9.21086C18.9709 9.077 19.0765 8.97138 19.2104 8.92118L21.7637 7.96366C22.192 7.80307 22.192 7.1973 21.7637 7.0367L19.2104 6.07918C19.0765 6.02899 18.9709 5.92337 18.9207 5.78951L17.9632 3.23614Z" fill="currentColor"/>
|
|
11
|
+
<path d="M9.30058 7.82012C9.54712 7.1791 10.454 7.1791 10.7006 7.82012L12.3809 12.189C12.4571 12.3871 12.6136 12.5436 12.8117 12.6198L17.1806 14.3001C17.8216 14.5466 17.8216 15.4536 17.1806 15.7001L12.8117 17.3804C12.6136 17.4566 12.4571 17.6131 12.3809 17.8112L10.7006 22.1801C10.454 22.8211 9.54712 22.8211 9.30058 22.1801L7.62024 17.8112C7.54406 17.6131 7.38754 17.4566 7.18947 17.3804L2.82061 15.7001C2.17959 15.4536 2.17959 14.5466 2.82061 14.3001L7.18947 12.6198C7.38754 12.5436 7.54406 12.3871 7.62024 12.189L9.30058 7.82012Z" fill="currentColor"/>
|
|
12
|
+
|
|
13
|
+
</symbol>
|
|
14
|
+
|
|
15
|
+
<symbol
|
|
16
|
+
fill="none"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
viewBox="0 0 24 24"
|
|
19
|
+
id="${ae}/image"
|
|
20
|
+
>
|
|
21
|
+
<path d="M3 16.5V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V6C21 4.34315 19.6569 3 18 3L17.999 5C18.5513 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V16.5H3Z" fill="currentColor"/>
|
|
22
|
+
<path d="M13.0982 0.884877C12.9734 0.568323 12.5254 0.568322 12.4005 0.884876L11.7485 2.53819C11.7104 2.63483 11.6339 2.71134 11.5372 2.74945L9.8839 3.40151C9.56735 3.52636 9.56734 3.97436 9.8839 4.09921L11.5372 4.75126C11.6339 4.78938 11.7104 4.86588 11.7485 4.96253L12.4005 6.61584C12.5254 6.93239 12.9734 6.9324 13.0982 6.61584L13.7503 4.96253C13.7884 4.86588 13.8649 4.78938 13.9616 4.75126L15.6149 4.09921C15.9314 3.97436 15.9314 3.52636 15.6149 3.40151L13.9616 2.74945C13.8649 2.71134 13.7884 2.63483 13.7503 2.53819L13.0982 0.884877Z" fill="currentColor"/>
|
|
23
|
+
<path d="M6.40053 5.38488C6.52538 5.06832 6.97338 5.06832 7.09823 5.38488L8.17455 8.11392C8.21267 8.21057 8.28917 8.28707 8.38582 8.32519L11.1149 9.40151C11.4314 9.52636 11.4314 9.97436 11.1149 10.0992L8.38582 11.1755C8.28917 11.2136 8.21267 11.2901 8.17455 11.3868L7.09823 14.1158C6.97338 14.4324 6.52538 14.4324 6.40053 14.1158L5.32421 11.3868C5.2861 11.2901 5.20959 11.2136 5.11295 11.1755L2.3839 10.0992C2.06735 9.97436 2.06735 9.52636 2.3839 9.40151L5.11295 8.32519C5.20959 8.28707 5.2861 8.21057 5.32421 8.11392L6.40053 5.38488Z" fill="currentColor"/>
|
|
24
|
+
<path d="M18.9994 16.5008V18.0004C18.9994 18.5526 18.5517 19.0004 17.9994 19.0004H9.33302L14.3753 11.4369C14.6722 10.9916 15.3266 10.9916 15.6234 11.4369L18.9994 16.5008Z" fill="currentColor"/>
|
|
25
|
+
|
|
26
|
+
</symbol>
|
|
27
|
+
<symbol
|
|
28
|
+
fill="none"
|
|
29
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
30
|
+
viewBox="0 0 24 24"
|
|
31
|
+
id="${ae}/video"
|
|
32
|
+
>
|
|
33
|
+
<path d="M6 3C4.34315 3 3 4.34315 3 6V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V16.5H19V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5V3Z" fill="currentColor"/>
|
|
34
|
+
<path d="M10.9025 0.8839C11.0273 0.567345 11.4753 0.567346 11.6002 0.883901L12.2522 2.53721C12.2904 2.63386 12.3669 2.71036 12.4635 2.74848L14.1168 3.40053C14.4334 3.52538 14.4334 3.97338 14.1168 4.09823L12.4635 4.75029C12.3669 4.7884 12.2904 4.86491 12.2522 4.96155L11.6002 6.61486C11.4753 6.93142 11.0273 6.93142 10.9025 6.61486L10.2504 4.96155C10.2123 4.86491 10.1358 4.7884 10.0392 4.75029L8.38585 4.09823C8.0693 3.97338 8.0693 3.52538 8.38585 3.40053L10.0392 2.74848C10.1358 2.71036 10.2123 2.63386 10.2504 2.53721L10.9025 0.8839Z" fill="currentColor"/>
|
|
35
|
+
<path d="M18.9019 3.3845C19.0267 3.06795 19.4747 3.06795 19.5996 3.3845L20.6759 6.11355C20.714 6.2102 20.7905 6.2867 20.8872 6.32482L23.6162 7.40114C23.9328 7.52598 23.9328 7.97399 23.6162 8.09883L20.8872 9.17515C20.7905 9.21327 20.714 9.28977 20.6759 9.38642L19.5996 12.1155C19.4747 12.432 19.0267 12.432 18.9019 12.1155L17.8255 9.38642C17.7874 9.28977 17.7109 9.21327 17.6143 9.17515L14.8852 8.09883C14.5687 7.97399 14.5687 7.52598 14.8852 7.40114L17.6143 6.32482C17.7109 6.2867 17.7874 6.2102 17.8255 6.11355L18.9019 3.3845Z" fill="currentColor"/>
|
|
36
|
+
<path d="M14.9994 13.2862C15.5089 12.8859 15.5089 12.1141 14.9995 11.7137L10.618 8.27047C9.96188 7.75485 9.00011 8.22225 9.00011 9.05673L9.00011 15.9429C9.00011 16.7773 9.96185 17.2448 10.618 16.7292L14.9994 13.2862Z" fill="currentColor"/>
|
|
37
|
+
</symbol>
|
|
38
|
+
<symbol
|
|
39
|
+
fill="none"
|
|
40
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
41
|
+
viewBox="0 0 24 24"
|
|
42
|
+
id="${ae}/audio"
|
|
43
|
+
>
|
|
44
|
+
<path d="M6 3.80273C4.2066 4.84016 3 6.77919 3 9.00004V12.8153C3 15.931 5.39501 18.4873 8.44444 18.7436V20.9645C8.44444 22.2198 9.89427 22.9198 10.8773 22.1392L15.1265 18.7647H15.5C17.8285 18.7647 19.8472 17.4384 20.8417 15.5H18.4187C17.6889 16.2784 16.6512 16.7647 15.5 16.7647H14.9522C14.6134 16.7647 14.2846 16.8794 14.0193 17.0901L10.4444 19.929V18.2597C10.4444 17.4341 9.77513 16.7647 8.9495 16.7647C7.80494 16.7647 6.77409 16.2779 6.05276 15.5H6V15.4419C5.37798 14.7439 5 13.8237 5 12.8153V9.00004C5 7.98559 5.37764 7.05935 6 6.35422V3.80273Z" fill="currentColor"/>
|
|
45
|
+
<path d="M11.6002 1.8839C11.4753 1.56735 11.0273 1.56735 10.9025 1.8839L10.2504 3.53721C10.2123 3.63386 10.1358 3.71036 10.0392 3.74848L8.38585 4.40053C8.0693 4.52538 8.0693 4.97338 8.38585 5.09823L10.0392 5.75029C10.1358 5.7884 10.2123 5.86491 10.2504 5.96155L10.9025 7.61486C11.0273 7.93142 11.4753 7.93142 11.6002 7.61486L12.2522 5.96155C12.2904 5.86491 12.3669 5.7884 12.4635 5.75029L14.1168 5.09823C14.4334 4.97338 14.4334 4.52538 14.1168 4.40053L12.4635 3.74848C12.3669 3.71036 12.2904 3.63386 12.2522 3.53721L11.6002 1.8839Z" fill="currentColor"/>
|
|
46
|
+
<path d="M19.5996 4.3845C19.4747 4.06795 19.0267 4.06795 18.9019 4.3845L17.8255 7.11355C17.7874 7.2102 17.7109 7.2867 17.6143 7.32482L14.8852 8.40114C14.5687 8.52598 14.5687 8.97399 14.8852 9.09883L17.6143 10.1752C17.7109 10.2133 17.7874 10.2898 17.8255 10.3864L18.9019 13.1155C19.0267 13.432 19.4747 13.432 19.5996 13.1155L20.6759 10.3864C20.714 10.2898 20.7905 10.2133 20.8872 10.1752L23.6162 9.09883C23.9328 8.97399 23.9328 8.52598 23.6162 8.40114L20.8872 7.32482C20.7905 7.2867 20.714 7.2102 20.6759 7.11355L19.5996 4.3845Z" fill="currentColor"/>
|
|
47
|
+
</symbol>
|
|
48
|
+
<symbol
|
|
49
|
+
fill="none"
|
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
51
|
+
viewBox="0 0 24 24"
|
|
52
|
+
id="@imgly/MixingPlate"
|
|
53
|
+
>
|
|
54
|
+
<path d="M9.75 9C10.5784 9 11.25 8.32843 11.25 7.5C11.25 6.67157 10.5784 6 9.75 6C8.92157 6 8.25 6.67157 8.25 7.5C8.25 8.32843 8.92157 9 9.75 9Z" fill="currentColor"/>
|
|
55
|
+
<path d="M7 13C7.82843 13 8.5 12.3284 8.5 11.5C8.5 10.6716 7.82843 10 7 10C6.17157 10 5.5 10.6716 5.5 11.5C5.5 12.3284 6.17157 13 7 13Z" fill="currentColor"/>
|
|
56
|
+
<path d="M15.75 7.5C15.75 8.32843 15.0784 9 14.25 9C13.4216 9 12.75 8.32843 12.75 7.5C12.75 6.67157 13.4216 6 14.25 6C15.0784 6 15.75 6.67157 15.75 7.5Z" fill="currentColor"/>
|
|
57
|
+
<path d="M17 13C17.8284 13 18.5 12.3284 18.5 11.5C18.5 10.6716 17.8284 10 17 10C16.1716 10 15.5 10.6716 15.5 11.5C15.5 12.3284 16.1716 13 17 13Z" fill="currentColor"/>
|
|
58
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.26309 2.77709C10.6681 1.77921 13.4829 1.7322 15.9209 2.64297C18.1572 3.47923 20.0876 5.09285 21.1766 7.28598C22.3395 9.62772 22.4889 13.1077 20.3864 15.2982C19.2693 16.4621 17.7657 16.9982 16.0026 16.9997C15.7897 16.9997 15.5555 16.9864 15.3497 16.9745C15.309 16.9722 15.2694 16.9699 15.2313 16.9679C14.9817 16.9542 14.761 16.9455 14.5569 16.9539C14.124 16.9718 13.9598 17.0612 13.89 17.1324C13.718 17.3081 13.6946 17.6672 13.8854 17.8895C14.2899 18.3608 14.5016 18.9277 14.5016 19.5497C14.5016 20.2206 14.3086 20.9011 13.7542 21.3896C13.2471 21.837 12.6082 21.9997 11.9635 21.9997C10.6049 21.9997 9.31155 21.7367 8.0934 21.2067C6.89058 20.6831 5.84501 19.9687 4.94363 19.0666C4.04281 18.1651 3.31836 17.107 2.79369 15.8978C1.72761 13.4409 1.72662 10.5261 2.81247 8.07034C3.88024 5.65548 5.84206 3.78161 8.26309 2.77709ZM15.2207 4.51639C13.2556 3.78239 10.9651 3.82132 9.02956 4.62439C7.06888 5.43791 5.49559 6.94785 4.64163 8.87914C3.78373 10.8194 3.78253 13.1522 4.62841 15.1017C5.05312 16.0805 5.63511 16.9291 6.35838 17.6529C7.08102 18.3761 7.91671 18.9484 8.89123 19.3728C9.8492 19.7895 10.87 19.9997 11.9635 19.9997C12.2815 19.9997 12.394 19.9225 12.431 19.8899L12.4319 19.8891C12.4367 19.8849 12.4487 19.8743 12.4631 19.8359C12.4799 19.7911 12.5016 19.7024 12.5016 19.5497C12.5016 19.4091 12.4633 19.3034 12.3677 19.192C11.5353 18.222 11.5272 16.6868 12.4611 15.7331C13.0741 15.1071 13.8844 14.98 14.4745 14.9556C14.7819 14.943 15.085 14.9568 15.3409 14.9709C15.3906 14.9736 15.4379 14.9763 15.4832 14.9788C15.6876 14.9904 15.8508 14.9997 16.0009 14.9997C17.3405 14.9986 18.2792 14.6054 18.9435 13.9133C20.2633 12.5382 20.3186 10.055 19.3853 8.1755C18.5436 6.48051 17.0293 5.19281 15.2207 4.51639Z" fill="currentColor"/>
|
|
59
|
+
|
|
60
|
+
</symbol>
|
|
61
|
+
</svg>
|
|
62
|
+
`;function On(e,t,r,i=3e5){let n=e.replace(/\/$/,""),s=null,a=null;async function u(){return s!=null&&Date.now()<s.expiresAt?s.value:(a!=null||(a=t().then(d=>(s={value:d,expiresAt:Date.now()+i},d)).finally(()=>{a=null})),a)}async function g(d,l){let o=async()=>{let p=await u();return fetch(d,{...l,headers:{...l.headers,Authorization:`Bearer ${p}`,...r??{}}})},c=await o();return c.status===401?(s=null,o()):c}return{async fetchSchema(d){let l=await g(`${n}/v1/models/schema?model=${encodeURIComponent(d)}`,{method:"GET",headers:{Accept:"application/json"}});if(!l.ok){let o=await l.text();throw new Error(`Gateway schema error: ${l.status} - ${o}`)}return await l.json()},async upload(d,l){let o=await g(`${n}/v1/uploads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content_type:l})});if(!o.ok){let v=await o.text();throw new Error(`Gateway upload error: ${o.status} - ${v}`)}let c=await o.json(),p=await fetch(c.upload_url,{method:"PUT",headers:{"Content-Type":l},body:d});if(!p.ok){let v=await p.text();throw new Error(`Presigned upload error: ${p.status} - ${v}`)}return c},async generate(d,l,o){let c=await g(`${n}/v1/responses`,{method:"POST",signal:o.abortSignal,headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:d,...l})});if(!c.ok){let p=await c.text();throw new Error(`Gateway generation error: ${c.status} - ${p}`)}return Nn(c,o.abortSignal,o.outputFilter)},async*generateStream(d,l,o){let c=await g(`${n}/v1/responses`,{method:"POST",signal:o.abortSignal,headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:d,...l})});if(!c.ok){let p=await c.text();throw new Error(`Gateway generation error: ${c.status} - ${p}`)}return yield*Dn(c,o.abortSignal)}}}async function Nn(e,t,r){let i=e.body?.getReader();if(!i)throw new Error("Response body is not readable");let n=new TextDecoder,s="",a="";try{for(;;){if(t?.aborted)throw new Error("Generation aborted");let{done:u,value:g}=await i.read();if(u)break;s+=n.decode(g,{stream:!0});let d=s.split(`
|
|
63
|
+
`);s=d.pop()??"";for(let l of d){let o=l.trim();if(!(o===""||o.startsWith(":"))){if(o.startsWith("event:")){a=o.slice(6).trim();continue}if(o.startsWith("data:")){let c=o.slice(5).trim();if(a==="generation.completed"){let p=JSON.parse(c),v=r?p.output?.find(r):p.output?.[0];if(v?.url)return v.url;throw new Error("Gateway response did not include a matching output")}if(a==="generation.failed"){let p=JSON.parse(c);throw new Error(p.error?.message??"Generation failed")}a=""}}}}}finally{i.releaseLock()}throw new Error("SSE stream ended without a completion event")}async function*Dn(e,t){let r=e.body?.getReader();if(!r)throw new Error("Response body is not readable");let i=new TextDecoder,n="",s="",a="";try{for(;;){if(t?.aborted)throw new Error("Generation aborted");let{done:u,value:g}=await r.read();if(u)break;n+=i.decode(g,{stream:!0});let d=n.split(`
|
|
64
|
+
`);n=d.pop()??"";for(let l of d){let o=l.trim();if(!(o===""||o.startsWith(":"))){if(o.startsWith("event:")){s=o.slice(6).trim();continue}if(o.startsWith("data:")){let c=o.slice(5).trim();if(s==="generation.delta"){let p=JSON.parse(c);p.contentType==="text"&&(a+=p.data,yield a)}if(s==="generation.completed")return a;if(s==="generation.failed"){let p=JSON.parse(c);throw new Error(p.error?.message??"Generation failed")}s=""}}}}}finally{r.releaseLock()}if(a.length>0)return a;throw new Error("SSE stream ended without content")}var zn="https://gateway.img.ly",Rn="ly.img.ai.getToken",Ne=new WeakMap;function Fn(e,t){let r=Ne.get(e);r==null&&(r=new Map,Ne.set(e,r));let i=t.gatewayUrl??zn,n=t.tokenActionId??Rn,s=`${i}\0${n}`,a=r.get(s);return a!=null||(a=On(i,async()=>{let u=await e.actions.run(n);if(typeof u=="string"){if(u.startsWith("sk_"))throw new Error(`The token action '${n}' returned a raw API key. Exposing API keys in client-side code is a security risk. If this is intentional, return { dangerouslyExposeApiKey: 'sk_...' } instead.`);if(u.length===0)throw new Error(`Action '${n}' returned an empty token string`);return u}if(u!=null&&typeof u=="object"&&"dangerouslyExposeApiKey"in u){let g=u.dangerouslyExposeApiKey;if(typeof g!="string"||g.length===0)throw new Error(`Action '${n}' returned { dangerouslyExposeApiKey } but the value is not a valid string`);return g}throw new Error(`Action '${n}' must return either a token string or { dangerouslyExposeApiKey: string }`)},t.headers,t.tokenCacheTTL),r.set(s,a)),a}function Ke(e,t,r){return async({cesdk:i})=>{r.onInitialize?.(i);let n=Fn(i,t),s=`gateway/${e}`,a=r.createOutput!=null,u;if(a){let d=n.fetchSchema(e),l=()=>d.then(c=>Un(e,c)),o;d.then(c=>{o=r.onSchemaReady?.({schema:c,providerId:s,cesdk:i})}).catch(c=>{let p=c instanceof Error?c:new Error(String(c));t.onError?.(p)}),u={type:"schema",document:l,inputReference:"#/components/schemas/GatewayInput",includeHistoryLibrary:!0,orderExtensionKeyword:"x-property-order",get renderCustomProperty(){return o},getBlockInput:r.getBlockInput,userFlow:r.userFlow??"placeholder"}}let g={id:s,kind:r.kind,name:t.modelName??e,input:{...u!=null?{panel:u}:{},quickActions:r.quickActions},output:{abortable:!0,history:t.history??"@imgly/indexedDB",generate:async(d,{abortSignal:l})=>{let o=r.processInput?await r.processInput(d,n,i):d;if(r.createStreamOutput!=null){let{createStreamOutput:p}=r,v=n.generateStream(e,o,{abortSignal:l});async function*k(){let S;for await(let f of v)S=p(f),yield S;return S}return k()}let c=await n.generate(e,o,{abortSignal:l,outputFilter:r.outputFilter});return await r.createOutput(c)}}};return t.debug&&console.log("Created Gateway Provider:",g),g}}function Un(e,t){let r=JSON.stringify(t.input_schema).includes("#/components/schemas/CustomSize");return{openapi:"3.0.0",info:{title:`Gateway - ${e}`,version:"1.0.0"},paths:{},components:{schemas:{GatewayInput:t.input_schema,...r?{CustomSize:{title:"Custom",type:"object",properties:{width:{type:"integer",minimum:1,default:1024},height:{type:"integer",minimum:1,default:1024}}}}:{}}}}}var Ze={ImageUrl:xn,StyleTransfer:Pn};var Vn=`
|
|
65
|
+
<svg>
|
|
66
|
+
<symbol
|
|
67
|
+
fill="none"
|
|
68
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
id="@imgly/plugin/formats/ratioFree"
|
|
71
|
+
>
|
|
72
|
+
<path d="M7 6C6.44772 6 6 6.44772 6 7V9.22222H4V7C4 5.34315 5.34315 4 7 4H9.22222V6H7Z" fill="currentColor"/>
|
|
73
|
+
<path d="M17 6H14.7778V4H17C18.6569 4 20 5.34315 20 7V9.22222H18V7C18 6.44772 17.5523 6 17 6Z" fill="currentColor"/>
|
|
74
|
+
<path d="M6 14.7778V17C6 17.5523 6.44772 18 7 18H9.22222V20H7C5.34315 20 4 18.6569 4 17V14.7778H6Z" fill="currentColor"/>
|
|
75
|
+
<path d="M18 17V14.7778H20V17C20 18.6569 18.6569 20 17 20H14.7778V18H17C17.5523 18 18 17.5523 18 17Z" fill="currentColor"/>
|
|
76
|
+
</symbol>
|
|
77
|
+
<symbol
|
|
78
|
+
fill="none"
|
|
79
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
80
|
+
viewBox="0 0 24 24"
|
|
81
|
+
id="@imgly/plugin/formats/ratio4by3"
|
|
82
|
+
>
|
|
83
|
+
<path d="M6.5 13H8V15H10V16.5H6.5V13Z" fill="currentColor"/>
|
|
84
|
+
<path d="M14 9V7.5H17.5V11H16V9H14Z" fill="currentColor"/>
|
|
85
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M6 4C4.34315 4 3 5.34315 3 7V17C3 18.6569 4.34315 20 6 20H18C19.6569 20 21 18.6569 21 17V7C21 5.34315 19.6569 4 18 4H6ZM5 7C5 6.44772 5.44772 6 6 6H18C18.5523 6 19 6.44772 19 7V17C19 17.5523 18.5523 18 18 18H6C5.44772 18 5 17.5523 5 17V7Z" fill="currentColor"/>
|
|
86
|
+
</symbol>
|
|
87
|
+
<symbol
|
|
88
|
+
fill="none"
|
|
89
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
90
|
+
viewBox="0 0 24 24"
|
|
91
|
+
id="@imgly/plugin/formats/ratio16by9"
|
|
92
|
+
>
|
|
93
|
+
<path d="M4.5 13H6V15H8V16.5H4.5V13Z" fill="currentColor"/>
|
|
94
|
+
<path d="M16 9V7.5H19.5V11H18V9H16Z" fill="currentColor"/>
|
|
95
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 4C2.34315 4 1 5.34315 1 7V17C1 18.6569 2.34315 20 4 20H20C21.6569 20 23 18.6569 23 17V7C23 5.34315 21.6569 4 20 4H4ZM3 7C3 6.44772 3.44772 6 4 6H20C20.5523 6 21 6.44772 21 7V17C21 17.5523 20.5523 18 20 18H4C3.44772 18 3 17.5523 3 17V7Z" fill="currentColor"/>
|
|
96
|
+
</symbol>
|
|
97
|
+
<symbol
|
|
98
|
+
fill="none"
|
|
99
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
100
|
+
viewBox="0 0 24 24"
|
|
101
|
+
id="@imgly/plugin/formats/ratio9by16"
|
|
102
|
+
>
|
|
103
|
+
<path d="M7.5 16H9V18H11V19.5H7.5V16Z" fill="currentColor"/>
|
|
104
|
+
<path d="M13 6V4.5H16.5V8H15V6H13Z" fill="currentColor"/>
|
|
105
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 20C4 21.6569 5.34315 23 7 23H17C18.6569 23 20 21.6569 20 20V4C20 2.34315 18.6569 1 17 1H7C5.34315 1 4 2.34315 4 4V20ZM7 21C6.44772 21 6 20.5523 6 20V4C6 3.44772 6.44772 3 7 3H17C17.5523 3 18 3.44772 18 4V20C18 20.5523 17.5523 21 17 21H7Z" fill="currentColor"/>
|
|
106
|
+
</symbol>
|
|
107
|
+
<symbol
|
|
108
|
+
fill="none"
|
|
109
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
110
|
+
viewBox="0 0 24 24"
|
|
111
|
+
id="@imgly/plugin/formats/ratio3by4"
|
|
112
|
+
>
|
|
113
|
+
<path d="M11 17.5V16H9V14H7.5V17.5H11Z" fill="currentColor"/>
|
|
114
|
+
<path d="M15 10H16.5V6.5H13V8H15V10Z" fill="currentColor"/>
|
|
115
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M20 18C20 19.6569 18.6569 21 17 21H7C5.34315 21 4 19.6569 4 18V6C4 4.34315 5.34315 3 7 3H17C18.6569 3 20 4.34315 20 6V18ZM17 19C17.5523 19 18 18.5523 18 18V6C18 5.44772 17.5523 5 17 5H7C6.44771 5 6 5.44771 6 6V18C6 18.5523 6.44772 19 7 19H17Z" fill="currentColor"/>
|
|
116
|
+
</symbol>
|
|
117
|
+
<symbol
|
|
118
|
+
fill="none"
|
|
119
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
120
|
+
viewBox="0 0 24 24"
|
|
121
|
+
id="@imgly/plugin/formats/ratio1by1"
|
|
122
|
+
>
|
|
123
|
+
<path d="M17.4142 8.00009L16 6.58587L14.2929 8.29298L15.7071 9.70719L17.4142 8.00009Z" fill="currentColor"/>
|
|
124
|
+
<path d="M13.0404 12.3739L15.0404 10.3739L13.6262 8.95965L11.6262 10.9596L13.0404 12.3739Z" fill="currentColor"/>
|
|
125
|
+
<path d="M10.3737 15.0405L12.3737 13.0405L10.9595 11.6263L8.95953 13.6263L10.3737 15.0405Z" fill="currentColor"/>
|
|
126
|
+
<path d="M9.70708 15.7072L8.29286 14.293L6.58576 16.0001L7.99997 17.4143L9.70708 15.7072Z" fill="currentColor"/>
|
|
127
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z" fill="currentColor"/>
|
|
128
|
+
</symbol>
|
|
129
|
+
</svg>
|
|
130
|
+
`;var Bn=typeof global=="object"&&global&&global.Object===Object&&global,ut=Bn,Gn=typeof self=="object"&&self&&self.Object===Object&&self,Hn=ut||Gn||Function("return this")(),A=Hn,qn=A.Symbol,P=qn,ct=Object.prototype,Kn=ct.hasOwnProperty,Zn=ct.toString,H=P?P.toStringTag:void 0;function Yn(e){var t=Kn.call(e,H),r=e[H];try{e[H]=void 0;var i=!0}catch{}var n=Zn.call(e);return i&&(t?e[H]=r:delete e[H]),n}var Qn=Yn,Wn=Object.prototype,Jn=Wn.toString;function Xn(e){return Jn.call(e)}var ea=Xn,ta="[object Null]",ra="[object Undefined]",Ye=P?P.toStringTag:void 0;function ia(e){return e==null?e===void 0?ra:ta:Ye&&Ye in Object(e)?Qn(e):ea(e)}var Y=ia;function na(e){return e!=null&&typeof e=="object"}var we=na,dl=Array.isArray;function aa(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var dt=aa,oa="[object AsyncFunction]",sa="[object Function]",la="[object GeneratorFunction]",ua="[object Proxy]";function ca(e){if(!dt(e))return!1;var t=Y(e);return t==sa||t==la||t==oa||t==ua}var da=ca,pa=A["__core-js_shared__"],ge=pa,Qe=function(){var e=/[^.]+$/.exec(ge&&ge.keys&&ge.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ga(e){return!!Qe&&Qe in e}var fa=ga,ma=Function.prototype,ya=ma.toString;function ha(e){if(e!=null){try{return ya.call(e)}catch{}try{return e+""}catch{}}return""}var x=ha,ba=/[\\^$.*+?()[\]{}|]/g,va=/^\[object .+?Constructor\]$/,wa=Function.prototype,ka=Object.prototype,Ia=wa.toString,Aa=ka.hasOwnProperty,Sa=RegExp("^"+Ia.call(Aa).replace(ba,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ca(e){if(!dt(e)||fa(e))return!1;var t=da(e)?Sa:va;return t.test(x(e))}var xa=Ca;function Ea(e,t){return e?.[t]}var Ma=Ea;function ja(e,t){var r=Ma(e,t);return xa(r)?r:void 0}var O=ja,$a=O(A,"WeakMap"),me=$a;function _a(e,t){return e===t||e!==e&&t!==t}var Ta=_a,La=9007199254740991;function Pa(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=La}var Oa=Pa;var pl=Object.prototype;var Na="[object Arguments]";function Da(e){return we(e)&&Y(e)==Na}var We=Da,pt=Object.prototype,za=pt.hasOwnProperty,Ra=pt.propertyIsEnumerable,gl=We(function(){return arguments}())?We:function(e){return we(e)&&za.call(e,"callee")&&!Ra.call(e,"callee")};var gt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Je=gt&&typeof module=="object"&&module&&!module.nodeType&&module,Fa=Je&&Je.exports===gt,Xe=Fa?A.Buffer:void 0,fl=Xe?Xe.isBuffer:void 0;var Ua="[object Arguments]",Va="[object Array]",Ba="[object Boolean]",Ga="[object Date]",Ha="[object Error]",qa="[object Function]",Ka="[object Map]",Za="[object Number]",Ya="[object Object]",Qa="[object RegExp]",Wa="[object Set]",Ja="[object String]",Xa="[object WeakMap]",eo="[object ArrayBuffer]",to="[object DataView]",ro="[object Float32Array]",io="[object Float64Array]",no="[object Int8Array]",ao="[object Int16Array]",oo="[object Int32Array]",so="[object Uint8Array]",lo="[object Uint8ClampedArray]",uo="[object Uint16Array]",co="[object Uint32Array]",y={};y[ro]=y[io]=y[no]=y[ao]=y[oo]=y[so]=y[lo]=y[uo]=y[co]=!0;y[Ua]=y[Va]=y[eo]=y[Ba]=y[to]=y[Ga]=y[Ha]=y[qa]=y[Ka]=y[Za]=y[Ya]=y[Qa]=y[Wa]=y[Ja]=y[Xa]=!1;function po(e){return we(e)&&Oa(e.length)&&!!y[Y(e)]}var go=po;function fo(e){return function(t){return e(t)}}var mo=fo,ft=typeof exports=="object"&&exports&&!exports.nodeType&&exports,q=ft&&typeof module=="object"&&module&&!module.nodeType&&module,yo=q&&q.exports===ft,fe=yo&&ut.process,ho=function(){try{var e=q&&q.require&&q.require("util").types;return e||fe&&fe.binding&&fe.binding("util")}catch{}}(),et=ho,tt=et&&et.isTypedArray,ml=tt?mo(tt):go;var bo=Object.prototype,yl=bo.hasOwnProperty;function vo(e,t){return function(r){return e(t(r))}}var wo=vo,hl=wo(Object.keys,Object);var ko=Object.prototype,bl=ko.hasOwnProperty;var Io=O(Object,"create"),K=Io;function Ao(){this.__data__=K?K(null):{},this.size=0}var So=Ao;function Co(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var xo=Co,Eo="__lodash_hash_undefined__",Mo=Object.prototype,jo=Mo.hasOwnProperty;function $o(e){var t=this.__data__;if(K){var r=t[e];return r===Eo?void 0:r}return jo.call(t,e)?t[e]:void 0}var _o=$o,To=Object.prototype,Lo=To.hasOwnProperty;function Po(e){var t=this.__data__;return K?t[e]!==void 0:Lo.call(t,e)}var Oo=Po,No="__lodash_hash_undefined__";function Do(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=K&&t===void 0?No:t,this}var zo=Do;function N(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}N.prototype.clear=So;N.prototype.delete=xo;N.prototype.get=_o;N.prototype.has=Oo;N.prototype.set=zo;var rt=N;function Ro(){this.__data__=[],this.size=0}var Fo=Ro;function Uo(e,t){for(var r=e.length;r--;)if(Ta(e[r][0],t))return r;return-1}var ee=Uo,Vo=Array.prototype,Bo=Vo.splice;function Go(e){var t=this.__data__,r=ee(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Bo.call(t,r,1),--this.size,!0}var Ho=Go;function qo(e){var t=this.__data__,r=ee(t,e);return r<0?void 0:t[r][1]}var Ko=qo;function Zo(e){return ee(this.__data__,e)>-1}var Yo=Zo;function Qo(e,t){var r=this.__data__,i=ee(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var Wo=Qo;function D(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}D.prototype.clear=Fo;D.prototype.delete=Ho;D.prototype.get=Ko;D.prototype.has=Yo;D.prototype.set=Wo;var te=D,Jo=O(A,"Map"),Z=Jo;function Xo(){this.size=0,this.__data__={hash:new rt,map:new(Z||te),string:new rt}}var es=Xo;function ts(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var rs=ts;function is(e,t){var r=e.__data__;return rs(t)?r[typeof t=="string"?"string":"hash"]:r.map}var re=is;function ns(e){var t=re(this,e).delete(e);return this.size-=t?1:0,t}var as=ns;function os(e){return re(this,e).get(e)}var ss=os;function ls(e){return re(this,e).has(e)}var us=ls;function cs(e,t){var r=re(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var ds=cs;function z(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}z.prototype.clear=es;z.prototype.delete=as;z.prototype.get=ss;z.prototype.has=us;z.prototype.set=ds;var mt=z;function ps(){this.__data__=new te,this.size=0}var gs=ps;function fs(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var ms=fs;function ys(e){return this.__data__.get(e)}var hs=ys;function bs(e){return this.__data__.has(e)}var vs=bs,ws=200;function ks(e,t){var r=this.__data__;if(r instanceof te){var i=r.__data__;if(!Z||i.length<ws-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new mt(i)}return r.set(e,t),this.size=r.size,this}var Is=ks;function Q(e){var t=this.__data__=new te(e);this.size=t.size}Q.prototype.clear=gs;Q.prototype.delete=ms;Q.prototype.get=hs;Q.prototype.has=vs;Q.prototype.set=Is;var As=Object.prototype,vl=As.propertyIsEnumerable;var Ss=O(A,"DataView"),ye=Ss,Cs=O(A,"Promise"),he=Cs,xs=O(A,"Set"),be=xs,it="[object Map]",Es="[object Object]",nt="[object Promise]",at="[object Set]",ot="[object WeakMap]",st="[object DataView]",Ms=x(ye),js=x(Z),$s=x(he),_s=x(be),Ts=x(me),L=Y;(ye&&L(new ye(new ArrayBuffer(1)))!=st||Z&&L(new Z)!=it||he&&L(he.resolve())!=nt||be&&L(new be)!=at||me&&L(new me)!=ot)&&(L=function(e){var t=Y(e),r=t==Es?e.constructor:void 0,i=r?x(r):"";if(i)switch(i){case Ms:return st;case js:return it;case $s:return nt;case _s:return at;case Ts:return ot}return t});var wl=A.Uint8Array;var Ls="__lodash_hash_undefined__";function Ps(e){return this.__data__.set(e,Ls),this}var Os=Ps;function Ns(e){return this.__data__.has(e)}var Ds=Ns;function ve(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new mt;++t<r;)this.add(e[t])}ve.prototype.add=ve.prototype.push=Os;ve.prototype.has=Ds;var lt=P?P.prototype:void 0,kl=lt?lt.valueOf:void 0;var zs=Object.prototype,Il=zs.hasOwnProperty;var Rs=Object.prototype,Al=Rs.hasOwnProperty;var Sl=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Cl=new RegExp(/[A-Fa-f0-9]{1}/,"g"),xl=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function Fs(e,t){if(e.startsWith("buffer:")){let r=await t.editor.getMimeType(e),i=t.editor.getBufferLength(e),n=t.editor.getBufferData(e,0,i),s=new Uint8Array(n),a=new Blob([s],{type:r});return URL.createObjectURL(a)}else return e}async function yt(e,t){let r=await Fs(e,t);return new Promise((i,n)=>{let s=new Image;s.onload=()=>{i({width:s.width,height:s.height})},s.onerror=n,s.src=r})}var ht={Formats:Vn};var vt={supported:{"ly.img.editImage":{mapInput:e=>({prompt:e.prompt,image_urls:[e.uri]})},"ly.img.swapBackground":{mapInput:e=>({prompt:e.prompt,image_urls:[e.uri]})},"ly.img.createVariant":{mapInput:e=>({prompt:e.prompt,image_urls:[e.uri]})},"ly.img.styleTransfer":{mapInput:e=>({prompt:e.style,image_urls:[e.uri]})},"ly.img.artistTransfer":{mapInput:e=>({prompt:e.artist,image_urls:[e.uri]})},"ly.img.combineImages":{mapInput:e=>({prompt:e.prompt,image_urls:e.uris})},"ly.img.remixPage":{mapInput:e=>({prompt:e.prompt,image_urls:[e.uri]})},"ly.img.remixPageWithPrompt":{mapInput:e=>({prompt:e.prompt,image_urls:[e.uri]})}}};function wt(e,t,r){return async({cesdk:i})=>{let n=!1;return Ke(e,t,{kind:"image",onInitialize:a=>{He(a,"@imgly/plugin/formats",ht.Formats)},onSchemaReady:({schema:a,providerId:u,cesdk:g})=>{if(n=Us(a),n)return Ze.ImageUrl(u,{cesdk:g,propertyKey:"image_urls"})},processInput:(a,u,g)=>Vs(a,u,g),createOutput:a=>({kind:"image",url:a}),getBlockInput:async a=>{let u=a.image_urls,g=typeof u=="string"?u:Array.isArray(u)?u[0]:void 0;if(typeof g=="string"){let{width:l,height:o}=await yt(g,i.engine);return{image:{width:l,height:o}}}return{image:Bs(a)}},outputFilter:a=>a.content_type?.startsWith("image/")||a.type==="image_url",quickActions:r?.quickActions?{supported:qe(r.quickActions.supported??{})}:void 0,userFlow:"placeholder"})({cesdk:i})}}function Us(e){return"image_urls"in e.input_schema.properties}async function Vs(e,t,r){let i={...e};return typeof i.image_urls=="string"?i.image_urls=[await bt(i.image_urls,t,r)]:Array.isArray(i.image_urls)&&(i.image_urls=await Promise.all(i.image_urls.map(n=>bt(n,t,r)))),i}async function bt(e,t,r){if(e.startsWith("blob:")){let i=await r.engine.editor.getMimeType(e),s=await(await fetch(e)).blob();return(await t.upload(s,i)).asset_url}if(e.startsWith("buffer:")){let i=await r.engine.editor.getMimeType(e),n=r.engine.editor.getBufferLength(e),s=r.engine.editor.getBufferData(e,0,n),a=new Blob([new Uint8Array(s)],{type:i});return(await t.upload(a,i)).asset_url}return e}function Bs(e){let t={width:1024,height:1024},r=e.format;return r==null?t:typeof r=="object"&&r.width&&r.height?{width:r.width,height:r.height}:typeof r=="string"?Gs[r]??t:t}var Gs={"1:1":{width:1024,height:1024},"16:9":{width:1344,height:768},"9:16":{width:768,height:1344},"4:3":{width:1152,height:896},"3:4":{width:896,height:1152},"3:2":{width:1216,height:832},"2:3":{width:832,height:1216}};var Hs={GatewayProvider:wt,IMAGE_I2I_QUICK_ACTIONS:vt},Tl=Hs;export{wt as GatewayProvider,vt as IMAGE_I2I_QUICK_ACTIONS,Tl as default};
|
|
131
|
+
/*! Bundled license information:
|
|
132
|
+
|
|
133
|
+
lodash-es/lodash.js:
|
|
134
|
+
(**
|
|
135
|
+
* @license
|
|
136
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
137
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
138
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
139
|
+
* Released under MIT license <https://lodash.com/license>
|
|
140
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
141
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
142
|
+
*)
|
|
143
|
+
*/
|
|
144
|
+
//# sourceMappingURL=index.mjs.map
|