@imgly/plugin-ai-sticker-generation-web 0.2.3 → 0.2.5
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/CHANGELOG.md +24 -0
- package/README.md +4 -0
- package/dist/fal-ai/createFalClient.d.ts +3 -0
- package/dist/fal-ai/createStickerProvider.d.ts +10 -0
- package/dist/fal-ai/index.mjs +9 -9
- package/dist/fal-ai/index.mjs.map +4 -4
- package/dist/fal-ai/utils.d.ts +2 -1
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +4 -4
- package/package.json +1 -1
package/dist/fal-ai/utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
2
|
+
import { FalClient } from './createFalClient';
|
|
2
3
|
type CustomImageSize = {
|
|
3
4
|
width: number;
|
|
4
5
|
height: number;
|
|
5
6
|
};
|
|
6
7
|
export declare function isCustomImageSize(imageSize: any): imageSize is CustomImageSize;
|
|
7
|
-
export declare function uploadImageInputToFalIfNeeded(imageUrl?: string, cesdk?: CreativeEditorSDK): Promise<string | undefined>;
|
|
8
|
+
export declare function uploadImageInputToFalIfNeeded(client: FalClient, imageUrl?: string, cesdk?: CreativeEditorSDK): Promise<string | undefined>;
|
|
8
9
|
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Zt=class{constructor(e,t,r){this.assetStoreName="assets",this.blobStoreName="blobs",this.db=null,this.id=e,this.engine=t,this.dbName=r?.dbName??`ly.img.assetSource/${e}`,this.dbVersion=r?.dbVersion??1}async initialize(){if(!this.db)return new Promise((e,t)=>{let r=indexedDB.open(this.dbName,this.dbVersion);r.onerror=i=>{t(new Error(`Failed to open IndexedDB: ${i.target.error}`))},r.onupgradeneeded=i=>{let n=i.target.result;n.objectStoreNames.contains(this.assetStoreName)||n.createObjectStore(this.assetStoreName,{keyPath:"id"}),n.objectStoreNames.contains(this.blobStoreName)||n.createObjectStore(this.blobStoreName,{keyPath:"id"})},r.onsuccess=i=>{this.db=i.target.result,e()}})}close(){this.db&&(this.db.close(),this.db=null)}async findAssets(e){if(await this.initialize(),!this.db)throw new Error("Database not initialized");try{let t=(await this.getAllAssets("asc")).reduce((u,l)=>{let c=e.locale??"en",d="",g=[];l.label!=null&&typeof l.label=="object"&&l.label[c]&&(d=l.label[c]),l.tags!=null&&typeof l.tags=="object"&&l.tags[c]&&(g=l.tags[c]);let p={...l,label:d,tags:g};return this.filterAsset(p,e)&&u.push(p),u},[]);t=await this.restoreBlobUrls(t),t=this.sortAssets(t,e);let{page:r,perPage:i}=e,n=r*i,o=n+i,a=t.slice(n,o),s=o<t.length?r+1:void 0;return{assets:a,currentPage:r,nextPage:s,total:t.length}}catch(t){console.error("Error finding assets:",t);return}}async getGroups(){if(await this.initialize(),!this.db)throw new Error("Database not initialized");return new Promise((e,t)=>{let r=this.db.transaction(this.assetStoreName,"readonly").objectStore(this.assetStoreName).getAll();r.onsuccess=()=>{let i=new Set;r.result.forEach(o=>{o.groups&&Array.isArray(o.groups)&&o.groups.forEach(a=>i.add(a))});let n=[...i];e(n)},r.onerror=()=>{t(new Error(`Failed to get groups: ${r.error}`))}})}addAsset(e){this.initialize().then(async()=>{if(!this.db)throw new Error("Database not initialized");let t=this.db.transaction(this.assetStoreName,"readwrite"),r=t.objectStore(this.assetStoreName),i=new Set;O(e,o=>{i.add(o)}),setTimeout(()=>{this.storeBlobUrls([...i])});let n={...e,meta:{...e.meta,insertedAt:e.meta?.insertedAt||Date.now()}};r.put(n),t.onerror=()=>{console.error(`Failed to add asset: ${t.error}`)}}).catch(t=>{console.error("Error initializing database:",t)})}async removeAsset(e){let t=await this.getAsset(e);return this.initialize().then(()=>{if(!this.db)throw new Error("Database not initialized");let r=this.db.transaction(this.assetStoreName,"readwrite");r.objectStore(this.assetStoreName).delete(e),r.oncomplete=()=>{O(t,i=>{this.removeBlob(i)}),this.engine.asset.assetSourceContentsChanged(this.id)},r.onerror=()=>{console.error(`Failed to remove asset: ${r.error}`)}}).catch(r=>{console.error("Error initializing database:",r)})}async removeBlob(e){return this.initialize().then(()=>{if(!this.db)throw new Error("Database not initialized");let t=this.db.transaction(this.blobStoreName,"readwrite");t.objectStore(this.blobStoreName).delete(e),t.onerror=()=>{console.error(`Failed to remove blob: ${t.error}`)}}).catch(t=>{console.error("Error initializing database:",t)})}async getAllAssets(e="desc"){return new Promise((t,r)=>{let i=this.db.transaction(this.assetStoreName,"readonly").objectStore(this.assetStoreName).getAll();i.onsuccess=()=>{let n=i.result;n.sort((o,a)=>{let s=o.meta?.insertedAt||o._insertedAt||Date.now(),u=a.meta?.insertedAt||a._insertedAt||Date.now();return e==="asc"?s-u:u-s}),t(n)},i.onerror=()=>{r(new Error(`Failed to get assets: ${i.error}`))}})}async getAsset(e){return new Promise((t,r)=>{let i=this.db.transaction(this.assetStoreName,"readonly").objectStore(this.assetStoreName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=()=>{r(new Error(`Failed to get blob: ${i.error}`))}})}async getBlob(e){return new Promise((t,r)=>{let i=this.db.transaction(this.blobStoreName,"readonly").objectStore(this.blobStoreName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=()=>{r(new Error(`Failed to get blob: ${i.error}`))}})}async createBlobUrlFromStore(e){let t=await this.getBlob(e);return t!=null?URL.createObjectURL(t.blob):e}async storeBlobUrls(e){let t={};return await Promise.all(e.map(async r=>{let i=await(await fetch(r)).blob();t[r]=i})),this.initialize().then(async()=>{if(!this.db)throw new Error("Database not initialized");let r=this.db.transaction(this.blobStoreName,"readwrite"),i=r.objectStore(this.blobStoreName);Object.entries(t).forEach(([n,o])=>{let a={id:n,blob:o};i.put(a)}),r.onerror=()=>{console.error(`Failed to add blobs: ${r.error}`)}}).catch(r=>{console.error("Error initializing database:",r)})}async restoreBlobUrls(e){let t={},r=new Set;return O(e,i=>{r.add(i)}),await Promise.all([...r].map(async i=>{let n=await this.createBlobUrlFromStore(i);t[i]=n})),O(e,i=>t[i]??i)}filterAsset(e,t){let{query:r,tags:i,groups:n,excludeGroups:o}=t;if(r&&r.trim()!==""){let a=r.trim().toLowerCase().split(" "),s=e.label?.toLowerCase()??"",u=e.tags?.map(l=>l.toLowerCase())??[];if(!a.every(l=>s.includes(l)||u.some(c=>c.includes(l))))return!1}if(i){let a=Array.isArray(i)?i:[i];if(a.length>0&&(!e.tags||!a.every(s=>e.tags?.includes(s))))return!1}return!(n&&n.length>0&&(!e.groups||!n.some(a=>e.groups?.includes(a)))||o&&o.length>0&&e.groups&&e.groups.some(a=>o.includes(a)))}sortAssets(e,t){let{sortingOrder:r,sortKey:i,sortActiveFirst:n}=t,o=[...e];return!r||r==="None"||(i?o.sort((a,s)=>{let u,l;return i==="id"?(u=a.id,l=s.id):(u=a.meta?.[i]??null,l=s.meta?.[i]??null),u==null?r==="Ascending"?-1:1:l==null?r==="Ascending"?1:-1:typeof u=="string"&&typeof l=="string"?r==="Ascending"?u.localeCompare(l):l.localeCompare(u):r==="Ascending"?u<l?-1:u>l?1:0:u>l?-1:u<l?1:0}):r==="Descending"&&o.reverse(),n&&o.sort((a,s)=>a.active&&!s.active?-1:!a.active&&s.active?1:0)),o}};function O(e,t,r=""){if(e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let i=0;i<e.length;i++){let n=r?`${r}[${i}]`:`[${i}]`;if(typeof e[i]=="string"&&e[i].startsWith("blob:")){let o=t(e[i],n);typeof o=="string"&&(e[i]=o)}else e[i]=O(e[i],t,n)}return e}for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let n=e[i],o=r?`${r}.${i}`:i;if(typeof n=="string"&&n.startsWith("blob:")){let a=t(n,o);typeof a=="string"&&(e[i]=a)}else e[i]=O(n,t,o)}return e}var Yt=class{constructor(e,t,r){this.id=e,this.cesdk=t,this.assetSourceIds=r}async findAssets(e){try{let t=this.assetSourceIds.map(c=>this.cesdk.engine.asset.findAssets(c,{...e,perPage:9999,page:0})),r=await Promise.all(t),i=[];r.forEach(c=>{c?.assets&&(i=i.concat(c.assets))}),i.sort((c,d)=>{let g=c.meta?.insertedAt||0;return(d.meta?.insertedAt||0)-g});let{page:n,perPage:o}=e,a=n*o,s=a+o,u=i.slice(a,s),l=s<i.length?n+1:void 0;return{assets:u,currentPage:n,nextPage:l,total:i.length}}catch(t){console.error("Error finding assets:",t);return}}async getGroups(){let e=this.assetSourceIds.map(i=>this.cesdk.engine.asset.getGroups(i)),t=await Promise.all(e),r=new Set;return t.forEach(i=>{i.forEach(n=>r.add(n))}),Array.from(r)}addAsset(e){throw new Error("AggregatedAssetSource does not support adding assets")}removeAsset(e){throw new Error("AggregatedAssetSource does not support removing assets")}};var Qt=typeof global=="object"&&global&&global.Object===Object&&global,We=Qt,Wt=typeof self=="object"&&self&&self.Object===Object&&self,Kt=We||Wt||Function("return this")(),C=Kt,Jt=C.Symbol,P=Jt,Ke=Object.prototype,Xt=Ke.hasOwnProperty,er=Ke.toString,H=P?P.toStringTag:void 0;function tr(e){var t=Xt.call(e,H),r=e[H];try{e[H]=void 0;var i=!0}catch{}var n=er.call(e);return i&&(t?e[H]=r:delete e[H]),n}var rr=tr,ir=Object.prototype,nr=ir.toString;function or(e){return nr.call(e)}var ar=or,sr="[object Null]",lr="[object Undefined]",Pe=P?P.toStringTag:void 0;function ur(e){return e==null?e===void 0?lr:sr:Pe&&Pe in Object(e)?rr(e):ar(e)}var K=ur;function cr(e){return e!=null&&typeof e=="object"}var Ie=cr,pu=Array.isArray;function dr(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Je=dr,gr="[object AsyncFunction]",pr="[object Function]",fr="[object GeneratorFunction]",hr="[object Proxy]";function mr(e){if(!Je(e))return!1;var t=K(e);return t==pr||t==fr||t==gr||t==hr}var br=mr,yr=C["__core-js_shared__"],ge=yr,$e=function(){var e=/[^.]+$/.exec(ge&&ge.keys&&ge.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function vr(e){return!!$e&&$e in e}var wr=vr,kr=Function.prototype,Ir=kr.toString;function Cr(e){if(e!=null){try{return Ir.call(e)}catch{}try{return e+""}catch{}}return""}var E=Cr,Sr=/[\\^$.*+?()[\]{}|]/g,Ar=/^\[object .+?Constructor\]$/,xr=Function.prototype,Mr=Object.prototype,Er=xr.toString,jr=Mr.hasOwnProperty,_r=RegExp("^"+Er.call(jr).replace(Sr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Lr(e){if(!Je(e)||wr(e))return!1;var t=br(e)?_r:Ar;return t.test(E(e))}var Nr=Lr;function Or(e,t){return e?.[t]}var Pr=Or;function $r(e,t){var r=Pr(e,t);return Nr(r)?r:void 0}var $=$r,Dr=$(C,"WeakMap"),be=Dr;function Tr(e,t){return e===t||e!==e&&t!==t}var zr=Tr,Rr=9007199254740991;function Fr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Rr}var Ur=Fr,fu=Object.prototype,Vr="[object Arguments]";function Br(e){return Ie(e)&&K(e)==Vr}var De=Br,Xe=Object.prototype,Gr=Xe.hasOwnProperty,Hr=Xe.propertyIsEnumerable,hu=De(function(){return arguments}())?De:function(e){return Ie(e)&&Gr.call(e,"callee")&&!Hr.call(e,"callee")},et=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=et&&typeof module=="object"&&module&&!module.nodeType&&module,qr=Te&&Te.exports===et,ze=qr?C.Buffer:void 0,mu=ze?ze.isBuffer:void 0,Zr="[object Arguments]",Yr="[object Array]",Qr="[object Boolean]",Wr="[object Date]",Kr="[object Error]",Jr="[object Function]",Xr="[object Map]",ei="[object Number]",ti="[object Object]",ri="[object RegExp]",ii="[object Set]",ni="[object String]",oi="[object WeakMap]",ai="[object ArrayBuffer]",si="[object DataView]",li="[object Float32Array]",ui="[object Float64Array]",ci="[object Int8Array]",di="[object Int16Array]",gi="[object Int32Array]",pi="[object Uint8Array]",fi="[object Uint8ClampedArray]",hi="[object Uint16Array]",mi="[object Uint32Array]",v={};v[li]=v[ui]=v[ci]=v[di]=v[gi]=v[pi]=v[fi]=v[hi]=v[mi]=!0;v[Zr]=v[Yr]=v[ai]=v[Qr]=v[si]=v[Wr]=v[Kr]=v[Jr]=v[Xr]=v[ei]=v[ti]=v[ri]=v[ii]=v[ni]=v[oi]=!1;function bi(e){return Ie(e)&&Ur(e.length)&&!!v[K(e)]}var yi=bi;function vi(e){return function(t){return e(t)}}var wi=vi,tt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Y=tt&&typeof module=="object"&&module&&!module.nodeType&&module,ki=Y&&Y.exports===tt,pe=ki&&We.process,Ii=function(){try{var e=Y&&Y.require&&Y.require("util").types;return e||pe&&pe.binding&&pe.binding("util")}catch{}}(),Re=Ii,Fe=Re&&Re.isTypedArray,bu=Fe?wi(Fe):yi,Ci=Object.prototype,yu=Ci.hasOwnProperty;function Si(e,t){return function(r){return e(t(r))}}var Ai=Si,vu=Ai(Object.keys,Object),xi=Object.prototype,wu=xi.hasOwnProperty,Mi=$(Object,"create"),Q=Mi;function Ei(){this.__data__=Q?Q(null):{},this.size=0}var ji=Ei;function _i(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Li=_i,Ni="__lodash_hash_undefined__",Oi=Object.prototype,Pi=Oi.hasOwnProperty;function $i(e){var t=this.__data__;if(Q){var r=t[e];return r===Ni?void 0:r}return Pi.call(t,e)?t[e]:void 0}var Di=$i,Ti=Object.prototype,zi=Ti.hasOwnProperty;function Ri(e){var t=this.__data__;return Q?t[e]!==void 0:zi.call(t,e)}var Fi=Ri,Ui="__lodash_hash_undefined__";function Vi(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Q&&t===void 0?Ui:t,this}var Bi=Vi;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=ji;D.prototype.delete=Li;D.prototype.get=Di;D.prototype.has=Fi;D.prototype.set=Bi;var Ue=D;function Gi(){this.__data__=[],this.size=0}var Hi=Gi;function qi(e,t){for(var r=e.length;r--;)if(zr(e[r][0],t))return r;return-1}var ae=qi,Zi=Array.prototype,Yi=Zi.splice;function Qi(e){var t=this.__data__,r=ae(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Yi.call(t,r,1),--this.size,!0}var Wi=Qi;function Ki(e){var t=this.__data__,r=ae(t,e);return r<0?void 0:t[r][1]}var Ji=Ki;function Xi(e){return ae(this.__data__,e)>-1}var en=Xi;function tn(e,t){var r=this.__data__,i=ae(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var rn=tn;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=Hi;T.prototype.delete=Wi;T.prototype.get=Ji;T.prototype.has=en;T.prototype.set=rn;var se=T,nn=$(C,"Map"),W=nn;function on(){this.size=0,this.__data__={hash:new Ue,map:new(W||se),string:new Ue}}var an=on;function sn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ln=sn;function un(e,t){var r=e.__data__;return ln(t)?r[typeof t=="string"?"string":"hash"]:r.map}var le=un;function cn(e){var t=le(this,e).delete(e);return this.size-=t?1:0,t}var dn=cn;function gn(e){return le(this,e).get(e)}var pn=gn;function fn(e){return le(this,e).has(e)}var hn=fn;function mn(e,t){var r=le(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var bn=mn;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=an;z.prototype.delete=dn;z.prototype.get=pn;z.prototype.has=hn;z.prototype.set=bn;var rt=z;function yn(){this.__data__=new se,this.size=0}var vn=yn;function wn(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var kn=wn;function In(e){return this.__data__.get(e)}var Cn=In;function Sn(e){return this.__data__.has(e)}var An=Sn,xn=200;function Mn(e,t){var r=this.__data__;if(r instanceof se){var i=r.__data__;if(!W||i.length<xn-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new rt(i)}return r.set(e,t),this.size=r.size,this}var En=Mn;function J(e){var t=this.__data__=new se(e);this.size=t.size}J.prototype.clear=vn;J.prototype.delete=kn;J.prototype.get=Cn;J.prototype.has=An;J.prototype.set=En;var jn=Object.prototype,ku=jn.propertyIsEnumerable,_n=$(C,"DataView"),ye=_n,Ln=$(C,"Promise"),ve=Ln,Nn=$(C,"Set"),we=Nn,Ve="[object Map]",On="[object Object]",Be="[object Promise]",Ge="[object Set]",He="[object WeakMap]",qe="[object DataView]",Pn=E(ye),$n=E(W),Dn=E(ve),Tn=E(we),zn=E(be),N=K;(ye&&N(new ye(new ArrayBuffer(1)))!=qe||W&&N(new W)!=Ve||ve&&N(ve.resolve())!=Be||we&&N(new we)!=Ge||be&&N(new be)!=He)&&(N=function(e){var t=K(e),r=t==On?e.constructor:void 0,i=r?E(r):"";if(i)switch(i){case Pn:return qe;case $n:return Ve;case Dn:return Be;case Tn:return Ge;case zn:return He}return t});var Iu=C.Uint8Array,Rn="__lodash_hash_undefined__";function Fn(e){return this.__data__.set(e,Rn),this}var Un=Fn;function Vn(e){return this.__data__.has(e)}var Bn=Vn;function ke(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new rt;++t<r;)this.add(e[t])}ke.prototype.add=ke.prototype.push=Un;ke.prototype.has=Bn;var Ze=P?P.prototype:void 0,Cu=Ze?Ze.valueOf:void 0,Gn=Object.prototype,Su=Gn.hasOwnProperty,Hn=Object.prototype,Au=Hn.hasOwnProperty,xu=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Mu=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Eu=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function it(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),o=new Blob([n],{type:r});return URL.createObjectURL(o)}else return e}async function qn(e,t){let r=await it(e,t);return new Promise((i,n)=>{let o=new Image;o.onload=()=>{i({width:o.width,height:o.height})},o.onerror=n,o.src=r})}async function Zn(e,t,r){let i,n=t.block.getFill(e),o=t.block.getSourceSet(n,"fill/image/sourceSet"),[a]=o;if(a==null){if(i=t.block.getString(n,"fill/image/imageFileURI"),i==null)throw new Error("No image source/uri found")}else i=a.uri;if(r?.throwErrorIfSvg&&await t.editor.getMimeType(i)==="image/svg+xml")throw new Error("SVG images are not supported");return it(i,t)}function Yn(e){return e!==void 0}var Qn=Yn;var nt=class ot{constructor(){this.actions=new Map,this.subscribers=new Map}static get(){let t="__imgly_action_registry__",r=typeof window<"u"?window:globalThis;return r[t]||(r[t]=new ot),r[t]}register(t){return this.actions.set(t.id,t),this.notifySubscribers(t,"registered"),()=>{this.actions.get(t.id)===t&&(this.actions.delete(t.id),this.notifySubscribers(t,"unregistered"))}}getAll(){return Array.from(this.actions.values())}getBy(t){return this.getAll().filter(r=>this.matchesFilters(r,t))}subscribe(t){return this.subscribers.set(t,null),()=>{this.subscribers.delete(t)}}subscribeBy(t,r){return this.subscribers.set(r,t),()=>{this.subscribers.delete(r)}}notifySubscribers(t,r){this.subscribers.forEach((i,n)=>{if(i===null){n(t,r);return}this.matchesFilters(t,i)&&n(t,r)})}matchesFilters(t,r){return!(r.type&&t.type!==r.type||r.pluginId&&t.type==="plugin"&&t.pluginId!==r.pluginId||r.id&&t.id!==r.id||r.kind&&(t.type!=="quick"||t.kind!==r.kind))}},Wn=class at{constructor(){this.providers=new Map}static get(){let t="__imgly_provider_registry__",r=typeof window<"u"?window:globalThis;return r[t]||(r[t]=new at),r[t]}register(t){return this.providers.has(t.provider.id)&&console.warn(`Provider with ID "${t.provider.id}" is already registered`),this.providers.set(t.provider.id,t),()=>{this.providers.get(t.provider.id)===t&&this.providers.delete(t.provider.id)}}getAll(){return Array.from(this.providers.values())}getById(t){return this.providers.get(t)}getByKind(t){return this.getAll().filter(({provider:r})=>r.kind===t)}};function Kn(e){let t=e.filter(r=>!!r);return r=>async(i,n)=>{let o=[],a=l=>{o.push(l)},s=async(l,c,d)=>{if(l>=t.length)return r(c,d);let g=t[l],p=async(b,m)=>s(l+1,b,m),h={...d,addDisposer:a};return g(c,h,p)},u={...n,addDisposer:a};return{result:await s(0,i,u),dispose:async()=>{for(let l=o.length-1;l>=0;l--)try{await o[l]()}catch(c){console.error("Error in disposer:",c)}o.length=0}}}}function Jn({enable:e=!0}){return async(t,r,i)=>{if(!e)return i(t,r);console.group("[GENERATION]"),console.log("Generating with input:",JSON.stringify(t,null,2));let n,o=Date.now();try{return n=await i(t,r),n}finally{n!=null&&(console.log(`Generation took ${Date.now()-o}ms`),console.log("Generation result:",JSON.stringify(n,null,2))),console.groupEnd()}}}var Xn=Jn;var fe="ly.img.ai.temp";async function eo(e,t){return e.engine.asset.findAllSources().includes(fe)||e.engine.asset.addLocalSource(fe),e.engine.asset.apply(fe,t)}function to(e,t="We encountered an unknown error while generating the asset. Please try again."){if(e===null)return t;if(e instanceof Error)return e.message;if(typeof e=="object"){let r=e;return"message"in r&&typeof r.message=="string"?r.message:"cause"in r&&typeof r.cause=="string"?r.cause:"detail"in r&&typeof r.detail=="object"&&r.detail!==null&&"message"in r.detail&&typeof r.detail.message=="string"?r.detail.message:"error"in r&&typeof r.error=="object"&&r.error!==null&&"message"in r.error&&typeof r.error.message=="string"?r.error.message:t}return typeof e=="string"?e:String(e)||t}function st(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function ro(e,t=0,r="image/jpeg",i=.8){return new Promise((n,o)=>{try{let a=document.createElement("video");a.crossOrigin="anonymous",a.style.display="none",a.addEventListener("loadedmetadata",()=>{a.currentTime=Math.min(t,a.duration),a.addEventListener("seeked",()=>{let s=document.createElement("canvas");s.width=a.videoWidth,s.height=a.videoHeight;let u=s.getContext("2d");if(!u){document.body.removeChild(a),o(new Error("Failed to create canvas context"));return}u.drawImage(a,0,0,s.width,s.height);try{let l=s.toDataURL(r,i);document.body.removeChild(a),n(l)}catch(l){document.body.removeChild(a),o(new Error(`Failed to create thumbnail: ${l instanceof Error?l.message:String(l)}`))}},{once:!0})}),a.addEventListener("error",()=>{document.body.removeChild(a),o(new Error(`Failed to load video from ${e}`))}),a.src=e,document.body.appendChild(a)}catch(a){o(a)}})}function lt(e){return e?e.replace(/[_-]/g," ").replace(/([A-Z])/g," $1").trim().split(" ").filter(t=>t.length>0).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" "):""}function io(e){return typeof e=="object"&&e!==null&&"next"in e&&"return"in e&&"throw"in e&&typeof e.next=="function"&&typeof e.return=="function"&&typeof e.throw=="function"&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]=="function"}function Ce(e){return e instanceof Error&&e.name==="AbortError"}function no(e,t,r){let i=`${t}.iconSetAdded`;e.ui.experimental.hasGlobalStateValue(i)||(e.ui.addIconSet(t,r),e.ui.experimental.setGlobalStateValue(i,!0))}function ut(e,t,r){let i="ai-plugin-version",n="ai-plugin-version-warning-shown";try{let o=e.ui.experimental.getGlobalStateValue(i);o?o!==r&&(e.ui.experimental.getGlobalStateValue(n,!1)||(console.warn(`[IMG.LY AI Plugins] Version mismatch detected!
|
|
2
|
-
Plugin "${t}" is using version ${r}, but other AI plugins are using version ${
|
|
1
|
+
var er=class{constructor(e,t,r){this.assetStoreName="assets",this.blobStoreName="blobs",this.db=null,this.id=e,this.engine=t,this.dbName=r?.dbName??`ly.img.assetSource/${e}`,this.dbVersion=r?.dbVersion??1}async initialize(){if(!this.db)return new Promise((e,t)=>{let r=indexedDB.open(this.dbName,this.dbVersion);r.onerror=i=>{t(new Error(`Failed to open IndexedDB: ${i.target.error}`))},r.onupgradeneeded=i=>{let n=i.target.result;n.objectStoreNames.contains(this.assetStoreName)||n.createObjectStore(this.assetStoreName,{keyPath:"id"}),n.objectStoreNames.contains(this.blobStoreName)||n.createObjectStore(this.blobStoreName,{keyPath:"id"})},r.onsuccess=i=>{this.db=i.target.result,e()}})}close(){this.db&&(this.db.close(),this.db=null)}async findAssets(e){if(await this.initialize(),!this.db)throw new Error("Database not initialized");try{let t=(await this.getAllAssets("asc")).reduce((u,s)=>{let c=e.locale??"en",g="",p=[];s.label!=null&&typeof s.label=="object"&&s.label[c]&&(g=s.label[c]),s.tags!=null&&typeof s.tags=="object"&&s.tags[c]&&(p=s.tags[c]);let d={...s,label:g,tags:p};return this.filterAsset(d,e)&&u.push(d),u},[]);t=await this.restoreBlobUrls(t),t=this.sortAssets(t,e);let{page:r,perPage:i}=e,n=r*i,a=n+i,o=t.slice(n,a),l=a<t.length?r+1:void 0;return{assets:o,currentPage:r,nextPage:l,total:t.length}}catch(t){console.error("Error finding assets:",t);return}}async getGroups(){if(await this.initialize(),!this.db)throw new Error("Database not initialized");return new Promise((e,t)=>{let r=this.db.transaction(this.assetStoreName,"readonly").objectStore(this.assetStoreName).getAll();r.onsuccess=()=>{let i=new Set;r.result.forEach(a=>{a.groups&&Array.isArray(a.groups)&&a.groups.forEach(o=>i.add(o))});let n=[...i];e(n)},r.onerror=()=>{t(new Error(`Failed to get groups: ${r.error}`))}})}addAsset(e){this.initialize().then(async()=>{if(!this.db)throw new Error("Database not initialized");let t=this.db.transaction(this.assetStoreName,"readwrite"),r=t.objectStore(this.assetStoreName),i=new Set;z(e,a=>{i.add(a)}),setTimeout(()=>{this.storeBlobUrls([...i])});let n={...e,meta:{...e.meta,insertedAt:e.meta?.insertedAt||Date.now()}};r.put(n),t.onerror=()=>{console.error(`Failed to add asset: ${t.error}`)}}).catch(t=>{console.error("Error initializing database:",t)})}async removeAsset(e){let t=await this.getAsset(e);return this.initialize().then(()=>{if(!this.db)throw new Error("Database not initialized");let r=this.db.transaction(this.assetStoreName,"readwrite");r.objectStore(this.assetStoreName).delete(e),r.oncomplete=()=>{z(t,i=>{this.removeBlob(i)}),this.engine.asset.assetSourceContentsChanged(this.id)},r.onerror=()=>{console.error(`Failed to remove asset: ${r.error}`)}}).catch(r=>{console.error("Error initializing database:",r)})}async removeBlob(e){return this.initialize().then(()=>{if(!this.db)throw new Error("Database not initialized");let t=this.db.transaction(this.blobStoreName,"readwrite");t.objectStore(this.blobStoreName).delete(e),t.onerror=()=>{console.error(`Failed to remove blob: ${t.error}`)}}).catch(t=>{console.error("Error initializing database:",t)})}async getAllAssets(e="desc"){return new Promise((t,r)=>{let i=this.db.transaction(this.assetStoreName,"readonly").objectStore(this.assetStoreName).getAll();i.onsuccess=()=>{let n=i.result;n.sort((a,o)=>{let l=a.meta?.insertedAt||a._insertedAt||Date.now(),u=o.meta?.insertedAt||o._insertedAt||Date.now();return e==="asc"?l-u:u-l}),t(n)},i.onerror=()=>{r(new Error(`Failed to get assets: ${i.error}`))}})}async getAsset(e){return new Promise((t,r)=>{let i=this.db.transaction(this.assetStoreName,"readonly").objectStore(this.assetStoreName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=()=>{r(new Error(`Failed to get blob: ${i.error}`))}})}async getBlob(e){return new Promise((t,r)=>{let i=this.db.transaction(this.blobStoreName,"readonly").objectStore(this.blobStoreName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=()=>{r(new Error(`Failed to get blob: ${i.error}`))}})}async createBlobUrlFromStore(e){let t=await this.getBlob(e);return t!=null?URL.createObjectURL(t.blob):e}async storeBlobUrls(e){let t={};return await Promise.all(e.map(async r=>{let i=await(await fetch(r)).blob();t[r]=i})),this.initialize().then(async()=>{if(!this.db)throw new Error("Database not initialized");let r=this.db.transaction(this.blobStoreName,"readwrite"),i=r.objectStore(this.blobStoreName);Object.entries(t).forEach(([n,a])=>{let o={id:n,blob:a};i.put(o)}),r.onerror=()=>{console.error(`Failed to add blobs: ${r.error}`)}}).catch(r=>{console.error("Error initializing database:",r)})}async restoreBlobUrls(e){let t={},r=new Set;return z(e,i=>{r.add(i)}),await Promise.all([...r].map(async i=>{let n=await this.createBlobUrlFromStore(i);t[i]=n})),z(e,i=>t[i]??i)}filterAsset(e,t){let{query:r,tags:i,groups:n,excludeGroups:a}=t;if(r&&r.trim()!==""){let o=r.trim().toLowerCase().split(" "),l=e.label?.toLowerCase()??"",u=e.tags?.map(s=>s.toLowerCase())??[];if(!o.every(s=>l.includes(s)||u.some(c=>c.includes(s))))return!1}if(i){let o=Array.isArray(i)?i:[i];if(o.length>0&&(!e.tags||!o.every(l=>e.tags?.includes(l))))return!1}return!(n&&n.length>0&&(!e.groups||!n.some(o=>e.groups?.includes(o)))||a&&a.length>0&&e.groups&&e.groups.some(o=>a.includes(o)))}sortAssets(e,t){let{sortingOrder:r,sortKey:i,sortActiveFirst:n}=t,a=[...e];return!r||r==="None"||(i?a.sort((o,l)=>{let u,s;return i==="id"?(u=o.id,s=l.id):(u=o.meta?.[i]??null,s=l.meta?.[i]??null),u==null?r==="Ascending"?-1:1:s==null?r==="Ascending"?1:-1:typeof u=="string"&&typeof s=="string"?r==="Ascending"?u.localeCompare(s):s.localeCompare(u):r==="Ascending"?u<s?-1:u>s?1:0:u>s?-1:u<s?1:0}):r==="Descending"&&a.reverse(),n&&a.sort((o,l)=>o.active&&!l.active?-1:!o.active&&l.active?1:0)),a}};function z(e,t,r=""){if(e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let i=0;i<e.length;i++){let n=r?`${r}[${i}]`:`[${i}]`;if(typeof e[i]=="string"&&e[i].startsWith("blob:")){let a=t(e[i],n);typeof a=="string"&&(e[i]=a)}else e[i]=z(e[i],t,n)}return e}for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let n=e[i],a=r?`${r}.${i}`:i;if(typeof n=="string"&&n.startsWith("blob:")){let o=t(n,a);typeof o=="string"&&(e[i]=o)}else e[i]=z(n,t,a)}return e}var tr=class{constructor(e,t,r){this.id=e,this.cesdk=t,this.assetSourceIds=r}async findAssets(e){try{let t=this.assetSourceIds.map(c=>this.cesdk.engine.asset.findAssets(c,{...e,perPage:9999,page:0})),r=await Promise.all(t),i=[];r.forEach(c=>{c?.assets&&(i=i.concat(c.assets))}),i.sort((c,g)=>{let p=c.meta?.insertedAt||0;return(g.meta?.insertedAt||0)-p});let{page:n,perPage:a}=e,o=n*a,l=o+a,u=i.slice(o,l),s=l<i.length?n+1:void 0;return{assets:u,currentPage:n,nextPage:s,total:i.length}}catch(t){console.error("Error finding assets:",t);return}}async getGroups(){let e=this.assetSourceIds.map(i=>this.cesdk.engine.asset.getGroups(i)),t=await Promise.all(e),r=new Set;return t.forEach(i=>{i.forEach(n=>r.add(n))}),Array.from(r)}addAsset(e){throw new Error("AggregatedAssetSource does not support adding assets")}removeAsset(e){throw new Error("AggregatedAssetSource does not support removing assets")}};var rr=typeof global=="object"&&global&&global.Object===Object&&global,nt=rr,ir=typeof self=="object"&&self&&self.Object===Object&&self,nr=nt||ir||Function("return this")(),S=nr,or=S.Symbol,R=or,ot=Object.prototype,ar=ot.hasOwnProperty,sr=ot.toString,W=R?R.toStringTag:void 0;function lr(e){var t=ar.call(e,W),r=e[W];try{e[W]=void 0;var i=!0}catch{}var n=sr.call(e);return i&&(t?e[W]=r:delete e[W]),n}var ur=lr,cr=Object.prototype,dr=cr.toString;function gr(e){return dr.call(e)}var pr=gr,fr="[object Null]",mr="[object Undefined]",Ue=R?R.toStringTag:void 0;function hr(e){return e==null?e===void 0?mr:fr:Ue&&Ue in Object(e)?ur(e):pr(e)}var ie=hr;function br(e){return e!=null&&typeof e=="object"}var je=br,Iu=Array.isArray;function yr(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var at=yr,vr="[object AsyncFunction]",wr="[object Function]",kr="[object GeneratorFunction]",Ir="[object Proxy]";function Cr(e){if(!at(e))return!1;var t=ie(e);return t==wr||t==kr||t==vr||t==Ir}var Sr=Cr,Ar=S["__core-js_shared__"],ye=Ar,Ve=function(){var e=/[^.]+$/.exec(ye&&ye.keys&&ye.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function xr(e){return!!Ve&&Ve in e}var Er=xr,Mr=Function.prototype,jr=Mr.toString;function _r(e){if(e!=null){try{return jr.call(e)}catch{}try{return e+""}catch{}}return""}var P=_r,Lr=/[\\^$.*+?()[\]{}|]/g,$r=/^\[object .+?Constructor\]$/,Nr=Function.prototype,Pr=Object.prototype,Or=Nr.toString,Tr=Pr.hasOwnProperty,Dr=RegExp("^"+Or.call(Tr).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zr(e){if(!at(e)||Er(e))return!1;var t=Sr(e)?Dr:$r;return t.test(P(e))}var Rr=zr;function Fr(e,t){return e?.[t]}var Ur=Fr;function Vr(e,t){var r=Ur(e,t);return Rr(r)?r:void 0}var F=Vr,Br=F(S,"WeakMap"),Ce=Br;function Gr(e,t){return e===t||e!==e&&t!==t}var Hr=Gr,qr=9007199254740991;function Zr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=qr}var Yr=Zr,Cu=Object.prototype,Qr="[object Arguments]";function Wr(e){return je(e)&&ie(e)==Qr}var Be=Wr,st=Object.prototype,Kr=st.hasOwnProperty,Jr=st.propertyIsEnumerable,Su=Be(function(){return arguments}())?Be:function(e){return je(e)&&Kr.call(e,"callee")&&!Jr.call(e,"callee")},lt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ge=lt&&typeof module=="object"&&module&&!module.nodeType&&module,Xr=Ge&&Ge.exports===lt,He=Xr?S.Buffer:void 0,Au=He?He.isBuffer:void 0,ei="[object Arguments]",ti="[object Array]",ri="[object Boolean]",ii="[object Date]",ni="[object Error]",oi="[object Function]",ai="[object Map]",si="[object Number]",li="[object Object]",ui="[object RegExp]",ci="[object Set]",di="[object String]",gi="[object WeakMap]",pi="[object ArrayBuffer]",fi="[object DataView]",mi="[object Float32Array]",hi="[object Float64Array]",bi="[object Int8Array]",yi="[object Int16Array]",vi="[object Int32Array]",wi="[object Uint8Array]",ki="[object Uint8ClampedArray]",Ii="[object Uint16Array]",Ci="[object Uint32Array]",v={};v[mi]=v[hi]=v[bi]=v[yi]=v[vi]=v[wi]=v[ki]=v[Ii]=v[Ci]=!0;v[ei]=v[ti]=v[pi]=v[ri]=v[fi]=v[ii]=v[ni]=v[oi]=v[ai]=v[si]=v[li]=v[ui]=v[ci]=v[di]=v[gi]=!1;function Si(e){return je(e)&&Yr(e.length)&&!!v[ie(e)]}var Ai=Si;function xi(e){return function(t){return e(t)}}var Ei=xi,ut=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ee=ut&&typeof module=="object"&&module&&!module.nodeType&&module,Mi=ee&&ee.exports===ut,ve=Mi&&nt.process,ji=function(){try{var e=ee&&ee.require&&ee.require("util").types;return e||ve&&ve.binding&&ve.binding("util")}catch{}}(),qe=ji,Ze=qe&&qe.isTypedArray,xu=Ze?Ei(Ze):Ai,_i=Object.prototype,Eu=_i.hasOwnProperty;function Li(e,t){return function(r){return e(t(r))}}var $i=Li,Mu=$i(Object.keys,Object),Ni=Object.prototype,ju=Ni.hasOwnProperty,Pi=F(Object,"create"),te=Pi;function Oi(){this.__data__=te?te(null):{},this.size=0}var Ti=Oi;function Di(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var zi=Di,Ri="__lodash_hash_undefined__",Fi=Object.prototype,Ui=Fi.hasOwnProperty;function Vi(e){var t=this.__data__;if(te){var r=t[e];return r===Ri?void 0:r}return Ui.call(t,e)?t[e]:void 0}var Bi=Vi,Gi=Object.prototype,Hi=Gi.hasOwnProperty;function qi(e){var t=this.__data__;return te?t[e]!==void 0:Hi.call(t,e)}var Zi=qi,Yi="__lodash_hash_undefined__";function Qi(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=te&&t===void 0?Yi:t,this}var Wi=Qi;function U(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])}}U.prototype.clear=Ti;U.prototype.delete=zi;U.prototype.get=Bi;U.prototype.has=Zi;U.prototype.set=Wi;var Ye=U;function Ki(){this.__data__=[],this.size=0}var Ji=Ki;function Xi(e,t){for(var r=e.length;r--;)if(Hr(e[r][0],t))return r;return-1}var de=Xi,en=Array.prototype,tn=en.splice;function rn(e){var t=this.__data__,r=de(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():tn.call(t,r,1),--this.size,!0}var nn=rn;function on(e){var t=this.__data__,r=de(t,e);return r<0?void 0:t[r][1]}var an=on;function sn(e){return de(this.__data__,e)>-1}var ln=sn;function un(e,t){var r=this.__data__,i=de(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var cn=un;function V(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])}}V.prototype.clear=Ji;V.prototype.delete=nn;V.prototype.get=an;V.prototype.has=ln;V.prototype.set=cn;var ge=V,dn=F(S,"Map"),re=dn;function gn(){this.size=0,this.__data__={hash:new Ye,map:new(re||ge),string:new Ye}}var pn=gn;function fn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var mn=fn;function hn(e,t){var r=e.__data__;return mn(t)?r[typeof t=="string"?"string":"hash"]:r.map}var pe=hn;function bn(e){var t=pe(this,e).delete(e);return this.size-=t?1:0,t}var yn=bn;function vn(e){return pe(this,e).get(e)}var wn=vn;function kn(e){return pe(this,e).has(e)}var In=kn;function Cn(e,t){var r=pe(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var Sn=Cn;function B(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])}}B.prototype.clear=pn;B.prototype.delete=yn;B.prototype.get=wn;B.prototype.has=In;B.prototype.set=Sn;var ct=B;function An(){this.__data__=new ge,this.size=0}var xn=An;function En(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Mn=En;function jn(e){return this.__data__.get(e)}var _n=jn;function Ln(e){return this.__data__.has(e)}var $n=Ln,Nn=200;function Pn(e,t){var r=this.__data__;if(r instanceof ge){var i=r.__data__;if(!re||i.length<Nn-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new ct(i)}return r.set(e,t),this.size=r.size,this}var On=Pn;function ne(e){var t=this.__data__=new ge(e);this.size=t.size}ne.prototype.clear=xn;ne.prototype.delete=Mn;ne.prototype.get=_n;ne.prototype.has=$n;ne.prototype.set=On;var Tn=Object.prototype,_u=Tn.propertyIsEnumerable,Dn=F(S,"DataView"),Se=Dn,zn=F(S,"Promise"),Ae=zn,Rn=F(S,"Set"),xe=Rn,Qe="[object Map]",Fn="[object Object]",We="[object Promise]",Ke="[object Set]",Je="[object WeakMap]",Xe="[object DataView]",Un=P(Se),Vn=P(re),Bn=P(Ae),Gn=P(xe),Hn=P(Ce),D=ie;(Se&&D(new Se(new ArrayBuffer(1)))!=Xe||re&&D(new re)!=Qe||Ae&&D(Ae.resolve())!=We||xe&&D(new xe)!=Ke||Ce&&D(new Ce)!=Je)&&(D=function(e){var t=ie(e),r=t==Fn?e.constructor:void 0,i=r?P(r):"";if(i)switch(i){case Un:return Xe;case Vn:return Qe;case Bn:return We;case Gn:return Ke;case Hn:return Je}return t});var Lu=S.Uint8Array,qn="__lodash_hash_undefined__";function Zn(e){return this.__data__.set(e,qn),this}var Yn=Zn;function Qn(e){return this.__data__.has(e)}var Wn=Qn;function Ee(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new ct;++t<r;)this.add(e[t])}Ee.prototype.add=Ee.prototype.push=Yn;Ee.prototype.has=Wn;var et=R?R.prototype:void 0,$u=et?et.valueOf:void 0,Kn=Object.prototype,Nu=Kn.hasOwnProperty,Jn=Object.prototype,Pu=Jn.hasOwnProperty,Ou=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Tu=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Du=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function dt(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),a=new Uint8Array(n),o=new Blob([a],{type:r});return URL.createObjectURL(o)}else return e}async function Xn(e,t){let r=await dt(e,t);return new Promise((i,n)=>{let a=new Image;a.onload=()=>{i({width:a.width,height:a.height})},a.onerror=n,a.src=r})}async function eo(e,t,r){let i,n=t.block.getFill(e),a=t.block.getSourceSet(n,"fill/image/sourceSet"),[o]=a;if(o==null){if(i=t.block.getString(n,"fill/image/imageFileURI"),i==null)throw new Error("No image source/uri found")}else i=o.uri;if(r?.throwErrorIfSvg&&await t.editor.getMimeType(i)==="image/svg+xml")throw new Error("SVG images are not supported");return dt(i,t)}function to(e){return e!==void 0}var ro=to;var gt=class pt{constructor(){this.actions=new Map,this.subscribers=new Map}static get(){let t="__imgly_action_registry__",r=typeof window<"u"?window:globalThis;return r[t]||(r[t]=new pt),r[t]}register(t){return this.actions.set(t.id,t),this.notifySubscribers(t,"registered"),()=>{this.actions.get(t.id)===t&&(this.actions.delete(t.id),this.notifySubscribers(t,"unregistered"))}}getAll(){return Array.from(this.actions.values())}getBy(t){return this.getAll().filter(r=>this.matchesFilters(r,t))}subscribe(t){return this.subscribers.set(t,null),()=>{this.subscribers.delete(t)}}subscribeBy(t,r){return this.subscribers.set(r,t),()=>{this.subscribers.delete(r)}}notifySubscribers(t,r){this.subscribers.forEach((i,n)=>{if(i===null){n(t,r);return}this.matchesFilters(t,i)&&n(t,r)})}matchesFilters(t,r){return!(r.type&&t.type!==r.type||r.pluginId&&t.type==="plugin"&&t.pluginId!==r.pluginId||r.id&&t.id!==r.id||r.kind&&(t.type!=="quick"||t.kind!==r.kind))}},io=class ft{constructor(){this.providers=new Map}static get(){let t="__imgly_provider_registry__",r=typeof window<"u"?window:globalThis;return r[t]||(r[t]=new ft),r[t]}register(t){return this.providers.has(t.provider.id)&&console.warn(`Provider with ID "${t.provider.id}" is already registered`),this.providers.set(t.provider.id,t),()=>{this.providers.get(t.provider.id)===t&&this.providers.delete(t.provider.id)}}getAll(){return Array.from(this.providers.values())}getById(t){return this.providers.get(t)}getByKind(t){return this.getAll().filter(({provider:r})=>r.kind===t)}};function no(e){let t=e.filter(r=>!!r);return r=>async(i,n)=>{let a=[],o=s=>{a.push(s)},l=async(s,c,g)=>{if(s>=t.length)return r(c,g);let p=t[s],d=async(f,b)=>l(s+1,f,b),m={...g,addDisposer:o};return p(c,m,d)},u={...n,addDisposer:o};return{result:await l(0,i,u),dispose:async()=>{for(let s=a.length-1;s>=0;s--)try{await a[s]()}catch(c){console.error("Error in disposer:",c)}a.length=0}}}}function oo({enable:e=!0}){return async(t,r,i)=>{if(!e)return i(t,r);console.group("[GENERATION]"),console.log("Generating with input:",JSON.stringify(t,null,2));let n,a=Date.now();try{return n=await i(t,r),n}finally{n!=null&&(console.log(`Generation took ${Date.now()-a}ms`),console.log("Generation result:",JSON.stringify(n,null,2))),console.groupEnd()}}}var ao=oo;var we="ly.img.ai.temp";async function so(e,t){return e.engine.asset.findAllSources().includes(we)||e.engine.asset.addLocalSource(we),e.engine.asset.apply(we,t)}function lo(e,t="We encountered an unknown error while generating the asset. Please try again."){if(e===null)return t;if(e instanceof Error)return e.message;if(typeof e=="object"){let r=e;return"message"in r&&typeof r.message=="string"?r.message:"cause"in r&&typeof r.cause=="string"?r.cause:"detail"in r&&typeof r.detail=="object"&&r.detail!==null&&"message"in r.detail&&typeof r.detail.message=="string"?r.detail.message:"error"in r&&typeof r.error=="object"&&r.error!==null&&"message"in r.error&&typeof r.error.message=="string"?r.error.message:t}return typeof e=="string"?e:String(e)||t}function mt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function uo(e,t=0,r="image/jpeg",i=.8){return new Promise((n,a)=>{try{let o=document.createElement("video");o.crossOrigin="anonymous",o.style.display="none",o.addEventListener("loadedmetadata",()=>{o.currentTime=Math.min(t,o.duration),o.addEventListener("seeked",()=>{let l=document.createElement("canvas");l.width=o.videoWidth,l.height=o.videoHeight;let u=l.getContext("2d");if(!u){document.body.removeChild(o),a(new Error("Failed to create canvas context"));return}u.drawImage(o,0,0,l.width,l.height);try{let s=l.toDataURL(r,i);document.body.removeChild(o),n(s)}catch(s){document.body.removeChild(o),a(new Error(`Failed to create thumbnail: ${s instanceof Error?s.message:String(s)}`))}},{once:!0})}),o.addEventListener("error",()=>{document.body.removeChild(o),a(new Error(`Failed to load video from ${e}`))}),o.src=e,document.body.appendChild(o)}catch(o){a(o)}})}function co(e){return typeof e=="object"&&e!==null&&"next"in e&&"return"in e&&"throw"in e&&typeof e.next=="function"&&typeof e.return=="function"&&typeof e.throw=="function"&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]=="function"}function _e(e){return e instanceof Error&&e.name==="AbortError"}function go(e,t,r){let i=`${t}.iconSetAdded`;e.ui.experimental.hasGlobalStateValue(i)||(e.ui.addIconSet(t,r),e.ui.experimental.setGlobalStateValue(i,!0))}function ht(e,t,r){let i="ai-plugin-version",n="ai-plugin-version-warning-shown";try{let a=e.ui.experimental.getGlobalStateValue(i);a?a!==r&&(e.ui.experimental.getGlobalStateValue(n,!1)||(console.warn(`[IMG.LY AI Plugins] Version mismatch detected!
|
|
2
|
+
Plugin "${t}" is using version ${r}, but other AI plugins are using version ${a}.
|
|
3
3
|
This may cause compatibility issues. Please ensure all AI plugins (@imgly/plugin-ai-*) use the same version.
|
|
4
|
-
Consider updating all AI plugins to the same version for optimal compatibility.`),e.ui.experimental.setGlobalStateValue(n,!0))):e.ui.experimental.setGlobalStateValue(i,r)}catch(o){console.debug("[IMG.LY AI Plugins] Could not check plugin version consistency:",o)}}function oo(e){let{cesdk:t,panelId:r}=e;r.startsWith("ly.img.ai.")||console.warn(`Dock components for AI generation should open a panel with an id starting with "ly.img.ai." \u2013 "${r}" was provided.`);let i=`${r}.dock`;t.ui.registerComponent(i,({builder:n})=>{let o=t.ui.isPanelOpen(r);n.Button(`${r}.dock.button`,{label:`${r}.dock.label`,isSelected:o,icon:"@imgly/Sparkle",onClick:()=>{t.ui.findAllPanels().forEach(a=>{a.startsWith("ly.img.ai.")&&t.ui.closePanel(a),!o&&a==="//ly.img.panel/assetLibrary"&&t.ui.closePanel(a)}),o?t.ui.closePanel(r):t.ui.openPanel(r)}})})}var ct=oo;function ao(e,t){let{cesdk:r,provider:i,getInput:n}=t;console.error("Generation failed:",e),so(r,i.output.notification,()=>({input:n?.().input,error:e}))||r.ui.showNotification({type:"error",message:to(e)})}function so(e,t,r){let i=t?.error;if(i==null||!(typeof i.show=="function"?i.show(r()):i.show))return!1;let n=typeof i.message=="function"?i.message(r()):i.message??"common.ai-generation.failed",o=i.action!=null?{label:typeof i.action.label=="function"?i.action.label(r()):i.action.label,onClick:()=>{i?.action?.onClick(r())}}:void 0;return e.ui.showNotification({type:"error",message:n,action:o}),!0}var Ye=ao,lo="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIzIiBoZWlnaHQ9IjMyMyIgdmlld0JveD0iMCAwIDMyMyAzMjMiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIzMjMiIGhlaWdodD0iMzIzIiBmaWxsPSIjRTlFQkVEIi8+CjxnIG9wYWNpdHk9IjAuMyI+CjxwYXRoIGQ9Ik0xMTYgMTg0VjE5MS41QzExNiAxOTkuNzg0IDEyMi43MTYgMjA2LjUgMTMxIDIwNi41SDE5MUMxOTkuMjg0IDIwNi41IDIwNiAxOTkuNzg0IDIwNiAxOTEuNVYxMzEuNUMyMDYgMTIzLjIxNiAxOTkuMjg0IDExNi41IDE5MSAxMTYuNUwxOTAuOTk1IDEyNi41QzE5My43NTcgMTI2LjUgMTk2IDEyOC43MzkgMTk2IDEzMS41VjE5MS41QzE5NiAxOTQuMjYxIDE5My43NjEgMTk2LjUgMTkxIDE5Ni41SDEzMUMxMjguMjM5IDE5Ni41IDEyNiAxOTQuMjYxIDEyNiAxOTEuNVYxODRIMTE2WiIgZmlsbD0iIzhGOEY4RiIvPgo8cGF0aCBkPSJNMTY2LjQ5NCAxMDUuOTI0QzE2NS44NjkgMTA0LjM0MiAxNjMuNjI5IDEwNC4zNDIgMTYzLjAwNSAxMDUuOTI0TDE1OS43NDUgMTE0LjE5MUMxNTkuNTU0IDExNC42NzQgMTU5LjE3MiAxMTUuMDU3IDE1OC42ODggMTE1LjI0N0wxNTAuNDIyIDExOC41MDhDMTQ4LjgzOSAxMTkuMTMyIDE0OC44MzkgMTIxLjM3MiAxNTAuNDIyIDEyMS45OTZMMTU4LjY4OCAxMjUuMjU2QzE1OS4xNzIgMTI1LjQ0NyAxNTkuNTU0IDEyNS44MjkgMTU5Ljc0NSAxMjYuMzEzTDE2My4wMDUgMTM0LjU3OUMxNjMuNjI5IDEzNi4xNjIgMTY1Ljg2OSAxMzYuMTYyIDE2Ni40OTQgMTM0LjU3OUwxNjkuNzU0IDEyNi4zMTNDMTY5Ljk0NCAxMjUuODI5IDE3MC4zMjcgMTI1LjQ0NyAxNzAuODEgMTI1LjI1NkwxNzkuMDc3IDEyMS45OTZDMTgwLjY2IDEyMS4zNzIgMTgwLjY2IDExOS4xMzIgMTc5LjA3NyAxMTguNTA4TDE3MC44MSAxMTUuMjQ3QzE3MC4zMjcgMTE1LjA1NyAxNjkuOTQ0IDExNC42NzQgMTY5Ljc1NCAxMTQuMTkxTDE2Ni40OTQgMTA1LjkyNFoiIGZpbGw9IiM4RjhGOEYiLz4KPHBhdGggZD0iTTEzMy4wMDUgMTI4LjQyNEMxMzMuNjI5IDEyNi44NDIgMTM1Ljg2OSAxMjYuODQyIDEzNi40OTQgMTI4LjQyNEwxNDEuODc1IDE0Mi4wN0MxNDIuMDY2IDE0Mi41NTMgMTQyLjQ0OCAxNDIuOTM1IDE0Mi45MzIgMTQzLjEyNkwxNTYuNTc3IDE0OC41MDhDMTU4LjE2IDE0OS4xMzIgMTU4LjE2IDE1MS4zNzIgMTU2LjU3NyAxNTEuOTk2TDE0Mi45MzIgMTU3LjM3OEMxNDIuNDQ4IDE1Ny41NjggMTQyLjA2NiAxNTcuOTUxIDE0MS44NzUgMTU4LjQzNEwxMzYuNDk0IDE3Mi4wNzlDMTM1Ljg2OSAxNzMuNjYyIDEzMy42MjkgMTczLjY2MiAxMzMuMDA1IDE3Mi4wNzlMMTI3LjYyMyAxNTguNDM0QzEyNy40MzMgMTU3Ljk1MSAxMjcuMDUgMTU3LjU2OCAxMjYuNTY3IDE1Ny4zNzhMMTEyLjkyMiAxNTEuOTk2QzExMS4zMzkgMTUxLjM3MiAxMTEuMzM5IDE0OS4xMzIgMTEyLjkyMiAxNDguNTA4TDEyNi41NjcgMTQzLjEyNkMxMjcuMDUgMTQyLjkzNSAxMjcuNDMzIDE0Mi41NTMgMTI3LjYyMyAxNDIuMDdMMTMzLjAwNSAxMjguNDI0WiIgZmlsbD0iIzhGOEY4RiIvPgo8cGF0aCBkPSJNMTk1Ljk5OSAxODQuMDA0VjE5MS41MDJDMTk1Ljk5OSAxOTQuMjYzIDE5My43NjEgMTk2LjUwMiAxOTAuOTk5IDE5Ni41MDJIMTQ3LjY2OEwxNzIuODc5IDE1OC42ODRDMTc0LjM2MyAxNTYuNDU4IDE3Ny42MzUgMTU2LjQ1OCAxNzkuMTIgMTU4LjY4NEwxOTUuOTk5IDE4NC4wMDRaIiBmaWxsPSIjOEY4RjhGIi8+CjwvZz4KPC9zdmc+Cg==",Se=lo;function uo(e,t,r){switch(t){case"image":return co(e,r[t]);case"video":return go(e,r[t]);case"sticker":return po(e,r[t]);default:throw new Error(`Unsupported output kind for creating placeholder block: ${t}`)}}function co(e,t){let r=t.width,i=t.height;return{id:e,meta:{previewUri:Se,fillType:"//ly.img.ubq/fill/image",kind:"image",width:r,height:i}}}function go(e,t){let r=t.width,i=t.height;return{id:e,label:t.label,meta:{previewUri:Se,mimeType:"video/mp4",kind:"video",fillType:"//ly.img.ubq/fill/video",duration:t.duration.toString(),width:r,height:i}}}function po(e,t){let r=t.width,i=t.height;return{id:e,meta:{previewUri:Se,fillType:"//ly.img.ubq/fill/image",kind:"sticker",width:r,height:i}}}var fo=uo;async function ho(e,t,r,i){switch(t){case"image":{if(i.kind!=="image")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: image)`);return mo(e,r[t],i)}case"video":{if(i.kind!=="video")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: video)`);return bo(e,r[t],i)}case"audio":{if(i.kind!=="audio")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: audio)`);return yo(e,r[t],i)}case"sticker":{if(i.kind!=="sticker")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: sticker)`);return vo(e,r[t],i)}default:throw new Error(`Unsupported output kind for creating placeholder block: ${t}`)}}function mo(e,t,r){let i=t.width,n=t.height;return{id:e,label:t.label,meta:{uri:r.url,thumbUri:r.url,fillType:"//ly.img.ubq/fill/image",kind:"image",width:i,height:n},payload:{sourceSet:[{uri:r.url,width:i,height:n}]}}}async function bo(e,t,r){let i=t.width,n=t.height,o=await ro(r.url,0);return{id:e,label:t.label,meta:{uri:r.url,thumbUri:o,mimeType:"video/mp4",kind:"video",fillType:"//ly.img.ubq/fill/video",duration:t.duration.toString(),width:i,height:n}}}function yo(e,t,r){return{id:e,label:t.label,meta:{uri:r.url,thumbUri:r.thumbnailUrl,blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:r.duration.toString()}}}function vo(e,t,r){let i=t.width,n=t.height;return{id:e,label:t.label,meta:{uri:r.url,thumbUri:r.url,fillType:"//ly.img.ubq/fill/image",kind:"sticker",width:i,height:n},payload:{sourceSet:[{uri:r.url,width:i,height:n}]}}}var dt=ho;function wo(e){switch(e.userFlow){case"placeholder":return Io(e);case"generation-only":return ko(e);default:throw new Error(`Unknown user flow: ${e.userFlow}. Expected 'placeholder' or 'generation-only'.`)}}function ko(e){let{cesdk:t,abortSignal:r}=e;return async i=>{try{let n=e.kind,o=await e.getBlockInput(i);if(A(t,r))return{status:"aborted"};let a=await e.generate(i,{middlewares:[...e.middlewares??[]],debug:e.debug,dryRun:e.dryRun,abortSignal:r});if(A(t,r))return{status:"aborted"};if(a.status!=="success")return a;if(a.type==="async")throw new Error("Async generation is not supported in this context yet.");if(A(t,r))return{status:"aborted"};if(e.historyAssetSourceId!=null){let s=st(),u=await dt(s,n,o,a.output),l={...u,id:`${Date.now()}-${u.id}`,label:u.label!=null?{en:u.label}:{},tags:{}};t.engine.asset.addAssetToSource(e.historyAssetSourceId,l)}else e.debug&&console.log("No asset source ID found in history and generation only was requested. Doing nothing. If no middleware is adding functionality this could be a bug.");return a}catch(n){return{status:"error",message:n instanceof Error?n.message:String(n)}}}}function Io(e){let{cesdk:t,abortSignal:r}=e,i;return async n=>{try{let o=e.kind,a=await e.getBlockInput(n);if(A(t,r))return{status:"aborted"};let s=st(),u=fo(s,o,a);if(i=await eo(t,u),A(t,r,i))return{status:"aborted"};if(i!=null&&e.kind==="video"){let d=t.engine.block.getPositionX(i),g=t.engine.block.getPositionY(i),p=t.engine.block.duplicate(i);t.engine.block.setPositionX(p,d),t.engine.block.setPositionY(p,g),t.engine.block.destroy(i),i=p}if(i==null)throw new Error("Could not create placeholder block");t.engine.block.setState(i,{type:"Pending",progress:0});let l=await e.generate(n,{middlewares:[...e.middlewares??[]],debug:e.debug,dryRun:e.dryRun,abortSignal:r});if(A(t,r,i))return{status:"aborted"};if(l.status!=="success")return l;if(l.type==="async")throw new Error("Async generation is not supported in this context yet.");if(!t.engine.block.isValid(i))return{status:"aborted",message:"Placeholder block was destroyed before generation completed."};let c=await dt(s,o,a,l.output);if(A(t,r,i))return{status:"aborted"};if(e.debug&&console.log("Updating placeholder in scene:",JSON.stringify(c,void 0,2)),await t.engine.asset.defaultApplyAssetToBlock(c,i),A(t,r,i))return{status:"aborted"};if(e.historyAssetSourceId!=null){let d={...c,id:`${Date.now()}-${c.id}`,label:c.label!=null?{en:c.label}:{},tags:{}};t.engine.asset.addAssetToSource(e.historyAssetSourceId,d)}return t.engine.block.isValid(i)&&t.engine.block.setState(i,{type:"Ready"}),l}catch(o){return i!=null&&t.engine.block.isValid(i)&&(Ce(o)?t.engine.block.destroy(i):t.engine.block.setState(i,{type:"Error",error:"Unknown"})),{status:"error",message:o instanceof Error?o.message:String(o)}}}}function A(e,t,r){return t.aborted?(r!=null&&e.engine.block.isValid(r)&&e.engine.block.destroy(r),!0):!1}var Co=wo;function Ae(e){return`${e}.generating`}function So(e){return`${e}.abort`}function Ao(e,t,r,i,n,o,a){let{builder:s,experimental:u}=e,{cesdk:l,includeHistoryLibrary:c=!0}=o,{id:d,output:{abortable:g}}=t,p=u.global(So(d),()=>{}),h=u.global(Ae(d),!1),b,m=h.value&&g,f=()=>{m&&(p.value(),h.setValue(!1),p.setValue(()=>{}))},L;if(o.requiredInputs!=null&&o.requiredInputs.length>0){let I=i();L=o.requiredInputs.every(k=>!I.input[k])}let y=u.global(`${d}.confirmationDialogId`,void 0);s.Section(`${d}.generate.section`,{children:()=>{s.Button(`${d}.generate`,{label:["common.generate",`panel.${d}.generate`],isLoading:h.value,color:"accent",isDisabled:L,suffix:m?{icon:"@imgly/Cross",color:"danger",tooltip:[`panel.${d}.abort`,"common.cancel"],onClick:()=>{let I=l.ui.showDialog({type:"warning",content:"panel.ly.img.ai.generation.confirmCancel.content",cancel:{label:"common.close",onClick:({id:k})=>{l.ui.closeDialog(k),y.setValue(void 0)}},actions:{label:"panel.ly.img.ai.generation.confirmCancel.confirm",color:"danger",onClick:({id:k})=>{f(),l.ui.closeDialog(k),y.setValue(void 0)}}});y.setValue(I)}}:void 0,onClick:async()=>{b=new AbortController;let I=b.signal;await(async()=>{try{h.setValue(!0),p.setValue(()=>{a.debug&&console.log("Aborting generation"),b?.abort()});let k=await Co({kind:t.kind,generate:r,historyAssetSourceId:o.historyAssetSourceId,userFlow:o.createPlaceholderBlock?"placeholder":"generation-only",getBlockInput:n,abortSignal:I,cesdk:l,debug:a.debug,dryRun:a.dryRun})(i().input);if(k.status==="aborted")return;if(k.status==="error"){Ye(k.message,{cesdk:l,provider:t,getInput:i});return}if(k.status==="success"&&k.type==="sync"){let M=t.output.notification;xo(l,M,()=>({input:i().input,output:k.output}))}}catch(k){if(Ce(k))return;Ye(k,{cesdk:l,provider:t,getInput:i})}finally{b=void 0,h.setValue(!1),p.setValue(()=>{}),y.value!=null&&(l.ui.closeDialog(y.value),y.setValue(void 0))}})()}}),t.output.generationHintText!=null&&s.Text(`${d}.generation-hint`,{align:"center",content:t.output.generationHintText})}}),c&&o.historyAssetLibraryEntryId!=null&&s.Library(`${d}.history.library`,{entries:[o.historyAssetLibraryEntryId]})}function xo(e,t,r){let i=t?.success;if(i==null||!(typeof i.show=="function"?i.show(r()):i.show))return!1;let n=typeof i.message=="function"?i.message(r()):i.message??"common.ai-generation.success",o=i.action!=null?{label:typeof i.action.label=="function"?i.action.label(r()):i.action.label,onClick:()=>{i?.action?.onClick(r())}}:void 0;return e.ui.showNotification({type:"success",message:n,action:o,duration:i.duration}),!0}var gt=Ao;async function Mo({options:e,provider:t,panelInput:r,config:i},n){if(r==null)return;let{cesdk:o}=e,{id:a}=t,s=r.render;return u=>{let{state:l}=u,c=l(Ae(a),{isGenerating:!1,abort:()=>{}}).value.isGenerating,{getInput:d,getBlockInput:g}=s(u,{cesdk:o,isGenerating:c});return gt(u,t,n,d,g,{...e,includeHistoryLibrary:r.includeHistoryLibrary??!0,createPlaceholderBlock:r.userFlow==="placeholder"},i),d}}var Eo=Mo;function pt(e,t){if(!t.startsWith("#/"))throw new Error(`External references are not supported: ${t}`);let r=t.substring(2).split("/"),i=e;for(let n of r){if(i==null)throw new Error(`Invalid reference path: ${t}`);i=i[n]}if(i===void 0)throw new Error(`Reference not found: ${t}`);return i}function Z(e,t,r=new Set){if(t==null||r.has(t))return t;if(r.add(t),t.$ref&&typeof t.$ref=="string"){let i=pt(e,t.$ref),n={...Z(e,i,r)};for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&o!=="$ref"&&(n[o]=Z(e,t[o],r));return n}if(Array.isArray(t))return t.map(i=>Z(e,i,r));if(typeof t=="object"){let i={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=Z(e,t[n],r));return i}return t}function jo(e){return Z(e,{...e})}function _o(e,t=!1){let r=a=>(t&&console.log(`OpenAPI Schema validation failed: ${a}`),!1);if(typeof e!="object"||e===null)return r(`Input is ${e===null?"null":typeof e}, not an object`);let i=e;if(!(typeof i.type=="string"||Array.isArray(i.enum)||typeof i.properties=="object"||typeof i.items=="object"||typeof i.allOf=="object"||typeof i.anyOf=="object"||typeof i.oneOf=="object"||typeof i.not=="object"))return r("Missing required schema-defining properties (type, enum, properties, items, allOf, anyOf, oneOf, not)");if(i.type!==void 0){let a=["string","number","integer","boolean","array","object","null"];if(typeof i.type=="string"){if(!a.includes(i.type))return r(`Invalid type: ${i.type}. Must be one of ${a.join(", ")}`)}else if(Array.isArray(i.type)){for(let s of i.type)if(typeof s!="string"||!a.includes(s))return r(`Array of types contains invalid value: ${s}. Must be one of ${a.join(", ")}`)}else return r(`Type must be a string or array of strings, got ${typeof i.type}`)}if(i.items!==void 0&&(typeof i.items!="object"||i.items===null))return r(`Items must be an object, got ${i.items===null?"null":typeof i.items}`);if(i.properties!==void 0&&(typeof i.properties!="object"||i.properties===null))return r(`Properties must be an object, got ${i.properties===null?"null":typeof i.properties}`);let n=["allOf","anyOf","oneOf"];for(let a of n)if(i[a]!==void 0){if(!Array.isArray(i[a]))return r(`${a} must be an array, got ${typeof i[a]}`);for(let s=0;s<i[a].length;s++){let u=i[a][s];if(typeof u!="object"||u===null)return r(`Item ${s} in ${a} must be an object, got ${u===null?"null":typeof u}`)}}if(i.not!==void 0&&(typeof i.not!="object"||i.not===null))return r(`'not' must be an object, got ${i.not===null?"null":typeof i.not}`);if(i.additionalProperties!==void 0&&typeof i.additionalProperties!="boolean"&&(typeof i.additionalProperties!="object"||i.additionalProperties===null))return r(`additionalProperties must be a boolean or an object, got ${i.additionalProperties===null?"null":typeof i.additionalProperties}`);if(i.format!==void 0&&typeof i.format!="string")return r(`format must be a string, got ${typeof i.format}`);let o=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf"];for(let a of o)if(i[a]!==void 0&&typeof i[a]!="number")return r(`${a} must be a number, got ${typeof i[a]}`);if(i.minLength!==void 0&&(typeof i.minLength!="number"||i.minLength<0))return r(`minLength must be a non-negative number, got ${typeof i.minLength=="number"?i.minLength:typeof i.minLength}`);if(i.maxLength!==void 0&&(typeof i.maxLength!="number"||i.maxLength<0))return r(`maxLength must be a non-negative number, got ${typeof i.maxLength=="number"?i.maxLength:typeof i.maxLength}`);if(i.pattern!==void 0&&typeof i.pattern!="string")return r(`pattern must be a string, got ${typeof i.pattern}`);if(i.minItems!==void 0&&(typeof i.minItems!="number"||i.minItems<0))return r(`minItems must be a non-negative number, got ${typeof i.minItems=="number"?i.minItems:typeof i.minItems}`);if(i.maxItems!==void 0&&(typeof i.maxItems!="number"||i.maxItems<0))return r(`maxItems must be a non-negative number, got ${typeof i.maxItems=="number"?i.maxItems:typeof i.maxItems}`);if(i.uniqueItems!==void 0&&typeof i.uniqueItems!="boolean")return r(`uniqueItems must be a boolean, got ${typeof i.uniqueItems}`);if(i.minProperties!==void 0&&(typeof i.minProperties!="number"||i.minProperties<0))return r(`minProperties must be a non-negative number, got ${typeof i.minProperties=="number"?i.minProperties:typeof i.minProperties}`);if(i.maxProperties!==void 0&&(typeof i.maxProperties!="number"||i.maxProperties<0))return r(`maxProperties must be a non-negative number, got ${typeof i.maxProperties=="number"?i.maxProperties:typeof i.maxProperties}`);if(i.required!==void 0){if(!Array.isArray(i.required))return r(`required must be an array, got ${typeof i.required}`);for(let a=0;a<i.required.length;a++){let s=i.required[a];if(typeof s!="string")return r(`Item ${a} in required array must be a string, got ${typeof s}`)}}return!0}function Lo(e,t){if(e.properties==null)throw new Error("Input schema must have properties");let r=e.properties,i=[];return No(e,t).forEach(n=>{let o=n,a=r[n]??void 0;i.push({id:o,schema:a})}),i}function No(e,t){let r=t.order;if(r!=null&&Array.isArray(r))return r;if(e.properties==null)throw new Error("Input schema must have properties");let i=e.properties,n=Object.keys(i),o=Oo(e,t)??n;return r!=null&&typeof r=="function"&&(o=r(o)),[...new Set(o)]}function Oo(e,t){if(t.orderExtensionKeyword==null)return;if(typeof t.orderExtensionKeyword!="string"&&!Array.isArray(t.orderExtensionKeyword))throw new Error("orderExtensionKeyword must be a string or an array of strings");let r=(typeof t.orderExtensionKeyword=="string"?[t.orderExtensionKeyword]:t.orderExtensionKeyword).find(i=>i in e);return r==null?void 0:e[r]}var ft=Lo;function ht(e,t,r,i,n,o){if(t.schema==null)return i.renderCustomProperty!=null&&i.renderCustomProperty[t.id]!=null?i.renderCustomProperty[t.id](e,t):void 0;let a=t,s=t.schema.type;if(i.renderCustomProperty!=null&&i.renderCustomProperty[t.id]!=null)return i.renderCustomProperty[t.id](e,t);switch(s){case"string":return t.schema.enum!=null?Po(e,a,r,i,n,o):bt(e,a,r,i,n,o);case"boolean":return yt(e,a,r,i,n,o);case"number":case"integer":return vt(e,a,r,i,n,o);case"object":return mt(e,a,r,i,n,o);case"array":break;case void 0:{if(t.schema.anyOf!=null&&Array.isArray(t.schema.anyOf))return $o(e,a,r,i,n,o);break}default:console.error(`Unsupported property type: ${s}`)}}function mt(e,t,r,i,n,o){let a=ft(t.schema??{},i).reduce((s,u)=>{let l=ht(e,u,r,i,n,o);return l!=null&&(s[u.id]=l()),s},{});return()=>({id:t.id,type:"object",value:a})}function bt(e,t,r,i,n,o){let{builder:a,experimental:{global:s}}=e,{id:u}=t,l=`${r.id}.${u}`,c=t.schema.title??l,d=s(l,t.schema.default??""),g=Do(t.schema),p=g?.component!=null&&g?.component==="TextArea"?"TextArea":"TextInput";return a[p](l,{inputLabel:c,placeholder:n.i18n?.prompt,...d}),()=>({id:t.id,type:"string",value:d.value})}function Po(e,t,r,i,n,o){let{builder:a,experimental:{global:s}}=e,{id:u}=t,l=`${r.id}.${u}`,c=t.schema.title??l,d=t.schema.enum!=null&&"x-imgly-enum-labels"in t.schema.enum&&typeof t.schema.enum["x-imgly-enum-labels"]=="object"?t.schema.enum["x-imgly-enum-labels"]:"x-imgly-enum-labels"in t.schema&&typeof t.schema["x-imgly-enum-labels"]=="object"?t.schema["x-imgly-enum-labels"]:{},g="x-imgly-enum-icons"in t.schema&&typeof t.schema["x-imgly-enum-icons"]=="object"?t.schema["x-imgly-enum-icons"]:{},p=(t.schema.enum??[]).map(m=>({id:m,label:d[m]??lt(m),icon:g[m]})),h=t.schema.default!=null?p.find(m=>m.id===t.schema.default)??p[0]:p[0],b=s(l,h);return a.Select(l,{inputLabel:c,values:p,...b}),()=>({id:t.id,type:"string",value:b.value.id})}function yt(e,t,r,i,n,o){let{builder:a,experimental:{global:s}}=e,{id:u}=t,l=`${r.id}.${u}`,c=t.schema.title??l,d=!!t.schema.default,g=s(l,d);return a.Checkbox(l,{inputLabel:c,...g}),()=>({id:t.id,type:"boolean",value:g.value})}function vt(e,t,r,i,n,o){let{builder:a,experimental:{global:s}}=e,{id:u}=t,l=`${r.id}.${u}`,c=t.schema.title??l,d=t.schema.minimum,g=t.schema.maximum,p=t.schema.default;p==null&&(d!=null?p=d:g!=null?p=g:p=0);let h=s(l,p);if(d!=null&&g!=null){let b=t.schema.type==="number"?.1:1;"x-imgly-step"in t.schema&&typeof t.schema["x-imgly-step"]=="number"&&(b=t.schema["x-imgly-step"]),a.Slider(l,{inputLabel:c,min:d,max:g,step:b,...h})}else a.NumberInput(l,{inputLabel:c,min:d,max:g,...h});return()=>({id:t.id,type:"integer",value:h.value})}function $o(e,t,r,i,n,o){let{builder:a,experimental:{global:s}}=e,{id:u}=t,l=`${r.id}.${u}`,c=t.schema.title??l,d=t.schema.anyOf??[],g=[],p={},h={};d.forEach((f,L)=>{let y=f.title??"common.custom",I=`${r.id}.${u}.anyOf[${L}]`,k="x-imgly-enum-labels"in t.schema&&typeof t.schema["x-imgly-enum-labels"]=="object"?t.schema["x-imgly-enum-labels"]:{},M="x-imgly-enum-icons"in t.schema&&typeof t.schema["x-imgly-enum-icons"]=="object"?t.schema["x-imgly-enum-icons"]:{};f.type==="string"?f.enum!=null?f.enum.forEach(oe=>{g.push({id:oe,label:k[oe]??lt(oe),icon:M[oe]})}):(p[I]=()=>bt(e,{id:I,schema:{...f,title:y}},r,i,n,o),g.push({id:I,label:k[y]??y,icon:M[y]})):f.type==="boolean"?(p[I]=()=>yt(e,{id:I,schema:{...f,title:y}},r,i,n,o),g.push({id:I,label:k[y]??y,icon:M[y]})):f.type==="integer"?(p[I]=()=>vt(e,{id:I,schema:{...f,title:y}},r,i,n,o),g.push({id:I,label:k[y]??y,icon:M[y]})):f.type==="array"||f.type==="object"&&(p[I]=()=>mt(e,{id:I,schema:{...f,title:y}},r,i,n,o),g.push({id:I,label:k[y]??y,icon:M[y]}))});let b=t.schema.default!=null?g.find(f=>f.id===t.schema.default)??g[0]:g[0],m=s(l,b);if(a.Select(l,{inputLabel:c,values:g,...m}),m.value.id in p){let f=p[m.value.id]();h[m.value.id]=f}return()=>{let f=h[m.value.id];return f!=null?{...f(),id:t.id}:{id:t.id,type:"string",value:m.value.id}}}function Do(e){if("x-imgly-builder"in e)return e["x-imgly-builder"]}var To=ht;async function zo({options:e,provider:t,panelInput:r,config:i},n){let{id:o}=t;if(r==null)return;i.debug&&console.log(`Registering schema-based panel input for provider ${o}`);let a=jo(r.document),s=pt(a,r.inputReference);if(!_o(s,i.debug))throw new Error(`Input reference '${r.inputReference}' does not resolve to a valid OpenAPI schema`);let u=s,l=ft(u,r);return c=>{let{builder:d}=c,g=[];d.Section(`${o}.schema.section`,{children:()=>{l.forEach(m=>{let f=To(c,m,t,r,e,i);f!=null&&(Array.isArray(f)?g.push(...f):g.push(f))})}});let p=g.map(m=>m()),h=m=>m.type==="object"?Object.entries(m.value).reduce((f,[L,y])=>(f[L]=h(y),f),{}):m.value,b=p.reduce((m,f)=>(m[f.id]=h(f),m),{});gt(c,t,n,()=>({input:b}),()=>r.getBlockInput(b),{...e,requiredInputs:u.required,createPlaceholderBlock:r.userFlow==="placeholder"},i)}}var Ro=zo;async function Fo(e,t){if(e.panelInput!=null)switch(e.panelInput.type){case"custom":return Eo(e,t);case"schema":return Ro(e,t);default:e.config.debug&&console.warn(`Invalid panel input type '${panelInput.type}' - skipping`)}}var Uo=Fo;function Vo(e){let{provider:t,options:{engine:r}}=e,i=t.output.history??"@imgly/local";if(i==null||i===!1)return;let n=r.asset.findAllSources();function o(){let a=`${t.id}.history`;for(;n.includes(a);)a+=`-${Math.random().toString(36).substring(2,6)}`;return a}if(i==="@imgly/local"){let a=o();return r.asset.addLocalSource(a),a}if(i==="@imgly/indexedDB"){let a=o();return r.asset.addSource(new Zt(a,r)),a}return i}var Bo=Vo;function Go(e,t){if(t==null||!t)return;let r=`${e.provider.id}.history`;return e.options.cesdk.ui.addAssetLibraryEntry({id:r,sourceIds:[t],sortBy:{sortKey:"insertedAt",sortingOrder:"Descending"},canRemove:!0,gridItemHeight:"square",gridBackgroundType:"cover"}),r}var Ho=Go,he="@imgly/plugin-ai-generation",qo=`
|
|
4
|
+
Consider updating all AI plugins to the same version for optimal compatibility.`),e.ui.experimental.setGlobalStateValue(n,!0))):e.ui.experimental.setGlobalStateValue(i,r)}catch(a){console.debug("[IMG.LY AI Plugins] Could not check plugin version consistency:",a)}}function po(e){let{cesdk:t,panelId:r}=e;r.startsWith("ly.img.ai.")||console.warn(`Dock components for AI generation should open a panel with an id starting with "ly.img.ai." \u2013 "${r}" was provided.`);let i=`${r}.dock`;t.ui.registerComponent(i,({builder:n})=>{let a=t.ui.isPanelOpen(r);n.Button(`${r}.dock.button`,{label:`${r}.dock.label`,isSelected:a,icon:"@imgly/Sparkle",onClick:()=>{t.ui.findAllPanels().forEach(o=>{o.startsWith("ly.img.ai.")&&t.ui.closePanel(o),!a&&o==="//ly.img.panel/assetLibrary"&&t.ui.closePanel(o)}),a?t.ui.closePanel(r):t.ui.openPanel(r)}})})}var bt=po;function fo(e,t){let{cesdk:r,provider:i,getInput:n}=t;console.error("Generation failed:",e),mo(r,i.output.notification,()=>({input:n?.().input,error:e}))||r.ui.showNotification({type:"error",message:lo(e)})}function mo(e,t,r){let i=t?.error;if(i==null||!(typeof i.show=="function"?i.show(r()):i.show))return!1;let n=typeof i.message=="function"?i.message(r()):i.message??"common.ai-generation.failed",a=i.action!=null?{label:typeof i.action.label=="function"?i.action.label(r()):i.action.label,onClick:()=>{i?.action?.onClick(r())}}:void 0;return e.ui.showNotification({type:"error",message:n,action:a}),!0}var tt=fo,ho="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIzIiBoZWlnaHQ9IjMyMyIgdmlld0JveD0iMCAwIDMyMyAzMjMiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIzMjMiIGhlaWdodD0iMzIzIiBmaWxsPSIjRTlFQkVEIi8+CjxnIG9wYWNpdHk9IjAuMyI+CjxwYXRoIGQ9Ik0xMTYgMTg0VjE5MS41QzExNiAxOTkuNzg0IDEyMi43MTYgMjA2LjUgMTMxIDIwNi41SDE5MUMxOTkuMjg0IDIwNi41IDIwNiAxOTkuNzg0IDIwNiAxOTEuNVYxMzEuNUMyMDYgMTIzLjIxNiAxOTkuMjg0IDExNi41IDE5MSAxMTYuNUwxOTAuOTk1IDEyNi41QzE5My43NTcgMTI2LjUgMTk2IDEyOC43MzkgMTk2IDEzMS41VjE5MS41QzE5NiAxOTQuMjYxIDE5My43NjEgMTk2LjUgMTkxIDE5Ni41SDEzMUMxMjguMjM5IDE5Ni41IDEyNiAxOTQuMjYxIDEyNiAxOTEuNVYxODRIMTE2WiIgZmlsbD0iIzhGOEY4RiIvPgo8cGF0aCBkPSJNMTY2LjQ5NCAxMDUuOTI0QzE2NS44NjkgMTA0LjM0MiAxNjMuNjI5IDEwNC4zNDIgMTYzLjAwNSAxMDUuOTI0TDE1OS43NDUgMTE0LjE5MUMxNTkuNTU0IDExNC42NzQgMTU5LjE3MiAxMTUuMDU3IDE1OC42ODggMTE1LjI0N0wxNTAuNDIyIDExOC41MDhDMTQ4LjgzOSAxMTkuMTMyIDE0OC44MzkgMTIxLjM3MiAxNTAuNDIyIDEyMS45OTZMMTU4LjY4OCAxMjUuMjU2QzE1OS4xNzIgMTI1LjQ0NyAxNTkuNTU0IDEyNS44MjkgMTU5Ljc0NSAxMjYuMzEzTDE2My4wMDUgMTM0LjU3OUMxNjMuNjI5IDEzNi4xNjIgMTY1Ljg2OSAxMzYuMTYyIDE2Ni40OTQgMTM0LjU3OUwxNjkuNzU0IDEyNi4zMTNDMTY5Ljk0NCAxMjUuODI5IDE3MC4zMjcgMTI1LjQ0NyAxNzAuODEgMTI1LjI1NkwxNzkuMDc3IDEyMS45OTZDMTgwLjY2IDEyMS4zNzIgMTgwLjY2IDExOS4xMzIgMTc5LjA3NyAxMTguNTA4TDE3MC44MSAxMTUuMjQ3QzE3MC4zMjcgMTE1LjA1NyAxNjkuOTQ0IDExNC42NzQgMTY5Ljc1NCAxMTQuMTkxTDE2Ni40OTQgMTA1LjkyNFoiIGZpbGw9IiM4RjhGOEYiLz4KPHBhdGggZD0iTTEzMy4wMDUgMTI4LjQyNEMxMzMuNjI5IDEyNi44NDIgMTM1Ljg2OSAxMjYuODQyIDEzNi40OTQgMTI4LjQyNEwxNDEuODc1IDE0Mi4wN0MxNDIuMDY2IDE0Mi41NTMgMTQyLjQ0OCAxNDIuOTM1IDE0Mi45MzIgMTQzLjEyNkwxNTYuNTc3IDE0OC41MDhDMTU4LjE2IDE0OS4xMzIgMTU4LjE2IDE1MS4zNzIgMTU2LjU3NyAxNTEuOTk2TDE0Mi45MzIgMTU3LjM3OEMxNDIuNDQ4IDE1Ny41NjggMTQyLjA2NiAxNTcuOTUxIDE0MS44NzUgMTU4LjQzNEwxMzYuNDk0IDE3Mi4wNzlDMTM1Ljg2OSAxNzMuNjYyIDEzMy42MjkgMTczLjY2MiAxMzMuMDA1IDE3Mi4wNzlMMTI3LjYyMyAxNTguNDM0QzEyNy40MzMgMTU3Ljk1MSAxMjcuMDUgMTU3LjU2OCAxMjYuNTY3IDE1Ny4zNzhMMTEyLjkyMiAxNTEuOTk2QzExMS4zMzkgMTUxLjM3MiAxMTEuMzM5IDE0OS4xMzIgMTEyLjkyMiAxNDguNTA4TDEyNi41NjcgMTQzLjEyNkMxMjcuMDUgMTQyLjkzNSAxMjcuNDMzIDE0Mi41NTMgMTI3LjYyMyAxNDIuMDdMMTMzLjAwNSAxMjguNDI0WiIgZmlsbD0iIzhGOEY4RiIvPgo8cGF0aCBkPSJNMTk1Ljk5OSAxODQuMDA0VjE5MS41MDJDMTk1Ljk5OSAxOTQuMjYzIDE5My43NjEgMTk2LjUwMiAxOTAuOTk5IDE5Ni41MDJIMTQ3LjY2OEwxNzIuODc5IDE1OC42ODRDMTc0LjM2MyAxNTYuNDU4IDE3Ny42MzUgMTU2LjQ1OCAxNzkuMTIgMTU4LjY4NEwxOTUuOTk5IDE4NC4wMDRaIiBmaWxsPSIjOEY4RjhGIi8+CjwvZz4KPC9zdmc+Cg==",Le=ho;function bo(e,t,r){switch(t){case"image":return yo(e,r[t]);case"video":return vo(e,r[t]);case"sticker":return wo(e,r[t]);default:throw new Error(`Unsupported output kind for creating placeholder block: ${t}`)}}function yo(e,t){let r=t.width,i=t.height;return{id:e,meta:{previewUri:Le,fillType:"//ly.img.ubq/fill/image",kind:"image",width:r,height:i}}}function vo(e,t){let r=t.width,i=t.height;return{id:e,label:t.label,meta:{previewUri:Le,mimeType:"video/mp4",kind:"video",fillType:"//ly.img.ubq/fill/video",duration:t.duration.toString(),width:r,height:i}}}function wo(e,t){let r=t.width,i=t.height;return{id:e,meta:{previewUri:Le,fillType:"//ly.img.ubq/fill/image",kind:"sticker",width:r,height:i}}}var ko=bo;async function Io(e,t,r,i){switch(t){case"image":{if(i.kind!=="image")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: image)`);return Co(e,r[t],i)}case"video":{if(i.kind!=="video")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: video)`);return So(e,r[t],i)}case"audio":{if(i.kind!=="audio")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: audio)`);return Ao(e,r[t],i)}case"sticker":{if(i.kind!=="sticker")throw new Error(`Output kind does not match the expected type: ${i.kind} (expected: sticker)`);return xo(e,r[t],i)}default:throw new Error(`Unsupported output kind for creating placeholder block: ${t}`)}}function Co(e,t,r){let i=t.width,n=t.height;return{id:e,label:t.label,meta:{uri:r.url,thumbUri:r.url,fillType:"//ly.img.ubq/fill/image",kind:"image",width:i,height:n},payload:{sourceSet:[{uri:r.url,width:i,height:n}]}}}async function So(e,t,r){let i=t.width,n=t.height,a=await uo(r.url,0);return{id:e,label:t.label,meta:{uri:r.url,thumbUri:a,mimeType:"video/mp4",kind:"video",fillType:"//ly.img.ubq/fill/video",duration:t.duration.toString(),width:i,height:n}}}function Ao(e,t,r){return{id:e,label:t.label,meta:{uri:r.url,thumbUri:r.thumbnailUrl,blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:r.duration.toString()}}}function xo(e,t,r){let i=t.width,n=t.height;return{id:e,label:t.label,meta:{uri:r.url,thumbUri:r.url,fillType:"//ly.img.ubq/fill/image",kind:"sticker",width:i,height:n},payload:{sourceSet:[{uri:r.url,width:i,height:n}]}}}var yt=Io;function Eo(e){switch(e.userFlow){case"placeholder":return jo(e);case"generation-only":return Mo(e);default:throw new Error(`Unknown user flow: ${e.userFlow}. Expected 'placeholder' or 'generation-only'.`)}}function Mo(e){let{cesdk:t,abortSignal:r}=e;return async i=>{try{let n=e.kind,a=await e.getBlockInput(i);if(j(t,r))return{status:"aborted"};let o=await e.generate(i,{middlewares:[...e.middlewares??[]],debug:e.debug,dryRun:e.dryRun,abortSignal:r});if(j(t,r))return{status:"aborted"};if(o.status!=="success")return o;if(o.type==="async")throw new Error("Async generation is not supported in this context yet.");if(j(t,r))return{status:"aborted"};if(e.historyAssetSourceId!=null){let l=mt(),u=await yt(l,n,a,o.output),s={...u,id:`${Date.now()}-${u.id}`,label:u.label!=null?{en:u.label}:{},tags:{}};t.engine.asset.addAssetToSource(e.historyAssetSourceId,s)}else e.debug&&console.log("No asset source ID found in history and generation only was requested. Doing nothing. If no middleware is adding functionality this could be a bug.");return o}catch(n){return{status:"error",message:n instanceof Error?n.message:String(n)}}}}function jo(e){let{cesdk:t,abortSignal:r}=e,i;return async n=>{try{let a=e.kind,o=await e.getBlockInput(n);if(j(t,r))return{status:"aborted"};let l=mt(),u=ko(l,a,o);if(i=await so(t,u),j(t,r,i))return{status:"aborted"};if(i!=null&&e.kind==="video"){let g=t.engine.block.getPositionX(i),p=t.engine.block.getPositionY(i),d=t.engine.block.duplicate(i);t.engine.block.setPositionX(d,g),t.engine.block.setPositionY(d,p),t.engine.block.destroy(i),i=d}if(i==null)throw new Error("Could not create placeholder block");t.engine.block.setState(i,{type:"Pending",progress:0});let s=await e.generate(n,{middlewares:[...e.middlewares??[]],debug:e.debug,dryRun:e.dryRun,abortSignal:r});if(j(t,r,i))return{status:"aborted"};if(s.status!=="success")return s;if(s.type==="async")throw new Error("Async generation is not supported in this context yet.");if(!t.engine.block.isValid(i))return{status:"aborted",message:"Placeholder block was destroyed before generation completed."};let c=await yt(l,a,o,s.output);if(j(t,r,i))return{status:"aborted"};if(e.debug&&console.log("Updating placeholder in scene:",JSON.stringify(c,void 0,2)),await t.engine.asset.defaultApplyAssetToBlock(c,i),j(t,r,i))return{status:"aborted"};if(e.historyAssetSourceId!=null){let g={...c,id:`${Date.now()}-${c.id}`,label:c.label!=null?{en:c.label}:{},tags:{}};t.engine.asset.addAssetToSource(e.historyAssetSourceId,g)}return t.engine.block.isValid(i)&&t.engine.block.setState(i,{type:"Ready"}),s}catch(a){return i!=null&&t.engine.block.isValid(i)&&(_e(a)?t.engine.block.destroy(i):t.engine.block.setState(i,{type:"Error",error:"Unknown"})),{status:"error",message:a instanceof Error?a.message:String(a)}}}}function j(e,t,r){return t.aborted?(r!=null&&e.engine.block.isValid(r)&&e.engine.block.destroy(r),!0):!1}var _o=Eo;function $e(e){return`${e}.generating`}function Lo(e){return`${e}.abort`}function $o(e,t,r,i,n,a,o){let{builder:l,experimental:u}=e,{cesdk:s,includeHistoryLibrary:c=!0}=a,{id:g,output:{abortable:p}}=t,d=u.global(Lo(g),()=>{}),m=u.global($e(g),!1),f,b=m.value&&p,y=()=>{b&&(d.value(),m.setValue(!1),d.setValue(()=>{}))},L;if(a.requiredInputs!=null&&a.requiredInputs.length>0){let C=i();L=a.requiredInputs.every(k=>!C.input[k])}let I=u.global(`${g}.confirmationDialogId`,void 0);l.Section(`${g}.generate.section`,{children:()=>{l.Button(`${g}.generate`,{label:["common.generate",`panel.${g}.generate`],isLoading:m.value,color:"accent",isDisabled:L,suffix:b?{icon:"@imgly/Cross",color:"danger",tooltip:[`panel.${g}.abort`,"common.cancel"],onClick:()=>{let C=s.ui.showDialog({type:"warning",content:"panel.ly.img.ai.generation.confirmCancel.content",cancel:{label:"common.close",onClick:({id:k})=>{s.ui.closeDialog(k),I.setValue(void 0)}},actions:{label:"panel.ly.img.ai.generation.confirmCancel.confirm",color:"danger",onClick:({id:k})=>{y(),s.ui.closeDialog(k),I.setValue(void 0)}}});I.setValue(C)}}:void 0,onClick:async()=>{f=new AbortController;let C=f.signal;await(async()=>{try{m.setValue(!0),d.setValue(()=>{o.debug&&console.log("Aborting generation"),f?.abort()});let k=await _o({kind:t.kind,generate:r,historyAssetSourceId:a.historyAssetSourceId,userFlow:a.createPlaceholderBlock?"placeholder":"generation-only",getBlockInput:n,abortSignal:C,cesdk:s,debug:o.debug,dryRun:o.dryRun})(i().input);if(k.status==="aborted")return;if(k.status==="error"){tt(k.message,{cesdk:s,provider:t,getInput:i});return}if(k.status==="success"&&k.type==="sync"){let x=t.output.notification;No(s,x,()=>({input:i().input,output:k.output}))}}catch(k){if(_e(k))return;tt(k,{cesdk:s,provider:t,getInput:i})}finally{f=void 0,m.setValue(!1),d.setValue(()=>{}),I.value!=null&&(s.ui.closeDialog(I.value),I.setValue(void 0))}})()}}),t.output.generationHintText!=null&&l.Text(`${g}.generation-hint`,{align:"center",content:t.output.generationHintText})}}),c&&a.historyAssetLibraryEntryId!=null&&l.Library(`${g}.history.library`,{entries:[a.historyAssetLibraryEntryId]})}function No(e,t,r){let i=t?.success;if(i==null||!(typeof i.show=="function"?i.show(r()):i.show))return!1;let n=typeof i.message=="function"?i.message(r()):i.message??"common.ai-generation.success",a=i.action!=null?{label:typeof i.action.label=="function"?i.action.label(r()):i.action.label,onClick:()=>{i?.action?.onClick(r())}}:void 0;return e.ui.showNotification({type:"success",message:n,action:a,duration:i.duration}),!0}var vt=$o;async function Po({options:e,provider:t,panelInput:r,config:i},n){if(r==null)return;let{cesdk:a}=e,{id:o}=t,l=r.render;return u=>{let{state:s}=u,c=s($e(o),{isGenerating:!1,abort:()=>{}}).value.isGenerating,{getInput:g,getBlockInput:p}=l(u,{cesdk:a,isGenerating:c});return vt(u,t,n,g,p,{...e,includeHistoryLibrary:r.includeHistoryLibrary??!0,createPlaceholderBlock:r.userFlow==="placeholder"},i),g}}var Oo=Po;function wt(e,t){if(!t.startsWith("#/"))throw new Error(`External references are not supported: ${t}`);let r=t.substring(2).split("/"),i=e;for(let n of r){if(i==null)throw new Error(`Invalid reference path: ${t}`);i=i[n]}if(i===void 0)throw new Error(`Reference not found: ${t}`);return i}function J(e,t,r=new Set){if(t==null||r.has(t))return t;if(r.add(t),t.$ref&&typeof t.$ref=="string"){let i=wt(e,t.$ref),n={...J(e,i,r)};for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&a!=="$ref"&&(n[a]=J(e,t[a],r));return n}if(Array.isArray(t))return t.map(i=>J(e,i,r));if(typeof t=="object"){let i={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=J(e,t[n],r));return i}return t}function To(e){return J(e,{...e})}function Do(e,t=!1){let r=o=>(t&&console.log(`OpenAPI Schema validation failed: ${o}`),!1);if(typeof e!="object"||e===null)return r(`Input is ${e===null?"null":typeof e}, not an object`);let i=e;if(!(typeof i.type=="string"||Array.isArray(i.enum)||typeof i.properties=="object"||typeof i.items=="object"||typeof i.allOf=="object"||typeof i.anyOf=="object"||typeof i.oneOf=="object"||typeof i.not=="object"))return r("Missing required schema-defining properties (type, enum, properties, items, allOf, anyOf, oneOf, not)");if(i.type!==void 0){let o=["string","number","integer","boolean","array","object","null"];if(typeof i.type=="string"){if(!o.includes(i.type))return r(`Invalid type: ${i.type}. Must be one of ${o.join(", ")}`)}else if(Array.isArray(i.type)){for(let l of i.type)if(typeof l!="string"||!o.includes(l))return r(`Array of types contains invalid value: ${l}. Must be one of ${o.join(", ")}`)}else return r(`Type must be a string or array of strings, got ${typeof i.type}`)}if(i.items!==void 0&&(typeof i.items!="object"||i.items===null))return r(`Items must be an object, got ${i.items===null?"null":typeof i.items}`);if(i.properties!==void 0&&(typeof i.properties!="object"||i.properties===null))return r(`Properties must be an object, got ${i.properties===null?"null":typeof i.properties}`);let n=["allOf","anyOf","oneOf"];for(let o of n)if(i[o]!==void 0){if(!Array.isArray(i[o]))return r(`${o} must be an array, got ${typeof i[o]}`);for(let l=0;l<i[o].length;l++){let u=i[o][l];if(typeof u!="object"||u===null)return r(`Item ${l} in ${o} must be an object, got ${u===null?"null":typeof u}`)}}if(i.not!==void 0&&(typeof i.not!="object"||i.not===null))return r(`'not' must be an object, got ${i.not===null?"null":typeof i.not}`);if(i.additionalProperties!==void 0&&typeof i.additionalProperties!="boolean"&&(typeof i.additionalProperties!="object"||i.additionalProperties===null))return r(`additionalProperties must be a boolean or an object, got ${i.additionalProperties===null?"null":typeof i.additionalProperties}`);if(i.format!==void 0&&typeof i.format!="string")return r(`format must be a string, got ${typeof i.format}`);let a=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf"];for(let o of a)if(i[o]!==void 0&&typeof i[o]!="number")return r(`${o} must be a number, got ${typeof i[o]}`);if(i.minLength!==void 0&&(typeof i.minLength!="number"||i.minLength<0))return r(`minLength must be a non-negative number, got ${typeof i.minLength=="number"?i.minLength:typeof i.minLength}`);if(i.maxLength!==void 0&&(typeof i.maxLength!="number"||i.maxLength<0))return r(`maxLength must be a non-negative number, got ${typeof i.maxLength=="number"?i.maxLength:typeof i.maxLength}`);if(i.pattern!==void 0&&typeof i.pattern!="string")return r(`pattern must be a string, got ${typeof i.pattern}`);if(i.minItems!==void 0&&(typeof i.minItems!="number"||i.minItems<0))return r(`minItems must be a non-negative number, got ${typeof i.minItems=="number"?i.minItems:typeof i.minItems}`);if(i.maxItems!==void 0&&(typeof i.maxItems!="number"||i.maxItems<0))return r(`maxItems must be a non-negative number, got ${typeof i.maxItems=="number"?i.maxItems:typeof i.maxItems}`);if(i.uniqueItems!==void 0&&typeof i.uniqueItems!="boolean")return r(`uniqueItems must be a boolean, got ${typeof i.uniqueItems}`);if(i.minProperties!==void 0&&(typeof i.minProperties!="number"||i.minProperties<0))return r(`minProperties must be a non-negative number, got ${typeof i.minProperties=="number"?i.minProperties:typeof i.minProperties}`);if(i.maxProperties!==void 0&&(typeof i.maxProperties!="number"||i.maxProperties<0))return r(`maxProperties must be a non-negative number, got ${typeof i.maxProperties=="number"?i.maxProperties:typeof i.maxProperties}`);if(i.required!==void 0){if(!Array.isArray(i.required))return r(`required must be an array, got ${typeof i.required}`);for(let o=0;o<i.required.length;o++){let l=i.required[o];if(typeof l!="string")return r(`Item ${o} in required array must be a string, got ${typeof l}`)}}return!0}function zo(e,t){if(e.properties==null)throw new Error("Input schema must have properties");let r=e.properties,i=[];return Ro(e,t).forEach(n=>{let a=n,o=r[n]??void 0;i.push({id:a,schema:o})}),i}function Ro(e,t){let r=t.order;if(r!=null&&Array.isArray(r))return r;if(e.properties==null)throw new Error("Input schema must have properties");let i=e.properties,n=Object.keys(i),a=Fo(e,t)??n;return r!=null&&typeof r=="function"&&(a=r(a)),[...new Set(a)]}function Fo(e,t){if(t.orderExtensionKeyword==null)return;if(typeof t.orderExtensionKeyword!="string"&&!Array.isArray(t.orderExtensionKeyword))throw new Error("orderExtensionKeyword must be a string or an array of strings");let r=(typeof t.orderExtensionKeyword=="string"?[t.orderExtensionKeyword]:t.orderExtensionKeyword).find(i=>i in e);return r==null?void 0:e[r]}var kt=zo;function N(e,t,r,i){let n=`property.${e.id}${i?`.${i}`:""}`;return[`ly.img.plugin-ai-${r}-generation-web.${t.id}.${n}`,`ly.img.plugin-ai-generation-web.${n}`,`ly.img.plugin-ai-${r}-generation-web.${t.id}.defaults.${n}`,`ly.img.plugin-ai-generation-web.defaults.${n}`]}function It(e){let t="x-imgly-enum-labels"in e&&typeof e["x-imgly-enum-labels"]=="object"?e["x-imgly-enum-labels"]:{},r="x-imgly-enum-icons"in e&&typeof e["x-imgly-enum-icons"]=="object"?e["x-imgly-enum-icons"]:{};return{labels:t,icons:r}}function Ct(e,t,r,i,n,a,o){if(t.schema==null)return i.renderCustomProperty!=null&&i.renderCustomProperty[t.id]!=null?i.renderCustomProperty[t.id](e,t):void 0;let l=t,u=t.schema.type;if(i.renderCustomProperty!=null&&i.renderCustomProperty[t.id]!=null)return i.renderCustomProperty[t.id](e,t);switch(u){case"string":return t.schema.enum!=null?Uo(e,l,r,i,n,a,o):St(e,l,r,i,n,a,o);case"boolean":return At(e,l,r,i,n,a,o);case"number":case"integer":return xt(e,l,r,i,n,a,o);case"object":return Me(e,l,r,i,n,a,o);case"array":break;case void 0:{if(t.schema.anyOf!=null&&Array.isArray(t.schema.anyOf))return Vo(e,l,r,i,n,a,o);break}default:console.error(`Unsupported property type: ${u}`)}}function Me(e,t,r,i,n,a,o){let l=kt(t.schema??{},i).reduce((u,s)=>{let c=Ct(e,s,r,i,n,a,o);return c!=null&&(u[s.id]=c()),u},{});return()=>({id:t.id,type:"object",value:l})}function St(e,t,r,i,n,a,o){let{builder:l,experimental:{global:u}}=e,{id:s}=t,c=`${r.id}.${s}`,g=N(t,r,o),p=u(c,t.schema.default??""),d=Bo(t.schema),m=d?.component!=null&&d?.component==="TextArea"?"TextArea":"TextInput";return l[m](c,{inputLabel:g,placeholder:n.i18n?.prompt,...p}),()=>({id:t.id,type:"string",value:p.value})}function Uo(e,t,r,i,n,a,o){let{builder:l,experimental:{global:u}}=e,{id:s}=t,c=`${r.id}.${s}`,g=N(t,r,o),{labels:p,icons:d}=It(t.schema),m=(t.schema.enum??[]).map(y=>({id:y,label:N(t,r,o,y),icon:d[y]})),f=t.schema.default!=null?m.find(y=>y.id===t.schema.default)??m[0]:m[0],b=u(c,f);return l.Select(c,{inputLabel:g,values:m,...b}),()=>({id:t.id,type:"string",value:b.value.id})}function At(e,t,r,i,n,a,o){let{builder:l,experimental:{global:u}}=e,{id:s}=t,c=`${r.id}.${s}`,g=N(t,r,o),p=!!t.schema.default,d=u(c,p);return l.Checkbox(c,{inputLabel:g,...d}),()=>({id:t.id,type:"boolean",value:d.value})}function xt(e,t,r,i,n,a,o){let{builder:l,experimental:{global:u}}=e,{id:s}=t,c=`${r.id}.${s}`,g=N(t,r,o),p=t.schema.minimum,d=t.schema.maximum,m=t.schema.default;m==null&&(p!=null?m=p:d!=null?m=d:m=0);let f=u(c,m);if(p!=null&&d!=null){let b=t.schema.type==="number"?.1:1;"x-imgly-step"in t.schema&&typeof t.schema["x-imgly-step"]=="number"&&(b=t.schema["x-imgly-step"]),l.Slider(c,{inputLabel:g,min:p,max:d,step:b,...f})}else l.NumberInput(c,{inputLabel:g,min:p,max:d,...f});return()=>({id:t.id,type:"integer",value:f.value})}function Vo(e,t,r,i,n,a,o){let{builder:l,experimental:{global:u}}=e,{id:s}=t,c=`${r.id}.${s}`,g=N(t,r,o),p=t.schema.anyOf??[],d=[],m={},f={},{labels:b,icons:y}=It(t.schema),L={string:St,boolean:At,integer:xt,object:Me},I=(h,$)=>h.$ref?h.$ref.split("/").pop():$.split(".").pop()??$,C=(h,$)=>({id:h,label:N(t,r,o,$),icon:y[$]??y[h]});p.forEach((h,$)=>{let E=`${r.id}.${s}.anyOf[${$}]`;if(h.$ref||h.title){let M=h.$ref?h.$ref.split("/").pop():h.title;m[E]=()=>Me(e,{id:E,schema:{...h,title:b[M]||M}},r,i,n,a,o),d.push(C(E,M))}else if(h.type==="string"&&h.enum)h.enum.forEach(M=>{d.push(C(M,M))});else if(h.type&&L[h.type]){let M=L[h.type];m[E]=()=>M(e,{id:E,schema:{...h,title:h.title}},r,i,n,a,o);let be=I(h,E);d.push(h.type==="string"&&!h.enum?{id:E,label:h.title||be,icon:h.title&&y[h.title]||y[be]}:C(E,be))}});let k=t.schema.default!=null?d.find(h=>h.id===t.schema.default)??d[0]:d[0],x=u(c,k);if(l.Select(c,{inputLabel:g,values:d,...x}),x.value.id in m){let h=m[x.value.id]();f[x.value.id]=h}return()=>{let h=f[x.value.id];return h!=null?{...h(),id:t.id}:{id:t.id,type:"string",value:x.value.id}}}function Bo(e){if("x-imgly-builder"in e)return e["x-imgly-builder"]}var Go=Ct,Ho={"ly.img.plugin-ai-generation-web.defaults.property.prompt":"Prompt","ly.img.plugin-ai-generation-web.defaults.property.style":"Style","ly.img.plugin-ai-generation-web.defaults.property.image_size":"Image Size","ly.img.plugin-ai-generation-web.defaults.property.size":"Image Size","ly.img.plugin-ai-generation-web.defaults.property.colors":"Colors","ly.img.plugin-ai-generation-web.defaults.property.background":"Background","ly.img.plugin-ai-generation-web.defaults.property.width":"Width","ly.img.plugin-ai-generation-web.defaults.property.height":"Height","ly.img.plugin-ai-generation-web.defaults.property.aspect_ratio":"Aspect Ratio","ly.img.plugin-ai-generation-web.defaults.property.duration":"Duration","ly.img.plugin-ai-generation-web.defaults.property.resolution":"Resolution","ly.img.plugin-ai-generation-web.defaults.property.generate_audio":"Generate Audio","ly.img.plugin-ai-generation-web.defaults.property.voice_id":"Voice","ly.img.plugin-ai-generation-web.defaults.property.speed":"Speed","ly.img.plugin-ai-generation-web.defaults.property.text":"Text","ly.img.plugin-ai-generation-web.defaults.property.duration_seconds":"Duration (seconds)","ly.img.plugin-ai-generation-web.defaults.property.style.type":"Type","ly.img.plugin-ai-generation-web.defaults.property.style.type.image":"Image","ly.img.plugin-ai-generation-web.defaults.property.style.type.vector":"Vector","ly.img.plugin-ai-generation-web.defaults.property.style.type.icon":"Icon","ly.img.plugin-ai-generation-web.defaults.property.image_size.square":"Square","ly.img.plugin-ai-generation-web.defaults.property.image_size.portrait":"Portrait","ly.img.plugin-ai-generation-web.defaults.property.image_size.landscape":"Landscape","ly.img.plugin-ai-generation-web.defaults.property.background.auto":"Auto","ly.img.plugin-ai-generation-web.defaults.property.background.transparent":"Transparent","ly.img.plugin-ai-generation-web.defaults.property.aspect_ratio.1:1":"1:1 (Square)","ly.img.plugin-ai-generation-web.defaults.property.aspect_ratio.16:9":"16:9 (Widescreen)","ly.img.plugin-ai-generation-web.defaults.property.aspect_ratio.9:16":"9:16 (Vertical)","ly.img.plugin-ai-generation-web.defaults.property.aspect_ratio.4:3":"4:3","ly.img.plugin-ai-generation-web.defaults.property.aspect_ratio.3:4":"3:4","ly.img.plugin-ai-generation-web.defaults.property.resolution.720p":"720p HD","ly.img.plugin-ai-generation-web.defaults.property.resolution.1080p":"1080p Full HD"};function rt(e){return e.replace(/_/g," ").replace(/\b3d\b/gi,"3D").replace(/\b2d\b/gi,"2D").replace(/\b\w/g,t=>t.toUpperCase())}function qo(e,t,r,i){let n={},a=(s,c)=>`ly.img.plugin-ai-${i}-generation-web.${t.id}.defaults.property.${s}${c?`.${c}`:""}`,o=s=>"x-imgly-enum-labels"in s&&typeof s["x-imgly-enum-labels"]=="object"?s["x-imgly-enum-labels"]:{},l=(s,c,g)=>{s.forEach(p=>{let d=String(p),m=g[d]||rt(d);n[a(c,d)]=m})};e.forEach(s=>{if(s.schema?.title&&(n[a(s.id)]=s.schema.title),s.schema?.enum){let c=o(s.schema);l(s.schema.enum,s.id,c)}if(s.schema?.anyOf&&Array.isArray(s.schema.anyOf)){let c=o(s.schema);s.schema.anyOf.forEach(g=>{let p=g;if(p.enum&&Array.isArray(p.enum))l(p.enum,s.id,c);else if(p.$ref){let d=p.$ref.split("/").pop();d&&c[d]&&(n[a(s.id,d)]=c[d])}else if(p.title){let d=p.title,m=c[d]||rt(d);n[a(s.id,d)]=m}})}});let u={...Ho,...n};Object.keys(u).length>0&&r.cesdk.i18n.setTranslations({en:u})}async function Zo({options:e,provider:t,panelInput:r,config:i},n){let{id:a}=t;if(r==null)return;i.debug&&console.log(`Registering schema-based panel input for provider ${a}`);let o=To(r.document),l=wt(o,r.inputReference);if(!Do(l,i.debug))throw new Error(`Input reference '${r.inputReference}' does not resolve to a valid OpenAPI schema`);let u=l,s=kt(u,r);return qo(s,t,e,t.kind),c=>{let{builder:g}=c,p=[];g.Section(`${a}.schema.section`,{children:()=>{s.forEach(b=>{let y=Go(c,b,t,r,e,i,t.kind);y!=null&&(Array.isArray(y)?p.push(...y):p.push(y))})}});let d=p.map(b=>b()),m=b=>b.type==="object"?Object.entries(b.value).reduce((y,[L,I])=>(y[L]=m(I),y),{}):b.value,f=d.reduce((b,y)=>(b[y.id]=m(y),b),{});vt(c,t,n,()=>({input:f}),()=>r.getBlockInput(f),{...e,requiredInputs:u.required,createPlaceholderBlock:r.userFlow==="placeholder"},i)}}var Yo=Zo;async function Qo(e,t){if(e.panelInput!=null)switch(e.panelInput.type){case"custom":return Oo(e,t);case"schema":return Yo(e,t);default:e.config.debug&&console.warn(`Invalid panel input type '${panelInput.type}' - skipping`)}}var Wo=Qo;function Ko(e){let{provider:t,options:{engine:r}}=e,i=t.output.history??"@imgly/local";if(i==null||i===!1)return;let n=r.asset.findAllSources();function a(){let o=`${t.id}.history`;for(;n.includes(o);)o+=`-${Math.random().toString(36).substring(2,6)}`;return o}if(i==="@imgly/local"){let o=a();return r.asset.addLocalSource(o),o}if(i==="@imgly/indexedDB"){let o=a();return r.asset.addSource(new er(o,r)),o}return i}var Jo=Ko;function Xo(e,t){if(t==null||!t)return;let r=`${e.provider.id}.history`;return e.options.cesdk.ui.addAssetLibraryEntry({id:r,sourceIds:[t],sortBy:{sortKey:"insertedAt",sortingOrder:"Descending"},canRemove:!0,gridItemHeight:"square",gridBackgroundType:"cover"}),r}var ea=Xo,ke="@imgly/plugin-ai-generation",ta=`
|
|
5
5
|
<svg>
|
|
6
6
|
<symbol
|
|
7
7
|
fill="none"
|
|
@@ -19,7 +19,7 @@ Consider updating all AI plugins to the same version for optimal compatibility.`
|
|
|
19
19
|
fill="none"
|
|
20
20
|
xmlns="http://www.w3.org/2000/svg"
|
|
21
21
|
viewBox="0 0 24 24"
|
|
22
|
-
id="${
|
|
22
|
+
id="${ke}/image"
|
|
23
23
|
>
|
|
24
24
|
<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"/>
|
|
25
25
|
<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"/>
|
|
@@ -31,7 +31,7 @@ Consider updating all AI plugins to the same version for optimal compatibility.`
|
|
|
31
31
|
fill="none"
|
|
32
32
|
xmlns="http://www.w3.org/2000/svg"
|
|
33
33
|
viewBox="0 0 24 24"
|
|
34
|
-
id="${
|
|
34
|
+
id="${ke}/video"
|
|
35
35
|
>
|
|
36
36
|
<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"/>
|
|
37
37
|
<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"/>
|
|
@@ -42,7 +42,7 @@ Consider updating all AI plugins to the same version for optimal compatibility.`
|
|
|
42
42
|
fill="none"
|
|
43
43
|
xmlns="http://www.w3.org/2000/svg"
|
|
44
44
|
viewBox="0 0 24 24"
|
|
45
|
-
id="${
|
|
45
|
+
id="${ke}/audio"
|
|
46
46
|
>
|
|
47
47
|
<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"/>
|
|
48
48
|
<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"/>
|
|
@@ -62,8 +62,8 @@ Consider updating all AI plugins to the same version for optimal compatibility.`
|
|
|
62
62
|
|
|
63
63
|
</symbol>
|
|
64
64
|
</svg>
|
|
65
|
-
`,
|
|
66
|
-
`,"+")}`}}async function
|
|
65
|
+
`,ra=ta;function ia(e){return async(t,r,i)=>e.enable?(console.log(`[DRY RUN]: Requesting dummy AI generation for kind '${e.kind}' with inputs: `,JSON.stringify(t,void 0,2)),await Et(2e3),await na(t,e,r)):i(t,r)}async function na(e,t,r){switch(t.kind){case"image":return oa(e,t,r);case"video":return aa(e,t,r);case"text":return sa(e,t,r);case"audio":return ua(e,t,r);default:throw new Error(`Unsupported output kind for creating dry run output: ${t.kind}`)}}async function oa(e,t,{engine:r}){let i,n,a=e!=null&&typeof e=="object"&&"prompt"in e&&typeof e.prompt=="string"?e.prompt:"AI Generated Image",o=a.match(/(\d+)x(\d+)/);if(o!=null)i=parseInt(o[1],10),n=parseInt(o[2],10);else if(t.blockInputs!=null&&(i=t.blockInputs.image.width,n=t.blockInputs.image.height),t.blockIds!=null&&Array.isArray(t.blockIds)&&t.blockIds.length>0){let[l]=t.blockIds,u=await eo(l,r),s=await Xn(u,r);i=s.width,n=s.height}else i=512,n=512;return{kind:"image",url:`https://placehold.co/${i}x${n}/000000/FFF?text=${a.replace(" ","+").replace(`
|
|
66
|
+
`,"+")}`}}async function aa(e,t,r){return Promise.resolve({kind:"video",url:"https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4"})}async function sa(e,t,r){let i="";if(t.blockIds&&t.blockIds.length>0){let[o]=t.blockIds;r.engine.block.isValid(o)&&(i=r.engine.block.getString(o,"text/text"))}if(!i&&e!=null&&typeof e=="object"&&"prompt"in e&&typeof e.prompt=="string"){let o=e.prompt,l=o.match(/text:\s*"([^"]+)"/i)||o.match(/content:\s*"([^"]+)"/i)||o.match(/"([^"]+)"/);l&&l[1]&&(i=l[1])}let n=i.length||50,a="";if(e!=null&&typeof e=="object")if("language"in e&&typeof e.language=="string")a=K(n,"translation");else if("type"in e&&typeof e.type=="string"){let o=e.type;a=K(n,o)}else"customPrompt"in e?a=K(n,"custom"):a=K(n,"improved");else a=K(n,"generated");return la(a,r.abortSignal)}async function*la(e,t){let r=Math.max(1,Math.ceil(e.length/20)),i=0;for(;i<e.length;){if(t?.aborted)return;let n=Math.min(i+r,e.length);yield{kind:"text",text:e.substring(0,n)},i=n,i<e.length&&await Et(100)}return{kind:"text",text:e}}function K(e,t){let r="[DRY RUN - Dummy Text] ",i=r.length;if(e<=i)return r.substring(0,e);let n=e-i,a={translation:"Ceci est un texte fictif traduit qui maintient la longueur approximative.",professional:"Enhanced professional content with improved clarity and structure.",casual:"Relaxed, friendly text that keeps things simple and approachable.",formal:"Refined formal documentation that preserves original structure.",humorous:"Amusing content that brings lighthearted fun to the text.",improved:"Enhanced text that demonstrates better clarity and readability.",custom:"Customized content reflecting the requested modifications.",generated:"AI-generated content maintaining original length and structure."},o=a[t]||a.generated,l="";if(n<=o.length)l=o.substring(0,n);else{l=o;let u=[" Additional content continues with similar phrasing."," Further elaboration maintains the established tone."," Extended content preserves the original style."," Continued text follows the same pattern."],s=0;for(;l.length<n;){let c=u[s%u.length];if(l.length+c.length<=n)l+=c;else{l+=c.substring(0,n-l.length);break}s++}}return r+l}async function ua(e,t,r){let i=3;if(e!=null&&typeof e=="object"){if("duration"in e&&typeof e.duration=="number")i=e.duration;else if("prompt"in e&&typeof e.prompt=="string"){let n=e.prompt.match(/(\d+)\s*(?:seconds?|secs?|s)\b/i);n&&(i=parseInt(n[1],10))}}return t.blockInputs?.audio?.duration&&(i=t.blockInputs.audio.duration),{kind:"audio",url:ca(220,i),duration:i,thumbnailUrl:void 0}}function ca(e,t){let r=Math.floor(44100*t),i=new Float32Array(r);for(let n=0;n<r;n++)i[n]=Math.sin(2*Math.PI*e*n/44100);return da(i,44100)}function da(e,t){let r=e.length,i=2,n=1,a=n*i,o=t*a,l=r*i,u=44+l,s=new ArrayBuffer(u),c=new DataView(s),g=(f,b)=>{for(let y=0;y<b.length;y++)c.setUint8(f+y,b.charCodeAt(y))};g(0,"RIFF"),c.setUint32(4,u-8,!0),g(8,"WAVE"),g(12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,n,!0),c.setUint32(24,t,!0),c.setUint32(28,o,!0),c.setUint16(32,a,!0),c.setUint16(34,16,!0),g(36,"data"),c.setUint32(40,l,!0);let p=44;for(let f=0;f<r;f++){let b=Math.max(-1,Math.min(1,e[f])),y=Math.round(b*32767);c.setInt16(p,y,!0),p+=2}let d=new Uint8Array(s),m="";for(let f=0;f<d.length;f++)m+=String.fromCharCode(d[f]);return`data:audio/wav;base64,${btoa(m)}`}async function Et(e){return new Promise(t=>{setTimeout(t,e)})}var ga=ia,pa="USER_CANCEL";function fa(e){return async(t,r)=>{if(r?.abortSignal?.aborted)return{status:"aborted"};let i=no([...e.provider.output.middleware??[],...r?.middlewares??[],ao({enable:r?.debug}),ga({enable:r?.dryRun,kind:e.provider.kind})]);try{let{result:n}=await i(e.provider.output.generate)(t,{abortSignal:r?.abortSignal,engine:e.engine,cesdk:e.cesdk});return r?.abortSignal?.aborted?{status:"aborted"}:n instanceof Error?{status:"error",message:n.message}:n==null?{status:"error",message:"No output generated"}:co(n)?{status:"success",type:"async",output:n}:{status:"success",type:"sync",output:n}}catch(n){return _e(n)?{status:"aborted",message:n.message}:n===pa?{status:"aborted",message:n}:{status:"error",message:n instanceof Error?n.message:String(n)}}}}var ma=fa;async function ha(e,t,r,i){let n={...i,provider:t},a={provider:t,panelInput:t.input?.panel,options:{cesdk:r.cesdk,engine:r.cesdk.engine},config:n};await t.initialize?.({...r,engine:r.cesdk.engine});let o=Jo(a),l=ea(a,o);a.options.historyAssetSourceId=o,a.options.historyAssetLibraryEntryId=l;let u=ma({provider:t,cesdk:r.cesdk,engine:r.cesdk.engine}),s=await Wo(a,u);go(r.cesdk,"@imgly/plugin-ai-generation",ra);let c={provider:t,panel:{builderRenderFunction:s},history:{assetSourceId:o,assetLibraryEntryId:l},generate:u};return io.get().register(c),c}var Ie=ha;function ba(e){let{kind:t,cesdk:r,historAssetSourceIds:i}=e,n=`ly.img.ai.${t}-generation.history`;if(r.engine.asset.findAllSources().includes(n))return n;let a=new tr(n,r,i);return r.engine.asset.addSource(a),a.id}var ya=ba;function X(e,t){return[`ly.img.plugin-ai-${e}-generation-web.${t}`,`ly.img.plugin-ai-generation-web.${t}`,`ly.img.plugin-ai-generation-web.defaults.${t}`]}async function va(e,t,r,i){let{cesdk:n}=r;n.setTranslations({en:{"ly.img.plugin-ai-generation-web.defaults.fromType.label":"Input","ly.img.plugin-ai-generation-web.defaults.providerSelect.label":"Provider","ly.img.plugin-ai-generation-web.defaults.fromText.label":"Text","ly.img.plugin-ai-generation-web.defaults.fromImage.label":"Image"}});let a,o=[];if(Array.isArray(t)){let s=await Promise.all(t.map(c=>Ie(e,c,r,i)));o.push(...s),a=ka({kind:e,prefix:e,providerInitializationResults:o})}else{let s=await Promise.all(t.fromText.map(g=>Ie(e,g,r,i)));o.push(...s);let c=await Promise.all(t.fromImage.map(g=>Ie(e,g,r,i)));o.push(...c),a=wa({kind:e,prefix:`ly.img.ai.${e}-generation`,initializedFromTextProviders:s,initializedFromImageProviders:c})}let l=ya({kind:e,cesdk:r.cesdk,historAssetSourceIds:o.map(s=>s.history?.assetSourceId).filter(ro)}),u;return l!=null&&(u=l,r.cesdk.ui.addAssetLibraryEntry({id:u,sourceIds:[l],sortBy:{sortKey:"insertedAt",sortingOrder:"Descending"},canRemove:!0,gridItemHeight:"square",gridBackgroundType:"cover"})),{panel:{builderRenderFunction:a},history:{assetSourceId:l,assetLibraryEntryId:u},providerInitializationResults:o}}function wa({kind:e,prefix:t,initializedFromTextProviders:r,initializedFromImageProviders:i}){let n=r.length>0&&i.length>0;return a=>{let{builder:o,experimental:l}=a,u=l.global(`${t}.fromType`,n?"fromText":void 0),s=[];u.value==="fromText"?s.push(...r):u.value==="fromImage"?s.push(...i):s.push(...r,...i);let c=r.map(({provider:f,panel:b})=>({id:f.id,label:f.name??f.id,builderRenderFunction:b?.builderRenderFunction})),g=i.map(({provider:f,panel:b})=>({id:f.id,label:f.name??f.id,builderRenderFunction:b?.builderRenderFunction})),p=a.experimental.global(`${t}.selectedProvider.fromText`,c[0]),d=a.experimental.global(`${t}.selectedProvider.fromImage`,g[0]),m=u.value==="fromText"?p:u.value==="fromImage"?d:void 0;if((n||s.length>1)&&o.Section(`${t}.providerSelection.section`,{children:()=>{if(n&&o.ButtonGroup(`${t}.fromType.buttonGroup`,{inputLabel:X(e,"fromType.label"),children:()=>{o.Button(`${t}.fromType.buttonGroup.fromText`,{label:X(e,"fromText.label"),icon:u.value!=="fromText"&&it(r,a)?"@imgly/LoadingSpinner":void 0,isActive:u.value==="fromText",onClick:()=>{u.setValue("fromText")}}),o.Button(`${t}.fromType.buttonGroup.fromImage`,{label:X(e,"fromImage.label"),icon:u.value!=="fromImage"&&it(i,a)?"@imgly/LoadingSpinner":void 0,isActive:u.value==="fromImage",onClick:()=>{u.setValue("fromImage")}})}}),s.length>1){let f=u.value==="fromText"?c:u.value==="fromImage"?g:[...c,...g];m!=null&&o.Select(`${t}.providerSelect.select`,{inputLabel:X(e,"providerSelect.label"),values:f,...m})}}}),s.length>1)m?.value.builderRenderFunction?.(a);else{let f=s[0];f&&f.panel?.builderRenderFunction?.(a)}}}function ka({kind:e,prefix:t,providerInitializationResults:r}){return i=>{let{builder:n}=i;if(r.length===0)return;let a=r.map(({provider:l,panel:u})=>({id:l.id,label:l.name??l.id,builderRenderFunction:u?.builderRenderFunction})),o=i.state(`${t}.selectedProvider`,a[0]);r.length>1&&o!=null&&n.Section(`${t}.providerSelection.section`,{children:()=>{n.Select(`${t}.providerSelect.select`,{inputLabel:X(e,"providerSelect.label"),values:a,...o})}}),o.value.builderRenderFunction?.(i)}}function it(e,t){return e.length===0?!1:e.some(({provider:r})=>r.id==null?!1:t.experimental.global($e(r.id),!1).value)}var Mt=va;var jt="@imgly/plugin-ai-sticker-generation",Ia=`
|
|
67
67
|
<svg>
|
|
68
68
|
<symbol
|
|
69
69
|
fill="none"
|
|
@@ -77,7 +77,7 @@ Consider updating all AI plugins to the same version for optimal compatibility.`
|
|
|
77
77
|
|
|
78
78
|
</symbol>
|
|
79
79
|
</svg>
|
|
80
|
-
`,
|
|
80
|
+
`,_t=Ia;var Ca=typeof global=="object"&&global&&global.Object===Object&&global,Ht=Ca,Sa=typeof self=="object"&&self&&self.Object===Object&&self,Aa=Ht||Sa||Function("return this")(),A=Aa,xa=A.Symbol,H=xa,qt=Object.prototype,Ea=qt.hasOwnProperty,Ma=qt.toString,oe=H?H.toStringTag:void 0;function ja(e){var t=Ea.call(e,oe),r=e[oe];try{e[oe]=void 0;var i=!0}catch{}var n=Ma.call(e);return i&&(t?e[oe]=r:delete e[oe]),n}var _a=ja,La=Object.prototype,$a=La.toString;function Na(e){return $a.call(e)}var Pa=Na,Oa="[object Null]",Ta="[object Undefined]",Lt=H?H.toStringTag:void 0;function Da(e){return e==null?e===void 0?Ta:Oa:Lt&&Lt in Object(e)?_a(e):Pa(e)}var ue=Da;function za(e){return e!=null&&typeof e=="object"}var Fe=za,Vu=Array.isArray;function Ra(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Zt=Ra,Fa="[object AsyncFunction]",Ua="[object Function]",Va="[object GeneratorFunction]",Ba="[object Proxy]";function Ga(e){if(!Zt(e))return!1;var t=ue(e);return t==Ua||t==Va||t==Fa||t==Ba}var Ha=Ga,qa=A["__core-js_shared__"],Ne=qa,$t=function(){var e=/[^.]+$/.exec(Ne&&Ne.keys&&Ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Za(e){return!!$t&&$t in e}var Ya=Za,Qa=Function.prototype,Wa=Qa.toString;function Ka(e){if(e!=null){try{return Wa.call(e)}catch{}try{return e+""}catch{}}return""}var O=Ka,Ja=/[\\^$.*+?()[\]{}|]/g,Xa=/^\[object .+?Constructor\]$/,es=Function.prototype,ts=Object.prototype,rs=es.toString,is=ts.hasOwnProperty,ns=RegExp("^"+rs.call(is).replace(Ja,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function os(e){if(!Zt(e)||Ya(e))return!1;var t=Ha(e)?ns:Xa;return t.test(O(e))}var as=os;function ss(e,t){return e?.[t]}var ls=ss;function us(e,t){var r=ls(e,t);return as(r)?r:void 0}var q=us,cs=q(A,"WeakMap"),Oe=cs;function ds(e,t){return e===t||e!==e&&t!==t}var gs=ds,ps=9007199254740991;function fs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ps}var ms=fs;var Bu=Object.prototype;var hs="[object Arguments]";function bs(e){return Fe(e)&&ue(e)==hs}var Nt=bs,Yt=Object.prototype,ys=Yt.hasOwnProperty,vs=Yt.propertyIsEnumerable,Gu=Nt(function(){return arguments}())?Nt:function(e){return Fe(e)&&ys.call(e,"callee")&&!vs.call(e,"callee")};var Qt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pt=Qt&&typeof module=="object"&&module&&!module.nodeType&&module,ws=Pt&&Pt.exports===Qt,Ot=ws?A.Buffer:void 0,Hu=Ot?Ot.isBuffer:void 0;var ks="[object Arguments]",Is="[object Array]",Cs="[object Boolean]",Ss="[object Date]",As="[object Error]",xs="[object Function]",Es="[object Map]",Ms="[object Number]",js="[object Object]",_s="[object RegExp]",Ls="[object Set]",$s="[object String]",Ns="[object WeakMap]",Ps="[object ArrayBuffer]",Os="[object DataView]",Ts="[object Float32Array]",Ds="[object Float64Array]",zs="[object Int8Array]",Rs="[object Int16Array]",Fs="[object Int32Array]",Us="[object Uint8Array]",Vs="[object Uint8ClampedArray]",Bs="[object Uint16Array]",Gs="[object Uint32Array]",w={};w[Ts]=w[Ds]=w[zs]=w[Rs]=w[Fs]=w[Us]=w[Vs]=w[Bs]=w[Gs]=!0;w[ks]=w[Is]=w[Ps]=w[Cs]=w[Os]=w[Ss]=w[As]=w[xs]=w[Es]=w[Ms]=w[js]=w[_s]=w[Ls]=w[$s]=w[Ns]=!1;function Hs(e){return Fe(e)&&ms(e.length)&&!!w[ue(e)]}var qs=Hs;function Zs(e){return function(t){return e(t)}}var Ys=Zs,Wt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ae=Wt&&typeof module=="object"&&module&&!module.nodeType&&module,Qs=ae&&ae.exports===Wt,Pe=Qs&&Ht.process,Ws=function(){try{var e=ae&&ae.require&&ae.require("util").types;return e||Pe&&Pe.binding&&Pe.binding("util")}catch{}}(),Tt=Ws,Dt=Tt&&Tt.isTypedArray,qu=Dt?Ys(Dt):qs;var Ks=Object.prototype,Zu=Ks.hasOwnProperty;function Js(e,t){return function(r){return e(t(r))}}var Xs=Js,Yu=Xs(Object.keys,Object);var el=Object.prototype,Qu=el.hasOwnProperty;var tl=q(Object,"create"),se=tl;function rl(){this.__data__=se?se(null):{},this.size=0}var il=rl;function nl(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ol=nl,al="__lodash_hash_undefined__",sl=Object.prototype,ll=sl.hasOwnProperty;function ul(e){var t=this.__data__;if(se){var r=t[e];return r===al?void 0:r}return ll.call(t,e)?t[e]:void 0}var cl=ul,dl=Object.prototype,gl=dl.hasOwnProperty;function pl(e){var t=this.__data__;return se?t[e]!==void 0:gl.call(t,e)}var fl=pl,ml="__lodash_hash_undefined__";function hl(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=se&&t===void 0?ml:t,this}var bl=hl;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=il;Z.prototype.delete=ol;Z.prototype.get=cl;Z.prototype.has=fl;Z.prototype.set=bl;var zt=Z;function yl(){this.__data__=[],this.size=0}var vl=yl;function wl(e,t){for(var r=e.length;r--;)if(gs(e[r][0],t))return r;return-1}var fe=wl,kl=Array.prototype,Il=kl.splice;function Cl(e){var t=this.__data__,r=fe(t,e);if(r<0)return!1;var i=t.length-1;return r==i?t.pop():Il.call(t,r,1),--this.size,!0}var Sl=Cl;function Al(e){var t=this.__data__,r=fe(t,e);return r<0?void 0:t[r][1]}var xl=Al;function El(e){return fe(this.__data__,e)>-1}var Ml=El;function jl(e,t){var r=this.__data__,i=fe(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var _l=jl;function Y(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])}}Y.prototype.clear=vl;Y.prototype.delete=Sl;Y.prototype.get=xl;Y.prototype.has=Ml;Y.prototype.set=_l;var me=Y,Ll=q(A,"Map"),le=Ll;function $l(){this.size=0,this.__data__={hash:new zt,map:new(le||me),string:new zt}}var Nl=$l;function Pl(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Ol=Pl;function Tl(e,t){var r=e.__data__;return Ol(t)?r[typeof t=="string"?"string":"hash"]:r.map}var he=Tl;function Dl(e){var t=he(this,e).delete(e);return this.size-=t?1:0,t}var zl=Dl;function Rl(e){return he(this,e).get(e)}var Fl=Rl;function Ul(e){return he(this,e).has(e)}var Vl=Ul;function Bl(e,t){var r=he(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var Gl=Bl;function Q(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])}}Q.prototype.clear=Nl;Q.prototype.delete=zl;Q.prototype.get=Fl;Q.prototype.has=Vl;Q.prototype.set=Gl;var Kt=Q;function Hl(){this.__data__=new me,this.size=0}var ql=Hl;function Zl(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Yl=Zl;function Ql(e){return this.__data__.get(e)}var Wl=Ql;function Kl(e){return this.__data__.has(e)}var Jl=Kl,Xl=200;function eu(e,t){var r=this.__data__;if(r instanceof me){var i=r.__data__;if(!le||i.length<Xl-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new Kt(i)}return r.set(e,t),this.size=r.size,this}var tu=eu;function ce(e){var t=this.__data__=new me(e);this.size=t.size}ce.prototype.clear=ql;ce.prototype.delete=Yl;ce.prototype.get=Wl;ce.prototype.has=Jl;ce.prototype.set=tu;var ru=Object.prototype,Wu=ru.propertyIsEnumerable;var iu=q(A,"DataView"),Te=iu,nu=q(A,"Promise"),De=nu,ou=q(A,"Set"),ze=ou,Rt="[object Map]",au="[object Object]",Ft="[object Promise]",Ut="[object Set]",Vt="[object WeakMap]",Bt="[object DataView]",su=O(Te),lu=O(le),uu=O(De),cu=O(ze),du=O(Oe),G=ue;(Te&&G(new Te(new ArrayBuffer(1)))!=Bt||le&&G(new le)!=Rt||De&&G(De.resolve())!=Ft||ze&&G(new ze)!=Ut||Oe&&G(new Oe)!=Vt)&&(G=function(e){var t=ue(e),r=t==au?e.constructor:void 0,i=r?O(r):"";if(i)switch(i){case su:return Bt;case lu:return Rt;case uu:return Ft;case cu:return Ut;case du:return Vt}return t});var Ku=A.Uint8Array;var gu="__lodash_hash_undefined__";function pu(e){return this.__data__.set(e,gu),this}var fu=pu;function mu(e){return this.__data__.has(e)}var hu=mu;function Re(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Kt;++t<r;)this.add(e[t])}Re.prototype.add=Re.prototype.push=fu;Re.prototype.has=hu;var Gt=H?H.prototype:void 0,Ju=Gt?Gt.valueOf:void 0;var bu=Object.prototype,Xu=bu.hasOwnProperty;var yu=Object.prototype,ec=yu.hasOwnProperty;var tc=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),rc=new RegExp(/[A-Fa-f0-9]{1}/,"g"),ic=new RegExp(/[A-Fa-f0-9]{2}/,"g");function vu(e){return e==null?[]:Array.isArray(e)?e:[e]}var Jt=vu;var T="@imgly/plugin-ai-sticker-generation-web";var _="ly.img.ai.sticker-generation";function wu(e){return{async initialize({cesdk:t}){if(t==null)return;ht(t,T,"0.2.5");let i=gt.get().register({type:"plugin",sceneMode:"Design",id:T,pluginId:T,label:"Generate Sticker",meta:{panelId:_},execute:()=>{t.ui.isPanelOpen(_)?t.ui.closePanel(_):t.ui.openPanel(_)}});t.ui.addIconSet(jt,_t),t.i18n.setTranslations({en:{[`panel.${_}`]:"Sticker Generation",[`${_}.dock.label`]:"AI Sticker"}});let n=e.providers?.text2sticker,a=await Promise.all(Jt(n).map(u=>u({cesdk:t})));if(!(a.length>0)){i();return}let l=await Mt("sticker",{fromText:a,fromImage:[]},{cesdk:t},e);l.history?.assetSourceId!=null,l.panel.builderRenderFunction!=null?(t.ui.registerPanel(_,l.panel.builderRenderFunction),bt({cesdk:t,panelId:_})):i()}}}var Xt=wu;var ku=e=>({name:T,version:"0.2.5",...Xt(e)}),fc=ku;export{fc as default};
|
|
81
81
|
/*! Bundled license information:
|
|
82
82
|
|
|
83
83
|
@imgly/plugin-ai-generation-web/dist/index.mjs:
|