@imgly/plugin-ai-image-generation-web 0.1.7 → 0.1.9

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.
@@ -1,8 +1,8 @@
1
- var eo=Object.create;var $i=Object.defineProperty;var to=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var ro=Object.getPrototypeOf,no=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var oo=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of io(t))!no.call(e,n)&&n!==i&&$i(e,n,{get:()=>t[n],enumerable:!(r=to(t,n))||r.enumerable});return e};var ji=(e,t,i)=>(i=e!=null?eo(ro(e)):{},oo(t||!e||!e.__esModule?$i(i,"default",{value:e,enumerable:!0}):i,e));var Wt=k($=>{"use strict";var yd=$&&$.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty($,"__esModule",{value:!0});$.TARGET_URL_HEADER=void 0;$.withMiddleware=bd;$.withProxy=_d;function bd(...e){let t=i=>typeof i=="function";return i=>yd(this,void 0,void 0,function*(){let r=Object.assign({},i);for(let n of e.filter(t))r=yield n(r);return r})}$.TARGET_URL_HEADER="x-fal-target-url";function _d(e){let t=i=>Promise.resolve(i);return typeof window>"u"?t:i=>i.headers&&$.TARGET_URL_HEADER in i?t(i):Promise.resolve(Object.assign(Object.assign({},i),{url:e.targetUrl,headers:Object.assign(Object.assign({},i.headers||{}),{[$.TARGET_URL_HEADER]:i.url})}))}});var Y=k(j=>{"use strict";var $r=j&&j.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(j,"__esModule",{value:!0});j.ValidationError=j.ApiError=void 0;j.defaultResponseHandler=jr;j.resultResponseHandler=wd;var vd="x-fal-request-id",fe=class extends Error{constructor({message:t,status:i,body:r}){super(t),this.name="ApiError",this.status=i,this.body=r}};j.ApiError=fe;var Je=class extends fe{constructor(t){super(t),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(t){return this.fieldErrors.filter(i=>i.loc[i.loc.length-1]===t)}};j.ValidationError=Je;function jr(e){return $r(this,void 0,void 0,function*(){var t;let{status:i,statusText:r}=e,n=(t=e.headers.get("Content-Type"))!==null&&t!==void 0?t:"";if(!e.ok){if(n.includes("application/json")){let o=yield e.json(),a=i===422?Je:fe;throw new a({message:o.message||r,status:i,body:o})}throw new fe({message:`HTTP ${i}: ${r}`,status:i})}return n.includes("application/json")?e.json():n.includes("text/html")?e.text():n.includes("application/octet-stream")?e.arrayBuffer():e.text()})}function wd(e){return $r(this,void 0,void 0,function*(){return{data:yield jr(e),requestId:e.headers.get(vd)||""}})}});var Pr=k((Nh,kd)=>{kd.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.3.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"}});var it=k(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.isBrowser=Id;tt.getUserAgent=Ad;function Id(){return typeof window<"u"&&typeof window.document<"u"}var et=null;function Ad(){if(et!==null)return et;let e=Pr();return et=`${e.name}/${e.version}`,et}});var rt=k(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.credentialsFromEnv=void 0;L.resolveDefaultFetch=Ur;L.createConfig=Td;L.getRestApiUrl=Od;var Dr=Wt(),Ed=Y(),xd=it();function Ur(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function Sd(){return typeof process<"u"&&process.env&&(typeof process.env.FAL_KEY<"u"||typeof process.env.FAL_KEY_ID<"u"&&typeof process.env.FAL_KEY_SECRET<"u")}var Cd=()=>{if(Sd())return typeof process.env.FAL_KEY<"u"?process.env.FAL_KEY:process.env.FAL_KEY_ID?`${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}`:void 0};L.credentialsFromEnv=Cd;var Md={credentials:L.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:Ed.defaultResponseHandler};function Td(e){var t;let i=Object.assign(Object.assign(Object.assign({},Md),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:Ur()});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,Dr.withMiddleware)(i.requestMiddleware,(0,Dr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,xd.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),i}function Od(){return"https://rest.alpha.fal.ai"}});var Z=k(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.ensureEndpointIdFormat=Nr;z.parseEndpointId=jd;z.isValidUrl=Pd;z.throttle=Dd;z.isReact=Ud;z.isPlainObject=Nd;function Nr(e){if(e.split("/").length>1)return e;let[,i,r]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(e)||[];if(i&&r)return`${i}/${r}`;throw new Error(`Invalid app id: ${e}. Must be in the format <appOwner>/<appId>`)}var $d=["workflows","comfy"];function jd(e){let i=Nr(e).split("/");return $d.includes(i[0])?{owner:i[1],alias:i[2],path:i.slice(3).join("/")||void 0,namespace:i[0]}:{owner:i[0],alias:i[1],path:i.slice(2).join("/")||void 0}}function Pd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function Dd(e,t,i=!1){let r,n;return(...o)=>{!n&&i?(e(...o),n=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-n>=t&&(e(...o),n=Date.now())},t-(Date.now()-n)))}}var Yt;function Ud(){if(Yt===void 0){let e=new Error().stack;Yt=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return Yt}function Nd(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}});var me=k(R=>{"use strict";var qd=R&&R.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})},Bd=R&&R.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]]);return i};Object.defineProperty(R,"__esModule",{value:!0});R.dispatchRequest=Ld;R.buildUrl=zd;var qr=it(),Br=Z(),Fd=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Ld(e){return qd(this,void 0,void 0,function*(){var t,i,r;let{targetUrl:n,input:o,config:a,options:s={}}=e,{credentials:l,requestMiddleware:u,responseHandler:c,fetch:d}=a,h=(0,qr.isBrowser)()?{}:{"User-Agent":(0,qr.getUserAgent)()},p=typeof l=="function"?l():l,{method:f,url:b,headers:v}=yield u({method:((i=(t=e.method)!==null&&t!==void 0?t:s.method)!==null&&i!==void 0?i:"post").toUpperCase(),url:n,headers:e.headers}),g=p?{Authorization:`Key ${p}`}:{},y=Object.assign(Object.assign(Object.assign(Object.assign({},g),{Accept:"application/json","Content-Type":"application/json"}),h),v??{}),{responseHandler:I}=s,w=Bd(s,["responseHandler"]),C=yield d(b,Object.assign(Object.assign(Object.assign(Object.assign({},w),{method:f,headers:Object.assign(Object.assign({},y),(r=w.headers)!==null&&r!==void 0?r:{})}),!Fd&&{mode:"cors"}),{signal:s.signal,body:f.toLowerCase()!=="get"&&o?JSON.stringify(o):void 0}));return yield(I??c)(C)})}function zd(e,t={}){var i,r;let n=((i=t.method)!==null&&i!==void 0?i:"post").toLowerCase(),o=((r=t.path)!==null&&r!==void 0?r:"").replace(/^\//,"").replace(/\/{2,}/,"/"),a=t.input,s=Object.assign(Object.assign({},t.query||{}),n==="get"?a:{}),l=Object.keys(s).length>0?`?${new URLSearchParams(s).toString()}`:"";if((0,Br.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${l}`;let u=(0,Br.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${l}`}});var Lr=k(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});function Rd(e){let t,i,r,n,o,a,s;return l(),{feed:u,reset:l};function l(){t=!0,i="",r=0,n=-1,o=void 0,a=void 0,s=""}function u(d){i=i?i+d:d,t&&Vd(i)&&(i=i.slice(Fr.length)),t=!1;let h=i.length,p=0,f=!1;for(;p<h;){f&&(i[p]===`
2
- `&&++p,f=!1);let b=-1,v=n,g;for(let y=r;b<0&&y<h;++y)g=i[y],g===":"&&v<0?v=y-p:g==="\r"?(f=!0,b=y-p):g===`
3
- `&&(b=y-p);if(b<0){r=h-p,n=v;break}else r=0,n=-1;c(i,p,v,b),p+=b+1}p===h?i="":p>0&&(i=i.slice(p))}function c(d,h,p,f){if(f===0){s.length>0&&(e({type:"event",id:o,event:a||void 0,data:s.slice(0,-1)}),s="",o=void 0),a=void 0;return}let b=p<0,v=d.slice(h,h+(b?f:p)),g=0;b?g=f:d[h+p+1]===" "?g=p+2:g=p+1;let y=h+g,I=f-g,w=d.slice(y,y+I).toString();if(v==="data")s+=w?"".concat(w,`
1
+ var eo=Object.create;var Oi=Object.defineProperty;var to=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var ro=Object.getPrototypeOf,no=Object.prototype.hasOwnProperty;var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var oo=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of io(t))!no.call(e,n)&&n!==i&&Oi(e,n,{get:()=>t[n],enumerable:!(r=to(t,n))||r.enumerable});return e};var ji=(e,t,i)=>(i=e!=null?eo(ro(e)):{},oo(t||!e||!e.__esModule?Oi(i,"default",{value:e,enumerable:!0}):i,e));var Wt=I(O=>{"use strict";var Cd=O&&O.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(O,"__esModule",{value:!0});O.TARGET_URL_HEADER=void 0;O.withMiddleware=Td;O.withProxy=Md;function Td(...e){let t=i=>typeof i=="function";return i=>Cd(this,void 0,void 0,function*(){let r=Object.assign({},i);for(let n of e.filter(t))r=yield n(r);return r})}O.TARGET_URL_HEADER="x-fal-target-url";function Md(e){let t=i=>Promise.resolve(i);return typeof window>"u"?t:i=>i.headers&&O.TARGET_URL_HEADER in i?t(i):Promise.resolve(Object.assign(Object.assign({},i),{url:e.targetUrl,headers:Object.assign(Object.assign({},i.headers||{}),{[O.TARGET_URL_HEADER]:i.url})}))}});var Y=I(j=>{"use strict";var Or=j&&j.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(j,"__esModule",{value:!0});j.ValidationError=j.ApiError=void 0;j.defaultResponseHandler=jr;j.resultResponseHandler=Od;var $d="x-fal-request-id",fe=class extends Error{constructor({message:t,status:i,body:r}){super(t),this.name="ApiError",this.status=i,this.body=r}};j.ApiError=fe;var Je=class extends fe{constructor(t){super(t),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(t){return this.fieldErrors.filter(i=>i.loc[i.loc.length-1]===t)}};j.ValidationError=Je;function jr(e){return Or(this,void 0,void 0,function*(){var t;let{status:i,statusText:r}=e,n=(t=e.headers.get("Content-Type"))!==null&&t!==void 0?t:"";if(!e.ok){if(n.includes("application/json")){let o=yield e.json(),a=i===422?Je:fe;throw new a({message:o.message||r,status:i,body:o})}throw new fe({message:`HTTP ${i}: ${r}`,status:i})}return n.includes("application/json")?e.json():n.includes("text/html")?e.text():n.includes("application/octet-stream")?e.arrayBuffer():e.text()})}function Od(e){return Or(this,void 0,void 0,function*(){return{data:yield jr(e),requestId:e.headers.get($d)||""}})}});var Pr=I((Wh,jd)=>{jd.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.3.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"}});var it=I(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.isBrowser=Pd;tt.getUserAgent=Dd;function Pd(){return typeof window<"u"&&typeof window.document<"u"}var et=null;function Dd(){if(et!==null)return et;let e=Pr();return et=`${e.name}/${e.version}`,et}});var rt=I(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.credentialsFromEnv=void 0;F.resolveDefaultFetch=Ur;F.createConfig=Fd;F.getRestApiUrl=zd;var Dr=Wt(),Ud=Y(),Nd=it();function Ur(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function qd(){return typeof process<"u"&&process.env&&(typeof process.env.FAL_KEY<"u"||typeof process.env.FAL_KEY_ID<"u"&&typeof process.env.FAL_KEY_SECRET<"u")}var Bd=()=>{if(qd())return typeof process.env.FAL_KEY<"u"?process.env.FAL_KEY:process.env.FAL_KEY_ID?`${process.env.FAL_KEY_ID}:${process.env.FAL_KEY_SECRET}`:void 0};F.credentialsFromEnv=Bd;var Ld={credentials:F.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:Ud.defaultResponseHandler};function Fd(e){var t;let i=Object.assign(Object.assign(Object.assign({},Ld),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:Ur()});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,Dr.withMiddleware)(i.requestMiddleware,(0,Dr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,Nd.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),i}function zd(){return"https://rest.alpha.fal.ai"}});var Z=I(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.ensureEndpointIdFormat=Nr;z.parseEndpointId=Vd;z.isValidUrl=Hd;z.throttle=Gd;z.isReact=Qd;z.isPlainObject=Kd;function Nr(e){if(e.split("/").length>1)return e;let[,i,r]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(e)||[];if(i&&r)return`${i}/${r}`;throw new Error(`Invalid app id: ${e}. Must be in the format <appOwner>/<appId>`)}var Rd=["workflows","comfy"];function Vd(e){let i=Nr(e).split("/");return Rd.includes(i[0])?{owner:i[1],alias:i[2],path:i.slice(3).join("/")||void 0,namespace:i[0]}:{owner:i[0],alias:i[1],path:i.slice(2).join("/")||void 0}}function Hd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function Gd(e,t,i=!1){let r,n;return(...o)=>{!n&&i?(e(...o),n=Date.now()):(r&&clearTimeout(r),r=setTimeout(()=>{Date.now()-n>=t&&(e(...o),n=Date.now())},t-(Date.now()-n)))}}var Yt;function Qd(){if(Yt===void 0){let e=new Error().stack;Yt=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return Yt}function Kd(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}});var me=I(R=>{"use strict";var Wd=R&&R.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})},Yd=R&&R.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]]);return i};Object.defineProperty(R,"__esModule",{value:!0});R.dispatchRequest=Xd;R.buildUrl=Jd;var qr=it(),Br=Z(),Zd=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Xd(e){return Wd(this,void 0,void 0,function*(){var t,i,r;let{targetUrl:n,input:o,config:a,options:s={}}=e,{credentials:c,requestMiddleware:u,responseHandler:l,fetch:d}=a,f=(0,qr.isBrowser)()?{}:{"User-Agent":(0,qr.getUserAgent)()},g=typeof c=="function"?c():c,{method:m,url:_,headers:w}=yield u({method:((i=(t=e.method)!==null&&t!==void 0?t:s.method)!==null&&i!==void 0?i:"post").toUpperCase(),url:n,headers:e.headers}),p=g?{Authorization:`Key ${g}`}:{},h=Object.assign(Object.assign(Object.assign(Object.assign({},p),{Accept:"application/json","Content-Type":"application/json"}),f),w??{}),{responseHandler:v}=s,b=Yd(s,["responseHandler"]),C=yield d(_,Object.assign(Object.assign(Object.assign(Object.assign({},b),{method:m,headers:Object.assign(Object.assign({},h),(r=b.headers)!==null&&r!==void 0?r:{})}),!Zd&&{mode:"cors"}),{signal:s.signal,body:m.toLowerCase()!=="get"&&o?JSON.stringify(o):void 0}));return yield(v??l)(C)})}function Jd(e,t={}){var i,r;let n=((i=t.method)!==null&&i!==void 0?i:"post").toLowerCase(),o=((r=t.path)!==null&&r!==void 0?r:"").replace(/^\//,"").replace(/\/{2,}/,"/"),a=t.input,s=Object.assign(Object.assign({},t.query||{}),n==="get"?a:{}),c=Object.keys(s).length>0?`?${new URLSearchParams(s).toString()}`:"";if((0,Br.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${c}`;let u=(0,Br.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var Fr=I(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});function ep(e){let t,i,r,n,o,a,s;return c(),{feed:u,reset:c};function c(){t=!0,i="",r=0,n=-1,o=void 0,a=void 0,s=""}function u(d){i=i?i+d:d,t&&tp(i)&&(i=i.slice(Lr.length)),t=!1;let f=i.length,g=0,m=!1;for(;g<f;){m&&(i[g]===`
2
+ `&&++g,m=!1);let _=-1,w=n,p;for(let h=r;_<0&&h<f;++h)p=i[h],p===":"&&w<0?w=h-g:p==="\r"?(m=!0,_=h-g):p===`
3
+ `&&(_=h-g);if(_<0){r=f-g,n=w;break}else r=0,n=-1;l(i,g,w,_),g+=_+1}g===f?i="":g>0&&(i=i.slice(g))}function l(d,f,g,m){if(m===0){s.length>0&&(e({type:"event",id:o,event:a||void 0,data:s.slice(0,-1)}),s="",o=void 0),a=void 0;return}let _=g<0,w=d.slice(f,f+(_?m:g)),p=0;_?p=m:d[f+g+1]===" "?p=g+2:p=g+1;let h=f+p,v=m-p,b=d.slice(h,h+v).toString();if(w==="data")s+=b?"".concat(b,`
4
4
  `):`
5
- `;else if(v==="event")a=w;else if(v==="id"&&!w.includes("\0"))o=w;else if(v==="retry"){let C=parseInt(w,10);Number.isNaN(C)||e({type:"reconnect-interval",value:C})}}}var Fr=[239,187,191];function Vd(e){return Fr.every((t,i)=>e.charCodeAt(i)===t)}Zt.createParser=Rd});var Xt=k(V=>{"use strict";var Hd=V&&V.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(V,"__esModule",{value:!0});V.TOKEN_EXPIRATION_SECONDS=void 0;V.getTemporaryAuthToken=Wd;var Gd=rt(),Qd=me(),Kd=Z();V.TOKEN_EXPIRATION_SECONDS=120;function Wd(e,t){return Hd(this,void 0,void 0,function*(){let i=(0,Kd.parseEndpointId)(e),r=yield(0,Qd.dispatchRequest)({method:"POST",targetUrl:`${(0,Gd.getRestApiUrl)()}/tokens/`,config:t,input:{allowed_apps:[i.alias],token_expiration:V.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var ei=k(O=>{"use strict";var je=O&&O.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})},Pe=O&&O.__await||function(e){return this instanceof Pe?(this.v=e,this):new Pe(e)},Yd=O&&O.__asyncGenerator||function(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(e,t||[]),n,o=[];return n={},s("next"),s("throw"),s("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(p){return function(f){return Promise.resolve(f).then(p,d)}}function s(p,f){r[p]&&(n[p]=function(b){return new Promise(function(v,g){o.push([p,b,v,g])>1||l(p,b)})},f&&(n[p]=f(n[p])))}function l(p,f){try{u(r[p](f))}catch(b){h(o[0][3],b)}}function u(p){p.value instanceof Pe?Promise.resolve(p.value.v).then(c,d):h(o[0][2],p)}function c(p){l("next",p)}function d(p){l("throw",p)}function h(p,f){p(f),o.shift(),o.length&&l(o[0][0],o[0][1])}};Object.defineProperty(O,"__esModule",{value:!0});O.FalStream=void 0;O.createStreamingClient=ep;var Zd=Lr(),Xd=Xt(),zr=me(),ye=Y(),Jt="text/event-stream",Jd=15*1e3,nt=class{constructor(t,i,r){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this.abortController=new AbortController,this.start=()=>je(this,void 0,void 0,function*(){var o,a;let{endpointId:s,options:l}=this,{input:u,method:c="post",connectionMode:d="server"}=l;try{if(d==="client"){let h=yield(0,Xd.getTemporaryAuthToken)(s,this.config),{fetch:p}=this.config,f=new URL(this.url);f.searchParams.set("fal_jwt_token",h);let b=yield p(f.toString(),{method:c.toUpperCase(),headers:{accept:(o=l.accept)!==null&&o!==void 0?o:Jt,"content-type":"application/json"},body:u&&c!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return yield this.handleResponse(b)}return yield(0,zr.dispatchRequest)({method:c.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=l.accept)!==null&&a!==void 0?a:Jt},responseHandler:this.handleResponse,signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>je(this,void 0,void 0,function*(){var a,s;if(!o.ok){try{yield(0,ye.defaultResponseHandler)(o)}catch(b){this.emit("error",b)}return}let l=o.body;if(!l){this.emit("error",new ye.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((a=o.headers.get("content-type"))!==null&&a!==void 0?a:"").startsWith(Jt)){let b=l.getReader(),v=()=>{b.read().then(({done:g,value:y})=>{if(g){this.emit("done",this.currentData);return}this.currentData=y,this.emit("data",y),v()})};v();return}let c=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,Zd.createParser)(b=>{if(b.type==="event"){let v=b.data;try{let g=JSON.parse(v);this.buffer.push(g),this.currentData=g,this.emit("data",g),this.emit("message",g)}catch(g){this.emit("error",g)}}}),p=(s=this.options.timeout)!==null&&s!==void 0?s:Jd,f=()=>je(this,void 0,void 0,function*(){let{value:b,done:v}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(c.decode(b)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new ye.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),v?this.emit("done",this.currentData):f().catch(this.handleError)});f().catch(this.handleError)}),this.handleError=o=>{var a;if(o.name==="AbortError"||this.signal.aborted)return;let s=o instanceof ye.ApiError?o:new ye.ApiError({message:(a=o.message)!==null&&a!==void 0?a:"An unknown error occurred",status:500});this.emit("error",s)},this.on=(o,a)=>{var s;this.listeners.has(o)||this.listeners.set(o,[]),(s=this.listeners.get(o))===null||s===void 0||s.push(a)},this.emit=(o,a)=>{let s=this.listeners.get(o)||[];for(let l of s)l(a)},this.done=()=>je(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=t,this.config=i,this.url=(n=r.url)!==null&&n!==void 0?n:(0,zr.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new ye.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var s;o((s=this.currentData)!==null&&s!==void 0?s:{})}),this.on("done",s=>{this.streamClosed=!0,o(s)}),this.on("error",s=>{this.streamClosed=!0,a(s)})}),r.signal&&r.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return Yd(this,arguments,function*(){let i=!0,r=()=>i=!1;for(this.on("error",r),this.on("done",r);i||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield Pe(n)),yield Pe(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}};O.FalStream=nt;function ep({config:e,storage:t}){return{stream(i,r){return je(this,void 0,void 0,function*(){let n=r.input?yield t.transformInput(r.input):void 0;return new nt(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var Vr=k(H=>{"use strict";var X=H&&H.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})},tp=H&&H.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]]);return i};Object.defineProperty(H,"__esModule",{value:!0});H.createQueueClient=void 0;var N=me(),ip=Y(),rp=ei(),ot=Z(),Rr=500,np=({config:e,storage:t})=>{let i={submit(r,n){return X(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a}=n,s=tp(n,["webhookUrl","priority"]),l=n.input?yield t.transformInput(n.input):void 0;return(0,N.dispatchRequest)({method:n.method,targetUrl:(0,N.buildUrl)(r,Object.assign(Object.assign({},s),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:{"x-fal-queue-priority":a??"normal"},input:l,config:e,options:{signal:n.abortSignal}})})},status(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,logs:s=!1,abortSignal:l}){let u=(0,ot.parseEndpointId)(o),c=u.namespace?`${u.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${c}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:s?"1":"0"},path:`/requests/${a}/status`}),config:e,options:{signal:l}})})},streamStatus(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,logs:s=!1,connectionMode:l}){let u=(0,ot.parseEndpointId)(o),c=u.namespace?`${u.namespace}/`:"",d={logs:s?"1":"0"},h=(0,N.buildUrl)(`${c}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new rp.FalStream(o,e,{url:h,method:"get",connectionMode:l,queryParams:d})})},subscribeToStatus(r,n){return X(this,void 0,void 0,function*(){let o=n.requestId,a=n.timeout,s,l=()=>{};if(n.mode==="streaming"){let u=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),c=[];a&&(s=setTimeout(()=>{throw u.abort(),i.cancel(r,{requestId:o}).catch(l),new Error(`Client timed out waiting for the request to complete after ${a}ms`)},a)),u.on("data",h=>{n.onQueueUpdate&&("logs"in h&&Array.isArray(h.logs)&&h.logs.length>0&&c.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:c}):h))});let d=yield u.done();return s&&clearTimeout(s),d}return new Promise((u,c)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:Rr,f=()=>{s&&clearTimeout(s),h&&clearTimeout(h)};a&&(s=setTimeout(()=>{f(),i.cancel(r,{requestId:o}).catch(l),c(new Error(`Client timed out waiting for the request to complete after ${a}ms`))},a));let b=()=>X(this,void 0,void 0,function*(){var v;try{let g=yield i.status(r,{requestId:o,logs:(v=n.logs)!==null&&v!==void 0?v:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){f(),u(g);return}h=setTimeout(b,p)}catch(g){f(),c(g)}});b().catch(c)})})},result(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let l=(0,ot.parseEndpointId)(o),u=l.namespace?`${l.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${u}${l.owner}/${l.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:ip.resultResponseHandler}),options:{signal:s}})})},cancel(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let l=(0,ot.parseEndpointId)(o),u=l.namespace?`${l.namespace}/`:"";yield(0,N.dispatchRequest)({method:"put",targetUrl:(0,N.buildUrl)(`${u}${l.owner}/${l.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:s}})})}};return i};H.createQueueClient=np});var at=k(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.utf8Count=op;q.utf8EncodeJs=Hr;q.utf8EncodeTE=Gr;q.utf8Encode=lp;q.utf8DecodeJs=Qr;q.utf8DecodeTD=Kr;q.utf8Decode=pp;function op(e){let t=e.length,i=0,r=0;for(;r<t;){let n=e.charCodeAt(r++);if(n&4294967168)if(!(n&4294965248))i+=2;else{if(n>=55296&&n<=56319&&r<t){let o=e.charCodeAt(r);(o&64512)===56320&&(++r,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?i+=4:i+=3}else{i++;continue}}return i}function Hr(e,t,i){let r=e.length,n=i,o=0;for(;o<r;){let a=e.charCodeAt(o++);if(a&4294967168)if(!(a&4294965248))t[n++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&o<r){let s=e.charCodeAt(o);(s&64512)===56320&&(++o,a=((a&1023)<<10)+(s&1023)+65536)}a&4294901760?(t[n++]=a>>18&7|240,t[n++]=a>>12&63|128,t[n++]=a>>6&63|128):(t[n++]=a>>12&15|224,t[n++]=a>>6&63|128)}else{t[n++]=a;continue}t[n++]=a&63|128}}var ap=new TextEncoder,sp=50;function Gr(e,t,i){ap.encodeInto(e,t.subarray(i))}function lp(e,t,i){e.length>sp?Gr(e,t,i):Hr(e,t,i)}var cp=4096;function Qr(e,t,i){let r=t,n=r+i,o=[],a="";for(;r<n;){let s=e[r++];if(!(s&128))o.push(s);else if((s&224)===192){let l=e[r++]&63;o.push((s&31)<<6|l)}else if((s&240)===224){let l=e[r++]&63,u=e[r++]&63;o.push((s&31)<<12|l<<6|u)}else if((s&248)===240){let l=e[r++]&63,u=e[r++]&63,c=e[r++]&63,d=(s&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(s);o.length>=cp&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var up=new TextDecoder,dp=200;function Kr(e,t,i){let r=e.subarray(t,t+i);return up.decode(r)}function pp(e,t,i){return i>dp?Kr(e,t,i):Qr(e,t,i)}});var ii=k(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.ExtData=void 0;var ti=class{constructor(t,i){this.type=t,this.data=i}};st.ExtData=ti});var ct=k(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.DecodeError=void 0;var ri=class e extends Error{constructor(t){super(t);let i=Object.create(e.prototype);Object.setPrototypeOf(this,i),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};lt.DecodeError=ri});var ut=k(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.UINT32_MAX=void 0;G.setUint64=gp;G.setInt64=hp;G.getInt64=fp;G.getUint64=mp;G.UINT32_MAX=4294967295;function gp(e,t,i){let r=i/4294967296,n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function hp(e,t,i){let r=Math.floor(i/4294967296),n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function fp(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function mp(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var ni=k(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.timestampExtension=M.EXT_TIMESTAMP=void 0;M.encodeTimeSpecToTimestamp=Yr;M.encodeDateToTimeSpec=Zr;M.encodeTimestampExtension=Xr;M.decodeTimestampToTimeSpec=Jr;M.decodeTimestampExtension=en;var yp=ct(),Wr=ut();M.EXT_TIMESTAMP=-1;var bp=4294967296-1,_p=17179869184-1;function Yr({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=_p)if(t===0&&e<=bp){let i=new Uint8Array(4);return new DataView(i.buffer).setUint32(0,e),i}else{let i=e/4294967296,r=e&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,t<<2|i&3),o.setUint32(4,r),n}else{let i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,t),(0,Wr.setInt64)(r,4,e),i}}function Zr(e){let t=e.getTime(),i=Math.floor(t/1e3),r=(t-i*1e3)*1e6,n=Math.floor(r/1e9);return{sec:i+n,nsec:r-n*1e9}}function Xr(e){if(e instanceof Date){let t=Zr(e);return Yr(t)}else return null}function Jr(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let i=t.getUint32(0),r=t.getUint32(4),n=(i&3)*4294967296+r,o=i>>>2;return{sec:n,nsec:o}}case 12:{let i=(0,Wr.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new yp.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function en(e){let t=Jr(e);return new Date(t.sec*1e3+t.nsec/1e6)}M.timestampExtension={type:M.EXT_TIMESTAMP,encode:Xr,decode:en}});var gt=k(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.ExtensionCodec=void 0;var dt=ii(),vp=ni(),De=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(vp.timestampExtension)}register({type:t,encode:i,decode:r}){if(t>=0)this.encoders[t]=i,this.decoders[t]=r;else{let n=-1-t;this.builtInEncoders[n]=i,this.builtInDecoders[n]=r}}tryToEncode(t,i){for(let r=0;r<this.builtInEncoders.length;r++){let n=this.builtInEncoders[r];if(n!=null){let o=n(t,i);if(o!=null){let a=-1-r;return new dt.ExtData(a,o)}}}for(let r=0;r<this.encoders.length;r++){let n=this.encoders[r];if(n!=null){let o=n(t,i);if(o!=null){let a=r;return new dt.ExtData(a,o)}}}return t instanceof dt.ExtData?t:null}decode(t,i,r){let n=i<0?this.builtInDecoders[-1-i]:this.decoders[i];return n?n(t,i,r):new dt.ExtData(i,t)}};pt.ExtensionCodec=De;De.defaultCodec=new De});var ai=k(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});oi.ensureUint8Array=kp;function wp(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function kp(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):wp(e)?new Uint8Array(e):Uint8Array.from(e)}});var li=k(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.Encoder=P.DEFAULT_INITIAL_BUFFER_SIZE=P.DEFAULT_MAX_DEPTH=void 0;var tn=at(),Ip=gt(),rn=ut(),Ap=ai();P.DEFAULT_MAX_DEPTH=100;P.DEFAULT_INITIAL_BUFFER_SIZE=2048;var si=class e{constructor(t){this.entered=!1,this.extensionCodec=t?.extensionCodec??Ip.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.maxDepth=t?.maxDepth??P.DEFAULT_MAX_DEPTH,this.initialBufferSize=t?.initialBufferSize??P.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=t?.sortKeys??!1,this.forceFloat32=t?.forceFloat32??!1,this.ignoreUndefined=t?.ignoreUndefined??!1,this.forceIntegerToFloat=t?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(t){if(this.entered)return this.clone().encodeSharedRef(t);try{return this.entered=!0,this.reinitializeState(),this.doEncode(t,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(t){if(this.entered)return this.clone().encode(t);try{return this.entered=!0,this.reinitializeState(),this.doEncode(t,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(t,i){if(i>this.maxDepth)throw new Error(`Too deep objects in depth ${i}`);t==null?this.encodeNil():typeof t=="boolean"?this.encodeBoolean(t):typeof t=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(t):this.encodeNumber(t):typeof t=="string"?this.encodeString(t):this.useBigInt64&&typeof t=="bigint"?this.encodeBigInt64(t):this.encodeObject(t,i)}ensureBufferSizeToWrite(t){let i=this.pos+t;this.view.byteLength<i&&this.resizeBuffer(i*2)}resizeBuffer(t){let i=new ArrayBuffer(t),r=new Uint8Array(i),n=new DataView(i);r.set(this.bytes),this.view=n,this.bytes=r}encodeNil(){this.writeU8(192)}encodeBoolean(t){t===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(t){!this.forceIntegerToFloat&&Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):this.useBigInt64?this.encodeNumberAsFloat(t):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):this.useBigInt64?this.encodeNumberAsFloat(t):(this.writeU8(211),this.writeI64(t)):this.encodeNumberAsFloat(t)}encodeNumberAsFloat(t){this.forceFloat32?(this.writeU8(202),this.writeF32(t)):(this.writeU8(203),this.writeF64(t))}encodeBigInt64(t){t>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(t)):(this.writeU8(211),this.writeBigInt64(t))}writeStringHeader(t){if(t<32)this.writeU8(160+t);else if(t<256)this.writeU8(217),this.writeU8(t);else if(t<65536)this.writeU8(218),this.writeU16(t);else if(t<4294967296)this.writeU8(219),this.writeU32(t);else throw new Error(`Too long string: ${t} bytes in UTF-8`)}encodeString(t){let r=(0,tn.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,tn.utf8Encode)(t,this.bytes,this.pos),this.pos+=r}encodeObject(t,i){let r=this.extensionCodec.tryToEncode(t,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(t))this.encodeArray(t,i);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if(typeof t=="object")this.encodeMap(t,i);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(t)}`)}encodeBinary(t){let i=t.byteLength;if(i<256)this.writeU8(196),this.writeU8(i);else if(i<65536)this.writeU8(197),this.writeU16(i);else if(i<4294967296)this.writeU8(198),this.writeU32(i);else throw new Error(`Too large binary: ${i}`);let r=(0,Ap.ensureUint8Array)(t);this.writeU8a(r)}encodeArray(t,i){let r=t.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let n of t)this.doEncode(n,i+1)}countWithoutUndefined(t,i){let r=0;for(let n of i)t[n]!==void 0&&r++;return r}encodeMap(t,i){let r=Object.keys(t);this.sortKeys&&r.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(t,r):r.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else if(n<4294967296)this.writeU8(223),this.writeU32(n);else throw new Error(`Too large map object: ${n}`);for(let o of r){let a=t[o];this.ignoreUndefined&&a===void 0||(this.encodeString(o),this.doEncode(a,i+1))}}encodeExtension(t){if(typeof t.data=="function"){let r=t.data(this.pos+6),n=r.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(t.type),this.writeU8a(r);return}let i=t.data.length;if(i===1)this.writeU8(212);else if(i===2)this.writeU8(213);else if(i===4)this.writeU8(214);else if(i===8)this.writeU8(215);else if(i===16)this.writeU8(216);else if(i<256)this.writeU8(199),this.writeU8(i);else if(i<65536)this.writeU8(200),this.writeU16(i);else if(i<4294967296)this.writeU8(201),this.writeU32(i);else throw new Error(`Too large extension object: ${i}`);this.writeI8(t.type),this.writeU8a(t.data)}writeU8(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++}writeU8a(t){let i=t.length;this.ensureBufferSizeToWrite(i),this.bytes.set(t,this.pos),this.pos+=i}writeI8(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++}writeU16(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2}writeI16(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2}writeU32(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4}writeI32(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4}writeF32(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4}writeF64(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8}writeU64(t){this.ensureBufferSizeToWrite(8),(0,rn.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,rn.setInt64)(this.view,this.pos,t),this.pos+=8}writeBigUint64(t){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,t),this.pos+=8}writeBigInt64(t){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,t),this.pos+=8}};P.Encoder=si});var nn=k(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.encode=xp;var Ep=li();function xp(e,t){return new Ep.Encoder(t).encodeSharedRef(e)}});var on=k(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.prettyByte=Sp;function Sp(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var an=k(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.CachedKeyDecoder=void 0;var Cp=at(),Mp=16,Tp=16,di=class{constructor(t=Mp,i=Tp){this.hit=0,this.miss=0,this.maxKeyLength=t,this.maxLengthPerKey=i,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(t){return t>0&&t<=this.maxKeyLength}find(t,i,r){let n=this.caches[r-1];e:for(let o of n){let a=o.bytes;for(let s=0;s<r;s++)if(a[s]!==t[i+s])continue e;return o.str}return null}store(t,i){let r=this.caches[t.length-1],n={bytes:t,str:i};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)}decode(t,i,r){let n=this.find(t,i,r);if(n!=null)return this.hit++,n;this.miss++;let o=(0,Cp.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};ht.CachedKeyDecoder=di});var mt=k(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.Decoder=void 0;var pi=on(),Op=gt(),J=ut(),$p=at(),sn=ai(),jp=an(),B=ct(),gi="array",Ne="map_key",cn="map_value",Pp=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new B.DecodeError("The type of key must be string or number but "+typeof e)},hi=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(t){let i=this.getUninitializedStateFromPool();i.type=gi,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=Ne,i.readCount=0,i.size=t,i.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let t={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(t)}return this.stack[this.stackHeadPosition]}release(t){if(this.stack[this.stackHeadPosition]!==t)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(t.type===gi){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===Ne||t.type===cn){let r=t;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Ue=-1,mi=new DataView(new ArrayBuffer(0)),Dp=new Uint8Array(mi.buffer);try{mi.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var ln=new RangeError("Insufficient data"),Up=new jp.CachedKeyDecoder,fi=class e{constructor(t){this.totalPos=0,this.pos=0,this.view=mi,this.bytes=Dp,this.headByte=Ue,this.stack=new hi,this.entered=!1,this.extensionCodec=t?.extensionCodec??Op.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.rawStrings=t?.rawStrings??!1,this.maxStrLength=t?.maxStrLength??J.UINT32_MAX,this.maxBinLength=t?.maxBinLength??J.UINT32_MAX,this.maxArrayLength=t?.maxArrayLength??J.UINT32_MAX,this.maxMapLength=t?.maxMapLength??J.UINT32_MAX,this.maxExtLength=t?.maxExtLength??J.UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:Up,this.mapKeyConverter=t?.mapKeyConverter??Pp}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ue,this.stack.reset()}setBuffer(t){let i=(0,sn.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===Ue&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,sn.ensureUint8Array)(t),n=new Uint8Array(i.length+r.length);n.set(i),n.set(r,i.length),this.setBuffer(n)}}hasRemaining(t){return this.view.byteLength-this.pos>=t}createExtraByteError(t){let{view:i,pos:r}=this;return new RangeError(`Extra ${i.byteLength-r} of ${i.byteLength} byte(s) found at buffer[${t}]`)}decode(t){if(this.entered)return this.clone().decode(t);try{this.entered=!0,this.reinitializeState(),this.setBuffer(t);let i=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return i}finally{this.entered=!1}}*decodeMulti(t){if(this.entered){yield*this.clone().decodeMulti(t);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(t);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(t){if(this.entered)return this.clone().decodeAsync(t);try{this.entered=!0;let i=!1,r;for await(let s of t){if(i)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(s);try{r=this.doDecodeSync(),i=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(i){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return r}let{headByte:n,pos:o,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${(0,pi.prettyByte)(n)} at ${a} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(t){return this.decodeMultiAsync(t,!0)}decodeStream(t){return this.decodeMultiAsync(t,!1)}async*decodeMultiAsync(t,i){if(this.entered){yield*this.clone().decodeMultiAsync(t,i);return}try{this.entered=!0;let r=i,n=-1;for await(let o of t){if(i&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),r&&(n=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let t=this.readHeadByte(),i;if(t>=224)i=t-256;else if(t<192)if(t<128)i=t;else if(t<144){let n=t-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t<160){let n=t-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else{let n=t-160;i=this.decodeString(n,0)}else if(t===192)i=null;else if(t===194)i=!1;else if(t===195)i=!0;else if(t===202)i=this.readF32();else if(t===203)i=this.readF64();else if(t===204)i=this.readU8();else if(t===205)i=this.readU16();else if(t===206)i=this.readU32();else if(t===207)this.useBigInt64?i=this.readU64AsBigInt():i=this.readU64();else if(t===208)i=this.readI8();else if(t===209)i=this.readI16();else if(t===210)i=this.readI32();else if(t===211)this.useBigInt64?i=this.readI64AsBigInt():i=this.readI64();else if(t===217){let n=this.lookU8();i=this.decodeString(n,1)}else if(t===218){let n=this.lookU16();i=this.decodeString(n,2)}else if(t===219){let n=this.lookU32();i=this.decodeString(n,4)}else if(t===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(t===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(t===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t===196){let n=this.lookU8();i=this.decodeBinary(n,1)}else if(t===197){let n=this.lookU16();i=this.decodeBinary(n,2)}else if(t===198){let n=this.lookU32();i=this.decodeBinary(n,4)}else if(t===212)i=this.decodeExtension(1,0);else if(t===213)i=this.decodeExtension(2,0);else if(t===214)i=this.decodeExtension(4,0);else if(t===215)i=this.decodeExtension(8,0);else if(t===216)i=this.decodeExtension(16,0);else if(t===199){let n=this.lookU8();i=this.decodeExtension(n,1)}else if(t===200){let n=this.lookU16();i=this.decodeExtension(n,2)}else if(t===201){let n=this.lookU32();i=this.decodeExtension(n,4)}else throw new B.DecodeError(`Unrecognized type byte: ${(0,pi.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===gi)if(n.array[n.position]=i,n.position++,n.position===n.size)i=n.array,r.release(n);else continue e;else if(n.type===Ne){if(i==="__proto__")throw new B.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=cn;continue e}else if(n.map[n.key]=i,n.readCount++,n.readCount===n.size)i=n.map,r.release(n);else{n.key=null,n.type=Ne;continue e}}return i}}readHeadByte(){return this.headByte===Ue&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ue}readArraySize(){let t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new B.DecodeError(`Unrecognized array type byte: ${(0,pi.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new B.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new B.DecodeError(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(t)}decodeString(t,i){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(t,i):this.decodeBinary(t,i)}decodeUtf8String(t,i){if(t>this.maxStrLength)throw new B.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw ln;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,$p.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ne:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new B.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw ln;let r=this.pos+i,n=this.bytes.subarray(r,r+t);return this.pos+=i+t,n}decodeExtension(t,i){if(t>this.maxExtLength)throw new B.DecodeError(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+i),n=this.decodeBinary(t,i+1);return this.extensionCodec.decode(n,r,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let t=this.view.getUint8(this.pos);return this.pos++,t}readI8(){let t=this.view.getInt8(this.pos);return this.pos++,t}readU16(){let t=this.view.getUint16(this.pos);return this.pos+=2,t}readI16(){let t=this.view.getInt16(this.pos);return this.pos+=2,t}readU32(){let t=this.view.getUint32(this.pos);return this.pos+=4,t}readI32(){let t=this.view.getInt32(this.pos);return this.pos+=4,t}readU64(){let t=(0,J.getUint64)(this.view,this.pos);return this.pos+=8,t}readI64(){let t=(0,J.getInt64)(this.view,this.pos);return this.pos+=8,t}readU64AsBigInt(){let t=this.view.getBigUint64(this.pos);return this.pos+=8,t}readI64AsBigInt(){let t=this.view.getBigInt64(this.pos);return this.pos+=8,t}readF32(){let t=this.view.getFloat32(this.pos);return this.pos+=4,t}readF64(){let t=this.view.getFloat64(this.pos);return this.pos+=8,t}};ft.Decoder=fi});var dn=k(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.decode=Np;yt.decodeMulti=qp;var un=mt();function Np(e,t){return new un.Decoder(t).decode(e)}function qp(e,t){return new un.Decoder(t).decodeMulti(e)}});var hn=k(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.isAsyncIterable=pn;qe.asyncIterableFromStream=gn;qe.ensureAsyncIterable=Bp;function pn(e){return e[Symbol.asyncIterator]!=null}async function*gn(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function Bp(e){return pn(e)?e:gn(e)}});var fn=k(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.decodeAsync=Fp;Be.decodeArrayStream=Lp;Be.decodeMultiStream=zp;var yi=mt(),bi=hn();async function Fp(e,t){let i=(0,bi.ensureAsyncIterable)(e);return new yi.Decoder(t).decodeAsync(i)}function Lp(e,t){let i=(0,bi.ensureAsyncIterable)(e);return new yi.Decoder(t).decodeArrayStream(i)}function zp(e,t){let i=(0,bi.ensureAsyncIterable)(e);return new yi.Decoder(t).decodeStream(i)}});var yn=k(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.decodeTimestampExtension=_.encodeTimestampExtension=_.decodeTimestampToTimeSpec=_.encodeTimeSpecToTimestamp=_.encodeDateToTimeSpec=_.EXT_TIMESTAMP=_.ExtData=_.ExtensionCodec=_.Encoder=_.DecodeError=_.Decoder=_.decodeMultiStream=_.decodeArrayStream=_.decodeAsync=_.decodeMulti=_.decode=_.encode=void 0;var Rp=nn();Object.defineProperty(_,"encode",{enumerable:!0,get:function(){return Rp.encode}});var mn=dn();Object.defineProperty(_,"decode",{enumerable:!0,get:function(){return mn.decode}});Object.defineProperty(_,"decodeMulti",{enumerable:!0,get:function(){return mn.decodeMulti}});var _i=fn();Object.defineProperty(_,"decodeAsync",{enumerable:!0,get:function(){return _i.decodeAsync}});Object.defineProperty(_,"decodeArrayStream",{enumerable:!0,get:function(){return _i.decodeArrayStream}});Object.defineProperty(_,"decodeMultiStream",{enumerable:!0,get:function(){return _i.decodeMultiStream}});var Vp=mt();Object.defineProperty(_,"Decoder",{enumerable:!0,get:function(){return Vp.Decoder}});var Hp=ct();Object.defineProperty(_,"DecodeError",{enumerable:!0,get:function(){return Hp.DecodeError}});var Gp=li();Object.defineProperty(_,"Encoder",{enumerable:!0,get:function(){return Gp.Encoder}});var Qp=gt();Object.defineProperty(_,"ExtensionCodec",{enumerable:!0,get:function(){return Qp.ExtensionCodec}});var Kp=ii();Object.defineProperty(_,"ExtData",{enumerable:!0,get:function(){return Kp.ExtData}});var be=ni();Object.defineProperty(_,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return be.EXT_TIMESTAMP}});Object.defineProperty(_,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return be.encodeDateToTimeSpec}});Object.defineProperty(_,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return be.encodeTimeSpecToTimestamp}});Object.defineProperty(_,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return be.decodeTimestampToTimeSpec}});Object.defineProperty(_,"encodeTimestampExtension",{enumerable:!0,get:function(){return be.encodeTimestampExtension}});Object.defineProperty(_,"decodeTimestampExtension",{enumerable:!0,get:function(){return be.decodeTimestampExtension}})});var $n=k(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});function S(e){return{enumerable:!0,value:e}}function bn(e){return{enumerable:!0,writable:!0,value:e}}var ee={},Wp=()=>!0,_n=()=>({}),wn=e=>e,Yp=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),Zp=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),Q=(e,t)=>Object.freeze(Object.create(e,t));function vn(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function kn(e){return Q(this,{fn:S(e)})}var In={},An=kn.bind(In),Xp=e=>An((t,i)=>!!~e(t,i)&&t),En={},Jp=kn.bind(En);function bt(e,t){return t.filter(i=>e.isPrototypeOf(i))}function xn(e,t,...i){let r=vn(bt(En,i).map(o=>o.fn),Wp,Yp),n=vn(bt(In,i).map(o=>o.fn),wn,Zp);return Q(this,{from:S(e),to:S(t),guards:S(r),reducers:S(n)})}var Sn={},Cn={},eg=xn.bind(Sn),tg=xn.bind(Cn,null);function ig(e,t,i){return wi(t,e,i,this.immediates)||e}function Mn(e){let t=new Map;for(let i of e)t.has(i.from)||t.set(i.from,[]),t.get(i.from).push(i);return t}var rg={enter:wn};function ng(...e){let t=bt(Sn,e),i=bt(Cn,e),r={final:S(e.length===0),transitions:S(Mn(t))};return i.length&&(r.immediates=S(i),r.enter=S(ig)),Q(rg,r)}var og={enter(e,t,i){let r=this.fn.call(t,t.context,i);return vi.isPrototypeOf(r)?Q(Tn,{machine:S(r),transitions:S(this.transitions)}).enter(e,t,i):(r.then(n=>t.send({type:"done",data:n})).catch(n=>t.send({type:"error",error:n})),e)}},Tn={enter(e,t,i){if(t.child=On(this.machine,r=>{t.onChange(r),t.child==r&&r.machine.state.value.final&&(delete t.child,t.send({type:"done",data:r.context}))},t.context,i),t.child.machine.state.value.final){let r=t.child.context;return delete t.child,wi(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function ag(e,...t){let i=S(Mn(t));return vi.isPrototypeOf(e)?Q(Tn,{machine:S(e),transitions:i}):Q(og,{fn:S(e),transitions:i})}var vi={get state(){return{name:this.current,value:this.states[this.current]}}};function sg(e,t,i=_n){return typeof e!="string"&&(i=t||_n,t=e,e=Object.keys(t)[0]),ee._create&&ee._create(e,t),Q(vi,{context:S(i),current:S(e),states:S(t)})}function wi(e,t,i,r){let{context:n}=e;for(let{to:o,guards:a,reducers:s}of r)if(a(n,i)){e.context=s.call(e,n,i);let l=t.original||t,u=Q(l,{current:S(o),original:{value:l}});return ee._onEnter&&ee._onEnter(t,o,e.context,n,i),u.state.value.enter(u,e,i)}}function lg(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?wi(e,r,t,n.transitions.get(i))||r:(ee._send&&ee._send(i,o),r)}var cg={send(e){this.machine=lg(this,e),this.onChange(this)}};function On(e,t,i,r){let n=Object.create(cg,{machine:bn(e),context:bn(e.context(i,r)),onChange:S(t)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}T.action=Xp;T.createMachine=sg;T.d=ee;T.guard=Jp;T.immediate=tg;T.interpret=On;T.invoke=ag;T.reduce=An;T.state=ng;T.transition=eg});var Nn=k(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.createRealtimeClient=Ag;var vt=yn(),m=$n(),jn=Xt(),ki=Y(),Pn=it(),Ei=Z(),ug=()=>({enqueuedMessage:void 0});function dg(e){return e.token!==void 0}function pg(e){return!dg(e)}function _t(e,t){return Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function F(e){return e.websocket&&e.websocket.readyState===WebSocket.OPEN&&e.websocket.close(),Object.assign(Object.assign({},e),{websocket:void 0})}function gg(e,t){return e.websocket&&e.websocket.readyState===WebSocket.OPEN?(t.message instanceof Uint8Array?e.websocket.send(t.message):e.websocket.send((0,vt.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function Ii(e){return Object.assign(Object.assign({},e),{token:void 0})}function hg(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function fg(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var mg=(0,m.createMachine)("idle",{idle:(0,m.state)((0,m.transition)("send","connecting",(0,m.reduce)(_t)),(0,m.transition)("expireToken","idle",(0,m.reduce)(Ii)),(0,m.transition)("close","idle",(0,m.reduce)(F))),connecting:(0,m.state)((0,m.transition)("connecting","connecting"),(0,m.transition)("connected","active",(0,m.reduce)(fg)),(0,m.transition)("connectionClosed","idle",(0,m.reduce)(F)),(0,m.transition)("send","connecting",(0,m.reduce)(_t)),(0,m.transition)("close","idle",(0,m.reduce)(F)),(0,m.immediate)("authRequired",(0,m.guard)(pg))),authRequired:(0,m.state)((0,m.transition)("initiateAuth","authInProgress"),(0,m.transition)("send","authRequired",(0,m.reduce)(_t)),(0,m.transition)("close","idle",(0,m.reduce)(F))),authInProgress:(0,m.state)((0,m.transition)("authenticated","connecting",(0,m.reduce)(hg)),(0,m.transition)("unauthorized","idle",(0,m.reduce)(Ii),(0,m.reduce)(F)),(0,m.transition)("send","authInProgress",(0,m.reduce)(_t)),(0,m.transition)("close","idle",(0,m.reduce)(F))),active:(0,m.state)((0,m.transition)("send","active",(0,m.reduce)(gg)),(0,m.transition)("unauthorized","idle",(0,m.reduce)(Ii)),(0,m.transition)("connectionClosed","idle",(0,m.reduce)(F)),(0,m.transition)("close","idle",(0,m.reduce)(F))),failed:(0,m.state)((0,m.transition)("send","failed"),(0,m.transition)("close","idle",(0,m.reduce)(F)))},ug);function yg(e,{token:t,maxBuffering:i}){if(i!==void 0&&(i<1||i>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let r=new URLSearchParams({fal_jwt_token:t});return i!==void 0&&r.set("max_buffering",i.toFixed(0)),`wss://fal.run/${(0,Ei.ensureEndpointIdFormat)(e)}/realtime?${r.toString()}`}var bg=128;function _g(e){return e.status==="error"&&e.error==="Unauthorized"}var vg={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Ai=new Map,Dn=new Map;function wg(e,t,i){if(!Ai.has(e)){let r=(0,m.interpret)(mg,i);Ai.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,Ei.throttle)(r.send,t,!0):r.send}))}return Ai.get(e)}var Fe=()=>{},kg={send:Fe,close:Fe};function Ig(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!Un(e)}function Un(e){return e.type==="x-fal-error"}function Ag({config:e}){return{connect(t,i){let{clientOnly:r=(0,Ei.isReact)()&&!(0,Pn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:a=bg}=i;if(r&&!(0,Pn.isBrowser)())return kg;let s;Dn.set(n,{onError:i.onError,onResult:i.onResult});let l=()=>Dn.get(n),u=wg(n,a,({context:h,machine:p,send:f})=>{let{enqueuedMessage:b,token:v}=h;if(p.current==="active"&&b&&f({type:"send",message:b}),p.current==="authRequired"&&v===void 0&&s!==p.current&&(f({type:"initiateAuth"}),(0,jn.getTemporaryAuthToken)(t,e).then(g=>{f({type:"authenticated",token:g});let y=Math.round(jn.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{f({type:"expireToken"})},y)}).catch(g=>{f({type:"unauthorized",error:g})})),p.current==="connecting"&&s!==p.current&&v!==void 0){let g=new WebSocket(yg(t,{token:v,maxBuffering:o}));g.onopen=()=>{f({type:"connected",websocket:g})},g.onclose=y=>{if(y.code!==vg.NORMAL_CLOSURE){let{onError:I=Fe}=l();I(new ki.ApiError({message:`Error closing the connection: ${y.reason}`,status:y.code}))}f({type:"connectionClosed",code:y.code})},g.onerror=y=>{let{onError:I=Fe}=l();I(new ki.ApiError({message:"Unknown error",status:500}))},g.onmessage=y=>{let{onResult:I}=l();if(y.data instanceof ArrayBuffer){let C=(0,vt.decode)(new Uint8Array(y.data));I(C);return}if(y.data instanceof Uint8Array){let C=(0,vt.decode)(y.data);I(C);return}if(y.data instanceof Blob){y.data.arrayBuffer().then(C=>{let Oi=(0,vt.decode)(new Uint8Array(C));I(Oi)});return}let w=JSON.parse(y.data);if(_g(w)){f({type:"unauthorized",error:new Error("Unauthorized")});return}if(Ig(w)){I(w);return}if(Un(w)){if(w.error==="TIMEOUT")return;let{onError:C=Fe}=l();C(new ki.ApiError({message:`${w.error}: ${w.reason}`,status:400,body:w}));return}}}s=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var zn=k(Le=>{"use strict";var te=Le&&Le.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(Le,"__esModule",{value:!0});Le.createStorageClient=Mg;var qn=rt(),Bn=me(),Eg=Z();function Fn(e){var t;let[i,r]=e.split("/");return(t=r.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function xg(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${Fn(i)}`;return yield(0,Bn.dispatchRequest)({method:"POST",targetUrl:`${(0,qn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function Sg(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${Fn(i)}`;return yield(0,Bn.dispatchRequest)({method:"POST",targetUrl:`${(0,qn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function Ln(e,t,i){return te(this,arguments,void 0,function*(r,n,o,a=3){if(a===0)throw new Error("Part upload failed, retries exhausted");let{fetch:s,responseHandler:l}=o;try{let u=yield s(r,{method:"PUT",body:n});return yield l(u)}catch{return yield Ln(r,n,o,a-1)}})}function Cg(e,t){return te(this,void 0,void 0,function*(){let{fetch:i,responseHandler:r}=t,n=e.type||"application/octet-stream",{upload_url:o,file_url:a}=yield Sg(e,t,n),s=10*1024*1024,l=Math.ceil(e.size/s),u=new URL(o),c=[];for(let p=0;p<l;p++){let f=p*s,b=Math.min(f+s,e.size),v=e.slice(f,b),g=p+1,y=`${u.origin}${u.pathname}/${g}${u.search}`;c.push(yield Ln(y,v,t))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield i(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:c.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield r(h),a})}function Mg({config:e}){let t={upload:i=>te(this,void 0,void 0,function*(){if(i.size>94371840)return yield Cg(i,e);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:o}=e,{upload_url:a,file_url:s}=yield xg(i,e,r),l=yield n(a,{method:"PUT",body:i,headers:{"Content-Type":i.type||"application/octet-stream"}});return yield o(l),s}),transformInput:i=>te(this,void 0,void 0,function*(){if(Array.isArray(i))return Promise.all(i.map(r=>t.transformInput(r)));if(i instanceof Blob)return yield t.upload(i);if((0,Eg.isPlainObject)(i)){let n=Object.entries(i).map(a=>te(this,[a],void 0,function*([s,l]){return[s,yield t.transformInput(l)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return i})};return t}});var Si=k(ze=>{"use strict";var Rn=ze&&ze.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(d){a(d)}}function l(c){try{u(r.throw(c))}catch(d){a(d)}}function u(c){c.done?o(c.value):n(c.value).then(s,l)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(ze,"__esModule",{value:!0});ze.createFalClient=Ug;var Tg=rt(),Og=Vr(),$g=Nn(),Vn=me(),jg=Y(),Pg=zn(),Dg=ei();function Ug(e={}){let t=(0,Tg.createConfig)(e),i=(0,Pg.createStorageClient)({config:t}),r=(0,Og.createQueueClient)({config:t,storage:i}),n=(0,Dg.createStreamingClient)({config:t,storage:i}),o=(0,$g.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return Rn(this,arguments,void 0,function*(s,l={}){let u=l.input?yield i.transformInput(l.input):void 0;return(0,Vn.dispatchRequest)({method:l.method,targetUrl:(0,Vn.buildUrl)(s,l),input:u,config:Object.assign(Object.assign({},t),{responseHandler:jg.resultResponseHandler}),options:{signal:l.abortSignal}})})},subscribe:(a,s)=>Rn(this,void 0,void 0,function*(){let{request_id:l}=yield r.submit(a,s);return s.onEnqueue&&s.onEnqueue(l),yield r.subscribeToStatus(a,Object.assign({requestId:l},s)),r.result(a,{requestId:l})})}}});var Gn=k(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.isQueueStatus=Hn;wt.isCompletedQueueStatus=Ng;function Hn(e){return e&&e.status&&e.response_url}function Ng(e){return Hn(e)&&e.status==="COMPLETED"}});var Ci=k(x=>{"use strict";var qg=x&&x.__createBinding||(Object.create?function(e,t,i,r){r===void 0&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){r===void 0&&(r=i),e[r]=t[i]}),Bg=x&&x.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&qg(t,e,i)};Object.defineProperty(x,"__esModule",{value:!0});x.fal=x.parseEndpointId=x.ValidationError=x.ApiError=x.withProxy=x.withMiddleware=x.createFalClient=void 0;var Qn=Si(),Fg=Si();Object.defineProperty(x,"createFalClient",{enumerable:!0,get:function(){return Fg.createFalClient}});var Kn=Wt();Object.defineProperty(x,"withMiddleware",{enumerable:!0,get:function(){return Kn.withMiddleware}});Object.defineProperty(x,"withProxy",{enumerable:!0,get:function(){return Kn.withProxy}});var Wn=Y();Object.defineProperty(x,"ApiError",{enumerable:!0,get:function(){return Wn.ApiError}});Object.defineProperty(x,"ValidationError",{enumerable:!0,get:function(){return Wn.ValidationError}});Bg(Gn(),x);var Lg=Z();Object.defineProperty(x,"parseEndpointId",{enumerable:!0,get:function(){return Lg.parseEndpointId}});x.fal=function(){let t=(0,Qn.createFalClient)();return{config(i){t=(0,Qn.createFalClient)(i)},get queue(){return t.queue},get realtime(){return t.realtime},get storage(){return t.storage},get streaming(){return t.streaming},run(i,r){return t.run(i,r)},subscribe(i,r){return t.subscribe(i,r)},stream(i,r){return t.stream(i,r)}}}()});var ao=`
5
+ `;else if(w==="event")a=b;else if(w==="id"&&!b.includes("\0"))o=b;else if(w==="retry"){let C=parseInt(b,10);Number.isNaN(C)||e({type:"reconnect-interval",value:C})}}}var Lr=[239,187,191];function tp(e){return Lr.every((t,i)=>e.charCodeAt(i)===t)}Zt.createParser=ep});var Xt=I(V=>{"use strict";var ip=V&&V.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(V,"__esModule",{value:!0});V.TOKEN_EXPIRATION_SECONDS=void 0;V.getTemporaryAuthToken=ap;var rp=rt(),np=me(),op=Z();V.TOKEN_EXPIRATION_SECONDS=120;function ap(e,t){return ip(this,void 0,void 0,function*(){let i=(0,op.parseEndpointId)(e),r=yield(0,np.dispatchRequest)({method:"POST",targetUrl:`${(0,rp.getRestApiUrl)()}/tokens/`,config:t,input:{allowed_apps:[i.alias],token_expiration:V.TOKEN_EXPIRATION_SECONDS}});return typeof r!="string"&&r.detail?r.detail:r})}});var ei=I($=>{"use strict";var je=$&&$.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})},Pe=$&&$.__await||function(e){return this instanceof Pe?(this.v=e,this):new Pe(e)},sp=$&&$.__asyncGenerator||function(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(e,t||[]),n,o=[];return n={},s("next"),s("throw"),s("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(g){return function(m){return Promise.resolve(m).then(g,d)}}function s(g,m){r[g]&&(n[g]=function(_){return new Promise(function(w,p){o.push([g,_,w,p])>1||c(g,_)})},m&&(n[g]=m(n[g])))}function c(g,m){try{u(r[g](m))}catch(_){f(o[0][3],_)}}function u(g){g.value instanceof Pe?Promise.resolve(g.value.v).then(l,d):f(o[0][2],g)}function l(g){c("next",g)}function d(g){c("throw",g)}function f(g,m){g(m),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty($,"__esModule",{value:!0});$.FalStream=void 0;$.createStreamingClient=dp;var lp=Fr(),cp=Xt(),zr=me(),ye=Y(),Jt="text/event-stream",up=15*1e3,nt=class{constructor(t,i,r){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this.abortController=new AbortController,this.start=()=>je(this,void 0,void 0,function*(){var o,a;let{endpointId:s,options:c}=this,{input:u,method:l="post",connectionMode:d="server"}=c;try{if(d==="client"){let f=yield(0,cp.getTemporaryAuthToken)(s,this.config),{fetch:g}=this.config,m=new URL(this.url);m.searchParams.set("fal_jwt_token",f);let _=yield g(m.toString(),{method:l.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:Jt,"content-type":"application/json"},body:u&&l!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return yield this.handleResponse(_)}return yield(0,zr.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:Jt},responseHandler:this.handleResponse,signal:this.abortController.signal}})}catch(f){this.handleError(f)}}),this.handleResponse=o=>je(this,void 0,void 0,function*(){var a,s;if(!o.ok){try{yield(0,ye.defaultResponseHandler)(o)}catch(_){this.emit("error",_)}return}let c=o.body;if(!c){this.emit("error",new ye.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((a=o.headers.get("content-type"))!==null&&a!==void 0?a:"").startsWith(Jt)){let _=c.getReader(),w=()=>{_.read().then(({done:p,value:h})=>{if(p){this.emit("done",this.currentData);return}this.currentData=h,this.emit("data",h),w()})};w();return}let l=new TextDecoder("utf-8"),d=o.body.getReader(),f=(0,lp.createParser)(_=>{if(_.type==="event"){let w=_.data;try{let p=JSON.parse(w);this.buffer.push(p),this.currentData=p,this.emit("data",p),this.emit("message",p)}catch(p){this.emit("error",p)}}}),g=(s=this.options.timeout)!==null&&s!==void 0?s:up,m=()=>je(this,void 0,void 0,function*(){let{value:_,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),f.feed(l.decode(_)),Date.now()-this.lastEventTimestamp>g&&this.emit("error",new ye.ApiError({message:`Event stream timed out after ${(g/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):m().catch(this.handleError)});m().catch(this.handleError)}),this.handleError=o=>{var a;if(o.name==="AbortError"||this.signal.aborted)return;let s=o instanceof ye.ApiError?o:new ye.ApiError({message:(a=o.message)!==null&&a!==void 0?a:"An unknown error occurred",status:500});this.emit("error",s)},this.on=(o,a)=>{var s;this.listeners.has(o)||this.listeners.set(o,[]),(s=this.listeners.get(o))===null||s===void 0||s.push(a)},this.emit=(o,a)=>{let s=this.listeners.get(o)||[];for(let c of s)c(a)},this.done=()=>je(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=t,this.config=i,this.url=(n=r.url)!==null&&n!==void 0?n:(0,zr.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new ye.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var s;o((s=this.currentData)!==null&&s!==void 0?s:{})}),this.on("done",s=>{this.streamClosed=!0,o(s)}),this.on("error",s=>{this.streamClosed=!0,a(s)})}),r.signal&&r.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return sp(this,arguments,function*(){let i=!0,r=()=>i=!1;for(this.on("error",r),this.on("done",r);i||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield Pe(n)),yield Pe(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}};$.FalStream=nt;function dp({config:e,storage:t}){return{stream(i,r){return je(this,void 0,void 0,function*(){let n=r.input?yield t.transformInput(r.input):void 0;return new nt(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var Vr=I(H=>{"use strict";var X=H&&H.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})},pp=H&&H.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]]);return i};Object.defineProperty(H,"__esModule",{value:!0});H.createQueueClient=void 0;var N=me(),gp=Y(),hp=ei(),ot=Z(),Rr=500,fp=({config:e,storage:t})=>{let i={submit(r,n){return X(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a}=n,s=pp(n,["webhookUrl","priority"]),c=n.input?yield t.transformInput(n.input):void 0;return(0,N.dispatchRequest)({method:n.method,targetUrl:(0,N.buildUrl)(r,Object.assign(Object.assign({},s),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:{"x-fal-queue-priority":a??"normal"},input:c,config:e,options:{signal:n.abortSignal}})})},status(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,logs:s=!1,abortSignal:c}){let u=(0,ot.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:s?"1":"0"},path:`/requests/${a}/status`}),config:e,options:{signal:c}})})},streamStatus(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,logs:s=!1,connectionMode:c}){let u=(0,ot.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"",d={logs:s?"1":"0"},f=(0,N.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:d});return new hp.FalStream(o,e,{url:f,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(r,n){return X(this,void 0,void 0,function*(){let o=n.requestId,a=n.timeout,s,c=()=>{};if(n.mode==="streaming"){let u=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];a&&(s=setTimeout(()=>{throw u.abort(),i.cancel(r,{requestId:o}).catch(c),new Error(`Client timed out waiting for the request to complete after ${a}ms`)},a)),u.on("data",f=>{n.onQueueUpdate&&("logs"in f&&Array.isArray(f.logs)&&f.logs.length>0&&l.push(...f.logs),n.onQueueUpdate("logs"in f?Object.assign(Object.assign({},f),{logs:l}):f))});let d=yield u.done();return s&&clearTimeout(s),d}return new Promise((u,l)=>{var d;let f,g="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:Rr,m=()=>{s&&clearTimeout(s),f&&clearTimeout(f)};a&&(s=setTimeout(()=>{m(),i.cancel(r,{requestId:o}).catch(c),l(new Error(`Client timed out waiting for the request to complete after ${a}ms`))},a));let _=()=>X(this,void 0,void 0,function*(){var w;try{let p=yield i.status(r,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(p),p.status==="COMPLETED"){m(),u(p);return}f=setTimeout(_,g)}catch(p){m(),l(p)}});_().catch(l)})})},result(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,ot.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:gp.resultResponseHandler}),options:{signal:s}})})},cancel(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,ot.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,N.dispatchRequest)({method:"put",targetUrl:(0,N.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:s}})})}};return i};H.createQueueClient=fp});var at=I(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.utf8Count=mp;q.utf8EncodeJs=Hr;q.utf8EncodeTE=Gr;q.utf8Encode=_p;q.utf8DecodeJs=Qr;q.utf8DecodeTD=Kr;q.utf8Decode=Ip;function mp(e){let t=e.length,i=0,r=0;for(;r<t;){let n=e.charCodeAt(r++);if(n&4294967168)if(!(n&4294965248))i+=2;else{if(n>=55296&&n<=56319&&r<t){let o=e.charCodeAt(r);(o&64512)===56320&&(++r,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?i+=4:i+=3}else{i++;continue}}return i}function Hr(e,t,i){let r=e.length,n=i,o=0;for(;o<r;){let a=e.charCodeAt(o++);if(a&4294967168)if(!(a&4294965248))t[n++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&o<r){let s=e.charCodeAt(o);(s&64512)===56320&&(++o,a=((a&1023)<<10)+(s&1023)+65536)}a&4294901760?(t[n++]=a>>18&7|240,t[n++]=a>>12&63|128,t[n++]=a>>6&63|128):(t[n++]=a>>12&15|224,t[n++]=a>>6&63|128)}else{t[n++]=a;continue}t[n++]=a&63|128}}var yp=new TextEncoder,bp=50;function Gr(e,t,i){yp.encodeInto(e,t.subarray(i))}function _p(e,t,i){e.length>bp?Gr(e,t,i):Hr(e,t,i)}var vp=4096;function Qr(e,t,i){let r=t,n=r+i,o=[],a="";for(;r<n;){let s=e[r++];if(!(s&128))o.push(s);else if((s&224)===192){let c=e[r++]&63;o.push((s&31)<<6|c)}else if((s&240)===224){let c=e[r++]&63,u=e[r++]&63;o.push((s&31)<<12|c<<6|u)}else if((s&248)===240){let c=e[r++]&63,u=e[r++]&63,l=e[r++]&63,d=(s&7)<<18|c<<12|u<<6|l;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(s);o.length>=vp&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var wp=new TextDecoder,kp=200;function Kr(e,t,i){let r=e.subarray(t,t+i);return wp.decode(r)}function Ip(e,t,i){return i>kp?Kr(e,t,i):Qr(e,t,i)}});var ii=I(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.ExtData=void 0;var ti=class{constructor(t,i){this.type=t,this.data=i}};st.ExtData=ti});var ct=I(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.DecodeError=void 0;var ri=class e extends Error{constructor(t){super(t);let i=Object.create(e.prototype);Object.setPrototypeOf(this,i),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};lt.DecodeError=ri});var ut=I(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.UINT32_MAX=void 0;G.setUint64=Ap;G.setInt64=xp;G.getInt64=Ep;G.getUint64=Sp;G.UINT32_MAX=4294967295;function Ap(e,t,i){let r=i/4294967296,n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function xp(e,t,i){let r=Math.floor(i/4294967296),n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function Ep(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function Sp(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var ni=I(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.timestampExtension=T.EXT_TIMESTAMP=void 0;T.encodeTimeSpecToTimestamp=Yr;T.encodeDateToTimeSpec=Zr;T.encodeTimestampExtension=Xr;T.decodeTimestampToTimeSpec=Jr;T.decodeTimestampExtension=en;var Cp=ct(),Wr=ut();T.EXT_TIMESTAMP=-1;var Tp=4294967296-1,Mp=17179869184-1;function Yr({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=Mp)if(t===0&&e<=Tp){let i=new Uint8Array(4);return new DataView(i.buffer).setUint32(0,e),i}else{let i=e/4294967296,r=e&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,t<<2|i&3),o.setUint32(4,r),n}else{let i=new Uint8Array(12),r=new DataView(i.buffer);return r.setUint32(0,t),(0,Wr.setInt64)(r,4,e),i}}function Zr(e){let t=e.getTime(),i=Math.floor(t/1e3),r=(t-i*1e3)*1e6,n=Math.floor(r/1e9);return{sec:i+n,nsec:r-n*1e9}}function Xr(e){if(e instanceof Date){let t=Zr(e);return Yr(t)}else return null}function Jr(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let i=t.getUint32(0),r=t.getUint32(4),n=(i&3)*4294967296+r,o=i>>>2;return{sec:n,nsec:o}}case 12:{let i=(0,Wr.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new Cp.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function en(e){let t=Jr(e);return new Date(t.sec*1e3+t.nsec/1e6)}T.timestampExtension={type:T.EXT_TIMESTAMP,encode:Xr,decode:en}});var gt=I(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.ExtensionCodec=void 0;var dt=ii(),$p=ni(),De=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register($p.timestampExtension)}register({type:t,encode:i,decode:r}){if(t>=0)this.encoders[t]=i,this.decoders[t]=r;else{let n=-1-t;this.builtInEncoders[n]=i,this.builtInDecoders[n]=r}}tryToEncode(t,i){for(let r=0;r<this.builtInEncoders.length;r++){let n=this.builtInEncoders[r];if(n!=null){let o=n(t,i);if(o!=null){let a=-1-r;return new dt.ExtData(a,o)}}}for(let r=0;r<this.encoders.length;r++){let n=this.encoders[r];if(n!=null){let o=n(t,i);if(o!=null){let a=r;return new dt.ExtData(a,o)}}}return t instanceof dt.ExtData?t:null}decode(t,i,r){let n=i<0?this.builtInDecoders[-1-i]:this.decoders[i];return n?n(t,i,r):new dt.ExtData(i,t)}};pt.ExtensionCodec=De;De.defaultCodec=new De});var ai=I(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});oi.ensureUint8Array=jp;function Op(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function jp(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Op(e)?new Uint8Array(e):Uint8Array.from(e)}});var li=I(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.Encoder=P.DEFAULT_INITIAL_BUFFER_SIZE=P.DEFAULT_MAX_DEPTH=void 0;var tn=at(),Pp=gt(),rn=ut(),Dp=ai();P.DEFAULT_MAX_DEPTH=100;P.DEFAULT_INITIAL_BUFFER_SIZE=2048;var si=class e{constructor(t){this.entered=!1,this.extensionCodec=t?.extensionCodec??Pp.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.maxDepth=t?.maxDepth??P.DEFAULT_MAX_DEPTH,this.initialBufferSize=t?.initialBufferSize??P.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=t?.sortKeys??!1,this.forceFloat32=t?.forceFloat32??!1,this.ignoreUndefined=t?.ignoreUndefined??!1,this.forceIntegerToFloat=t?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(t){if(this.entered)return this.clone().encodeSharedRef(t);try{return this.entered=!0,this.reinitializeState(),this.doEncode(t,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(t){if(this.entered)return this.clone().encode(t);try{return this.entered=!0,this.reinitializeState(),this.doEncode(t,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(t,i){if(i>this.maxDepth)throw new Error(`Too deep objects in depth ${i}`);t==null?this.encodeNil():typeof t=="boolean"?this.encodeBoolean(t):typeof t=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(t):this.encodeNumber(t):typeof t=="string"?this.encodeString(t):this.useBigInt64&&typeof t=="bigint"?this.encodeBigInt64(t):this.encodeObject(t,i)}ensureBufferSizeToWrite(t){let i=this.pos+t;this.view.byteLength<i&&this.resizeBuffer(i*2)}resizeBuffer(t){let i=new ArrayBuffer(t),r=new Uint8Array(i),n=new DataView(i);r.set(this.bytes),this.view=n,this.bytes=r}encodeNil(){this.writeU8(192)}encodeBoolean(t){t===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(t){!this.forceIntegerToFloat&&Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):this.useBigInt64?this.encodeNumberAsFloat(t):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):this.useBigInt64?this.encodeNumberAsFloat(t):(this.writeU8(211),this.writeI64(t)):this.encodeNumberAsFloat(t)}encodeNumberAsFloat(t){this.forceFloat32?(this.writeU8(202),this.writeF32(t)):(this.writeU8(203),this.writeF64(t))}encodeBigInt64(t){t>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(t)):(this.writeU8(211),this.writeBigInt64(t))}writeStringHeader(t){if(t<32)this.writeU8(160+t);else if(t<256)this.writeU8(217),this.writeU8(t);else if(t<65536)this.writeU8(218),this.writeU16(t);else if(t<4294967296)this.writeU8(219),this.writeU32(t);else throw new Error(`Too long string: ${t} bytes in UTF-8`)}encodeString(t){let r=(0,tn.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,tn.utf8Encode)(t,this.bytes,this.pos),this.pos+=r}encodeObject(t,i){let r=this.extensionCodec.tryToEncode(t,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(t))this.encodeArray(t,i);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if(typeof t=="object")this.encodeMap(t,i);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(t)}`)}encodeBinary(t){let i=t.byteLength;if(i<256)this.writeU8(196),this.writeU8(i);else if(i<65536)this.writeU8(197),this.writeU16(i);else if(i<4294967296)this.writeU8(198),this.writeU32(i);else throw new Error(`Too large binary: ${i}`);let r=(0,Dp.ensureUint8Array)(t);this.writeU8a(r)}encodeArray(t,i){let r=t.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let n of t)this.doEncode(n,i+1)}countWithoutUndefined(t,i){let r=0;for(let n of i)t[n]!==void 0&&r++;return r}encodeMap(t,i){let r=Object.keys(t);this.sortKeys&&r.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(t,r):r.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else if(n<4294967296)this.writeU8(223),this.writeU32(n);else throw new Error(`Too large map object: ${n}`);for(let o of r){let a=t[o];this.ignoreUndefined&&a===void 0||(this.encodeString(o),this.doEncode(a,i+1))}}encodeExtension(t){if(typeof t.data=="function"){let r=t.data(this.pos+6),n=r.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(t.type),this.writeU8a(r);return}let i=t.data.length;if(i===1)this.writeU8(212);else if(i===2)this.writeU8(213);else if(i===4)this.writeU8(214);else if(i===8)this.writeU8(215);else if(i===16)this.writeU8(216);else if(i<256)this.writeU8(199),this.writeU8(i);else if(i<65536)this.writeU8(200),this.writeU16(i);else if(i<4294967296)this.writeU8(201),this.writeU32(i);else throw new Error(`Too large extension object: ${i}`);this.writeI8(t.type),this.writeU8a(t.data)}writeU8(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++}writeU8a(t){let i=t.length;this.ensureBufferSizeToWrite(i),this.bytes.set(t,this.pos),this.pos+=i}writeI8(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++}writeU16(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2}writeI16(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2}writeU32(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4}writeI32(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4}writeF32(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4}writeF64(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8}writeU64(t){this.ensureBufferSizeToWrite(8),(0,rn.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,rn.setInt64)(this.view,this.pos,t),this.pos+=8}writeBigUint64(t){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,t),this.pos+=8}writeBigInt64(t){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,t),this.pos+=8}};P.Encoder=si});var nn=I(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.encode=Np;var Up=li();function Np(e,t){return new Up.Encoder(t).encodeSharedRef(e)}});var on=I(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.prettyByte=qp;function qp(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var an=I(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.CachedKeyDecoder=void 0;var Bp=at(),Lp=16,Fp=16,di=class{constructor(t=Lp,i=Fp){this.hit=0,this.miss=0,this.maxKeyLength=t,this.maxLengthPerKey=i,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(t){return t>0&&t<=this.maxKeyLength}find(t,i,r){let n=this.caches[r-1];e:for(let o of n){let a=o.bytes;for(let s=0;s<r;s++)if(a[s]!==t[i+s])continue e;return o.str}return null}store(t,i){let r=this.caches[t.length-1],n={bytes:t,str:i};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)}decode(t,i,r){let n=this.find(t,i,r);if(n!=null)return this.hit++,n;this.miss++;let o=(0,Bp.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};ht.CachedKeyDecoder=di});var mt=I(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.Decoder=void 0;var pi=on(),zp=gt(),J=ut(),Rp=at(),sn=ai(),Vp=an(),B=ct(),gi="array",Ne="map_key",cn="map_value",Hp=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new B.DecodeError("The type of key must be string or number but "+typeof e)},hi=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(t){let i=this.getUninitializedStateFromPool();i.type=gi,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=Ne,i.readCount=0,i.size=t,i.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let t={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(t)}return this.stack[this.stackHeadPosition]}release(t){if(this.stack[this.stackHeadPosition]!==t)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(t.type===gi){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===Ne||t.type===cn){let r=t;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Ue=-1,mi=new DataView(new ArrayBuffer(0)),Gp=new Uint8Array(mi.buffer);try{mi.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var ln=new RangeError("Insufficient data"),Qp=new Vp.CachedKeyDecoder,fi=class e{constructor(t){this.totalPos=0,this.pos=0,this.view=mi,this.bytes=Gp,this.headByte=Ue,this.stack=new hi,this.entered=!1,this.extensionCodec=t?.extensionCodec??zp.ExtensionCodec.defaultCodec,this.context=t?.context,this.useBigInt64=t?.useBigInt64??!1,this.rawStrings=t?.rawStrings??!1,this.maxStrLength=t?.maxStrLength??J.UINT32_MAX,this.maxBinLength=t?.maxBinLength??J.UINT32_MAX,this.maxArrayLength=t?.maxArrayLength??J.UINT32_MAX,this.maxMapLength=t?.maxMapLength??J.UINT32_MAX,this.maxExtLength=t?.maxExtLength??J.UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:Qp,this.mapKeyConverter=t?.mapKeyConverter??Hp}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ue,this.stack.reset()}setBuffer(t){let i=(0,sn.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===Ue&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,sn.ensureUint8Array)(t),n=new Uint8Array(i.length+r.length);n.set(i),n.set(r,i.length),this.setBuffer(n)}}hasRemaining(t){return this.view.byteLength-this.pos>=t}createExtraByteError(t){let{view:i,pos:r}=this;return new RangeError(`Extra ${i.byteLength-r} of ${i.byteLength} byte(s) found at buffer[${t}]`)}decode(t){if(this.entered)return this.clone().decode(t);try{this.entered=!0,this.reinitializeState(),this.setBuffer(t);let i=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return i}finally{this.entered=!1}}*decodeMulti(t){if(this.entered){yield*this.clone().decodeMulti(t);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(t);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(t){if(this.entered)return this.clone().decodeAsync(t);try{this.entered=!0;let i=!1,r;for await(let s of t){if(i)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(s);try{r=this.doDecodeSync(),i=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(i){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return r}let{headByte:n,pos:o,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${(0,pi.prettyByte)(n)} at ${a} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(t){return this.decodeMultiAsync(t,!0)}decodeStream(t){return this.decodeMultiAsync(t,!1)}async*decodeMultiAsync(t,i){if(this.entered){yield*this.clone().decodeMultiAsync(t,i);return}try{this.entered=!0;let r=i,n=-1;for await(let o of t){if(i&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),r&&(n=this.readArraySize(),r=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let t=this.readHeadByte(),i;if(t>=224)i=t-256;else if(t<192)if(t<128)i=t;else if(t<144){let n=t-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t<160){let n=t-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else{let n=t-160;i=this.decodeString(n,0)}else if(t===192)i=null;else if(t===194)i=!1;else if(t===195)i=!0;else if(t===202)i=this.readF32();else if(t===203)i=this.readF64();else if(t===204)i=this.readU8();else if(t===205)i=this.readU16();else if(t===206)i=this.readU32();else if(t===207)this.useBigInt64?i=this.readU64AsBigInt():i=this.readU64();else if(t===208)i=this.readI8();else if(t===209)i=this.readI16();else if(t===210)i=this.readI32();else if(t===211)this.useBigInt64?i=this.readI64AsBigInt():i=this.readI64();else if(t===217){let n=this.lookU8();i=this.decodeString(n,1)}else if(t===218){let n=this.lookU16();i=this.decodeString(n,2)}else if(t===219){let n=this.lookU32();i=this.decodeString(n,4)}else if(t===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(t===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else i=[]}else if(t===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else i={}}else if(t===196){let n=this.lookU8();i=this.decodeBinary(n,1)}else if(t===197){let n=this.lookU16();i=this.decodeBinary(n,2)}else if(t===198){let n=this.lookU32();i=this.decodeBinary(n,4)}else if(t===212)i=this.decodeExtension(1,0);else if(t===213)i=this.decodeExtension(2,0);else if(t===214)i=this.decodeExtension(4,0);else if(t===215)i=this.decodeExtension(8,0);else if(t===216)i=this.decodeExtension(16,0);else if(t===199){let n=this.lookU8();i=this.decodeExtension(n,1)}else if(t===200){let n=this.lookU16();i=this.decodeExtension(n,2)}else if(t===201){let n=this.lookU32();i=this.decodeExtension(n,4)}else throw new B.DecodeError(`Unrecognized type byte: ${(0,pi.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===gi)if(n.array[n.position]=i,n.position++,n.position===n.size)i=n.array,r.release(n);else continue e;else if(n.type===Ne){if(i==="__proto__")throw new B.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=cn;continue e}else if(n.map[n.key]=i,n.readCount++,n.readCount===n.size)i=n.map,r.release(n);else{n.key=null,n.type=Ne;continue e}}return i}}readHeadByte(){return this.headByte===Ue&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ue}readArraySize(){let t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new B.DecodeError(`Unrecognized array type byte: ${(0,pi.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new B.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new B.DecodeError(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(t)}decodeString(t,i){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(t,i):this.decodeBinary(t,i)}decodeUtf8String(t,i){if(t>this.maxStrLength)throw new B.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw ln;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,Rp.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Ne:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new B.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw ln;let r=this.pos+i,n=this.bytes.subarray(r,r+t);return this.pos+=i+t,n}decodeExtension(t,i){if(t>this.maxExtLength)throw new B.DecodeError(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+i),n=this.decodeBinary(t,i+1);return this.extensionCodec.decode(n,r,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let t=this.view.getUint8(this.pos);return this.pos++,t}readI8(){let t=this.view.getInt8(this.pos);return this.pos++,t}readU16(){let t=this.view.getUint16(this.pos);return this.pos+=2,t}readI16(){let t=this.view.getInt16(this.pos);return this.pos+=2,t}readU32(){let t=this.view.getUint32(this.pos);return this.pos+=4,t}readI32(){let t=this.view.getInt32(this.pos);return this.pos+=4,t}readU64(){let t=(0,J.getUint64)(this.view,this.pos);return this.pos+=8,t}readI64(){let t=(0,J.getInt64)(this.view,this.pos);return this.pos+=8,t}readU64AsBigInt(){let t=this.view.getBigUint64(this.pos);return this.pos+=8,t}readI64AsBigInt(){let t=this.view.getBigInt64(this.pos);return this.pos+=8,t}readF32(){let t=this.view.getFloat32(this.pos);return this.pos+=4,t}readF64(){let t=this.view.getFloat64(this.pos);return this.pos+=8,t}};ft.Decoder=fi});var dn=I(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.decode=Kp;yt.decodeMulti=Wp;var un=mt();function Kp(e,t){return new un.Decoder(t).decode(e)}function Wp(e,t){return new un.Decoder(t).decodeMulti(e)}});var hn=I(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.isAsyncIterable=pn;qe.asyncIterableFromStream=gn;qe.ensureAsyncIterable=Yp;function pn(e){return e[Symbol.asyncIterator]!=null}async function*gn(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function Yp(e){return pn(e)?e:gn(e)}});var fn=I(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.decodeAsync=Zp;Be.decodeArrayStream=Xp;Be.decodeMultiStream=Jp;var yi=mt(),bi=hn();async function Zp(e,t){let i=(0,bi.ensureAsyncIterable)(e);return new yi.Decoder(t).decodeAsync(i)}function Xp(e,t){let i=(0,bi.ensureAsyncIterable)(e);return new yi.Decoder(t).decodeArrayStream(i)}function Jp(e,t){let i=(0,bi.ensureAsyncIterable)(e);return new yi.Decoder(t).decodeStream(i)}});var yn=I(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.decodeTimestampExtension=k.encodeTimestampExtension=k.decodeTimestampToTimeSpec=k.encodeTimeSpecToTimestamp=k.encodeDateToTimeSpec=k.EXT_TIMESTAMP=k.ExtData=k.ExtensionCodec=k.Encoder=k.DecodeError=k.Decoder=k.decodeMultiStream=k.decodeArrayStream=k.decodeAsync=k.decodeMulti=k.decode=k.encode=void 0;var eg=nn();Object.defineProperty(k,"encode",{enumerable:!0,get:function(){return eg.encode}});var mn=dn();Object.defineProperty(k,"decode",{enumerable:!0,get:function(){return mn.decode}});Object.defineProperty(k,"decodeMulti",{enumerable:!0,get:function(){return mn.decodeMulti}});var _i=fn();Object.defineProperty(k,"decodeAsync",{enumerable:!0,get:function(){return _i.decodeAsync}});Object.defineProperty(k,"decodeArrayStream",{enumerable:!0,get:function(){return _i.decodeArrayStream}});Object.defineProperty(k,"decodeMultiStream",{enumerable:!0,get:function(){return _i.decodeMultiStream}});var tg=mt();Object.defineProperty(k,"Decoder",{enumerable:!0,get:function(){return tg.Decoder}});var ig=ct();Object.defineProperty(k,"DecodeError",{enumerable:!0,get:function(){return ig.DecodeError}});var rg=li();Object.defineProperty(k,"Encoder",{enumerable:!0,get:function(){return rg.Encoder}});var ng=gt();Object.defineProperty(k,"ExtensionCodec",{enumerable:!0,get:function(){return ng.ExtensionCodec}});var og=ii();Object.defineProperty(k,"ExtData",{enumerable:!0,get:function(){return og.ExtData}});var be=ni();Object.defineProperty(k,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return be.EXT_TIMESTAMP}});Object.defineProperty(k,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return be.encodeDateToTimeSpec}});Object.defineProperty(k,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return be.encodeTimeSpecToTimestamp}});Object.defineProperty(k,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return be.decodeTimestampToTimeSpec}});Object.defineProperty(k,"encodeTimestampExtension",{enumerable:!0,get:function(){return be.encodeTimestampExtension}});Object.defineProperty(k,"decodeTimestampExtension",{enumerable:!0,get:function(){return be.decodeTimestampExtension}})});var On=I(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});function S(e){return{enumerable:!0,value:e}}function bn(e){return{enumerable:!0,writable:!0,value:e}}var ee={},ag=()=>!0,_n=()=>({}),wn=e=>e,sg=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),lg=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),Q=(e,t)=>Object.freeze(Object.create(e,t));function vn(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function kn(e){return Q(this,{fn:S(e)})}var In={},An=kn.bind(In),cg=e=>An((t,i)=>!!~e(t,i)&&t),xn={},ug=kn.bind(xn);function bt(e,t){return t.filter(i=>e.isPrototypeOf(i))}function En(e,t,...i){let r=vn(bt(xn,i).map(o=>o.fn),ag,sg),n=vn(bt(In,i).map(o=>o.fn),wn,lg);return Q(this,{from:S(e),to:S(t),guards:S(r),reducers:S(n)})}var Sn={},Cn={},dg=En.bind(Sn),pg=En.bind(Cn,null);function gg(e,t,i){return wi(t,e,i,this.immediates)||e}function Tn(e){let t=new Map;for(let i of e)t.has(i.from)||t.set(i.from,[]),t.get(i.from).push(i);return t}var hg={enter:wn};function fg(...e){let t=bt(Sn,e),i=bt(Cn,e),r={final:S(e.length===0),transitions:S(Tn(t))};return i.length&&(r.immediates=S(i),r.enter=S(gg)),Q(hg,r)}var mg={enter(e,t,i){let r=this.fn.call(t,t.context,i);return vi.isPrototypeOf(r)?Q(Mn,{machine:S(r),transitions:S(this.transitions)}).enter(e,t,i):(r.then(n=>t.send({type:"done",data:n})).catch(n=>t.send({type:"error",error:n})),e)}},Mn={enter(e,t,i){if(t.child=$n(this.machine,r=>{t.onChange(r),t.child==r&&r.machine.state.value.final&&(delete t.child,t.send({type:"done",data:r.context}))},t.context,i),t.child.machine.state.value.final){let r=t.child.context;return delete t.child,wi(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function yg(e,...t){let i=S(Tn(t));return vi.isPrototypeOf(e)?Q(Mn,{machine:S(e),transitions:i}):Q(mg,{fn:S(e),transitions:i})}var vi={get state(){return{name:this.current,value:this.states[this.current]}}};function bg(e,t,i=_n){return typeof e!="string"&&(i=t||_n,t=e,e=Object.keys(t)[0]),ee._create&&ee._create(e,t),Q(vi,{context:S(i),current:S(e),states:S(t)})}function wi(e,t,i,r){let{context:n}=e;for(let{to:o,guards:a,reducers:s}of r)if(a(n,i)){e.context=s.call(e,n,i);let c=t.original||t,u=Q(c,{current:S(o),original:{value:c}});return ee._onEnter&&ee._onEnter(t,o,e.context,n,i),u.state.value.enter(u,e,i)}}function _g(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?wi(e,r,t,n.transitions.get(i))||r:(ee._send&&ee._send(i,o),r)}var vg={send(e){this.machine=_g(this,e),this.onChange(this)}};function $n(e,t,i,r){let n=Object.create(vg,{machine:bn(e),context:bn(e.context(i,r)),onChange:S(t)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}M.action=cg;M.createMachine=bg;M.d=ee;M.guard=ug;M.immediate=pg;M.interpret=$n;M.invoke=yg;M.reduce=An;M.state=fg;M.transition=dg});var Nn=I(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.createRealtimeClient=Dg;var vt=yn(),y=On(),jn=Xt(),ki=Y(),Pn=it(),xi=Z(),wg=()=>({enqueuedMessage:void 0});function kg(e){return e.token!==void 0}function Ig(e){return!kg(e)}function _t(e,t){return Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function L(e){return e.websocket&&e.websocket.readyState===WebSocket.OPEN&&e.websocket.close(),Object.assign(Object.assign({},e),{websocket:void 0})}function Ag(e,t){return e.websocket&&e.websocket.readyState===WebSocket.OPEN?(t.message instanceof Uint8Array?e.websocket.send(t.message):e.websocket.send((0,vt.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function Ii(e){return Object.assign(Object.assign({},e),{token:void 0})}function xg(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function Eg(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var Sg=(0,y.createMachine)("idle",{idle:(0,y.state)((0,y.transition)("send","connecting",(0,y.reduce)(_t)),(0,y.transition)("expireToken","idle",(0,y.reduce)(Ii)),(0,y.transition)("close","idle",(0,y.reduce)(L))),connecting:(0,y.state)((0,y.transition)("connecting","connecting"),(0,y.transition)("connected","active",(0,y.reduce)(Eg)),(0,y.transition)("connectionClosed","idle",(0,y.reduce)(L)),(0,y.transition)("send","connecting",(0,y.reduce)(_t)),(0,y.transition)("close","idle",(0,y.reduce)(L)),(0,y.immediate)("authRequired",(0,y.guard)(Ig))),authRequired:(0,y.state)((0,y.transition)("initiateAuth","authInProgress"),(0,y.transition)("send","authRequired",(0,y.reduce)(_t)),(0,y.transition)("close","idle",(0,y.reduce)(L))),authInProgress:(0,y.state)((0,y.transition)("authenticated","connecting",(0,y.reduce)(xg)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(Ii),(0,y.reduce)(L)),(0,y.transition)("send","authInProgress",(0,y.reduce)(_t)),(0,y.transition)("close","idle",(0,y.reduce)(L))),active:(0,y.state)((0,y.transition)("send","active",(0,y.reduce)(Ag)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(Ii)),(0,y.transition)("connectionClosed","idle",(0,y.reduce)(L)),(0,y.transition)("close","idle",(0,y.reduce)(L))),failed:(0,y.state)((0,y.transition)("send","failed"),(0,y.transition)("close","idle",(0,y.reduce)(L)))},wg);function Cg(e,{token:t,maxBuffering:i}){if(i!==void 0&&(i<1||i>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let r=new URLSearchParams({fal_jwt_token:t});return i!==void 0&&r.set("max_buffering",i.toFixed(0)),`wss://fal.run/${(0,xi.ensureEndpointIdFormat)(e)}/realtime?${r.toString()}`}var Tg=128;function Mg(e){return e.status==="error"&&e.error==="Unauthorized"}var $g={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},Ai=new Map,Dn=new Map;function Og(e,t,i){if(!Ai.has(e)){let r=(0,y.interpret)(Sg,i);Ai.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,xi.throttle)(r.send,t,!0):r.send}))}return Ai.get(e)}var Le=()=>{},jg={send:Le,close:Le};function Pg(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!Un(e)}function Un(e){return e.type==="x-fal-error"}function Dg({config:e}){return{connect(t,i){let{clientOnly:r=(0,xi.isReact)()&&!(0,Pn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:a=Tg}=i;if(r&&!(0,Pn.isBrowser)())return jg;let s;Dn.set(n,{onError:i.onError,onResult:i.onResult});let c=()=>Dn.get(n),u=Og(n,a,({context:f,machine:g,send:m})=>{let{enqueuedMessage:_,token:w}=f;if(g.current==="active"&&_&&m({type:"send",message:_}),g.current==="authRequired"&&w===void 0&&s!==g.current&&(m({type:"initiateAuth"}),(0,jn.getTemporaryAuthToken)(t,e).then(p=>{m({type:"authenticated",token:p});let h=Math.round(jn.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{m({type:"expireToken"})},h)}).catch(p=>{m({type:"unauthorized",error:p})})),g.current==="connecting"&&s!==g.current&&w!==void 0){let p=new WebSocket(Cg(t,{token:w,maxBuffering:o}));p.onopen=()=>{m({type:"connected",websocket:p})},p.onclose=h=>{if(h.code!==$g.NORMAL_CLOSURE){let{onError:v=Le}=c();v(new ki.ApiError({message:`Error closing the connection: ${h.reason}`,status:h.code}))}m({type:"connectionClosed",code:h.code})},p.onerror=h=>{let{onError:v=Le}=c();v(new ki.ApiError({message:"Unknown error",status:500}))},p.onmessage=h=>{let{onResult:v}=c();if(h.data instanceof ArrayBuffer){let C=(0,vt.decode)(new Uint8Array(h.data));v(C);return}if(h.data instanceof Uint8Array){let C=(0,vt.decode)(h.data);v(C);return}if(h.data instanceof Blob){h.data.arrayBuffer().then(C=>{let $i=(0,vt.decode)(new Uint8Array(C));v($i)});return}let b=JSON.parse(h.data);if(Mg(b)){m({type:"unauthorized",error:new Error("Unauthorized")});return}if(Pg(b)){v(b);return}if(Un(b)){if(b.error==="TIMEOUT")return;let{onError:C=Le}=c();C(new ki.ApiError({message:`${b.error}: ${b.reason}`,status:400,body:b}));return}}}s=g.current});return{send:f=>{u.throttledSend({type:"send",message:f})},close:()=>{u.send({type:"close"})}}}}}});var zn=I(Fe=>{"use strict";var te=Fe&&Fe.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(Fe,"__esModule",{value:!0});Fe.createStorageClient=Lg;var qn=rt(),Bn=me(),Ug=Z();function Ln(e){var t;let[i,r]=e.split("/");return(t=r.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function Ng(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${Ln(i)}`;return yield(0,Bn.dispatchRequest)({method:"POST",targetUrl:`${(0,qn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function qg(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${Ln(i)}`;return yield(0,Bn.dispatchRequest)({method:"POST",targetUrl:`${(0,qn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function Fn(e,t,i){return te(this,arguments,void 0,function*(r,n,o,a=3){if(a===0)throw new Error("Part upload failed, retries exhausted");let{fetch:s,responseHandler:c}=o;try{let u=yield s(r,{method:"PUT",body:n});return yield c(u)}catch{return yield Fn(r,n,o,a-1)}})}function Bg(e,t){return te(this,void 0,void 0,function*(){let{fetch:i,responseHandler:r}=t,n=e.type||"application/octet-stream",{upload_url:o,file_url:a}=yield qg(e,t,n),s=10*1024*1024,c=Math.ceil(e.size/s),u=new URL(o),l=[];for(let g=0;g<c;g++){let m=g*s,_=Math.min(m+s,e.size),w=e.slice(m,_),p=g+1,h=`${u.origin}${u.pathname}/${p}${u.search}`;l.push(yield Fn(h,w,t))}let d=`${u.origin}${u.pathname}/complete${u.search}`,f=yield i(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(g=>({partNumber:g.partNumber,etag:g.etag}))})});return yield r(f),a})}function Lg({config:e}){let t={upload:i=>te(this,void 0,void 0,function*(){if(i.size>94371840)return yield Bg(i,e);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:o}=e,{upload_url:a,file_url:s}=yield Ng(i,e,r),c=yield n(a,{method:"PUT",body:i,headers:{"Content-Type":i.type||"application/octet-stream"}});return yield o(c),s}),transformInput:i=>te(this,void 0,void 0,function*(){if(Array.isArray(i))return Promise.all(i.map(r=>t.transformInput(r)));if(i instanceof Blob)return yield t.upload(i);if((0,Ug.isPlainObject)(i)){let n=Object.entries(i).map(a=>te(this,[a],void 0,function*([s,c]){return[s,yield t.transformInput(c)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return i})};return t}});var Si=I(ze=>{"use strict";var Rn=ze&&ze.__awaiter||function(e,t,i,r){function n(o){return o instanceof i?o:new i(function(a){a(o)})}return new(i||(i=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(d){a(d)}}function c(l){try{u(r.throw(l))}catch(d){a(d)}}function u(l){l.done?o(l.value):n(l.value).then(s,c)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(ze,"__esModule",{value:!0});ze.createFalClient=Qg;var Fg=rt(),zg=Vr(),Rg=Nn(),Vn=me(),Vg=Y(),Hg=zn(),Gg=ei();function Qg(e={}){let t=(0,Fg.createConfig)(e),i=(0,Hg.createStorageClient)({config:t}),r=(0,zg.createQueueClient)({config:t,storage:i}),n=(0,Gg.createStreamingClient)({config:t,storage:i}),o=(0,Rg.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return Rn(this,arguments,void 0,function*(s,c={}){let u=c.input?yield i.transformInput(c.input):void 0;return(0,Vn.dispatchRequest)({method:c.method,targetUrl:(0,Vn.buildUrl)(s,c),input:u,config:Object.assign(Object.assign({},t),{responseHandler:Vg.resultResponseHandler}),options:{signal:c.abortSignal}})})},subscribe:(a,s)=>Rn(this,void 0,void 0,function*(){let{request_id:c}=yield r.submit(a,s);return s.onEnqueue&&s.onEnqueue(c),yield r.subscribeToStatus(a,Object.assign({requestId:c},s)),r.result(a,{requestId:c})})}}});var Gn=I(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.isQueueStatus=Hn;wt.isCompletedQueueStatus=Kg;function Hn(e){return e&&e.status&&e.response_url}function Kg(e){return Hn(e)&&e.status==="COMPLETED"}});var Ci=I(E=>{"use strict";var Wg=E&&E.__createBinding||(Object.create?function(e,t,i,r){r===void 0&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){r===void 0&&(r=i),e[r]=t[i]}),Yg=E&&E.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&Wg(t,e,i)};Object.defineProperty(E,"__esModule",{value:!0});E.fal=E.parseEndpointId=E.ValidationError=E.ApiError=E.withProxy=E.withMiddleware=E.createFalClient=void 0;var Qn=Si(),Zg=Si();Object.defineProperty(E,"createFalClient",{enumerable:!0,get:function(){return Zg.createFalClient}});var Kn=Wt();Object.defineProperty(E,"withMiddleware",{enumerable:!0,get:function(){return Kn.withMiddleware}});Object.defineProperty(E,"withProxy",{enumerable:!0,get:function(){return Kn.withProxy}});var Wn=Y();Object.defineProperty(E,"ApiError",{enumerable:!0,get:function(){return Wn.ApiError}});Object.defineProperty(E,"ValidationError",{enumerable:!0,get:function(){return Wn.ValidationError}});Yg(Gn(),E);var Xg=Z();Object.defineProperty(E,"parseEndpointId",{enumerable:!0,get:function(){return Xg.parseEndpointId}});E.fal=function(){let t=(0,Qn.createFalClient)();return{config(i){t=(0,Qn.createFalClient)(i)},get queue(){return t.queue},get realtime(){return t.realtime},get storage(){return t.storage},get streaming(){return t.streaming},run(i,r){return t.run(i,r)},subscribe(i,r){return t.subscribe(i,r)},stream(i,r){return t.stream(i,r)}}}()});var ao=`
6
6
  <svg>
7
7
  <symbol
8
8
  fill="none"
@@ -68,7 +68,7 @@ var eo=Object.create;var $i=Object.defineProperty;var to=Object.getOwnPropertyDe
68
68
  <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"/>
69
69
  </symbol>
70
70
  </svg>
71
- `,Ot=class{constructor(e,t=[]){this.id=e,this.assets=t.map(i=>{if(typeof i.label=="string"&&!(i.label&&typeof i.label=="object")){let r=i;return{id:r.id,label:{en:r.label},meta:r.thumbUri?{thumbUri:r.thumbUri}:void 0}}return i}),this.activeAssetIds=new Set}async findAssets(e){let{page:t,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:s,excludeGroups:l,sortingOrder:u,sortKey:c}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(g=>g.groups&&s.some(y=>g.groups?.includes(y)))),l&&l.length>0&&(d=d.filter(g=>!g.groups||!l.some(y=>g.groups?.includes(y)))),o){let g=o.toLowerCase();d=d.filter(y=>{let I=y.label?.[r]?.toLowerCase(),w=y.tags?.[r]||[];return I&&I.includes(g)||w.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];d=d.filter(y=>{let I=y.tags?.[r]||[];return g.some(w=>I.includes(w))})}n&&d.sort((g,y)=>{let I=this.activeAssetIds.has(g.id),w=this.activeAssetIds.has(y.id);return I&&!w?-1:!I&&w?1:0}),c&&c!=="id"?d.sort((g,y)=>{let I=g.meta?.[c],w=y.meta?.[c];return I===void 0?1:w===void 0?-1:typeof I=="string"&&typeof w=="string"?u==="Descending"?w.localeCompare(I):I.localeCompare(w):typeof I=="number"&&typeof w=="number"?u==="Descending"?w-I:I-w:0}):c==="id"&&d.sort((g,y)=>u==="Descending"?y.id.localeCompare(g.id):g.id.localeCompare(y.id));let h=d.length,p=t*i,f=p+i,b=d.slice(p,f).map(g=>({id:g.id,groups:g.groups,meta:g.meta,payload:g.payload,locale:r,label:g.label?.[r],tags:g.tags?.[r],active:this.activeAssetIds.has(g.id)})),v=f<h?t+1:void 0;return{assets:b,currentPage:t,nextPage:v,total:h}}updateLabel(e,t,i){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[i]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:i})=>i===e);if(t)return{id:t.id,label:t.label?.en||"",thumbUri:t.meta?.thumbUri}}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(i=>i.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(i=>i.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(i=>e.add(i))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var so=typeof global=="object"&&global&&global.Object===Object&&global,Ki=so,lo=typeof self=="object"&&self&&self.Object===Object&&self,co=Ki||lo||Function("return this")(),D=co,uo=D.Symbol,re=uo,Wi=Object.prototype,po=Wi.hasOwnProperty,go=Wi.toString,_e=re?re.toStringTag:void 0;function ho(e){var t=po.call(e,_e),i=e[_e];try{e[_e]=void 0;var r=!0}catch{}var n=go.call(e);return r&&(t?e[_e]=i:delete e[_e]),n}var fo=ho,mo=Object.prototype,yo=mo.toString;function bo(e){return yo.call(e)}var _o=bo,vo="[object Null]",wo="[object Undefined]",Pi=re?re.toStringTag:void 0;function ko(e){return e==null?e===void 0?wo:vo:Pi&&Pi in Object(e)?fo(e):_o(e)}var Ie=ko;function Io(e){return e!=null&&typeof e=="object"}var $t=Io,Wg=Array.isArray;function Ao(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Yi=Ao,Eo="[object AsyncFunction]",xo="[object Function]",So="[object GeneratorFunction]",Co="[object Proxy]";function Mo(e){if(!Yi(e))return!1;var t=Ie(e);return t==xo||t==So||t==Eo||t==Co}var To=Mo,Oo=D["__core-js_shared__"],At=Oo,Di=function(){var e=/[^.]+$/.exec(At&&At.keys&&At.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function $o(e){return!!Di&&Di in e}var jo=$o,Po=Function.prototype,Do=Po.toString;function Uo(e){if(e!=null){try{return Do.call(e)}catch{}try{return e+""}catch{}}return""}var K=Uo,No=/[\\^$.*+?()[\]{}|]/g,qo=/^\[object .+?Constructor\]$/,Bo=Function.prototype,Fo=Object.prototype,Lo=Bo.toString,zo=Fo.hasOwnProperty,Ro=RegExp("^"+Lo.call(zo).replace(No,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vo(e){if(!Yi(e)||jo(e))return!1;var t=To(e)?Ro:qo;return t.test(K(e))}var Ho=Vo;function Go(e,t){return e?.[t]}var Qo=Go;function Ko(e,t){var i=Qo(e,t);return Ho(i)?i:void 0}var ne=Ko,Wo=ne(D,"WeakMap"),xt=Wo;function Yo(e,t){return e===t||e!==e&&t!==t}var Zo=Yo,Xo=9007199254740991;function Jo(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Xo}var ea=Jo;var Yg=Object.prototype;var ta="[object Arguments]";function ia(e){return $t(e)&&Ie(e)==ta}var Ui=ia,Zi=Object.prototype,ra=Zi.hasOwnProperty,na=Zi.propertyIsEnumerable,Zg=Ui(function(){return arguments}())?Ui:function(e){return $t(e)&&ra.call(e,"callee")&&!na.call(e,"callee")};var Xi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ni=Xi&&typeof module=="object"&&module&&!module.nodeType&&module,oa=Ni&&Ni.exports===Xi,qi=oa?D.Buffer:void 0,Xg=qi?qi.isBuffer:void 0;var aa="[object Arguments]",sa="[object Array]",la="[object Boolean]",ca="[object Date]",ua="[object Error]",da="[object Function]",pa="[object Map]",ga="[object Number]",ha="[object Object]",fa="[object RegExp]",ma="[object Set]",ya="[object String]",ba="[object WeakMap]",_a="[object ArrayBuffer]",va="[object DataView]",wa="[object Float32Array]",ka="[object Float64Array]",Ia="[object Int8Array]",Aa="[object Int16Array]",Ea="[object Int32Array]",xa="[object Uint8Array]",Sa="[object Uint8ClampedArray]",Ca="[object Uint16Array]",Ma="[object Uint32Array]",A={};A[wa]=A[ka]=A[Ia]=A[Aa]=A[Ea]=A[xa]=A[Sa]=A[Ca]=A[Ma]=!0;A[aa]=A[sa]=A[_a]=A[la]=A[va]=A[ca]=A[ua]=A[da]=A[pa]=A[ga]=A[ha]=A[fa]=A[ma]=A[ya]=A[ba]=!1;function Ta(e){return $t(e)&&ea(e.length)&&!!A[Ie(e)]}var Oa=Ta;function $a(e){return function(t){return e(t)}}var ja=$a,Ji=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ve=Ji&&typeof module=="object"&&module&&!module.nodeType&&module,Pa=ve&&ve.exports===Ji,Et=Pa&&Ki.process,Da=function(){try{var e=ve&&ve.require&&ve.require("util").types;return e||Et&&Et.binding&&Et.binding("util")}catch{}}(),Bi=Da,Fi=Bi&&Bi.isTypedArray,Jg=Fi?ja(Fi):Oa;var Ua=Object.prototype,eh=Ua.hasOwnProperty;function Na(e,t){return function(i){return e(t(i))}}var qa=Na,th=qa(Object.keys,Object);var Ba=Object.prototype,ih=Ba.hasOwnProperty;var Fa=ne(Object,"create"),we=Fa;function La(){this.__data__=we?we(null):{},this.size=0}var za=La;function Ra(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Va=Ra,Ha="__lodash_hash_undefined__",Ga=Object.prototype,Qa=Ga.hasOwnProperty;function Ka(e){var t=this.__data__;if(we){var i=t[e];return i===Ha?void 0:i}return Qa.call(t,e)?t[e]:void 0}var Wa=Ka,Ya=Object.prototype,Za=Ya.hasOwnProperty;function Xa(e){var t=this.__data__;return we?t[e]!==void 0:Za.call(t,e)}var Ja=Xa,es="__lodash_hash_undefined__";function ts(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=we&&t===void 0?es:t,this}var is=ts;function oe(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}oe.prototype.clear=za;oe.prototype.delete=Va;oe.prototype.get=Wa;oe.prototype.has=Ja;oe.prototype.set=is;var Li=oe;function rs(){this.__data__=[],this.size=0}var ns=rs;function os(e,t){for(var i=e.length;i--;)if(Zo(e[i][0],t))return i;return-1}var He=os,as=Array.prototype,ss=as.splice;function ls(e){var t=this.__data__,i=He(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():ss.call(t,i,1),--this.size,!0}var cs=ls;function us(e){var t=this.__data__,i=He(t,e);return i<0?void 0:t[i][1]}var ds=us;function ps(e){return He(this.__data__,e)>-1}var gs=ps;function hs(e,t){var i=this.__data__,r=He(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var fs=hs;function ae(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ae.prototype.clear=ns;ae.prototype.delete=cs;ae.prototype.get=ds;ae.prototype.has=gs;ae.prototype.set=fs;var Ge=ae,ms=ne(D,"Map"),ke=ms;function ys(){this.size=0,this.__data__={hash:new Li,map:new(ke||Ge),string:new Li}}var bs=ys;function _s(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var vs=_s;function ws(e,t){var i=e.__data__;return vs(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Qe=ws;function ks(e){var t=Qe(this,e).delete(e);return this.size-=t?1:0,t}var Is=ks;function As(e){return Qe(this,e).get(e)}var Es=As;function xs(e){return Qe(this,e).has(e)}var Ss=xs;function Cs(e,t){var i=Qe(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Ms=Cs;function se(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}se.prototype.clear=bs;se.prototype.delete=Is;se.prototype.get=Es;se.prototype.has=Ss;se.prototype.set=Ms;var er=se;function Ts(){this.__data__=new Ge,this.size=0}var Os=Ts;function $s(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var js=$s;function Ps(e){return this.__data__.get(e)}var Ds=Ps;function Us(e){return this.__data__.has(e)}var Ns=Us,qs=200;function Bs(e,t){var i=this.__data__;if(i instanceof Ge){var r=i.__data__;if(!ke||r.length<qs-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new er(r)}return i.set(e,t),this.size=i.size,this}var Fs=Bs;function Ae(e){var t=this.__data__=new Ge(e);this.size=t.size}Ae.prototype.clear=Os;Ae.prototype.delete=js;Ae.prototype.get=Ds;Ae.prototype.has=Ns;Ae.prototype.set=Fs;var Ls=Object.prototype,rh=Ls.propertyIsEnumerable;var zs=ne(D,"DataView"),St=zs,Rs=ne(D,"Promise"),Ct=Rs,Vs=ne(D,"Set"),Mt=Vs,zi="[object Map]",Hs="[object Object]",Ri="[object Promise]",Vi="[object Set]",Hi="[object WeakMap]",Gi="[object DataView]",Gs=K(St),Qs=K(ke),Ks=K(Ct),Ws=K(Mt),Ys=K(xt),ie=Ie;(St&&ie(new St(new ArrayBuffer(1)))!=Gi||ke&&ie(new ke)!=zi||Ct&&ie(Ct.resolve())!=Ri||Mt&&ie(new Mt)!=Vi||xt&&ie(new xt)!=Hi)&&(ie=function(e){var t=Ie(e),i=t==Hs?e.constructor:void 0,r=i?K(i):"";if(r)switch(r){case Gs:return Gi;case Qs:return zi;case Ks:return Ri;case Ws:return Vi;case Ys:return Hi}return t});var nh=D.Uint8Array;var Zs="__lodash_hash_undefined__";function Xs(e){return this.__data__.set(e,Zs),this}var Js=Xs;function el(e){return this.__data__.has(e)}var tl=el;function Tt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new er;++t<i;)this.add(e[t])}Tt.prototype.add=Tt.prototype.push=Js;Tt.prototype.has=tl;var Qi=re?re.prototype:void 0,oh=Qi?Qi.valueOf:void 0;var il=Object.prototype,ah=il.hasOwnProperty;var rl=Object.prototype,sh=rl.hasOwnProperty;var lh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),ch=new RegExp(/[A-Fa-f0-9]{1}/,"g"),uh=new RegExp(/[A-Fa-f0-9]{2}/,"g");function jt(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}async function nl(e,t){if(e.startsWith("buffer:")){let i=await t.editor.getMimeType(e),r=t.editor.getBufferLength(e),n=t.editor.getBufferData(e,0,r),o=new Blob([n],{type:i});return URL.createObjectURL(o)}else return e}async function tr(e,t){let i=await nl(e,t);return new Promise((r,n)=>{let o=new Image;o.onload=()=>{r({width:o.width,height:o.height})},o.onerror=n,o.src=i})}var ir={Formats:ao};function ol(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=Nt(e);return i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Image To Change"}}),al(e,i),{[r]:(o,a)=>{let{builder:s,experimental:{global:l},payload:u}=o,c=u?.url??t.defaultUrl,d=l(`${e}.${a.id}`,c);return s.MediaPreview(a.id,{preview:{type:"image",uri:d.value},action:{label:"Select Image",onClick:()=>{i?.ui.openPanel(n,{payload:{onSelect:h=>{h.meta?.uri!=null&&d.setValue(h.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:d.value})}}}function al(e,t){t?.ui.registerPanel(Nt(e),({builder:i,payload:r})=>{i.Library(`${e}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let a=await t.engine.editor.getMimeType(o);a==="image/svg+xml"?t.ui.showNotification({type:"warning",message:"SVG images are not supported. Please choose a different image."}):a.startsWith("image/")?(r?.onSelect(n),t?.ui.closePanel(Nt(e))):t.ui.showNotification({type:"warning",message:`Only images are supported. Found '${a}'. Please choose a different image.`})}})})}function Nt(e){return`ly.img.ai/${e}.imageSelection`}var sl=ol;var ll="ly.img.ai";function Te(e){return`${ll}/${e}`}function cl(){return async(e,t,i)=>{console.group("[GENERATION]"),console.log("Generating with input:",JSON.stringify(e,null,2));let r,n=Date.now();try{return r=await i(e,t),r}finally{r!=null&&(console.log(`Generation took ${Date.now()-n}ms`),console.log("Generation result:",JSON.stringify(r,null,2))),console.groupEnd()}}}var br=cl;var ul=typeof global=="object"&&global&&global.Object===Object&&global,_r=ul,dl=typeof self=="object"&&self&&self.Object===Object&&self,pl=_r||dl||Function("return this")(),U=pl,gl=U.Symbol,ce=gl,vr=Object.prototype,hl=vr.hasOwnProperty,fl=vr.toString,Ee=ce?ce.toStringTag:void 0;function ml(e){var t=hl.call(e,Ee),i=e[Ee];try{e[Ee]=void 0;var r=!0}catch{}var n=fl.call(e);return r&&(t?e[Ee]=i:delete e[Ee]),n}var yl=ml,bl=Object.prototype,_l=bl.toString;function vl(e){return _l.call(e)}var wl=vl,kl="[object Null]",Il="[object Undefined]",rr=ce?ce.toStringTag:void 0;function Al(e){return e==null?e===void 0?Il:kl:rr&&rr in Object(e)?yl(e):wl(e)}var Oe=Al;function El(e){return e!=null&&typeof e=="object"}var Rt=El,gh=Array.isArray;function xl(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var wr=xl,Sl="[object AsyncFunction]",Cl="[object Function]",Ml="[object GeneratorFunction]",Tl="[object Proxy]";function Ol(e){if(!wr(e))return!1;var t=Oe(e);return t==Cl||t==Ml||t==Sl||t==Tl}var $l=Ol,jl=U["__core-js_shared__"],Pt=jl,nr=function(){var e=/[^.]+$/.exec(Pt&&Pt.keys&&Pt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Pl(e){return!!nr&&nr in e}var Dl=Pl,Ul=Function.prototype,Nl=Ul.toString;function ql(e){if(e!=null){try{return Nl.call(e)}catch{}try{return e+""}catch{}}return""}var W=ql,Bl=/[\\^$.*+?()[\]{}|]/g,Fl=/^\[object .+?Constructor\]$/,Ll=Function.prototype,zl=Object.prototype,Rl=Ll.toString,Vl=zl.hasOwnProperty,Hl=RegExp("^"+Rl.call(Vl).replace(Bl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gl(e){if(!wr(e)||Dl(e))return!1;var t=$l(e)?Hl:Fl;return t.test(W(e))}var Ql=Gl;function Kl(e,t){return e?.[t]}var Wl=Kl;function Yl(e,t){var i=Wl(e,t);return Ql(i)?i:void 0}var ue=Yl,Zl=ue(U,"WeakMap"),qt=Zl;function Xl(e,t){return e===t||e!==e&&t!==t}var Jl=Xl,ec=9007199254740991;function tc(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ec}var ic=tc,hh=Object.prototype,rc="[object Arguments]";function nc(e){return Rt(e)&&Oe(e)==rc}var or=nc,kr=Object.prototype,oc=kr.hasOwnProperty,ac=kr.propertyIsEnumerable,fh=or(function(){return arguments}())?or:function(e){return Rt(e)&&oc.call(e,"callee")&&!ac.call(e,"callee")},Ir=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ar=Ir&&typeof module=="object"&&module&&!module.nodeType&&module,sc=ar&&ar.exports===Ir,sr=sc?U.Buffer:void 0,mh=sr?sr.isBuffer:void 0,lc="[object Arguments]",cc="[object Array]",uc="[object Boolean]",dc="[object Date]",pc="[object Error]",gc="[object Function]",hc="[object Map]",fc="[object Number]",mc="[object Object]",yc="[object RegExp]",bc="[object Set]",_c="[object String]",vc="[object WeakMap]",wc="[object ArrayBuffer]",kc="[object DataView]",Ic="[object Float32Array]",Ac="[object Float64Array]",Ec="[object Int8Array]",xc="[object Int16Array]",Sc="[object Int32Array]",Cc="[object Uint8Array]",Mc="[object Uint8ClampedArray]",Tc="[object Uint16Array]",Oc="[object Uint32Array]",E={};E[Ic]=E[Ac]=E[Ec]=E[xc]=E[Sc]=E[Cc]=E[Mc]=E[Tc]=E[Oc]=!0;E[lc]=E[cc]=E[wc]=E[uc]=E[kc]=E[dc]=E[pc]=E[gc]=E[hc]=E[fc]=E[mc]=E[yc]=E[bc]=E[_c]=E[vc]=!1;function $c(e){return Rt(e)&&ic(e.length)&&!!E[Oe(e)]}var jc=$c;function Pc(e){return function(t){return e(t)}}var Dc=Pc,Ar=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=Ar&&typeof module=="object"&&module&&!module.nodeType&&module,Uc=Se&&Se.exports===Ar,Dt=Uc&&_r.process,Nc=function(){try{var e=Se&&Se.require&&Se.require("util").types;return e||Dt&&Dt.binding&&Dt.binding("util")}catch{}}(),lr=Nc,cr=lr&&lr.isTypedArray,yh=cr?Dc(cr):jc,qc=Object.prototype,bh=qc.hasOwnProperty;function Bc(e,t){return function(i){return e(t(i))}}var Fc=Bc,_h=Fc(Object.keys,Object),Lc=Object.prototype,vh=Lc.hasOwnProperty,zc=ue(Object,"create"),Ce=zc;function Rc(){this.__data__=Ce?Ce(null):{},this.size=0}var Vc=Rc;function Hc(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Gc=Hc,Qc="__lodash_hash_undefined__",Kc=Object.prototype,Wc=Kc.hasOwnProperty;function Yc(e){var t=this.__data__;if(Ce){var i=t[e];return i===Qc?void 0:i}return Wc.call(t,e)?t[e]:void 0}var Zc=Yc,Xc=Object.prototype,Jc=Xc.hasOwnProperty;function eu(e){var t=this.__data__;return Ce?t[e]!==void 0:Jc.call(t,e)}var tu=eu,iu="__lodash_hash_undefined__";function ru(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ce&&t===void 0?iu:t,this}var nu=ru;function de(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}de.prototype.clear=Vc;de.prototype.delete=Gc;de.prototype.get=Zc;de.prototype.has=tu;de.prototype.set=nu;var ur=de;function ou(){this.__data__=[],this.size=0}var au=ou;function su(e,t){for(var i=e.length;i--;)if(Jl(e[i][0],t))return i;return-1}var Ke=su,lu=Array.prototype,cu=lu.splice;function uu(e){var t=this.__data__,i=Ke(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():cu.call(t,i,1),--this.size,!0}var du=uu;function pu(e){var t=this.__data__,i=Ke(t,e);return i<0?void 0:t[i][1]}var gu=pu;function hu(e){return Ke(this.__data__,e)>-1}var fu=hu;function mu(e,t){var i=this.__data__,r=Ke(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var yu=mu;function pe(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}pe.prototype.clear=au;pe.prototype.delete=du;pe.prototype.get=gu;pe.prototype.has=fu;pe.prototype.set=yu;var We=pe,bu=ue(U,"Map"),Me=bu;function _u(){this.size=0,this.__data__={hash:new ur,map:new(Me||We),string:new ur}}var vu=_u;function wu(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ku=wu;function Iu(e,t){var i=e.__data__;return ku(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Ye=Iu;function Au(e){var t=Ye(this,e).delete(e);return this.size-=t?1:0,t}var Eu=Au;function xu(e){return Ye(this,e).get(e)}var Su=xu;function Cu(e){return Ye(this,e).has(e)}var Mu=Cu;function Tu(e,t){var i=Ye(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Ou=Tu;function ge(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ge.prototype.clear=vu;ge.prototype.delete=Eu;ge.prototype.get=Su;ge.prototype.has=Mu;ge.prototype.set=Ou;var Er=ge;function $u(){this.__data__=new We,this.size=0}var ju=$u;function Pu(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Du=Pu;function Uu(e){return this.__data__.get(e)}var Nu=Uu;function qu(e){return this.__data__.has(e)}var Bu=qu,Fu=200;function Lu(e,t){var i=this.__data__;if(i instanceof We){var r=i.__data__;if(!Me||r.length<Fu-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Er(r)}return i.set(e,t),this.size=i.size,this}var zu=Lu;function $e(e){var t=this.__data__=new We(e);this.size=t.size}$e.prototype.clear=ju;$e.prototype.delete=Du;$e.prototype.get=Nu;$e.prototype.has=Bu;$e.prototype.set=zu;var Ru=Object.prototype,wh=Ru.propertyIsEnumerable,Vu=ue(U,"DataView"),Bt=Vu,Hu=ue(U,"Promise"),Ft=Hu,Gu=ue(U,"Set"),Lt=Gu,dr="[object Map]",Qu="[object Object]",pr="[object Promise]",gr="[object Set]",hr="[object WeakMap]",fr="[object DataView]",Ku=W(Bt),Wu=W(Me),Yu=W(Ft),Zu=W(Lt),Xu=W(qt),le=Oe;(Bt&&le(new Bt(new ArrayBuffer(1)))!=fr||Me&&le(new Me)!=dr||Ft&&le(Ft.resolve())!=pr||Lt&&le(new Lt)!=gr||qt&&le(new qt)!=hr)&&(le=function(e){var t=Oe(e),i=t==Qu?e.constructor:void 0,r=i?W(i):"";if(r)switch(r){case Ku:return fr;case Wu:return dr;case Yu:return pr;case Zu:return gr;case Xu:return hr}return t});var kh=U.Uint8Array,Ju="__lodash_hash_undefined__";function ed(e){return this.__data__.set(e,Ju),this}var td=ed;function id(e){return this.__data__.has(e)}var rd=id;function zt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Er;++t<i;)this.add(e[t])}zt.prototype.add=zt.prototype.push=td;zt.prototype.has=rd;var mr=ce?ce.prototype:void 0,Ih=mr?mr.valueOf:void 0,nd=Object.prototype,Ah=nd.hasOwnProperty,od=Object.prototype,Eh=od.hasOwnProperty,xh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Sh=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Ch=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function ad(e,t){if(e.startsWith("buffer:")){let i=await t.editor.getMimeType(e),r=t.editor.getBufferLength(e),n=t.editor.getBufferData(e,0,r),o=new Blob([n],{type:i});return URL.createObjectURL(o)}else return e}async function Ze(e,t,i){let r,n=t.block.getFill(e),o=t.block.getSourceSet(n,"fill/image/sourceSet"),[a]=o;if(a==null){if(r=t.block.getString(n,"fill/image/imageFileURI"),r==null)throw new Error("No image source/uri found")}else r=a.uri;if(i?.throwErrorIfSvg&&await t.editor.getMimeType(r)==="image/svg+xml")throw new Error("SVG images are not supported");return ad(r,t)}var Ut="@imgly/plugin-ai-generation",Mh=`
71
+ `,$t=class{constructor(e,t=[]){this.id=e,this.assets=t.map(i=>{if(typeof i.label=="string"&&!(i.label&&typeof i.label=="object")){let r=i;return{id:r.id,label:{en:r.label},meta:r.thumbUri?{...r.meta??{},thumbUri:r.thumbUri}:r.meta}}return i}),this.activeAssetIds=new Set}async findAssets(e){let{page:t,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:s,excludeGroups:c,sortingOrder:u,sortKey:l}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(p=>p.groups&&s.some(h=>p.groups?.includes(h)))),c&&c.length>0&&(d=d.filter(p=>!p.groups||!c.some(h=>p.groups?.includes(h)))),o){let p=o.toLowerCase();d=d.filter(h=>{let v=h.label?.[r]?.toLowerCase(),b=h.tags?.[r]||[];return v&&v.includes(p)||b.some(C=>C.toLowerCase().includes(p))})}if(a&&a.length>0){let p=Array.isArray(a)?a:[a];d=d.filter(h=>{let v=h.tags?.[r]||[];return p.some(b=>v.includes(b))})}n&&d.sort((p,h)=>{let v=this.activeAssetIds.has(p.id),b=this.activeAssetIds.has(h.id);return v&&!b?-1:!v&&b?1:0}),l&&l!=="id"?d.sort((p,h)=>{let v=p.meta?.[l],b=h.meta?.[l];return v===void 0?1:b===void 0?-1:typeof v=="string"&&typeof b=="string"?u==="Descending"?b.localeCompare(v):v.localeCompare(b):typeof v=="number"&&typeof b=="number"?u==="Descending"?b-v:v-b:0}):l==="id"&&d.sort((p,h)=>u==="Descending"?h.id.localeCompare(p.id):p.id.localeCompare(h.id));let f=d.length,g=t*i,m=g+i,_=d.slice(g,m).map(p=>({id:p.id,groups:p.groups,meta:p.meta,payload:p.payload,locale:r,label:p.label?.[r],tags:p.tags?.[r],active:this.activeAssetIds.has(p.id)})),w=m<f?t+1:void 0;return{assets:_,currentPage:t,nextPage:w,total:f}}updateLabel(e,t,i){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[i]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:i})=>i===e);if(t)return{id:t.id,label:t.label?.en||"",thumbUri:t.meta?.thumbUri}}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(i=>i.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(i=>i.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(i=>e.add(i))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var so=typeof global=="object"&&global&&global.Object===Object&&global,Ki=so,lo=typeof self=="object"&&self&&self.Object===Object&&self,co=Ki||lo||Function("return this")(),D=co,uo=D.Symbol,re=uo,Wi=Object.prototype,po=Wi.hasOwnProperty,go=Wi.toString,_e=re?re.toStringTag:void 0;function ho(e){var t=po.call(e,_e),i=e[_e];try{e[_e]=void 0;var r=!0}catch{}var n=go.call(e);return r&&(t?e[_e]=i:delete e[_e]),n}var fo=ho,mo=Object.prototype,yo=mo.toString;function bo(e){return yo.call(e)}var _o=bo,vo="[object Null]",wo="[object Undefined]",Pi=re?re.toStringTag:void 0;function ko(e){return e==null?e===void 0?wo:vo:Pi&&Pi in Object(e)?fo(e):_o(e)}var Ie=ko;function Io(e){return e!=null&&typeof e=="object"}var Ot=Io,ah=Array.isArray;function Ao(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Yi=Ao,xo="[object AsyncFunction]",Eo="[object Function]",So="[object GeneratorFunction]",Co="[object Proxy]";function To(e){if(!Yi(e))return!1;var t=Ie(e);return t==Eo||t==So||t==xo||t==Co}var Mo=To,$o=D["__core-js_shared__"],At=$o,Di=function(){var e=/[^.]+$/.exec(At&&At.keys&&At.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Oo(e){return!!Di&&Di in e}var jo=Oo,Po=Function.prototype,Do=Po.toString;function Uo(e){if(e!=null){try{return Do.call(e)}catch{}try{return e+""}catch{}}return""}var K=Uo,No=/[\\^$.*+?()[\]{}|]/g,qo=/^\[object .+?Constructor\]$/,Bo=Function.prototype,Lo=Object.prototype,Fo=Bo.toString,zo=Lo.hasOwnProperty,Ro=RegExp("^"+Fo.call(zo).replace(No,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vo(e){if(!Yi(e)||jo(e))return!1;var t=Mo(e)?Ro:qo;return t.test(K(e))}var Ho=Vo;function Go(e,t){return e?.[t]}var Qo=Go;function Ko(e,t){var i=Qo(e,t);return Ho(i)?i:void 0}var ne=Ko,Wo=ne(D,"WeakMap"),Et=Wo;function Yo(e,t){return e===t||e!==e&&t!==t}var Zo=Yo,Xo=9007199254740991;function Jo(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Xo}var ea=Jo;var sh=Object.prototype;var ta="[object Arguments]";function ia(e){return Ot(e)&&Ie(e)==ta}var Ui=ia,Zi=Object.prototype,ra=Zi.hasOwnProperty,na=Zi.propertyIsEnumerable,lh=Ui(function(){return arguments}())?Ui:function(e){return Ot(e)&&ra.call(e,"callee")&&!na.call(e,"callee")};var Xi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ni=Xi&&typeof module=="object"&&module&&!module.nodeType&&module,oa=Ni&&Ni.exports===Xi,qi=oa?D.Buffer:void 0,ch=qi?qi.isBuffer:void 0;var aa="[object Arguments]",sa="[object Array]",la="[object Boolean]",ca="[object Date]",ua="[object Error]",da="[object Function]",pa="[object Map]",ga="[object Number]",ha="[object Object]",fa="[object RegExp]",ma="[object Set]",ya="[object String]",ba="[object WeakMap]",_a="[object ArrayBuffer]",va="[object DataView]",wa="[object Float32Array]",ka="[object Float64Array]",Ia="[object Int8Array]",Aa="[object Int16Array]",xa="[object Int32Array]",Ea="[object Uint8Array]",Sa="[object Uint8ClampedArray]",Ca="[object Uint16Array]",Ta="[object Uint32Array]",A={};A[wa]=A[ka]=A[Ia]=A[Aa]=A[xa]=A[Ea]=A[Sa]=A[Ca]=A[Ta]=!0;A[aa]=A[sa]=A[_a]=A[la]=A[va]=A[ca]=A[ua]=A[da]=A[pa]=A[ga]=A[ha]=A[fa]=A[ma]=A[ya]=A[ba]=!1;function Ma(e){return Ot(e)&&ea(e.length)&&!!A[Ie(e)]}var $a=Ma;function Oa(e){return function(t){return e(t)}}var ja=Oa,Ji=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ve=Ji&&typeof module=="object"&&module&&!module.nodeType&&module,Pa=ve&&ve.exports===Ji,xt=Pa&&Ki.process,Da=function(){try{var e=ve&&ve.require&&ve.require("util").types;return e||xt&&xt.binding&&xt.binding("util")}catch{}}(),Bi=Da,Li=Bi&&Bi.isTypedArray,uh=Li?ja(Li):$a;var Ua=Object.prototype,dh=Ua.hasOwnProperty;function Na(e,t){return function(i){return e(t(i))}}var qa=Na,ph=qa(Object.keys,Object);var Ba=Object.prototype,gh=Ba.hasOwnProperty;var La=ne(Object,"create"),we=La;function Fa(){this.__data__=we?we(null):{},this.size=0}var za=Fa;function Ra(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Va=Ra,Ha="__lodash_hash_undefined__",Ga=Object.prototype,Qa=Ga.hasOwnProperty;function Ka(e){var t=this.__data__;if(we){var i=t[e];return i===Ha?void 0:i}return Qa.call(t,e)?t[e]:void 0}var Wa=Ka,Ya=Object.prototype,Za=Ya.hasOwnProperty;function Xa(e){var t=this.__data__;return we?t[e]!==void 0:Za.call(t,e)}var Ja=Xa,es="__lodash_hash_undefined__";function ts(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=we&&t===void 0?es:t,this}var is=ts;function oe(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}oe.prototype.clear=za;oe.prototype.delete=Va;oe.prototype.get=Wa;oe.prototype.has=Ja;oe.prototype.set=is;var Fi=oe;function rs(){this.__data__=[],this.size=0}var ns=rs;function os(e,t){for(var i=e.length;i--;)if(Zo(e[i][0],t))return i;return-1}var He=os,as=Array.prototype,ss=as.splice;function ls(e){var t=this.__data__,i=He(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():ss.call(t,i,1),--this.size,!0}var cs=ls;function us(e){var t=this.__data__,i=He(t,e);return i<0?void 0:t[i][1]}var ds=us;function ps(e){return He(this.__data__,e)>-1}var gs=ps;function hs(e,t){var i=this.__data__,r=He(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var fs=hs;function ae(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ae.prototype.clear=ns;ae.prototype.delete=cs;ae.prototype.get=ds;ae.prototype.has=gs;ae.prototype.set=fs;var Ge=ae,ms=ne(D,"Map"),ke=ms;function ys(){this.size=0,this.__data__={hash:new Fi,map:new(ke||Ge),string:new Fi}}var bs=ys;function _s(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var vs=_s;function ws(e,t){var i=e.__data__;return vs(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Qe=ws;function ks(e){var t=Qe(this,e).delete(e);return this.size-=t?1:0,t}var Is=ks;function As(e){return Qe(this,e).get(e)}var xs=As;function Es(e){return Qe(this,e).has(e)}var Ss=Es;function Cs(e,t){var i=Qe(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Ts=Cs;function se(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}se.prototype.clear=bs;se.prototype.delete=Is;se.prototype.get=xs;se.prototype.has=Ss;se.prototype.set=Ts;var er=se;function Ms(){this.__data__=new Ge,this.size=0}var $s=Ms;function Os(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var js=Os;function Ps(e){return this.__data__.get(e)}var Ds=Ps;function Us(e){return this.__data__.has(e)}var Ns=Us,qs=200;function Bs(e,t){var i=this.__data__;if(i instanceof Ge){var r=i.__data__;if(!ke||r.length<qs-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new er(r)}return i.set(e,t),this.size=i.size,this}var Ls=Bs;function Ae(e){var t=this.__data__=new Ge(e);this.size=t.size}Ae.prototype.clear=$s;Ae.prototype.delete=js;Ae.prototype.get=Ds;Ae.prototype.has=Ns;Ae.prototype.set=Ls;var Fs=Object.prototype,hh=Fs.propertyIsEnumerable;var zs=ne(D,"DataView"),St=zs,Rs=ne(D,"Promise"),Ct=Rs,Vs=ne(D,"Set"),Tt=Vs,zi="[object Map]",Hs="[object Object]",Ri="[object Promise]",Vi="[object Set]",Hi="[object WeakMap]",Gi="[object DataView]",Gs=K(St),Qs=K(ke),Ks=K(Ct),Ws=K(Tt),Ys=K(Et),ie=Ie;(St&&ie(new St(new ArrayBuffer(1)))!=Gi||ke&&ie(new ke)!=zi||Ct&&ie(Ct.resolve())!=Ri||Tt&&ie(new Tt)!=Vi||Et&&ie(new Et)!=Hi)&&(ie=function(e){var t=Ie(e),i=t==Hs?e.constructor:void 0,r=i?K(i):"";if(r)switch(r){case Gs:return Gi;case Qs:return zi;case Ks:return Ri;case Ws:return Vi;case Ys:return Hi}return t});var fh=D.Uint8Array;var Zs="__lodash_hash_undefined__";function Xs(e){return this.__data__.set(e,Zs),this}var Js=Xs;function el(e){return this.__data__.has(e)}var tl=el;function Mt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new er;++t<i;)this.add(e[t])}Mt.prototype.add=Mt.prototype.push=Js;Mt.prototype.has=tl;var Qi=re?re.prototype:void 0,mh=Qi?Qi.valueOf:void 0;var il=Object.prototype,yh=il.hasOwnProperty;var rl=Object.prototype,bh=rl.hasOwnProperty;var _h=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),vh=new RegExp(/[A-Fa-f0-9]{1}/,"g"),wh=new RegExp(/[A-Fa-f0-9]{2}/,"g");function jt(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}async function nl(e,t){if(e.startsWith("buffer:")){let i=await t.editor.getMimeType(e),r=t.editor.getBufferLength(e),n=t.editor.getBufferData(e,0,r),o=new Blob([n],{type:i});return URL.createObjectURL(o)}else return e}async function tr(e,t){let i=await nl(e,t);return new Promise((r,n)=>{let o=new Image;o.onload=()=>{r({width:o.width,height:o.height})},o.onerror=n,o.src=i})}var ir={Formats:ao};function ol(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=Nt(e);return i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Image To Change"}}),al(e,i),{[r]:(o,a)=>{let{builder:s,experimental:{global:c},payload:u}=o,l=u?.url??t.defaultUrl,d=c(`${e}.${a.id}`,l);return s.MediaPreview(a.id,{preview:{type:"image",uri:d.value},action:{label:"Select Image",onClick:()=>{i?.ui.openPanel(n,{payload:{onSelect:f=>{f.meta?.uri!=null&&d.setValue(f.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:d.value})}}}function al(e,t){t?.ui.registerPanel(Nt(e),({builder:i,payload:r})=>{i.Library(`${e}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let a=await t.engine.editor.getMimeType(o);a==="image/svg+xml"?t.ui.showNotification({type:"warning",message:"SVG images are not supported. Please choose a different image."}):a.startsWith("image/")?(r?.onSelect(n),t?.ui.closePanel(Nt(e))):t.ui.showNotification({type:"warning",message:`Only images are supported. Found '${a}'. Please choose a different image.`})}})})}function Nt(e){return`ly.img.ai/${e}.imageSelection`}var sl=ol,ll=class{constructor(e,t=[]){this.id=e,this.assets=t.map(i=>{if(typeof i.label=="string"&&!(i.label&&typeof i.label=="object")){let r=i;return{id:r.id,label:{en:r.label},meta:r.thumbUri?{...r.meta??{},thumbUri:r.thumbUri}:r.meta}}return i}),this.activeAssetIds=new Set}async findAssets(e){let{page:t,perPage:i,locale:r="en",sortActiveFirst:n,query:o,tags:a,groups:s,excludeGroups:c,sortingOrder:u,sortKey:l}=e,d=[...this.assets];if(s&&s.length>0&&(d=d.filter(p=>p.groups&&s.some(h=>p.groups?.includes(h)))),c&&c.length>0&&(d=d.filter(p=>!p.groups||!c.some(h=>p.groups?.includes(h)))),o){let p=o.toLowerCase();d=d.filter(h=>{let v=h.label?.[r]?.toLowerCase(),b=h.tags?.[r]||[];return v&&v.includes(p)||b.some(C=>C.toLowerCase().includes(p))})}if(a&&a.length>0){let p=Array.isArray(a)?a:[a];d=d.filter(h=>{let v=h.tags?.[r]||[];return p.some(b=>v.includes(b))})}n&&d.sort((p,h)=>{let v=this.activeAssetIds.has(p.id),b=this.activeAssetIds.has(h.id);return v&&!b?-1:!v&&b?1:0}),l&&l!=="id"?d.sort((p,h)=>{let v=p.meta?.[l],b=h.meta?.[l];return v===void 0?1:b===void 0?-1:typeof v=="string"&&typeof b=="string"?u==="Descending"?b.localeCompare(v):v.localeCompare(b):typeof v=="number"&&typeof b=="number"?u==="Descending"?b-v:v-b:0}):l==="id"&&d.sort((p,h)=>u==="Descending"?h.id.localeCompare(p.id):p.id.localeCompare(h.id));let f=d.length,g=t*i,m=g+i,_=d.slice(g,m).map(p=>({id:p.id,groups:p.groups,meta:p.meta,payload:p.payload,locale:r,label:p.label?.[r],tags:p.tags?.[r],active:this.activeAssetIds.has(p.id)})),w=m<f?t+1:void 0;return{assets:_,currentPage:t,nextPage:w,total:f}}updateLabel(e,t,i){this.assets.forEach(r=>{r.id===e&&(r.label=r.label||{},r.label[i]=t)})}getAssetSelectValue(e){let t=this.assets.find(({id:i})=>i===e);if(t)return{id:t.id,label:t.label?.en||"",thumbUri:t.meta?.thumbUri}}getAsset(e){return this.assets.find(t=>t.id===e)}setAssetActive(e){this.activeAssetIds.add(e)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(e){e.forEach(t=>this.activeAssetIds.add(t))}setAssetInactive(e){this.activeAssetIds.delete(e)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(e){return this.activeAssetIds.has(e)}addAsset(e){let t=this.assets.findIndex(i=>i.id===e.id);t>=0?this.assets[t]=e:this.assets.push(e)}removeAsset(e){let t=this.assets.findIndex(i=>i.id===e);t!==-1&&(this.assets.splice(t,1),this.activeAssetIds.delete(e))}async getGroups(){let e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(i=>e.add(i))}),Array.from(e)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var cl=typeof global=="object"&&global&&global.Object===Object&&global,br=cl,ul=typeof self=="object"&&self&&self.Object===Object&&self,dl=br||ul||Function("return this")(),U=dl,pl=U.Symbol,ce=pl,_r=Object.prototype,gl=_r.hasOwnProperty,hl=_r.toString,xe=ce?ce.toStringTag:void 0;function fl(e){var t=gl.call(e,xe),i=e[xe];try{e[xe]=void 0;var r=!0}catch{}var n=hl.call(e);return r&&(t?e[xe]=i:delete e[xe]),n}var ml=fl,yl=Object.prototype,bl=yl.toString;function _l(e){return bl.call(e)}var vl=_l,wl="[object Null]",kl="[object Undefined]",rr=ce?ce.toStringTag:void 0;function Il(e){return e==null?e===void 0?kl:wl:rr&&rr in Object(e)?ml(e):vl(e)}var Me=Il;function Al(e){return e!=null&&typeof e=="object"}var Rt=Al,Ah=Array.isArray;function xl(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var vr=xl,El="[object AsyncFunction]",Sl="[object Function]",Cl="[object GeneratorFunction]",Tl="[object Proxy]";function Ml(e){if(!vr(e))return!1;var t=Me(e);return t==Sl||t==Cl||t==El||t==Tl}var $l=Ml,Ol=U["__core-js_shared__"],Pt=Ol,nr=function(){var e=/[^.]+$/.exec(Pt&&Pt.keys&&Pt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function jl(e){return!!nr&&nr in e}var Pl=jl,Dl=Function.prototype,Ul=Dl.toString;function Nl(e){if(e!=null){try{return Ul.call(e)}catch{}try{return e+""}catch{}}return""}var W=Nl,ql=/[\\^$.*+?()[\]{}|]/g,Bl=/^\[object .+?Constructor\]$/,Ll=Function.prototype,Fl=Object.prototype,zl=Ll.toString,Rl=Fl.hasOwnProperty,Vl=RegExp("^"+zl.call(Rl).replace(ql,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hl(e){if(!vr(e)||Pl(e))return!1;var t=$l(e)?Vl:Bl;return t.test(W(e))}var Gl=Hl;function Ql(e,t){return e?.[t]}var Kl=Ql;function Wl(e,t){var i=Kl(e,t);return Gl(i)?i:void 0}var ue=Wl,Yl=ue(U,"WeakMap"),qt=Yl;function Zl(e,t){return e===t||e!==e&&t!==t}var Xl=Zl,Jl=9007199254740991;function ec(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Jl}var tc=ec,xh=Object.prototype,ic="[object Arguments]";function rc(e){return Rt(e)&&Me(e)==ic}var or=rc,wr=Object.prototype,nc=wr.hasOwnProperty,oc=wr.propertyIsEnumerable,Eh=or(function(){return arguments}())?or:function(e){return Rt(e)&&nc.call(e,"callee")&&!oc.call(e,"callee")},kr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ar=kr&&typeof module=="object"&&module&&!module.nodeType&&module,ac=ar&&ar.exports===kr,sr=ac?U.Buffer:void 0,Sh=sr?sr.isBuffer:void 0,sc="[object Arguments]",lc="[object Array]",cc="[object Boolean]",uc="[object Date]",dc="[object Error]",pc="[object Function]",gc="[object Map]",hc="[object Number]",fc="[object Object]",mc="[object RegExp]",yc="[object Set]",bc="[object String]",_c="[object WeakMap]",vc="[object ArrayBuffer]",wc="[object DataView]",kc="[object Float32Array]",Ic="[object Float64Array]",Ac="[object Int8Array]",xc="[object Int16Array]",Ec="[object Int32Array]",Sc="[object Uint8Array]",Cc="[object Uint8ClampedArray]",Tc="[object Uint16Array]",Mc="[object Uint32Array]",x={};x[kc]=x[Ic]=x[Ac]=x[xc]=x[Ec]=x[Sc]=x[Cc]=x[Tc]=x[Mc]=!0;x[sc]=x[lc]=x[vc]=x[cc]=x[wc]=x[uc]=x[dc]=x[pc]=x[gc]=x[hc]=x[fc]=x[mc]=x[yc]=x[bc]=x[_c]=!1;function $c(e){return Rt(e)&&tc(e.length)&&!!x[Me(e)]}var Oc=$c;function jc(e){return function(t){return e(t)}}var Pc=jc,Ir=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=Ir&&typeof module=="object"&&module&&!module.nodeType&&module,Dc=Se&&Se.exports===Ir,Dt=Dc&&br.process,Uc=function(){try{var e=Se&&Se.require&&Se.require("util").types;return e||Dt&&Dt.binding&&Dt.binding("util")}catch{}}(),lr=Uc,cr=lr&&lr.isTypedArray,Ch=cr?Pc(cr):Oc,Nc=Object.prototype,Th=Nc.hasOwnProperty;function qc(e,t){return function(i){return e(t(i))}}var Bc=qc,Mh=Bc(Object.keys,Object),Lc=Object.prototype,$h=Lc.hasOwnProperty,Fc=ue(Object,"create"),Ce=Fc;function zc(){this.__data__=Ce?Ce(null):{},this.size=0}var Rc=zc;function Vc(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Hc=Vc,Gc="__lodash_hash_undefined__",Qc=Object.prototype,Kc=Qc.hasOwnProperty;function Wc(e){var t=this.__data__;if(Ce){var i=t[e];return i===Gc?void 0:i}return Kc.call(t,e)?t[e]:void 0}var Yc=Wc,Zc=Object.prototype,Xc=Zc.hasOwnProperty;function Jc(e){var t=this.__data__;return Ce?t[e]!==void 0:Xc.call(t,e)}var eu=Jc,tu="__lodash_hash_undefined__";function iu(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ce&&t===void 0?tu:t,this}var ru=iu;function de(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}de.prototype.clear=Rc;de.prototype.delete=Hc;de.prototype.get=Yc;de.prototype.has=eu;de.prototype.set=ru;var ur=de;function nu(){this.__data__=[],this.size=0}var ou=nu;function au(e,t){for(var i=e.length;i--;)if(Xl(e[i][0],t))return i;return-1}var Ke=au,su=Array.prototype,lu=su.splice;function cu(e){var t=this.__data__,i=Ke(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():lu.call(t,i,1),--this.size,!0}var uu=cu;function du(e){var t=this.__data__,i=Ke(t,e);return i<0?void 0:t[i][1]}var pu=du;function gu(e){return Ke(this.__data__,e)>-1}var hu=gu;function fu(e,t){var i=this.__data__,r=Ke(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var mu=fu;function pe(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}pe.prototype.clear=ou;pe.prototype.delete=uu;pe.prototype.get=pu;pe.prototype.has=hu;pe.prototype.set=mu;var We=pe,yu=ue(U,"Map"),Te=yu;function bu(){this.size=0,this.__data__={hash:new ur,map:new(Te||We),string:new ur}}var _u=bu;function vu(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var wu=vu;function ku(e,t){var i=e.__data__;return wu(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Ye=ku;function Iu(e){var t=Ye(this,e).delete(e);return this.size-=t?1:0,t}var Au=Iu;function xu(e){return Ye(this,e).get(e)}var Eu=xu;function Su(e){return Ye(this,e).has(e)}var Cu=Su;function Tu(e,t){var i=Ye(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Mu=Tu;function ge(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ge.prototype.clear=_u;ge.prototype.delete=Au;ge.prototype.get=Eu;ge.prototype.has=Cu;ge.prototype.set=Mu;var Ar=ge;function $u(){this.__data__=new We,this.size=0}var Ou=$u;function ju(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Pu=ju;function Du(e){return this.__data__.get(e)}var Uu=Du;function Nu(e){return this.__data__.has(e)}var qu=Nu,Bu=200;function Lu(e,t){var i=this.__data__;if(i instanceof We){var r=i.__data__;if(!Te||r.length<Bu-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Ar(r)}return i.set(e,t),this.size=i.size,this}var Fu=Lu;function $e(e){var t=this.__data__=new We(e);this.size=t.size}$e.prototype.clear=Ou;$e.prototype.delete=Pu;$e.prototype.get=Uu;$e.prototype.has=qu;$e.prototype.set=Fu;var zu=Object.prototype,Oh=zu.propertyIsEnumerable,Ru=ue(U,"DataView"),Bt=Ru,Vu=ue(U,"Promise"),Lt=Vu,Hu=ue(U,"Set"),Ft=Hu,dr="[object Map]",Gu="[object Object]",pr="[object Promise]",gr="[object Set]",hr="[object WeakMap]",fr="[object DataView]",Qu=W(Bt),Ku=W(Te),Wu=W(Lt),Yu=W(Ft),Zu=W(qt),le=Me;(Bt&&le(new Bt(new ArrayBuffer(1)))!=fr||Te&&le(new Te)!=dr||Lt&&le(Lt.resolve())!=pr||Ft&&le(new Ft)!=gr||qt&&le(new qt)!=hr)&&(le=function(e){var t=Me(e),i=t==Gu?e.constructor:void 0,r=i?W(i):"";if(r)switch(r){case Qu:return fr;case Ku:return dr;case Wu:return pr;case Yu:return gr;case Zu:return hr}return t});var jh=U.Uint8Array,Xu="__lodash_hash_undefined__";function Ju(e){return this.__data__.set(e,Xu),this}var ed=Ju;function td(e){return this.__data__.has(e)}var id=td;function zt(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Ar;++t<i;)this.add(e[t])}zt.prototype.add=zt.prototype.push=ed;zt.prototype.has=id;var mr=ce?ce.prototype:void 0,Ph=mr?mr.valueOf:void 0,rd=Object.prototype,Dh=rd.hasOwnProperty,nd=Object.prototype,Uh=nd.hasOwnProperty,Nh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),qh=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Bh=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function od(e,t){if(e.startsWith("buffer:")){let i=await t.editor.getMimeType(e),r=t.editor.getBufferLength(e),n=t.editor.getBufferData(e,0,r),o=new Blob([n],{type:i});return URL.createObjectURL(o)}else return e}async function Ze(e,t,i){let r,n=t.block.getFill(e),o=t.block.getSourceSet(n,"fill/image/sourceSet"),[a]=o;if(a==null){if(r=t.block.getString(n,"fill/image/imageFileURI"),r==null)throw new Error("No image source/uri found")}else r=a.uri;if(i?.throwErrorIfSvg&&await t.editor.getMimeType(r)==="image/svg+xml")throw new Error("SVG images are not supported");return od(r,t)}function ad(e){return e!==void 0}var sd=ad;function ld(e,t){let{cesdk:i}=t;if(i==null)return{};let r=t.propertyKey??"style",n=ud(e);i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${e}.${r}`]:"Style"}});let o=pd({baseURL:t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0}),a=o;t.styles!=null&&(Array.isArray(t.styles)?a=t.styles:typeof t.styles=="function"&&(a=t.styles(o)));let s=gd({cesdk:i,providerId:e,styles:a}),c=s.id;return hd(s,{cesdk:i}),cd({providerId:e,cesdk:i,panelId:n,entryId:c}),{[t.propertyKeyForPrompt??"prompt"]:(u,l)=>{let d=u.state("prompt","");return u.builder.TextArea(`${l.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??"prompt",placeholder:t.i18n?.prompt?.placeholder,...d}),()=>{let[f]=s.getActiveAssetIds(),g=s.getAsset(f);return{id:l.id,type:"string",value:g?.meta?.prompt==null?d.value:`${d.value}; ${g.meta.prompt}`}}},[r]:(u,l)=>{let{builder:d,state:f}=u;if(a.length>0){let g=f("style",a[0]);return d.Button(`${l.id}`,{inputLabel:`${e}.${l.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:g.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async _=>{s.clearActiveAssets(),s.setAssetActive(_.id),g.setValue({id:_.id,label:_.label??_.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:l.id,type:"string",value:g.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function cd(e){let{providerId:t,cesdk:i,panelId:r,entryId:n}=e;i?.ui.registerPanel(r,({builder:o,payload:a})=>{a?.onSelect==null&&o.Section(`${t}.error`,{children:()=>{o.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),o.Library(`${t}.library.image`,{entries:[n],onSelect:async s=>{a?.onSelect?.(s)}})})}function ud(e){return`ly.img.ai/${e}.styleSelection`}var dd=[{id:"none",label:"None",prompt:""},{id:"anime-celshaded",label:"Anime",prompt:"anime cel\u2011shaded, bright pastel palette, expressive eyes, clean line art "},{id:"cyberpunk-neon",label:"Cyberpunk",prompt:"cyberpunk cityscape, glowing neon signage, reflective puddles, dark atmosphere"},{id:"kodak-portra-400",label:"Kodak 400",prompt:"shot on Kodak Portra 400, soft grain, golden\u2011hour warmth, 35 mm photo"},{id:"watercolor-storybook",label:"Watercolor",prompt:"loose watercolor washes, gentle gradients, dreamy storybook feel"},{id:"dark-fantasy-realism",label:"Dark Fantasy",prompt:"dark fantasy realm, moody chiaroscuro lighting, hyper\u2011real textures"},{id:"vaporwave-retrofuturism",label:"Vaporwave",prompt:"retro\u2011futuristic vaporwave, pastel sunset gradient, chrome text, VHS scanlines"},{id:"minimal-vector-flat",label:"Vector Flat",prompt:"minimalist flat vector illustration, bold geometry, two\u2011tone palette"},{id:"pixarstyle-3d-render",label:"3D Animation",prompt:"Pixar\u2011style 3D render, oversized eyes, subtle subsurface scattering, cinematic lighting"},{id:"ukiyoe-woodblock",label:"Ukiyo\u2011e",prompt:"ukiyo\u2011e woodblock print, Edo\u2011period style, visible washi texture, limited color ink"},{id:"surreal-dreamscape",label:"Surreal",prompt:"surreal dreamscape, floating objects, impossible architecture, vivid clouds"},{id:"steampunk-victorian",label:"Steampunk",prompt:"Victorian steampunk world, ornate brass gears, leather attire, atmospheric fog"},{id:"nightstreet-photo-bokeh",label:"Night Bokeh",prompt:"night\u2011time street shot, large aperture bokeh lights, candid urban mood"},{id:"comicbook-pop-art",label:"Pop Art",prompt:"classic comic\u2011book panel, halftone shading, exaggerated action lines, CMYK pop colors"}];function pd(e){return dd.map(t=>t.id==="none"?e.includeNone?{...t,thumbUri:`${e.baseURL}/thumbnails/None.svg`}:void 0:{...t,thumbUri:`${e.baseURL}/thumbnails/${t.id}.jpeg`}).filter(sd)}var gd=e=>{let t=e.styles.map(a=>({...a,meta:{prompt:a.prompt}})),i=e.cesdk.engine.asset.findAllSources(),r=`${e.providerId}/styles`;for(;i.includes(r);)r+=`-${Math.random().toString(36).substring(2,5)}`;let n=new ll(r,t),o=e.styles[0];return n.setAssetActive(o.id),n},hd=(e,t)=>{t.cesdk.engine.asset.addSource(e),t.cesdk.ui.addAssetLibraryEntry({id:e.id,sourceIds:[e.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:i})=>i,cardLabelPosition:()=>"below"})},fd=ld;var md="ly.img.ai";function Oe(e){return`${md}/${e}`}function yd(){return async(e,t,i)=>{console.group("[GENERATION]"),console.log("Generating with input:",JSON.stringify(e,null,2));let r,n=Date.now();try{return r=await i(e,t),r}finally{r!=null&&(console.log(`Generation took ${Date.now()-n}ms`),console.log("Generation result:",JSON.stringify(r,null,2))),console.groupEnd()}}}var xr=yd;var Ut="@imgly/plugin-ai-generation",Lh=`
72
72
  <svg>
73
73
  <symbol
74
74
  fill="none"
@@ -129,7 +129,7 @@ var eo=Object.create;var $i=Object.defineProperty;var to=Object.getOwnPropertyDe
129
129
 
130
130
  </symbol>
131
131
  </svg>
132
- `;var yr="ly.img.ai.quickAction.order",xe="ly.img.ai.quickAction.actions";function sd(e,t){return{id:t,setQuickActionMenuOrder:i=>{e.ui.experimental.setGlobalStateValue(`${yr}.${t}`,i)},getQuickActionMenuOrder:()=>e.ui.experimental.getGlobalStateValue(`${yr}.${t}`,[]),registerQuickAction:i=>{if(!e.ui.experimental.hasGlobalStateValue(`${xe}.${t}`))e.ui.experimental.setGlobalStateValue(`${xe}.${t}`,{[i.id]:i});else{let r=e.ui.experimental.getGlobalStateValue(`${xe}.${t}`,{});e.ui.experimental.setGlobalStateValue(`${xe}.${t}`,{...r,[i.id]:i})}},getQuickAction:i=>e.ui.experimental.getGlobalStateValue(`${xe}.${t}`,{})[i]}}var xr=sd;function ld(e){let t=e.quickAction.id;return{confirmation:!0,lockDuringConfirmation:!1,...e.quickAction,render:({builder:i},{toggleExpand:r})=>{i.Button(`${t}.button`,{label:`ly.img.ai.quickAction.${t}`,icon:"@imgly/Sparkle",labelAlignment:"left",variant:"plain",...e.buttonOptions,onClick:r})},renderExpanded:({builder:i,state:r,experimental:n},o)=>{let a=r(`${t}.prompt`,"");i.TextArea(`${t}.textarea`,{inputLabel:`ly.img.ai.quickAction.${t}.prompt.inputLabel`,placeholder:`ly.img.ai.quickAction.${t}.prompt.placeholder`,...e.textAreaOptions,...a}),i.Separator(`${t}.separator`),n.builder.ButtonRow(`${t}.footer`,{justifyContent:"space-between",children:()=>{i.Button(`${t}.footer.cancel`,{label:"common.back",icon:"@imgly/ChevronLeft",onClick:o.toggleExpand}),i.Button(`${t}.footer.apply`,{label:`ly.img.ai.quickAction.${t}.apply`,icon:"@imgly/MagicWand",color:"accent",isDisabled:a.value.length===0,onClick:async()=>{try{let s=a.value;if(!s)return;e.onApply(s,o),o.toggleExpand(),o.closeMenu()}catch(s){o.handleGenerationError(s)}}})}})}}}var Vt=ld;function cd(e){let t=e.quickAction.id;if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return{...e.quickAction,render:({builder:i,experimental:r},n)=>{r.builder.Popover(`${t}.popover`,{label:`ly.img.ai.quickAction.${t}`,icon:"@imgly/Appearance",labelAlignment:"left",variant:"plain",trailingIcon:"@imgly/ChevronRight",placement:"right",...e.buttonOptions,children:()=>{i.Section(`${t}.popover.section`,{children:()=>{r.builder.Menu(`${t}.popover.menu`,{children:()=>{e.items.forEach(o=>{i.Button(`${t}.popover.menu.${o.id}`,{label:o.label,labelAlignment:"left",variant:"plain",icon:o.icon,onClick:async()=>{let{generate:a,closeMenu:s,handleGenerationError:l}=n;try{s();let[u]=e.cesdk.engine.block.findAllSelected(),c=await Ze(u,e.cesdk.engine,{throwErrorIfSvg:!0});if(e.mapInput){let d=e.mapInput({item:o,uri:c,blockId:u});return await a(d)}else{if(e.onApply)return await e.onApply({item:o,uri:c,blockId:u},n);throw new Error("Please provide either mapInput or onApply")}}catch(u){l(u)}}})})}})}})}})}}}var Ht=cd;function ud(){return({engine:e})=>{let t=e.block.findAllSelected();if(t==null||t.length!==1)return!1;let[i]=t;if(!e.block.supportsFill(i)||!["//ly.img.ubq/graphic","//ly.img.ubq/page"].includes(e.block.getType(i)))return!1;let r=e.block.getFill(i);return e.block.getType(r)==="//ly.img.ubq/fill/image"}}var he=ud;function dd(e){let t=e.id??"changeImage";if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return e.cesdk.i18n.setTranslations({en:{[`ly.img.ai.quickAction.${t}.apply`]:"Change",[`ly.img.ai.quickAction.${t}`]:"Edit Image...",[`ly.img.ai.quickAction.${t}.prompt.inputLabel`]:"Change image...",[`ly.img.ai.quickAction.${t}.prompt.placeholder`]:"Describe what you want to change..."}}),Vt({buttonOptions:{icon:"@imgly/plugin-ai-generation/image"},quickAction:{id:t,version:"1",confirmation:!0,lockDuringConfirmation:!1,scopes:["fill/change"],enable:he()},onApply:async(i,r)=>{let[n]=e.cesdk.engine.block.findAllSelected(),o=await Ze(n,e.cesdk.engine,{throwErrorIfSvg:!0});if(e.mapInput){let a=e.mapInput({prompt:i,uri:o,blockId:n});return r.generate(a)}else{if(e.onApply)return e.onApply({prompt:i,uri:o,blockId:n},r);throw new Error("Please provide either mapInput or onApply")}}})}var Sr=dd;function pd(e){let t=e.id??"createVariant";if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return e.cesdk.i18n.setTranslations({en:{[`ly.img.ai.quickAction.${t}.apply`]:"Create",[`ly.img.ai.quickAction.${t}`]:"Create Variant...",[`ly.img.ai.quickAction.${t}.prompt.inputLabel`]:"Describe Your Variant...",[`ly.img.ai.quickAction.${t}.prompt.placeholder`]:"e.g., same character with arms raised"}}),Vt({buttonOptions:{icon:"@imgly/ImageVariation"},quickAction:{id:t,version:"1",confirmation:!1,lockDuringConfirmation:!1,scopes:["lifecycle/duplicate","fill/change"],enable:i=>{if(!he()(i))return!1;let[r]=i.engine.block.findAllSelected();return!(!e.cesdk.feature.isEnabled("ly.img.duplicate",{engine:i.engine})||!i.engine.block.isAllowedByScope(r,"lifecycle/duplicate"))}},onApply:async(i,r)=>{let n=e.cesdk.engine,[o]=n.block.findAllSelected(),a=n.block.getType(o),s=n.block.duplicate(o);a==="//ly.img.ubq/page"&&n.block.getChildren(s).forEach(c=>{n.block.destroy(c)}),n.block.setSelected(o,!1),n.block.setSelected(s,!0);let l=n.block.getParent(s);if(l==null)throw new Error("Parent not found");if(!(l!=null&&n.block.getType(l)==="//ly.img.ubq/track"&&n.block.isPageDurationSource(l))&&a!=="//ly.img.ubq/page"){let c=n.block.getWidth(l),d=n.block.getHeight(l),h=.02*Math.min(c,d)*1;n.block.setPositionX(s,n.block.getPositionX(s)+h),n.block.setPositionY(s,n.block.getPositionY(s)+h)}let u=await Ze(s,e.cesdk.engine,{throwErrorIfSvg:!0});if(e.mapInput){let c=e.mapInput({prompt:i,uri:u,duplicatedBlockId:s});return r.generate(c)}else{if(e.onApply)return e.onApply({prompt:i,uri:u,duplicatedBlockId:s},r);throw new Error("Please provide either mapInput or onApply")}}})}var Cr=pd;function gd(e){let t=e.id??"swapBackground";if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return e.cesdk.i18n.setTranslations({en:{[`ly.img.ai.quickAction.${t}.apply`]:"Change",[`ly.img.ai.quickAction.${t}`]:"Change Background...",[`ly.img.ai.quickAction.${t}.prompt.inputLabel`]:"Change background...",[`ly.img.ai.quickAction.${t}.prompt.placeholder`]:"Describe the background you want..."}}),Vt({buttonOptions:{icon:"@imgly/plugin-ai-generation/image"},quickAction:{id:t,version:"1",confirmation:!0,lockDuringConfirmation:!1,scopes:["fill/change"],enable:he()},onApply:async(i,r)=>{let[n]=e.cesdk.engine.block.findAllSelected(),o=await Ze(n,e.cesdk.engine,{throwErrorIfSvg:!0}),a=`Swap the background to ${i}`;if(e.mapInput){let s=e.mapInput({prompt:a,uri:o,blockId:n});return r.generate(s)}else{if(e.onApply)return e.onApply({prompt:a,uri:o,blockId:n},r);throw new Error("Please provide either mapInput or onApply")}}})}var Mr=gd,Tr={ImageUrl:sl};var Or={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"]},RecraftV3Input:{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:["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"],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"]},RecraftV3Output:{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-v3/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-v3/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-v3":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/RecraftV3Input"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft-v3/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/RecraftV3Output"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var fd={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 Xe(e){return fd[e]}var Gt=[{id:"realistic_image",label:"Realistic Image"},{id:"digital_illustration",label:"Digital Illustration"},{id:"realistic_image/b_and_w",label:"Black & White"},{id:"realistic_image/hard_flash",label:"Hard Flash"},{id:"realistic_image/hdr",label:"HDR"},{id:"realistic_image/natural_light",label:"Natural Light"},{id:"realistic_image/studio_portrait",label:"Studio Portrait"},{id:"realistic_image/enterprise",label:"Enterprise"},{id:"realistic_image/motion_blur",label:"Motion Blur"},{id:"realistic_image/evening_light",label:"Evening Light"},{id:"realistic_image/faded_nostalgia",label:"Faded Nostalgia"},{id:"realistic_image/forest_life",label:"Forest Life"},{id:"realistic_image/mystic_naturalism",label:"Mystic Naturalism"},{id:"realistic_image/natural_tones",label:"Natural Tones"},{id:"realistic_image/organic_calm",label:"Organic Calm"},{id:"realistic_image/real_life_glow",label:"Real Life Glow"},{id:"realistic_image/retro_realism",label:"Retro Realism"},{id:"realistic_image/retro_snapshot",label:"Retro Snapshot"},{id:"realistic_image/urban_drama",label:"Urban Drama"},{id:"realistic_image/village_realism",label:"Village Realism"},{id:"realistic_image/warm_folk",label:"Warm Folk"},{id:"digital_illustration/pixel_art",label:"Pixel Art"},{id:"digital_illustration/hand_drawn",label:"Hand Drawn"},{id:"digital_illustration/grain",label:"Grain"},{id:"digital_illustration/infantile_sketch",label:"Infantile Sketch"},{id:"digital_illustration/2d_art_poster",label:"2D Art Poster"},{id:"digital_illustration/handmade_3d",label:"Handmade 3D"},{id:"digital_illustration/hand_drawn_outline",label:"Hand Drawn Outline"},{id:"digital_illustration/engraving_color",label:"Engraving Color"},{id:"digital_illustration/2d_art_poster_2",label:"2D Art Poster 2"},{id:"digital_illustration/antiquarian",label:"Antiquarian"},{id:"digital_illustration/bold_fantasy",label:"Bold Fantasy"},{id:"digital_illustration/child_book",label:"Child Book"},{id:"digital_illustration/child_books",label:"Child Books"},{id:"digital_illustration/cover",label:"Cover"},{id:"digital_illustration/crosshatch",label:"Crosshatch"},{id:"digital_illustration/digital_engraving",label:"Digital Engraving"},{id:"digital_illustration/expressionism",label:"Expressionism"},{id:"digital_illustration/freehand_details",label:"Freehand Details"},{id:"digital_illustration/grain_20",label:"Grain 20"},{id:"digital_illustration/graphic_intensity",label:"Graphic Intensity"},{id:"digital_illustration/hard_comics",label:"Hard Comics"},{id:"digital_illustration/long_shadow",label:"Long Shadow"},{id:"digital_illustration/modern_folk",label:"Modern Folk"},{id:"digital_illustration/multicolor",label:"Multicolor"},{id:"digital_illustration/neon_calm",label:"Neon Calm"},{id:"digital_illustration/noir",label:"Noir"},{id:"digital_illustration/nostalgic_pastel",label:"Nostalgic Pastel"},{id:"digital_illustration/outline_details",label:"Outline Details"},{id:"digital_illustration/pastel_gradient",label:"Pastel Gradient"},{id:"digital_illustration/pastel_sketch",label:"Pastel Sketch"},{id:"digital_illustration/pop_art",label:"Pop Art"},{id:"digital_illustration/pop_renaissance",label:"Pop Renaissance"},{id:"digital_illustration/street_art",label:"Street Art"},{id:"digital_illustration/tablet_sketch",label:"Tablet Sketch"},{id:"digital_illustration/urban_glow",label:"Urban Glow"},{id:"digital_illustration/urban_sketching",label:"Urban Sketching"},{id:"digital_illustration/vanilla_dreams",label:"Vanilla Dreams"},{id:"digital_illustration/young_adult_book",label:"Young Adult Book"},{id:"digital_illustration/young_adult_book_2",label:"Young Adult Book 2"}],$h=Gt[0],Qt=[{id:"vector_illustration",label:"Vector Illustration"},{id:"vector_illustration/bold_stroke",label:"Bold Stroke"},{id:"vector_illustration/chemistry",label:"Chemistry"},{id:"vector_illustration/colored_stencil",label:"Colored Stencil"},{id:"vector_illustration/contour_pop_art",label:"Contour Pop Art"},{id:"vector_illustration/cosmics",label:"Cosmics"},{id:"vector_illustration/cutout",label:"Cutout"},{id:"vector_illustration/depressive",label:"Depressive"},{id:"vector_illustration/editorial",label:"Editorial"},{id:"vector_illustration/emotional_flat",label:"Emotional Flat"},{id:"vector_illustration/infographical",label:"Infographical"},{id:"vector_illustration/marker_outline",label:"Marker Outline"},{id:"vector_illustration/mosaic",label:"Mosaic"},{id:"vector_illustration/naivector",label:"Naive Vector"},{id:"vector_illustration/roundish_flat",label:"Roundish Flat"},{id:"vector_illustration/segmented_colors",label:"Segmented Colors"},{id:"vector_illustration/sharp_contrast",label:"Sharp Contrast"},{id:"vector_illustration/thin",label:"Thin"},{id:"vector_illustration/vector_photo",label:"Vector Photo"},{id:"vector_illustration/vivid_shapes",label:"Vivid Shapes"},{id:"vector_illustration/engraving",label:"Engraving"},{id:"vector_illustration/line_art",label:"Line Art"},{id:"vector_illustration/line_circuit",label:"Line Circuit"},{id:"vector_illustration/linocut",label:"Linocut"}],jh=Qt[0],md=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`});function Kt(e,t){return md(`${t}thumbnails/`)[e]}var Ti=ji(Ci());var Mi=ji(Ci());function kt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function Yn(e,t){if(e!=null){if(e.startsWith("blob:")){let i=t!=null?await t.engine.editor.getMimeType(e):"image/png",n=await(await fetch(e)).blob(),o=new File([n],`image.${jt(i)}`,{type:i});return Mi.fal.storage.upload(o)}if(t!=null&&e.startsWith("buffer:")){let i=await t.engine.editor.getMimeType(e),r=t.engine.editor.getBufferLength(e),n=t.engine.editor.getBufferData(e,0,r),o=new File([n],`image.${jt(i)}`,{type:i});return Mi.fal.storage.upload(o)}return e}}function zg(e,t){let i=e.middleware??[];t.debug&&i.unshift(br());let r={id:e.modelKey,kind:"image",name:e.name,initialize:async n=>{Ti.fal.config({proxyUrl:t.proxyUrl}),e.initialize?.(n)},input:{quickActions:{actions:e.quickActions??[]},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?Tr.ImageUrl(e.modelKey,{cesdk:e.cesdk}):{},...e.renderCustomProperty},getBlockInput:n=>{if(e.getBlockInput!=null)return e.getBlockInput(n);if(e.getImageSize!=null){let{width:o,height:a}=e.getImageSize(n);return Promise.resolve({image:{width:o,height:a}})}if(n.image_size!=null&&kt(n.image_size))return Promise.resolve({image:{width:n.image_size.width??512,height:n.image_size.height??512}});if(n.image_size!=null&&typeof n.image_size=="string"){let o=Xe(n.image_size);return Promise.resolve({image:o})}throw new Error("getBlockInput or getImageSize must be provided")},userFlow:e.useFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:"@imgly/indexedDB",generate:async(n,{abortSignal:o})=>{let a=await Yn(n.image_url,e.cesdk),s=await Ti.fal.subscribe(e.modelKey,{abortSignal:o,input:a!=null?{...n,image_url:a}:n,logs:!0}),l=s?.data?.images;if(l!=null&&Array.isArray(l)){let c=l[0]?.url;if(c!=null)return{kind:"image",url:c}}else{let u=s?.data?.image;if(u!=null){let c=u?.url;if(c!=null)return{kind:"image",url:c}}}throw console.error("Cannot extract generated image from response:",s),new Error("Cannot find generated image")}}};return t.debug&&console.log("Created Provider:",r),r}var It=zg;var Re,Ve;function Zn(e){return async({cesdk:t})=>Rg(t,e)}function Rg(e,t){let i="fal-ai/recraft-v3",r=`${i}/styles/image`,n=`${i}/styles/vector`,o=t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/";return e.ui.addIconSet("@imgly/plugin/formats",ir.Formats),Re=new Ot(r,Gt.map(({id:a,label:s})=>({id:a,label:s,thumbUri:Kt(a,o)}))),Ve=new Ot(n,Qt.map(({id:a,label:s})=>({id:a,label:s,thumbUri:Kt(a,o)}))),Re.setAssetActive("realistic_image"),Ve.setAssetActive("vector_illustration"),e.engine.asset.addSource(Re),e.engine.asset.addSource(Ve),e.ui.addAssetLibraryEntry({id:r,sourceIds:[r],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:a})=>a,cardLabelPosition:()=>"below"}),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:a})=>a,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${Te(i)}.styleSelection`,({builder:a,payload:s})=>{if(s==null)return null;let l=s.generationType==="image"?[r]:[n];a.Library(`${i}.library.style`,{entries:l,onSelect:async u=>{s.onSelect(u)}})}),e.i18n.setTranslations({en:{[`panel.${Te("fal-ai/recraft-v3")}.styleSelection`]:"Style Selection",[`${i}.style`]:"Style",[`${i}.style.type`]:"Type",[`${i}.style.type.image`]:"Image",[`${i}.style.type.vector`]:"Vector"}}),It({modelKey:i,schema:Or,inputReference:"#/components/schemas/RecraftV3Input",middleware:t.middleware??[],userFlow:"placeholder",renderCustomProperty:{style:({builder:a,state:s},l)=>{let u=s("type","image"),c=s("style/image",{id:"realistic_image",label:"Realistic Image"}),d=s("style/vector",{id:"vector_illustration",label:"Vector Illustration"}),h=u.value==="image"?c:d;return a.ButtonGroup(`${l.id}.type`,{inputLabel:`${i}.${l.id}.type`,children:()=>{a.Button(`${l.id}.type.image`,{label:`${i}.${l.id}.type.image`,isActive:u.value==="image",onClick:()=>u.setValue("image")}),a.Button(`${l.id}.type.vector`,{label:`${i}.${l.id}.type.vector`,isActive:u.value==="vector",onClick:()=>u.setValue("vector")})}}),a.Button(`${l.id}`,{inputLabel:`${i}.${l.id}`,icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:h.value.label,labelAlignment:"left",onClick:()=>{let p={generationType:u.value,onSelect:async f=>{if(f.id==="back")return;let b={id:f.id,label:f.label??f.id};u.value==="image"?(Re.clearActiveAssets(),Re.setAssetActive(f.id),c.setValue(b)):u.value==="vector"&&(Ve.clearActiveAssets(),Ve.setAssetActive(f.id),d.setValue(b)),e.ui.closePanel(`${Te(i)}.styleSelection`)}};e.ui.openPanel(`${Te(i)}.styleSelection`,{payload:p})}}),()=>({id:l.id,type:"string",value:h.value.id??"realistic_image"})}},getBlockInput:a=>{if(kt(a.image_size))return Promise.resolve({image:{width:a.image_size.width??512,height:a.image_size.height??512}});let s=Xe(a.image_size??"square_hd");return Promise.resolve({image:s})}},t)}var Xn={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"]},GeminiFlashEditInput:{title:"GeminiImageRequest",type:"object",properties:{prompt:{maxLength:5e3,type:"string",title:"Prompt",minLength:3,description:"The prompt for image generation or editing","x-imgly-builder":{component:"TextArea"}},image_url:{title:"Image Url",type:"string",description:"Optional URL of an input image for editing. If not provided, generates a new image."}},"x-fal-order-properties":["image_url","prompt"],required:["prompt","image_url"]},GeminiFlashEditOutput:{title:"GeminiImageOutput",type:"object",properties:{description:{title:"Description",type:"string",description:"Text description or response from Gemini"},image:{description:"The generated or edited image",$ref:"#/components/schemas/Image"}},"x-fal-order-properties":["image","description"],required:["image","description"]},Image:{title:"Image",type:"object",properties:{file_size:{anyOf:[{type:"integer"},{type:"null"}],title:"File Size",description:"The size of the file in bytes."},height:{anyOf:[{type:"integer"},{type:"null"}],title:"Height",description:"The height of the image in pixels."},file_name:{anyOf:[{type:"string"},{type:"null"}],title:"File Name",description:"The name of the file. It will be auto-generated if not provided."},content_type:{anyOf:[{type:"string"},{type:"null"}],title:"Content Type",description:"The mime type of the file."},url:{title:"Url",type:"string",description:"The URL where the file can be downloaded from."},width:{anyOf:[{type:"integer"},{type:"null"}],title:"Width",description:"The width of the image in pixels."}},description:"Represents an image file.","x-fal-order-properties":["url","content_type","file_name","file_size","width","height"],required:["url"]}}},paths:{"/fal-ai/gemini-flash-edit/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/gemini-flash-edit/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/gemini-flash-edit":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/GeminiFlashEditInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/gemini-flash-edit/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/GeminiFlashEditOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Jn(e){return async({cesdk:t})=>Hg(t,e)}function Hg(e,t){let i="fal-ai/gemini-flash-edit",r=Gg(e),n=xr(e,"image");return n.setQuickActionMenuOrder([...n.getQuickActionMenuOrder(),"ly.img.separator","styleTransfer","artists","ly.img.separator","changeImage","createVariant"]),It({modelKey:i,name:"Change Image",schema:Xn,inputReference:"#/components/schemas/GeminiFlashEditInput",cesdk:e,quickActions:r,middleware:t.middleware,getBlockInput:async o=>{let{width:a,height:s}=await tr(o.image_url,e.engine);return Promise.resolve({image:{width:a,height:s}})}},t)}function Gg(e){return e.i18n.setTranslations({en:{"ly.img.ai.quickAction.styleTransfer":"Change Art Style","ly.img.ai.quickAction.artists":"Painted By"}}),[Mr({mapInput:t=>({...t,image_url:t.uri}),cesdk:e}),Sr({mapInput:t=>({...t,image_url:t.uri}),cesdk:e}),Cr({onApply:async({prompt:t,uri:i,duplicatedBlockId:r},n)=>n.generate({prompt:t,image_url:i},{blockIds:[r]}),cesdk:e}),Ht({quickAction:{id:"styleTransfer",version:"1",enable:he(),scopes:["fill/change"],confirmation:!0,lockDuringConfirmation:!1},mapInput:t=>({prompt:t.item.prompt,image_url:t.uri,blockId:t.blockId}),items:[{id:"water",label:"Watercolor Painting",prompt:"Convert to watercolor painting."},{id:"oil",label:"Oil Painting",prompt:"Render in oil painting style."},{id:"charcoal",label:"Charcoal Sketch",prompt:"Transform into a charcoal sketch."},{id:"pencil",label:"Pencil Drawing",prompt:"Apply pencil drawing effect."},{id:"pastel",label:"Pastel Artwork",prompt:"Make it look like a pastel artwork."},{id:"ink",label:"Ink Wash",prompt:"Turn into a classic ink wash painting."},{id:"stained-glass",label:"Stained Glass Window",prompt:"Stylize as a stained glass window."},{id:"japanse",label:"Japanese Woodblock Print",prompt:"Repaint as a traditional Japanese woodblock print."}],cesdk:e}),Ht({quickAction:{id:"artists",version:"1",enable:he(),scopes:["fill/change"],confirmation:!0,lockDuringConfirmation:!1},mapInput:t=>({prompt:t.item.prompt,image_url:t.uri,blockId:t.blockId}),items:[{id:"van-gogh",label:"Van Gogh",prompt:"Render this image in the style of Vincent van Gogh, using expressive brushstrokes and swirling motion."},{id:"monet",label:"Monet",prompt:"Transform this image into the soft, impressionistic style of Claude Monet with natural light and delicate color blending."},{id:"picasso",label:"Picasso",prompt:"Apply a Pablo Picasso cubist style with abstract geometry and fragmented shapes."},{id:"dali",label:"Dal\xED",prompt:"Make this image resemble Salvador Dal\xED's surrealist style, with dreamlike distortion and soft shadows."},{id:"matisse",label:"Matisse",prompt:"Stylize the image using Henri Matisse's bold colors and simplified, flowing shapes."},{id:"warhol",label:"Warhol",prompt:"Convert this image into Andy Warhol's pop art style with flat colors, repetition, and bold outlines."},{id:"michelangelo",label:"Michelangelo",prompt:"Render the image in the classical Renaissance style of Michelangelo, with dramatic anatomy and fresco-like detail."},{id:"da-vinci",label:"Da Vinci",prompt:"Make this image look like a Leonardo da Vinci painting, using soft transitions, balanced composition, and natural tones."},{id:"rembrandt",label:"Rembrandt",prompt:"Apply Rembrandt's style with rich contrast, warm tones, and dramatic use of light and shadow."},{id:"mon-drain",label:"Mondrian",prompt:"Transform the image into Piet Mondrian's abstract geometric style with grids and primary colors."},{id:"khalo",label:"Frida Kahlo",prompt:"Stylize this image in the expressive, symbolic style of Frida Kahlo with vivid colors and surreal framing."},{id:"hokusai",label:"Hokusai",prompt:"Render the image in the style of Hokusai, using bold outlines, flat color, and traditional Japanese woodblock aesthetics."}],cesdk:e})]}var Qg={RecraftV3:Zn,GeminiFlashEdit:Jn},Gf=Qg;export{Gf as default};
132
+ `;var yr="ly.img.ai.quickAction.order",Ee="ly.img.ai.quickAction.actions";function bd(e,t){return{id:t,setQuickActionMenuOrder:i=>{e.ui.experimental.setGlobalStateValue(`${yr}.${t}`,i)},getQuickActionMenuOrder:()=>e.ui.experimental.getGlobalStateValue(`${yr}.${t}`,[]),registerQuickAction:i=>{if(!e.ui.experimental.hasGlobalStateValue(`${Ee}.${t}`))e.ui.experimental.setGlobalStateValue(`${Ee}.${t}`,{[i.id]:i});else{let r=e.ui.experimental.getGlobalStateValue(`${Ee}.${t}`,{});e.ui.experimental.setGlobalStateValue(`${Ee}.${t}`,{...r,[i.id]:i})}},getQuickAction:i=>e.ui.experimental.getGlobalStateValue(`${Ee}.${t}`,{})[i]}}var Er=bd;function _d(e){let t=e.quickAction.id;return{confirmation:!0,lockDuringConfirmation:!1,...e.quickAction,render:({builder:i},{toggleExpand:r})=>{i.Button(`${t}.button`,{label:`ly.img.ai.quickAction.${t}`,icon:"@imgly/Sparkle",labelAlignment:"left",variant:"plain",...e.buttonOptions,onClick:r})},renderExpanded:({builder:i,state:r,experimental:n},o)=>{let a=r(`${t}.prompt`,"");i.TextArea(`${t}.textarea`,{inputLabel:`ly.img.ai.quickAction.${t}.prompt.inputLabel`,placeholder:`ly.img.ai.quickAction.${t}.prompt.placeholder`,...e.textAreaOptions,...a}),i.Separator(`${t}.separator`),n.builder.ButtonRow(`${t}.footer`,{justifyContent:"space-between",children:()=>{i.Button(`${t}.footer.cancel`,{label:"common.back",icon:"@imgly/ChevronLeft",onClick:o.toggleExpand}),i.Button(`${t}.footer.apply`,{label:`ly.img.ai.quickAction.${t}.apply`,icon:"@imgly/MagicWand",color:"accent",isDisabled:a.value.length===0,onClick:async()=>{try{let s=a.value;if(!s)return;e.onApply(s,o),o.toggleExpand(),o.closeMenu()}catch(s){o.handleGenerationError(s)}}})}})}}}var Vt=_d;function vd(e){let t=e.quickAction.id;if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return{...e.quickAction,render:({builder:i,experimental:r},n)=>{r.builder.Popover(`${t}.popover`,{label:`ly.img.ai.quickAction.${t}`,icon:"@imgly/Appearance",labelAlignment:"left",variant:"plain",trailingIcon:"@imgly/ChevronRight",placement:"right",...e.buttonOptions,children:()=>{i.Section(`${t}.popover.section`,{children:()=>{r.builder.Menu(`${t}.popover.menu`,{children:()=>{e.items.forEach(o=>{i.Button(`${t}.popover.menu.${o.id}`,{label:o.label,labelAlignment:"left",variant:"plain",icon:o.icon,onClick:async()=>{let{generate:a,closeMenu:s,handleGenerationError:c}=n;try{s();let[u]=e.cesdk.engine.block.findAllSelected(),l=await Ze(u,e.cesdk.engine,{throwErrorIfSvg:!0});if(e.mapInput){let d=e.mapInput({item:o,uri:l,blockId:u});return await a(d)}else{if(e.onApply)return await e.onApply({item:o,uri:l,blockId:u},n);throw new Error("Please provide either mapInput or onApply")}}catch(u){c(u)}}})})}})}})}})}}}var Ht=vd;function wd(){return({engine:e})=>{let t=e.block.findAllSelected();if(t==null||t.length!==1)return!1;let[i]=t;if(!e.block.supportsFill(i)||!["//ly.img.ubq/graphic","//ly.img.ubq/page"].includes(e.block.getType(i)))return!1;let r=e.block.getFill(i);return e.block.getType(r)==="//ly.img.ubq/fill/image"}}var he=wd;function kd(e){let t=e.id??"changeImage";if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return e.cesdk.i18n.setTranslations({en:{[`ly.img.ai.quickAction.${t}.apply`]:"Change",[`ly.img.ai.quickAction.${t}`]:"Edit Image...",[`ly.img.ai.quickAction.${t}.prompt.inputLabel`]:"Change image...",[`ly.img.ai.quickAction.${t}.prompt.placeholder`]:"Describe what you want to change..."}}),Vt({buttonOptions:{icon:"@imgly/plugin-ai-generation/image"},quickAction:{id:t,version:"1",confirmation:!0,lockDuringConfirmation:!1,scopes:["fill/change"],enable:he()},onApply:async(i,r)=>{let[n]=e.cesdk.engine.block.findAllSelected(),o=await Ze(n,e.cesdk.engine,{throwErrorIfSvg:!0});if(e.mapInput){let a=e.mapInput({prompt:i,uri:o,blockId:n});return r.generate(a)}else{if(e.onApply)return e.onApply({prompt:i,uri:o,blockId:n},r);throw new Error("Please provide either mapInput or onApply")}}})}var Sr=kd;function Id(e){let t=e.id??"createVariant";if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return e.cesdk.i18n.setTranslations({en:{[`ly.img.ai.quickAction.${t}.apply`]:"Create",[`ly.img.ai.quickAction.${t}`]:"Create Variant...",[`ly.img.ai.quickAction.${t}.prompt.inputLabel`]:"Describe Your Variant...",[`ly.img.ai.quickAction.${t}.prompt.placeholder`]:"e.g., same character with arms raised"}}),Vt({buttonOptions:{icon:"@imgly/ImageVariation"},quickAction:{id:t,version:"1",confirmation:!1,lockDuringConfirmation:!1,scopes:["lifecycle/duplicate","fill/change"],enable:i=>{if(!he()(i))return!1;let[r]=i.engine.block.findAllSelected();return!(!e.cesdk.feature.isEnabled("ly.img.duplicate",{engine:i.engine})||!i.engine.block.isAllowedByScope(r,"lifecycle/duplicate"))}},onApply:async(i,r)=>{let n=e.cesdk.engine,[o]=n.block.findAllSelected(),a=n.block.getType(o),s=n.block.duplicate(o);a==="//ly.img.ubq/page"&&n.block.getChildren(s).forEach(l=>{n.block.destroy(l)}),n.block.setSelected(o,!1),n.block.setSelected(s,!0);let c=n.block.getParent(s);if(c==null)throw new Error("Parent not found");if(!(c!=null&&n.block.getType(c)==="//ly.img.ubq/track"&&n.block.isPageDurationSource(c))&&a!=="//ly.img.ubq/page"){let l=n.block.getWidth(c),d=n.block.getHeight(c),f=.02*Math.min(l,d)*1;n.block.setPositionX(s,n.block.getPositionX(s)+f),n.block.setPositionY(s,n.block.getPositionY(s)+f)}let u=await Ze(s,e.cesdk.engine,{throwErrorIfSvg:!0});if(e.mapInput){let l=e.mapInput({prompt:i,uri:u,duplicatedBlockId:s});return r.generate(l)}else{if(e.onApply)return e.onApply({prompt:i,uri:u,duplicatedBlockId:s},r);throw new Error("Please provide either mapInput or onApply")}}})}var Cr=Id;function Ad(e){let t=e.id??"swapBackground";if(e.mapInput==null&&e.onApply==null)throw new Error(`QuickAction '${t}': Either mapInput or onApply must be provided to QuickActionChangeImage`);if(e.mapInput!=null&&e.onApply!=null)throw new Error(`QuickAction '${t}': Only one of mapInput or onApply can be provided to QuickActionChangeImage, not both`);return e.cesdk.i18n.setTranslations({en:{[`ly.img.ai.quickAction.${t}.apply`]:"Change",[`ly.img.ai.quickAction.${t}`]:"Change Background...",[`ly.img.ai.quickAction.${t}.prompt.inputLabel`]:"Change background...",[`ly.img.ai.quickAction.${t}.prompt.placeholder`]:"Describe the background you want..."}}),Vt({buttonOptions:{icon:"@imgly/plugin-ai-generation/image"},quickAction:{id:t,version:"1",confirmation:!0,lockDuringConfirmation:!1,scopes:["fill/change"],enable:he()},onApply:async(i,r)=>{let[n]=e.cesdk.engine.block.findAllSelected(),o=await Ze(n,e.cesdk.engine,{throwErrorIfSvg:!0}),a=`Swap the background to ${i}`;if(e.mapInput){let s=e.mapInput({prompt:a,uri:o,blockId:n});return r.generate(s)}else{if(e.onApply)return e.onApply({prompt:a,uri:o,blockId:n},r);throw new Error("Please provide either mapInput or onApply")}}})}var Tr=Ad,Mr={ImageUrl:sl,StyleTransfer:fd};var $r={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"]},RecraftV3Input:{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:["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"],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"]},RecraftV3Output:{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-v3/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-v3/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-v3":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/RecraftV3Input"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft-v3/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/RecraftV3Output"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var Ed={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 Xe(e){return Ed[e]}var Gt=[{id:"realistic_image",label:"Realistic Image"},{id:"digital_illustration",label:"Digital Illustration"},{id:"realistic_image/b_and_w",label:"Black & White"},{id:"realistic_image/hard_flash",label:"Hard Flash"},{id:"realistic_image/hdr",label:"HDR"},{id:"realistic_image/natural_light",label:"Natural Light"},{id:"realistic_image/studio_portrait",label:"Studio Portrait"},{id:"realistic_image/enterprise",label:"Enterprise"},{id:"realistic_image/motion_blur",label:"Motion Blur"},{id:"realistic_image/evening_light",label:"Evening Light"},{id:"realistic_image/faded_nostalgia",label:"Faded Nostalgia"},{id:"realistic_image/forest_life",label:"Forest Life"},{id:"realistic_image/mystic_naturalism",label:"Mystic Naturalism"},{id:"realistic_image/natural_tones",label:"Natural Tones"},{id:"realistic_image/organic_calm",label:"Organic Calm"},{id:"realistic_image/real_life_glow",label:"Real Life Glow"},{id:"realistic_image/retro_realism",label:"Retro Realism"},{id:"realistic_image/retro_snapshot",label:"Retro Snapshot"},{id:"realistic_image/urban_drama",label:"Urban Drama"},{id:"realistic_image/village_realism",label:"Village Realism"},{id:"realistic_image/warm_folk",label:"Warm Folk"},{id:"digital_illustration/pixel_art",label:"Pixel Art"},{id:"digital_illustration/hand_drawn",label:"Hand Drawn"},{id:"digital_illustration/grain",label:"Grain"},{id:"digital_illustration/infantile_sketch",label:"Infantile Sketch"},{id:"digital_illustration/2d_art_poster",label:"2D Art Poster"},{id:"digital_illustration/handmade_3d",label:"Handmade 3D"},{id:"digital_illustration/hand_drawn_outline",label:"Hand Drawn Outline"},{id:"digital_illustration/engraving_color",label:"Engraving Color"},{id:"digital_illustration/2d_art_poster_2",label:"2D Art Poster 2"},{id:"digital_illustration/antiquarian",label:"Antiquarian"},{id:"digital_illustration/bold_fantasy",label:"Bold Fantasy"},{id:"digital_illustration/child_book",label:"Child Book"},{id:"digital_illustration/child_books",label:"Child Books"},{id:"digital_illustration/cover",label:"Cover"},{id:"digital_illustration/crosshatch",label:"Crosshatch"},{id:"digital_illustration/digital_engraving",label:"Digital Engraving"},{id:"digital_illustration/expressionism",label:"Expressionism"},{id:"digital_illustration/freehand_details",label:"Freehand Details"},{id:"digital_illustration/grain_20",label:"Grain 20"},{id:"digital_illustration/graphic_intensity",label:"Graphic Intensity"},{id:"digital_illustration/hard_comics",label:"Hard Comics"},{id:"digital_illustration/long_shadow",label:"Long Shadow"},{id:"digital_illustration/modern_folk",label:"Modern Folk"},{id:"digital_illustration/multicolor",label:"Multicolor"},{id:"digital_illustration/neon_calm",label:"Neon Calm"},{id:"digital_illustration/noir",label:"Noir"},{id:"digital_illustration/nostalgic_pastel",label:"Nostalgic Pastel"},{id:"digital_illustration/outline_details",label:"Outline Details"},{id:"digital_illustration/pastel_gradient",label:"Pastel Gradient"},{id:"digital_illustration/pastel_sketch",label:"Pastel Sketch"},{id:"digital_illustration/pop_art",label:"Pop Art"},{id:"digital_illustration/pop_renaissance",label:"Pop Renaissance"},{id:"digital_illustration/street_art",label:"Street Art"},{id:"digital_illustration/tablet_sketch",label:"Tablet Sketch"},{id:"digital_illustration/urban_glow",label:"Urban Glow"},{id:"digital_illustration/urban_sketching",label:"Urban Sketching"},{id:"digital_illustration/vanilla_dreams",label:"Vanilla Dreams"},{id:"digital_illustration/young_adult_book",label:"Young Adult Book"},{id:"digital_illustration/young_adult_book_2",label:"Young Adult Book 2"}],Vh=Gt[0],Qt=[{id:"vector_illustration",label:"Vector Illustration"},{id:"vector_illustration/bold_stroke",label:"Bold Stroke"},{id:"vector_illustration/chemistry",label:"Chemistry"},{id:"vector_illustration/colored_stencil",label:"Colored Stencil"},{id:"vector_illustration/contour_pop_art",label:"Contour Pop Art"},{id:"vector_illustration/cosmics",label:"Cosmics"},{id:"vector_illustration/cutout",label:"Cutout"},{id:"vector_illustration/depressive",label:"Depressive"},{id:"vector_illustration/editorial",label:"Editorial"},{id:"vector_illustration/emotional_flat",label:"Emotional Flat"},{id:"vector_illustration/infographical",label:"Infographical"},{id:"vector_illustration/marker_outline",label:"Marker Outline"},{id:"vector_illustration/mosaic",label:"Mosaic"},{id:"vector_illustration/naivector",label:"Naive Vector"},{id:"vector_illustration/roundish_flat",label:"Roundish Flat"},{id:"vector_illustration/segmented_colors",label:"Segmented Colors"},{id:"vector_illustration/sharp_contrast",label:"Sharp Contrast"},{id:"vector_illustration/thin",label:"Thin"},{id:"vector_illustration/vector_photo",label:"Vector Photo"},{id:"vector_illustration/vivid_shapes",label:"Vivid Shapes"},{id:"vector_illustration/engraving",label:"Engraving"},{id:"vector_illustration/line_art",label:"Line Art"},{id:"vector_illustration/line_circuit",label:"Line Circuit"},{id:"vector_illustration/linocut",label:"Linocut"}],Hh=Qt[0],Sd=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`});function Kt(e,t){return Sd(`${t}thumbnails/`)[e]}var Mi=ji(Ci());var Ti=ji(Ci());function kt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function Yn(e,t){if(e!=null){if(e.startsWith("blob:")){let i=t!=null?await t.engine.editor.getMimeType(e):"image/png",n=await(await fetch(e)).blob(),o=new File([n],`image.${jt(i)}`,{type:i});return Ti.fal.storage.upload(o)}if(t!=null&&e.startsWith("buffer:")){let i=await t.engine.editor.getMimeType(e),r=t.engine.editor.getBufferLength(e),n=t.engine.editor.getBufferData(e,0,r),o=new File([n],`image.${jt(i)}`,{type:i});return Ti.fal.storage.upload(o)}return e}}function Jg(e,t){let i=e.middleware??[];t.debug&&i.unshift(xr());let r={id:e.modelKey,kind:"image",name:e.name,initialize:async n=>{Mi.fal.config({proxyUrl:t.proxyUrl,requestMiddleware:async o=>({...o,headers:{...o.headers,...e.headers??{}}})}),e.initialize?.(n)},input:{quickActions:{actions:e.quickActions??[]},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?Mr.ImageUrl(e.modelKey,{cesdk:e.cesdk}):{},...e.renderCustomProperty},getBlockInput:n=>{if(e.getBlockInput!=null)return e.getBlockInput(n);if(e.getImageSize!=null){let{width:o,height:a}=e.getImageSize(n);return Promise.resolve({image:{width:o,height:a}})}if(n.image_size!=null&&kt(n.image_size))return Promise.resolve({image:{width:n.image_size.width??512,height:n.image_size.height??512}});if(n.image_size!=null&&typeof n.image_size=="string"){let o=Xe(n.image_size);return Promise.resolve({image:o})}throw new Error("getBlockInput or getImageSize must be provided")},userFlow:e.useFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:"@imgly/indexedDB",generate:async(n,{abortSignal:o})=>{let a=await Yn(n.image_url,e.cesdk),s=await Mi.fal.subscribe(e.modelKey,{abortSignal:o,input:a!=null?{...n,image_url:a}:n,logs:!0}),c=s?.data?.images;if(c!=null&&Array.isArray(c)){let l=c[0]?.url;if(l!=null)return{kind:"image",url:l}}else{let u=s?.data?.image;if(u!=null){let l=u?.url;if(l!=null)return{kind:"image",url:l}}}throw console.error("Cannot extract generated image from response:",s),new Error("Cannot find generated image")}}};return t.debug&&console.log("Created Provider:",r),r}var It=Jg;var Re,Ve;function Zn(e){return async({cesdk:t})=>eh(t,e)}function eh(e,t){let i="fal-ai/recraft-v3",r=`${i}/styles/image`,n=`${i}/styles/vector`,o=t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/";return e.ui.addIconSet("@imgly/plugin/formats",ir.Formats),Re=new $t(r,Gt.map(({id:a,label:s})=>({id:a,label:s,thumbUri:Kt(a,o)}))),Ve=new $t(n,Qt.map(({id:a,label:s})=>({id:a,label:s,thumbUri:Kt(a,o)}))),Re.setAssetActive("realistic_image"),Ve.setAssetActive("vector_illustration"),e.engine.asset.addSource(Re),e.engine.asset.addSource(Ve),e.ui.addAssetLibraryEntry({id:r,sourceIds:[r],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:a})=>a,cardLabelPosition:()=>"below"}),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:a})=>a,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${Oe(i)}.styleSelection`,({builder:a,payload:s})=>{if(s==null)return null;let c=s.generationType==="image"?[r]:[n];a.Library(`${i}.library.style`,{entries:c,onSelect:async u=>{s.onSelect(u)}})}),e.i18n.setTranslations({en:{[`panel.${Oe("fal-ai/recraft-v3")}.styleSelection`]:"Style Selection",[`${i}.style`]:"Style",[`${i}.style.type`]:"Type",[`${i}.style.type.image`]:"Image",[`${i}.style.type.vector`]:"Vector"}}),It({modelKey:i,schema:$r,inputReference:"#/components/schemas/RecraftV3Input",middleware:t.middleware??[],headers:t.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:a,state:s},c)=>{let u=s("type","image"),l=s("style/image",{id:"realistic_image",label:"Realistic Image"}),d=s("style/vector",{id:"vector_illustration",label:"Vector Illustration"}),f=u.value==="image"?l:d;return a.ButtonGroup(`${c.id}.type`,{inputLabel:`${i}.${c.id}.type`,children:()=>{a.Button(`${c.id}.type.image`,{label:`${i}.${c.id}.type.image`,isActive:u.value==="image",onClick:()=>u.setValue("image")}),a.Button(`${c.id}.type.vector`,{label:`${i}.${c.id}.type.vector`,isActive:u.value==="vector",onClick:()=>u.setValue("vector")})}}),a.Button(`${c.id}`,{inputLabel:`${i}.${c.id}`,icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:f.value.label,labelAlignment:"left",onClick:()=>{let g={generationType:u.value,onSelect:async m=>{if(m.id==="back")return;let _={id:m.id,label:m.label??m.id};u.value==="image"?(Re.clearActiveAssets(),Re.setAssetActive(m.id),l.setValue(_)):u.value==="vector"&&(Ve.clearActiveAssets(),Ve.setAssetActive(m.id),d.setValue(_)),e.ui.closePanel(`${Oe(i)}.styleSelection`)}};e.ui.openPanel(`${Oe(i)}.styleSelection`,{payload:g})}}),()=>({id:c.id,type:"string",value:f.value.id??"realistic_image"})}},getBlockInput:a=>{if(kt(a.image_size))return Promise.resolve({image:{width:a.image_size.width??512,height:a.image_size.height??512}});let s=Xe(a.image_size??"square_hd");return Promise.resolve({image:s})}},t)}var Xn={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"]},GeminiFlashEditInput:{title:"GeminiImageRequest",type:"object",properties:{prompt:{maxLength:5e3,type:"string",title:"Prompt",minLength:3,description:"The prompt for image generation or editing","x-imgly-builder":{component:"TextArea"}},image_url:{title:"Image Url",type:"string",description:"Optional URL of an input image for editing. If not provided, generates a new image."}},"x-fal-order-properties":["image_url","prompt"],required:["prompt","image_url"]},GeminiFlashEditOutput:{title:"GeminiImageOutput",type:"object",properties:{description:{title:"Description",type:"string",description:"Text description or response from Gemini"},image:{description:"The generated or edited image",$ref:"#/components/schemas/Image"}},"x-fal-order-properties":["image","description"],required:["image","description"]},Image:{title:"Image",type:"object",properties:{file_size:{anyOf:[{type:"integer"},{type:"null"}],title:"File Size",description:"The size of the file in bytes."},height:{anyOf:[{type:"integer"},{type:"null"}],title:"Height",description:"The height of the image in pixels."},file_name:{anyOf:[{type:"string"},{type:"null"}],title:"File Name",description:"The name of the file. It will be auto-generated if not provided."},content_type:{anyOf:[{type:"string"},{type:"null"}],title:"Content Type",description:"The mime type of the file."},url:{title:"Url",type:"string",description:"The URL where the file can be downloaded from."},width:{anyOf:[{type:"integer"},{type:"null"}],title:"Width",description:"The width of the image in pixels."}},description:"Represents an image file.","x-fal-order-properties":["url","content_type","file_name","file_size","width","height"],required:["url"]}}},paths:{"/fal-ai/gemini-flash-edit/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/gemini-flash-edit/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/gemini-flash-edit":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/GeminiFlashEditInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/gemini-flash-edit/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/GeminiFlashEditOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Jn(e){return async({cesdk:t})=>ih(t,e)}function ih(e,t){let i="fal-ai/gemini-flash-edit",r=rh(e),n=Er(e,"image");return n.setQuickActionMenuOrder([...n.getQuickActionMenuOrder(),"ly.img.separator","styleTransfer","artists","ly.img.separator","changeImage","createVariant"]),It({modelKey:i,name:"Change Image",schema:Xn,inputReference:"#/components/schemas/GeminiFlashEditInput",cesdk:e,quickActions:r,middleware:t.middleware,headers:t.headers,getBlockInput:async o=>{let{width:a,height:s}=await tr(o.image_url,e.engine);return Promise.resolve({image:{width:a,height:s}})}},t)}function rh(e){return e.i18n.setTranslations({en:{"ly.img.ai.quickAction.styleTransfer":"Change Art Style","ly.img.ai.quickAction.artists":"Painted By"}}),[Tr({mapInput:t=>({...t,image_url:t.uri}),cesdk:e}),Sr({mapInput:t=>({...t,image_url:t.uri}),cesdk:e}),Cr({onApply:async({prompt:t,uri:i,duplicatedBlockId:r},n)=>n.generate({prompt:t,image_url:i},{blockIds:[r]}),cesdk:e}),Ht({quickAction:{id:"styleTransfer",version:"1",enable:he(),scopes:["fill/change"],confirmation:!0,lockDuringConfirmation:!1},mapInput:t=>({prompt:t.item.prompt,image_url:t.uri,blockId:t.blockId}),items:[{id:"water",label:"Watercolor Painting",prompt:"Convert to watercolor painting."},{id:"oil",label:"Oil Painting",prompt:"Render in oil painting style."},{id:"charcoal",label:"Charcoal Sketch",prompt:"Transform into a charcoal sketch."},{id:"pencil",label:"Pencil Drawing",prompt:"Apply pencil drawing effect."},{id:"pastel",label:"Pastel Artwork",prompt:"Make it look like a pastel artwork."},{id:"ink",label:"Ink Wash",prompt:"Turn into a classic ink wash painting."},{id:"stained-glass",label:"Stained Glass Window",prompt:"Stylize as a stained glass window."},{id:"japanse",label:"Japanese Woodblock Print",prompt:"Repaint as a traditional Japanese woodblock print."}],cesdk:e}),Ht({quickAction:{id:"artists",version:"1",enable:he(),scopes:["fill/change"],confirmation:!0,lockDuringConfirmation:!1},mapInput:t=>({prompt:t.item.prompt,image_url:t.uri,blockId:t.blockId}),items:[{id:"van-gogh",label:"Van Gogh",prompt:"Render this image in the style of Vincent van Gogh, using expressive brushstrokes and swirling motion."},{id:"monet",label:"Monet",prompt:"Transform this image into the soft, impressionistic style of Claude Monet with natural light and delicate color blending."},{id:"picasso",label:"Picasso",prompt:"Apply a Pablo Picasso cubist style with abstract geometry and fragmented shapes."},{id:"dali",label:"Dal\xED",prompt:"Make this image resemble Salvador Dal\xED's surrealist style, with dreamlike distortion and soft shadows."},{id:"matisse",label:"Matisse",prompt:"Stylize the image using Henri Matisse's bold colors and simplified, flowing shapes."},{id:"warhol",label:"Warhol",prompt:"Convert this image into Andy Warhol's pop art style with flat colors, repetition, and bold outlines."},{id:"michelangelo",label:"Michelangelo",prompt:"Render the image in the classical Renaissance style of Michelangelo, with dramatic anatomy and fresco-like detail."},{id:"da-vinci",label:"Da Vinci",prompt:"Make this image look like a Leonardo da Vinci painting, using soft transitions, balanced composition, and natural tones."},{id:"rembrandt",label:"Rembrandt",prompt:"Apply Rembrandt's style with rich contrast, warm tones, and dramatic use of light and shadow."},{id:"mon-drain",label:"Mondrian",prompt:"Transform the image into Piet Mondrian's abstract geometric style with grids and primary colors."},{id:"khalo",label:"Frida Kahlo",prompt:"Stylize this image in the expressive, symbolic style of Frida Kahlo with vivid colors and surreal framing."},{id:"hokusai",label:"Hokusai",prompt:"Render the image in the style of Hokusai, using bold outlines, flat color, and traditional Japanese woodblock aesthetics."}],cesdk:e})]}var nh={RecraftV3:Zn,GeminiFlashEdit:Jn},rm=nh;export{rm as default};
133
133
  /*! Bundled license information:
134
134
 
135
135
  @imgly/plugin-utils/dist/index.mjs: