@imgly/plugin-ai-sticker-generation-web 1.87.0-rc.0 → 1.88.0-nightly.20261117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fal-ai/index.mjs +1 -1
- package/dist/fal-ai/index.mjs.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/fal-ai/index.mjs
CHANGED
|
@@ -64,7 +64,7 @@ var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPro
|
|
|
64
64
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 4C5.34315 4 4 5.34315 4 7V17C4 18.6569 5.34315 20 7 20H17C18.6569 20 20 18.6569 20 17V7C20 5.34315 18.6569 4 17 4H7ZM6 7C6 6.44772 6.44772 6 7 6H17C17.5523 6 18 6.44772 18 7V17C18 17.5523 17.5523 18 17 18H7C6.44772 18 6 17.5523 6 17V7Z" fill="currentColor"/>
|
|
65
65
|
</symbol>
|
|
66
66
|
</svg>
|
|
67
|
-
`,u=class{constructor(e,t=[],n){this.id=e,this.translateLabel=n?.translateLabel,this.assets=t.map(e=>{if(typeof e.label==`string`&&!(e.label&&typeof e.label==`object`)){let t=e;return{id:t.id,label:{en:t.label},meta:t.thumbUri?{...t.meta??{},thumbUri:t.thumbUri}:t.meta}}return e}),this.activeAssetIds=/* @__PURE__ */ new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(e){let{page:t,perPage:n,locale:r=`en`,sortActiveFirst:i,query:a,tags:o,groups:s,excludeGroups:c,sortingOrder:l,sortKey:u}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(e=>e.groups&&s.some(t=>e.groups?.includes(t)))),c&&c.length>0&&(d=d.filter(e=>!e.groups||!c.some(t=>e.groups?.includes(t)))),a){let e=a.toLowerCase();d=d.filter(t=>{let n=t.label?.[r]?.toLowerCase(),i=t.tags?.[r]||[];return n&&n.includes(e)||i.some(t=>t.toLowerCase().includes(e))})}if(o&&o.length>0){let e=Array.isArray(o)?o:[o];d=d.filter(t=>{let n=t.tags?.[r]||[];return e.some(e=>n.includes(e))})}i&&d.sort((e,t)=>{let n=this.activeAssetIds.has(e.id),r=this.activeAssetIds.has(t.id);return n&&!r?-1:!n&&r?1:0}),u&&u!==`id`?d.sort((e,t)=>{let n=e.meta?.[u],r=t.meta?.[u];return n===void 0?1:r===void 0?-1:typeof n==`string`&&typeof r==`string`?l===`Descending`?r.localeCompare(n):n.localeCompare(r):typeof n==`number`&&typeof r==`number`?l===`Descending`?r-n:n-r:0}):u===`id`&&d.sort((e,t)=>l===`Descending`?t.id.localeCompare(e.id):e.id.localeCompare(t.id));let f=d.length,p=t*n,m=p+n;return{assets:d.slice(p,m).map(e=>{let t=e.label?.[r]||``,n=this.translateLabel?this.translateLabel(e.id,t,r):t;return{id:e.id,groups:e.groups,meta:e.meta,payload:e.payload,locale:r,label:n,tags:e.tags?.[r],active:this.activeAssetIds.has(e.id)}}),currentPage:t,nextPage:m<f?t+1:void 0,total:f}}updateLabel(e,t,n){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[n]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:t})=>t===e);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:t})=>t===e[0]);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:t})=>t===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(t=>t.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(t=>t.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=/* @__PURE__ */ new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(t=>e.add(t))}),Array.from(e)}getSupportedMimeTypes(){return[`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`video/mp4`,`audio/mpeg`]}},d=typeof global==`object`&&global&&global.Object===Object&&global,f=typeof self==`object`&&self&&self.Object===Object&&self,p=d||f||Function(`return this`)(),m=p.Symbol,h=Object.prototype,g=h.hasOwnProperty,_=h.toString,v=m?m.toStringTag:void 0;function y(e){var t=g.call(e,v),n=e[v];try{e[v]=void 0;var r=!0}catch{}var i=_.call(e);return r&&(t?e[v]=n:delete e[v]),i}var b=Object.prototype.toString;function ee(e){return b.call(e)}var x=`[object Null]`,te=`[object Undefined]`,S=m?m.toStringTag:void 0;function C(e){return e==null?e===void 0?te:x:S&&S in Object(e)?y(e):ee(e)}function ne(e){return typeof e==`object`&&!!e}Array.isArray;function w(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var re=`[object AsyncFunction]`,ie=`[object Function]`,T=`[object GeneratorFunction]`,ae=`[object Proxy]`;function oe(e){if(!w(e))return!1;var t=C(e);return t==ie||t==T||t==re||t==ae}var E=p[`__core-js_shared__`],se=function(){var e=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function ce(e){return!!se&&se in e}var le=Function.prototype.toString;function D(e){if(e!=null){try{return le.call(e)}catch{}try{return e+``}catch{}}return``}var ue=/[\\^$.*+?()[\]{}|]/g,de=/^\[object .+?Constructor\]$/,fe=Function.prototype,pe=Object.prototype,me=fe.toString,he=pe.hasOwnProperty,ge=RegExp(`^`+me.call(he).replace(ue,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function _e(e){return!w(e)||ce(e)?!1:(oe(e)?ge:de).test(D(e))}function ve(e,t){return e?.[t]}function O(e,t){var n=ve(e,t);return _e(n)?n:void 0}var ye=O(p,`WeakMap`);function be(e,t){return e===t||e!==e&&t!==t}var xe=`[object Arguments]`;function Se(e){return ne(e)&&C(e)==xe}var Ce=Object.prototype;Ce.hasOwnProperty,Ce.propertyIsEnumerable,Se(function(){return arguments}());var we=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Te=we&&typeof module==`object`&&module&&!module.nodeType&&module,Ee=Te&&Te.exports===we?p.Buffer:void 0;Ee&&Ee.isBuffer;var De=`[object Arguments]`,Oe=`[object Array]`,ke=`[object Boolean]`,Ae=`[object Date]`,je=`[object Error]`,Me=`[object Function]`,Ne=`[object Map]`,Pe=`[object Number]`,Fe=`[object Object]`,Ie=`[object RegExp]`,Le=`[object Set]`,Re=`[object String]`,ze=`[object WeakMap]`,Be=`[object ArrayBuffer]`,Ve=`[object DataView]`,He=`[object Float32Array]`,Ue=`[object Float64Array]`,We=`[object Int8Array]`,Ge=`[object Int16Array]`,Ke=`[object Int32Array]`,qe=`[object Uint8Array]`,Je=`[object Uint8ClampedArray]`,Ye=`[object Uint16Array]`,Xe=`[object Uint32Array]`,k={};k[He]=k[Ue]=k[We]=k[Ge]=k[Ke]=k[qe]=k[Je]=k[Ye]=k[Xe]=!0,k[De]=k[Oe]=k[Be]=k[ke]=k[Ve]=k[Ae]=k[je]=k[Me]=k[Ne]=k[Pe]=k[Fe]=k[Ie]=k[Le]=k[Re]=k[ze]=!1;var Ze=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Qe=Ze&&typeof module==`object`&&module&&!module.nodeType&&module,$e=Qe&&Qe.exports===Ze&&d.process,et=function(){try{return Qe&&Qe.require&&Qe.require(`util`).types||$e&&$e.binding&&$e.binding(`util`)}catch{}}();et&&et.isTypedArray;var tt=O(Object,`create`);function nt(){this.__data__=tt?tt(null):{},this.size=0}function rt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var it=`__lodash_hash_undefined__`,at=Object.prototype.hasOwnProperty;function ot(e){var t=this.__data__;if(tt){var n=t[e];return n===it?void 0:n}return at.call(t,e)?t[e]:void 0}var st=Object.prototype.hasOwnProperty;function ct(e){var t=this.__data__;return tt?t[e]!==void 0:st.call(t,e)}var lt=`__lodash_hash_undefined__`;function ut(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=tt&&t===void 0?lt:t,this}function A(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}A.prototype.clear=nt,A.prototype.delete=rt,A.prototype.get=ot,A.prototype.has=ct,A.prototype.set=ut;function dt(){this.__data__=[],this.size=0}function ft(e,t){for(var n=e.length;n--;)if(be(e[n][0],t))return n;return-1}var pt=Array.prototype.splice;function mt(e){var t=this.__data__,n=ft(t,e);return n<0?!1:(n==t.length-1?t.pop():pt.call(t,n,1),--this.size,!0)}function ht(e){var t=this.__data__,n=ft(t,e);return n<0?void 0:t[n][1]}function gt(e){return ft(this.__data__,e)>-1}function _t(e,t){var n=this.__data__,r=ft(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function j(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}j.prototype.clear=dt,j.prototype.delete=mt,j.prototype.get=ht,j.prototype.has=gt,j.prototype.set=_t;var vt=O(p,`Map`);function yt(){this.size=0,this.__data__={hash:new A,map:new(vt||j),string:new A}}function bt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function xt(e,t){var n=e.__data__;return bt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function St(e){var t=xt(this,e).delete(e);return this.size-=+!!t,t}function Ct(e){return xt(this,e).get(e)}function wt(e){return xt(this,e).has(e)}function Tt(e,t){var n=xt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function M(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}M.prototype.clear=yt,M.prototype.delete=St,M.prototype.get=Ct,M.prototype.has=wt,M.prototype.set=Tt;function Et(){this.__data__=new j,this.size=0}function Dt(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Ot(e){return this.__data__.get(e)}function kt(e){return this.__data__.has(e)}var At=200;function jt(e,t){var n=this.__data__;if(n instanceof j){var r=n.__data__;if(!vt||r.length<At-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new M(r)}return n.set(e,t),this.size=n.size,this}function Mt(e){var t=this.__data__=new j(e);this.size=t.size}Mt.prototype.clear=Et,Mt.prototype.delete=Dt,Mt.prototype.get=Ot,Mt.prototype.has=kt,Mt.prototype.set=jt;var Nt=O(p,`DataView`),Pt=O(p,`Promise`),Ft=O(p,`Set`),It=`[object Map]`,Lt=`[object Object]`,Rt=`[object Promise]`,zt=`[object Set]`,Bt=`[object WeakMap]`,Vt=`[object DataView]`,Ht=D(Nt),Ut=D(vt),Wt=D(Pt),Gt=D(Ft),Kt=D(ye),N=C;(Nt&&N(new Nt(/* @__PURE__ */ new ArrayBuffer(1)))!=Vt||vt&&N(new vt)!=It||Pt&&N(Pt.resolve())!=Rt||Ft&&N(new Ft)!=zt||ye&&N(new ye)!=Bt)&&(N=function(e){var t=C(e),n=t==Lt?e.constructor:void 0,r=n?D(n):``;if(r)switch(r){case Ht:return Vt;case Ut:return It;case Wt:return Rt;case Gt:return zt;case Kt:return Bt}return t}),p.Uint8Array;var qt=`__lodash_hash_undefined__`;function Jt(e){return this.__data__.set(e,qt),this}function Yt(e){return this.__data__.has(e)}function Xt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new M;++t<n;)this.add(e[t])}Xt.prototype.add=Xt.prototype.push=Jt,Xt.prototype.has=Yt;var Zt=m?m.prototype:void 0;Zt&&Zt.valueOf;function Qt(e){return{"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`,"image/gif":`gif`,"image/svg+xml":`svg`}[e]??`png`}const $t={Formats:l};function en(e,t,n,r){let i=`property.${n}${r?`.${r}`:``}`,a=[`ly.img.plugin-ai-${t}-generation-web.${e}.${i}`,`ly.img.plugin-ai-generation-web.${i}`,`ly.img.plugin-ai-${t}-generation-web.${e}.defaults.${i}`,`ly.img.plugin-ai-generation-web.defaults.${i}`];return r===`placeholder`&&a.push(`ly.img.plugin-ai-generation-web.fallback.property.placeholder`),a}var tn=class{constructor(e,t=[],n){this.id=e,this.translateLabel=n?.translateLabel,this.assets=t.map(e=>{if(typeof e.label==`string`&&!(e.label&&typeof e.label==`object`)){let t=e;return{id:t.id,label:{en:t.label},meta:t.thumbUri?{...t.meta??{},thumbUri:t.thumbUri}:t.meta}}return e}),this.activeAssetIds=/* @__PURE__ */ new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(e){let{page:t,perPage:n,locale:r=`en`,sortActiveFirst:i,query:a,tags:o,groups:s,excludeGroups:c,sortingOrder:l,sortKey:u}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(e=>e.groups&&s.some(t=>e.groups?.includes(t)))),c&&c.length>0&&(d=d.filter(e=>!e.groups||!c.some(t=>e.groups?.includes(t)))),a){let e=a.toLowerCase();d=d.filter(t=>{let n=t.label?.[r]?.toLowerCase(),i=t.tags?.[r]||[];return n&&n.includes(e)||i.some(t=>t.toLowerCase().includes(e))})}if(o&&o.length>0){let e=Array.isArray(o)?o:[o];d=d.filter(t=>{let n=t.tags?.[r]||[];return e.some(e=>n.includes(e))})}i&&d.sort((e,t)=>{let n=this.activeAssetIds.has(e.id),r=this.activeAssetIds.has(t.id);return n&&!r?-1:!n&&r?1:0}),u&&u!==`id`?d.sort((e,t)=>{let n=e.meta?.[u],r=t.meta?.[u];return n===void 0?1:r===void 0?-1:typeof n==`string`&&typeof r==`string`?l===`Descending`?r.localeCompare(n):n.localeCompare(r):typeof n==`number`&&typeof r==`number`?l===`Descending`?r-n:n-r:0}):u===`id`&&d.sort((e,t)=>l===`Descending`?t.id.localeCompare(e.id):e.id.localeCompare(t.id));let f=d.length,p=t*n,m=p+n;return{assets:d.slice(p,m).map(e=>{let t=e.label?.[r]||``,n=this.translateLabel?this.translateLabel(e.id,t,r):t;return{id:e.id,groups:e.groups,meta:e.meta,payload:e.payload,locale:r,label:n,tags:e.tags?.[r],active:this.activeAssetIds.has(e.id)}}),currentPage:t,nextPage:m<f?t+1:void 0,total:f}}updateLabel(e,t,n){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[n]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:t})=>t===e);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:t})=>t===e[0]);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:t})=>t===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(t=>t.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(t=>t.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=/* @__PURE__ */ new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(t=>e.add(t))}),Array.from(e)}getSupportedMimeTypes(){return[`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`video/mp4`,`audio/mpeg`]}},nn=typeof global==`object`&&global&&global.Object===Object&&global,rn=typeof self==`object`&&self&&self.Object===Object&&self,P=nn||rn||Function(`return this`)(),F=P.Symbol,an=Object.prototype,on=an.hasOwnProperty,sn=an.toString,cn=F?F.toStringTag:void 0;function ln(e){var t=on.call(e,cn),n=e[cn];try{e[cn]=void 0;var r=!0}catch{}var i=sn.call(e);return r&&(t?e[cn]=n:delete e[cn]),i}var un=Object.prototype.toString;function dn(e){return un.call(e)}var fn=`[object Null]`,pn=`[object Undefined]`,mn=F?F.toStringTag:void 0;function hn(e){return e==null?e===void 0?pn:fn:mn&&mn in Object(e)?ln(e):dn(e)}function gn(e){return typeof e==`object`&&!!e}Array.isArray;function _n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var vn=`[object AsyncFunction]`,yn=`[object Function]`,bn=`[object GeneratorFunction]`,xn=`[object Proxy]`;function Sn(e){if(!_n(e))return!1;var t=hn(e);return t==yn||t==bn||t==vn||t==xn}var Cn=P[`__core-js_shared__`],wn=function(){var e=/[^.]+$/.exec(Cn&&Cn.keys&&Cn.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Tn(e){return!!wn&&wn in e}var En=Function.prototype.toString;function I(e){if(e!=null){try{return En.call(e)}catch{}try{return e+``}catch{}}return``}var Dn=/[\\^$.*+?()[\]{}|]/g,On=/^\[object .+?Constructor\]$/,kn=Function.prototype,An=Object.prototype,jn=kn.toString,Mn=An.hasOwnProperty,Nn=RegExp(`^`+jn.call(Mn).replace(Dn,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Pn(e){return!_n(e)||Tn(e)?!1:(Sn(e)?Nn:On).test(I(e))}function Fn(e,t){return e?.[t]}function L(e,t){var n=Fn(e,t);return Pn(n)?n:void 0}var In=L(P,`WeakMap`);function Ln(e,t){return e===t||e!==e&&t!==t}var Rn=`[object Arguments]`;function zn(e){return gn(e)&&hn(e)==Rn}var Bn=Object.prototype;Bn.hasOwnProperty,Bn.propertyIsEnumerable,zn(function(){return arguments}());var Vn=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Hn=Vn&&typeof module==`object`&&module&&!module.nodeType&&module,Un=Hn&&Hn.exports===Vn?P.Buffer:void 0;Un&&Un.isBuffer;var Wn=`[object Arguments]`,Gn=`[object Array]`,Kn=`[object Boolean]`,qn=`[object Date]`,Jn=`[object Error]`,Yn=`[object Function]`,Xn=`[object Map]`,Zn=`[object Number]`,Qn=`[object Object]`,$n=`[object RegExp]`,er=`[object Set]`,tr=`[object String]`,nr=`[object WeakMap]`,rr=`[object ArrayBuffer]`,ir=`[object DataView]`,ar=`[object Float32Array]`,or=`[object Float64Array]`,sr=`[object Int8Array]`,cr=`[object Int16Array]`,lr=`[object Int32Array]`,ur=`[object Uint8Array]`,dr=`[object Uint8ClampedArray]`,fr=`[object Uint16Array]`,pr=`[object Uint32Array]`,R={};R[ar]=R[or]=R[sr]=R[cr]=R[lr]=R[ur]=R[dr]=R[fr]=R[pr]=!0,R[Wn]=R[Gn]=R[rr]=R[Kn]=R[ir]=R[qn]=R[Jn]=R[Yn]=R[Xn]=R[Zn]=R[Qn]=R[$n]=R[er]=R[tr]=R[nr]=!1;var mr=typeof exports==`object`&&exports&&!exports.nodeType&&exports,z=mr&&typeof module==`object`&&module&&!module.nodeType&&module,hr=z&&z.exports===mr&&nn.process,gr=function(){try{return z&&z.require&&z.require(`util`).types||hr&&hr.binding&&hr.binding(`util`)}catch{}}();gr&&gr.isTypedArray;var _r=L(Object,`create`);function vr(){this.__data__=_r?_r(null):{},this.size=0}function yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var br=`__lodash_hash_undefined__`,xr=Object.prototype.hasOwnProperty;function Sr(e){var t=this.__data__;if(_r){var n=t[e];return n===br?void 0:n}return xr.call(t,e)?t[e]:void 0}var Cr=Object.prototype.hasOwnProperty;function wr(e){var t=this.__data__;return _r?t[e]!==void 0:Cr.call(t,e)}var Tr=`__lodash_hash_undefined__`;function Er(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=_r&&t===void 0?Tr:t,this}function B(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}B.prototype.clear=vr,B.prototype.delete=yr,B.prototype.get=Sr,B.prototype.has=wr,B.prototype.set=Er;function Dr(){this.__data__=[],this.size=0}function Or(e,t){for(var n=e.length;n--;)if(Ln(e[n][0],t))return n;return-1}var kr=Array.prototype.splice;function Ar(e){var t=this.__data__,n=Or(t,e);return n<0?!1:(n==t.length-1?t.pop():kr.call(t,n,1),--this.size,!0)}function jr(e){var t=this.__data__,n=Or(t,e);return n<0?void 0:t[n][1]}function Mr(e){return Or(this.__data__,e)>-1}function Nr(e,t){var n=this.__data__,r=Or(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function V(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}V.prototype.clear=Dr,V.prototype.delete=Ar,V.prototype.get=jr,V.prototype.has=Mr,V.prototype.set=Nr;var Pr=L(P,`Map`);function Fr(){this.size=0,this.__data__={hash:new B,map:new(Pr||V),string:new B}}function Ir(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Lr(e,t){var n=e.__data__;return Ir(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Rr(e){var t=Lr(this,e).delete(e);return this.size-=+!!t,t}function zr(e){return Lr(this,e).get(e)}function Br(e){return Lr(this,e).has(e)}function Vr(e,t){var n=Lr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function H(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}H.prototype.clear=Fr,H.prototype.delete=Rr,H.prototype.get=zr,H.prototype.has=Br,H.prototype.set=Vr;function Hr(){this.__data__=new V,this.size=0}function Ur(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Wr(e){return this.__data__.get(e)}function Gr(e){return this.__data__.has(e)}var Kr=200;function qr(e,t){var n=this.__data__;if(n instanceof V){var r=n.__data__;if(!Pr||r.length<Kr-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new H(r)}return n.set(e,t),this.size=n.size,this}function Jr(e){var t=this.__data__=new V(e);this.size=t.size}Jr.prototype.clear=Hr,Jr.prototype.delete=Ur,Jr.prototype.get=Wr,Jr.prototype.has=Gr,Jr.prototype.set=qr;var Yr=L(P,`DataView`),Xr=L(P,`Promise`),Zr=L(P,`Set`),Qr=`[object Map]`,$r=`[object Object]`,ei=`[object Promise]`,ti=`[object Set]`,ni=`[object WeakMap]`,ri=`[object DataView]`,ii=I(Yr),ai=I(Pr),oi=I(Xr),si=I(Zr),ci=I(In),U=hn;(Yr&&U(new Yr(/* @__PURE__ */ new ArrayBuffer(1)))!=ri||Pr&&U(new Pr)!=Qr||Xr&&U(Xr.resolve())!=ei||Zr&&U(new Zr)!=ti||In&&U(new In)!=ni)&&(U=function(e){var t=hn(e),n=t==$r?e.constructor:void 0,r=n?I(n):``;if(r)switch(r){case ii:return ri;case ai:return Qr;case oi:return ei;case si:return ti;case ci:return ni}return t}),P.Uint8Array;var li=`__lodash_hash_undefined__`;function ui(e){return this.__data__.set(e,li),this}function di(e){return this.__data__.has(e)}function fi(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new H;++t<n;)this.add(e[t])}fi.prototype.add=fi.prototype.push=ui,fi.prototype.has=di;var pi=F?F.prototype:void 0;pi&&pi.valueOf;function mi(e,t){if(!t.block.isValid(e)||!t.block.supportsFill(e))return[];let n=t.block.getFill(e);return!t.block.isValid(n)||t.block.getType(n)!==`//ly.img.ubq/fill/image`?[]:[...t.block.getSourceSet(n,`fill/image/sourceSet`).map(e=>e.uri),t.block.getString(n,`fill/image/imageFileURI`)].filter(e=>e!=null&&e!==``&&!e.startsWith(`buffer:`))}function hi(e){return e!==void 0}function gi(e){return e?.version?e.version.localeCompare(`1.59.0`,void 0,{numeric:!0,sensitivity:`base`})>=0&&typeof e.i18n?.translate==`function`:!1}function _i(e){return typeof e?.translate==`function`}function vi(e,t,n){return e&&gi(e)&&_i(e.i18n)?e.i18n.translate(t):n}function yi(e,t){return{engine:e,cesdk:t,locale:t?.i18n?.getLocale?.()||`en`}}function bi(e,t,n,r,i){if(t?.default!==void 0){let e=t.default;return typeof e==`function`?e(n):e}return r===void 0?i:r}function xi(e,t){if(typeof e.i18n?.getTranslations!=`function`){e.i18n.setTranslations(t);return}let n=Object.keys(t),r=e.i18n.getTranslations(n),i={};for(let e of n){let n=t[e];if(!n)continue;let a=r[e]??{},o={};for(let[e,t]of Object.entries(n))!(e in a)&&t!==void 0&&(o[e]=t);Object.keys(o).length>0&&(i[e]=o)}Object.keys(i).length>0&&e.i18n.setTranslations(i)}function Si(e,t,n=`style`,r=`image`){return(i,a)=>{if(!gi(e))return a;let o=Ci(t,n,i,r);if(_i(e.i18n)){let t=e.i18n.translate(o);return t===o[o.length-1]?a:t}return a}}function Ci(e,t,n,r=`image`){return[`ly.img.plugin-ai-${r}-generation-web.${e}.property.${t}.${n}`,`ly.img.plugin-ai-generation-web.property.${t}.${n}`,`ly.img.plugin-ai-${r}-generation-web.${e}.defaults.property.${t}.${n}`,`ly.img.plugin-ai-generation-web.defaults.property.${t}.${n}`]}function wi(e,t){let{cesdk:n}=t,r=t.propertyKey??`image_url`,i=t.promptPropertyKey??`prompt`,a=Ni(e);xi(n,{en:{[`panel.${a}`]:`Select Image To Change`,"ly.img.ai.imageSelection.selectImage.label":`Select Image`,"ly.img.ai.imageSelection.error.svg":`SVG images are not supported. Please choose a different image.`,"ly.img.ai.imageSelection.error.invalidType":`Only images are supported. Found '{mimeType}'. Please choose a different image.`,"ly.img.ai.prompt.referenceImage":`Reference image`,"ly.img.ai.prompt.attachSelectedImage":`Use the image selected on the canvas`,"ly.img.ai.prompt.images":`Reference images`,"ly.img.ai.prompt.addImage":`Add image`,"ly.img.ai.prompt.removeImage":`Remove image`}}),Mi(e,n);let o=`${e}.${r}`,s={stateId:o,maxCount:1,isList:!1};return Pi().set(e,s),{[r]:(e,n)=>{let r=Ti(e.experimental.global(o,Ai(e,n.id,t)).value);return()=>Di(n.schema)?{id:n.id,type:`array`,value:r,required:!0}:{id:n.id,type:`string`,value:r[0]??``,required:!0}},[i]:(i,c)=>{let{builder:l,engine:u,experimental:{global:d}}=i,f=i.kind??`image`,p=i.properties?.find(({id:e})=>e===r),m=i.properties==null||p!=null,h=Oi(p?.schema),g=Di(p?.schema);s.maxCount=h,s.isList=g;let _=d(`${e}.${c.id}`,ji(i,c.id,c.schema?.default)??``),v=d(o,Ai(i,r,t)),y=e=>{let t=Ti(v.value);t.includes(e)||v.setValue(Ei([...t,e].slice(-h),g))},b=e=>v.setValue(Ei(Ti(v.value).filter(t=>t!==e),g));return l.PromptInput(`${e}.${c.id}`,{inputLabel:en(e,f,c.id),placeholder:en(e,f,c.id,`placeholder`),..._,attachments:m?{items:ki(u,Ti(v.value),{maxCount:h,attach:y,detach:b}),label:`ly.img.ai.prompt.images`,addLabel:`ly.img.ai.prompt.addImage`,maxCount:h,addIcon:`@imgly/ImageAdd`,onAdd:()=>{n.ui.openPanel(a,{payload:{onSelect:e=>{e.meta?.uri!=null&&y(e.meta.uri)}}})}}:void 0}),()=>({id:c.id,type:`string`,value:_.value})}}}function Ti(e){return Array.isArray(e)?e:e?[e]:[]}function Ei(e,t){return t?e:e[0]??``}function Di(e){return e?.type===`array`}function Oi(e){return Di(e)?e?.maxItems??1:1}function ki(e,t,{maxCount:n,attach:r,detach:i}){let a=e.block.findAllSelected().map(t=>mi(t,e)).filter(e=>e.length>0),o=a.flat(),s=t.map(e=>({id:e,thumbnailUri:e,label:`ly.img.ai.prompt.referenceImage`,isHighlighted:o.includes(e),removeLabel:`ly.img.ai.prompt.removeImage`,onRemove:()=>i(e)})),c=a.filter(e=>!e.some(e=>t.includes(e))).map(([e])=>e),l=[...new Set(c)].slice(0,Math.max(n-t.length,0)).map(e=>({id:e,thumbnailUri:e,label:`ly.img.ai.prompt.attachSelectedImage`,isSuggested:!0,onClick:()=>r(e)}));return[...s,...l]}function Ai(e,t,n){return ji(e,t)??e.payload?.url??n.defaultUrl??``}function ji(e,t,n){return bi(t,e.providerConfig?.properties?.[t]??e.config?.properties?.[t],yi(e.engine),n)}function Mi(e,t){t?.ui.registerPanel(Ni(e),({builder:n,payload:r})=>{n.Library(`${e}.library.image`,{entries:[`ly.img.image`],onSelect:async n=>{let i=n?.meta?.uri;if(i==null)return;let a=await t.engine.editor.getMimeType(i);a===`image/svg+xml`?t.ui.showNotification({type:`warning`,message:`ly.img.ai.imageSelection.error.svg`}):a.startsWith(`image/`)?(r?.onSelect(n),t?.ui.closePanel(Ni(e))):t.ui.showNotification({type:`warning`,message:`ly.img.ai.imageSelection.error.invalidType`})}})})}function Ni(e){return`ly.img.ai.${e}.imageSelection`}function Pi(){let e=`__imgly_ai_prompt_image_entries__`,t=typeof window<`u`?window:globalThis;return t[e]??(t[e]=/* @__PURE__ */ new Map),t[e]}function Fi(e,t){let{cesdk:n}=t;if(n==null)return{};let r=t.propertyKey??`style`,i=Li(e);xi(n,{en:{[`panel.${i}`]:`Select Style`,[`${e}.${r}`]:`Style`,"ly.img.ai.styleTransfer.none":`None`,"ly.img.ai.styleTransfer.anime":`Anime`,"ly.img.ai.styleTransfer.cyberpunk":`Cyberpunk`,"ly.img.ai.styleTransfer.kodak400":`Kodak 400`,"ly.img.ai.styleTransfer.watercolor":`Watercolor`,"ly.img.ai.styleTransfer.darkFantasy":`Dark Fantasy`,"ly.img.ai.styleTransfer.vaporwave":`Vaporwave`,"ly.img.ai.styleTransfer.vectorFlat":`Vector Flat`,"ly.img.ai.styleTransfer.3dAnimation":`3D Animation`,"ly.img.ai.styleTransfer.ukiyoe":`Ukiyo‑e`,"ly.img.ai.styleTransfer.surreal":`Surreal`,"ly.img.ai.styleTransfer.steampunk":`Steampunk`,"ly.img.ai.styleTransfer.nightBokeh":`Night Bokeh`,"ly.img.ai.styleTransfer.popArt":`Pop Art`}});let a=zi({baseURL:t.baseURL??`https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/`,includeNone:!0,cesdk:n}),o=a;t.styles!=null&&(Array.isArray(t.styles)?o=t.styles:typeof t.styles==`function`&&(o=t.styles(a)));let s=Bi({cesdk:n,providerId:e,styles:o}),c=s.id;return Vi(s,{cesdk:n}),Ii({providerId:e,cesdk:n,panelId:i,entryId:c}),{[t.propertyKeyForPrompt??`prompt`]:(e,n)=>{let r=e.state(`prompt`,``);return e.builder.PromptInput(`${n.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??`prompt`,placeholder:t.i18n?.prompt?.placeholder,...r}),()=>{let[e]=s.getActiveAssetIds(),t=s.getAsset(e);return{id:n.id,type:`string`,value:t?.meta?.prompt==null?r.value:`${r.value}; ${t.meta.prompt}`}}},[r]:(t,r)=>{let{builder:a,state:c}=t;if(o.length>0){let t=c(`style`,o[0]);return a.Button(`${r.id}`,{inputLabel:`${e}.${r.id}`,icon:`@imgly/Appearance`,isDisabled:o.length===0,trailingIcon:`@imgly/ChevronRight`,label:t.value.label,labelAlignment:`left`,onClick:()=>{n.ui.openPanel(i,{payload:{onSelect:async e=>{s.clearActiveAssets(),s.setAssetActive(e.id),t.setValue({id:e.id,label:e.label??e.id}),n.ui.closePanel(i)}}})}}),()=>({id:r.id,type:`string`,value:t.value.id})}return()=>({id:r.id,type:`string`,value:`none`})}}}function Ii(e){let{providerId:t,cesdk:n,panelId:r,entryId:i}=e;n?.ui.registerPanel(r,({builder:e,payload:n})=>{n?.onSelect??e.Section(`${t}.error`,{children:()=>{e.Text(`error`,{content:`No onSelect function provided for the style selection panel.`})}}),e.Library(`${t}.library.image`,{entries:[i],onSelect:async e=>{n?.onSelect?.(e)}})})}function Li(e){return`ly.img.ai.${e}.styleSelection`}const Ri=[{id:`none`,labelKey:`ly.img.ai.styleTransfer.none`,prompt:``},{id:`anime-celshaded`,labelKey:`ly.img.ai.styleTransfer.anime`,prompt:`anime cel‑shaded, bright pastel palette, expressive eyes, clean line art `},{id:`cyberpunk-neon`,labelKey:`ly.img.ai.styleTransfer.cyberpunk`,prompt:`cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere`},{id:`kodak-portra-400`,labelKey:`ly.img.ai.styleTransfer.kodak400`,prompt:`shot on Kodak Portra 400, soft grain, golden‑hour warmth, 35 mm photo`},{id:`watercolor-storybook`,labelKey:`ly.img.ai.styleTransfer.watercolor`,prompt:`loose watercolor washes, gentle gradients, dreamy storybook feel`},{id:`dark-fantasy-realism`,labelKey:`ly.img.ai.styleTransfer.darkFantasy`,prompt:`dark fantasy realm, moody chiaroscuro lighting, hyper‑real textures`},{id:`vaporwave-retrofuturism`,labelKey:`ly.img.ai.styleTransfer.vaporwave`,prompt:`retro‑futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines`},{id:`minimal-vector-flat`,labelKey:`ly.img.ai.styleTransfer.vectorFlat`,prompt:`minimalist flat vector illustration, bold geometry, two‑tone palette`},{id:`pixarstyle-3d-render`,labelKey:`ly.img.ai.styleTransfer.3dAnimation`,prompt:`Pixar‑style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting`},{id:`ukiyoe-woodblock`,labelKey:`ly.img.ai.styleTransfer.ukiyoe`,prompt:`ukiyo‑e woodblock print, Edo‑period style, visible washi texture, limited color ink`},{id:`surreal-dreamscape`,labelKey:`ly.img.ai.styleTransfer.surreal`,prompt:`surreal dreamscape, floating objects, impossible architecture, vivid clouds`},{id:`steampunk-victorian`,labelKey:`ly.img.ai.styleTransfer.steampunk`,prompt:`Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog`},{id:`nightstreet-photo-bokeh`,labelKey:`ly.img.ai.styleTransfer.nightBokeh`,prompt:`night‑time street shot, large aperture bokeh lights, candid urban mood`},{id:`comicbook-pop-art`,labelKey:`ly.img.ai.styleTransfer.popArt`,prompt:`classic comic‑book panel, halftone shading, exaggerated action lines, CMYK pop colors`}];function zi(e){return Ri.map(t=>t.id===`none`?e.includeNone?{id:t.id,label:vi(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/None.svg`}:void 0:{id:t.id,label:vi(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/${t.id}.jpeg`}).filter(hi)}const Bi=e=>{let t=e.styles.map(e=>({...e,meta:{prompt:e.prompt}})),n=e.cesdk.engine.asset.findAllSources(),r=`${e.providerId}/styles`;for(;n.includes(r);)r+=`-${Math.random().toString(36).substring(2,5)}`;let i=new tn(r,t),a=e.styles[0];return i.setAssetActive(a.id),i},Vi=(e,t)=>{t.cesdk.engine.asset.addSource(e),t.cesdk.ui.addAssetLibraryEntry({id:e.id,sourceIds:[e.id],gridItemHeight:`square`,gridBackgroundType:`cover`,cardLabel:({label:e})=>e,cardLabelPosition:()=>`below`})};function Hi(e){return`ly.img.ai.${e}`}function Ui(e){return`${e.replace(/\/+$/,``)}/`}function Wi(e,t){let n={...e};if(!t)return n;for(let[r,i]of Object.entries(t))i===!1||i==null?delete n[r]:i===!0?r in e||(n[r]=!0):n[r]=i;return n}const Gi={ImageUrl:wi,StyleTransfer:Fi};var Ki={openapi:`3.0.0`,info:{title:`Fal Queue API`,version:`1.0.0`,description:`The Fal Queue API.`},components:{securitySchemes:{apiKeyAuth:{type:`apiKey`,in:`header`,name:`Authorization`,description:`Fal Key`}},schemas:{QueueStatus:{type:`object`,properties:{status:{type:`string`,enum:[`IN_QUEUE`,`IN_PROGRESS`,`COMPLETED`]},request_id:{type:`string`,description:`The request id.`},response_url:{type:`string`,description:`The response url.`},status_url:{type:`string`,description:`The status url.`},cancel_url:{type:`string`,description:`The cancel url.`},logs:{type:`object`,description:`The logs.`,additionalProperties:!0},metrics:{type:`object`,description:`The metrics.`,additionalProperties:!0},queue_position:{type:`integer`,description:`The queue position.`}},required:[`status`,`request_id`]},Recraft20bInput:{title:`TextToImageInput`,type:`object`,properties:{prompt:{title:`Prompt`,type:`string`,"x-imgly-builder":{component:`TextArea`}},image_size:{anyOf:[{enum:[`square_hd`,`square`,`portrait_4_3`,`portrait_16_9`,`landscape_4_3`,`landscape_16_9`],type:`string`},{$ref:`#/components/schemas/ImageSize`}],title:`Format`,default:`square_hd`,"x-imgly-enum-labels":{ImageSize:`Custom`,square_hd:`Square HD`,square:`Square`,portrait_4_3:`Portrait 4:3`,portrait_16_9:`Portrait 16:9`,landscape_4_3:`Landscape 4:3`,landscape_16_9:`Landscape 16:9`},"x-imgly-enum-icons":{square:`@imgly/plugin/formats/ratio1by1`,square_hd:`@imgly/plugin/formats/ratio1by1`,portrait_4_3:`@imgly/plugin/formats/ratio3by4`,portrait_16_9:`@imgly/plugin/formats/ratio9by16`,landscape_4_3:`@imgly/plugin/formats/ratio4by3`,landscape_16_9:`@imgly/plugin/formats/ratio16by9`,ImageSize:`@imgly/plugin/formats/ratioFree`}},style:{enum:/* @__PURE__ */ `any.realistic_image.digital_illustration.vector_illustration.realistic_image/b_and_w.realistic_image/hard_flash.realistic_image/hdr.realistic_image/natural_light.realistic_image/studio_portrait.realistic_image/enterprise.realistic_image/motion_blur.realistic_image/evening_light.realistic_image/faded_nostalgia.realistic_image/forest_life.realistic_image/mystic_naturalism.realistic_image/natural_tones.realistic_image/organic_calm.realistic_image/real_life_glow.realistic_image/retro_realism.realistic_image/retro_snapshot.realistic_image/urban_drama.realistic_image/village_realism.realistic_image/warm_folk.digital_illustration/pixel_art.digital_illustration/hand_drawn.digital_illustration/grain.digital_illustration/infantile_sketch.digital_illustration/2d_art_poster.digital_illustration/handmade_3d.digital_illustration/hand_drawn_outline.digital_illustration/engraving_color.digital_illustration/2d_art_poster_2.digital_illustration/antiquarian.digital_illustration/bold_fantasy.digital_illustration/child_book.digital_illustration/child_books.digital_illustration/cover.digital_illustration/crosshatch.digital_illustration/digital_engraving.digital_illustration/expressionism.digital_illustration/freehand_details.digital_illustration/grain_20.digital_illustration/graphic_intensity.digital_illustration/hard_comics.digital_illustration/long_shadow.digital_illustration/modern_folk.digital_illustration/multicolor.digital_illustration/neon_calm.digital_illustration/noir.digital_illustration/nostalgic_pastel.digital_illustration/outline_details.digital_illustration/pastel_gradient.digital_illustration/pastel_sketch.digital_illustration/pop_art.digital_illustration/pop_renaissance.digital_illustration/street_art.digital_illustration/tablet_sketch.digital_illustration/urban_glow.digital_illustration/urban_sketching.digital_illustration/vanilla_dreams.digital_illustration/young_adult_book.digital_illustration/young_adult_book_2.vector_illustration/bold_stroke.vector_illustration/chemistry.vector_illustration/colored_stencil.vector_illustration/contour_pop_art.vector_illustration/cosmics.vector_illustration/cutout.vector_illustration/depressive.vector_illustration/editorial.vector_illustration/emotional_flat.vector_illustration/infographical.vector_illustration/marker_outline.vector_illustration/mosaic.vector_illustration/naivector.vector_illustration/roundish_flat.vector_illustration/segmented_colors.vector_illustration/sharp_contrast.vector_illustration/thin.vector_illustration/vector_photo.vector_illustration/vivid_shapes.vector_illustration/engraving.vector_illustration/line_art.vector_illustration/line_circuit.vector_illustration/linocut.icon/broken_line.icon/colored_outline.icon/colored_shapes.icon/colored_shapes_gradient.icon/doodle_fill.icon/doodle_offset_fill.icon/offset_fill.icon/outline.icon/outline_gradient.icon/uneven_fill`.split(`.`),title:`Style`,type:`string`,description:`The style of the generated images. Vector images cost 2X as much.`,default:`realistic_image`},colors:{title:`Colors`,type:`array`,description:`An array of preferable colors`,items:{$ref:`#/components/schemas/RGBColor`},default:[]}},"x-fal-order-properties":[`prompt`,`style`,`image_size`],required:[`prompt`]},Recraft20bOutput:{title:`TextToImageOutput`,type:`object`,properties:{images:{title:`Images`,type:`array`,items:{$ref:`#/components/schemas/File`}}},"x-fal-order-properties":[`images`],required:[`images`]},ImageSize:{title:`ImageSize`,type:`object`,properties:{height:{maximum:14142,type:`integer`,title:`Height`,description:`The height of the generated image.`,exclusiveMinimum:0,default:512},width:{maximum:14142,type:`integer`,title:`Width`,description:`The width of the generated image.`,exclusiveMinimum:0,default:512}},"x-fal-order-properties":[`width`,`height`]},RGBColor:{title:`RGBColor`,type:`object`,properties:{r:{minimum:0,maximum:255,type:`integer`,title:`R`,description:`Red color value`,default:0},b:{minimum:0,maximum:255,type:`integer`,title:`B`,description:`Blue color value`,default:0},g:{minimum:0,maximum:255,type:`integer`,title:`G`,description:`Green color value`,default:0}},"x-fal-order-properties":[`r`,`g`,`b`]},File:{title:`File`,type:`object`,properties:{file_size:{title:`File Size`,type:`integer`,description:`The size of the file in bytes.`},file_name:{title:`File Name`,type:`string`,description:`The name of the file. It will be auto-generated if not provided.`},content_type:{title:`Content Type`,type:`string`,description:`The mime type of the file.`},url:{title:`Url`,type:`string`,description:`The URL where the file can be downloaded from.`},file_data:{format:`binary`,title:`File Data`,type:`string`,description:`File data`}},"x-fal-order-properties":[`url`,`content_type`,`file_name`,`file_size`,`file_data`],required:[`url`]}}},paths:{"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/status":{get:{parameters:[{name:`request_id`,in:`path`,required:!0,schema:{type:`string`,description:`Request ID`}},{name:`logs`,in:`query`,required:!1,schema:{type:`number`,description:"Whether to include logs (`1`) in the response or not (`0`)."}}],responses:{200:{description:`The request status.`,content:{"application/json":{schema:{$ref:`#/components/schemas/QueueStatus`}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/cancel":{put:{parameters:[{name:`request_id`,in:`path`,required:!0,schema:{type:`string`,description:`Request ID`}}],responses:{200:{description:`The request was cancelled.`,content:{"application/json":{schema:{type:`object`,properties:{success:{type:`boolean`,description:`Whether the request was cancelled successfully.`}}}}}}}}},"/fal-ai/recraft/v2/text-to-image":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:`#/components/schemas/Recraft20bInput`}}}},responses:{200:{description:`The request status.`,content:{"application/json":{schema:{$ref:`#/components/schemas/QueueStatus`}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}":{get:{parameters:[{name:`request_id`,in:`path`,required:!0,schema:{type:`string`,description:`Request ID`}}],responses:{200:{description:`Result of the request.`,content:{"application/json":{schema:{$ref:`#/components/schemas/Recraft20bOutput`}}}}}}}},servers:[{url:`https://queue.fal.run`}],security:[{apiKeyAuth:[]}]};const qi={square_hd:{width:1024,height:1024},square:{width:512,height:512},portrait_4_3:{width:1024,height:1365},portrait_16_9:{width:1024,height:1820},landscape_4_3:{width:1365,height:1024},landscape_16_9:{width:1820,height:1024}};function Ji(e){return qi[e]}const Yi=[{id:`icon/broken_line`,label:`Broken Line`},{id:`icon/colored_outline`,label:`Colored Outline`},{id:`icon/colored_shapes`,label:`Colored Shapes`},{id:`icon/colored_shapes_gradient`,label:`Colored Shapes Gradient`},{id:`icon/doodle_fill`,label:`Doodle Fill`},{id:`icon/doodle_offset_fill`,label:`Doodle Offset Fill`},{id:`icon/offset_fill`,label:`Offset Fill`},{id:`icon/outline`,label:`Outline`},{id:`icon/outline_gradient`,label:`Outline Gradient`},{id:`icon/uneven_fill`,label:`Uneven Fill`}];Yi[0];const Xi=e=>({realistic_image:`${e}realistic_image.webp`,digital_illustration:`${e}digital_illustration.webp`,"realistic_image/b_and_w":`${e}realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${e}realistic_image_hard_flash.webp`,"realistic_image/hdr":`${e}realistic_image_hdr.webp`,"realistic_image/natural_light":`${e}realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${e}realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${e}realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${e}realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${e}digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${e}digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${e}digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${e}digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${e}digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${e}digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${e}digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${e}digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${e}digital_illustration_2d_artposter_2.webp`,vector_illustration:`${e}vector_illustration.svg`,"vector_illustration/bold_stroke":`${e}vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${e}vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${e}vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${e}vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${e}vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${e}vector_illustration_cutout.svg`,"vector_illustration/depressive":`${e}vector_illustration_depressive.svg`,"vector_illustration/editorial":`${e}vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${e}vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${e}vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${e}vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${e}vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${e}vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${e}vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${e}vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${e}vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${e}vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${e}vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${e}vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${e}vector_illustration_engraving.svg`,"vector_illustration/line_art":`${e}vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${e}vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${e}vector_illustration_linocut.svg`,"realistic_image/evening_light":`${e}realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${e}realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${e}realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${e}realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${e}realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${e}realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${e}realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${e}realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${e}realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${e}realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${e}realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${e}realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${e}digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${e}digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${e}digital_illustration_child_book.webp`,"digital_illustration/child_books":`${e}digital_illustration_child_books.webp`,"digital_illustration/cover":`${e}digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${e}digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${e}digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${e}digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${e}digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${e}digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${e}digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${e}digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${e}digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${e}digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${e}digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${e}digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${e}digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${e}digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${e}digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${e}digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${e}digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${e}digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${e}digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${e}digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${e}digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${e}digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${e}digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${e}digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${e}digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${e}digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${e}icon_broken_line.svg`,"icon/colored_outline":`${e}icon_colored_outline.svg`,"icon/colored_shapes":`${e}icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${e}icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${e}icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${e}icon_doodle_offset_fill.svg`,"icon/offset_fill":`${e}icon_offset_fill.svg`,"icon/outline":`${e}icon_outline.svg`,"icon/outline_gradient":`${e}icon_outline_gradient.svg`,"icon/uneven_fill":`${e}icon_uneven_fill.svg`});function Zi(e,t){return Xi(`${t}thumbnails/`)[e]}var Qi=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.TARGET_URL_HEADER=void 0,e.withMiddleware=i,e.withProxy=a;function i(...e){let t=e=>typeof e==`function`;return n=>r(this,void 0,void 0,function*(){let r=Object.assign({},n);for(let n of e.filter(t))r=yield n(r);return r})}e.TARGET_URL_HEADER=`x-fal-target-url`;function a(t){let n=e=>Promise.resolve(e);return typeof window>`u`?n:r=>r.headers&&e.TARGET_URL_HEADER in r?n(r):Promise.resolve(Object.assign(Object.assign({},r),{url:t.targetUrl,headers:Object.assign(Object.assign({},r.headers||{}),{[e.TARGET_URL_HEADER]:r.url})}))}})),$i=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RUNNER_HINT_HEADER=e.QUEUE_PRIORITY_HEADER=e.REQUEST_TIMEOUT_TYPE_HEADER=e.REQUEST_TIMEOUT_HEADER=e.MIN_REQUEST_TIMEOUT_SECONDS=void 0,e.validateTimeoutHeader=t,e.buildTimeoutHeaders=n,e.MIN_REQUEST_TIMEOUT_SECONDS=1,e.REQUEST_TIMEOUT_HEADER=`x-fal-request-timeout`,e.REQUEST_TIMEOUT_TYPE_HEADER=`x-fal-request-timeout-type`,e.QUEUE_PRIORITY_HEADER=`x-fal-queue-priority`,e.RUNNER_HINT_HEADER=`x-fal-runner-hint`;function t(t){if(typeof t!=`number`||isNaN(t))throw Error(`Timeout must be a number, got ${t}`);if(t<=e.MIN_REQUEST_TIMEOUT_SECONDS)throw Error(`Timeout must be greater than ${e.MIN_REQUEST_TIMEOUT_SECONDS} seconds`);return t.toString()}function n(n){return n===void 0?{}:{[e.REQUEST_TIMEOUT_HEADER]:t(n)}}})),W=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.ValidationError=e.ApiError=void 0,e.defaultResponseHandler=c,e.resultResponseHandler=l;let i=$i(),a=`x-fal-request-id`;var o=class extends Error{constructor({message:e,status:t,body:n,requestId:r,timeoutType:i}){super(e),this.name=`ApiError`,this.status=t,this.body=n,this.requestId=r||``,this.timeoutType=i}get isUserTimeout(){return this.status===504&&this.timeoutType===`user`}};e.ApiError=o;var s=class extends o{constructor(e){super(e),this.name=`ValidationError`}get fieldErrors(){return typeof this.body.detail==`string`?[{loc:[`body`],msg:this.body.detail,type:`value_error`}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(t=>t.loc[t.loc.length-1]===e)}};e.ValidationError=s;function c(e){return r(this,void 0,void 0,function*(){let{status:t,statusText:n}=e,r=e.headers.get(`Content-Type`)??``,c=e.headers.get(a)||void 0,l=e.headers.get(i.REQUEST_TIMEOUT_TYPE_HEADER)||void 0;if(!e.ok){if(r.includes(`application/json`)){let r=yield e.json();throw new(t===422?s:o)({message:r.message||n,status:t,body:r,requestId:c,timeoutType:l})}throw new o({message:`HTTP ${t}: ${n}`,status:t,requestId:c,timeoutType:l})}return r.includes(`application/json`)?e.json():r.includes(`text/html`)?e.text():r.includes(`application/octet-stream`)?e.arrayBuffer():e.text()})}function l(e){return r(this,void 0,void 0,function*(){return{data:yield c(e),requestId:e.headers.get(a)||``}})}})),G=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.ensureEndpointIdFormat=i,e.parseEndpointId=o,e.isValidUrl=s,e.throttle=c,e.isReact=u,e.isPlainObject=d,e.sleep=f;function i(e){if(e.split(`/`).length>1)return e;let[,t,n]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(e)||[];if(t&&n)return`${t}/${n}`;throw Error(`Invalid app id: ${e}. Must be in the format <appOwner>/<appId>`)}let a=[`workflows`,`comfy`];function o(e){let t=i(e).split(`/`);return a.includes(t[0])?{owner:t[1],alias:t[2],path:t.slice(3).join(`/`)||void 0,namespace:t[0]}:{owner:t[0],alias:t[1],path:t.slice(2).join(`/`)||void 0}}function s(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function c(e,t,n=!1){let r,i;return(...a)=>{!i&&n?(e(...a),i=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-i>=t&&(e(...a),i=Date.now())},t-(Date.now()-i)))}}let l;function u(){if(l===void 0){let e=(/* @__PURE__ */ Error()).stack;l=!!e&&(e.includes(`node_modules/react-dom/`)||e.includes(`node_modules/next/`))}return l}function d(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function f(e){return r(this,void 0,void 0,function*(){return new Promise(t=>setTimeout(t,e))})}})),ea=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_RETRY_OPTIONS=e.DEFAULT_RETRYABLE_STATUS_CODES=void 0,e.isRetryableError=o,e.calculateBackoffDelay=s,e.executeWithRetry=c;let i=W(),a=G();e.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504],e.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:e.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function o(e,t){return!(e instanceof i.ApiError)||e.isUserTimeout?!1:t.includes(e.status)}function s(e,t,n,r,i){let a=Math.min(t*r**+e,n);if(i){let e=.25*a*(Math.random()*2-1);return Math.max(0,a+e)}return a}function c(e,t,n){return r(this,void 0,void 0,function*(){let r={totalAttempts:0,totalDelay:0},i;for(let c=0;c<=t.maxRetries;c++){r.totalAttempts++;try{return{result:yield e(),metrics:r}}catch(e){if(i=e,r.lastError=e,c===t.maxRetries||!o(e,t.retryableStatusCodes))throw e;let l=s(c,t.baseDelay,t.maxDelay,t.backoffMultiplier,t.enableJitter);r.totalDelay+=l,n&&n(c+1,e,l),yield(0,a.sleep)(l)}}throw i})}})),ta=/* @__PURE__ */ a(((e,t)=>{t.exports={name:`@fal-ai/client`,description:`The fal.ai client for JavaScript and TypeScript`,version:`1.9.0`,license:`MIT`,repository:{type:`git`,url:`https://github.com/fal-ai/fal-js.git`,directory:`libs/client`},keywords:[`fal`,`client`,`ai`,`ml`,`typescript`],exports:{".":`./src/index.js`,"./endpoints":`./src/types/endpoints.js`},typesVersions:{"*":{endpoints:[`src/types/endpoints.d.ts`]}},main:`./src/index.js`,types:`./src/index.d.ts`,dependencies:{"@msgpack/msgpack":`^3.0.0-beta2`,"eventsource-parser":`^1.1.2`,robot3:`^0.4.1`},engines:{node:`>=18.0.0`},type:`commonjs`}})),na=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowser=t,e.getUserAgent=r;function t(){return typeof window<`u`&&window.document!==void 0}let n=null;function r(){if(n!==null)return n;let e=ta();return n=`${e.name}/${e.version}`,n}})),ra=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.credentialsFromEnv=void 0,e.resolveDefaultFetch=a,e.createConfig=c,e.getRestApiUrl=l;let t=Qi(),n=W(),r=ea(),i=na();function a(){if(typeof fetch>`u`)throw Error(`Your environment does not support fetch. Please provide your own fetch implementation.`);return fetch}function o(){return typeof process<`u`&&process.env&&(process.env.FAL_KEY!==void 0||process.env.FAL_KEY_ID!==void 0&&process.env.FAL_KEY_SECRET!==void 0)}e.credentialsFromEnv=()=>{if(o())return process.env.FAL_KEY===void 0?process.env.FAL_KEY_ID?`${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}`:void 0:process.env.FAL_KEY};let s={credentials:e.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:n.defaultResponseHandler,retry:r.DEFAULT_RETRY_OPTIONS};function c(e){let n=Object.assign(Object.assign(Object.assign({},s),e),{fetch:e.fetch??a(),retry:Object.assign(Object.assign({},r.DEFAULT_RETRY_OPTIONS),e.retry||{})});e.proxyUrl&&(n=Object.assign(Object.assign({},n),{requestMiddleware:(0,t.withMiddleware)(n.requestMiddleware,(0,t.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:o,suppressLocalCredentialsWarning:c}=n,l=typeof o==`function`?o():o;return(0,i.isBrowser)()&&l&&!c&&console.warn(`The fal credentials are exposed in the browser's environment. That's not recommended for production use cases.`),n}function l(){return`https://rest.alpha.fal.ai`}})),ia=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},i=n&&n.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};Object.defineProperty(e,"__esModule",{value:!0}),e.dispatchRequest=l,e.buildUrl=u;let a=ea(),o=na(),s=G(),c=typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)===`Cloudflare-Workers`;function l(e){return r(this,void 0,void 0,function*(){let{targetUrl:t,input:n,config:l,options:u={}}=e,{credentials:d,requestMiddleware:f,responseHandler:p,fetch:m}=l,h=Object.assign(Object.assign({},l.retry),u.retry||{}),g=()=>r(this,void 0,void 0,function*(){let r=(0,o.isBrowser)()?{}:{"User-Agent":(0,o.getUserAgent)()},a=typeof d==`function`?d():d,{method:s,url:l,headers:h}=yield f({method:(e.method??u.method??`post`).toUpperCase(),url:t,headers:e.headers}),g=a?{Authorization:`Key ${a}`}:{},_=Object.assign(Object.assign(Object.assign(Object.assign({},g),{Accept:`application/json`,"Content-Type":`application/json`}),r),h??{}),{responseHandler:v,retry:y}=u,b=i(u,[`responseHandler`,`retry`]),ee=yield m(l,Object.assign(Object.assign(Object.assign(Object.assign({},b),{method:s,headers:Object.assign(Object.assign({},_),b.headers??{})}),!c&&{mode:`cors`}),{signal:u.signal,body:s.toLowerCase()!==`get`&&n?JSON.stringify(n):void 0}));return yield(v??p)(ee)}),_;for(let e=0;e<=h.maxRetries;e++)try{return yield g()}catch(t){if(_=t,e===h.maxRetries||!(0,a.isRetryableError)(t,h.retryableStatusCodes)||u.signal?.aborted)throw t;let n=(0,a.calculateBackoffDelay)(e,h.baseDelay,h.maxDelay,h.backoffMultiplier,h.enableJitter);yield(0,s.sleep)(n)}throw _})}function u(e,t={}){let n=(t.method??`post`).toLowerCase(),r=(t.path??``).replace(/^\//,``).replace(/\/{2,}/,`/`),i=t.input,a=Object.assign(Object.assign({},t.query||{}),n===`get`?i:{}),o=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:``;if((0,s.isValidUrl)(e))return`${e.endsWith(`/`)?e:`${e}/`}${r}${o}`;let c=(0,s.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:``}fal.run/${c}/${r}`.replace(/\/$/,``)}${o}`}})),aa=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.OBJECT_LIFECYCYLE_PREFERENCE_HEADER=void 0,e.getExpirationDurationSeconds=c,e.buildObjectLifecycleHeaders=l,e.createStorageClient=h;let i=ra(),a=ia(),o=G();e.OBJECT_LIFECYCYLE_PREFERENCE_HEADER=`x-fal-object-lifecycle-preference`;let s={never:31536e5,immediate:void 0,"1h":3600,"1d":86400,"7d":604800,"30d":2592e3,"1y":31536e3};function c(e){let{expiresIn:t}=e;return typeof t==`number`?t:s[t]}function l(t){if(!t)return{};let n=c(t);return n===void 0?{}:{[e.OBJECT_LIFECYCYLE_PREFERENCE_HEADER]:JSON.stringify({expiration_duration_seconds:n})}}function u(e){let[,t]=e.split(`/`);return t.split(/[-;]/)[0]??`bin`}function d(e,t,n,o){return r(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${u(n)}`,s={};if(o){let e={expiration_duration_seconds:c(o),allow_io_storage:o.expiresIn!==`immediate`};s[`X-Fal-Object-Lifecycle`]=JSON.stringify(e)}return yield(0,a.dispatchRequest)({method:`POST`,targetUrl:`${(0,i.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:n,file_name:r},config:t,headers:s})})}function f(e,t,n,o){return r(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${u(n)}`,s={};return o&&(s[`X-Fal-Object-Lifecycle`]=JSON.stringify(o)),yield(0,a.dispatchRequest)({method:`POST`,targetUrl:`${(0,i.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:n,file_name:r},config:t,headers:s})})}function p(e,t,n){return r(this,arguments,void 0,function*(e,t,n,r=3){if(r===0)throw Error(`Part upload failed, retries exhausted`);let{fetch:i,responseHandler:a}=n;try{return yield a(yield i(e,{method:`PUT`,body:t}))}catch{return yield p(e,t,n,r-1)}})}function m(e,t,n){return r(this,void 0,void 0,function*(){let{fetch:r,responseHandler:i}=t,{upload_url:a,file_url:o}=yield f(e,t,e.type||`application/octet-stream`,n),s=10485760,c=Math.ceil(e.size/s),l=new URL(a),u=[];for(let n=0;n<c;n++){let r=n*s,i=Math.min(r+s,e.size),a=e.slice(r,i),o=n+1,c=`${l.origin}${l.pathname}/${o}${l.search}`;u.push(yield p(c,a,t))}return yield i(yield r(`${l.origin}${l.pathname}/complete${l.search}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({parts:u.map(e=>({partNumber:e.partNumber,etag:e.etag}))})})),o})}function h({config:e}){let t={upload:(t,n)=>r(this,void 0,void 0,function*(){let r=n?.lifecycle;if(t.size>94371840)return yield m(t,e,r);let i=t.type||`application/octet-stream`,{fetch:a,responseHandler:o}=e,{upload_url:s,file_url:c}=yield d(t,e,i,r);return yield o(yield a(s,{method:`PUT`,body:t,headers:{"Content-Type":t.type||`application/octet-stream`}})),c}),transformInput:e=>r(this,void 0,void 0,function*(){if(Array.isArray(e))return Promise.all(e.map(e=>t.transformInput(e)));if(e instanceof Blob)return yield t.upload(e);if((0,o.isPlainObject)(e)){let n=Object.entries(e).map(e=>r(this,[e],void 0,function*([e,n]){return[e,yield t.transformInput(n)]})),i=yield Promise.all(n);return Object.fromEntries(i)}return e})};return t}})),oa=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t,i,a,o,s,c,l;return u(),{feed:d,reset:u};function u(){t=!0,i=``,a=0,o=-1,s=void 0,c=void 0,l=``}function d(e){i=i?i+e:e,t&&r(i)&&(i=i.slice(n.length)),t=!1;let s=i.length,c=0,l=!1;for(;c<s;){l&&=(i[c]===`
|
|
67
|
+
`,u=class{constructor(e,t=[],n){this.id=e,this.translateLabel=n?.translateLabel,this.assets=t.map(e=>{if(typeof e.label==`string`&&!(e.label&&typeof e.label==`object`)){let t=e;return{id:t.id,label:{en:t.label},meta:t.thumbUri?{...t.meta??{},thumbUri:t.thumbUri}:t.meta}}return e}),this.activeAssetIds=/* @__PURE__ */ new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(e){let{page:t,perPage:n,locale:r=`en`,sortActiveFirst:i,query:a,tags:o,groups:s,excludeGroups:c,sortingOrder:l,sortKey:u}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(e=>e.groups&&s.some(t=>e.groups?.includes(t)))),c&&c.length>0&&(d=d.filter(e=>!e.groups||!c.some(t=>e.groups?.includes(t)))),a){let e=a.toLowerCase();d=d.filter(t=>{let n=t.label?.[r]?.toLowerCase(),i=t.tags?.[r]||[];return n&&n.includes(e)||i.some(t=>t.toLowerCase().includes(e))})}if(o&&o.length>0){let e=Array.isArray(o)?o:[o];d=d.filter(t=>{let n=t.tags?.[r]||[];return e.some(e=>n.includes(e))})}i&&d.sort((e,t)=>{let n=this.activeAssetIds.has(e.id),r=this.activeAssetIds.has(t.id);return n&&!r?-1:!n&&r?1:0}),u&&u!==`id`?d.sort((e,t)=>{let n=e.meta?.[u],r=t.meta?.[u];return n===void 0?1:r===void 0?-1:typeof n==`string`&&typeof r==`string`?l===`Descending`?r.localeCompare(n):n.localeCompare(r):typeof n==`number`&&typeof r==`number`?l===`Descending`?r-n:n-r:0}):u===`id`&&d.sort((e,t)=>l===`Descending`?t.id.localeCompare(e.id):e.id.localeCompare(t.id));let f=d.length,p=t*n,m=p+n;return{assets:d.slice(p,m).map(e=>{let t=e.label?.[r]||``,n=this.translateLabel?this.translateLabel(e.id,t,r):t;return{id:e.id,groups:e.groups,meta:e.meta,payload:e.payload,locale:r,label:n,tags:e.tags?.[r],active:this.activeAssetIds.has(e.id)}}),currentPage:t,nextPage:m<f?t+1:void 0,total:f}}updateLabel(e,t,n){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[n]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:t})=>t===e);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:t})=>t===e[0]);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:t})=>t===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(t=>t.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(t=>t.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=/* @__PURE__ */ new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(t=>e.add(t))}),Array.from(e)}getSupportedMimeTypes(){return[`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`video/mp4`,`audio/mpeg`]}},d=typeof global==`object`&&global&&global.Object===Object&&global,f=typeof self==`object`&&self&&self.Object===Object&&self,p=d||f||Function(`return this`)(),m=p.Symbol,h=Object.prototype,g=h.hasOwnProperty,_=h.toString,v=m?m.toStringTag:void 0;function y(e){var t=g.call(e,v),n=e[v];try{e[v]=void 0;var r=!0}catch{}var i=_.call(e);return r&&(t?e[v]=n:delete e[v]),i}var b=Object.prototype.toString;function ee(e){return b.call(e)}var x=`[object Null]`,te=`[object Undefined]`,S=m?m.toStringTag:void 0;function C(e){return e==null?e===void 0?te:x:S&&S in Object(e)?y(e):ee(e)}function ne(e){return typeof e==`object`&&!!e}Array.isArray;function w(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var re=`[object AsyncFunction]`,ie=`[object Function]`,T=`[object GeneratorFunction]`,ae=`[object Proxy]`;function oe(e){if(!w(e))return!1;var t=C(e);return t==ie||t==T||t==re||t==ae}var E=p[`__core-js_shared__`],se=function(){var e=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function ce(e){return!!se&&se in e}var le=Function.prototype.toString;function D(e){if(e!=null){try{return le.call(e)}catch{}try{return e+``}catch{}}return``}var ue=/[\\^$.*+?()[\]{}|]/g,de=/^\[object .+?Constructor\]$/,fe=Function.prototype,pe=Object.prototype,me=fe.toString,he=pe.hasOwnProperty,ge=RegExp(`^`+me.call(he).replace(ue,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function _e(e){return!w(e)||ce(e)?!1:(oe(e)?ge:de).test(D(e))}function ve(e,t){return e?.[t]}function O(e,t){var n=ve(e,t);return _e(n)?n:void 0}var ye=O(p,`WeakMap`);function be(e,t){return e===t||e!==e&&t!==t}var xe=`[object Arguments]`;function Se(e){return ne(e)&&C(e)==xe}var Ce=Object.prototype;Ce.hasOwnProperty,Ce.propertyIsEnumerable,Se(function(){return arguments}());var we=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Te=we&&typeof module==`object`&&module&&!module.nodeType&&module,Ee=Te&&Te.exports===we?p.Buffer:void 0;Ee&&Ee.isBuffer;var De=`[object Arguments]`,Oe=`[object Array]`,ke=`[object Boolean]`,Ae=`[object Date]`,je=`[object Error]`,Me=`[object Function]`,Ne=`[object Map]`,Pe=`[object Number]`,Fe=`[object Object]`,Ie=`[object RegExp]`,Le=`[object Set]`,Re=`[object String]`,ze=`[object WeakMap]`,Be=`[object ArrayBuffer]`,Ve=`[object DataView]`,He=`[object Float32Array]`,Ue=`[object Float64Array]`,We=`[object Int8Array]`,Ge=`[object Int16Array]`,Ke=`[object Int32Array]`,qe=`[object Uint8Array]`,Je=`[object Uint8ClampedArray]`,Ye=`[object Uint16Array]`,Xe=`[object Uint32Array]`,k={};k[He]=k[Ue]=k[We]=k[Ge]=k[Ke]=k[qe]=k[Je]=k[Ye]=k[Xe]=!0,k[De]=k[Oe]=k[Be]=k[ke]=k[Ve]=k[Ae]=k[je]=k[Me]=k[Ne]=k[Pe]=k[Fe]=k[Ie]=k[Le]=k[Re]=k[ze]=!1;var Ze=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Qe=Ze&&typeof module==`object`&&module&&!module.nodeType&&module,$e=Qe&&Qe.exports===Ze&&d.process,et=function(){try{return Qe&&Qe.require&&Qe.require(`util`).types||$e&&$e.binding&&$e.binding(`util`)}catch{}}();et&&et.isTypedArray;var tt=O(Object,`create`);function nt(){this.__data__=tt?tt(null):{},this.size=0}function rt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var it=`__lodash_hash_undefined__`,at=Object.prototype.hasOwnProperty;function ot(e){var t=this.__data__;if(tt){var n=t[e];return n===it?void 0:n}return at.call(t,e)?t[e]:void 0}var st=Object.prototype.hasOwnProperty;function ct(e){var t=this.__data__;return tt?t[e]!==void 0:st.call(t,e)}var lt=`__lodash_hash_undefined__`;function ut(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=tt&&t===void 0?lt:t,this}function A(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}A.prototype.clear=nt,A.prototype.delete=rt,A.prototype.get=ot,A.prototype.has=ct,A.prototype.set=ut;function dt(){this.__data__=[],this.size=0}function ft(e,t){for(var n=e.length;n--;)if(be(e[n][0],t))return n;return-1}var pt=Array.prototype.splice;function mt(e){var t=this.__data__,n=ft(t,e);return n<0?!1:(n==t.length-1?t.pop():pt.call(t,n,1),--this.size,!0)}function ht(e){var t=this.__data__,n=ft(t,e);return n<0?void 0:t[n][1]}function gt(e){return ft(this.__data__,e)>-1}function _t(e,t){var n=this.__data__,r=ft(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function j(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}j.prototype.clear=dt,j.prototype.delete=mt,j.prototype.get=ht,j.prototype.has=gt,j.prototype.set=_t;var vt=O(p,`Map`);function yt(){this.size=0,this.__data__={hash:new A,map:new(vt||j),string:new A}}function bt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function xt(e,t){var n=e.__data__;return bt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function St(e){var t=xt(this,e).delete(e);return this.size-=+!!t,t}function Ct(e){return xt(this,e).get(e)}function wt(e){return xt(this,e).has(e)}function Tt(e,t){var n=xt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function M(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}M.prototype.clear=yt,M.prototype.delete=St,M.prototype.get=Ct,M.prototype.has=wt,M.prototype.set=Tt;function Et(){this.__data__=new j,this.size=0}function Dt(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Ot(e){return this.__data__.get(e)}function kt(e){return this.__data__.has(e)}var At=200;function jt(e,t){var n=this.__data__;if(n instanceof j){var r=n.__data__;if(!vt||r.length<At-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new M(r)}return n.set(e,t),this.size=n.size,this}function Mt(e){var t=this.__data__=new j(e);this.size=t.size}Mt.prototype.clear=Et,Mt.prototype.delete=Dt,Mt.prototype.get=Ot,Mt.prototype.has=kt,Mt.prototype.set=jt;var Nt=O(p,`DataView`),Pt=O(p,`Promise`),Ft=O(p,`Set`),It=`[object Map]`,Lt=`[object Object]`,Rt=`[object Promise]`,zt=`[object Set]`,Bt=`[object WeakMap]`,Vt=`[object DataView]`,Ht=D(Nt),Ut=D(vt),Wt=D(Pt),Gt=D(Ft),Kt=D(ye),N=C;(Nt&&N(new Nt(/* @__PURE__ */ new ArrayBuffer(1)))!=Vt||vt&&N(new vt)!=It||Pt&&N(Pt.resolve())!=Rt||Ft&&N(new Ft)!=zt||ye&&N(new ye)!=Bt)&&(N=function(e){var t=C(e),n=t==Lt?e.constructor:void 0,r=n?D(n):``;if(r)switch(r){case Ht:return Vt;case Ut:return It;case Wt:return Rt;case Gt:return zt;case Kt:return Bt}return t}),p.Uint8Array;var qt=`__lodash_hash_undefined__`;function Jt(e){return this.__data__.set(e,qt),this}function Yt(e){return this.__data__.has(e)}function Xt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new M;++t<n;)this.add(e[t])}Xt.prototype.add=Xt.prototype.push=Jt,Xt.prototype.has=Yt;var Zt=m?m.prototype:void 0;Zt&&Zt.valueOf;function Qt(e){return{"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`,"image/gif":`gif`,"image/svg+xml":`svg`}[e]??`png`}const $t={Formats:l};function en(e,t,n,r){let i=`property.${n}${r?`.${r}`:``}`,a=[`ly.img.plugin-ai-${t}-generation-web.${e}.${i}`,`ly.img.plugin-ai-generation-web.${i}`,`ly.img.plugin-ai-${t}-generation-web.${e}.defaults.${i}`,`ly.img.plugin-ai-generation-web.defaults.${i}`];return r===`placeholder`&&a.push(`ly.img.plugin-ai-generation-web.fallback.property.placeholder`),a}var tn=class{constructor(e,t=[],n){this.id=e,this.translateLabel=n?.translateLabel,this.assets=t.map(e=>{if(typeof e.label==`string`&&!(e.label&&typeof e.label==`object`)){let t=e;return{id:t.id,label:{en:t.label},meta:t.thumbUri?{...t.meta??{},thumbUri:t.thumbUri}:t.meta}}return e}),this.activeAssetIds=/* @__PURE__ */ new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(e){let{page:t,perPage:n,locale:r=`en`,sortActiveFirst:i,query:a,tags:o,groups:s,excludeGroups:c,sortingOrder:l,sortKey:u}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(e=>e.groups&&s.some(t=>e.groups?.includes(t)))),c&&c.length>0&&(d=d.filter(e=>!e.groups||!c.some(t=>e.groups?.includes(t)))),a){let e=a.toLowerCase();d=d.filter(t=>{let n=t.label?.[r]?.toLowerCase(),i=t.tags?.[r]||[];return n&&n.includes(e)||i.some(t=>t.toLowerCase().includes(e))})}if(o&&o.length>0){let e=Array.isArray(o)?o:[o];d=d.filter(t=>{let n=t.tags?.[r]||[];return e.some(e=>n.includes(e))})}i&&d.sort((e,t)=>{let n=this.activeAssetIds.has(e.id),r=this.activeAssetIds.has(t.id);return n&&!r?-1:!n&&r?1:0}),u&&u!==`id`?d.sort((e,t)=>{let n=e.meta?.[u],r=t.meta?.[u];return n===void 0?1:r===void 0?-1:typeof n==`string`&&typeof r==`string`?l===`Descending`?r.localeCompare(n):n.localeCompare(r):typeof n==`number`&&typeof r==`number`?l===`Descending`?r-n:n-r:0}):u===`id`&&d.sort((e,t)=>l===`Descending`?t.id.localeCompare(e.id):e.id.localeCompare(t.id));let f=d.length,p=t*n,m=p+n;return{assets:d.slice(p,m).map(e=>{let t=e.label?.[r]||``,n=this.translateLabel?this.translateLabel(e.id,t,r):t;return{id:e.id,groups:e.groups,meta:e.meta,payload:e.payload,locale:r,label:n,tags:e.tags?.[r],active:this.activeAssetIds.has(e.id)}}),currentPage:t,nextPage:m<f?t+1:void 0,total:f}}updateLabel(e,t,n){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[n]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:t})=>t===e);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}getActiveSelectValue(){let e=this.getActiveAssetIds();if(e.length>0){let t=this.assets.find(({id:t})=>t===e[0]);if(t){let e=this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``;return{id:t.id,label:e,thumbUri:t.meta?.thumbUri}}}}getTranslatedLabel(e){let t=this.assets.find(({id:t})=>t===e);if(t)return this.translateLabel?this.translateLabel(t.id,t.label?.en||``,``):t.label?.en||``}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(t=>t.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(t=>t.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=/* @__PURE__ */ new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(t=>e.add(t))}),Array.from(e)}getSupportedMimeTypes(){return[`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`video/mp4`,`audio/mpeg`]}},nn=typeof global==`object`&&global&&global.Object===Object&&global,rn=typeof self==`object`&&self&&self.Object===Object&&self,P=nn||rn||Function(`return this`)(),F=P.Symbol,an=Object.prototype,on=an.hasOwnProperty,sn=an.toString,cn=F?F.toStringTag:void 0;function ln(e){var t=on.call(e,cn),n=e[cn];try{e[cn]=void 0;var r=!0}catch{}var i=sn.call(e);return r&&(t?e[cn]=n:delete e[cn]),i}var un=Object.prototype.toString;function dn(e){return un.call(e)}var fn=`[object Null]`,pn=`[object Undefined]`,mn=F?F.toStringTag:void 0;function hn(e){return e==null?e===void 0?pn:fn:mn&&mn in Object(e)?ln(e):dn(e)}function gn(e){return typeof e==`object`&&!!e}Array.isArray;function _n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var vn=`[object AsyncFunction]`,yn=`[object Function]`,bn=`[object GeneratorFunction]`,xn=`[object Proxy]`;function Sn(e){if(!_n(e))return!1;var t=hn(e);return t==yn||t==bn||t==vn||t==xn}var Cn=P[`__core-js_shared__`],wn=function(){var e=/[^.]+$/.exec(Cn&&Cn.keys&&Cn.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Tn(e){return!!wn&&wn in e}var En=Function.prototype.toString;function I(e){if(e!=null){try{return En.call(e)}catch{}try{return e+``}catch{}}return``}var Dn=/[\\^$.*+?()[\]{}|]/g,On=/^\[object .+?Constructor\]$/,kn=Function.prototype,An=Object.prototype,jn=kn.toString,Mn=An.hasOwnProperty,Nn=RegExp(`^`+jn.call(Mn).replace(Dn,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Pn(e){return!_n(e)||Tn(e)?!1:(Sn(e)?Nn:On).test(I(e))}function Fn(e,t){return e?.[t]}function L(e,t){var n=Fn(e,t);return Pn(n)?n:void 0}var In=L(P,`WeakMap`);function Ln(e,t){return e===t||e!==e&&t!==t}var Rn=`[object Arguments]`;function zn(e){return gn(e)&&hn(e)==Rn}var Bn=Object.prototype;Bn.hasOwnProperty,Bn.propertyIsEnumerable,zn(function(){return arguments}());var Vn=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Hn=Vn&&typeof module==`object`&&module&&!module.nodeType&&module,Un=Hn&&Hn.exports===Vn?P.Buffer:void 0;Un&&Un.isBuffer;var Wn=`[object Arguments]`,Gn=`[object Array]`,Kn=`[object Boolean]`,qn=`[object Date]`,Jn=`[object Error]`,Yn=`[object Function]`,Xn=`[object Map]`,Zn=`[object Number]`,Qn=`[object Object]`,$n=`[object RegExp]`,er=`[object Set]`,tr=`[object String]`,nr=`[object WeakMap]`,rr=`[object ArrayBuffer]`,ir=`[object DataView]`,ar=`[object Float32Array]`,or=`[object Float64Array]`,sr=`[object Int8Array]`,cr=`[object Int16Array]`,lr=`[object Int32Array]`,ur=`[object Uint8Array]`,dr=`[object Uint8ClampedArray]`,fr=`[object Uint16Array]`,pr=`[object Uint32Array]`,R={};R[ar]=R[or]=R[sr]=R[cr]=R[lr]=R[ur]=R[dr]=R[fr]=R[pr]=!0,R[Wn]=R[Gn]=R[rr]=R[Kn]=R[ir]=R[qn]=R[Jn]=R[Yn]=R[Xn]=R[Zn]=R[Qn]=R[$n]=R[er]=R[tr]=R[nr]=!1;var mr=typeof exports==`object`&&exports&&!exports.nodeType&&exports,z=mr&&typeof module==`object`&&module&&!module.nodeType&&module,hr=z&&z.exports===mr&&nn.process,gr=function(){try{return z&&z.require&&z.require(`util`).types||hr&&hr.binding&&hr.binding(`util`)}catch{}}();gr&&gr.isTypedArray;var _r=L(Object,`create`);function vr(){this.__data__=_r?_r(null):{},this.size=0}function yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var br=`__lodash_hash_undefined__`,xr=Object.prototype.hasOwnProperty;function Sr(e){var t=this.__data__;if(_r){var n=t[e];return n===br?void 0:n}return xr.call(t,e)?t[e]:void 0}var Cr=Object.prototype.hasOwnProperty;function wr(e){var t=this.__data__;return _r?t[e]!==void 0:Cr.call(t,e)}var Tr=`__lodash_hash_undefined__`;function Er(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=_r&&t===void 0?Tr:t,this}function B(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}B.prototype.clear=vr,B.prototype.delete=yr,B.prototype.get=Sr,B.prototype.has=wr,B.prototype.set=Er;function Dr(){this.__data__=[],this.size=0}function Or(e,t){for(var n=e.length;n--;)if(Ln(e[n][0],t))return n;return-1}var kr=Array.prototype.splice;function Ar(e){var t=this.__data__,n=Or(t,e);return n<0?!1:(n==t.length-1?t.pop():kr.call(t,n,1),--this.size,!0)}function jr(e){var t=this.__data__,n=Or(t,e);return n<0?void 0:t[n][1]}function Mr(e){return Or(this.__data__,e)>-1}function Nr(e,t){var n=this.__data__,r=Or(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function V(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}V.prototype.clear=Dr,V.prototype.delete=Ar,V.prototype.get=jr,V.prototype.has=Mr,V.prototype.set=Nr;var Pr=L(P,`Map`);function Fr(){this.size=0,this.__data__={hash:new B,map:new(Pr||V),string:new B}}function Ir(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Lr(e,t){var n=e.__data__;return Ir(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Rr(e){var t=Lr(this,e).delete(e);return this.size-=+!!t,t}function zr(e){return Lr(this,e).get(e)}function Br(e){return Lr(this,e).has(e)}function Vr(e,t){var n=Lr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function H(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}H.prototype.clear=Fr,H.prototype.delete=Rr,H.prototype.get=zr,H.prototype.has=Br,H.prototype.set=Vr;function Hr(){this.__data__=new V,this.size=0}function Ur(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Wr(e){return this.__data__.get(e)}function Gr(e){return this.__data__.has(e)}var Kr=200;function qr(e,t){var n=this.__data__;if(n instanceof V){var r=n.__data__;if(!Pr||r.length<Kr-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new H(r)}return n.set(e,t),this.size=n.size,this}function Jr(e){var t=this.__data__=new V(e);this.size=t.size}Jr.prototype.clear=Hr,Jr.prototype.delete=Ur,Jr.prototype.get=Wr,Jr.prototype.has=Gr,Jr.prototype.set=qr;var Yr=L(P,`DataView`),Xr=L(P,`Promise`),Zr=L(P,`Set`),Qr=`[object Map]`,$r=`[object Object]`,ei=`[object Promise]`,ti=`[object Set]`,ni=`[object WeakMap]`,ri=`[object DataView]`,ii=I(Yr),ai=I(Pr),oi=I(Xr),si=I(Zr),ci=I(In),U=hn;(Yr&&U(new Yr(/* @__PURE__ */ new ArrayBuffer(1)))!=ri||Pr&&U(new Pr)!=Qr||Xr&&U(Xr.resolve())!=ei||Zr&&U(new Zr)!=ti||In&&U(new In)!=ni)&&(U=function(e){var t=hn(e),n=t==$r?e.constructor:void 0,r=n?I(n):``;if(r)switch(r){case ii:return ri;case ai:return Qr;case oi:return ei;case si:return ti;case ci:return ni}return t}),P.Uint8Array;var li=`__lodash_hash_undefined__`;function ui(e){return this.__data__.set(e,li),this}function di(e){return this.__data__.has(e)}function fi(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new H;++t<n;)this.add(e[t])}fi.prototype.add=fi.prototype.push=ui,fi.prototype.has=di;var pi=F?F.prototype:void 0;pi&&pi.valueOf;function mi(e,t){if(!t.block.isValid(e)||!t.block.supportsFill(e))return[];let n=t.block.getFill(e);return n==null||!t.block.isValid(n)||t.block.getType(n)!==`//ly.img.ubq/fill/image`?[]:[...t.block.getSourceSet(n,`fill/image/sourceSet`).map(e=>e.uri),t.block.getString(n,`fill/image/imageFileURI`)].filter(e=>e!=null&&e!==``&&!e.startsWith(`buffer:`))}function hi(e){return e!==void 0}function gi(e){return e?.version?e.version.localeCompare(`1.59.0`,void 0,{numeric:!0,sensitivity:`base`})>=0&&typeof e.i18n?.translate==`function`:!1}function _i(e){return typeof e?.translate==`function`}function vi(e,t,n){return e&&gi(e)&&_i(e.i18n)?e.i18n.translate(t):n}function yi(e,t){return{engine:e,cesdk:t,locale:t?.i18n?.getLocale?.()||`en`}}function bi(e,t,n,r,i){if(t?.default!==void 0){let e=t.default;return typeof e==`function`?e(n):e}return r===void 0?i:r}function xi(e,t){if(typeof e.i18n?.getTranslations!=`function`){e.i18n.setTranslations(t);return}let n=Object.keys(t),r=e.i18n.getTranslations(n),i={};for(let e of n){let n=t[e];if(!n)continue;let a=r[e]??{},o={};for(let[e,t]of Object.entries(n))!(e in a)&&t!==void 0&&(o[e]=t);Object.keys(o).length>0&&(i[e]=o)}Object.keys(i).length>0&&e.i18n.setTranslations(i)}function Si(e,t,n=`style`,r=`image`){return(i,a)=>{if(!gi(e))return a;let o=Ci(t,n,i,r);if(_i(e.i18n)){let t=e.i18n.translate(o);return t===o[o.length-1]?a:t}return a}}function Ci(e,t,n,r=`image`){return[`ly.img.plugin-ai-${r}-generation-web.${e}.property.${t}.${n}`,`ly.img.plugin-ai-generation-web.property.${t}.${n}`,`ly.img.plugin-ai-${r}-generation-web.${e}.defaults.property.${t}.${n}`,`ly.img.plugin-ai-generation-web.defaults.property.${t}.${n}`]}function wi(e,t){let{cesdk:n}=t,r=t.propertyKey??`image_url`,i=t.promptPropertyKey??`prompt`,a=Ni(e);xi(n,{en:{[`panel.${a}`]:`Select Image To Change`,"ly.img.ai.imageSelection.selectImage.label":`Select Image`,"ly.img.ai.imageSelection.error.svg":`SVG images are not supported. Please choose a different image.`,"ly.img.ai.imageSelection.error.invalidType":`Only images are supported. Found '{mimeType}'. Please choose a different image.`,"ly.img.ai.prompt.referenceImage":`Reference image`,"ly.img.ai.prompt.attachSelectedImage":`Use the image selected on the canvas`,"ly.img.ai.prompt.images":`Reference images`,"ly.img.ai.prompt.addImage":`Add image`,"ly.img.ai.prompt.removeImage":`Remove image`}}),Mi(e,n);let o=`${e}.${r}`,s={stateId:o,maxCount:1,isList:!1};return Pi().set(e,s),{[r]:(e,n)=>{let r=Ti(e.experimental.global(o,Ai(e,n.id,t)).value);return()=>Di(n.schema)?{id:n.id,type:`array`,value:r,required:!0}:{id:n.id,type:`string`,value:r[0]??``,required:!0}},[i]:(i,c)=>{let{builder:l,engine:u,experimental:{global:d}}=i,f=i.kind??`image`,p=i.properties?.find(({id:e})=>e===r),m=i.properties==null||p!=null,h=Oi(p?.schema),g=Di(p?.schema);s.maxCount=h,s.isList=g;let _=d(`${e}.${c.id}`,ji(i,c.id,c.schema?.default)??``),v=d(o,Ai(i,r,t)),y=e=>{let t=Ti(v.value);t.includes(e)||v.setValue(Ei([...t,e].slice(-h),g))},b=e=>v.setValue(Ei(Ti(v.value).filter(t=>t!==e),g));return l.PromptInput(`${e}.${c.id}`,{inputLabel:en(e,f,c.id),placeholder:en(e,f,c.id,`placeholder`),..._,attachments:m?{items:ki(u,Ti(v.value),{maxCount:h,attach:y,detach:b}),label:`ly.img.ai.prompt.images`,addLabel:`ly.img.ai.prompt.addImage`,maxCount:h,addIcon:`@imgly/ImageAdd`,onAdd:()=>{n.ui.openPanel(a,{payload:{onSelect:e=>{e.meta?.uri!=null&&y(e.meta.uri)}}})}}:void 0}),()=>({id:c.id,type:`string`,value:_.value})}}}function Ti(e){return Array.isArray(e)?e:e?[e]:[]}function Ei(e,t){return t?e:e[0]??``}function Di(e){return e?.type===`array`}function Oi(e){return Di(e)?e?.maxItems??1:1}function ki(e,t,{maxCount:n,attach:r,detach:i}){let a=e.block.findAllSelected().map(t=>mi(t,e)).filter(e=>e.length>0),o=a.flat(),s=t.map(e=>({id:e,thumbnailUri:e,label:`ly.img.ai.prompt.referenceImage`,isHighlighted:o.includes(e),removeLabel:`ly.img.ai.prompt.removeImage`,onRemove:()=>i(e)})),c=a.filter(e=>!e.some(e=>t.includes(e))).map(([e])=>e),l=[...new Set(c)].slice(0,Math.max(n-t.length,0)).map(e=>({id:e,thumbnailUri:e,label:`ly.img.ai.prompt.attachSelectedImage`,isSuggested:!0,onClick:()=>r(e)}));return[...s,...l]}function Ai(e,t,n){return ji(e,t)??e.payload?.url??n.defaultUrl??``}function ji(e,t,n){return bi(t,e.providerConfig?.properties?.[t]??e.config?.properties?.[t],yi(e.engine),n)}function Mi(e,t){t?.ui.registerPanel(Ni(e),({builder:n,payload:r})=>{n.Library(`${e}.library.image`,{entries:[`ly.img.image`],onSelect:async n=>{let i=n?.meta?.uri;if(i==null)return;let a=await t.engine.editor.getMimeType(i);a===`image/svg+xml`?t.ui.showNotification({type:`warning`,message:`ly.img.ai.imageSelection.error.svg`}):a.startsWith(`image/`)?(r?.onSelect(n),t?.ui.closePanel(Ni(e))):t.ui.showNotification({type:`warning`,message:`ly.img.ai.imageSelection.error.invalidType`})}})})}function Ni(e){return`ly.img.ai.${e}.imageSelection`}function Pi(){let e=`__imgly_ai_prompt_image_entries__`,t=typeof window<`u`?window:globalThis;return t[e]??(t[e]=/* @__PURE__ */ new Map),t[e]}function Fi(e,t){let{cesdk:n}=t;if(n==null)return{};let r=t.propertyKey??`style`,i=Li(e);xi(n,{en:{[`panel.${i}`]:`Select Style`,[`${e}.${r}`]:`Style`,"ly.img.ai.styleTransfer.none":`None`,"ly.img.ai.styleTransfer.anime":`Anime`,"ly.img.ai.styleTransfer.cyberpunk":`Cyberpunk`,"ly.img.ai.styleTransfer.kodak400":`Kodak 400`,"ly.img.ai.styleTransfer.watercolor":`Watercolor`,"ly.img.ai.styleTransfer.darkFantasy":`Dark Fantasy`,"ly.img.ai.styleTransfer.vaporwave":`Vaporwave`,"ly.img.ai.styleTransfer.vectorFlat":`Vector Flat`,"ly.img.ai.styleTransfer.3dAnimation":`3D Animation`,"ly.img.ai.styleTransfer.ukiyoe":`Ukiyo‑e`,"ly.img.ai.styleTransfer.surreal":`Surreal`,"ly.img.ai.styleTransfer.steampunk":`Steampunk`,"ly.img.ai.styleTransfer.nightBokeh":`Night Bokeh`,"ly.img.ai.styleTransfer.popArt":`Pop Art`}});let a=zi({baseURL:t.baseURL??`https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/`,includeNone:!0,cesdk:n}),o=a;t.styles!=null&&(Array.isArray(t.styles)?o=t.styles:typeof t.styles==`function`&&(o=t.styles(a)));let s=Bi({cesdk:n,providerId:e,styles:o}),c=s.id;return Vi(s,{cesdk:n}),Ii({providerId:e,cesdk:n,panelId:i,entryId:c}),{[t.propertyKeyForPrompt??`prompt`]:(e,n)=>{let r=e.state(`prompt`,``);return e.builder.PromptInput(`${n.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??`prompt`,placeholder:t.i18n?.prompt?.placeholder,...r}),()=>{let[e]=s.getActiveAssetIds(),t=s.getAsset(e);return{id:n.id,type:`string`,value:t?.meta?.prompt==null?r.value:`${r.value}; ${t.meta.prompt}`}}},[r]:(t,r)=>{let{builder:a,state:c}=t;if(o.length>0){let t=c(`style`,o[0]);return a.Button(`${r.id}`,{inputLabel:`${e}.${r.id}`,icon:`@imgly/Appearance`,isDisabled:o.length===0,trailingIcon:`@imgly/ChevronRight`,label:t.value.label,labelAlignment:`left`,onClick:()=>{n.ui.openPanel(i,{payload:{onSelect:async e=>{s.clearActiveAssets(),s.setAssetActive(e.id),t.setValue({id:e.id,label:e.label??e.id}),n.ui.closePanel(i)}}})}}),()=>({id:r.id,type:`string`,value:t.value.id})}return()=>({id:r.id,type:`string`,value:`none`})}}}function Ii(e){let{providerId:t,cesdk:n,panelId:r,entryId:i}=e;n?.ui.registerPanel(r,({builder:e,payload:n})=>{n?.onSelect??e.Section(`${t}.error`,{children:()=>{e.Text(`error`,{content:`No onSelect function provided for the style selection panel.`})}}),e.Library(`${t}.library.image`,{entries:[i],onSelect:async e=>{n?.onSelect?.(e)}})})}function Li(e){return`ly.img.ai.${e}.styleSelection`}const Ri=[{id:`none`,labelKey:`ly.img.ai.styleTransfer.none`,prompt:``},{id:`anime-celshaded`,labelKey:`ly.img.ai.styleTransfer.anime`,prompt:`anime cel‑shaded, bright pastel palette, expressive eyes, clean line art `},{id:`cyberpunk-neon`,labelKey:`ly.img.ai.styleTransfer.cyberpunk`,prompt:`cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere`},{id:`kodak-portra-400`,labelKey:`ly.img.ai.styleTransfer.kodak400`,prompt:`shot on Kodak Portra 400, soft grain, golden‑hour warmth, 35 mm photo`},{id:`watercolor-storybook`,labelKey:`ly.img.ai.styleTransfer.watercolor`,prompt:`loose watercolor washes, gentle gradients, dreamy storybook feel`},{id:`dark-fantasy-realism`,labelKey:`ly.img.ai.styleTransfer.darkFantasy`,prompt:`dark fantasy realm, moody chiaroscuro lighting, hyper‑real textures`},{id:`vaporwave-retrofuturism`,labelKey:`ly.img.ai.styleTransfer.vaporwave`,prompt:`retro‑futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines`},{id:`minimal-vector-flat`,labelKey:`ly.img.ai.styleTransfer.vectorFlat`,prompt:`minimalist flat vector illustration, bold geometry, two‑tone palette`},{id:`pixarstyle-3d-render`,labelKey:`ly.img.ai.styleTransfer.3dAnimation`,prompt:`Pixar‑style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting`},{id:`ukiyoe-woodblock`,labelKey:`ly.img.ai.styleTransfer.ukiyoe`,prompt:`ukiyo‑e woodblock print, Edo‑period style, visible washi texture, limited color ink`},{id:`surreal-dreamscape`,labelKey:`ly.img.ai.styleTransfer.surreal`,prompt:`surreal dreamscape, floating objects, impossible architecture, vivid clouds`},{id:`steampunk-victorian`,labelKey:`ly.img.ai.styleTransfer.steampunk`,prompt:`Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog`},{id:`nightstreet-photo-bokeh`,labelKey:`ly.img.ai.styleTransfer.nightBokeh`,prompt:`night‑time street shot, large aperture bokeh lights, candid urban mood`},{id:`comicbook-pop-art`,labelKey:`ly.img.ai.styleTransfer.popArt`,prompt:`classic comic‑book panel, halftone shading, exaggerated action lines, CMYK pop colors`}];function zi(e){return Ri.map(t=>t.id===`none`?e.includeNone?{id:t.id,label:vi(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/None.svg`}:void 0:{id:t.id,label:vi(e.cesdk,t.labelKey,t.labelKey),prompt:t.prompt,thumbUri:`${e.baseURL}thumbnails/${t.id}.jpeg`}).filter(hi)}const Bi=e=>{let t=e.styles.map(e=>({...e,meta:{prompt:e.prompt}})),n=e.cesdk.engine.asset.findAllSources(),r=`${e.providerId}/styles`;for(;n.includes(r);)r+=`-${Math.random().toString(36).substring(2,5)}`;let i=new tn(r,t),a=e.styles[0];return i.setAssetActive(a.id),i},Vi=(e,t)=>{t.cesdk.engine.asset.addSource(e),t.cesdk.ui.addAssetLibraryEntry({id:e.id,sourceIds:[e.id],gridItemHeight:`square`,gridBackgroundType:`cover`,cardLabel:({label:e})=>e,cardLabelPosition:()=>`below`})};function Hi(e){return`ly.img.ai.${e}`}function Ui(e){return`${e.replace(/\/+$/,``)}/`}function Wi(e,t){let n={...e};if(!t)return n;for(let[r,i]of Object.entries(t))i===!1||i==null?delete n[r]:i===!0?r in e||(n[r]=!0):n[r]=i;return n}const Gi={ImageUrl:wi,StyleTransfer:Fi};var Ki={openapi:`3.0.0`,info:{title:`Fal Queue API`,version:`1.0.0`,description:`The Fal Queue API.`},components:{securitySchemes:{apiKeyAuth:{type:`apiKey`,in:`header`,name:`Authorization`,description:`Fal Key`}},schemas:{QueueStatus:{type:`object`,properties:{status:{type:`string`,enum:[`IN_QUEUE`,`IN_PROGRESS`,`COMPLETED`]},request_id:{type:`string`,description:`The request id.`},response_url:{type:`string`,description:`The response url.`},status_url:{type:`string`,description:`The status url.`},cancel_url:{type:`string`,description:`The cancel url.`},logs:{type:`object`,description:`The logs.`,additionalProperties:!0},metrics:{type:`object`,description:`The metrics.`,additionalProperties:!0},queue_position:{type:`integer`,description:`The queue position.`}},required:[`status`,`request_id`]},Recraft20bInput:{title:`TextToImageInput`,type:`object`,properties:{prompt:{title:`Prompt`,type:`string`,"x-imgly-builder":{component:`TextArea`}},image_size:{anyOf:[{enum:[`square_hd`,`square`,`portrait_4_3`,`portrait_16_9`,`landscape_4_3`,`landscape_16_9`],type:`string`},{$ref:`#/components/schemas/ImageSize`}],title:`Format`,default:`square_hd`,"x-imgly-enum-labels":{ImageSize:`Custom`,square_hd:`Square HD`,square:`Square`,portrait_4_3:`Portrait 4:3`,portrait_16_9:`Portrait 16:9`,landscape_4_3:`Landscape 4:3`,landscape_16_9:`Landscape 16:9`},"x-imgly-enum-icons":{square:`@imgly/plugin/formats/ratio1by1`,square_hd:`@imgly/plugin/formats/ratio1by1`,portrait_4_3:`@imgly/plugin/formats/ratio3by4`,portrait_16_9:`@imgly/plugin/formats/ratio9by16`,landscape_4_3:`@imgly/plugin/formats/ratio4by3`,landscape_16_9:`@imgly/plugin/formats/ratio16by9`,ImageSize:`@imgly/plugin/formats/ratioFree`}},style:{enum:/* @__PURE__ */ `any.realistic_image.digital_illustration.vector_illustration.realistic_image/b_and_w.realistic_image/hard_flash.realistic_image/hdr.realistic_image/natural_light.realistic_image/studio_portrait.realistic_image/enterprise.realistic_image/motion_blur.realistic_image/evening_light.realistic_image/faded_nostalgia.realistic_image/forest_life.realistic_image/mystic_naturalism.realistic_image/natural_tones.realistic_image/organic_calm.realistic_image/real_life_glow.realistic_image/retro_realism.realistic_image/retro_snapshot.realistic_image/urban_drama.realistic_image/village_realism.realistic_image/warm_folk.digital_illustration/pixel_art.digital_illustration/hand_drawn.digital_illustration/grain.digital_illustration/infantile_sketch.digital_illustration/2d_art_poster.digital_illustration/handmade_3d.digital_illustration/hand_drawn_outline.digital_illustration/engraving_color.digital_illustration/2d_art_poster_2.digital_illustration/antiquarian.digital_illustration/bold_fantasy.digital_illustration/child_book.digital_illustration/child_books.digital_illustration/cover.digital_illustration/crosshatch.digital_illustration/digital_engraving.digital_illustration/expressionism.digital_illustration/freehand_details.digital_illustration/grain_20.digital_illustration/graphic_intensity.digital_illustration/hard_comics.digital_illustration/long_shadow.digital_illustration/modern_folk.digital_illustration/multicolor.digital_illustration/neon_calm.digital_illustration/noir.digital_illustration/nostalgic_pastel.digital_illustration/outline_details.digital_illustration/pastel_gradient.digital_illustration/pastel_sketch.digital_illustration/pop_art.digital_illustration/pop_renaissance.digital_illustration/street_art.digital_illustration/tablet_sketch.digital_illustration/urban_glow.digital_illustration/urban_sketching.digital_illustration/vanilla_dreams.digital_illustration/young_adult_book.digital_illustration/young_adult_book_2.vector_illustration/bold_stroke.vector_illustration/chemistry.vector_illustration/colored_stencil.vector_illustration/contour_pop_art.vector_illustration/cosmics.vector_illustration/cutout.vector_illustration/depressive.vector_illustration/editorial.vector_illustration/emotional_flat.vector_illustration/infographical.vector_illustration/marker_outline.vector_illustration/mosaic.vector_illustration/naivector.vector_illustration/roundish_flat.vector_illustration/segmented_colors.vector_illustration/sharp_contrast.vector_illustration/thin.vector_illustration/vector_photo.vector_illustration/vivid_shapes.vector_illustration/engraving.vector_illustration/line_art.vector_illustration/line_circuit.vector_illustration/linocut.icon/broken_line.icon/colored_outline.icon/colored_shapes.icon/colored_shapes_gradient.icon/doodle_fill.icon/doodle_offset_fill.icon/offset_fill.icon/outline.icon/outline_gradient.icon/uneven_fill`.split(`.`),title:`Style`,type:`string`,description:`The style of the generated images. Vector images cost 2X as much.`,default:`realistic_image`},colors:{title:`Colors`,type:`array`,description:`An array of preferable colors`,items:{$ref:`#/components/schemas/RGBColor`},default:[]}},"x-fal-order-properties":[`prompt`,`style`,`image_size`],required:[`prompt`]},Recraft20bOutput:{title:`TextToImageOutput`,type:`object`,properties:{images:{title:`Images`,type:`array`,items:{$ref:`#/components/schemas/File`}}},"x-fal-order-properties":[`images`],required:[`images`]},ImageSize:{title:`ImageSize`,type:`object`,properties:{height:{maximum:14142,type:`integer`,title:`Height`,description:`The height of the generated image.`,exclusiveMinimum:0,default:512},width:{maximum:14142,type:`integer`,title:`Width`,description:`The width of the generated image.`,exclusiveMinimum:0,default:512}},"x-fal-order-properties":[`width`,`height`]},RGBColor:{title:`RGBColor`,type:`object`,properties:{r:{minimum:0,maximum:255,type:`integer`,title:`R`,description:`Red color value`,default:0},b:{minimum:0,maximum:255,type:`integer`,title:`B`,description:`Blue color value`,default:0},g:{minimum:0,maximum:255,type:`integer`,title:`G`,description:`Green color value`,default:0}},"x-fal-order-properties":[`r`,`g`,`b`]},File:{title:`File`,type:`object`,properties:{file_size:{title:`File Size`,type:`integer`,description:`The size of the file in bytes.`},file_name:{title:`File Name`,type:`string`,description:`The name of the file. It will be auto-generated if not provided.`},content_type:{title:`Content Type`,type:`string`,description:`The mime type of the file.`},url:{title:`Url`,type:`string`,description:`The URL where the file can be downloaded from.`},file_data:{format:`binary`,title:`File Data`,type:`string`,description:`File data`}},"x-fal-order-properties":[`url`,`content_type`,`file_name`,`file_size`,`file_data`],required:[`url`]}}},paths:{"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/status":{get:{parameters:[{name:`request_id`,in:`path`,required:!0,schema:{type:`string`,description:`Request ID`}},{name:`logs`,in:`query`,required:!1,schema:{type:`number`,description:"Whether to include logs (`1`) in the response or not (`0`)."}}],responses:{200:{description:`The request status.`,content:{"application/json":{schema:{$ref:`#/components/schemas/QueueStatus`}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/cancel":{put:{parameters:[{name:`request_id`,in:`path`,required:!0,schema:{type:`string`,description:`Request ID`}}],responses:{200:{description:`The request was cancelled.`,content:{"application/json":{schema:{type:`object`,properties:{success:{type:`boolean`,description:`Whether the request was cancelled successfully.`}}}}}}}}},"/fal-ai/recraft/v2/text-to-image":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:`#/components/schemas/Recraft20bInput`}}}},responses:{200:{description:`The request status.`,content:{"application/json":{schema:{$ref:`#/components/schemas/QueueStatus`}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}":{get:{parameters:[{name:`request_id`,in:`path`,required:!0,schema:{type:`string`,description:`Request ID`}}],responses:{200:{description:`Result of the request.`,content:{"application/json":{schema:{$ref:`#/components/schemas/Recraft20bOutput`}}}}}}}},servers:[{url:`https://queue.fal.run`}],security:[{apiKeyAuth:[]}]};const qi={square_hd:{width:1024,height:1024},square:{width:512,height:512},portrait_4_3:{width:1024,height:1365},portrait_16_9:{width:1024,height:1820},landscape_4_3:{width:1365,height:1024},landscape_16_9:{width:1820,height:1024}};function Ji(e){return qi[e]}const Yi=[{id:`icon/broken_line`,label:`Broken Line`},{id:`icon/colored_outline`,label:`Colored Outline`},{id:`icon/colored_shapes`,label:`Colored Shapes`},{id:`icon/colored_shapes_gradient`,label:`Colored Shapes Gradient`},{id:`icon/doodle_fill`,label:`Doodle Fill`},{id:`icon/doodle_offset_fill`,label:`Doodle Offset Fill`},{id:`icon/offset_fill`,label:`Offset Fill`},{id:`icon/outline`,label:`Outline`},{id:`icon/outline_gradient`,label:`Outline Gradient`},{id:`icon/uneven_fill`,label:`Uneven Fill`}];Yi[0];const Xi=e=>({realistic_image:`${e}realistic_image.webp`,digital_illustration:`${e}digital_illustration.webp`,"realistic_image/b_and_w":`${e}realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${e}realistic_image_hard_flash.webp`,"realistic_image/hdr":`${e}realistic_image_hdr.webp`,"realistic_image/natural_light":`${e}realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${e}realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${e}realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${e}realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${e}digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${e}digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${e}digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${e}digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${e}digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${e}digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${e}digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${e}digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${e}digital_illustration_2d_artposter_2.webp`,vector_illustration:`${e}vector_illustration.svg`,"vector_illustration/bold_stroke":`${e}vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${e}vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${e}vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${e}vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${e}vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${e}vector_illustration_cutout.svg`,"vector_illustration/depressive":`${e}vector_illustration_depressive.svg`,"vector_illustration/editorial":`${e}vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${e}vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${e}vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${e}vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${e}vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${e}vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${e}vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${e}vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${e}vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${e}vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${e}vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${e}vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${e}vector_illustration_engraving.svg`,"vector_illustration/line_art":`${e}vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${e}vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${e}vector_illustration_linocut.svg`,"realistic_image/evening_light":`${e}realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${e}realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${e}realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${e}realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${e}realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${e}realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${e}realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${e}realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${e}realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${e}realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${e}realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${e}realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${e}digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${e}digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${e}digital_illustration_child_book.webp`,"digital_illustration/child_books":`${e}digital_illustration_child_books.webp`,"digital_illustration/cover":`${e}digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${e}digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${e}digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${e}digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${e}digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${e}digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${e}digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${e}digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${e}digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${e}digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${e}digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${e}digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${e}digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${e}digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${e}digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${e}digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${e}digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${e}digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${e}digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${e}digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${e}digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${e}digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${e}digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${e}digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${e}digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${e}digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${e}icon_broken_line.svg`,"icon/colored_outline":`${e}icon_colored_outline.svg`,"icon/colored_shapes":`${e}icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${e}icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${e}icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${e}icon_doodle_offset_fill.svg`,"icon/offset_fill":`${e}icon_offset_fill.svg`,"icon/outline":`${e}icon_outline.svg`,"icon/outline_gradient":`${e}icon_outline_gradient.svg`,"icon/uneven_fill":`${e}icon_uneven_fill.svg`});function Zi(e,t){return Xi(`${t}thumbnails/`)[e]}var Qi=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.TARGET_URL_HEADER=void 0,e.withMiddleware=i,e.withProxy=a;function i(...e){let t=e=>typeof e==`function`;return n=>r(this,void 0,void 0,function*(){let r=Object.assign({},n);for(let n of e.filter(t))r=yield n(r);return r})}e.TARGET_URL_HEADER=`x-fal-target-url`;function a(t){let n=e=>Promise.resolve(e);return typeof window>`u`?n:r=>r.headers&&e.TARGET_URL_HEADER in r?n(r):Promise.resolve(Object.assign(Object.assign({},r),{url:t.targetUrl,headers:Object.assign(Object.assign({},r.headers||{}),{[e.TARGET_URL_HEADER]:r.url})}))}})),$i=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RUNNER_HINT_HEADER=e.QUEUE_PRIORITY_HEADER=e.REQUEST_TIMEOUT_TYPE_HEADER=e.REQUEST_TIMEOUT_HEADER=e.MIN_REQUEST_TIMEOUT_SECONDS=void 0,e.validateTimeoutHeader=t,e.buildTimeoutHeaders=n,e.MIN_REQUEST_TIMEOUT_SECONDS=1,e.REQUEST_TIMEOUT_HEADER=`x-fal-request-timeout`,e.REQUEST_TIMEOUT_TYPE_HEADER=`x-fal-request-timeout-type`,e.QUEUE_PRIORITY_HEADER=`x-fal-queue-priority`,e.RUNNER_HINT_HEADER=`x-fal-runner-hint`;function t(t){if(typeof t!=`number`||isNaN(t))throw Error(`Timeout must be a number, got ${t}`);if(t<=e.MIN_REQUEST_TIMEOUT_SECONDS)throw Error(`Timeout must be greater than ${e.MIN_REQUEST_TIMEOUT_SECONDS} seconds`);return t.toString()}function n(n){return n===void 0?{}:{[e.REQUEST_TIMEOUT_HEADER]:t(n)}}})),W=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.ValidationError=e.ApiError=void 0,e.defaultResponseHandler=c,e.resultResponseHandler=l;let i=$i(),a=`x-fal-request-id`;var o=class extends Error{constructor({message:e,status:t,body:n,requestId:r,timeoutType:i}){super(e),this.name=`ApiError`,this.status=t,this.body=n,this.requestId=r||``,this.timeoutType=i}get isUserTimeout(){return this.status===504&&this.timeoutType===`user`}};e.ApiError=o;var s=class extends o{constructor(e){super(e),this.name=`ValidationError`}get fieldErrors(){return typeof this.body.detail==`string`?[{loc:[`body`],msg:this.body.detail,type:`value_error`}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(t=>t.loc[t.loc.length-1]===e)}};e.ValidationError=s;function c(e){return r(this,void 0,void 0,function*(){let{status:t,statusText:n}=e,r=e.headers.get(`Content-Type`)??``,c=e.headers.get(a)||void 0,l=e.headers.get(i.REQUEST_TIMEOUT_TYPE_HEADER)||void 0;if(!e.ok){if(r.includes(`application/json`)){let r=yield e.json();throw new(t===422?s:o)({message:r.message||n,status:t,body:r,requestId:c,timeoutType:l})}throw new o({message:`HTTP ${t}: ${n}`,status:t,requestId:c,timeoutType:l})}return r.includes(`application/json`)?e.json():r.includes(`text/html`)?e.text():r.includes(`application/octet-stream`)?e.arrayBuffer():e.text()})}function l(e){return r(this,void 0,void 0,function*(){return{data:yield c(e),requestId:e.headers.get(a)||``}})}})),G=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.ensureEndpointIdFormat=i,e.parseEndpointId=o,e.isValidUrl=s,e.throttle=c,e.isReact=u,e.isPlainObject=d,e.sleep=f;function i(e){if(e.split(`/`).length>1)return e;let[,t,n]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(e)||[];if(t&&n)return`${t}/${n}`;throw Error(`Invalid app id: ${e}. Must be in the format <appOwner>/<appId>`)}let a=[`workflows`,`comfy`];function o(e){let t=i(e).split(`/`);return a.includes(t[0])?{owner:t[1],alias:t[2],path:t.slice(3).join(`/`)||void 0,namespace:t[0]}:{owner:t[0],alias:t[1],path:t.slice(2).join(`/`)||void 0}}function s(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function c(e,t,n=!1){let r,i;return(...a)=>{!i&&n?(e(...a),i=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-i>=t&&(e(...a),i=Date.now())},t-(Date.now()-i)))}}let l;function u(){if(l===void 0){let e=(/* @__PURE__ */ Error()).stack;l=!!e&&(e.includes(`node_modules/react-dom/`)||e.includes(`node_modules/next/`))}return l}function d(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function f(e){return r(this,void 0,void 0,function*(){return new Promise(t=>setTimeout(t,e))})}})),ea=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_RETRY_OPTIONS=e.DEFAULT_RETRYABLE_STATUS_CODES=void 0,e.isRetryableError=o,e.calculateBackoffDelay=s,e.executeWithRetry=c;let i=W(),a=G();e.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504],e.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:e.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function o(e,t){return!(e instanceof i.ApiError)||e.isUserTimeout?!1:t.includes(e.status)}function s(e,t,n,r,i){let a=Math.min(t*r**+e,n);if(i){let e=.25*a*(Math.random()*2-1);return Math.max(0,a+e)}return a}function c(e,t,n){return r(this,void 0,void 0,function*(){let r={totalAttempts:0,totalDelay:0},i;for(let c=0;c<=t.maxRetries;c++){r.totalAttempts++;try{return{result:yield e(),metrics:r}}catch(e){if(i=e,r.lastError=e,c===t.maxRetries||!o(e,t.retryableStatusCodes))throw e;let l=s(c,t.baseDelay,t.maxDelay,t.backoffMultiplier,t.enableJitter);r.totalDelay+=l,n&&n(c+1,e,l),yield(0,a.sleep)(l)}}throw i})}})),ta=/* @__PURE__ */ a(((e,t)=>{t.exports={name:`@fal-ai/client`,description:`The fal.ai client for JavaScript and TypeScript`,version:`1.9.0`,license:`MIT`,repository:{type:`git`,url:`https://github.com/fal-ai/fal-js.git`,directory:`libs/client`},keywords:[`fal`,`client`,`ai`,`ml`,`typescript`],exports:{".":`./src/index.js`,"./endpoints":`./src/types/endpoints.js`},typesVersions:{"*":{endpoints:[`src/types/endpoints.d.ts`]}},main:`./src/index.js`,types:`./src/index.d.ts`,dependencies:{"@msgpack/msgpack":`^3.0.0-beta2`,"eventsource-parser":`^1.1.2`,robot3:`^0.4.1`},engines:{node:`>=18.0.0`},type:`commonjs`}})),na=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowser=t,e.getUserAgent=r;function t(){return typeof window<`u`&&window.document!==void 0}let n=null;function r(){if(n!==null)return n;let e=ta();return n=`${e.name}/${e.version}`,n}})),ra=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.credentialsFromEnv=void 0,e.resolveDefaultFetch=a,e.createConfig=c,e.getRestApiUrl=l;let t=Qi(),n=W(),r=ea(),i=na();function a(){if(typeof fetch>`u`)throw Error(`Your environment does not support fetch. Please provide your own fetch implementation.`);return fetch}function o(){return typeof process<`u`&&process.env&&(process.env.FAL_KEY!==void 0||process.env.FAL_KEY_ID!==void 0&&process.env.FAL_KEY_SECRET!==void 0)}e.credentialsFromEnv=()=>{if(o())return process.env.FAL_KEY===void 0?process.env.FAL_KEY_ID?`${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}`:void 0:process.env.FAL_KEY};let s={credentials:e.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:n.defaultResponseHandler,retry:r.DEFAULT_RETRY_OPTIONS};function c(e){let n=Object.assign(Object.assign(Object.assign({},s),e),{fetch:e.fetch??a(),retry:Object.assign(Object.assign({},r.DEFAULT_RETRY_OPTIONS),e.retry||{})});e.proxyUrl&&(n=Object.assign(Object.assign({},n),{requestMiddleware:(0,t.withMiddleware)(n.requestMiddleware,(0,t.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:o,suppressLocalCredentialsWarning:c}=n,l=typeof o==`function`?o():o;return(0,i.isBrowser)()&&l&&!c&&console.warn(`The fal credentials are exposed in the browser's environment. That's not recommended for production use cases.`),n}function l(){return`https://rest.alpha.fal.ai`}})),ia=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},i=n&&n.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};Object.defineProperty(e,"__esModule",{value:!0}),e.dispatchRequest=l,e.buildUrl=u;let a=ea(),o=na(),s=G(),c=typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)===`Cloudflare-Workers`;function l(e){return r(this,void 0,void 0,function*(){let{targetUrl:t,input:n,config:l,options:u={}}=e,{credentials:d,requestMiddleware:f,responseHandler:p,fetch:m}=l,h=Object.assign(Object.assign({},l.retry),u.retry||{}),g=()=>r(this,void 0,void 0,function*(){let r=(0,o.isBrowser)()?{}:{"User-Agent":(0,o.getUserAgent)()},a=typeof d==`function`?d():d,{method:s,url:l,headers:h}=yield f({method:(e.method??u.method??`post`).toUpperCase(),url:t,headers:e.headers}),g=a?{Authorization:`Key ${a}`}:{},_=Object.assign(Object.assign(Object.assign(Object.assign({},g),{Accept:`application/json`,"Content-Type":`application/json`}),r),h??{}),{responseHandler:v,retry:y}=u,b=i(u,[`responseHandler`,`retry`]),ee=yield m(l,Object.assign(Object.assign(Object.assign(Object.assign({},b),{method:s,headers:Object.assign(Object.assign({},_),b.headers??{})}),!c&&{mode:`cors`}),{signal:u.signal,body:s.toLowerCase()!==`get`&&n?JSON.stringify(n):void 0}));return yield(v??p)(ee)}),_;for(let e=0;e<=h.maxRetries;e++)try{return yield g()}catch(t){if(_=t,e===h.maxRetries||!(0,a.isRetryableError)(t,h.retryableStatusCodes)||u.signal?.aborted)throw t;let n=(0,a.calculateBackoffDelay)(e,h.baseDelay,h.maxDelay,h.backoffMultiplier,h.enableJitter);yield(0,s.sleep)(n)}throw _})}function u(e,t={}){let n=(t.method??`post`).toLowerCase(),r=(t.path??``).replace(/^\//,``).replace(/\/{2,}/,`/`),i=t.input,a=Object.assign(Object.assign({},t.query||{}),n===`get`?i:{}),o=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:``;if((0,s.isValidUrl)(e))return`${e.endsWith(`/`)?e:`${e}/`}${r}${o}`;let c=(0,s.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:``}fal.run/${c}/${r}`.replace(/\/$/,``)}${o}`}})),aa=/* @__PURE__ */ a(((e,t,n)=>{var r=n&&n.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.OBJECT_LIFECYCYLE_PREFERENCE_HEADER=void 0,e.getExpirationDurationSeconds=c,e.buildObjectLifecycleHeaders=l,e.createStorageClient=h;let i=ra(),a=ia(),o=G();e.OBJECT_LIFECYCYLE_PREFERENCE_HEADER=`x-fal-object-lifecycle-preference`;let s={never:31536e5,immediate:void 0,"1h":3600,"1d":86400,"7d":604800,"30d":2592e3,"1y":31536e3};function c(e){let{expiresIn:t}=e;return typeof t==`number`?t:s[t]}function l(t){if(!t)return{};let n=c(t);return n===void 0?{}:{[e.OBJECT_LIFECYCYLE_PREFERENCE_HEADER]:JSON.stringify({expiration_duration_seconds:n})}}function u(e){let[,t]=e.split(`/`);return t.split(/[-;]/)[0]??`bin`}function d(e,t,n,o){return r(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${u(n)}`,s={};if(o){let e={expiration_duration_seconds:c(o),allow_io_storage:o.expiresIn!==`immediate`};s[`X-Fal-Object-Lifecycle`]=JSON.stringify(e)}return yield(0,a.dispatchRequest)({method:`POST`,targetUrl:`${(0,i.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:n,file_name:r},config:t,headers:s})})}function f(e,t,n,o){return r(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${u(n)}`,s={};return o&&(s[`X-Fal-Object-Lifecycle`]=JSON.stringify(o)),yield(0,a.dispatchRequest)({method:`POST`,targetUrl:`${(0,i.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:n,file_name:r},config:t,headers:s})})}function p(e,t,n){return r(this,arguments,void 0,function*(e,t,n,r=3){if(r===0)throw Error(`Part upload failed, retries exhausted`);let{fetch:i,responseHandler:a}=n;try{return yield a(yield i(e,{method:`PUT`,body:t}))}catch{return yield p(e,t,n,r-1)}})}function m(e,t,n){return r(this,void 0,void 0,function*(){let{fetch:r,responseHandler:i}=t,{upload_url:a,file_url:o}=yield f(e,t,e.type||`application/octet-stream`,n),s=10485760,c=Math.ceil(e.size/s),l=new URL(a),u=[];for(let n=0;n<c;n++){let r=n*s,i=Math.min(r+s,e.size),a=e.slice(r,i),o=n+1,c=`${l.origin}${l.pathname}/${o}${l.search}`;u.push(yield p(c,a,t))}return yield i(yield r(`${l.origin}${l.pathname}/complete${l.search}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({parts:u.map(e=>({partNumber:e.partNumber,etag:e.etag}))})})),o})}function h({config:e}){let t={upload:(t,n)=>r(this,void 0,void 0,function*(){let r=n?.lifecycle;if(t.size>94371840)return yield m(t,e,r);let i=t.type||`application/octet-stream`,{fetch:a,responseHandler:o}=e,{upload_url:s,file_url:c}=yield d(t,e,i,r);return yield o(yield a(s,{method:`PUT`,body:t,headers:{"Content-Type":t.type||`application/octet-stream`}})),c}),transformInput:e=>r(this,void 0,void 0,function*(){if(Array.isArray(e))return Promise.all(e.map(e=>t.transformInput(e)));if(e instanceof Blob)return yield t.upload(e);if((0,o.isPlainObject)(e)){let n=Object.entries(e).map(e=>r(this,[e],void 0,function*([e,n]){return[e,yield t.transformInput(n)]})),i=yield Promise.all(n);return Object.fromEntries(i)}return e})};return t}})),oa=/* @__PURE__ */ a((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t,i,a,o,s,c,l;return u(),{feed:d,reset:u};function u(){t=!0,i=``,a=0,o=-1,s=void 0,c=void 0,l=``}function d(e){i=i?i+e:e,t&&r(i)&&(i=i.slice(n.length)),t=!1;let s=i.length,c=0,l=!1;for(;c<s;){l&&=(i[c]===`
|
|
68
68
|
`&&++c,!1);let e=-1,t=o,n;for(let r=a;e<0&&r<s;++r)n=i[r],n===`:`&&t<0?t=r-c:n===`\r`?(l=!0,e=r-c):n===`
|
|
69
69
|
`&&(e=r-c);if(e<0){a=s-c,o=t;break}a=0,o=-1,f(i,c,t,e),c+=e+1}c===s?i=``:c>0&&(i=i.slice(c))}function f(t,n,r,i){if(i===0){l.length>0&&(e({type:`event`,id:s,event:c||void 0,data:l.slice(0,-1)}),l=``,s=void 0),c=void 0;return}let a=r<0,o=t.slice(n,n+(a?i:r)),u=0;u=a?i:t[n+r+1]===` `?r+2:r+1;let d=n+u,f=i-u,p=t.slice(d,d+f).toString();if(o===`data`)l+=p?`${p}
|
|
70
70
|
`:`
|