@imgly/plugin-ai-sticker-generation-web 0.2.3 → 0.2.4

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 zn=Object.create;var xi=Object.defineProperty;var Fn=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Bn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var qn=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ln(t))!Rn.call(e,n)&&n!==i&&xi(e,n,{get:()=>t[n],enumerable:!(r=Fn(t,n))||r.enumerable});return e};var ki=(e,t,i)=>(i=e!=null?zn(Bn(e)):{},qn(t||!e||!e.__esModule?xi(i,"default",{value:e,enumerable:!0}):i,e));var Ft=k(O=>{"use strict";var nd=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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(O,"__esModule",{value:!0});O.TARGET_URL_HEADER=void 0;O.withMiddleware=od;O.withProxy=ad;function od(...e){let t=i=>typeof i=="function";return i=>nd(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 ad(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 Q=k($=>{"use strict";var yr=$&&$.__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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty($,"__esModule",{value:!0});$.ValidationError=$.ApiError=void 0;$.defaultResponseHandler=br;$.resultResponseHandler=ld;var sd="x-fal-request-id",he=class extends Error{constructor({message:t,status:i,body:r}){super(t),this.name="ApiError",this.status=i,this.body=r}};$.ApiError=he;var We=class extends he{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)}};$.ValidationError=We;function br(e){return yr(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?We:he;throw new a({message:o.message||r,status:i,body:o})}throw new he({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 ld(e){return yr(this,void 0,void 0,function*(){return{data:yield br(e),requestId:e.headers.get(sd)||""}})}});var _r=k((kh,cd)=>{cd.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 Xe=k(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.isBrowser=ud;Ze.getUserAgent=dd;function ud(){return typeof window<"u"&&typeof window.document<"u"}var Qe=null;function dd(){if(Qe!==null)return Qe;let e=_r();return Qe=`${e.name}/${e.version}`,Qe}});var Je=k(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.credentialsFromEnv=void 0;B.resolveDefaultFetch=wr;B.createConfig=yd;B.getRestApiUrl=bd;var vr=Ft(),gd=Q(),pd=Xe();function wr(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function hd(){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 fd=()=>{if(hd())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};B.credentialsFromEnv=fd;var md={credentials:B.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:gd.defaultResponseHandler};function yd(e){var t;let i=Object.assign(Object.assign(Object.assign({},md),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:wr()});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,vr.withMiddleware)(i.requestMiddleware,(0,vr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,pd.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 bd(){return"https://rest.alpha.fal.ai"}});var Z=k(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.ensureEndpointIdFormat=xr;R.parseEndpointId=vd;R.isValidUrl=wd;R.throttle=xd;R.isReact=kd;R.isPlainObject=Sd;function xr(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 vd(e){let i=xr(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 wd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function xd(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 Lt;function kd(){if(Lt===void 0){let e=new Error().stack;Lt=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return Lt}function Sd(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}});var fe=k(q=>{"use strict";var Id=q&&q.__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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})},Ed=q&&q.__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(q,"__esModule",{value:!0});q.dispatchRequest=Cd;q.buildUrl=Td;var kr=Xe(),Sr=Z(),Ad=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Cd(e){return Id(this,void 0,void 0,function*(){var t,i,r;let{targetUrl:n,input:o,config:a,options:s={}}=e,{credentials:c,requestMiddleware:d,responseHandler:l,fetch:u}=a,f=(0,kr.isBrowser)()?{}:{"User-Agent":(0,kr.getUserAgent)()},p=typeof c=="function"?c():c,{method:m,url:v,headers:w}=yield d({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}`}:{},h=Object.assign(Object.assign(Object.assign(Object.assign({},g),{Accept:"application/json","Content-Type":"application/json"}),f),w??{}),{responseHandler:_}=s,b=Ed(s,["responseHandler"]),C=yield u(v,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:{})}),!Ad&&{mode:"cors"}),{signal:s.signal,body:m.toLowerCase()!=="get"&&o?JSON.stringify(o):void 0}));return yield(_??l)(C)})}function Td(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,Sr.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${c}`;let d=(0,Sr.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${d}/${o}`.replace(/\/$/,"")}${c}`}});var Er=k(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});function Md(e){let t,i,r,n,o,a,s;return c(),{feed:d,reset:c};function c(){t=!0,i="",r=0,n=-1,o=void 0,a=void 0,s=""}function d(u){i=i?i+u:u,t&&jd(i)&&(i=i.slice(Ir.length)),t=!1;let f=i.length,p=0,m=!1;for(;p<f;){m&&(i[p]===`
2
- `&&++p,m=!1);let v=-1,w=n,g;for(let h=r;v<0&&h<f;++h)g=i[h],g===":"&&w<0?w=h-p:g==="\r"?(m=!0,v=h-p):g===`
3
- `&&(v=h-p);if(v<0){r=f-p,n=w;break}else r=0,n=-1;l(i,p,w,v),p+=v+1}p===f?i="":p>0&&(i=i.slice(p))}function l(u,f,p,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 v=p<0,w=u.slice(f,f+(v?m:p)),g=0;v?g=m:u[f+p+1]===" "?g=p+2:g=p+1;let h=f+g,_=m-g,b=u.slice(h,h+_).toString();if(w==="data")s+=b?"".concat(b,`
1
+ var Fn=Object.create;var xi=Object.defineProperty;var Ln=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var Rn=Object.getPrototypeOf,qn=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Vn=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Bn(t))!qn.call(e,n)&&n!==i&&xi(e,n,{get:()=>t[n],enumerable:!(r=Ln(t,n))||r.enumerable});return e};var ki=(e,t,i)=>(i=e!=null?Fn(Rn(e)):{},Vn(t||!e||!e.__esModule?xi(i,"default",{value:e,enumerable:!0}):i,e));var Ft=k(j=>{"use strict";var od=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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(j,"__esModule",{value:!0});j.TARGET_URL_HEADER=void 0;j.withMiddleware=ad;j.withProxy=sd;function ad(...e){let t=i=>typeof i=="function";return i=>od(this,void 0,void 0,function*(){let r=Object.assign({},i);for(let n of e.filter(t))r=yield n(r);return r})}j.TARGET_URL_HEADER="x-fal-target-url";function sd(e){let t=i=>Promise.resolve(i);return typeof window>"u"?t:i=>i.headers&&j.TARGET_URL_HEADER in i?t(i):Promise.resolve(Object.assign(Object.assign({},i),{url:e.targetUrl,headers:Object.assign(Object.assign({},i.headers||{}),{[j.TARGET_URL_HEADER]:i.url})}))}});var W=k(O=>{"use strict";var br=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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(O,"__esModule",{value:!0});O.ValidationError=O.ApiError=void 0;O.defaultResponseHandler=_r;O.resultResponseHandler=cd;var ld="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}};O.ApiError=fe;var Qe=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)}};O.ValidationError=Qe;function _r(e){return br(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?Qe: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 cd(e){return br(this,void 0,void 0,function*(){return{data:yield _r(e),requestId:e.headers.get(ld)||""}})}});var vr=k((If,ud)=>{ud.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 Xe=k(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.isBrowser=dd;Ze.getUserAgent=gd;function dd(){return typeof window<"u"&&typeof window.document<"u"}var We=null;function gd(){if(We!==null)return We;let e=vr();return We=`${e.name}/${e.version}`,We}});var Je=k(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.credentialsFromEnv=void 0;B.resolveDefaultFetch=xr;B.createConfig=bd;B.getRestApiUrl=_d;var wr=Ft(),pd=W(),fd=Xe();function xr(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function hd(){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 md=()=>{if(hd())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};B.credentialsFromEnv=md;var yd={credentials:B.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:e=>Promise.resolve(e),responseHandler:pd.defaultResponseHandler};function bd(e){var t;let i=Object.assign(Object.assign(Object.assign({},yd),e),{fetch:(t=e.fetch)!==null&&t!==void 0?t:xr()});e.proxyUrl&&(i=Object.assign(Object.assign({},i),{requestMiddleware:(0,wr.withMiddleware)(i.requestMiddleware,(0,wr.withProxy)({targetUrl:e.proxyUrl}))}));let{credentials:r,suppressLocalCredentialsWarning:n}=i,o=typeof r=="function"?r():r;return(0,fd.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 _d(){return"https://rest.alpha.fal.ai"}});var Z=k(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.ensureEndpointIdFormat=kr;R.parseEndpointId=wd;R.isValidUrl=xd;R.throttle=kd;R.isReact=Sd;R.isPlainObject=Id;function kr(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 vd=["workflows","comfy"];function wd(e){let i=kr(e).split("/");return vd.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 xd(e){try{let{host:t}=new URL(e);return/(fal\.(ai|run))$/.test(t)}catch{return!1}}function kd(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 Lt;function Sd(){if(Lt===void 0){let e=new Error().stack;Lt=!!e&&(e.includes("node_modules/react-dom/")||e.includes("node_modules/next/"))}return Lt}function Id(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}});var he=k(q=>{"use strict";var Ed=q&&q.__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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})},Ad=q&&q.__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(q,"__esModule",{value:!0});q.dispatchRequest=Td;q.buildUrl=Md;var Sr=Xe(),Ir=Z(),Cd=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Td(e){return Ed(this,void 0,void 0,function*(){var t,i,r;let{targetUrl:n,input:o,config:a,options:s={}}=e,{credentials:c,requestMiddleware:d,responseHandler:l,fetch:u}=a,h=(0,Sr.isBrowser)()?{}:{"User-Agent":(0,Sr.getUserAgent)()},p=typeof c=="function"?c():c,{method:m,url:v,headers:w}=yield d({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}`}:{},f=Object.assign(Object.assign(Object.assign(Object.assign({},g),{Accept:"application/json","Content-Type":"application/json"}),h),w??{}),{responseHandler:_}=s,b=Ad(s,["responseHandler"]),C=yield u(v,Object.assign(Object.assign(Object.assign(Object.assign({},b),{method:m,headers:Object.assign(Object.assign({},f),(r=b.headers)!==null&&r!==void 0?r:{})}),!Cd&&{mode:"cors"}),{signal:s.signal,body:m.toLowerCase()!=="get"&&o?JSON.stringify(o):void 0}));return yield(_??l)(C)})}function Md(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,Ir.isValidUrl)(e))return`${e.endsWith("/")?e:`${e}/`}${o}${c}`;let d=(0,Ir.ensureEndpointIdFormat)(e);return`${`https://${t.subdomain?`${t.subdomain}.`:""}fal.run/${d}/${o}`.replace(/\/$/,"")}${c}`}});var Ar=k(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});function $d(e){let t,i,r,n,o,a,s;return c(),{feed:d,reset:c};function c(){t=!0,i="",r=0,n=-1,o=void 0,a=void 0,s=""}function d(u){i=i?i+u:u,t&&jd(i)&&(i=i.slice(Er.length)),t=!1;let h=i.length,p=0,m=!1;for(;p<h;){m&&(i[p]===`
2
+ `&&++p,m=!1);let v=-1,w=n,g;for(let f=r;v<0&&f<h;++f)g=i[f],g===":"&&w<0?w=f-p:g==="\r"?(m=!0,v=f-p):g===`
3
+ `&&(v=f-p);if(v<0){r=h-p,n=w;break}else r=0,n=-1;l(i,p,w,v),p+=v+1}p===h?i="":p>0&&(i=i.slice(p))}function l(u,h,p,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 v=p<0,w=u.slice(h,h+(v?m:p)),g=0;v?g=m:u[h+p+1]===" "?g=p+2:g=p+1;let f=h+g,_=m-g,b=u.slice(f,f+_).toString();if(w==="data")s+=b?"".concat(b,`
4
4
  `):`
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 Ir=[239,187,191];function jd(e){return Ir.every((t,i)=>e.charCodeAt(i)===t)}Bt.createParser=Md});var Rt=k(V=>{"use strict";var Od=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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(V,"__esModule",{value:!0});V.TOKEN_EXPIRATION_SECONDS=void 0;V.getTemporaryAuthToken=Ud;var $d=Je(),Pd=fe(),Dd=Z();V.TOKEN_EXPIRATION_SECONDS=120;function Ud(e,t){return Od(this,void 0,void 0,function*(){let i=(0,Dd.parseEndpointId)(e),r=yield(0,Pd.dispatchRequest)({method:"POST",targetUrl:`${(0,$d.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 Vt=k(j=>{"use strict";var je=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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})},Oe=j&&j.__await||function(e){return this instanceof Oe?(this.v=e,this):new Oe(e)},Nd=j&&j.__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(m){return Promise.resolve(m).then(p,u)}}function s(p,m){r[p]&&(n[p]=function(v){return new Promise(function(w,g){o.push([p,v,w,g])>1||c(p,v)})},m&&(n[p]=m(n[p])))}function c(p,m){try{d(r[p](m))}catch(v){f(o[0][3],v)}}function d(p){p.value instanceof Oe?Promise.resolve(p.value.v).then(l,u):f(o[0][2],p)}function l(p){c("next",p)}function u(p){c("throw",p)}function f(p,m){p(m),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty(j,"__esModule",{value:!0});j.FalStream=void 0;j.createStreamingClient=Bd;var zd=Er(),Fd=Rt(),Ar=fe(),me=Q(),qt="text/event-stream",Ld=15*1e3,et=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:d,method:l="post",connectionMode:u="server"}=c;try{if(u==="client"){let f=yield(0,Fd.getTemporaryAuthToken)(s,this.config),{fetch:p}=this.config,m=new URL(this.url);m.searchParams.set("fal_jwt_token",f);let v=yield p(m.toString(),{method:l.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:qt,"content-type":"application/json"},body:d&&l!=="get"?JSON.stringify(d):void 0,signal:this.abortController.signal});return yield this.handleResponse(v)}return yield(0,Ar.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:d,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:qt},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,me.defaultResponseHandler)(o)}catch(v){this.emit("error",v)}return}let c=o.body;if(!c){this.emit("error",new me.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(qt)){let v=c.getReader(),w=()=>{v.read().then(({done:g,value:h})=>{if(g){this.emit("done",this.currentData);return}this.currentData=h,this.emit("data",h),w()})};w();return}let l=new TextDecoder("utf-8"),u=o.body.getReader(),f=(0,zd.createParser)(v=>{if(v.type==="event"){let w=v.data;try{let g=JSON.parse(w);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:Ld,m=()=>je(this,void 0,void 0,function*(){let{value:v,done:w}=yield u.read();this.lastEventTimestamp=Date.now(),f.feed(l.decode(v)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new me.ApiError({message:`Event stream timed out after ${(p/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 me.ApiError?o:new me.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,Ar.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new me.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 Nd(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 Oe(n)),yield Oe(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}};j.FalStream=et;function Bd({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 et(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var Tr=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(l){try{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})},Rd=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=fe(),qd=Q(),Vd=Vt(),tt=Z(),Cr=500,Hd=({config:e,storage:t})=>{let i={submit(r,n){return X(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a}=n,s=Rd(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 d=(0,tt.parseEndpointId)(o),l=d.namespace?`${d.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${l}${d.owner}/${d.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 d=(0,tt.parseEndpointId)(o),l=d.namespace?`${d.namespace}/`:"",u={logs:s?"1":"0"},f=(0,N.buildUrl)(`${l}${d.owner}/${d.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:u});return new Vd.FalStream(o,e,{url:f,method:"get",connectionMode:c,queryParams:u})})},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 d=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];a&&(s=setTimeout(()=>{throw d.abort(),i.cancel(r,{requestId:o}).catch(c),new Error(`Client timed out waiting for the request to complete after ${a}ms`)},a)),d.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 u=yield d.done();return s&&clearTimeout(s),u}return new Promise((d,l)=>{var u;let f,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(u=n.pollInterval)!==null&&u!==void 0?u:Cr,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 v=()=>X(this,void 0,void 0,function*(){var w;try{let g=yield i.status(r,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){m(),d(g);return}f=setTimeout(v,p)}catch(g){m(),l(g)}});v().catch(l)})})},result(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,tt.parseEndpointId)(o),d=c.namespace?`${c.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${d}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:qd.resultResponseHandler}),options:{signal:s}})})},cancel(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,tt.parseEndpointId)(o),d=c.namespace?`${c.namespace}/`:"";yield(0,N.dispatchRequest)({method:"put",targetUrl:(0,N.buildUrl)(`${d}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:s}})})}};return i};H.createQueueClient=Hd});var it=k(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.utf8Count=Gd;z.utf8EncodeJs=Mr;z.utf8EncodeTE=jr;z.utf8Encode=Wd;z.utf8DecodeJs=Or;z.utf8DecodeTD=$r;z.utf8Decode=Jd;function Gd(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 Mr(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 Kd=new TextEncoder,Yd=50;function jr(e,t,i){Kd.encodeInto(e,t.subarray(i))}function Wd(e,t,i){e.length>Yd?jr(e,t,i):Mr(e,t,i)}var Qd=4096;function Or(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,d=e[r++]&63;o.push((s&31)<<12|c<<6|d)}else if((s&248)===240){let c=e[r++]&63,d=e[r++]&63,l=e[r++]&63,u=(s&7)<<18|c<<12|d<<6|l;u>65535&&(u-=65536,o.push(u>>>10&1023|55296),u=56320|u&1023),o.push(u)}else o.push(s);o.length>=Qd&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var Zd=new TextDecoder,Xd=200;function $r(e,t,i){let r=e.subarray(t,t+i);return Zd.decode(r)}function Jd(e,t,i){return i>Xd?$r(e,t,i):Or(e,t,i)}});var Gt=k(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.ExtData=void 0;var Ht=class{constructor(t,i){this.type=t,this.data=i}};rt.ExtData=Ht});var ot=k(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.DecodeError=void 0;var Kt=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})}};nt.DecodeError=Kt});var at=k(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.UINT32_MAX=void 0;G.setUint64=eg;G.setInt64=tg;G.getInt64=ig;G.getUint64=rg;G.UINT32_MAX=4294967295;function eg(e,t,i){let r=i/4294967296,n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function tg(e,t,i){let r=Math.floor(i/4294967296),n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function ig(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function rg(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var Yt=k(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.timestampExtension=T.EXT_TIMESTAMP=void 0;T.encodeTimeSpecToTimestamp=Dr;T.encodeDateToTimeSpec=Ur;T.encodeTimestampExtension=Nr;T.decodeTimestampToTimeSpec=zr;T.decodeTimestampExtension=Fr;var ng=ot(),Pr=at();T.EXT_TIMESTAMP=-1;var og=4294967296-1,ag=17179869184-1;function Dr({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=ag)if(t===0&&e<=og){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,Pr.setInt64)(r,4,e),i}}function Ur(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 Nr(e){if(e instanceof Date){let t=Ur(e);return Dr(t)}else return null}function zr(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,Pr.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new ng.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function Fr(e){let t=zr(e);return new Date(t.sec*1e3+t.nsec/1e6)}T.timestampExtension={type:T.EXT_TIMESTAMP,encode:Nr,decode:Fr}});var ct=k(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.ExtensionCodec=void 0;var st=Gt(),sg=Yt(),$e=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(sg.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 st.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 st.ExtData(a,o)}}}return t instanceof st.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 st.ExtData(i,t)}};lt.ExtensionCodec=$e;$e.defaultCodec=new $e});var Qt=k(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.ensureUint8Array=cg;function lg(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function cg(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):lg(e)?new Uint8Array(e):Uint8Array.from(e)}});var Xt=k(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.Encoder=P.DEFAULT_INITIAL_BUFFER_SIZE=P.DEFAULT_MAX_DEPTH=void 0;var Lr=it(),ug=ct(),Br=at(),dg=Qt();P.DEFAULT_MAX_DEPTH=100;P.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Zt=class e{constructor(t){this.entered=!1,this.extensionCodec=t?.extensionCodec??ug.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,Lr.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,Lr.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,dg.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,Br.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,Br.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=Zt});var Rr=k(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.encode=pg;var gg=Xt();function pg(e,t){return new gg.Encoder(t).encodeSharedRef(e)}});var qr=k(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.prettyByte=hg;function hg(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var Vr=k(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.CachedKeyDecoder=void 0;var fg=it(),mg=16,yg=16,ti=class{constructor(t=mg,i=yg){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,fg.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};ut.CachedKeyDecoder=ti});var gt=k(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.Decoder=void 0;var ii=qr(),bg=ct(),J=at(),_g=it(),Hr=Qt(),vg=Vr(),F=ot(),ri="array",De="map_key",Kr="map_value",wg=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new F.DecodeError("The type of key must be string or number but "+typeof e)},ni=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=ri,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=De,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===ri){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===De||t.type===Kr){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}},Pe=-1,ai=new DataView(new ArrayBuffer(0)),xg=new Uint8Array(ai.buffer);try{ai.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 Gr=new RangeError("Insufficient data"),kg=new vg.CachedKeyDecoder,oi=class e{constructor(t){this.totalPos=0,this.pos=0,this.view=ai,this.bytes=xg,this.headByte=Pe,this.stack=new ni,this.entered=!1,this.extensionCodec=t?.extensionCodec??bg.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:kg,this.mapKeyConverter=t?.mapKeyConverter??wg}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=Pe,this.stack.reset()}setBuffer(t){let i=(0,Hr.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===Pe&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,Hr.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,ii.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 F.DecodeError(`Unrecognized type byte: ${(0,ii.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===ri)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===De){if(i==="__proto__")throw new F.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=Kr;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=De;continue e}}return i}}readHeadByte(){return this.headByte===Pe&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Pe}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 F.DecodeError(`Unrecognized array type byte: ${(0,ii.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new F.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new F.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 F.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw Gr;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,_g.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===De:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new F.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw Gr;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 F.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}};dt.Decoder=oi});var Wr=k(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.decode=Sg;pt.decodeMulti=Ig;var Yr=gt();function Sg(e,t){return new Yr.Decoder(t).decode(e)}function Ig(e,t){return new Yr.Decoder(t).decodeMulti(e)}});var Xr=k(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.isAsyncIterable=Qr;Ue.asyncIterableFromStream=Zr;Ue.ensureAsyncIterable=Eg;function Qr(e){return e[Symbol.asyncIterator]!=null}async function*Zr(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function Eg(e){return Qr(e)?e:Zr(e)}});var Jr=k(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.decodeAsync=Ag;Ne.decodeArrayStream=Cg;Ne.decodeMultiStream=Tg;var si=gt(),li=Xr();async function Ag(e,t){let i=(0,li.ensureAsyncIterable)(e);return new si.Decoder(t).decodeAsync(i)}function Cg(e,t){let i=(0,li.ensureAsyncIterable)(e);return new si.Decoder(t).decodeArrayStream(i)}function Tg(e,t){let i=(0,li.ensureAsyncIterable)(e);return new si.Decoder(t).decodeStream(i)}});var tn=k(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.decodeTimestampExtension=x.encodeTimestampExtension=x.decodeTimestampToTimeSpec=x.encodeTimeSpecToTimestamp=x.encodeDateToTimeSpec=x.EXT_TIMESTAMP=x.ExtData=x.ExtensionCodec=x.Encoder=x.DecodeError=x.Decoder=x.decodeMultiStream=x.decodeArrayStream=x.decodeAsync=x.decodeMulti=x.decode=x.encode=void 0;var Mg=Rr();Object.defineProperty(x,"encode",{enumerable:!0,get:function(){return Mg.encode}});var en=Wr();Object.defineProperty(x,"decode",{enumerable:!0,get:function(){return en.decode}});Object.defineProperty(x,"decodeMulti",{enumerable:!0,get:function(){return en.decodeMulti}});var ci=Jr();Object.defineProperty(x,"decodeAsync",{enumerable:!0,get:function(){return ci.decodeAsync}});Object.defineProperty(x,"decodeArrayStream",{enumerable:!0,get:function(){return ci.decodeArrayStream}});Object.defineProperty(x,"decodeMultiStream",{enumerable:!0,get:function(){return ci.decodeMultiStream}});var jg=gt();Object.defineProperty(x,"Decoder",{enumerable:!0,get:function(){return jg.Decoder}});var Og=ot();Object.defineProperty(x,"DecodeError",{enumerable:!0,get:function(){return Og.DecodeError}});var $g=Xt();Object.defineProperty(x,"Encoder",{enumerable:!0,get:function(){return $g.Encoder}});var Pg=ct();Object.defineProperty(x,"ExtensionCodec",{enumerable:!0,get:function(){return Pg.ExtensionCodec}});var Dg=Gt();Object.defineProperty(x,"ExtData",{enumerable:!0,get:function(){return Dg.ExtData}});var ye=Yt();Object.defineProperty(x,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return ye.EXT_TIMESTAMP}});Object.defineProperty(x,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return ye.encodeDateToTimeSpec}});Object.defineProperty(x,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return ye.encodeTimeSpecToTimestamp}});Object.defineProperty(x,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return ye.decodeTimestampToTimeSpec}});Object.defineProperty(x,"encodeTimestampExtension",{enumerable:!0,get:function(){return ye.encodeTimestampExtension}});Object.defineProperty(x,"decodeTimestampExtension",{enumerable:!0,get:function(){return ye.decodeTimestampExtension}})});var yn=k(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});function A(e){return{enumerable:!0,value:e}}function rn(e){return{enumerable:!0,writable:!0,value:e}}var ee={},Ug=()=>!0,nn=()=>({}),an=e=>e,Ng=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),zg=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),K=(e,t)=>Object.freeze(Object.create(e,t));function on(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function sn(e){return K(this,{fn:A(e)})}var ln={},cn=sn.bind(ln),Fg=e=>cn((t,i)=>!!~e(t,i)&&t),un={},Lg=sn.bind(un);function ht(e,t){return t.filter(i=>e.isPrototypeOf(i))}function dn(e,t,...i){let r=on(ht(un,i).map(o=>o.fn),Ug,Ng),n=on(ht(ln,i).map(o=>o.fn),an,zg);return K(this,{from:A(e),to:A(t),guards:A(r),reducers:A(n)})}var gn={},pn={},Bg=dn.bind(gn),Rg=dn.bind(pn,null);function qg(e,t,i){return di(t,e,i,this.immediates)||e}function hn(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 Vg={enter:an};function Hg(...e){let t=ht(gn,e),i=ht(pn,e),r={final:A(e.length===0),transitions:A(hn(t))};return i.length&&(r.immediates=A(i),r.enter=A(qg)),K(Vg,r)}var Gg={enter(e,t,i){let r=this.fn.call(t,t.context,i);return ui.isPrototypeOf(r)?K(fn,{machine:A(r),transitions:A(this.transitions)}).enter(e,t,i):(r.then(n=>t.send({type:"done",data:n})).catch(n=>t.send({type:"error",error:n})),e)}},fn={enter(e,t,i){if(t.child=mn(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,di(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function Kg(e,...t){let i=A(hn(t));return ui.isPrototypeOf(e)?K(fn,{machine:A(e),transitions:i}):K(Gg,{fn:A(e),transitions:i})}var ui={get state(){return{name:this.current,value:this.states[this.current]}}};function Yg(e,t,i=nn){return typeof e!="string"&&(i=t||nn,t=e,e=Object.keys(t)[0]),ee._create&&ee._create(e,t),K(ui,{context:A(i),current:A(e),states:A(t)})}function di(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,d=K(c,{current:A(o),original:{value:c}});return ee._onEnter&&ee._onEnter(t,o,e.context,n,i),d.state.value.enter(d,e,i)}}function Wg(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?di(e,r,t,n.transitions.get(i))||r:(ee._send&&ee._send(i,o),r)}var Qg={send(e){this.machine=Wg(this,e),this.onChange(this)}};function mn(e,t,i,r){let n=Object.create(Qg,{machine:rn(e),context:rn(e.context(i,r)),onChange:A(t)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}M.action=Fg;M.createMachine=Yg;M.d=ee;M.guard=Lg;M.immediate=Rg;M.interpret=mn;M.invoke=Kg;M.reduce=cn;M.state=Hg;M.transition=Bg});var xn=k(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.createRealtimeClient=dp;var mt=tn(),y=yn(),bn=Rt(),gi=Q(),_n=Xe(),fi=Z(),Zg=()=>({enqueuedMessage:void 0});function Xg(e){return e.token!==void 0}function Jg(e){return!Xg(e)}function ft(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 ep(e,t){return e.websocket&&e.websocket.readyState===WebSocket.OPEN?(t.message instanceof Uint8Array?e.websocket.send(t.message):e.websocket.send((0,mt.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function pi(e){return Object.assign(Object.assign({},e),{token:void 0})}function tp(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function ip(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var rp=(0,y.createMachine)("idle",{idle:(0,y.state)((0,y.transition)("send","connecting",(0,y.reduce)(ft)),(0,y.transition)("expireToken","idle",(0,y.reduce)(pi)),(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)(ip)),(0,y.transition)("connectionClosed","idle",(0,y.reduce)(L)),(0,y.transition)("send","connecting",(0,y.reduce)(ft)),(0,y.transition)("close","idle",(0,y.reduce)(L)),(0,y.immediate)("authRequired",(0,y.guard)(Jg))),authRequired:(0,y.state)((0,y.transition)("initiateAuth","authInProgress"),(0,y.transition)("send","authRequired",(0,y.reduce)(ft)),(0,y.transition)("close","idle",(0,y.reduce)(L))),authInProgress:(0,y.state)((0,y.transition)("authenticated","connecting",(0,y.reduce)(tp)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(pi),(0,y.reduce)(L)),(0,y.transition)("send","authInProgress",(0,y.reduce)(ft)),(0,y.transition)("close","idle",(0,y.reduce)(L))),active:(0,y.state)((0,y.transition)("send","active",(0,y.reduce)(ep)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(pi)),(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)))},Zg);function np(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,fi.ensureEndpointIdFormat)(e)}/realtime?${r.toString()}`}var op=128;function ap(e){return e.status==="error"&&e.error==="Unauthorized"}var sp={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},hi=new Map,vn=new Map;function lp(e,t,i){if(!hi.has(e)){let r=(0,y.interpret)(rp,i);hi.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,fi.throttle)(r.send,t,!0):r.send}))}return hi.get(e)}var ze=()=>{},cp={send:ze,close:ze};function up(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!wn(e)}function wn(e){return e.type==="x-fal-error"}function dp({config:e}){return{connect(t,i){let{clientOnly:r=(0,fi.isReact)()&&!(0,_n.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:a=op}=i;if(r&&!(0,_n.isBrowser)())return cp;let s;vn.set(n,{onError:i.onError,onResult:i.onResult});let c=()=>vn.get(n),d=lp(n,a,({context:f,machine:p,send:m})=>{let{enqueuedMessage:v,token:w}=f;if(p.current==="active"&&v&&m({type:"send",message:v}),p.current==="authRequired"&&w===void 0&&s!==p.current&&(m({type:"initiateAuth"}),(0,bn.getTemporaryAuthToken)(t,e).then(g=>{m({type:"authenticated",token:g});let h=Math.round(bn.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{m({type:"expireToken"})},h)}).catch(g=>{m({type:"unauthorized",error:g})})),p.current==="connecting"&&s!==p.current&&w!==void 0){let g=new WebSocket(np(t,{token:w,maxBuffering:o}));g.onopen=()=>{m({type:"connected",websocket:g})},g.onclose=h=>{if(h.code!==sp.NORMAL_CLOSURE){let{onError:_=ze}=c();_(new gi.ApiError({message:`Error closing the connection: ${h.reason}`,status:h.code}))}m({type:"connectionClosed",code:h.code})},g.onerror=h=>{let{onError:_=ze}=c();_(new gi.ApiError({message:"Unknown error",status:500}))},g.onmessage=h=>{let{onResult:_}=c();if(h.data instanceof ArrayBuffer){let C=(0,mt.decode)(new Uint8Array(h.data));_(C);return}if(h.data instanceof Uint8Array){let C=(0,mt.decode)(h.data);_(C);return}if(h.data instanceof Blob){h.data.arrayBuffer().then(C=>{let wi=(0,mt.decode)(new Uint8Array(C));_(wi)});return}let b=JSON.parse(h.data);if(ap(b)){m({type:"unauthorized",error:new Error("Unauthorized")});return}if(up(b)){_(b);return}if(wn(b)){if(b.error==="TIMEOUT")return;let{onError:C=ze}=c();C(new gi.ApiError({message:`${b.error}: ${b.reason}`,status:400,body:b}));return}}}s=p.current});return{send:f=>{d.throttledSend({type:"send",message:f})},close:()=>{d.send({type:"close"})}}}}}});var An=k(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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(Fe,"__esModule",{value:!0});Fe.createStorageClient=mp;var kn=Je(),Sn=fe(),gp=Z();function In(e){var t;let[i,r]=e.split("/");return(t=r.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function pp(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${In(i)}`;return yield(0,Sn.dispatchRequest)({method:"POST",targetUrl:`${(0,kn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function hp(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${In(i)}`;return yield(0,Sn.dispatchRequest)({method:"POST",targetUrl:`${(0,kn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function En(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 d=yield s(r,{method:"PUT",body:n});return yield c(d)}catch{return yield En(r,n,o,a-1)}})}function fp(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 hp(e,t,n),s=10*1024*1024,c=Math.ceil(e.size/s),d=new URL(o),l=[];for(let p=0;p<c;p++){let m=p*s,v=Math.min(m+s,e.size),w=e.slice(m,v),g=p+1,h=`${d.origin}${d.pathname}/${g}${d.search}`;l.push(yield En(h,w,t))}let u=`${d.origin}${d.pathname}/complete${d.search}`,f=yield i(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield r(f),a})}function mp({config:e}){let t={upload:i=>te(this,void 0,void 0,function*(){if(i.size>94371840)return yield fp(i,e);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:o}=e,{upload_url:a,file_url:s}=yield pp(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,gp.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 yi=k(Le=>{"use strict";var Cn=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(l){try{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(Le,"__esModule",{value:!0});Le.createFalClient=kp;var yp=Je(),bp=Tr(),_p=xn(),Tn=fe(),vp=Q(),wp=An(),xp=Vt();function kp(e={}){let t=(0,yp.createConfig)(e),i=(0,wp.createStorageClient)({config:t}),r=(0,bp.createQueueClient)({config:t,storage:i}),n=(0,xp.createStreamingClient)({config:t,storage:i}),o=(0,_p.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return Cn(this,arguments,void 0,function*(s,c={}){let d=c.input?yield i.transformInput(c.input):void 0;return(0,Tn.dispatchRequest)({method:c.method,targetUrl:(0,Tn.buildUrl)(s,c),input:d,config:Object.assign(Object.assign({},t),{responseHandler:vp.resultResponseHandler}),options:{signal:c.abortSignal}})})},subscribe:(a,s)=>Cn(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 jn=k(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.isQueueStatus=Mn;yt.isCompletedQueueStatus=Sp;function Mn(e){return e&&e.status&&e.response_url}function Sp(e){return Mn(e)&&e.status==="COMPLETED"}});var bi=k(E=>{"use strict";var Ip=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]}),Ep=E&&E.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&Ip(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 On=yi(),Ap=yi();Object.defineProperty(E,"createFalClient",{enumerable:!0,get:function(){return Ap.createFalClient}});var $n=Ft();Object.defineProperty(E,"withMiddleware",{enumerable:!0,get:function(){return $n.withMiddleware}});Object.defineProperty(E,"withProxy",{enumerable:!0,get:function(){return $n.withProxy}});var Pn=Q();Object.defineProperty(E,"ApiError",{enumerable:!0,get:function(){return Pn.ApiError}});Object.defineProperty(E,"ValidationError",{enumerable:!0,get:function(){return Pn.ValidationError}});Ep(jn(),E);var Cp=Z();Object.defineProperty(E,"parseEndpointId",{enumerable:!0,get:function(){return Cp.parseEndpointId}});E.fal=function(){let t=(0,On.createFalClient)();return{config(i){t=(0,On.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 Vn=`
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 Er=[239,187,191];function jd(e){return Er.every((t,i)=>e.charCodeAt(i)===t)}Bt.createParser=$d});var Rt=k(V=>{"use strict";var Od=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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(V,"__esModule",{value:!0});V.TOKEN_EXPIRATION_SECONDS=void 0;V.getTemporaryAuthToken=Nd;var Pd=Je(),Dd=he(),Ud=Z();V.TOKEN_EXPIRATION_SECONDS=120;function Nd(e,t){return Od(this,void 0,void 0,function*(){let i=(0,Ud.parseEndpointId)(e),r=yield(0,Dd.dispatchRequest)({method:"POST",targetUrl:`${(0,Pd.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 Vt=k($=>{"use strict";var $e=$&&$.__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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})},je=$&&$.__await||function(e){return this instanceof je?(this.v=e,this):new je(e)},zd=$&&$.__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(m){return Promise.resolve(m).then(p,u)}}function s(p,m){r[p]&&(n[p]=function(v){return new Promise(function(w,g){o.push([p,v,w,g])>1||c(p,v)})},m&&(n[p]=m(n[p])))}function c(p,m){try{d(r[p](m))}catch(v){h(o[0][3],v)}}function d(p){p.value instanceof je?Promise.resolve(p.value.v).then(l,u):h(o[0][2],p)}function l(p){c("next",p)}function u(p){c("throw",p)}function h(p,m){p(m),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty($,"__esModule",{value:!0});$.FalStream=void 0;$.createStreamingClient=Rd;var Fd=Ar(),Ld=Rt(),Cr=he(),me=W(),qt="text/event-stream",Bd=15*1e3,et=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=()=>$e(this,void 0,void 0,function*(){var o,a;let{endpointId:s,options:c}=this,{input:d,method:l="post",connectionMode:u="server"}=c;try{if(u==="client"){let h=yield(0,Ld.getTemporaryAuthToken)(s,this.config),{fetch:p}=this.config,m=new URL(this.url);m.searchParams.set("fal_jwt_token",h);let v=yield p(m.toString(),{method:l.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:qt,"content-type":"application/json"},body:d&&l!=="get"?JSON.stringify(d):void 0,signal:this.abortController.signal});return yield this.handleResponse(v)}return yield(0,Cr.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:d,config:this.config,options:{headers:{accept:(a=c.accept)!==null&&a!==void 0?a:qt},responseHandler:this.handleResponse,signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>$e(this,void 0,void 0,function*(){var a,s;if(!o.ok){try{yield(0,me.defaultResponseHandler)(o)}catch(v){this.emit("error",v)}return}let c=o.body;if(!c){this.emit("error",new me.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(qt)){let v=c.getReader(),w=()=>{v.read().then(({done:g,value:f})=>{if(g){this.emit("done",this.currentData);return}this.currentData=f,this.emit("data",f),w()})};w();return}let l=new TextDecoder("utf-8"),u=o.body.getReader(),h=(0,Fd.createParser)(v=>{if(v.type==="event"){let w=v.data;try{let g=JSON.parse(w);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:Bd,m=()=>$e(this,void 0,void 0,function*(){let{value:v,done:w}=yield u.read();this.lastEventTimestamp=Date.now(),h.feed(l.decode(v)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new me.ApiError({message:`Event stream timed out after ${(p/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 me.ApiError?o:new me.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=()=>$e(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,Cr.buildUrl)(t,{path:"/stream",query:r.queryParams}),this.options=r,this.donePromise=new Promise((o,a)=>{this.streamClosed&&a(new me.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 zd(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 je(n)),yield je(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}};$.FalStream=et;function Rd({config:e,storage:t}){return{stream(i,r){return $e(this,void 0,void 0,function*(){let n=r.input?yield t.transformInput(r.input):void 0;return new et(i,e,Object.assign(Object.assign({},r),{input:n}))})}}}});var Mr=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(l){try{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})},qd=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=he(),Vd=W(),Hd=Vt(),tt=Z(),Tr=500,Gd=({config:e,storage:t})=>{let i={submit(r,n){return X(this,void 0,void 0,function*(){let{webhookUrl:o,priority:a}=n,s=qd(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 d=(0,tt.parseEndpointId)(o),l=d.namespace?`${d.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${l}${d.owner}/${d.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 d=(0,tt.parseEndpointId)(o),l=d.namespace?`${d.namespace}/`:"",u={logs:s?"1":"0"},h=(0,N.buildUrl)(`${l}${d.owner}/${d.alias}`,{subdomain:"queue",path:`/requests/${a}/status/stream`,query:u});return new Hd.FalStream(o,e,{url:h,method:"get",connectionMode:c,queryParams:u})})},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 d=yield i.streamStatus(r,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];a&&(s=setTimeout(()=>{throw d.abort(),i.cancel(r,{requestId:o}).catch(c),new Error(`Client timed out waiting for the request to complete after ${a}ms`)},a)),d.on("data",h=>{n.onQueueUpdate&&("logs"in h&&Array.isArray(h.logs)&&h.logs.length>0&&l.push(...h.logs),n.onQueueUpdate("logs"in h?Object.assign(Object.assign({},h),{logs:l}):h))});let u=yield d.done();return s&&clearTimeout(s),u}return new Promise((d,l)=>{var u;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(u=n.pollInterval)!==null&&u!==void 0?u:Tr,m=()=>{s&&clearTimeout(s),h&&clearTimeout(h)};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 v=()=>X(this,void 0,void 0,function*(){var w;try{let g=yield i.status(r,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(g),g.status==="COMPLETED"){m(),d(g);return}h=setTimeout(v,p)}catch(g){m(),l(g)}});v().catch(l)})})},result(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,tt.parseEndpointId)(o),d=c.namespace?`${c.namespace}/`:"";return(0,N.dispatchRequest)({method:"get",targetUrl:(0,N.buildUrl)(`${d}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}`}),config:Object.assign(Object.assign({},e),{responseHandler:Vd.resultResponseHandler}),options:{signal:s}})})},cancel(r,n){return X(this,arguments,void 0,function*(o,{requestId:a,abortSignal:s}){let c=(0,tt.parseEndpointId)(o),d=c.namespace?`${c.namespace}/`:"";yield(0,N.dispatchRequest)({method:"put",targetUrl:(0,N.buildUrl)(`${d}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${a}/cancel`}),config:e,options:{signal:s}})})}};return i};H.createQueueClient=Gd});var it=k(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.utf8Count=Kd;z.utf8EncodeJs=$r;z.utf8EncodeTE=jr;z.utf8Encode=Wd;z.utf8DecodeJs=Or;z.utf8DecodeTD=Pr;z.utf8Decode=eg;function Kd(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 $r(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 Yd=new TextEncoder,Qd=50;function jr(e,t,i){Yd.encodeInto(e,t.subarray(i))}function Wd(e,t,i){e.length>Qd?jr(e,t,i):$r(e,t,i)}var Zd=4096;function Or(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,d=e[r++]&63;o.push((s&31)<<12|c<<6|d)}else if((s&248)===240){let c=e[r++]&63,d=e[r++]&63,l=e[r++]&63,u=(s&7)<<18|c<<12|d<<6|l;u>65535&&(u-=65536,o.push(u>>>10&1023|55296),u=56320|u&1023),o.push(u)}else o.push(s);o.length>=Zd&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}var Xd=new TextDecoder,Jd=200;function Pr(e,t,i){let r=e.subarray(t,t+i);return Xd.decode(r)}function eg(e,t,i){return i>Jd?Pr(e,t,i):Or(e,t,i)}});var Gt=k(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.ExtData=void 0;var Ht=class{constructor(t,i){this.type=t,this.data=i}};rt.ExtData=Ht});var ot=k(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.DecodeError=void 0;var Kt=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})}};nt.DecodeError=Kt});var at=k(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.UINT32_MAX=void 0;G.setUint64=tg;G.setInt64=ig;G.getInt64=rg;G.getUint64=ng;G.UINT32_MAX=4294967295;function tg(e,t,i){let r=i/4294967296,n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function ig(e,t,i){let r=Math.floor(i/4294967296),n=i;e.setUint32(t,r),e.setUint32(t+4,n)}function rg(e,t){let i=e.getInt32(t),r=e.getUint32(t+4);return i*4294967296+r}function ng(e,t){let i=e.getUint32(t),r=e.getUint32(t+4);return i*4294967296+r}});var Yt=k(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.timestampExtension=T.EXT_TIMESTAMP=void 0;T.encodeTimeSpecToTimestamp=Ur;T.encodeDateToTimeSpec=Nr;T.encodeTimestampExtension=zr;T.decodeTimestampToTimeSpec=Fr;T.decodeTimestampExtension=Lr;var og=ot(),Dr=at();T.EXT_TIMESTAMP=-1;var ag=4294967296-1,sg=17179869184-1;function Ur({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=sg)if(t===0&&e<=ag){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,Dr.setInt64)(r,4,e),i}}function Nr(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 zr(e){if(e instanceof Date){let t=Nr(e);return Ur(t)}else return null}function Fr(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,Dr.getInt64)(t,4),r=t.getUint32(0);return{sec:i,nsec:r}}default:throw new og.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function Lr(e){let t=Fr(e);return new Date(t.sec*1e3+t.nsec/1e6)}T.timestampExtension={type:T.EXT_TIMESTAMP,encode:zr,decode:Lr}});var ct=k(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.ExtensionCodec=void 0;var st=Gt(),lg=Yt(),Oe=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(lg.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 st.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 st.ExtData(a,o)}}}return t instanceof st.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 st.ExtData(i,t)}};lt.ExtensionCodec=Oe;Oe.defaultCodec=new Oe});var Wt=k(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.ensureUint8Array=ug;function cg(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function ug(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):cg(e)?new Uint8Array(e):Uint8Array.from(e)}});var Xt=k(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.Encoder=P.DEFAULT_INITIAL_BUFFER_SIZE=P.DEFAULT_MAX_DEPTH=void 0;var Br=it(),dg=ct(),Rr=at(),gg=Wt();P.DEFAULT_MAX_DEPTH=100;P.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Zt=class e{constructor(t){this.entered=!1,this.extensionCodec=t?.extensionCodec??dg.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,Br.utf8Count)(t);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),(0,Br.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,gg.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,Rr.setUint64)(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),(0,Rr.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=Zt});var qr=k(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.encode=fg;var pg=Xt();function fg(e,t){return new pg.Encoder(t).encodeSharedRef(e)}});var Vr=k(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.prettyByte=hg;function hg(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}});var Hr=k(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.CachedKeyDecoder=void 0;var mg=it(),yg=16,bg=16,ti=class{constructor(t=yg,i=bg){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,mg.utf8DecodeJs)(t,i,r),a=Uint8Array.prototype.slice.call(t,i,i+r);return this.store(a,o),o}};ut.CachedKeyDecoder=ti});var gt=k(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.Decoder=void 0;var ii=Vr(),_g=ct(),J=at(),vg=it(),Gr=Wt(),wg=Hr(),F=ot(),ri="array",De="map_key",Yr="map_value",xg=e=>{if(typeof e=="string"||typeof e=="number")return e;throw new F.DecodeError("The type of key must be string or number but "+typeof e)},ni=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=ri,i.position=0,i.size=t,i.array=new Array(t)}pushMapState(t){let i=this.getUninitializedStateFromPool();i.type=De,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===ri){let r=t;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(t.type===De||t.type===Yr){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}},Pe=-1,ai=new DataView(new ArrayBuffer(0)),kg=new Uint8Array(ai.buffer);try{ai.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 Kr=new RangeError("Insufficient data"),Sg=new wg.CachedKeyDecoder,oi=class e{constructor(t){this.totalPos=0,this.pos=0,this.view=ai,this.bytes=kg,this.headByte=Pe,this.stack=new ni,this.entered=!1,this.extensionCodec=t?.extensionCodec??_g.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:Sg,this.mapKeyConverter=t?.mapKeyConverter??xg}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=Pe,this.stack.reset()}setBuffer(t){let i=(0,Gr.ensureUint8Array)(t);this.bytes=i,this.view=new DataView(i.buffer,i.byteOffset,i.byteLength),this.pos=0}appendBuffer(t){if(this.headByte===Pe&&!this.hasRemaining(1))this.setBuffer(t);else{let i=this.bytes.subarray(this.pos),r=(0,Gr.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,ii.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 F.DecodeError(`Unrecognized type byte: ${(0,ii.prettyByte)(t)}`);this.complete();let r=this.stack;for(;r.length>0;){let n=r.top();if(n.type===ri)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===De){if(i==="__proto__")throw new F.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(i),n.type=Yr;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=De;continue e}}return i}}readHeadByte(){return this.headByte===Pe&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Pe}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 F.DecodeError(`Unrecognized array type byte: ${(0,ii.prettyByte)(t)}`)}}}pushMapState(t){if(t>this.maxMapLength)throw new F.DecodeError(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(t)}pushArrayState(t){if(t>this.maxArrayLength)throw new F.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 F.DecodeError(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+i+t)throw Kr;let r=this.pos+i,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(t)?n=this.keyDecoder.decode(this.bytes,r,t):n=(0,vg.utf8Decode)(this.bytes,r,t),this.pos+=i+t,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===De:!1}decodeBinary(t,i){if(t>this.maxBinLength)throw new F.DecodeError(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+i))throw Kr;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 F.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}};dt.Decoder=oi});var Wr=k(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.decode=Ig;pt.decodeMulti=Eg;var Qr=gt();function Ig(e,t){return new Qr.Decoder(t).decode(e)}function Eg(e,t){return new Qr.Decoder(t).decodeMulti(e)}});var Jr=k(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.isAsyncIterable=Zr;Ue.asyncIterableFromStream=Xr;Ue.ensureAsyncIterable=Ag;function Zr(e){return e[Symbol.asyncIterator]!=null}async function*Xr(e){let t=e.getReader();try{for(;;){let{done:i,value:r}=await t.read();if(i)return;yield r}}finally{t.releaseLock()}}function Ag(e){return Zr(e)?e:Xr(e)}});var en=k(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.decodeAsync=Cg;Ne.decodeArrayStream=Tg;Ne.decodeMultiStream=Mg;var si=gt(),li=Jr();async function Cg(e,t){let i=(0,li.ensureAsyncIterable)(e);return new si.Decoder(t).decodeAsync(i)}function Tg(e,t){let i=(0,li.ensureAsyncIterable)(e);return new si.Decoder(t).decodeArrayStream(i)}function Mg(e,t){let i=(0,li.ensureAsyncIterable)(e);return new si.Decoder(t).decodeStream(i)}});var rn=k(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.decodeTimestampExtension=x.encodeTimestampExtension=x.decodeTimestampToTimeSpec=x.encodeTimeSpecToTimestamp=x.encodeDateToTimeSpec=x.EXT_TIMESTAMP=x.ExtData=x.ExtensionCodec=x.Encoder=x.DecodeError=x.Decoder=x.decodeMultiStream=x.decodeArrayStream=x.decodeAsync=x.decodeMulti=x.decode=x.encode=void 0;var $g=qr();Object.defineProperty(x,"encode",{enumerable:!0,get:function(){return $g.encode}});var tn=Wr();Object.defineProperty(x,"decode",{enumerable:!0,get:function(){return tn.decode}});Object.defineProperty(x,"decodeMulti",{enumerable:!0,get:function(){return tn.decodeMulti}});var ci=en();Object.defineProperty(x,"decodeAsync",{enumerable:!0,get:function(){return ci.decodeAsync}});Object.defineProperty(x,"decodeArrayStream",{enumerable:!0,get:function(){return ci.decodeArrayStream}});Object.defineProperty(x,"decodeMultiStream",{enumerable:!0,get:function(){return ci.decodeMultiStream}});var jg=gt();Object.defineProperty(x,"Decoder",{enumerable:!0,get:function(){return jg.Decoder}});var Og=ot();Object.defineProperty(x,"DecodeError",{enumerable:!0,get:function(){return Og.DecodeError}});var Pg=Xt();Object.defineProperty(x,"Encoder",{enumerable:!0,get:function(){return Pg.Encoder}});var Dg=ct();Object.defineProperty(x,"ExtensionCodec",{enumerable:!0,get:function(){return Dg.ExtensionCodec}});var Ug=Gt();Object.defineProperty(x,"ExtData",{enumerable:!0,get:function(){return Ug.ExtData}});var ye=Yt();Object.defineProperty(x,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return ye.EXT_TIMESTAMP}});Object.defineProperty(x,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return ye.encodeDateToTimeSpec}});Object.defineProperty(x,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return ye.encodeTimeSpecToTimestamp}});Object.defineProperty(x,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return ye.decodeTimestampToTimeSpec}});Object.defineProperty(x,"encodeTimestampExtension",{enumerable:!0,get:function(){return ye.encodeTimestampExtension}});Object.defineProperty(x,"decodeTimestampExtension",{enumerable:!0,get:function(){return ye.decodeTimestampExtension}})});var bn=k(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});function A(e){return{enumerable:!0,value:e}}function nn(e){return{enumerable:!0,writable:!0,value:e}}var ee={},Ng=()=>!0,on=()=>({}),sn=e=>e,zg=(e,t,i,r)=>e.apply(i,r)&&t.apply(i,r),Fg=(e,t,i,[r,n])=>t.call(i,e.call(i,r,n),n),K=(e,t)=>Object.freeze(Object.create(e,t));function an(e,t,i){return e.reduce((r,n)=>function(...o){return i(r,n,this,o)},t)}function ln(e){return K(this,{fn:A(e)})}var cn={},un=ln.bind(cn),Lg=e=>un((t,i)=>!!~e(t,i)&&t),dn={},Bg=ln.bind(dn);function ft(e,t){return t.filter(i=>e.isPrototypeOf(i))}function gn(e,t,...i){let r=an(ft(dn,i).map(o=>o.fn),Ng,zg),n=an(ft(cn,i).map(o=>o.fn),sn,Fg);return K(this,{from:A(e),to:A(t),guards:A(r),reducers:A(n)})}var pn={},fn={},Rg=gn.bind(pn),qg=gn.bind(fn,null);function Vg(e,t,i){return di(t,e,i,this.immediates)||e}function hn(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:sn};function Gg(...e){let t=ft(pn,e),i=ft(fn,e),r={final:A(e.length===0),transitions:A(hn(t))};return i.length&&(r.immediates=A(i),r.enter=A(Vg)),K(Hg,r)}var Kg={enter(e,t,i){let r=this.fn.call(t,t.context,i);return ui.isPrototypeOf(r)?K(mn,{machine:A(r),transitions:A(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=yn(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,di(t,e,{type:"done",data:r},this.transitions.get("done"))}return e}};function Yg(e,...t){let i=A(hn(t));return ui.isPrototypeOf(e)?K(mn,{machine:A(e),transitions:i}):K(Kg,{fn:A(e),transitions:i})}var ui={get state(){return{name:this.current,value:this.states[this.current]}}};function Qg(e,t,i=on){return typeof e!="string"&&(i=t||on,t=e,e=Object.keys(t)[0]),ee._create&&ee._create(e,t),K(ui,{context:A(i),current:A(e),states:A(t)})}function di(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,d=K(c,{current:A(o),original:{value:c}});return ee._onEnter&&ee._onEnter(t,o,e.context,n,i),d.state.value.enter(d,e,i)}}function Wg(e,t){let i=t.type||t,{machine:r}=e,{value:n,name:o}=r.state;return n.transitions.has(i)?di(e,r,t,n.transitions.get(i))||r:(ee._send&&ee._send(i,o),r)}var Zg={send(e){this.machine=Wg(this,e),this.onChange(this)}};function yn(e,t,i,r){let n=Object.create(Zg,{machine:nn(e),context:nn(e.context(i,r)),onChange:A(t)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,r),n}M.action=Lg;M.createMachine=Qg;M.d=ee;M.guard=Bg;M.immediate=qg;M.interpret=yn;M.invoke=Yg;M.reduce=un;M.state=Gg;M.transition=Rg});var kn=k(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.createRealtimeClient=gp;var mt=rn(),y=bn(),_n=Rt(),gi=W(),vn=Xe(),hi=Z(),Xg=()=>({enqueuedMessage:void 0});function Jg(e){return e.token!==void 0}function ep(e){return!Jg(e)}function ht(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 tp(e,t){return e.websocket&&e.websocket.readyState===WebSocket.OPEN?(t.message instanceof Uint8Array?e.websocket.send(t.message):e.websocket.send((0,mt.encode)(t.message)),Object.assign(Object.assign({},e),{enqueuedMessage:void 0})):Object.assign(Object.assign({},e),{enqueuedMessage:t.message})}function pi(e){return Object.assign(Object.assign({},e),{token:void 0})}function ip(e,t){return Object.assign(Object.assign({},e),{token:t.token})}function rp(e,t){return Object.assign(Object.assign({},e),{websocket:t.websocket})}var np=(0,y.createMachine)("idle",{idle:(0,y.state)((0,y.transition)("send","connecting",(0,y.reduce)(ht)),(0,y.transition)("expireToken","idle",(0,y.reduce)(pi)),(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)(rp)),(0,y.transition)("connectionClosed","idle",(0,y.reduce)(L)),(0,y.transition)("send","connecting",(0,y.reduce)(ht)),(0,y.transition)("close","idle",(0,y.reduce)(L)),(0,y.immediate)("authRequired",(0,y.guard)(ep))),authRequired:(0,y.state)((0,y.transition)("initiateAuth","authInProgress"),(0,y.transition)("send","authRequired",(0,y.reduce)(ht)),(0,y.transition)("close","idle",(0,y.reduce)(L))),authInProgress:(0,y.state)((0,y.transition)("authenticated","connecting",(0,y.reduce)(ip)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(pi),(0,y.reduce)(L)),(0,y.transition)("send","authInProgress",(0,y.reduce)(ht)),(0,y.transition)("close","idle",(0,y.reduce)(L))),active:(0,y.state)((0,y.transition)("send","active",(0,y.reduce)(tp)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(pi)),(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)))},Xg);function op(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,hi.ensureEndpointIdFormat)(e)}/realtime?${r.toString()}`}var ap=128;function sp(e){return e.status==="error"&&e.error==="Unauthorized"}var lp={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},fi=new Map,wn=new Map;function cp(e,t,i){if(!fi.has(e)){let r=(0,y.interpret)(np,i);fi.set(e,Object.assign(Object.assign({},r),{throttledSend:t>0?(0,hi.throttle)(r.send,t,!0):r.send}))}return fi.get(e)}var ze=()=>{},up={send:ze,close:ze};function dp(e){return e.status!=="error"&&e.type!=="x-fal-message"&&!xn(e)}function xn(e){return e.type==="x-fal-error"}function gp({config:e}){return{connect(t,i){let{clientOnly:r=(0,hi.isReact)()&&!(0,vn.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:a=ap}=i;if(r&&!(0,vn.isBrowser)())return up;let s;wn.set(n,{onError:i.onError,onResult:i.onResult});let c=()=>wn.get(n),d=cp(n,a,({context:h,machine:p,send:m})=>{let{enqueuedMessage:v,token:w}=h;if(p.current==="active"&&v&&m({type:"send",message:v}),p.current==="authRequired"&&w===void 0&&s!==p.current&&(m({type:"initiateAuth"}),(0,_n.getTemporaryAuthToken)(t,e).then(g=>{m({type:"authenticated",token:g});let f=Math.round(_n.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{m({type:"expireToken"})},f)}).catch(g=>{m({type:"unauthorized",error:g})})),p.current==="connecting"&&s!==p.current&&w!==void 0){let g=new WebSocket(op(t,{token:w,maxBuffering:o}));g.onopen=()=>{m({type:"connected",websocket:g})},g.onclose=f=>{if(f.code!==lp.NORMAL_CLOSURE){let{onError:_=ze}=c();_(new gi.ApiError({message:`Error closing the connection: ${f.reason}`,status:f.code}))}m({type:"connectionClosed",code:f.code})},g.onerror=f=>{let{onError:_=ze}=c();_(new gi.ApiError({message:"Unknown error",status:500}))},g.onmessage=f=>{let{onResult:_}=c();if(f.data instanceof ArrayBuffer){let C=(0,mt.decode)(new Uint8Array(f.data));_(C);return}if(f.data instanceof Uint8Array){let C=(0,mt.decode)(f.data);_(C);return}if(f.data instanceof Blob){f.data.arrayBuffer().then(C=>{let wi=(0,mt.decode)(new Uint8Array(C));_(wi)});return}let b=JSON.parse(f.data);if(sp(b)){m({type:"unauthorized",error:new Error("Unauthorized")});return}if(dp(b)){_(b);return}if(xn(b)){if(b.error==="TIMEOUT")return;let{onError:C=ze}=c();C(new gi.ApiError({message:`${b.error}: ${b.reason}`,status:400,body:b}));return}}}s=p.current});return{send:h=>{d.throttledSend({type:"send",message:h})},close:()=>{d.send({type:"close"})}}}}}});var Cn=k(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{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(Fe,"__esModule",{value:!0});Fe.createStorageClient=yp;var Sn=Je(),In=he(),pp=Z();function En(e){var t;let[i,r]=e.split("/");return(t=r.split(/[-;]/)[0])!==null&&t!==void 0?t:"bin"}function fp(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${En(i)}`;return yield(0,In.dispatchRequest)({method:"POST",targetUrl:`${(0,Sn.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function hp(e,t,i){return te(this,void 0,void 0,function*(){let r=e.name||`${Date.now()}.${En(i)}`;return yield(0,In.dispatchRequest)({method:"POST",targetUrl:`${(0,Sn.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:i,file_name:r},config:t})})}function An(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 d=yield s(r,{method:"PUT",body:n});return yield c(d)}catch{return yield An(r,n,o,a-1)}})}function mp(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 hp(e,t,n),s=10*1024*1024,c=Math.ceil(e.size/s),d=new URL(o),l=[];for(let p=0;p<c;p++){let m=p*s,v=Math.min(m+s,e.size),w=e.slice(m,v),g=p+1,f=`${d.origin}${d.pathname}/${g}${d.search}`;l.push(yield An(f,w,t))}let u=`${d.origin}${d.pathname}/complete${d.search}`,h=yield i(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield r(h),a})}function yp({config:e}){let t={upload:i=>te(this,void 0,void 0,function*(){if(i.size>94371840)return yield mp(i,e);let r=i.type||"application/octet-stream",{fetch:n,responseHandler:o}=e,{upload_url:a,file_url:s}=yield fp(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,pp.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 yi=k(Le=>{"use strict";var Tn=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(l){try{d(r.next(l))}catch(u){a(u)}}function c(l){try{d(r.throw(l))}catch(u){a(u)}}function d(l){l.done?o(l.value):n(l.value).then(s,c)}d((r=r.apply(e,t||[])).next())})};Object.defineProperty(Le,"__esModule",{value:!0});Le.createFalClient=Sp;var bp=Je(),_p=Mr(),vp=kn(),Mn=he(),wp=W(),xp=Cn(),kp=Vt();function Sp(e={}){let t=(0,bp.createConfig)(e),i=(0,xp.createStorageClient)({config:t}),r=(0,_p.createQueueClient)({config:t,storage:i}),n=(0,kp.createStreamingClient)({config:t,storage:i}),o=(0,vp.createRealtimeClient)({config:t});return{queue:r,realtime:o,storage:i,streaming:n,stream:n.stream,run(a){return Tn(this,arguments,void 0,function*(s,c={}){let d=c.input?yield i.transformInput(c.input):void 0;return(0,Mn.dispatchRequest)({method:c.method,targetUrl:(0,Mn.buildUrl)(s,c),input:d,config:Object.assign(Object.assign({},t),{responseHandler:wp.resultResponseHandler}),options:{signal:c.abortSignal}})})},subscribe:(a,s)=>Tn(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 jn=k(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.isQueueStatus=$n;yt.isCompletedQueueStatus=Ip;function $n(e){return e&&e.status&&e.response_url}function Ip(e){return $n(e)&&e.status==="COMPLETED"}});var bi=k(E=>{"use strict";var Ep=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]}),Ap=E&&E.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&Ep(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 On=yi(),Cp=yi();Object.defineProperty(E,"createFalClient",{enumerable:!0,get:function(){return Cp.createFalClient}});var Pn=Ft();Object.defineProperty(E,"withMiddleware",{enumerable:!0,get:function(){return Pn.withMiddleware}});Object.defineProperty(E,"withProxy",{enumerable:!0,get:function(){return Pn.withProxy}});var Dn=W();Object.defineProperty(E,"ApiError",{enumerable:!0,get:function(){return Dn.ApiError}});Object.defineProperty(E,"ValidationError",{enumerable:!0,get:function(){return Dn.ValidationError}});Ap(jn(),E);var Tp=Z();Object.defineProperty(E,"parseEndpointId",{enumerable:!0,get:function(){return Tp.parseEndpointId}});E.fal=function(){let t=(0,On.createFalClient)();return{config(i){t=(0,On.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 Hn=`
6
6
  <svg>
7
7
  <symbol
8
8
  fill="none"
@@ -68,7 +68,7 @@ var zn=Object.create;var xi=Object.defineProperty;var Fn=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
- `,zi=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:d,sortKey:l}=e,u=[...this.assets];if(s&&s.length>0&&(u=u.filter(g=>g.groups&&s.some(h=>g.groups?.includes(h)))),c&&c.length>0&&(u=u.filter(g=>!g.groups||!c.some(h=>g.groups?.includes(h)))),o){let g=o.toLowerCase();u=u.filter(h=>{let _=h.label?.[r]?.toLowerCase(),b=h.tags?.[r]||[];return _&&_.includes(g)||b.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];u=u.filter(h=>{let _=h.tags?.[r]||[];return g.some(b=>_.includes(b))})}n&&u.sort((g,h)=>{let _=this.activeAssetIds.has(g.id),b=this.activeAssetIds.has(h.id);return _&&!b?-1:!_&&b?1:0}),l&&l!=="id"?u.sort((g,h)=>{let _=g.meta?.[l],b=h.meta?.[l];return _===void 0?1:b===void 0?-1:typeof _=="string"&&typeof b=="string"?d==="Descending"?b.localeCompare(_):_.localeCompare(b):typeof _=="number"&&typeof b=="number"?d==="Descending"?b-_:_-b:0}):l==="id"&&u.sort((g,h)=>d==="Descending"?h.id.localeCompare(g.id):g.id.localeCompare(h.id));let f=u.length,p=t*i,m=p+i,v=u.slice(p,m).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)})),w=m<f?t+1:void 0;return{assets:v,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 Hn=typeof global=="object"&&global&&global.Object===Object&&global,Fi=Hn,Gn=typeof self=="object"&&self&&self.Object===Object&&self,Kn=Fi||Gn||Function("return this")(),D=Kn,Yn=D.Symbol,re=Yn,Li=Object.prototype,Wn=Li.hasOwnProperty,Qn=Li.toString,be=re?re.toStringTag:void 0;function Zn(e){var t=Wn.call(e,be),i=e[be];try{e[be]=void 0;var r=!0}catch{}var n=Qn.call(e);return r&&(t?e[be]=i:delete e[be]),n}var Xn=Zn,Jn=Object.prototype,eo=Jn.toString;function to(e){return eo.call(e)}var io=to,ro="[object Null]",no="[object Undefined]",Si=re?re.toStringTag:void 0;function oo(e){return e==null?e===void 0?no:ro:Si&&Si in Object(e)?Xn(e):io(e)}var xe=oo;function ao(e){return e!=null&&typeof e=="object"}var Et=ao,$p=Array.isArray;function so(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Bi=so,lo="[object AsyncFunction]",co="[object Function]",uo="[object GeneratorFunction]",go="[object Proxy]";function po(e){if(!Bi(e))return!1;var t=xe(e);return t==co||t==uo||t==lo||t==go}var ho=po,fo=D["__core-js_shared__"],_t=fo,Ii=function(){var e=/[^.]+$/.exec(_t&&_t.keys&&_t.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function mo(e){return!!Ii&&Ii in e}var yo=mo,bo=Function.prototype,_o=bo.toString;function vo(e){if(e!=null){try{return _o.call(e)}catch{}try{return e+""}catch{}}return""}var Y=vo,wo=/[\\^$.*+?()[\]{}|]/g,xo=/^\[object .+?Constructor\]$/,ko=Function.prototype,So=Object.prototype,Io=ko.toString,Eo=So.hasOwnProperty,Ao=RegExp("^"+Io.call(Eo).replace(wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Co(e){if(!Bi(e)||yo(e))return!1;var t=ho(e)?Ao:xo;return t.test(Y(e))}var To=Co;function Mo(e,t){return e?.[t]}var jo=Mo;function Oo(e,t){var i=jo(e,t);return To(i)?i:void 0}var ne=Oo,$o=ne(D,"WeakMap"),wt=$o;function Po(e,t){return e===t||e!==e&&t!==t}var Do=Po,Uo=9007199254740991;function No(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Uo}var zo=No;var Pp=Object.prototype;var Fo="[object Arguments]";function Lo(e){return Et(e)&&xe(e)==Fo}var Ei=Lo,Ri=Object.prototype,Bo=Ri.hasOwnProperty,Ro=Ri.propertyIsEnumerable,Dp=Ei(function(){return arguments}())?Ei:function(e){return Et(e)&&Bo.call(e,"callee")&&!Ro.call(e,"callee")};var qi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ai=qi&&typeof module=="object"&&module&&!module.nodeType&&module,qo=Ai&&Ai.exports===qi,Ci=qo?D.Buffer:void 0,Up=Ci?Ci.isBuffer:void 0;var Vo="[object Arguments]",Ho="[object Array]",Go="[object Boolean]",Ko="[object Date]",Yo="[object Error]",Wo="[object Function]",Qo="[object Map]",Zo="[object Number]",Xo="[object Object]",Jo="[object RegExp]",ea="[object Set]",ta="[object String]",ia="[object WeakMap]",ra="[object ArrayBuffer]",na="[object DataView]",oa="[object Float32Array]",aa="[object Float64Array]",sa="[object Int8Array]",la="[object Int16Array]",ca="[object Int32Array]",ua="[object Uint8Array]",da="[object Uint8ClampedArray]",ga="[object Uint16Array]",pa="[object Uint32Array]",S={};S[oa]=S[aa]=S[sa]=S[la]=S[ca]=S[ua]=S[da]=S[ga]=S[pa]=!0;S[Vo]=S[Ho]=S[ra]=S[Go]=S[na]=S[Ko]=S[Yo]=S[Wo]=S[Qo]=S[Zo]=S[Xo]=S[Jo]=S[ea]=S[ta]=S[ia]=!1;function ha(e){return Et(e)&&zo(e.length)&&!!S[xe(e)]}var fa=ha;function ma(e){return function(t){return e(t)}}var ya=ma,Vi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_e=Vi&&typeof module=="object"&&module&&!module.nodeType&&module,ba=_e&&_e.exports===Vi,vt=ba&&Fi.process,_a=function(){try{var e=_e&&_e.require&&_e.require("util").types;return e||vt&&vt.binding&&vt.binding("util")}catch{}}(),Ti=_a,Mi=Ti&&Ti.isTypedArray,Np=Mi?ya(Mi):fa;var va=Object.prototype,zp=va.hasOwnProperty;function wa(e,t){return function(i){return e(t(i))}}var xa=wa,Fp=xa(Object.keys,Object);var ka=Object.prototype,Lp=ka.hasOwnProperty;var Sa=ne(Object,"create"),ve=Sa;function Ia(){this.__data__=ve?ve(null):{},this.size=0}var Ea=Ia;function Aa(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ca=Aa,Ta="__lodash_hash_undefined__",Ma=Object.prototype,ja=Ma.hasOwnProperty;function Oa(e){var t=this.__data__;if(ve){var i=t[e];return i===Ta?void 0:i}return ja.call(t,e)?t[e]:void 0}var $a=Oa,Pa=Object.prototype,Da=Pa.hasOwnProperty;function Ua(e){var t=this.__data__;return ve?t[e]!==void 0:Da.call(t,e)}var Na=Ua,za="__lodash_hash_undefined__";function Fa(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=ve&&t===void 0?za:t,this}var La=Fa;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=Ea;oe.prototype.delete=Ca;oe.prototype.get=$a;oe.prototype.has=Na;oe.prototype.set=La;var ji=oe;function Ba(){this.__data__=[],this.size=0}var Ra=Ba;function qa(e,t){for(var i=e.length;i--;)if(Do(e[i][0],t))return i;return-1}var Re=qa,Va=Array.prototype,Ha=Va.splice;function Ga(e){var t=this.__data__,i=Re(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():Ha.call(t,i,1),--this.size,!0}var Ka=Ga;function Ya(e){var t=this.__data__,i=Re(t,e);return i<0?void 0:t[i][1]}var Wa=Ya;function Qa(e){return Re(this.__data__,e)>-1}var Za=Qa;function Xa(e,t){var i=this.__data__,r=Re(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var Ja=Xa;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=Ra;ae.prototype.delete=Ka;ae.prototype.get=Wa;ae.prototype.has=Za;ae.prototype.set=Ja;var qe=ae,es=ne(D,"Map"),we=es;function ts(){this.size=0,this.__data__={hash:new ji,map:new(we||qe),string:new ji}}var is=ts;function rs(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ns=rs;function os(e,t){var i=e.__data__;return ns(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Ve=os;function as(e){var t=Ve(this,e).delete(e);return this.size-=t?1:0,t}var ss=as;function ls(e){return Ve(this,e).get(e)}var cs=ls;function us(e){return Ve(this,e).has(e)}var ds=us;function gs(e,t){var i=Ve(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var ps=gs;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=is;se.prototype.delete=ss;se.prototype.get=cs;se.prototype.has=ds;se.prototype.set=ps;var Hi=se;function hs(){this.__data__=new qe,this.size=0}var fs=hs;function ms(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var ys=ms;function bs(e){return this.__data__.get(e)}var _s=bs;function vs(e){return this.__data__.has(e)}var ws=vs,xs=200;function ks(e,t){var i=this.__data__;if(i instanceof qe){var r=i.__data__;if(!we||r.length<xs-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Hi(r)}return i.set(e,t),this.size=i.size,this}var Ss=ks;function ke(e){var t=this.__data__=new qe(e);this.size=t.size}ke.prototype.clear=fs;ke.prototype.delete=ys;ke.prototype.get=_s;ke.prototype.has=ws;ke.prototype.set=Ss;var Is=Object.prototype,Bp=Is.propertyIsEnumerable;var Es=ne(D,"DataView"),xt=Es,As=ne(D,"Promise"),kt=As,Cs=ne(D,"Set"),St=Cs,Oi="[object Map]",Ts="[object Object]",$i="[object Promise]",Pi="[object Set]",Di="[object WeakMap]",Ui="[object DataView]",Ms=Y(xt),js=Y(we),Os=Y(kt),$s=Y(St),Ps=Y(wt),ie=xe;(xt&&ie(new xt(new ArrayBuffer(1)))!=Ui||we&&ie(new we)!=Oi||kt&&ie(kt.resolve())!=$i||St&&ie(new St)!=Pi||wt&&ie(new wt)!=Di)&&(ie=function(e){var t=xe(e),i=t==Ts?e.constructor:void 0,r=i?Y(i):"";if(r)switch(r){case Ms:return Ui;case js:return Oi;case Os:return $i;case $s:return Pi;case Ps:return Di}return t});var Rp=D.Uint8Array;var Ds="__lodash_hash_undefined__";function Us(e){return this.__data__.set(e,Ds),this}var Ns=Us;function zs(e){return this.__data__.has(e)}var Fs=zs;function It(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Hi;++t<i;)this.add(e[t])}It.prototype.add=It.prototype.push=Ns;It.prototype.has=Fs;var Ni=re?re.prototype:void 0,qp=Ni?Ni.valueOf:void 0;var Ls=Object.prototype,Vp=Ls.hasOwnProperty;var Bs=Object.prototype,Hp=Bs.hasOwnProperty;var Gp=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Kp=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Yp=new RegExp(/[A-Fa-f0-9]{2}/,"g");function At(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}var Gi={Formats:Vn};function Rs(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=jt(e);return i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Image To Change"}}),qs(e,i),{[r]:(o,a)=>{let{builder:s,experimental:{global:c},payload:d}=o,l=d?.url??t.defaultUrl,u=c(`${e}.${a.id}`,l);return s.MediaPreview(a.id,{preview:{type:"image",uri:u.value},action:{label:"Select Image",onClick:()=>{i?.ui.openPanel(n,{payload:{onSelect:f=>{f.meta?.uri!=null&&u.setValue(f.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:u.value})}}}function qs(e,t){t?.ui.registerPanel(jt(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(jt(e))):t.ui.showNotification({type:"warning",message:`Only images are supported. Found '${a}'. Please choose a different image.`})}})})}function jt(e){return`ly.img.ai.${e}.imageSelection`}var Vs=Rs,Hs=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:d,sortKey:l}=e,u=[...this.assets];if(s&&s.length>0&&(u=u.filter(g=>g.groups&&s.some(h=>g.groups?.includes(h)))),c&&c.length>0&&(u=u.filter(g=>!g.groups||!c.some(h=>g.groups?.includes(h)))),o){let g=o.toLowerCase();u=u.filter(h=>{let _=h.label?.[r]?.toLowerCase(),b=h.tags?.[r]||[];return _&&_.includes(g)||b.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];u=u.filter(h=>{let _=h.tags?.[r]||[];return g.some(b=>_.includes(b))})}n&&u.sort((g,h)=>{let _=this.activeAssetIds.has(g.id),b=this.activeAssetIds.has(h.id);return _&&!b?-1:!_&&b?1:0}),l&&l!=="id"?u.sort((g,h)=>{let _=g.meta?.[l],b=h.meta?.[l];return _===void 0?1:b===void 0?-1:typeof _=="string"&&typeof b=="string"?d==="Descending"?b.localeCompare(_):_.localeCompare(b):typeof _=="number"&&typeof b=="number"?d==="Descending"?b-_:_-b:0}):l==="id"&&u.sort((g,h)=>d==="Descending"?h.id.localeCompare(g.id):g.id.localeCompare(h.id));let f=u.length,p=t*i,m=p+i,v=u.slice(p,m).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)})),w=m<f?t+1:void 0;return{assets:v,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 Gs=typeof global=="object"&&global&&global.Object===Object&&global,sr=Gs,Ks=typeof self=="object"&&self&&self.Object===Object&&self,Ys=sr||Ks||Function("return this")(),U=Ys,Ws=U.Symbol,ce=Ws,lr=Object.prototype,Qs=lr.hasOwnProperty,Zs=lr.toString,Se=ce?ce.toStringTag:void 0;function Xs(e){var t=Qs.call(e,Se),i=e[Se];try{e[Se]=void 0;var r=!0}catch{}var n=Zs.call(e);return r&&(t?e[Se]=i:delete e[Se]),n}var Js=Xs,el=Object.prototype,tl=el.toString;function il(e){return tl.call(e)}var rl=il,nl="[object Null]",ol="[object Undefined]",Ki=ce?ce.toStringTag:void 0;function al(e){return e==null?e===void 0?ol:nl:Ki&&Ki in Object(e)?Js(e):rl(e)}var Ce=al;function sl(e){return e!=null&&typeof e=="object"}var Nt=sl,Zp=Array.isArray;function ll(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var cr=ll,cl="[object AsyncFunction]",ul="[object Function]",dl="[object GeneratorFunction]",gl="[object Proxy]";function pl(e){if(!cr(e))return!1;var t=Ce(e);return t==ul||t==dl||t==cl||t==gl}var hl=pl,fl=U["__core-js_shared__"],Ct=fl,Yi=function(){var e=/[^.]+$/.exec(Ct&&Ct.keys&&Ct.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ml(e){return!!Yi&&Yi in e}var yl=ml,bl=Function.prototype,_l=bl.toString;function vl(e){if(e!=null){try{return _l.call(e)}catch{}try{return e+""}catch{}}return""}var W=vl,wl=/[\\^$.*+?()[\]{}|]/g,xl=/^\[object .+?Constructor\]$/,kl=Function.prototype,Sl=Object.prototype,Il=kl.toString,El=Sl.hasOwnProperty,Al=RegExp("^"+Il.call(El).replace(wl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Cl(e){if(!cr(e)||yl(e))return!1;var t=hl(e)?Al:xl;return t.test(W(e))}var Tl=Cl;function Ml(e,t){return e?.[t]}var jl=Ml;function Ol(e,t){var i=jl(e,t);return Tl(i)?i:void 0}var ue=Ol,$l=ue(U,"WeakMap"),Ot=$l;function Pl(e,t){return e===t||e!==e&&t!==t}var Dl=Pl,Ul=9007199254740991;function Nl(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Ul}var zl=Nl,Xp=Object.prototype,Fl="[object Arguments]";function Ll(e){return Nt(e)&&Ce(e)==Fl}var Wi=Ll,ur=Object.prototype,Bl=ur.hasOwnProperty,Rl=ur.propertyIsEnumerable,Jp=Wi(function(){return arguments}())?Wi:function(e){return Nt(e)&&Bl.call(e,"callee")&&!Rl.call(e,"callee")},dr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Qi=dr&&typeof module=="object"&&module&&!module.nodeType&&module,ql=Qi&&Qi.exports===dr,Zi=ql?U.Buffer:void 0,eh=Zi?Zi.isBuffer:void 0,Vl="[object Arguments]",Hl="[object Array]",Gl="[object Boolean]",Kl="[object Date]",Yl="[object Error]",Wl="[object Function]",Ql="[object Map]",Zl="[object Number]",Xl="[object Object]",Jl="[object RegExp]",ec="[object Set]",tc="[object String]",ic="[object WeakMap]",rc="[object ArrayBuffer]",nc="[object DataView]",oc="[object Float32Array]",ac="[object Float64Array]",sc="[object Int8Array]",lc="[object Int16Array]",cc="[object Int32Array]",uc="[object Uint8Array]",dc="[object Uint8ClampedArray]",gc="[object Uint16Array]",pc="[object Uint32Array]",I={};I[oc]=I[ac]=I[sc]=I[lc]=I[cc]=I[uc]=I[dc]=I[gc]=I[pc]=!0;I[Vl]=I[Hl]=I[rc]=I[Gl]=I[nc]=I[Kl]=I[Yl]=I[Wl]=I[Ql]=I[Zl]=I[Xl]=I[Jl]=I[ec]=I[tc]=I[ic]=!1;function hc(e){return Nt(e)&&zl(e.length)&&!!I[Ce(e)]}var fc=hc;function mc(e){return function(t){return e(t)}}var yc=mc,gr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ie=gr&&typeof module=="object"&&module&&!module.nodeType&&module,bc=Ie&&Ie.exports===gr,Tt=bc&&sr.process,_c=function(){try{var e=Ie&&Ie.require&&Ie.require("util").types;return e||Tt&&Tt.binding&&Tt.binding("util")}catch{}}(),Xi=_c,Ji=Xi&&Xi.isTypedArray,th=Ji?yc(Ji):fc,vc=Object.prototype,ih=vc.hasOwnProperty;function wc(e,t){return function(i){return e(t(i))}}var xc=wc,rh=xc(Object.keys,Object),kc=Object.prototype,nh=kc.hasOwnProperty,Sc=ue(Object,"create"),Ee=Sc;function Ic(){this.__data__=Ee?Ee(null):{},this.size=0}var Ec=Ic;function Ac(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Cc=Ac,Tc="__lodash_hash_undefined__",Mc=Object.prototype,jc=Mc.hasOwnProperty;function Oc(e){var t=this.__data__;if(Ee){var i=t[e];return i===Tc?void 0:i}return jc.call(t,e)?t[e]:void 0}var $c=Oc,Pc=Object.prototype,Dc=Pc.hasOwnProperty;function Uc(e){var t=this.__data__;return Ee?t[e]!==void 0:Dc.call(t,e)}var Nc=Uc,zc="__lodash_hash_undefined__";function Fc(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ee&&t===void 0?zc:t,this}var Lc=Fc;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=Ec;de.prototype.delete=Cc;de.prototype.get=$c;de.prototype.has=Nc;de.prototype.set=Lc;var er=de;function Bc(){this.__data__=[],this.size=0}var Rc=Bc;function qc(e,t){for(var i=e.length;i--;)if(Dl(e[i][0],t))return i;return-1}var He=qc,Vc=Array.prototype,Hc=Vc.splice;function Gc(e){var t=this.__data__,i=He(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():Hc.call(t,i,1),--this.size,!0}var Kc=Gc;function Yc(e){var t=this.__data__,i=He(t,e);return i<0?void 0:t[i][1]}var Wc=Yc;function Qc(e){return He(this.__data__,e)>-1}var Zc=Qc;function Xc(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 Jc=Xc;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=Rc;ge.prototype.delete=Kc;ge.prototype.get=Wc;ge.prototype.has=Zc;ge.prototype.set=Jc;var Ge=ge,eu=ue(U,"Map"),Ae=eu;function tu(){this.size=0,this.__data__={hash:new er,map:new(Ae||Ge),string:new er}}var iu=tu;function ru(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var nu=ru;function ou(e,t){var i=e.__data__;return nu(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Ke=ou;function au(e){var t=Ke(this,e).delete(e);return this.size-=t?1:0,t}var su=au;function lu(e){return Ke(this,e).get(e)}var cu=lu;function uu(e){return Ke(this,e).has(e)}var du=uu;function gu(e,t){var i=Ke(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var pu=gu;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=iu;pe.prototype.delete=su;pe.prototype.get=cu;pe.prototype.has=du;pe.prototype.set=pu;var pr=pe;function hu(){this.__data__=new Ge,this.size=0}var fu=hu;function mu(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var yu=mu;function bu(e){return this.__data__.get(e)}var _u=bu;function vu(e){return this.__data__.has(e)}var wu=vu,xu=200;function ku(e,t){var i=this.__data__;if(i instanceof Ge){var r=i.__data__;if(!Ae||r.length<xu-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new pr(r)}return i.set(e,t),this.size=i.size,this}var Su=ku;function Te(e){var t=this.__data__=new Ge(e);this.size=t.size}Te.prototype.clear=fu;Te.prototype.delete=yu;Te.prototype.get=_u;Te.prototype.has=wu;Te.prototype.set=Su;var Iu=Object.prototype,oh=Iu.propertyIsEnumerable,Eu=ue(U,"DataView"),$t=Eu,Au=ue(U,"Promise"),Pt=Au,Cu=ue(U,"Set"),Dt=Cu,tr="[object Map]",Tu="[object Object]",ir="[object Promise]",rr="[object Set]",nr="[object WeakMap]",or="[object DataView]",Mu=W($t),ju=W(Ae),Ou=W(Pt),$u=W(Dt),Pu=W(Ot),le=Ce;($t&&le(new $t(new ArrayBuffer(1)))!=or||Ae&&le(new Ae)!=tr||Pt&&le(Pt.resolve())!=ir||Dt&&le(new Dt)!=rr||Ot&&le(new Ot)!=nr)&&(le=function(e){var t=Ce(e),i=t==Tu?e.constructor:void 0,r=i?W(i):"";if(r)switch(r){case Mu:return or;case ju:return tr;case Ou:return ir;case $u:return rr;case Pu:return nr}return t});var ah=U.Uint8Array,Du="__lodash_hash_undefined__";function Uu(e){return this.__data__.set(e,Du),this}var Nu=Uu;function zu(e){return this.__data__.has(e)}var Fu=zu;function Ut(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new pr;++t<i;)this.add(e[t])}Ut.prototype.add=Ut.prototype.push=Nu;Ut.prototype.has=Fu;var ar=ce?ce.prototype:void 0,sh=ar?ar.valueOf:void 0,Lu=Object.prototype,lh=Lu.hasOwnProperty,Bu=Object.prototype,ch=Bu.hasOwnProperty,uh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),dh=new RegExp(/[A-Fa-f0-9]{1}/,"g"),gh=new RegExp(/[A-Fa-f0-9]{2}/,"g");function Ru(e){return e!==void 0}var qu=Ru;function Vu(e,t){let{cesdk:i}=t;if(i==null)return{};let r=t.propertyKey??"style",n=Gu(e);i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${e}.${r}`]:"Style"}});let o=Yu({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=Wu({cesdk:i,providerId:e,styles:a}),c=s.id;return Qu(s,{cesdk:i}),Hu({providerId:e,cesdk:i,panelId:n,entryId:c}),{[t.propertyKeyForPrompt??"prompt"]:(d,l)=>{let u=d.state("prompt","");return d.builder.TextArea(`${l.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??"prompt",placeholder:t.i18n?.prompt?.placeholder,...u}),()=>{let[f]=s.getActiveAssetIds(),p=s.getAsset(f);return{id:l.id,type:"string",value:p?.meta?.prompt==null?u.value:`${u.value}; ${p.meta.prompt}`}}},[r]:(d,l)=>{let{builder:u,state:f}=d;if(a.length>0){let p=f("style",a[0]);return u.Button(`${l.id}`,{inputLabel:`${e}.${l.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async v=>{s.clearActiveAssets(),s.setAssetActive(v.id),p.setValue({id:v.id,label:v.label??v.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function Hu(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 Gu(e){return`ly.img.ai.${e}.styleSelection`}var Ku=[{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 Yu(e){return Ku.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(qu)}var Wu=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 Hs(r,t),o=e.styles[0];return n.setAssetActive(o.id),n},Qu=(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"})},Zu=Vu;var Xu="ly.img.ai";function Me(e){return`${Xu}.${e}`}var Mt="@imgly/plugin-ai-generation",ph=`
71
+ `,zi=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:d,sortKey:l}=e,u=[...this.assets];if(s&&s.length>0&&(u=u.filter(g=>g.groups&&s.some(f=>g.groups?.includes(f)))),c&&c.length>0&&(u=u.filter(g=>!g.groups||!c.some(f=>g.groups?.includes(f)))),o){let g=o.toLowerCase();u=u.filter(f=>{let _=f.label?.[r]?.toLowerCase(),b=f.tags?.[r]||[];return _&&_.includes(g)||b.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];u=u.filter(f=>{let _=f.tags?.[r]||[];return g.some(b=>_.includes(b))})}n&&u.sort((g,f)=>{let _=this.activeAssetIds.has(g.id),b=this.activeAssetIds.has(f.id);return _&&!b?-1:!_&&b?1:0}),l&&l!=="id"?u.sort((g,f)=>{let _=g.meta?.[l],b=f.meta?.[l];return _===void 0?1:b===void 0?-1:typeof _=="string"&&typeof b=="string"?d==="Descending"?b.localeCompare(_):_.localeCompare(b):typeof _=="number"&&typeof b=="number"?d==="Descending"?b-_:_-b:0}):l==="id"&&u.sort((g,f)=>d==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=u.length,p=t*i,m=p+i,v=u.slice(p,m).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)})),w=m<h?t+1:void 0;return{assets:v,currentPage:t,nextPage:w,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 Gn=typeof global=="object"&&global&&global.Object===Object&&global,Fi=Gn,Kn=typeof self=="object"&&self&&self.Object===Object&&self,Yn=Fi||Kn||Function("return this")(),D=Yn,Qn=D.Symbol,re=Qn,Li=Object.prototype,Wn=Li.hasOwnProperty,Zn=Li.toString,be=re?re.toStringTag:void 0;function Xn(e){var t=Wn.call(e,be),i=e[be];try{e[be]=void 0;var r=!0}catch{}var n=Zn.call(e);return r&&(t?e[be]=i:delete e[be]),n}var Jn=Xn,eo=Object.prototype,to=eo.toString;function io(e){return to.call(e)}var ro=io,no="[object Null]",oo="[object Undefined]",Si=re?re.toStringTag:void 0;function ao(e){return e==null?e===void 0?oo:no:Si&&Si in Object(e)?Jn(e):ro(e)}var xe=ao;function so(e){return e!=null&&typeof e=="object"}var Et=so,Pp=Array.isArray;function lo(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Bi=lo,co="[object AsyncFunction]",uo="[object Function]",go="[object GeneratorFunction]",po="[object Proxy]";function fo(e){if(!Bi(e))return!1;var t=xe(e);return t==uo||t==go||t==co||t==po}var ho=fo,mo=D["__core-js_shared__"],_t=mo,Ii=function(){var e=/[^.]+$/.exec(_t&&_t.keys&&_t.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function yo(e){return!!Ii&&Ii in e}var bo=yo,_o=Function.prototype,vo=_o.toString;function wo(e){if(e!=null){try{return vo.call(e)}catch{}try{return e+""}catch{}}return""}var Y=wo,xo=/[\\^$.*+?()[\]{}|]/g,ko=/^\[object .+?Constructor\]$/,So=Function.prototype,Io=Object.prototype,Eo=So.toString,Ao=Io.hasOwnProperty,Co=RegExp("^"+Eo.call(Ao).replace(xo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function To(e){if(!Bi(e)||bo(e))return!1;var t=ho(e)?Co:ko;return t.test(Y(e))}var Mo=To;function $o(e,t){return e?.[t]}var jo=$o;function Oo(e,t){var i=jo(e,t);return Mo(i)?i:void 0}var ne=Oo,Po=ne(D,"WeakMap"),wt=Po;function Do(e,t){return e===t||e!==e&&t!==t}var Uo=Do,No=9007199254740991;function zo(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=No}var Fo=zo;var Dp=Object.prototype;var Lo="[object Arguments]";function Bo(e){return Et(e)&&xe(e)==Lo}var Ei=Bo,Ri=Object.prototype,Ro=Ri.hasOwnProperty,qo=Ri.propertyIsEnumerable,Up=Ei(function(){return arguments}())?Ei:function(e){return Et(e)&&Ro.call(e,"callee")&&!qo.call(e,"callee")};var qi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ai=qi&&typeof module=="object"&&module&&!module.nodeType&&module,Vo=Ai&&Ai.exports===qi,Ci=Vo?D.Buffer:void 0,Np=Ci?Ci.isBuffer:void 0;var Ho="[object Arguments]",Go="[object Array]",Ko="[object Boolean]",Yo="[object Date]",Qo="[object Error]",Wo="[object Function]",Zo="[object Map]",Xo="[object Number]",Jo="[object Object]",ea="[object RegExp]",ta="[object Set]",ia="[object String]",ra="[object WeakMap]",na="[object ArrayBuffer]",oa="[object DataView]",aa="[object Float32Array]",sa="[object Float64Array]",la="[object Int8Array]",ca="[object Int16Array]",ua="[object Int32Array]",da="[object Uint8Array]",ga="[object Uint8ClampedArray]",pa="[object Uint16Array]",fa="[object Uint32Array]",S={};S[aa]=S[sa]=S[la]=S[ca]=S[ua]=S[da]=S[ga]=S[pa]=S[fa]=!0;S[Ho]=S[Go]=S[na]=S[Ko]=S[oa]=S[Yo]=S[Qo]=S[Wo]=S[Zo]=S[Xo]=S[Jo]=S[ea]=S[ta]=S[ia]=S[ra]=!1;function ha(e){return Et(e)&&Fo(e.length)&&!!S[xe(e)]}var ma=ha;function ya(e){return function(t){return e(t)}}var ba=ya,Vi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_e=Vi&&typeof module=="object"&&module&&!module.nodeType&&module,_a=_e&&_e.exports===Vi,vt=_a&&Fi.process,va=function(){try{var e=_e&&_e.require&&_e.require("util").types;return e||vt&&vt.binding&&vt.binding("util")}catch{}}(),Ti=va,Mi=Ti&&Ti.isTypedArray,zp=Mi?ba(Mi):ma;var wa=Object.prototype,Fp=wa.hasOwnProperty;function xa(e,t){return function(i){return e(t(i))}}var ka=xa,Lp=ka(Object.keys,Object);var Sa=Object.prototype,Bp=Sa.hasOwnProperty;var Ia=ne(Object,"create"),ve=Ia;function Ea(){this.__data__=ve?ve(null):{},this.size=0}var Aa=Ea;function Ca(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ta=Ca,Ma="__lodash_hash_undefined__",$a=Object.prototype,ja=$a.hasOwnProperty;function Oa(e){var t=this.__data__;if(ve){var i=t[e];return i===Ma?void 0:i}return ja.call(t,e)?t[e]:void 0}var Pa=Oa,Da=Object.prototype,Ua=Da.hasOwnProperty;function Na(e){var t=this.__data__;return ve?t[e]!==void 0:Ua.call(t,e)}var za=Na,Fa="__lodash_hash_undefined__";function La(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=ve&&t===void 0?Fa:t,this}var Ba=La;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=Aa;oe.prototype.delete=Ta;oe.prototype.get=Pa;oe.prototype.has=za;oe.prototype.set=Ba;var $i=oe;function Ra(){this.__data__=[],this.size=0}var qa=Ra;function Va(e,t){for(var i=e.length;i--;)if(Uo(e[i][0],t))return i;return-1}var Re=Va,Ha=Array.prototype,Ga=Ha.splice;function Ka(e){var t=this.__data__,i=Re(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():Ga.call(t,i,1),--this.size,!0}var Ya=Ka;function Qa(e){var t=this.__data__,i=Re(t,e);return i<0?void 0:t[i][1]}var Wa=Qa;function Za(e){return Re(this.__data__,e)>-1}var Xa=Za;function Ja(e,t){var i=this.__data__,r=Re(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var es=Ja;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=qa;ae.prototype.delete=Ya;ae.prototype.get=Wa;ae.prototype.has=Xa;ae.prototype.set=es;var qe=ae,ts=ne(D,"Map"),we=ts;function is(){this.size=0,this.__data__={hash:new $i,map:new(we||qe),string:new $i}}var rs=is;function ns(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var os=ns;function as(e,t){var i=e.__data__;return os(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Ve=as;function ss(e){var t=Ve(this,e).delete(e);return this.size-=t?1:0,t}var ls=ss;function cs(e){return Ve(this,e).get(e)}var us=cs;function ds(e){return Ve(this,e).has(e)}var gs=ds;function ps(e,t){var i=Ve(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var fs=ps;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=rs;se.prototype.delete=ls;se.prototype.get=us;se.prototype.has=gs;se.prototype.set=fs;var Hi=se;function hs(){this.__data__=new qe,this.size=0}var ms=hs;function ys(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var bs=ys;function _s(e){return this.__data__.get(e)}var vs=_s;function ws(e){return this.__data__.has(e)}var xs=ws,ks=200;function Ss(e,t){var i=this.__data__;if(i instanceof qe){var r=i.__data__;if(!we||r.length<ks-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Hi(r)}return i.set(e,t),this.size=i.size,this}var Is=Ss;function ke(e){var t=this.__data__=new qe(e);this.size=t.size}ke.prototype.clear=ms;ke.prototype.delete=bs;ke.prototype.get=vs;ke.prototype.has=xs;ke.prototype.set=Is;var Es=Object.prototype,Rp=Es.propertyIsEnumerable;var As=ne(D,"DataView"),xt=As,Cs=ne(D,"Promise"),kt=Cs,Ts=ne(D,"Set"),St=Ts,ji="[object Map]",Ms="[object Object]",Oi="[object Promise]",Pi="[object Set]",Di="[object WeakMap]",Ui="[object DataView]",$s=Y(xt),js=Y(we),Os=Y(kt),Ps=Y(St),Ds=Y(wt),ie=xe;(xt&&ie(new xt(new ArrayBuffer(1)))!=Ui||we&&ie(new we)!=ji||kt&&ie(kt.resolve())!=Oi||St&&ie(new St)!=Pi||wt&&ie(new wt)!=Di)&&(ie=function(e){var t=xe(e),i=t==Ms?e.constructor:void 0,r=i?Y(i):"";if(r)switch(r){case $s:return Ui;case js:return ji;case Os:return Oi;case Ps:return Pi;case Ds:return Di}return t});var qp=D.Uint8Array;var Us="__lodash_hash_undefined__";function Ns(e){return this.__data__.set(e,Us),this}var zs=Ns;function Fs(e){return this.__data__.has(e)}var Ls=Fs;function It(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Hi;++t<i;)this.add(e[t])}It.prototype.add=It.prototype.push=zs;It.prototype.has=Ls;var Ni=re?re.prototype:void 0,Vp=Ni?Ni.valueOf:void 0;var Bs=Object.prototype,Hp=Bs.hasOwnProperty;var Rs=Object.prototype,Gp=Rs.hasOwnProperty;var Kp=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Yp=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Qp=new RegExp(/[A-Fa-f0-9]{2}/,"g");function At(e){return{"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg"}[e]??"png"}var Gi={Formats:Hn};function qs(e,t){let{cesdk:i}=t,r=t.propertyKey??"image_url",n=$t(e);return i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Image To Change"}}),Vs(e,i),{[r]:(o,a)=>{let{builder:s,experimental:{global:c},payload:d}=o,l=d?.url??t.defaultUrl,u=c(`${e}.${a.id}`,l);return s.MediaPreview(a.id,{preview:{type:"image",uri:u.value},action:{label:"Select Image",onClick:()=>{i?.ui.openPanel(n,{payload:{onSelect:h=>{h.meta?.uri!=null&&u.setValue(h.meta?.uri)}}})}}}),()=>({id:a.id,type:"string",value:u.value})}}}function Vs(e,t){t?.ui.registerPanel($t(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($t(e))):t.ui.showNotification({type:"warning",message:`Only images are supported. Found '${a}'. Please choose a different image.`})}})})}function $t(e){return`ly.img.ai.${e}.imageSelection`}var Hs=qs,Gs=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:d,sortKey:l}=e,u=[...this.assets];if(s&&s.length>0&&(u=u.filter(g=>g.groups&&s.some(f=>g.groups?.includes(f)))),c&&c.length>0&&(u=u.filter(g=>!g.groups||!c.some(f=>g.groups?.includes(f)))),o){let g=o.toLowerCase();u=u.filter(f=>{let _=f.label?.[r]?.toLowerCase(),b=f.tags?.[r]||[];return _&&_.includes(g)||b.some(C=>C.toLowerCase().includes(g))})}if(a&&a.length>0){let g=Array.isArray(a)?a:[a];u=u.filter(f=>{let _=f.tags?.[r]||[];return g.some(b=>_.includes(b))})}n&&u.sort((g,f)=>{let _=this.activeAssetIds.has(g.id),b=this.activeAssetIds.has(f.id);return _&&!b?-1:!_&&b?1:0}),l&&l!=="id"?u.sort((g,f)=>{let _=g.meta?.[l],b=f.meta?.[l];return _===void 0?1:b===void 0?-1:typeof _=="string"&&typeof b=="string"?d==="Descending"?b.localeCompare(_):_.localeCompare(b):typeof _=="number"&&typeof b=="number"?d==="Descending"?b-_:_-b:0}):l==="id"&&u.sort((g,f)=>d==="Descending"?f.id.localeCompare(g.id):g.id.localeCompare(f.id));let h=u.length,p=t*i,m=p+i,v=u.slice(p,m).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)})),w=m<h?t+1:void 0;return{assets:v,currentPage:t,nextPage:w,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 Ks=typeof global=="object"&&global&&global.Object===Object&&global,sr=Ks,Ys=typeof self=="object"&&self&&self.Object===Object&&self,Qs=sr||Ys||Function("return this")(),U=Qs,Ws=U.Symbol,ce=Ws,lr=Object.prototype,Zs=lr.hasOwnProperty,Xs=lr.toString,Se=ce?ce.toStringTag:void 0;function Js(e){var t=Zs.call(e,Se),i=e[Se];try{e[Se]=void 0;var r=!0}catch{}var n=Xs.call(e);return r&&(t?e[Se]=i:delete e[Se]),n}var el=Js,tl=Object.prototype,il=tl.toString;function rl(e){return il.call(e)}var nl=rl,ol="[object Null]",al="[object Undefined]",Ki=ce?ce.toStringTag:void 0;function sl(e){return e==null?e===void 0?al:ol:Ki&&Ki in Object(e)?el(e):nl(e)}var Ce=sl;function ll(e){return e!=null&&typeof e=="object"}var Nt=ll,Xp=Array.isArray;function cl(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var cr=cl,ul="[object AsyncFunction]",dl="[object Function]",gl="[object GeneratorFunction]",pl="[object Proxy]";function fl(e){if(!cr(e))return!1;var t=Ce(e);return t==dl||t==gl||t==ul||t==pl}var hl=fl,ml=U["__core-js_shared__"],Ct=ml,Yi=function(){var e=/[^.]+$/.exec(Ct&&Ct.keys&&Ct.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function yl(e){return!!Yi&&Yi in e}var bl=yl,_l=Function.prototype,vl=_l.toString;function wl(e){if(e!=null){try{return vl.call(e)}catch{}try{return e+""}catch{}}return""}var Q=wl,xl=/[\\^$.*+?()[\]{}|]/g,kl=/^\[object .+?Constructor\]$/,Sl=Function.prototype,Il=Object.prototype,El=Sl.toString,Al=Il.hasOwnProperty,Cl=RegExp("^"+El.call(Al).replace(xl,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Tl(e){if(!cr(e)||bl(e))return!1;var t=hl(e)?Cl:kl;return t.test(Q(e))}var Ml=Tl;function $l(e,t){return e?.[t]}var jl=$l;function Ol(e,t){var i=jl(e,t);return Ml(i)?i:void 0}var ue=Ol,Pl=ue(U,"WeakMap"),jt=Pl;function Dl(e,t){return e===t||e!==e&&t!==t}var Ul=Dl,Nl=9007199254740991;function zl(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Nl}var Fl=zl,Jp=Object.prototype,Ll="[object Arguments]";function Bl(e){return Nt(e)&&Ce(e)==Ll}var Qi=Bl,ur=Object.prototype,Rl=ur.hasOwnProperty,ql=ur.propertyIsEnumerable,ef=Qi(function(){return arguments}())?Qi:function(e){return Nt(e)&&Rl.call(e,"callee")&&!ql.call(e,"callee")},dr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wi=dr&&typeof module=="object"&&module&&!module.nodeType&&module,Vl=Wi&&Wi.exports===dr,Zi=Vl?U.Buffer:void 0,tf=Zi?Zi.isBuffer:void 0,Hl="[object Arguments]",Gl="[object Array]",Kl="[object Boolean]",Yl="[object Date]",Ql="[object Error]",Wl="[object Function]",Zl="[object Map]",Xl="[object Number]",Jl="[object Object]",ec="[object RegExp]",tc="[object Set]",ic="[object String]",rc="[object WeakMap]",nc="[object ArrayBuffer]",oc="[object DataView]",ac="[object Float32Array]",sc="[object Float64Array]",lc="[object Int8Array]",cc="[object Int16Array]",uc="[object Int32Array]",dc="[object Uint8Array]",gc="[object Uint8ClampedArray]",pc="[object Uint16Array]",fc="[object Uint32Array]",I={};I[ac]=I[sc]=I[lc]=I[cc]=I[uc]=I[dc]=I[gc]=I[pc]=I[fc]=!0;I[Hl]=I[Gl]=I[nc]=I[Kl]=I[oc]=I[Yl]=I[Ql]=I[Wl]=I[Zl]=I[Xl]=I[Jl]=I[ec]=I[tc]=I[ic]=I[rc]=!1;function hc(e){return Nt(e)&&Fl(e.length)&&!!I[Ce(e)]}var mc=hc;function yc(e){return function(t){return e(t)}}var bc=yc,gr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ie=gr&&typeof module=="object"&&module&&!module.nodeType&&module,_c=Ie&&Ie.exports===gr,Tt=_c&&sr.process,vc=function(){try{var e=Ie&&Ie.require&&Ie.require("util").types;return e||Tt&&Tt.binding&&Tt.binding("util")}catch{}}(),Xi=vc,Ji=Xi&&Xi.isTypedArray,rf=Ji?bc(Ji):mc,wc=Object.prototype,nf=wc.hasOwnProperty;function xc(e,t){return function(i){return e(t(i))}}var kc=xc,of=kc(Object.keys,Object),Sc=Object.prototype,af=Sc.hasOwnProperty,Ic=ue(Object,"create"),Ee=Ic;function Ec(){this.__data__=Ee?Ee(null):{},this.size=0}var Ac=Ec;function Cc(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Tc=Cc,Mc="__lodash_hash_undefined__",$c=Object.prototype,jc=$c.hasOwnProperty;function Oc(e){var t=this.__data__;if(Ee){var i=t[e];return i===Mc?void 0:i}return jc.call(t,e)?t[e]:void 0}var Pc=Oc,Dc=Object.prototype,Uc=Dc.hasOwnProperty;function Nc(e){var t=this.__data__;return Ee?t[e]!==void 0:Uc.call(t,e)}var zc=Nc,Fc="__lodash_hash_undefined__";function Lc(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ee&&t===void 0?Fc:t,this}var Bc=Lc;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=Ac;de.prototype.delete=Tc;de.prototype.get=Pc;de.prototype.has=zc;de.prototype.set=Bc;var er=de;function Rc(){this.__data__=[],this.size=0}var qc=Rc;function Vc(e,t){for(var i=e.length;i--;)if(Ul(e[i][0],t))return i;return-1}var He=Vc,Hc=Array.prototype,Gc=Hc.splice;function Kc(e){var t=this.__data__,i=He(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():Gc.call(t,i,1),--this.size,!0}var Yc=Kc;function Qc(e){var t=this.__data__,i=He(t,e);return i<0?void 0:t[i][1]}var Wc=Qc;function Zc(e){return He(this.__data__,e)>-1}var Xc=Zc;function Jc(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 eu=Jc;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=qc;ge.prototype.delete=Yc;ge.prototype.get=Wc;ge.prototype.has=Xc;ge.prototype.set=eu;var Ge=ge,tu=ue(U,"Map"),Ae=tu;function iu(){this.size=0,this.__data__={hash:new er,map:new(Ae||Ge),string:new er}}var ru=iu;function nu(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ou=nu;function au(e,t){var i=e.__data__;return ou(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Ke=au;function su(e){var t=Ke(this,e).delete(e);return this.size-=t?1:0,t}var lu=su;function cu(e){return Ke(this,e).get(e)}var uu=cu;function du(e){return Ke(this,e).has(e)}var gu=du;function pu(e,t){var i=Ke(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var fu=pu;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=ru;pe.prototype.delete=lu;pe.prototype.get=uu;pe.prototype.has=gu;pe.prototype.set=fu;var pr=pe;function hu(){this.__data__=new Ge,this.size=0}var mu=hu;function yu(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var bu=yu;function _u(e){return this.__data__.get(e)}var vu=_u;function wu(e){return this.__data__.has(e)}var xu=wu,ku=200;function Su(e,t){var i=this.__data__;if(i instanceof Ge){var r=i.__data__;if(!Ae||r.length<ku-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new pr(r)}return i.set(e,t),this.size=i.size,this}var Iu=Su;function Te(e){var t=this.__data__=new Ge(e);this.size=t.size}Te.prototype.clear=mu;Te.prototype.delete=bu;Te.prototype.get=vu;Te.prototype.has=xu;Te.prototype.set=Iu;var Eu=Object.prototype,sf=Eu.propertyIsEnumerable,Au=ue(U,"DataView"),Ot=Au,Cu=ue(U,"Promise"),Pt=Cu,Tu=ue(U,"Set"),Dt=Tu,tr="[object Map]",Mu="[object Object]",ir="[object Promise]",rr="[object Set]",nr="[object WeakMap]",or="[object DataView]",$u=Q(Ot),ju=Q(Ae),Ou=Q(Pt),Pu=Q(Dt),Du=Q(jt),le=Ce;(Ot&&le(new Ot(new ArrayBuffer(1)))!=or||Ae&&le(new Ae)!=tr||Pt&&le(Pt.resolve())!=ir||Dt&&le(new Dt)!=rr||jt&&le(new jt)!=nr)&&(le=function(e){var t=Ce(e),i=t==Mu?e.constructor:void 0,r=i?Q(i):"";if(r)switch(r){case $u:return or;case ju:return tr;case Ou:return ir;case Pu:return rr;case Du:return nr}return t});var lf=U.Uint8Array,Uu="__lodash_hash_undefined__";function Nu(e){return this.__data__.set(e,Uu),this}var zu=Nu;function Fu(e){return this.__data__.has(e)}var Lu=Fu;function Ut(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new pr;++t<i;)this.add(e[t])}Ut.prototype.add=Ut.prototype.push=zu;Ut.prototype.has=Lu;var ar=ce?ce.prototype:void 0,cf=ar?ar.valueOf:void 0,Bu=Object.prototype,uf=Bu.hasOwnProperty,Ru=Object.prototype,df=Ru.hasOwnProperty,gf=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),pf=new RegExp(/[A-Fa-f0-9]{1}/,"g"),ff=new RegExp(/[A-Fa-f0-9]{2}/,"g");function qu(e){return e!==void 0}var Vu=qu;function Hu(e,t){let{cesdk:i}=t;if(i==null)return{};let r=t.propertyKey??"style",n=Ku(e);i.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${e}.${r}`]:"Style"}});let o=Qu({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=Wu({cesdk:i,providerId:e,styles:a}),c=s.id;return Zu(s,{cesdk:i}),Gu({providerId:e,cesdk:i,panelId:n,entryId:c}),{[t.propertyKeyForPrompt??"prompt"]:(d,l)=>{let u=d.state("prompt","");return d.builder.TextArea(`${l.id}`,{inputLabel:t.i18n?.prompt?.inputLabel??t.propertyKeyForPrompt??"prompt",placeholder:t.i18n?.prompt?.placeholder,...u}),()=>{let[h]=s.getActiveAssetIds(),p=s.getAsset(h);return{id:l.id,type:"string",value:p?.meta?.prompt==null?u.value:`${u.value}; ${p.meta.prompt}`}}},[r]:(d,l)=>{let{builder:u,state:h}=d;if(a.length>0){let p=h("style",a[0]);return u.Button(`${l.id}`,{inputLabel:`${e}.${l.id}`,icon:"@imgly/Appearance",isDisabled:a.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let m={onSelect:async v=>{s.clearActiveAssets(),s.setAssetActive(v.id),p.setValue({id:v.id,label:v.label??v.id}),i.ui.closePanel(n)}};i.ui.openPanel(n,{payload:m})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function Gu(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 Ku(e){return`ly.img.ai.${e}.styleSelection`}var Yu=[{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 Qu(e){return Yu.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(Vu)}var Wu=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 Gs(r,t),o=e.styles[0];return n.setAssetActive(o.id),n},Zu=(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"})},Xu=Hu;var Ju="ly.img.ai";function Me(e){return`${Ju}.${e}`}function fr(e,t){let i={...e};if(!t)return i;for(let[r,n]of Object.entries(t))n===!1||n===null||n===void 0?delete i[r]:n===!0?r in e||(i[r]=!0):i[r]=n;return i}var Mt="@imgly/plugin-ai-generation",hf=`
72
72
  <svg>
73
73
  <symbol
74
74
  fill="none"
@@ -129,7 +129,7 @@ var zn=Object.create;var xi=Object.defineProperty;var Fn=Object.getOwnPropertyDe
129
129
 
130
130
  </symbol>
131
131
  </svg>
132
- `;var hr={ImageUrl:Vs,StyleTransfer:Zu};var fr={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},Recraft20bInput:{title:"TextToImageInput",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},image_size:{anyOf:[{enum:["square_hd","square","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"],type:"string"},{$ref:"#/components/schemas/ImageSize"}],title:"Format",default:"square_hd","x-imgly-enum-labels":{ImageSize:"Custom",square_hd:"Square HD",square:"Square",portrait_4_3:"Portrait 4:3",portrait_16_9:"Portrait 16:9",landscape_4_3:"Landscape 4:3",landscape_16_9:"Landscape 16:9"},"x-imgly-enum-icons":{square:"@imgly/plugin/formats/ratio1by1",square_hd:"@imgly/plugin/formats/ratio1by1",portrait_4_3:"@imgly/plugin/formats/ratio3by4",portrait_16_9:"@imgly/plugin/formats/ratio9by16",landscape_4_3:"@imgly/plugin/formats/ratio4by3",landscape_16_9:"@imgly/plugin/formats/ratio16by9",ImageSize:"@imgly/plugin/formats/ratioFree"}},style:{enum:["any","realistic_image","digital_illustration","vector_illustration","realistic_image/b_and_w","realistic_image/hard_flash","realistic_image/hdr","realistic_image/natural_light","realistic_image/studio_portrait","realistic_image/enterprise","realistic_image/motion_blur","realistic_image/evening_light","realistic_image/faded_nostalgia","realistic_image/forest_life","realistic_image/mystic_naturalism","realistic_image/natural_tones","realistic_image/organic_calm","realistic_image/real_life_glow","realistic_image/retro_realism","realistic_image/retro_snapshot","realistic_image/urban_drama","realistic_image/village_realism","realistic_image/warm_folk","digital_illustration/pixel_art","digital_illustration/hand_drawn","digital_illustration/grain","digital_illustration/infantile_sketch","digital_illustration/2d_art_poster","digital_illustration/handmade_3d","digital_illustration/hand_drawn_outline","digital_illustration/engraving_color","digital_illustration/2d_art_poster_2","digital_illustration/antiquarian","digital_illustration/bold_fantasy","digital_illustration/child_book","digital_illustration/child_books","digital_illustration/cover","digital_illustration/crosshatch","digital_illustration/digital_engraving","digital_illustration/expressionism","digital_illustration/freehand_details","digital_illustration/grain_20","digital_illustration/graphic_intensity","digital_illustration/hard_comics","digital_illustration/long_shadow","digital_illustration/modern_folk","digital_illustration/multicolor","digital_illustration/neon_calm","digital_illustration/noir","digital_illustration/nostalgic_pastel","digital_illustration/outline_details","digital_illustration/pastel_gradient","digital_illustration/pastel_sketch","digital_illustration/pop_art","digital_illustration/pop_renaissance","digital_illustration/street_art","digital_illustration/tablet_sketch","digital_illustration/urban_glow","digital_illustration/urban_sketching","digital_illustration/vanilla_dreams","digital_illustration/young_adult_book","digital_illustration/young_adult_book_2","vector_illustration/bold_stroke","vector_illustration/chemistry","vector_illustration/colored_stencil","vector_illustration/contour_pop_art","vector_illustration/cosmics","vector_illustration/cutout","vector_illustration/depressive","vector_illustration/editorial","vector_illustration/emotional_flat","vector_illustration/infographical","vector_illustration/marker_outline","vector_illustration/mosaic","vector_illustration/naivector","vector_illustration/roundish_flat","vector_illustration/segmented_colors","vector_illustration/sharp_contrast","vector_illustration/thin","vector_illustration/vector_photo","vector_illustration/vivid_shapes","vector_illustration/engraving","vector_illustration/line_art","vector_illustration/line_circuit","vector_illustration/linocut","icon/broken_line","icon/colored_outline","icon/colored_shapes","icon/colored_shapes_gradient","icon/doodle_fill","icon/doodle_offset_fill","icon/offset_fill","icon/outline","icon/outline_gradient","icon/uneven_fill"],title:"Style",type:"string",description:"The style of the generated images. Vector images cost 2X as much.",default:"realistic_image"},colors:{title:"Colors",type:"array",description:"An array of preferable colors",items:{$ref:"#/components/schemas/RGBColor"},default:[]}},"x-fal-order-properties":["prompt","style","image_size"],required:["prompt"]},Recraft20bOutput:{title:"TextToImageOutput",type:"object",properties:{images:{title:"Images",type:"array",items:{$ref:"#/components/schemas/File"}}},"x-fal-order-properties":["images"],required:["images"]},ImageSize:{title:"ImageSize",type:"object",properties:{height:{maximum:14142,type:"integer",title:"Height",description:"The height of the generated image.",exclusiveMinimum:0,default:512},width:{maximum:14142,type:"integer",title:"Width",description:"The width of the generated image.",exclusiveMinimum:0,default:512}},"x-fal-order-properties":["width","height"]},RGBColor:{title:"RGBColor",type:"object",properties:{r:{minimum:0,maximum:255,type:"integer",title:"R",description:"Red color value",default:0},b:{minimum:0,maximum:255,type:"integer",title:"B",description:"Blue color value",default:0},g:{minimum:0,maximum:255,type:"integer",title:"G",description:"Green color value",default:0}},"x-fal-order-properties":["r","g","b"]},File:{title:"File",type:"object",properties:{file_size:{title:"File Size",type:"integer",description:"The size of the file in bytes."},file_name:{title:"File Name",type:"string",description:"The name of the file. It will be auto-generated if not provided."},content_type:{title:"Content Type",type:"string",description:"The mime type of the file."},url:{title:"Url",type:"string",description:"The URL where the file can be downloaded from."},file_data:{format:"binary",title:"File Data",type:"string",description:"File data"}},"x-fal-order-properties":["url","content_type","file_name","file_size","file_data"],required:["url"]}}},paths:{"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/status":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}},{name:"logs",in:"query",required:!1,schema:{type:"number",description:"Whether to include logs (`1`) in the response or not (`0`)."}}],responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/cancel":{put:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"The request was cancelled.",content:{"application/json":{schema:{type:"object",properties:{success:{type:"boolean",description:"Whether the request was cancelled successfully."}}}}}}}}},"/fal-ai/recraft/v2/text-to-image":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"Result of the request.",content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};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 Ye(e){return ed[e]}var td=[{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"}],yh=td[0],id=[{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"}],bh=id[0],zt=[{id:"icon/broken_line",label:"Broken Line"},{id:"icon/colored_outline",label:"Colored Outline"},{id:"icon/colored_shapes",label:"Colored Shapes"},{id:"icon/colored_shapes_gradient",label:"Colored Shapes Gradient"},{id:"icon/doodle_fill",label:"Doodle Fill"},{id:"icon/doodle_offset_fill",label:"Doodle Offset Fill"},{id:"icon/offset_fill",label:"Offset Fill"},{id:"icon/outline",label:"Outline"},{id:"icon/outline_gradient",label:"Outline Gradient"},{id:"icon/uneven_fill",label:"Uneven Fill"}],_h=zt[0],rd=e=>({realistic_image:`${e}/realistic_image.webp`,digital_illustration:`${e}/digital_illustration.webp`,"realistic_image/b_and_w":`${e}/realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${e}/realistic_image_hard_flash.webp`,"realistic_image/hdr":`${e}/realistic_image_hdr.webp`,"realistic_image/natural_light":`${e}/realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${e}/realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${e}/realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${e}/realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${e}/digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${e}/digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${e}/digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${e}/digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${e}/digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${e}/digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${e}/digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${e}/digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${e}/digital_illustration_2d_artposter_2.webp`,vector_illustration:`${e}/vector_illustration.svg`,"vector_illustration/bold_stroke":`${e}/vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${e}/vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${e}/vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${e}/vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${e}/vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${e}/vector_illustration_cutout.svg`,"vector_illustration/depressive":`${e}/vector_illustration_depressive.svg`,"vector_illustration/editorial":`${e}/vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${e}/vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${e}/vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${e}/vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${e}/vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${e}/vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${e}/vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${e}/vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${e}/vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${e}/vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${e}/vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${e}/vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${e}/vector_illustration_engraving.svg`,"vector_illustration/line_art":`${e}/vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${e}/vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${e}/vector_illustration_linocut.svg`,"realistic_image/evening_light":`${e}/realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${e}/realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${e}/realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${e}/realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${e}/realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${e}/realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${e}/realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${e}/realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${e}/realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${e}/realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${e}/realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${e}/realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${e}/digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${e}/digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${e}/digital_illustration_child_book.webp`,"digital_illustration/child_books":`${e}/digital_illustration_child_books.webp`,"digital_illustration/cover":`${e}/digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${e}/digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${e}/digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${e}/digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${e}/digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${e}/digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${e}/digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${e}/digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${e}/digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${e}/digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${e}/digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${e}/digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${e}/digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${e}/digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${e}/digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${e}/digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${e}/digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${e}/digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${e}/digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${e}/digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${e}/digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${e}/digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${e}/digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${e}/digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${e}/digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${e}/digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${e}/icon_broken_line.svg`,"icon/colored_outline":`${e}/icon_colored_outline.svg`,"icon/colored_shapes":`${e}/icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${e}/icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${e}/icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${e}/icon_doodle_offset_fill.svg`,"icon/offset_fill":`${e}/icon_offset_fill.svg`,"icon/outline":`${e}/icon_outline.svg`,"icon/outline_gradient":`${e}/icon_outline_gradient.svg`,"icon/uneven_fill":`${e}/icon_uneven_fill.svg`});function mr(e,t){return rd(`${t}thumbnails/`)[e]}var vi=ki(bi());var _i=ki(bi());function bt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function Dn(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.${At(i)}`,{type:i});return _i.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.${At(i)}`,{type:i});return _i.fal.storage.upload(o)}return e}}function Tp(e,t){let i=e.middleware??t.middlewares??t.middleware??[],r={id:e.modelKey,kind:"sticker",name:e.name,initialize:async n=>{vi.fal.config({proxyUrl:t.proxyUrl,requestMiddleware:async o=>({...o,headers:{...o.headers,...e.headers??{}}})}),e.initialize?.(n)},input:{quickActions:{supported:e.supportedQuickActions??{}},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?hr.ImageUrl(e.modelKey,{cesdk:e.cesdk}):{},...e.renderCustomProperty},getBlockInput:n=>{if(e.getBlockInput!=null)return e.getBlockInput(n);if(e.getStickerSize!=null){let{width:o,height:a}=e.getStickerSize(n);return Promise.resolve({sticker:{width:o,height:a}})}if(n.image_size!=null&&bt(n.image_size))return Promise.resolve({sticker:{width:n.image_size.width??512,height:n.image_size.height??512}});if(n.image_size!=null&&typeof n.image_size=="string"){let o=Ye(n.image_size);return Promise.resolve({sticker:o})}throw new Error("getBlockInput or getStickerSize must be provided")},userFlow:e.userFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:"@imgly/indexedDB",generate:async(n,{abortSignal:o})=>{let a=await Dn(n.image_url,e.cesdk),s=await vi.fal.subscribe(e.falKey??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:"sticker",url:l}}else{let d=s?.data?.image;if(d!=null){let l=d?.url;if(l!=null)return{kind:"sticker",url:l}}}throw console.error("Cannot extract generated sticker from response:",s),new Error("Cannot find generated sticker")}}};return t.debug&&console.log("Created Provider:",r),r}var Un=Tp;var Be;function Nn(e){return async({cesdk:t})=>Mp(t,e)}function Mp(e,t){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/";return e.ui.addIconSet("@imgly/plugin/formats",Gi.Formats),Be=new zi(n,zt.map(({id:a,label:s})=>({id:a,label:s,thumbUri:mr(a,o)}))),Be.setAssetActive("icon/broken_line"),e.engine.asset.addSource(Be),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:a})=>a,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${Me(r)}.styleSelection`,({builder:a,payload:s})=>{if(s==null)return null;a.Library(`${r}.library.style`,{entries:[n],onSelect:async c=>{s.onSelect(c)}})}),e.i18n.setTranslations({en:{[`panel.${Me("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection",[`${r}.style`]:"Style",[`${r}.style.type`]:"Type",[`${r}.style.type.icon`]:"Icon"}}),Un({falKey:i,modelKey:r,name:"Recraft 20b",schema:fr,inputReference:"#/components/schemas/Recraft20bInput",middleware:t.middlewares??t.middleware??[],headers:t.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:a,state:s},c)=>{let d=s("style/icon",{id:"icon/broken_line",label:"Broken Line"});return a.Button(`${c.id}`,{inputLabel:`${r}.${c.id}`,icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:d.value.label,labelAlignment:"left",onClick:()=>{let l={onSelect:async u=>{if(u.id==="back")return;let f={id:u.id,label:u.label??u.id};Be.clearActiveAssets(),Be.setAssetActive(u.id),d.setValue(f),e.ui.closePanel(`${Me(r)}.styleSelection`)}};e.ui.openPanel(`${Me(r)}.styleSelection`,{payload:l})}}),()=>({id:c.id,type:"string",value:d.value.id??"icon/broken_line"})}},getBlockInput:a=>{if(bt(a.image_size))return Promise.resolve({sticker:{width:a.image_size.width??512,height:a.image_size.height??512}});let s=Ye(a.image_size??"square_hd");return Promise.resolve({sticker:s})}},t)}var jp={Recraft20b:Nn},bf=jp;export{bf as default};
132
+ `;var hr={ImageUrl:Hs,StyleTransfer:Xu};var mr={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},Recraft20bInput:{title:"TextToImageInput",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},image_size:{anyOf:[{enum:["square_hd","square","portrait_4_3","portrait_16_9","landscape_4_3","landscape_16_9"],type:"string"},{$ref:"#/components/schemas/ImageSize"}],title:"Format",default:"square_hd","x-imgly-enum-labels":{ImageSize:"Custom",square_hd:"Square HD",square:"Square",portrait_4_3:"Portrait 4:3",portrait_16_9:"Portrait 16:9",landscape_4_3:"Landscape 4:3",landscape_16_9:"Landscape 16:9"},"x-imgly-enum-icons":{square:"@imgly/plugin/formats/ratio1by1",square_hd:"@imgly/plugin/formats/ratio1by1",portrait_4_3:"@imgly/plugin/formats/ratio3by4",portrait_16_9:"@imgly/plugin/formats/ratio9by16",landscape_4_3:"@imgly/plugin/formats/ratio4by3",landscape_16_9:"@imgly/plugin/formats/ratio16by9",ImageSize:"@imgly/plugin/formats/ratioFree"}},style:{enum:["any","realistic_image","digital_illustration","vector_illustration","realistic_image/b_and_w","realistic_image/hard_flash","realistic_image/hdr","realistic_image/natural_light","realistic_image/studio_portrait","realistic_image/enterprise","realistic_image/motion_blur","realistic_image/evening_light","realistic_image/faded_nostalgia","realistic_image/forest_life","realistic_image/mystic_naturalism","realistic_image/natural_tones","realistic_image/organic_calm","realistic_image/real_life_glow","realistic_image/retro_realism","realistic_image/retro_snapshot","realistic_image/urban_drama","realistic_image/village_realism","realistic_image/warm_folk","digital_illustration/pixel_art","digital_illustration/hand_drawn","digital_illustration/grain","digital_illustration/infantile_sketch","digital_illustration/2d_art_poster","digital_illustration/handmade_3d","digital_illustration/hand_drawn_outline","digital_illustration/engraving_color","digital_illustration/2d_art_poster_2","digital_illustration/antiquarian","digital_illustration/bold_fantasy","digital_illustration/child_book","digital_illustration/child_books","digital_illustration/cover","digital_illustration/crosshatch","digital_illustration/digital_engraving","digital_illustration/expressionism","digital_illustration/freehand_details","digital_illustration/grain_20","digital_illustration/graphic_intensity","digital_illustration/hard_comics","digital_illustration/long_shadow","digital_illustration/modern_folk","digital_illustration/multicolor","digital_illustration/neon_calm","digital_illustration/noir","digital_illustration/nostalgic_pastel","digital_illustration/outline_details","digital_illustration/pastel_gradient","digital_illustration/pastel_sketch","digital_illustration/pop_art","digital_illustration/pop_renaissance","digital_illustration/street_art","digital_illustration/tablet_sketch","digital_illustration/urban_glow","digital_illustration/urban_sketching","digital_illustration/vanilla_dreams","digital_illustration/young_adult_book","digital_illustration/young_adult_book_2","vector_illustration/bold_stroke","vector_illustration/chemistry","vector_illustration/colored_stencil","vector_illustration/contour_pop_art","vector_illustration/cosmics","vector_illustration/cutout","vector_illustration/depressive","vector_illustration/editorial","vector_illustration/emotional_flat","vector_illustration/infographical","vector_illustration/marker_outline","vector_illustration/mosaic","vector_illustration/naivector","vector_illustration/roundish_flat","vector_illustration/segmented_colors","vector_illustration/sharp_contrast","vector_illustration/thin","vector_illustration/vector_photo","vector_illustration/vivid_shapes","vector_illustration/engraving","vector_illustration/line_art","vector_illustration/line_circuit","vector_illustration/linocut","icon/broken_line","icon/colored_outline","icon/colored_shapes","icon/colored_shapes_gradient","icon/doodle_fill","icon/doodle_offset_fill","icon/offset_fill","icon/outline","icon/outline_gradient","icon/uneven_fill"],title:"Style",type:"string",description:"The style of the generated images. Vector images cost 2X as much.",default:"realistic_image"},colors:{title:"Colors",type:"array",description:"An array of preferable colors",items:{$ref:"#/components/schemas/RGBColor"},default:[]}},"x-fal-order-properties":["prompt","style","image_size"],required:["prompt"]},Recraft20bOutput:{title:"TextToImageOutput",type:"object",properties:{images:{title:"Images",type:"array",items:{$ref:"#/components/schemas/File"}}},"x-fal-order-properties":["images"],required:["images"]},ImageSize:{title:"ImageSize",type:"object",properties:{height:{maximum:14142,type:"integer",title:"Height",description:"The height of the generated image.",exclusiveMinimum:0,default:512},width:{maximum:14142,type:"integer",title:"Width",description:"The width of the generated image.",exclusiveMinimum:0,default:512}},"x-fal-order-properties":["width","height"]},RGBColor:{title:"RGBColor",type:"object",properties:{r:{minimum:0,maximum:255,type:"integer",title:"R",description:"Red color value",default:0},b:{minimum:0,maximum:255,type:"integer",title:"B",description:"Blue color value",default:0},g:{minimum:0,maximum:255,type:"integer",title:"G",description:"Green color value",default:0}},"x-fal-order-properties":["r","g","b"]},File:{title:"File",type:"object",properties:{file_size:{title:"File Size",type:"integer",description:"The size of the file in bytes."},file_name:{title:"File Name",type:"string",description:"The name of the file. It will be auto-generated if not provided."},content_type:{title:"Content Type",type:"string",description:"The mime type of the file."},url:{title:"Url",type:"string",description:"The URL where the file can be downloaded from."},file_data:{format:"binary",title:"File Data",type:"string",description:"File data"}},"x-fal-order-properties":["url","content_type","file_name","file_size","file_data"],required:["url"]}}},paths:{"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/status":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}},{name:"logs",in:"query",required:!1,schema:{type:"number",description:"Whether to include logs (`1`) in the response or not (`0`)."}}],responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}/cancel":{put:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"The request was cancelled.",content:{"application/json":{schema:{type:"object",properties:{success:{type:"boolean",description:"Whether the request was cancelled successfully."}}}}}}}}},"/fal-ai/recraft/v2/text-to-image":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/recraft/v2/text-to-image/requests/{request_id}":{get:{parameters:[{name:"request_id",in:"path",required:!0,schema:{type:"string",description:"Request ID"}}],responses:{"200":{description:"Result of the request.",content:{"application/json":{schema:{$ref:"#/components/schemas/Recraft20bOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};var td={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 Ye(e){return td[e]}var id=[{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"}],_f=id[0],rd=[{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"}],vf=rd[0],zt=[{id:"icon/broken_line",label:"Broken Line"},{id:"icon/colored_outline",label:"Colored Outline"},{id:"icon/colored_shapes",label:"Colored Shapes"},{id:"icon/colored_shapes_gradient",label:"Colored Shapes Gradient"},{id:"icon/doodle_fill",label:"Doodle Fill"},{id:"icon/doodle_offset_fill",label:"Doodle Offset Fill"},{id:"icon/offset_fill",label:"Offset Fill"},{id:"icon/outline",label:"Outline"},{id:"icon/outline_gradient",label:"Outline Gradient"},{id:"icon/uneven_fill",label:"Uneven Fill"}],wf=zt[0],nd=e=>({realistic_image:`${e}/realistic_image.webp`,digital_illustration:`${e}/digital_illustration.webp`,"realistic_image/b_and_w":`${e}/realistic_image_black_&_white.webp`,"realistic_image/hard_flash":`${e}/realistic_image_hard_flash.webp`,"realistic_image/hdr":`${e}/realistic_image_hdr.webp`,"realistic_image/natural_light":`${e}/realistic_image_natural_light.webp`,"realistic_image/studio_portrait":`${e}/realistic_image_studio_portrait.webp`,"realistic_image/enterprise":`${e}/realistic_image_enterprise.webp`,"realistic_image/motion_blur":`${e}/realistic_image_motion_blur.webp`,"digital_illustration/pixel_art":`${e}/digital_illustration_pixel_art.webp`,"digital_illustration/hand_drawn":`${e}/digital_illustration_hand_drawn.webp`,"digital_illustration/grain":`${e}/digital_illustration_grain.webp`,"digital_illustration/infantile_sketch":`${e}/digital_illustration_infantile_sketch.webp`,"digital_illustration/2d_art_poster":`${e}/digital_illustration_2d_art_poster.webp`,"digital_illustration/handmade_3d":`${e}/digital_illustration_handmade_3d.webp`,"digital_illustration/hand_drawn_outline":`${e}/digital_illustration_handdrawn_outline.webp`,"digital_illustration/engraving_color":`${e}/digital_illustration_engraving_color.webp`,"digital_illustration/2d_art_poster_2":`${e}/digital_illustration_2d_artposter_2.webp`,vector_illustration:`${e}/vector_illustration.svg`,"vector_illustration/bold_stroke":`${e}/vector_illustration_bold_stroke.svg`,"vector_illustration/chemistry":`${e}/vector_illustration_chemistry.svg`,"vector_illustration/colored_stencil":`${e}/vector_illustration_colored_stencil.svg`,"vector_illustration/contour_pop_art":`${e}/vector_illustration_contour_pop_art.svg`,"vector_illustration/cosmics":`${e}/vector_illustration_cosmics.svg`,"vector_illustration/cutout":`${e}/vector_illustration_cutout.svg`,"vector_illustration/depressive":`${e}/vector_illustration_depressive.svg`,"vector_illustration/editorial":`${e}/vector_illustration_editorial.svg`,"vector_illustration/emotional_flat":`${e}/vector_illustration_emotional_flat.svg`,"vector_illustration/infographical":`${e}/vector_illustration_infographical.svg`,"vector_illustration/marker_outline":`${e}/vector_illustration_marker_outline.svg`,"vector_illustration/mosaic":`${e}/vector_illustration_mosaic.svg`,"vector_illustration/naivector":`${e}/vector_illustration_naivector.svg`,"vector_illustration/roundish_flat":`${e}/vector_illustration_roundish_flat.svg`,"vector_illustration/segmented_colors":`${e}/vector_illustration_segmented_colors.svg`,"vector_illustration/sharp_contrast":`${e}/vector_illustration_sharp_contrast.svg`,"vector_illustration/thin":`${e}/vector_illustration_thin.svg`,"vector_illustration/vector_photo":`${e}/vector_illustration_vector_photo.svg`,"vector_illustration/vivid_shapes":`${e}/vector_illustration_vivid_shapes.svg`,"vector_illustration/engraving":`${e}/vector_illustration_engraving.svg`,"vector_illustration/line_art":`${e}/vector_illustration_line_art.svg`,"vector_illustration/line_circuit":`${e}/vector_illustration_line_circuit.svg`,"vector_illustration/linocut":`${e}/vector_illustration_linocut.svg`,"realistic_image/evening_light":`${e}/realistic_image_evening_light.webp`,"realistic_image/faded_nostalgia":`${e}/realistic_image_faded_nostalgia.webp`,"realistic_image/forest_life":`${e}/realistic_image_forest_life.webp`,"realistic_image/mystic_naturalism":`${e}/realistic_image_mystic_naturalism.webp`,"realistic_image/natural_tones":`${e}/realistic_image_natural_tones.webp`,"realistic_image/organic_calm":`${e}/realistic_image_organic_calm.webp`,"realistic_image/real_life_glow":`${e}/realistic_image_real_life_glow.webp`,"realistic_image/retro_realism":`${e}/realistic_image_retro_realism.webp`,"realistic_image/retro_snapshot":`${e}/realistic_image_retro_snapshot.webp`,"realistic_image/urban_drama":`${e}/realistic_image_urban_drama.webp`,"realistic_image/village_realism":`${e}/realistic_image_village_realism.webp`,"realistic_image/warm_folk":`${e}/realistic_image_warm_folk.webp`,"digital_illustration/antiquarian":`${e}/digital_illustration_antiquarian.webp`,"digital_illustration/bold_fantasy":`${e}/digital_illustration_bold_fantasy.webp`,"digital_illustration/child_book":`${e}/digital_illustration_child_book.webp`,"digital_illustration/child_books":`${e}/digital_illustration_child_books.webp`,"digital_illustration/cover":`${e}/digital_illustration_cover.webp`,"digital_illustration/crosshatch":`${e}/digital_illustration_crosshatch.webp`,"digital_illustration/digital_engraving":`${e}/digital_illustration_digital_engraving.webp`,"digital_illustration/expressionism":`${e}/digital_illustration_expressionism.webp`,"digital_illustration/freehand_details":`${e}/digital_illustration_freehand_details.webp`,"digital_illustration/grain_20":`${e}/digital_illustration_grain_20.webp`,"digital_illustration/graphic_intensity":`${e}/digital_illustration_graphic_intensity.webp`,"digital_illustration/hard_comics":`${e}/digital_illustration_hard_comics.webp`,"digital_illustration/long_shadow":`${e}/digital_illustration_long_shadow.webp`,"digital_illustration/modern_folk":`${e}/digital_illustration_modern_folk.webp`,"digital_illustration/multicolor":`${e}/digital_illustration_multicolor.webp`,"digital_illustration/neon_calm":`${e}/digital_illustration_neon_calm.webp`,"digital_illustration/noir":`${e}/digital_illustration_noir.webp`,"digital_illustration/nostalgic_pastel":`${e}/digital_illustration_nostalgic_pastel.webp`,"digital_illustration/outline_details":`${e}/digital_illustration_outline_details.webp`,"digital_illustration/pastel_gradient":`${e}/digital_illustration_pastel_gradient.webp`,"digital_illustration/pastel_sketch":`${e}/digital_illustration_pastel_sketch.webp`,"digital_illustration/pop_art":`${e}/digital_illustration_pop_art.webp`,"digital_illustration/pop_renaissance":`${e}/digital_illustration_pop_renaissance.webp`,"digital_illustration/street_art":`${e}/digital_illustration_street_art.webp`,"digital_illustration/tablet_sketch":`${e}/digital_illustration_tablet_sketch.webp`,"digital_illustration/urban_glow":`${e}/digital_illustration_urban_glow.webp`,"digital_illustration/urban_sketching":`${e}/digital_illustration_urban_sketching.webp`,"digital_illustration/vanilla_dreams":`${e}/digital_illustration_vanilla_dreams.webp`,"digital_illustration/young_adult_book":`${e}/digital_illustration_young_adult_book.webp`,"digital_illustration/young_adult_book_2":`${e}/digital_illustration_young_adult_book_2.webp`,"icon/broken_line":`${e}/icon_broken_line.svg`,"icon/colored_outline":`${e}/icon_colored_outline.svg`,"icon/colored_shapes":`${e}/icon_colored_shapes.svg`,"icon/colored_shapes_gradient":`${e}/icon_colored_shapes_gradient.svg`,"icon/doodle_fill":`${e}/icon_doodle_fill.svg`,"icon/doodle_offset_fill":`${e}/icon_doodle_offset_fill.svg`,"icon/offset_fill":`${e}/icon_offset_fill.svg`,"icon/outline":`${e}/icon_outline.svg`,"icon/outline_gradient":`${e}/icon_outline_gradient.svg`,"icon/uneven_fill":`${e}/icon_uneven_fill.svg`});function yr(e,t){return nd(`${t}thumbnails/`)[e]}var vi=ki(bi());var _i=ki(bi());function bt(e){return e!=null&&typeof e!="string"&&"width"in e&&"height"in e}async function Un(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.${At(i)}`,{type:i});return _i.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.${At(i)}`,{type:i});return _i.fal.storage.upload(o)}return e}}function Mp(e,t){let i=e.middleware??t.middlewares??t.middleware??[],r={id:e.modelKey,kind:"sticker",name:e.name,initialize:async n=>{vi.fal.config({proxyUrl:t.proxyUrl,requestMiddleware:async o=>({...o,headers:{...o.headers,...e.headers??{}}})}),e.initialize?.(n)},input:{quickActions:{supported:fr(e.supportedQuickActions??{},t.supportedQuickActions)},panel:{type:"schema",document:e.schema,inputReference:e.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...e.cesdk!=null?hr.ImageUrl(e.modelKey,{cesdk:e.cesdk}):{},...e.renderCustomProperty},getBlockInput:n=>{if(e.getBlockInput!=null)return e.getBlockInput(n);if(e.getStickerSize!=null){let{width:o,height:a}=e.getStickerSize(n);return Promise.resolve({sticker:{width:o,height:a}})}if(n.image_size!=null&&bt(n.image_size))return Promise.resolve({sticker:{width:n.image_size.width??512,height:n.image_size.height??512}});if(n.image_size!=null&&typeof n.image_size=="string"){let o=Ye(n.image_size);return Promise.resolve({sticker:o})}throw new Error("getBlockInput or getStickerSize must be provided")},userFlow:e.userFlow??"placeholder"}},output:{abortable:!0,middleware:i,history:t.history??"@imgly/indexedDB",generate:async(n,{abortSignal:o})=>{let a=await Un(n.image_url,e.cesdk),s=await vi.fal.subscribe(e.falKey??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:"sticker",url:l}}else{let d=s?.data?.image;if(d!=null){let l=d?.url;if(l!=null)return{kind:"sticker",url:l}}}throw console.error("Cannot extract generated sticker from response:",s),new Error("Cannot find generated sticker")}}};return t.debug&&console.log("Created Provider:",r),r}var Nn=Mp;var Be;function zn(e){return async({cesdk:t})=>$p(t,e)}function $p(e,t){let i="fal-ai/recraft/v2/text-to-image",r="fal-ai/recraft/v2/text-to-sticker",n=`${r}/styles/icon`,o=t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/recraft-v3/";return e.ui.addIconSet("@imgly/plugin/formats",Gi.Formats),Be=new zi(n,zt.map(({id:a,label:s})=>({id:a,label:s,thumbUri:yr(a,o)}))),Be.setAssetActive("icon/broken_line"),e.engine.asset.addSource(Be),e.ui.addAssetLibraryEntry({id:n,sourceIds:[n],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:a})=>a,cardLabelPosition:()=>"below"}),e.ui.registerPanel(`${Me(r)}.styleSelection`,({builder:a,payload:s})=>{if(s==null)return null;a.Library(`${r}.library.style`,{entries:[n],onSelect:async c=>{s.onSelect(c)}})}),e.i18n.setTranslations({en:{[`panel.${Me("fal-ai/recraft/v2/text-to-sticker")}.styleSelection`]:"Style Selection"}}),Nn({falKey:i,modelKey:r,name:"Recraft 20b",schema:mr,inputReference:"#/components/schemas/Recraft20bInput",middleware:t.middlewares??t.middleware??[],headers:t.headers,userFlow:"placeholder",renderCustomProperty:{style:({builder:a,state:s},c)=>{let d=s("style/icon",{id:"icon/broken_line",label:"Broken Line"});return a.Button(`${c.id}`,{inputLabel:[`ly.img.plugin-ai-sticker-generation-web.${r}.property.${c.id}`,`ly.img.plugin-ai-generation-web.property.${c.id}`,`ly.img.plugin-ai-sticker-generation-web.${r}.defaults.property.${c.id}`,`ly.img.plugin-ai-generation-web.defaults.property.${c.id}`],icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",label:d.value.label,labelAlignment:"left",onClick:()=>{let l={onSelect:async u=>{if(u.id==="back")return;let h={id:u.id,label:u.label??u.id};Be.clearActiveAssets(),Be.setAssetActive(u.id),d.setValue(h),e.ui.closePanel(`${Me(r)}.styleSelection`)}};e.ui.openPanel(`${Me(r)}.styleSelection`,{payload:l})}}),()=>({id:c.id,type:"string",value:d.value.id??"icon/broken_line"})}},getBlockInput:a=>{if(bt(a.image_size))return Promise.resolve({sticker:{width:a.image_size.width??512,height:a.image_size.height??512}});let s=Ye(a.image_size??"square_hd");return Promise.resolve({sticker:s})}},t)}var jp={Recraft20b:zn},_h=jp;export{_h as default};
133
133
  /*! Bundled license information:
134
134
 
135
135
  @imgly/plugin-utils/dist/index.mjs: