@imgly/plugin-ai-video-generation-web 0.2.5 → 0.2.6

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 to=Object.create;var xr=Object.defineProperty;var ro=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var no=Object.getPrototypeOf,oo=Object.prototype.hasOwnProperty;var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var so=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of io(e))!oo.call(t,n)&&n!==r&&xr(t,n,{get:()=>e[n],enumerable:!(i=ro(e,n))||i.enumerable});return t};var ao=(t,e,r)=>(r=t!=null?to(no(t)):{},so(e||!t||!t.__esModule?xr(r,"default",{value:t,enumerable:!0}):r,t));var jt=_(L=>{"use strict";var xl=L&&L.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(L,"__esModule",{value:!0});L.TARGET_URL_HEADER=void 0;L.withMiddleware=_l;L.withProxy=Il;function _l(...t){let e=r=>typeof r=="function";return r=>xl(this,void 0,void 0,function*(){let i=Object.assign({},r);for(let n of t.filter(e))i=yield n(i);return i})}L.TARGET_URL_HEADER="x-fal-target-url";function Il(t){let e=r=>Promise.resolve(r);return typeof window>"u"?e:r=>r.headers&&L.TARGET_URL_HEADER in r?e(r):Promise.resolve(Object.assign(Object.assign({},r),{url:t.targetUrl,headers:Object.assign(Object.assign({},r.headers||{}),{[L.TARGET_URL_HEADER]:r.url})}))}});var K=_(R=>{"use strict";var Gr=R&&R.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(R,"__esModule",{value:!0});R.ValidationError=R.ApiError=void 0;R.defaultResponseHandler=Qr;R.resultResponseHandler=Sl;var El="x-fal-request-id",de=class extends Error{constructor({message:e,status:r,body:i}){super(e),this.name="ApiError",this.status=r,this.body=i}};R.ApiError=de;var Ge=class extends de{constructor(e){super(e),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(r=>r.loc[r.loc.length-1]===e)}};R.ValidationError=Ge;function Qr(t){return Gr(this,void 0,void 0,function*(){var e;let{status:r,statusText:i}=t,n=(e=t.headers.get("Content-Type"))!==null&&e!==void 0?e:"";if(!t.ok){if(n.includes("application/json")){let o=yield t.json(),s=r===422?Ge:de;throw new s({message:o.message||i,status:r,body:o})}throw new de({message:`HTTP ${r}: ${i}`,status:r})}return n.includes("application/json")?t.json():n.includes("text/html")?t.text():n.includes("application/octet-stream")?t.arrayBuffer():t.text()})}function Sl(t){return Gr(this,void 0,void 0,function*(){return{data:yield Qr(t),requestId:t.headers.get(El)||""}})}});var H=_(D=>{"use strict";var Tl=D&&D.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(D,"__esModule",{value:!0});D.ensureEndpointIdFormat=Yr;D.parseEndpointId=Al;D.isValidUrl=Cl;D.throttle=Ml;D.isReact=Pl;D.isPlainObject=jl;D.sleep=Ol;function Yr(t){if(t.split("/").length>1)return t;let[,r,i]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(t)||[];if(r&&i)return`${r}/${i}`;throw new Error(`Invalid app id: ${t}. Must be in the format <appOwner>/<appId>`)}var kl=["workflows","comfy"];function Al(t){let r=Yr(t).split("/");return kl.includes(r[0])?{owner:r[1],alias:r[2],path:r.slice(3).join("/")||void 0,namespace:r[0]}:{owner:r[0],alias:r[1],path:r.slice(2).join("/")||void 0}}function Cl(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function Ml(t,e,r=!1){let i,n;return(...o)=>{!n&&r?(t(...o),n=Date.now()):(i&&clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=e&&(t(...o),n=Date.now())},e-(Date.now()-n)))}}var Ot;function Pl(){if(Ot===void 0){let t=new Error().stack;Ot=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return Ot}function jl(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}function Ol(t){return Tl(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}});var Ae=_(C=>{"use strict";var Dl=C&&C.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(C,"__esModule",{value:!0});C.DEFAULT_RETRY_OPTIONS=C.DEFAULT_RETRYABLE_STATUS_CODES=void 0;C.isRetryableError=Wr;C.calculateBackoffDelay=Zr;C.executeWithRetry=Rl;var Ul=K(),Ll=H();C.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];C.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:C.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Wr(t,e){return t instanceof Ul.ApiError&&e.includes(t.status)}function Zr(t,e,r,i,n){let o=Math.min(e*Math.pow(i,t),r);if(n){let s=.25*o*(Math.random()*2-1);return Math.max(0,o+s)}return o}function Rl(t,e,r){return Dl(this,void 0,void 0,function*(){let i={totalAttempts:0,totalDelay:0},n;for(let o=0;o<=e.maxRetries;o++){i.totalAttempts++;try{return{result:yield t(),metrics:i}}catch(s){if(n=s,i.lastError=s,o===e.maxRetries||!Wr(s,e.retryableStatusCodes))throw s;let a=Zr(o,e.baseDelay,e.maxDelay,e.backoffMultiplier,e.enableJitter);i.totalDelay+=a,r&&r(o+1,s,a),yield(0,Ll.sleep)(a)}}throw n})}});var Xr=_((Rh,$l)=>{$l.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.6.2",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 We=_(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isBrowser=ql;Ye.getUserAgent=Vl;function ql(){return typeof window<"u"&&typeof window.document<"u"}var Qe=null;function Vl(){if(Qe!==null)return Qe;let t=Xr();return Qe=`${t.name}/${t.version}`,Qe}});var Ze=_(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.credentialsFromEnv=void 0;G.resolveDefaultFetch=ti;G.createConfig=Hl;G.getRestApiUrl=Gl;var Jr=jt(),Nl=K(),ei=Ae(),Fl=We();function ti(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function zl(){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 Bl=()=>{if(zl())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};G.credentialsFromEnv=Bl;var Kl={credentials:G.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:Nl.defaultResponseHandler,retry:ei.DEFAULT_RETRY_OPTIONS};function Hl(t){var e;let r=Object.assign(Object.assign(Object.assign({},Kl),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:ti(),retry:Object.assign(Object.assign({},ei.DEFAULT_RETRY_OPTIONS),t.retry||{})});t.proxyUrl&&(r=Object.assign(Object.assign({},r),{requestMiddleware:(0,Jr.withMiddleware)(r.requestMiddleware,(0,Jr.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:i,suppressLocalCredentialsWarning:n}=r,o=typeof i=="function"?i():i;return(0,Fl.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),r}function Gl(){return"https://rest.alpha.fal.ai"}});var pe=_(Q=>{"use strict";var ri=Q&&Q.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})},Ql=Q&&Q.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(Q,"__esModule",{value:!0});Q.dispatchRequest=Wl;Q.buildUrl=Zl;var ii=Ae(),ni=We(),Dt=H(),Yl=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Wl(t){return ri(this,void 0,void 0,function*(){var e;let{targetUrl:r,input:i,config:n,options:o={}}=t,{credentials:s,requestMiddleware:a,responseHandler:c,fetch:u}=n,l=Object.assign(Object.assign({},n.retry),o.retry||{}),d=()=>ri(this,void 0,void 0,function*(){var p,g,b;let w=(0,ni.isBrowser)()?{}:{"User-Agent":(0,ni.getUserAgent)()},f=typeof s=="function"?s():s,{method:y,url:I,headers:x}=yield a({method:((g=(p=t.method)!==null&&p!==void 0?p:o.method)!==null&&g!==void 0?g:"post").toUpperCase(),url:r,headers:t.headers}),A=f?{Authorization:`Key ${f}`}:{},wt=Object.assign(Object.assign(Object.assign(Object.assign({},A),{Accept:"application/json","Content-Type":"application/json"}),w),x??{}),{responseHandler:xt,retry:uh}=o,wr=Ql(o,["responseHandler","retry"]),eo=yield u(I,Object.assign(Object.assign(Object.assign(Object.assign({},wr),{method:y,headers:Object.assign(Object.assign({},wt),(b=wr.headers)!==null&&b!==void 0?b:{})}),!Yl&&{mode:"cors"}),{signal:o.signal,body:y.toLowerCase()!=="get"&&i?JSON.stringify(i):void 0}));return yield(xt??c)(eo)}),h;for(let p=0;p<=l.maxRetries;p++)try{return yield d()}catch(g){if(h=g,p===l.maxRetries||!(0,ii.isRetryableError)(g,l.retryableStatusCodes)||((e=o.signal)===null||e===void 0?void 0:e.aborted))throw g;let w=(0,ii.calculateBackoffDelay)(p,l.baseDelay,l.maxDelay,l.backoffMultiplier,l.enableJitter);yield(0,Dt.sleep)(w)}throw h})}function Zl(t,e={}){var r,i;let n=((r=e.method)!==null&&r!==void 0?r:"post").toLowerCase(),o=((i=e.path)!==null&&i!==void 0?i:"").replace(/^\//,"").replace(/\/{2,}/,"/"),s=e.input,a=Object.assign(Object.assign({},e.query||{}),n==="get"?s:{}),c=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:"";if((0,Dt.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${o}${c}`;let u=(0,Dt.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var si=_(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Xl(t){let e,r,i,n,o,s,a;return c(),{feed:u,reset:c};function c(){e=!0,r="",i=0,n=-1,o=void 0,s=void 0,a=""}function u(d){r=r?r+d:d,e&&Jl(r)&&(r=r.slice(oi.length)),e=!1;let h=r.length,p=0,g=!1;for(;p<h;){g&&(r[p]===`
2
- `&&++p,g=!1);let b=-1,w=n,f;for(let y=i;b<0&&y<h;++y)f=r[y],f===":"&&w<0?w=y-p:f==="\r"?(g=!0,b=y-p):f===`
3
- `&&(b=y-p);if(b<0){i=h-p,n=w;break}else i=0,n=-1;l(r,p,w,b),p+=b+1}p===h?r="":p>0&&(r=r.slice(p))}function l(d,h,p,g){if(g===0){a.length>0&&(t({type:"event",id:o,event:s||void 0,data:a.slice(0,-1)}),a="",o=void 0),s=void 0;return}let b=p<0,w=d.slice(h,h+(b?g:p)),f=0;b?f=g:d[h+p+1]===" "?f=p+2:f=p+1;let y=h+f,I=g-f,x=d.slice(y,y+I).toString();if(w==="data")a+=x?"".concat(x,`
1
+ var to=Object.create;var xr=Object.defineProperty;var ro=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var no=Object.getPrototypeOf,oo=Object.prototype.hasOwnProperty;var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var so=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of io(e))!oo.call(t,n)&&n!==r&&xr(t,n,{get:()=>e[n],enumerable:!(i=ro(e,n))||i.enumerable});return t};var ao=(t,e,r)=>(r=t!=null?to(no(t)):{},so(e||!t||!t.__esModule?xr(r,"default",{value:t,enumerable:!0}):r,t));var jt=_(L=>{"use strict";var xl=L&&L.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(L,"__esModule",{value:!0});L.TARGET_URL_HEADER=void 0;L.withMiddleware=_l;L.withProxy=Il;function _l(...t){let e=r=>typeof r=="function";return r=>xl(this,void 0,void 0,function*(){let i=Object.assign({},r);for(let n of t.filter(e))i=yield n(i);return i})}L.TARGET_URL_HEADER="x-fal-target-url";function Il(t){let e=r=>Promise.resolve(r);return typeof window>"u"?e:r=>r.headers&&L.TARGET_URL_HEADER in r?e(r):Promise.resolve(Object.assign(Object.assign({},r),{url:t.targetUrl,headers:Object.assign(Object.assign({},r.headers||{}),{[L.TARGET_URL_HEADER]:r.url})}))}});var K=_($=>{"use strict";var Gr=$&&$.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty($,"__esModule",{value:!0});$.ValidationError=$.ApiError=void 0;$.defaultResponseHandler=Qr;$.resultResponseHandler=Sl;var El="x-fal-request-id",de=class extends Error{constructor({message:e,status:r,body:i}){super(e),this.name="ApiError",this.status=r,this.body=i}};$.ApiError=de;var Ge=class extends de{constructor(e){super(e),this.name="ValidationError"}get fieldErrors(){return typeof this.body.detail=="string"?[{loc:["body"],msg:this.body.detail,type:"value_error"}]:this.body.detail||[]}getFieldErrors(e){return this.fieldErrors.filter(r=>r.loc[r.loc.length-1]===e)}};$.ValidationError=Ge;function Qr(t){return Gr(this,void 0,void 0,function*(){var e;let{status:r,statusText:i}=t,n=(e=t.headers.get("Content-Type"))!==null&&e!==void 0?e:"";if(!t.ok){if(n.includes("application/json")){let o=yield t.json(),s=r===422?Ge:de;throw new s({message:o.message||i,status:r,body:o})}throw new de({message:`HTTP ${r}: ${i}`,status:r})}return n.includes("application/json")?t.json():n.includes("text/html")?t.text():n.includes("application/octet-stream")?t.arrayBuffer():t.text()})}function Sl(t){return Gr(this,void 0,void 0,function*(){return{data:yield Qr(t),requestId:t.headers.get(El)||""}})}});var H=_(D=>{"use strict";var kl=D&&D.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(D,"__esModule",{value:!0});D.ensureEndpointIdFormat=Yr;D.parseEndpointId=Al;D.isValidUrl=Cl;D.throttle=Ml;D.isReact=Pl;D.isPlainObject=jl;D.sleep=Ol;function Yr(t){if(t.split("/").length>1)return t;let[,r,i]=/^([0-9]+)-([a-zA-Z0-9-]+)$/.exec(t)||[];if(r&&i)return`${r}/${i}`;throw new Error(`Invalid app id: ${t}. Must be in the format <appOwner>/<appId>`)}var Tl=["workflows","comfy"];function Al(t){let r=Yr(t).split("/");return Tl.includes(r[0])?{owner:r[1],alias:r[2],path:r.slice(3).join("/")||void 0,namespace:r[0]}:{owner:r[0],alias:r[1],path:r.slice(2).join("/")||void 0}}function Cl(t){try{let{host:e}=new URL(t);return/(fal\.(ai|run))$/.test(e)}catch{return!1}}function Ml(t,e,r=!1){let i,n;return(...o)=>{!n&&r?(t(...o),n=Date.now()):(i&&clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=e&&(t(...o),n=Date.now())},e-(Date.now()-n)))}}var Ot;function Pl(){if(Ot===void 0){let t=new Error().stack;Ot=!!t&&(t.includes("node_modules/react-dom/")||t.includes("node_modules/next/"))}return Ot}function jl(t){return!!t&&Object.getPrototypeOf(t)===Object.prototype}function Ol(t){return kl(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}});var Ae=_(C=>{"use strict";var Dl=C&&C.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(C,"__esModule",{value:!0});C.DEFAULT_RETRY_OPTIONS=C.DEFAULT_RETRYABLE_STATUS_CODES=void 0;C.isRetryableError=Wr;C.calculateBackoffDelay=Zr;C.executeWithRetry=$l;var Ul=K(),Ll=H();C.DEFAULT_RETRYABLE_STATUS_CODES=[429,502,503,504];C.DEFAULT_RETRY_OPTIONS={maxRetries:3,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2,retryableStatusCodes:C.DEFAULT_RETRYABLE_STATUS_CODES,enableJitter:!0};function Wr(t,e){return t instanceof Ul.ApiError&&e.includes(t.status)}function Zr(t,e,r,i,n){let o=Math.min(e*Math.pow(i,t),r);if(n){let s=.25*o*(Math.random()*2-1);return Math.max(0,o+s)}return o}function $l(t,e,r){return Dl(this,void 0,void 0,function*(){let i={totalAttempts:0,totalDelay:0},n;for(let o=0;o<=e.maxRetries;o++){i.totalAttempts++;try{return{result:yield t(),metrics:i}}catch(s){if(n=s,i.lastError=s,o===e.maxRetries||!Wr(s,e.retryableStatusCodes))throw s;let a=Zr(o,e.baseDelay,e.maxDelay,e.backoffMultiplier,e.enableJitter);i.totalDelay+=a,r&&r(o+1,s,a),yield(0,Ll.sleep)(a)}}throw n})}});var Xr=_(($h,Rl)=>{Rl.exports={name:"@fal-ai/client",description:"The fal.ai client for JavaScript and TypeScript",version:"1.6.2",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 We=_(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isBrowser=ql;Ye.getUserAgent=Vl;function ql(){return typeof window<"u"&&typeof window.document<"u"}var Qe=null;function Vl(){if(Qe!==null)return Qe;let t=Xr();return Qe=`${t.name}/${t.version}`,Qe}});var Ze=_(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.credentialsFromEnv=void 0;G.resolveDefaultFetch=ti;G.createConfig=Hl;G.getRestApiUrl=Gl;var Jr=jt(),Nl=K(),ei=Ae(),Fl=We();function ti(){if(typeof fetch>"u")throw new Error("Your environment does not support fetch. Please provide your own fetch implementation.");return fetch}function zl(){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 Bl=()=>{if(zl())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};G.credentialsFromEnv=Bl;var Kl={credentials:G.credentialsFromEnv,suppressLocalCredentialsWarning:!1,requestMiddleware:t=>Promise.resolve(t),responseHandler:Nl.defaultResponseHandler,retry:ei.DEFAULT_RETRY_OPTIONS};function Hl(t){var e;let r=Object.assign(Object.assign(Object.assign({},Kl),t),{fetch:(e=t.fetch)!==null&&e!==void 0?e:ti(),retry:Object.assign(Object.assign({},ei.DEFAULT_RETRY_OPTIONS),t.retry||{})});t.proxyUrl&&(r=Object.assign(Object.assign({},r),{requestMiddleware:(0,Jr.withMiddleware)(r.requestMiddleware,(0,Jr.withProxy)({targetUrl:t.proxyUrl}))}));let{credentials:i,suppressLocalCredentialsWarning:n}=r,o=typeof i=="function"?i():i;return(0,Fl.isBrowser)()&&o&&!n&&console.warn("The fal credentials are exposed in the browser's environment. That's not recommended for production use cases."),r}function Gl(){return"https://rest.alpha.fal.ai"}});var pe=_(Q=>{"use strict";var ri=Q&&Q.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})},Ql=Q&&Q.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(Q,"__esModule",{value:!0});Q.dispatchRequest=Wl;Q.buildUrl=Zl;var ii=Ae(),ni=We(),Dt=H(),Yl=typeof navigator<"u"&&navigator?.userAgent==="Cloudflare-Workers";function Wl(t){return ri(this,void 0,void 0,function*(){var e;let{targetUrl:r,input:i,config:n,options:o={}}=t,{credentials:s,requestMiddleware:a,responseHandler:c,fetch:u}=n,l=Object.assign(Object.assign({},n.retry),o.retry||{}),d=()=>ri(this,void 0,void 0,function*(){var p,g,b;let w=(0,ni.isBrowser)()?{}:{"User-Agent":(0,ni.getUserAgent)()},f=typeof s=="function"?s():s,{method:m,url:I,headers:x}=yield a({method:((g=(p=t.method)!==null&&p!==void 0?p:o.method)!==null&&g!==void 0?g:"post").toUpperCase(),url:r,headers:t.headers}),A=f?{Authorization:`Key ${f}`}:{},wt=Object.assign(Object.assign(Object.assign(Object.assign({},A),{Accept:"application/json","Content-Type":"application/json"}),w),x??{}),{responseHandler:xt,retry:uh}=o,wr=Ql(o,["responseHandler","retry"]),eo=yield u(I,Object.assign(Object.assign(Object.assign(Object.assign({},wr),{method:m,headers:Object.assign(Object.assign({},wt),(b=wr.headers)!==null&&b!==void 0?b:{})}),!Yl&&{mode:"cors"}),{signal:o.signal,body:m.toLowerCase()!=="get"&&i?JSON.stringify(i):void 0}));return yield(xt??c)(eo)}),h;for(let p=0;p<=l.maxRetries;p++)try{return yield d()}catch(g){if(h=g,p===l.maxRetries||!(0,ii.isRetryableError)(g,l.retryableStatusCodes)||((e=o.signal)===null||e===void 0?void 0:e.aborted))throw g;let w=(0,ii.calculateBackoffDelay)(p,l.baseDelay,l.maxDelay,l.backoffMultiplier,l.enableJitter);yield(0,Dt.sleep)(w)}throw h})}function Zl(t,e={}){var r,i;let n=((r=e.method)!==null&&r!==void 0?r:"post").toLowerCase(),o=((i=e.path)!==null&&i!==void 0?i:"").replace(/^\//,"").replace(/\/{2,}/,"/"),s=e.input,a=Object.assign(Object.assign({},e.query||{}),n==="get"?s:{}),c=Object.keys(a).length>0?`?${new URLSearchParams(a).toString()}`:"";if((0,Dt.isValidUrl)(t))return`${t.endsWith("/")?t:`${t}/`}${o}${c}`;let u=(0,Dt.ensureEndpointIdFormat)(t);return`${`https://${e.subdomain?`${e.subdomain}.`:""}fal.run/${u}/${o}`.replace(/\/$/,"")}${c}`}});var si=_(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Xl(t){let e,r,i,n,o,s,a;return c(),{feed:u,reset:c};function c(){e=!0,r="",i=0,n=-1,o=void 0,s=void 0,a=""}function u(d){r=r?r+d:d,e&&Jl(r)&&(r=r.slice(oi.length)),e=!1;let h=r.length,p=0,g=!1;for(;p<h;){g&&(r[p]===`
2
+ `&&++p,g=!1);let b=-1,w=n,f;for(let m=i;b<0&&m<h;++m)f=r[m],f===":"&&w<0?w=m-p:f==="\r"?(g=!0,b=m-p):f===`
3
+ `&&(b=m-p);if(b<0){i=h-p,n=w;break}else i=0,n=-1;l(r,p,w,b),p+=b+1}p===h?r="":p>0&&(r=r.slice(p))}function l(d,h,p,g){if(g===0){a.length>0&&(t({type:"event",id:o,event:s||void 0,data:a.slice(0,-1)}),a="",o=void 0),s=void 0;return}let b=p<0,w=d.slice(h,h+(b?g:p)),f=0;b?f=g:d[h+p+1]===" "?f=p+2:f=p+1;let m=h+f,I=g-f,x=d.slice(m,m+I).toString();if(w==="data")a+=x?"".concat(x,`
4
4
  `):`
5
- `;else if(w==="event")s=x;else if(w==="id"&&!x.includes("\0"))o=x;else if(w==="retry"){let A=parseInt(x,10);Number.isNaN(A)||t({type:"reconnect-interval",value:A})}}}var oi=[239,187,191];function Jl(t){return oi.every((e,r)=>t.charCodeAt(r)===e)}Ut.createParser=Xl});var Lt=_(Y=>{"use strict";var eu=Y&&Y.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Y,"__esModule",{value:!0});Y.TOKEN_EXPIRATION_SECONDS=void 0;Y.getTemporaryAuthToken=nu;var tu=Ze(),ru=pe(),iu=H();Y.TOKEN_EXPIRATION_SECONDS=120;function nu(t,e){return eu(this,void 0,void 0,function*(){let r=(0,iu.parseEndpointId)(t),i=yield(0,ru.dispatchRequest)({method:"POST",targetUrl:`${(0,tu.getRestApiUrl)()}/tokens/`,config:e,input:{allowed_apps:[r.alias],token_expiration:Y.TOKEN_EXPIRATION_SECONDS}});return typeof i!="string"&&i.detail?i.detail:i})}});var $t=_(U=>{"use strict";var he=U&&U.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})},Ce=U&&U.__await||function(t){return this instanceof Ce?(this.v=t,this):new Ce(t)},ou=U&&U.__asyncGenerator||function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,o=[];return n={},a("next"),a("throw"),a("return",s),n[Symbol.asyncIterator]=function(){return this},n;function s(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){i[p]&&(n[p]=function(b){return new Promise(function(w,f){o.push([p,b,w,f])>1||c(p,b)})},g&&(n[p]=g(n[p])))}function c(p,g){try{u(i[p](g))}catch(b){h(o[0][3],b)}}function u(p){p.value instanceof Ce?Promise.resolve(p.value.v).then(l,d):h(o[0][2],p)}function l(p){c("next",p)}function d(p){c("throw",p)}function h(p,g){p(g),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty(U,"__esModule",{value:!0});U.FalStream=void 0;U.createStreamingClient=uu;var su=si(),au=Lt(),ai=pe(),fe=K(),Rt="text/event-stream",lu=15*1e3,Xe=class{constructor(e,r,i){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this._requestId=null,this.abortController=new AbortController,this.start=()=>he(this,void 0,void 0,function*(){var o,s;let{endpointId:a,options:c}=this,{input:u,method:l="post",connectionMode:d="server"}=c;try{if(d==="client"){let h=yield(0,au.getTemporaryAuthToken)(a,this.config),{fetch:p}=this.config,g=new URL(this.url);g.searchParams.set("fal_jwt_token",h);let b=yield p(g.toString(),{method:l.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:Rt,"content-type":"application/json"},body:u&&l!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return this._requestId=b.headers.get("x-fal-request-id"),yield this.handleResponse(b)}return yield(0,ai.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(s=c.accept)!==null&&s!==void 0?s:Rt},responseHandler:h=>he(this,void 0,void 0,function*(){return this._requestId=h.headers.get("x-fal-request-id"),yield this.handleResponse(h)}),signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>he(this,void 0,void 0,function*(){var s,a;if(!o.ok){try{yield(0,fe.defaultResponseHandler)(o)}catch(b){this.emit("error",b)}return}let c=o.body;if(!c){this.emit("error",new fe.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((s=o.headers.get("content-type"))!==null&&s!==void 0?s:"").startsWith(Rt)){let b=c.getReader(),w=()=>{b.read().then(({done:f,value:y})=>{if(f){this.emit("done",this.currentData);return}this.currentData=y,this.emit("data",y),w()})};w();return}let l=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,su.createParser)(b=>{if(b.type==="event"){let w=b.data;try{let f=JSON.parse(w);this.buffer.push(f),this.currentData=f,this.emit("data",f),this.emit("message",f)}catch(f){this.emit("error",f)}}}),p=(a=this.options.timeout)!==null&&a!==void 0?a:lu,g=()=>he(this,void 0,void 0,function*(){let{value:b,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(l.decode(b)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new fe.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):g().catch(this.handleError)});g().catch(this.handleError)}),this.handleError=o=>{var s;if(o.name==="AbortError"||this.signal.aborted)return;let a=o instanceof fe.ApiError?o:new fe.ApiError({message:(s=o.message)!==null&&s!==void 0?s:"An unknown error occurred",status:500});this.emit("error",a)},this.on=(o,s)=>{var a;this.listeners.has(o)||this.listeners.set(o,[]),(a=this.listeners.get(o))===null||a===void 0||a.push(s)},this.emit=(o,s)=>{let a=this.listeners.get(o)||[];for(let c of a)c(s)},this.done=()=>he(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=e,this.config=r,this.url=(n=i.url)!==null&&n!==void 0?n:(0,ai.buildUrl)(e,{path:"/stream",query:i.queryParams}),this.options=i,this.donePromise=new Promise((o,s)=>{this.streamClosed&&s(new fe.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var a;o((a=this.currentData)!==null&&a!==void 0?a:{})}),this.on("done",a=>{this.streamClosed=!0,o(a)}),this.on("error",a=>{this.streamClosed=!0,s(a)})}),i.signal&&i.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return ou(this,arguments,function*(){let r=!0,i=()=>r=!1;for(this.on("error",i),this.on("done",i);r||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield Ce(n)),yield Ce(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};U.FalStream=Xe;function uu({config:t,storage:e}){return{stream(r,i){return he(this,void 0,void 0,function*(){let n=i.input?yield e.transformInput(i.input):void 0;return new Xe(r,t,Object.assign(Object.assign({},i),{input:n}))})}}}});var di=_(W=>{"use strict";var ee=W&&W.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})},cu=W&&W.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(W,"__esModule",{value:!0});W.createQueueClient=void 0;var V=pe(),du=K(),ci=Ae(),pu=$t(),Je=H(),li=500,ui={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:ci.DEFAULT_RETRYABLE_STATUS_CODES},fu={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...ci.DEFAULT_RETRYABLE_STATUS_CODES,500]},hu=({config:t,storage:e})=>{let r={submit(i,n){return ee(this,void 0,void 0,function*(){let{webhookUrl:o,priority:s,hint:a}=n,c=cu(n,["webhookUrl","priority","hint"]),u=n.input?yield e.transformInput(n.input):void 0;return(0,V.dispatchRequest)({method:n.method,targetUrl:(0,V.buildUrl)(i,Object.assign(Object.assign({},c),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:Object.assign({"x-fal-queue-priority":s??"normal"},a&&{"x-fal-runner-hint":a}),input:u,config:t,options:{signal:n.abortSignal,retry:ui}})})},status(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,abortSignal:c}){let u=(0,Je.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"";return(0,V.dispatchRequest)({method:"get",targetUrl:(0,V.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:a?"1":"0"},path:`/requests/${s}/status`}),config:t,options:{signal:c,retry:fu}})})},streamStatus(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,connectionMode:c}){let u=(0,Je.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"",d={logs:a?"1":"0"},h=(0,V.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${s}/status/stream`,query:d});return new pu.FalStream(o,t,{url:h,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(i,n){return ee(this,void 0,void 0,function*(){let o=n.requestId,s=n.timeout,a,c=()=>{};if(n.mode==="streaming"){let u=yield r.streamStatus(i,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];s&&(a=setTimeout(()=>{throw u.abort(),r.cancel(i,{requestId:o}).catch(c),new Error(`Client timed out waiting for the request to complete after ${s}ms`)},s)),u.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 d=yield u.done();return a&&clearTimeout(a),d}return new Promise((u,l)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:li,g=()=>{a&&clearTimeout(a),h&&clearTimeout(h)};s&&(a=setTimeout(()=>{g(),r.cancel(i,{requestId:o}).catch(c),l(new Error(`Client timed out waiting for the request to complete after ${s}ms`))},s));let b=()=>ee(this,void 0,void 0,function*(){var w;try{let f=yield r.status(i,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(f),f.status==="COMPLETED"){g(),u(f);return}h=setTimeout(b,p)}catch(f){g(),l(f)}});b().catch(l)})})},result(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let c=(0,Je.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,V.dispatchRequest)({method:"get",targetUrl:(0,V.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${s}`}),config:Object.assign(Object.assign({},t),{responseHandler:du.resultResponseHandler}),options:{signal:a,retry:ui}})})},cancel(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let c=(0,Je.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,V.dispatchRequest)({method:"put",targetUrl:(0,V.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${s}/cancel`}),config:t,options:{signal:a}})})}};return r};W.createQueueClient=hu});var et=_(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.utf8Count=gu;N.utf8EncodeJs=pi;N.utf8EncodeTE=fi;N.utf8Encode=bu;N.utf8DecodeJs=hi;N.utf8DecodeTD=gi;N.utf8Decode=_u;function gu(t){let e=t.length,r=0,i=0;for(;i<e;){let n=t.charCodeAt(i++);if(n&4294967168)if(!(n&4294965248))r+=2;else{if(n>=55296&&n<=56319&&i<e){let o=t.charCodeAt(i);(o&64512)===56320&&(++i,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?r+=4:r+=3}else{r++;continue}}return r}function pi(t,e,r){let i=t.length,n=r,o=0;for(;o<i;){let s=t.charCodeAt(o++);if(s&4294967168)if(!(s&4294965248))e[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<i){let a=t.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}s&4294901760?(e[n++]=s>>18&7|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128):(e[n++]=s>>12&15|224,e[n++]=s>>6&63|128)}else{e[n++]=s;continue}e[n++]=s&63|128}}var mu=new TextEncoder,yu=50;function fi(t,e,r){mu.encodeInto(t,e.subarray(r))}function bu(t,e,r){t.length>yu?fi(t,e,r):pi(t,e,r)}var vu=4096;function hi(t,e,r){let i=e,n=i+r,o=[],s="";for(;i<n;){let a=t[i++];if(!(a&128))o.push(a);else if((a&224)===192){let c=t[i++]&63;o.push((a&31)<<6|c)}else if((a&240)===224){let c=t[i++]&63,u=t[i++]&63;o.push((a&31)<<12|c<<6|u)}else if((a&248)===240){let c=t[i++]&63,u=t[i++]&63,l=t[i++]&63,d=(a&7)<<18|c<<12|u<<6|l;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(a);o.length>=vu&&(s+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(s+=String.fromCharCode(...o)),s}var wu=new TextDecoder,xu=200;function gi(t,e,r){let i=t.subarray(e,e+r);return wu.decode(i)}function _u(t,e,r){return r>xu?gi(t,e,r):hi(t,e,r)}});var Vt=_(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.ExtData=void 0;var qt=class{constructor(e,r){this.type=e,this.data=r}};tt.ExtData=qt});var it=_(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.DecodeError=void 0;var Nt=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};rt.DecodeError=Nt});var nt=_(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.UINT32_MAX=void 0;Z.setUint64=Iu;Z.setInt64=Eu;Z.getInt64=Su;Z.getUint64=Tu;Z.UINT32_MAX=4294967295;function Iu(t,e,r){let i=r/4294967296,n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Eu(t,e,r){let i=Math.floor(r/4294967296),n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Su(t,e){let r=t.getInt32(e),i=t.getUint32(e+4);return r*4294967296+i}function Tu(t,e){let r=t.getUint32(e),i=t.getUint32(e+4);return r*4294967296+i}});var Ft=_(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.timestampExtension=M.EXT_TIMESTAMP=void 0;M.encodeTimeSpecToTimestamp=yi;M.encodeDateToTimeSpec=bi;M.encodeTimestampExtension=vi;M.decodeTimestampToTimeSpec=wi;M.decodeTimestampExtension=xi;var ku=it(),mi=nt();M.EXT_TIMESTAMP=-1;var Au=4294967296-1,Cu=17179869184-1;function yi({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Cu)if(e===0&&t<=Au){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,i=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,e<<2|r&3),o.setUint32(4,i),n}else{let r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,e),(0,mi.setInt64)(i,4,t),r}}function bi(t){let e=t.getTime(),r=Math.floor(e/1e3),i=(e-r*1e3)*1e6,n=Math.floor(i/1e9);return{sec:r+n,nsec:i-n*1e9}}function vi(t){if(t instanceof Date){let e=bi(t);return yi(e)}else return null}function wi(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),i=e.getUint32(4),n=(r&3)*4294967296+i,o=r>>>2;return{sec:n,nsec:o}}case 12:{let r=(0,mi.getInt64)(e,4),i=e.getUint32(0);return{sec:r,nsec:i}}default:throw new ku.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function xi(t){let e=wi(t);return new Date(e.sec*1e3+e.nsec/1e6)}M.timestampExtension={type:M.EXT_TIMESTAMP,encode:vi,decode:xi}});var at=_(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.ExtensionCodec=void 0;var ot=Vt(),Mu=Ft(),Me=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Mu.timestampExtension)}register({type:e,encode:r,decode:i}){if(e>=0)this.encoders[e]=r,this.decoders[e]=i;else{let n=-1-e;this.builtInEncoders[n]=r,this.builtInDecoders[n]=i}}tryToEncode(e,r){for(let i=0;i<this.builtInEncoders.length;i++){let n=this.builtInEncoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=-1-i;return new ot.ExtData(s,o)}}}for(let i=0;i<this.encoders.length;i++){let n=this.encoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=i;return new ot.ExtData(s,o)}}}return e instanceof ot.ExtData?e:null}decode(e,r,i){let n=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return n?n(e,r,i):new ot.ExtData(r,e)}};st.ExtensionCodec=Me;Me.defaultCodec=new Me});var Bt=_(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.ensureUint8Array=ju;function Pu(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function ju(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Pu(t)?new Uint8Array(t):Uint8Array.from(t)}});var Ht=_($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.Encoder=$.DEFAULT_INITIAL_BUFFER_SIZE=$.DEFAULT_MAX_DEPTH=void 0;var _i=et(),Ou=at(),Ii=nt(),Du=Bt();$.DEFAULT_MAX_DEPTH=100;$.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Kt=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??Ou.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??$.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??$.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({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(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),i=new Uint8Array(r),n=new DataView(r);i.set(this.bytes),this.view=n,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let i=(0,_i.utf8Count)(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),(0,_i.utf8Encode)(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,r){let i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let i=(0,Du.ensureUint8Array)(e);this.writeU8a(i)}encodeArray(e,r){let i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(let n of e)this.doEncode(n,r+1)}countWithoutUndefined(e,r){let i=0;for(let n of r)e[n]!==void 0&&i++;return i}encodeMap(e,r){let i=Object.keys(e);this.sortKeys&&i.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.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 i){let s=e[o];this.ignoreUndefined&&s===void 0||(this.encodeString(o),this.doEncode(s,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let i=e.data(this.pos+6),n=i.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(i);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Ii.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Ii.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};$.Encoder=Kt});var Ei=_(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.encode=Lu;var Uu=Ht();function Lu(t,e){return new Uu.Encoder(e).encodeSharedRef(t)}});var Si=_(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.prettyByte=Ru;function Ru(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var Ti=_(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.CachedKeyDecoder=void 0;var $u=et(),qu=16,Vu=16,Yt=class{constructor(e=qu,r=Vu){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,i){let n=this.caches[i-1];e:for(let o of n){let s=o.bytes;for(let a=0;a<i;a++)if(s[a]!==e[r+a])continue e;return o.str}return null}store(e,r){let i=this.caches[e.length-1],n={bytes:e,str:r};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=n:i.push(n)}decode(e,r,i){let n=this.find(e,r,i);if(n!=null)return this.hit++,n;this.miss++;let o=(0,$u.utf8DecodeJs)(e,r,i),s=Uint8Array.prototype.slice.call(e,r,r+i);return this.store(s,o),o}};lt.CachedKeyDecoder=Yt});var ct=_(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.Decoder=void 0;var Wt=Si(),Nu=at(),te=nt(),Fu=et(),ki=Bt(),zu=Ti(),F=it(),Zt="array",je="map_key",Ci="map_value",Bu=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new F.DecodeError("The type of key must be string or number but "+typeof t)},Xt=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=Zt,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=je,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Zt){let i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===je||e.type===Ci){let i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Pe=-1,er=new DataView(new ArrayBuffer(0)),Ku=new Uint8Array(er.buffer);try{er.getInt8(0)}catch(t){if(!(t 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 Ai=new RangeError("Insufficient data"),Hu=new zu.CachedKeyDecoder,Jt=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=er,this.bytes=Ku,this.headByte=Pe,this.stack=new Xt,this.entered=!1,this.extensionCodec=e?.extensionCodec??Nu.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??te.UINT32_MAX,this.maxBinLength=e?.maxBinLength??te.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??te.UINT32_MAX,this.maxMapLength=e?.maxMapLength??te.UINT32_MAX,this.maxExtLength=e?.maxExtLength??te.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Hu,this.mapKeyConverter=e?.mapKeyConverter??Bu}clone(){return new t({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(e){let r=(0,ki.ensureUint8Array)(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Pe&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),i=(0,ki.ensureUint8Array)(e),n=new Uint8Array(r.length+i.length);n.set(r),n.set(i,r.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:i}=this;return new RangeError(`Extra ${r.byteLength-i} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,i;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),r=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}let{headByte:n,pos:o,totalPos:s}=this;throw new RangeError(`Insufficient data in parsing ${(0,Wt.prettyByte)(n)} at ${s} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let i=r,n=-1;for await(let o of e){if(r&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),i&&(n=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(s){if(!(s instanceof RangeError))throw s}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{let n=e-160;r=this.decodeString(n,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let n=this.lookU8();r=this.decodeString(n,1)}else if(e===218){let n=this.lookU16();r=this.decodeString(n,2)}else if(e===219){let n=this.lookU32();r=this.decodeString(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===196){let n=this.lookU8();r=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();r=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();r=this.decodeBinary(n,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();r=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();r=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();r=this.decodeExtension(n,4)}else throw new F.DecodeError(`Unrecognized type byte: ${(0,Wt.prettyByte)(e)}`);this.complete();let i=this.stack;for(;i.length>0;){let n=i.top();if(n.type===Zt)if(n.array[n.position]=r,n.position++,n.position===n.size)r=n.array,i.release(n);else continue e;else if(n.type===je){if(r==="__proto__")throw new F.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(r),n.type=Ci;continue e}else if(n.map[n.key]=r,n.readCount++,n.readCount===n.size)r=n.map,i.release(n);else{n.key=null,n.type=je;continue e}}return r}}readHeadByte(){return this.headByte===Pe&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Pe}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new F.DecodeError(`Unrecognized array type byte: ${(0,Wt.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new F.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new F.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new F.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Ai;let i=this.pos+r,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,i,e):n=(0,Fu.utf8Decode)(this.bytes,i,e),this.pos+=r+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===je:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new F.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Ai;let i=this.pos+r,n=this.bytes.subarray(i,i+e);return this.pos+=r+e,n}decodeExtension(e,r){if(e>this.maxExtLength)throw new F.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let i=this.view.getInt8(this.pos+r),n=this.decodeBinary(e,r+1);return this.extensionCodec.decode(n,i,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 e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,te.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,te.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};ut.Decoder=Jt});var Pi=_(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.decode=Gu;dt.decodeMulti=Qu;var Mi=ct();function Gu(t,e){return new Mi.Decoder(e).decode(t)}function Qu(t,e){return new Mi.Decoder(e).decodeMulti(t)}});var Di=_(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.isAsyncIterable=ji;Oe.asyncIterableFromStream=Oi;Oe.ensureAsyncIterable=Yu;function ji(t){return t[Symbol.asyncIterator]!=null}async function*Oi(t){let e=t.getReader();try{for(;;){let{done:r,value:i}=await e.read();if(r)return;yield i}}finally{e.releaseLock()}}function Yu(t){return ji(t)?t:Oi(t)}});var Ui=_(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.decodeAsync=Wu;De.decodeArrayStream=Zu;De.decodeMultiStream=Xu;var tr=ct(),rr=Di();async function Wu(t,e){let r=(0,rr.ensureAsyncIterable)(t);return new tr.Decoder(e).decodeAsync(r)}function Zu(t,e){let r=(0,rr.ensureAsyncIterable)(t);return new tr.Decoder(e).decodeArrayStream(r)}function Xu(t,e){let r=(0,rr.ensureAsyncIterable)(t);return new tr.Decoder(e).decodeStream(r)}});var Ri=_(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.decodeTimestampExtension=v.encodeTimestampExtension=v.decodeTimestampToTimeSpec=v.encodeTimeSpecToTimestamp=v.encodeDateToTimeSpec=v.EXT_TIMESTAMP=v.ExtData=v.ExtensionCodec=v.Encoder=v.DecodeError=v.Decoder=v.decodeMultiStream=v.decodeArrayStream=v.decodeAsync=v.decodeMulti=v.decode=v.encode=void 0;var Ju=Ei();Object.defineProperty(v,"encode",{enumerable:!0,get:function(){return Ju.encode}});var Li=Pi();Object.defineProperty(v,"decode",{enumerable:!0,get:function(){return Li.decode}});Object.defineProperty(v,"decodeMulti",{enumerable:!0,get:function(){return Li.decodeMulti}});var ir=Ui();Object.defineProperty(v,"decodeAsync",{enumerable:!0,get:function(){return ir.decodeAsync}});Object.defineProperty(v,"decodeArrayStream",{enumerable:!0,get:function(){return ir.decodeArrayStream}});Object.defineProperty(v,"decodeMultiStream",{enumerable:!0,get:function(){return ir.decodeMultiStream}});var ec=ct();Object.defineProperty(v,"Decoder",{enumerable:!0,get:function(){return ec.Decoder}});var tc=it();Object.defineProperty(v,"DecodeError",{enumerable:!0,get:function(){return tc.DecodeError}});var rc=Ht();Object.defineProperty(v,"Encoder",{enumerable:!0,get:function(){return rc.Encoder}});var ic=at();Object.defineProperty(v,"ExtensionCodec",{enumerable:!0,get:function(){return ic.ExtensionCodec}});var nc=Vt();Object.defineProperty(v,"ExtData",{enumerable:!0,get:function(){return nc.ExtData}});var ge=Ft();Object.defineProperty(v,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return ge.EXT_TIMESTAMP}});Object.defineProperty(v,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return ge.encodeDateToTimeSpec}});Object.defineProperty(v,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return ge.encodeTimeSpecToTimestamp}});Object.defineProperty(v,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return ge.decodeTimestampToTimeSpec}});Object.defineProperty(v,"encodeTimestampExtension",{enumerable:!0,get:function(){return ge.encodeTimestampExtension}});Object.defineProperty(v,"decodeTimestampExtension",{enumerable:!0,get:function(){return ge.decodeTimestampExtension}})});var Xi=_(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});function k(t){return{enumerable:!0,value:t}}function $i(t){return{enumerable:!0,writable:!0,value:t}}var re={},oc=()=>!0,qi=()=>({}),Ni=t=>t,sc=(t,e,r,i)=>t.apply(r,i)&&e.apply(r,i),ac=(t,e,r,[i,n])=>e.call(r,t.call(r,i,n),n),X=(t,e)=>Object.freeze(Object.create(t,e));function Vi(t,e,r){return t.reduce((i,n)=>function(...o){return r(i,n,this,o)},e)}function Fi(t){return X(this,{fn:k(t)})}var zi={},Bi=Fi.bind(zi),lc=t=>Bi((e,r)=>!!~t(e,r)&&e),Ki={},uc=Fi.bind(Ki);function pt(t,e){return e.filter(r=>t.isPrototypeOf(r))}function Hi(t,e,...r){let i=Vi(pt(Ki,r).map(o=>o.fn),oc,sc),n=Vi(pt(zi,r).map(o=>o.fn),Ni,ac);return X(this,{from:k(t),to:k(e),guards:k(i),reducers:k(n)})}var Gi={},Qi={},cc=Hi.bind(Gi),dc=Hi.bind(Qi,null);function pc(t,e,r){return or(e,t,r,this.immediates)||t}function Yi(t){let e=new Map;for(let r of t)e.has(r.from)||e.set(r.from,[]),e.get(r.from).push(r);return e}var fc={enter:Ni};function hc(...t){let e=pt(Gi,t),r=pt(Qi,t),i={final:k(t.length===0),transitions:k(Yi(e))};return r.length&&(i.immediates=k(r),i.enter=k(pc)),X(fc,i)}var gc={enter(t,e,r){let i=this.fn.call(e,e.context,r);return nr.isPrototypeOf(i)?X(Wi,{machine:k(i),transitions:k(this.transitions)}).enter(t,e,r):(i.then(n=>e.send({type:"done",data:n})).catch(n=>e.send({type:"error",error:n})),t)}},Wi={enter(t,e,r){if(e.child=Zi(this.machine,i=>{e.onChange(i),e.child==i&&i.machine.state.value.final&&(delete e.child,e.send({type:"done",data:i.context}))},e.context,r),e.child.machine.state.value.final){let i=e.child.context;return delete e.child,or(e,t,{type:"done",data:i},this.transitions.get("done"))}return t}};function mc(t,...e){let r=k(Yi(e));return nr.isPrototypeOf(t)?X(Wi,{machine:k(t),transitions:r}):X(gc,{fn:k(t),transitions:r})}var nr={get state(){return{name:this.current,value:this.states[this.current]}}};function yc(t,e,r=qi){return typeof t!="string"&&(r=e||qi,e=t,t=Object.keys(e)[0]),re._create&&re._create(t,e),X(nr,{context:k(r),current:k(t),states:k(e)})}function or(t,e,r,i){let{context:n}=t;for(let{to:o,guards:s,reducers:a}of i)if(s(n,r)){t.context=a.call(t,n,r);let c=e.original||e,u=X(c,{current:k(o),original:{value:c}});return re._onEnter&&re._onEnter(e,o,t.context,n,r),u.state.value.enter(u,t,r)}}function bc(t,e){let r=e.type||e,{machine:i}=t,{value:n,name:o}=i.state;return n.transitions.has(r)?or(t,i,e,n.transitions.get(r))||i:(re._send&&re._send(r,o),i)}var vc={send(t){this.machine=bc(this,t),this.onChange(this)}};function Zi(t,e,r,i){let n=Object.create(vc,{machine:$i(t),context:$i(t.context(r,i)),onChange:k(e)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,i),n}P.action=lc;P.createMachine=yc;P.d=re;P.guard=uc;P.immediate=dc;P.interpret=Zi;P.invoke=mc;P.reduce=Bi;P.state=hc;P.transition=cc});var nn=_(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.createRealtimeClient=Dc;var ht=Ri(),m=Xi(),Ji=Lt(),sr=K(),en=We(),ur=H(),wc=()=>({enqueuedMessage:void 0});function xc(t){return t.token!==void 0}function _c(t){return!xc(t)}function ft(t,e){return Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function z(t){return t.websocket&&t.websocket.readyState===WebSocket.OPEN&&t.websocket.close(),Object.assign(Object.assign({},t),{websocket:void 0})}function Ic(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,ht.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function ar(t){return Object.assign(Object.assign({},t),{token:void 0})}function Ec(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Sc(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var Tc=(0,m.createMachine)("idle",{idle:(0,m.state)((0,m.transition)("send","connecting",(0,m.reduce)(ft)),(0,m.transition)("expireToken","idle",(0,m.reduce)(ar)),(0,m.transition)("close","idle",(0,m.reduce)(z))),connecting:(0,m.state)((0,m.transition)("connecting","connecting"),(0,m.transition)("connected","active",(0,m.reduce)(Sc)),(0,m.transition)("connectionClosed","idle",(0,m.reduce)(z)),(0,m.transition)("send","connecting",(0,m.reduce)(ft)),(0,m.transition)("close","idle",(0,m.reduce)(z)),(0,m.immediate)("authRequired",(0,m.guard)(_c))),authRequired:(0,m.state)((0,m.transition)("initiateAuth","authInProgress"),(0,m.transition)("send","authRequired",(0,m.reduce)(ft)),(0,m.transition)("close","idle",(0,m.reduce)(z))),authInProgress:(0,m.state)((0,m.transition)("authenticated","connecting",(0,m.reduce)(Ec)),(0,m.transition)("unauthorized","idle",(0,m.reduce)(ar),(0,m.reduce)(z)),(0,m.transition)("send","authInProgress",(0,m.reduce)(ft)),(0,m.transition)("close","idle",(0,m.reduce)(z))),active:(0,m.state)((0,m.transition)("send","active",(0,m.reduce)(Ic)),(0,m.transition)("unauthorized","idle",(0,m.reduce)(ar)),(0,m.transition)("connectionClosed","idle",(0,m.reduce)(z)),(0,m.transition)("close","idle",(0,m.reduce)(z))),failed:(0,m.state)((0,m.transition)("send","failed"),(0,m.transition)("close","idle",(0,m.reduce)(z)))},wc);function kc(t,{token:e,maxBuffering:r}){if(r!==void 0&&(r<1||r>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let i=new URLSearchParams({fal_jwt_token:e});return r!==void 0&&i.set("max_buffering",r.toFixed(0)),`wss://fal.run/${(0,ur.ensureEndpointIdFormat)(t)}/realtime?${i.toString()}`}var Ac=128;function Cc(t){return t.status==="error"&&t.error==="Unauthorized"}var Mc={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},lr=new Map,tn=new Map;function Pc(t,e,r){if(!lr.has(t)){let i=(0,m.interpret)(Tc,r);lr.set(t,Object.assign(Object.assign({},i),{throttledSend:e>0?(0,ur.throttle)(i.send,e,!0):i.send}))}return lr.get(t)}var Ue=()=>{},jc={send:Ue,close:Ue};function Oc(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!rn(t)}function rn(t){return t.type==="x-fal-error"}function Dc({config:t}){return{connect(e,r){let{clientOnly:i=(0,ur.isReact)()&&!(0,en.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:s=Ac}=r;if(i&&!(0,en.isBrowser)())return jc;let a;tn.set(n,{onError:r.onError,onResult:r.onResult});let c=()=>tn.get(n),u=Pc(n,s,({context:h,machine:p,send:g})=>{let{enqueuedMessage:b,token:w}=h;if(p.current==="active"&&b&&g({type:"send",message:b}),p.current==="authRequired"&&w===void 0&&a!==p.current&&(g({type:"initiateAuth"}),(0,Ji.getTemporaryAuthToken)(e,t).then(f=>{g({type:"authenticated",token:f});let y=Math.round(Ji.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{g({type:"expireToken"})},y)}).catch(f=>{g({type:"unauthorized",error:f})})),p.current==="connecting"&&a!==p.current&&w!==void 0){let f=new WebSocket(kc(e,{token:w,maxBuffering:o}));f.onopen=()=>{g({type:"connected",websocket:f})},f.onclose=y=>{if(y.code!==Mc.NORMAL_CLOSURE){let{onError:I=Ue}=c();I(new sr.ApiError({message:`Error closing the connection: ${y.reason}`,status:y.code}))}g({type:"connectionClosed",code:y.code})},f.onerror=y=>{let{onError:I=Ue}=c();I(new sr.ApiError({message:"Unknown error",status:500}))},f.onmessage=y=>{let{onResult:I}=c();if(y.data instanceof ArrayBuffer){let A=(0,ht.decode)(new Uint8Array(y.data));I(A);return}if(y.data instanceof Uint8Array){let A=(0,ht.decode)(y.data);I(A);return}if(y.data instanceof Blob){y.data.arrayBuffer().then(A=>{let wt=(0,ht.decode)(new Uint8Array(A));I(wt)});return}let x=JSON.parse(y.data);if(Cc(x)){g({type:"unauthorized",error:new Error("Unauthorized")});return}if(Oc(x)){I(x);return}if(rn(x)){if(x.error==="TIMEOUT")return;let{onError:A=Ue}=c();A(new sr.ApiError({message:`${x.error}: ${x.reason}`,status:400,body:x}));return}}}a=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var un=_(Le=>{"use strict";var ie=Le&&Le.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Le,"__esModule",{value:!0});Le.createStorageClient=qc;var on=Ze(),sn=pe(),Uc=H();function an(t){var e;let[r,i]=t.split("/");return(e=i.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function Lc(t,e,r){return ie(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${an(r)}`;return yield(0,sn.dispatchRequest)({method:"POST",targetUrl:`${(0,on.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function Rc(t,e,r){return ie(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${an(r)}`;return yield(0,sn.dispatchRequest)({method:"POST",targetUrl:`${(0,on.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function ln(t,e,r){return ie(this,arguments,void 0,function*(i,n,o,s=3){if(s===0)throw new Error("Part upload failed, retries exhausted");let{fetch:a,responseHandler:c}=o;try{let u=yield a(i,{method:"PUT",body:n});return yield c(u)}catch{return yield ln(i,n,o,s-1)}})}function $c(t,e){return ie(this,void 0,void 0,function*(){let{fetch:r,responseHandler:i}=e,n=t.type||"application/octet-stream",{upload_url:o,file_url:s}=yield Rc(t,e,n),a=10*1024*1024,c=Math.ceil(t.size/a),u=new URL(o),l=[];for(let p=0;p<c;p++){let g=p*a,b=Math.min(g+a,t.size),w=t.slice(g,b),f=p+1,y=`${u.origin}${u.pathname}/${f}${u.search}`;l.push(yield ln(y,w,e))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield r(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield i(h),s})}function qc({config:t}){let e={upload:r=>ie(this,void 0,void 0,function*(){if(r.size>94371840)return yield $c(r,t);let i=r.type||"application/octet-stream",{fetch:n,responseHandler:o}=t,{upload_url:s,file_url:a}=yield Lc(r,t,i),c=yield n(s,{method:"PUT",body:r,headers:{"Content-Type":r.type||"application/octet-stream"}});return yield o(c),a}),transformInput:r=>ie(this,void 0,void 0,function*(){if(Array.isArray(r))return Promise.all(r.map(i=>e.transformInput(i)));if(r instanceof Blob)return yield e.upload(r);if((0,Uc.isPlainObject)(r)){let n=Object.entries(r).map(s=>ie(this,[s],void 0,function*([a,c]){return[a,yield e.transformInput(c)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return r})};return e}});var dr=_(Re=>{"use strict";var cn=Re&&Re.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Re,"__esModule",{value:!0});Re.createFalClient=Hc;var Vc=Ze(),Nc=di(),Fc=nn(),dn=pe(),zc=K(),Bc=un(),Kc=$t();function Hc(t={}){let e=(0,Vc.createConfig)(t),r=(0,Bc.createStorageClient)({config:e}),i=(0,Nc.createQueueClient)({config:e,storage:r}),n=(0,Kc.createStreamingClient)({config:e,storage:r}),o=(0,Fc.createRealtimeClient)({config:e});return{queue:i,realtime:o,storage:r,streaming:n,stream:n.stream,run(s){return cn(this,arguments,void 0,function*(a,c={}){let u=c.input?yield r.transformInput(c.input):void 0;return(0,dn.dispatchRequest)({method:c.method,targetUrl:(0,dn.buildUrl)(a,c),input:u,config:Object.assign(Object.assign({},e),{responseHandler:zc.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(s,a)=>cn(this,void 0,void 0,function*(){let{request_id:c}=yield i.submit(s,a);return a.onEnqueue&&a.onEnqueue(c),yield i.subscribeToStatus(s,Object.assign({requestId:c},a)),i.result(s,{requestId:c})})}}});var fn=_(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.isQueueStatus=pn;gt.isCompletedQueueStatus=Gc;function pn(t){return t&&t.status&&t.response_url}function Gc(t){return pn(t)&&t.status==="COMPLETED"}});var yn=_(T=>{"use strict";var Qc=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Yc=T&&T.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Qc(e,t,r)};Object.defineProperty(T,"__esModule",{value:!0});T.fal=T.parseEndpointId=T.isRetryableError=T.ValidationError=T.ApiError=T.withProxy=T.withMiddleware=T.createFalClient=void 0;var hn=dr(),Wc=dr();Object.defineProperty(T,"createFalClient",{enumerable:!0,get:function(){return Wc.createFalClient}});var gn=jt();Object.defineProperty(T,"withMiddleware",{enumerable:!0,get:function(){return gn.withMiddleware}});Object.defineProperty(T,"withProxy",{enumerable:!0,get:function(){return gn.withProxy}});var mn=K();Object.defineProperty(T,"ApiError",{enumerable:!0,get:function(){return mn.ApiError}});Object.defineProperty(T,"ValidationError",{enumerable:!0,get:function(){return mn.ValidationError}});var Zc=Ae();Object.defineProperty(T,"isRetryableError",{enumerable:!0,get:function(){return Zc.isRetryableError}});Yc(fn(),T);var Xc=H();Object.defineProperty(T,"parseEndpointId",{enumerable:!0,get:function(){return Xc.parseEndpointId}});T.fal=function(){let e=(0,hn.createFalClient)();return{config(r){e=(0,hn.createFalClient)(r)},get queue(){return e.queue},get realtime(){return e.realtime},get storage(){return e.storage},get streaming(){return e.streaming},run(r,i){return e.run(r,i)},subscribe(r,i){return e.subscribe(r,i)},stream(r,i){return e.stream(r,i)}}}()});var _r={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},MinimaxVideo01LiveInput:{title:"TextToVideoLiveRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0}},"x-fal-order-properties":["prompt"],required:["prompt"]},MinimaxVideo01LiveOutput:{title:"T2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/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/minimax/video-01-live/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/minimax/video-01-live":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/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/MinimaxVideo01LiveOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};async function Ir(t,e,r){if(e!=null){if(e.startsWith("blob:")){let n=await(await fetch(e)).blob(),o=new File([n],"image.png",{type:"image/png"});return t.storage.upload(o)}if(r!=null&&e.startsWith("buffer:")){let i=await r.engine.editor.getMimeType(e),n=r.engine.editor.getBufferLength(e),o=r.engine.editor.getBufferData(e,0,n),s=new Uint8Array(o),a=new File([s],"image.png",{type:i});return t.storage.upload(a)}return e}}function uo(t,e){let{cesdk:r}=e,i=e.propertyKey??"image_url",n=St(t);return r.i18n.setTranslations({en:{[`panel.${n}`]:"Select Image To Change"}}),co(t,r),{[i]:(o,s)=>{let{builder:a,experimental:{global:c},payload:u}=o,l=u?.url??e.defaultUrl,d=c(`${t}.${s.id}`,l);return a.MediaPreview(s.id,{preview:{type:"image",uri:d.value},action:{label:"Select Image",onClick:()=>{r?.ui.openPanel(n,{payload:{onSelect:h=>{h.meta?.uri!=null&&d.setValue(h.meta?.uri)}}})}}}),()=>({id:s.id,type:"string",value:d.value})}}}function co(t,e){e?.ui.registerPanel(St(t),({builder:r,payload:i})=>{r.Library(`${t}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let s=await e.engine.editor.getMimeType(o);s==="image/svg+xml"?e.ui.showNotification({type:"warning",message:"SVG images are not supported. Please choose a different image."}):s.startsWith("image/")?(i?.onSelect(n),e?.ui.closePanel(St(t))):e.ui.showNotification({type:"warning",message:`Only images are supported. Found '${s}'. Please choose a different image.`})}})})}function St(t){return`ly.img.ai.${t}.imageSelection`}var po=uo,fo=class{constructor(t,e=[]){this.id=t,this.assets=e.map(r=>{if(typeof r.label=="string"&&!(r.label&&typeof r.label=="object")){let i=r;return{id:i.id,label:{en:i.label},meta:i.thumbUri?{...i.meta??{},thumbUri:i.thumbUri}:i.meta}}return r}),this.activeAssetIds=new Set}async findAssets(t){let{page:e,perPage:r,locale:i="en",sortActiveFirst:n,query:o,tags:s,groups:a,excludeGroups:c,sortingOrder:u,sortKey:l}=t,d=[...this.assets];if(a&&a.length>0&&(d=d.filter(f=>f.groups&&a.some(y=>f.groups?.includes(y)))),c&&c.length>0&&(d=d.filter(f=>!f.groups||!c.some(y=>f.groups?.includes(y)))),o){let f=o.toLowerCase();d=d.filter(y=>{let I=y.label?.[i]?.toLowerCase(),x=y.tags?.[i]||[];return I&&I.includes(f)||x.some(A=>A.toLowerCase().includes(f))})}if(s&&s.length>0){let f=Array.isArray(s)?s:[s];d=d.filter(y=>{let I=y.tags?.[i]||[];return f.some(x=>I.includes(x))})}n&&d.sort((f,y)=>{let I=this.activeAssetIds.has(f.id),x=this.activeAssetIds.has(y.id);return I&&!x?-1:!I&&x?1:0}),l&&l!=="id"?d.sort((f,y)=>{let I=f.meta?.[l],x=y.meta?.[l];return I===void 0?1:x===void 0?-1:typeof I=="string"&&typeof x=="string"?u==="Descending"?x.localeCompare(I):I.localeCompare(x):typeof I=="number"&&typeof x=="number"?u==="Descending"?x-I:I-x:0}):l==="id"&&d.sort((f,y)=>u==="Descending"?y.id.localeCompare(f.id):f.id.localeCompare(y.id));let h=d.length,p=e*r,g=p+r,b=d.slice(p,g).map(f=>({id:f.id,groups:f.groups,meta:f.meta,payload:f.payload,locale:i,label:f.label?.[i],tags:f.tags?.[i],active:this.activeAssetIds.has(f.id)})),w=g<h?e+1:void 0;return{assets:b,currentPage:e,nextPage:w,total:h}}updateLabel(t,e,r){this.assets.forEach(i=>{i.id===t&&(i.label=i.label||{},i.label[r]=e)})}getAssetSelectValue(t){let e=this.assets.find(({id:r})=>r===t);if(e)return{id:e.id,label:e.label?.en||"",thumbUri:e.meta?.thumbUri}}getAsset(t){return this.assets.find(e=>e.id===t)}setAssetActive(t){this.activeAssetIds.add(t)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(t){t.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(t){this.activeAssetIds.delete(t)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(t){return this.activeAssetIds.has(t)}addAsset(t){let e=this.assets.findIndex(r=>r.id===t.id);e>=0?this.assets[e]=t:this.assets.push(t)}removeAsset(t){let e=this.assets.findIndex(r=>r.id===t);e!==-1&&(this.assets.splice(e,1),this.activeAssetIds.delete(t))}async getGroups(){let t=new Set;return this.assets.forEach(e=>{e.groups&&e.groups.forEach(r=>t.add(r))}),Array.from(t)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var ho=typeof global=="object"&&global&&global.Object===Object&&global,$r=ho,go=typeof self=="object"&&self&&self.Object===Object&&self,mo=$r||go||Function("return this")(),q=mo,yo=q.Symbol,se=yo,qr=Object.prototype,bo=qr.hasOwnProperty,vo=qr.toString,_e=se?se.toStringTag:void 0;function wo(t){var e=bo.call(t,_e),r=t[_e];try{t[_e]=void 0;var i=!0}catch{}var n=vo.call(t);return i&&(e?t[_e]=r:delete t[_e]),n}var xo=wo,_o=Object.prototype,Io=_o.toString;function Eo(t){return Io.call(t)}var So=Eo,To="[object Null]",ko="[object Undefined]",Er=se?se.toStringTag:void 0;function Ao(t){return t==null?t===void 0?ko:To:Er&&Er in Object(t)?xo(t):So(t)}var Te=Ao;function Co(t){return t!=null&&typeof t=="object"}var Pt=Co,hh=Array.isArray;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Vr=Mo,Po="[object AsyncFunction]",jo="[object Function]",Oo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!Vr(t))return!1;var e=Te(t);return e==jo||e==Oo||e==Po||e==Do}var Lo=Uo,Ro=q["__core-js_shared__"],_t=Ro,Sr=function(){var t=/[^.]+$/.exec(_t&&_t.keys&&_t.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function $o(t){return!!Sr&&Sr in t}var qo=$o,Vo=Function.prototype,No=Vo.toString;function Fo(t){if(t!=null){try{return No.call(t)}catch{}try{return t+""}catch{}}return""}var J=Fo,zo=/[\\^$.*+?()[\]{}|]/g,Bo=/^\[object .+?Constructor\]$/,Ko=Function.prototype,Ho=Object.prototype,Go=Ko.toString,Qo=Ho.hasOwnProperty,Yo=RegExp("^"+Go.call(Qo).replace(zo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Wo(t){if(!Vr(t)||qo(t))return!1;var e=Lo(t)?Yo:Bo;return e.test(J(t))}var Zo=Wo;function Xo(t,e){return t?.[e]}var Jo=Xo;function es(t,e){var r=Jo(t,e);return Zo(r)?r:void 0}var ae=es,ts=ae(q,"WeakMap"),Tt=ts;function rs(t,e){return t===e||t!==t&&e!==e}var is=rs,ns=9007199254740991;function os(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ns}var ss=os,gh=Object.prototype,as="[object Arguments]";function ls(t){return Pt(t)&&Te(t)==as}var Tr=ls,Nr=Object.prototype,us=Nr.hasOwnProperty,cs=Nr.propertyIsEnumerable,mh=Tr(function(){return arguments}())?Tr:function(t){return Pt(t)&&us.call(t,"callee")&&!cs.call(t,"callee")},Fr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kr=Fr&&typeof module=="object"&&module&&!module.nodeType&&module,ds=kr&&kr.exports===Fr,Ar=ds?q.Buffer:void 0,yh=Ar?Ar.isBuffer:void 0,ps="[object Arguments]",fs="[object Array]",hs="[object Boolean]",gs="[object Date]",ms="[object Error]",ys="[object Function]",bs="[object Map]",vs="[object Number]",ws="[object Object]",xs="[object RegExp]",_s="[object Set]",Is="[object String]",Es="[object WeakMap]",Ss="[object ArrayBuffer]",Ts="[object DataView]",ks="[object Float32Array]",As="[object Float64Array]",Cs="[object Int8Array]",Ms="[object Int16Array]",Ps="[object Int32Array]",js="[object Uint8Array]",Os="[object Uint8ClampedArray]",Ds="[object Uint16Array]",Us="[object Uint32Array]",E={};E[ks]=E[As]=E[Cs]=E[Ms]=E[Ps]=E[js]=E[Os]=E[Ds]=E[Us]=!0;E[ps]=E[fs]=E[Ss]=E[hs]=E[Ts]=E[gs]=E[ms]=E[ys]=E[bs]=E[vs]=E[ws]=E[xs]=E[_s]=E[Is]=E[Es]=!1;function Ls(t){return Pt(t)&&ss(t.length)&&!!E[Te(t)]}var Rs=Ls;function $s(t){return function(e){return t(e)}}var qs=$s,zr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ie=zr&&typeof module=="object"&&module&&!module.nodeType&&module,Vs=Ie&&Ie.exports===zr,It=Vs&&$r.process,Ns=function(){try{var t=Ie&&Ie.require&&Ie.require("util").types;return t||It&&It.binding&&It.binding("util")}catch{}}(),Cr=Ns,Mr=Cr&&Cr.isTypedArray,bh=Mr?qs(Mr):Rs,Fs=Object.prototype,vh=Fs.hasOwnProperty;function zs(t,e){return function(r){return t(e(r))}}var Bs=zs,wh=Bs(Object.keys,Object),Ks=Object.prototype,xh=Ks.hasOwnProperty,Hs=ae(Object,"create"),Ee=Hs;function Gs(){this.__data__=Ee?Ee(null):{},this.size=0}var Qs=Gs;function Ys(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ws=Ys,Zs="__lodash_hash_undefined__",Xs=Object.prototype,Js=Xs.hasOwnProperty;function ea(t){var e=this.__data__;if(Ee){var r=e[t];return r===Zs?void 0:r}return Js.call(e,t)?e[t]:void 0}var ta=ea,ra=Object.prototype,ia=ra.hasOwnProperty;function na(t){var e=this.__data__;return Ee?e[t]!==void 0:ia.call(e,t)}var oa=na,sa="__lodash_hash_undefined__";function aa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ee&&e===void 0?sa:e,this}var la=aa;function le(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}le.prototype.clear=Qs;le.prototype.delete=Ws;le.prototype.get=ta;le.prototype.has=oa;le.prototype.set=la;var Pr=le;function ua(){this.__data__=[],this.size=0}var ca=ua;function da(t,e){for(var r=t.length;r--;)if(is(t[r][0],e))return r;return-1}var Be=da,pa=Array.prototype,fa=pa.splice;function ha(t){var e=this.__data__,r=Be(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():fa.call(e,r,1),--this.size,!0}var ga=ha;function ma(t){var e=this.__data__,r=Be(e,t);return r<0?void 0:e[r][1]}var ya=ma;function ba(t){return Be(this.__data__,t)>-1}var va=ba;function wa(t,e){var r=this.__data__,i=Be(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var xa=wa;function ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ue.prototype.clear=ca;ue.prototype.delete=ga;ue.prototype.get=ya;ue.prototype.has=va;ue.prototype.set=xa;var Ke=ue,_a=ae(q,"Map"),Se=_a;function Ia(){this.size=0,this.__data__={hash:new Pr,map:new(Se||Ke),string:new Pr}}var Ea=Ia;function Sa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Ta=Sa;function ka(t,e){var r=t.__data__;return Ta(e)?r[typeof e=="string"?"string":"hash"]:r.map}var He=ka;function Aa(t){var e=He(this,t).delete(t);return this.size-=e?1:0,e}var Ca=Aa;function Ma(t){return He(this,t).get(t)}var Pa=Ma;function ja(t){return He(this,t).has(t)}var Oa=ja;function Da(t,e){var r=He(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var Ua=Da;function ce(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ce.prototype.clear=Ea;ce.prototype.delete=Ca;ce.prototype.get=Pa;ce.prototype.has=Oa;ce.prototype.set=Ua;var Br=ce;function La(){this.__data__=new Ke,this.size=0}var Ra=La;function $a(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var qa=$a;function Va(t){return this.__data__.get(t)}var Na=Va;function Fa(t){return this.__data__.has(t)}var za=Fa,Ba=200;function Ka(t,e){var r=this.__data__;if(r instanceof Ke){var i=r.__data__;if(!Se||i.length<Ba-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Br(i)}return r.set(t,e),this.size=r.size,this}var Ha=Ka;function ke(t){var e=this.__data__=new Ke(t);this.size=e.size}ke.prototype.clear=Ra;ke.prototype.delete=qa;ke.prototype.get=Na;ke.prototype.has=za;ke.prototype.set=Ha;var Ga=Object.prototype,_h=Ga.propertyIsEnumerable,Qa=ae(q,"DataView"),kt=Qa,Ya=ae(q,"Promise"),At=Ya,Wa=ae(q,"Set"),Ct=Wa,jr="[object Map]",Za="[object Object]",Or="[object Promise]",Dr="[object Set]",Ur="[object WeakMap]",Lr="[object DataView]",Xa=J(kt),Ja=J(Se),el=J(At),tl=J(Ct),rl=J(Tt),oe=Te;(kt&&oe(new kt(new ArrayBuffer(1)))!=Lr||Se&&oe(new Se)!=jr||At&&oe(At.resolve())!=Or||Ct&&oe(new Ct)!=Dr||Tt&&oe(new Tt)!=Ur)&&(oe=function(t){var e=Te(t),r=e==Za?t.constructor:void 0,i=r?J(r):"";if(i)switch(i){case Xa:return Lr;case Ja:return jr;case el:return Or;case tl:return Dr;case rl:return Ur}return e});var Ih=q.Uint8Array,il="__lodash_hash_undefined__";function nl(t){return this.__data__.set(t,il),this}var ol=nl;function sl(t){return this.__data__.has(t)}var al=sl;function Mt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Br;++e<r;)this.add(t[e])}Mt.prototype.add=Mt.prototype.push=ol;Mt.prototype.has=al;var Rr=se?se.prototype:void 0,Eh=Rr?Rr.valueOf:void 0,ll=Object.prototype,Sh=ll.hasOwnProperty,ul=Object.prototype,Th=ul.hasOwnProperty,kh=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ah=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Ch=new RegExp(/[A-Fa-f0-9]{2}/,"g");function cl(t){return t!==void 0}var dl=cl;function pl(t,e){let{cesdk:r}=e;if(r==null)return{};let i=e.propertyKey??"style",n=hl(t);r.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${t}.${i}`]:"Style"}});let o=ml({baseURL:e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0}),s=o;e.styles!=null&&(Array.isArray(e.styles)?s=e.styles:typeof e.styles=="function"&&(s=e.styles(o)));let a=yl({cesdk:r,providerId:t,styles:s}),c=a.id;return bl(a,{cesdk:r}),fl({providerId:t,cesdk:r,panelId:n,entryId:c}),{[e.propertyKeyForPrompt??"prompt"]:(u,l)=>{let d=u.state("prompt","");return u.builder.TextArea(`${l.id}`,{inputLabel:e.i18n?.prompt?.inputLabel??e.propertyKeyForPrompt??"prompt",placeholder:e.i18n?.prompt?.placeholder,...d}),()=>{let[h]=a.getActiveAssetIds(),p=a.getAsset(h);return{id:l.id,type:"string",value:p?.meta?.prompt==null?d.value:`${d.value}; ${p.meta.prompt}`}}},[i]:(u,l)=>{let{builder:d,state:h}=u;if(s.length>0){let p=h("style",s[0]);return d.Button(`${l.id}`,{inputLabel:`${t}.${l.id}`,icon:"@imgly/Appearance",isDisabled:s.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let g={onSelect:async b=>{a.clearActiveAssets(),a.setAssetActive(b.id),p.setValue({id:b.id,label:b.label??b.id}),r.ui.closePanel(n)}};r.ui.openPanel(n,{payload:g})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function fl(t){let{providerId:e,cesdk:r,panelId:i,entryId:n}=t;r?.ui.registerPanel(i,({builder:o,payload:s})=>{s?.onSelect==null&&o.Section(`${e}.error`,{children:()=>{o.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),o.Library(`${e}.library.image`,{entries:[n],onSelect:async a=>{s?.onSelect?.(a)}})})}function hl(t){return`ly.img.ai.${t}.styleSelection`}var gl=[{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 ml(t){return gl.map(e=>e.id==="none"?t.includeNone?{...e,thumbUri:`${t.baseURL}/thumbnails/None.svg`}:void 0:{...e,thumbUri:`${t.baseURL}/thumbnails/${e.id}.jpeg`}).filter(dl)}var yl=t=>{let e=t.styles.map(s=>({...s,meta:{prompt:s.prompt}})),r=t.cesdk.engine.asset.findAllSources(),i=`${t.providerId}/styles`;for(;r.includes(i);)i+=`-${Math.random().toString(36).substring(2,5)}`;let n=new fo(i,e),o=t.styles[0];return n.setAssetActive(o.id),n},bl=(t,e)=>{e.cesdk.engine.asset.addSource(t),e.cesdk.ui.addAssetLibraryEntry({id:t.id,sourceIds:[t.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:r})=>r,cardLabelPosition:()=>"below"})},vl=pl;var wl="ly.img.ai";function O(t){return`${wl}.${t}`}function Kr(t,e){let r={...t};if(!e)return r;for(let[i,n]of Object.entries(e))n===!1||n===null||n===void 0?delete r[i]:n===!0?i in t||(r[i]=!0):r[i]=n;return r}var Et="@imgly/plugin-ai-generation",Mh=`
5
+ `;else if(w==="event")s=x;else if(w==="id"&&!x.includes("\0"))o=x;else if(w==="retry"){let A=parseInt(x,10);Number.isNaN(A)||t({type:"reconnect-interval",value:A})}}}var oi=[239,187,191];function Jl(t){return oi.every((e,r)=>t.charCodeAt(r)===e)}Ut.createParser=Xl});var Lt=_(Y=>{"use strict";var eu=Y&&Y.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Y,"__esModule",{value:!0});Y.TOKEN_EXPIRATION_SECONDS=void 0;Y.getTemporaryAuthToken=nu;var tu=Ze(),ru=pe(),iu=H();Y.TOKEN_EXPIRATION_SECONDS=120;function nu(t,e){return eu(this,void 0,void 0,function*(){let r=(0,iu.parseEndpointId)(t),i=yield(0,ru.dispatchRequest)({method:"POST",targetUrl:`${(0,tu.getRestApiUrl)()}/tokens/`,config:e,input:{allowed_apps:[r.alias],token_expiration:Y.TOKEN_EXPIRATION_SECONDS}});return typeof i!="string"&&i.detail?i.detail:i})}});var Rt=_(U=>{"use strict";var he=U&&U.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})},Ce=U&&U.__await||function(t){return this instanceof Ce?(this.v=t,this):new Ce(t)},ou=U&&U.__asyncGenerator||function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,o=[];return n={},a("next"),a("throw"),a("return",s),n[Symbol.asyncIterator]=function(){return this},n;function s(p){return function(g){return Promise.resolve(g).then(p,d)}}function a(p,g){i[p]&&(n[p]=function(b){return new Promise(function(w,f){o.push([p,b,w,f])>1||c(p,b)})},g&&(n[p]=g(n[p])))}function c(p,g){try{u(i[p](g))}catch(b){h(o[0][3],b)}}function u(p){p.value instanceof Ce?Promise.resolve(p.value.v).then(l,d):h(o[0][2],p)}function l(p){c("next",p)}function d(p){c("throw",p)}function h(p,g){p(g),o.shift(),o.length&&c(o[0][0],o[0][1])}};Object.defineProperty(U,"__esModule",{value:!0});U.FalStream=void 0;U.createStreamingClient=uu;var su=si(),au=Lt(),ai=pe(),fe=K(),$t="text/event-stream",lu=15*1e3,Xe=class{constructor(e,r,i){var n;this.listeners=new Map,this.buffer=[],this.currentData=void 0,this.lastEventTimestamp=0,this.streamClosed=!1,this._requestId=null,this.abortController=new AbortController,this.start=()=>he(this,void 0,void 0,function*(){var o,s;let{endpointId:a,options:c}=this,{input:u,method:l="post",connectionMode:d="server"}=c;try{if(d==="client"){let h=yield(0,au.getTemporaryAuthToken)(a,this.config),{fetch:p}=this.config,g=new URL(this.url);g.searchParams.set("fal_jwt_token",h);let b=yield p(g.toString(),{method:l.toUpperCase(),headers:{accept:(o=c.accept)!==null&&o!==void 0?o:$t,"content-type":"application/json"},body:u&&l!=="get"?JSON.stringify(u):void 0,signal:this.abortController.signal});return this._requestId=b.headers.get("x-fal-request-id"),yield this.handleResponse(b)}return yield(0,ai.dispatchRequest)({method:l.toUpperCase(),targetUrl:this.url,input:u,config:this.config,options:{headers:{accept:(s=c.accept)!==null&&s!==void 0?s:$t},responseHandler:h=>he(this,void 0,void 0,function*(){return this._requestId=h.headers.get("x-fal-request-id"),yield this.handleResponse(h)}),signal:this.abortController.signal}})}catch(h){this.handleError(h)}}),this.handleResponse=o=>he(this,void 0,void 0,function*(){var s,a;if(!o.ok){try{yield(0,fe.defaultResponseHandler)(o)}catch(b){this.emit("error",b)}return}let c=o.body;if(!c){this.emit("error",new fe.ApiError({message:"Response body is empty.",status:400,body:void 0}));return}if(!((s=o.headers.get("content-type"))!==null&&s!==void 0?s:"").startsWith($t)){let b=c.getReader(),w=()=>{b.read().then(({done:f,value:m})=>{if(f){this.emit("done",this.currentData);return}this.currentData=m,this.emit("data",m),w()})};w();return}let l=new TextDecoder("utf-8"),d=o.body.getReader(),h=(0,su.createParser)(b=>{if(b.type==="event"){let w=b.data;try{let f=JSON.parse(w);this.buffer.push(f),this.currentData=f,this.emit("data",f),this.emit("message",f)}catch(f){this.emit("error",f)}}}),p=(a=this.options.timeout)!==null&&a!==void 0?a:lu,g=()=>he(this,void 0,void 0,function*(){let{value:b,done:w}=yield d.read();this.lastEventTimestamp=Date.now(),h.feed(l.decode(b)),Date.now()-this.lastEventTimestamp>p&&this.emit("error",new fe.ApiError({message:`Event stream timed out after ${(p/1e3).toFixed(0)} seconds with no messages.`,status:408})),w?this.emit("done",this.currentData):g().catch(this.handleError)});g().catch(this.handleError)}),this.handleError=o=>{var s;if(o.name==="AbortError"||this.signal.aborted)return;let a=o instanceof fe.ApiError?o:new fe.ApiError({message:(s=o.message)!==null&&s!==void 0?s:"An unknown error occurred",status:500});this.emit("error",a)},this.on=(o,s)=>{var a;this.listeners.has(o)||this.listeners.set(o,[]),(a=this.listeners.get(o))===null||a===void 0||a.push(s)},this.emit=(o,s)=>{let a=this.listeners.get(o)||[];for(let c of a)c(s)},this.done=()=>he(this,void 0,void 0,function*(){return this.donePromise}),this.abort=o=>{this.streamClosed||this.abortController.abort(o)},this.endpointId=e,this.config=r,this.url=(n=i.url)!==null&&n!==void 0?n:(0,ai.buildUrl)(e,{path:"/stream",query:i.queryParams}),this.options=i,this.donePromise=new Promise((o,s)=>{this.streamClosed&&s(new fe.ApiError({message:"Streaming connection is already closed.",status:400,body:void 0})),this.signal.addEventListener("abort",()=>{var a;o((a=this.currentData)!==null&&a!==void 0?a:{})}),this.on("done",a=>{this.streamClosed=!0,o(a)}),this.on("error",a=>{this.streamClosed=!0,s(a)})}),i.signal&&i.signal.addEventListener("abort",()=>{this.abortController.abort()}),this.start().catch(this.handleError)}[Symbol.asyncIterator](){return ou(this,arguments,function*(){let r=!0,i=()=>r=!1;for(this.on("error",i),this.on("done",i);r||this.buffer.length>0;){let n=this.buffer.shift();n&&(yield yield Ce(n)),yield Ce(new Promise(o=>setTimeout(o,16)))}})}get signal(){return this.abortController.signal}get requestId(){return this._requestId}};U.FalStream=Xe;function uu({config:t,storage:e}){return{stream(r,i){return he(this,void 0,void 0,function*(){let n=i.input?yield e.transformInput(i.input):void 0;return new Xe(r,t,Object.assign(Object.assign({},i),{input:n}))})}}}});var di=_(W=>{"use strict";var ee=W&&W.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})},cu=W&&W.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r};Object.defineProperty(W,"__esModule",{value:!0});W.createQueueClient=void 0;var V=pe(),du=K(),ci=Ae(),pu=Rt(),Je=H(),li=500,ui={maxRetries:3,baseDelay:1e3,maxDelay:6e4,retryableStatusCodes:ci.DEFAULT_RETRYABLE_STATUS_CODES},fu={maxRetries:5,baseDelay:1e3,maxDelay:3e4,retryableStatusCodes:[...ci.DEFAULT_RETRYABLE_STATUS_CODES,500]},hu=({config:t,storage:e})=>{let r={submit(i,n){return ee(this,void 0,void 0,function*(){let{webhookUrl:o,priority:s,hint:a}=n,c=cu(n,["webhookUrl","priority","hint"]),u=n.input?yield e.transformInput(n.input):void 0;return(0,V.dispatchRequest)({method:n.method,targetUrl:(0,V.buildUrl)(i,Object.assign(Object.assign({},c),{subdomain:"queue",query:o?{fal_webhook:o}:void 0})),headers:Object.assign({"x-fal-queue-priority":s??"normal"},a&&{"x-fal-runner-hint":a}),input:u,config:t,options:{signal:n.abortSignal,retry:ui}})})},status(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,abortSignal:c}){let u=(0,Je.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"";return(0,V.dispatchRequest)({method:"get",targetUrl:(0,V.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",query:{logs:a?"1":"0"},path:`/requests/${s}/status`}),config:t,options:{signal:c,retry:fu}})})},streamStatus(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,logs:a=!1,connectionMode:c}){let u=(0,Je.parseEndpointId)(o),l=u.namespace?`${u.namespace}/`:"",d={logs:a?"1":"0"},h=(0,V.buildUrl)(`${l}${u.owner}/${u.alias}`,{subdomain:"queue",path:`/requests/${s}/status/stream`,query:d});return new pu.FalStream(o,t,{url:h,method:"get",connectionMode:c,queryParams:d})})},subscribeToStatus(i,n){return ee(this,void 0,void 0,function*(){let o=n.requestId,s=n.timeout,a,c=()=>{};if(n.mode==="streaming"){let u=yield r.streamStatus(i,{requestId:o,logs:n.logs,connectionMode:"connectionMode"in n?n.connectionMode:void 0}),l=[];s&&(a=setTimeout(()=>{throw u.abort(),r.cancel(i,{requestId:o}).catch(c),new Error(`Client timed out waiting for the request to complete after ${s}ms`)},s)),u.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 d=yield u.done();return a&&clearTimeout(a),d}return new Promise((u,l)=>{var d;let h,p="pollInterval"in n&&typeof n.pollInterval=="number"&&(d=n.pollInterval)!==null&&d!==void 0?d:li,g=()=>{a&&clearTimeout(a),h&&clearTimeout(h)};s&&(a=setTimeout(()=>{g(),r.cancel(i,{requestId:o}).catch(c),l(new Error(`Client timed out waiting for the request to complete after ${s}ms`))},s));let b=()=>ee(this,void 0,void 0,function*(){var w;try{let f=yield r.status(i,{requestId:o,logs:(w=n.logs)!==null&&w!==void 0?w:!1,abortSignal:n.abortSignal});if(n.onQueueUpdate&&n.onQueueUpdate(f),f.status==="COMPLETED"){g(),u(f);return}h=setTimeout(b,p)}catch(f){g(),l(f)}});b().catch(l)})})},result(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let c=(0,Je.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";return(0,V.dispatchRequest)({method:"get",targetUrl:(0,V.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${s}`}),config:Object.assign(Object.assign({},t),{responseHandler:du.resultResponseHandler}),options:{signal:a,retry:ui}})})},cancel(i,n){return ee(this,arguments,void 0,function*(o,{requestId:s,abortSignal:a}){let c=(0,Je.parseEndpointId)(o),u=c.namespace?`${c.namespace}/`:"";yield(0,V.dispatchRequest)({method:"put",targetUrl:(0,V.buildUrl)(`${u}${c.owner}/${c.alias}`,{subdomain:"queue",path:`/requests/${s}/cancel`}),config:t,options:{signal:a}})})}};return r};W.createQueueClient=hu});var et=_(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.utf8Count=gu;N.utf8EncodeJs=pi;N.utf8EncodeTE=fi;N.utf8Encode=bu;N.utf8DecodeJs=hi;N.utf8DecodeTD=gi;N.utf8Decode=_u;function gu(t){let e=t.length,r=0,i=0;for(;i<e;){let n=t.charCodeAt(i++);if(n&4294967168)if(!(n&4294965248))r+=2;else{if(n>=55296&&n<=56319&&i<e){let o=t.charCodeAt(i);(o&64512)===56320&&(++i,n=((n&1023)<<10)+(o&1023)+65536)}n&4294901760?r+=4:r+=3}else{r++;continue}}return r}function pi(t,e,r){let i=t.length,n=r,o=0;for(;o<i;){let s=t.charCodeAt(o++);if(s&4294967168)if(!(s&4294965248))e[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<i){let a=t.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}s&4294901760?(e[n++]=s>>18&7|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128):(e[n++]=s>>12&15|224,e[n++]=s>>6&63|128)}else{e[n++]=s;continue}e[n++]=s&63|128}}var mu=new TextEncoder,yu=50;function fi(t,e,r){mu.encodeInto(t,e.subarray(r))}function bu(t,e,r){t.length>yu?fi(t,e,r):pi(t,e,r)}var vu=4096;function hi(t,e,r){let i=e,n=i+r,o=[],s="";for(;i<n;){let a=t[i++];if(!(a&128))o.push(a);else if((a&224)===192){let c=t[i++]&63;o.push((a&31)<<6|c)}else if((a&240)===224){let c=t[i++]&63,u=t[i++]&63;o.push((a&31)<<12|c<<6|u)}else if((a&248)===240){let c=t[i++]&63,u=t[i++]&63,l=t[i++]&63,d=(a&7)<<18|c<<12|u<<6|l;d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d)}else o.push(a);o.length>=vu&&(s+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(s+=String.fromCharCode(...o)),s}var wu=new TextDecoder,xu=200;function gi(t,e,r){let i=t.subarray(e,e+r);return wu.decode(i)}function _u(t,e,r){return r>xu?gi(t,e,r):hi(t,e,r)}});var Vt=_(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.ExtData=void 0;var qt=class{constructor(e,r){this.type=e,this.data=r}};tt.ExtData=qt});var it=_(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.DecodeError=void 0;var Nt=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};rt.DecodeError=Nt});var nt=_(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.UINT32_MAX=void 0;Z.setUint64=Iu;Z.setInt64=Eu;Z.getInt64=Su;Z.getUint64=ku;Z.UINT32_MAX=4294967295;function Iu(t,e,r){let i=r/4294967296,n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Eu(t,e,r){let i=Math.floor(r/4294967296),n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function Su(t,e){let r=t.getInt32(e),i=t.getUint32(e+4);return r*4294967296+i}function ku(t,e){let r=t.getUint32(e),i=t.getUint32(e+4);return r*4294967296+i}});var Ft=_(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.timestampExtension=M.EXT_TIMESTAMP=void 0;M.encodeTimeSpecToTimestamp=yi;M.encodeDateToTimeSpec=bi;M.encodeTimestampExtension=vi;M.decodeTimestampToTimeSpec=wi;M.decodeTimestampExtension=xi;var Tu=it(),mi=nt();M.EXT_TIMESTAMP=-1;var Au=4294967296-1,Cu=17179869184-1;function yi({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Cu)if(e===0&&t<=Au){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,i=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,e<<2|r&3),o.setUint32(4,i),n}else{let r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,e),(0,mi.setInt64)(i,4,t),r}}function bi(t){let e=t.getTime(),r=Math.floor(e/1e3),i=(e-r*1e3)*1e6,n=Math.floor(i/1e9);return{sec:r+n,nsec:i-n*1e9}}function vi(t){if(t instanceof Date){let e=bi(t);return yi(e)}else return null}function wi(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),i=e.getUint32(4),n=(r&3)*4294967296+i,o=r>>>2;return{sec:n,nsec:o}}case 12:{let r=(0,mi.getInt64)(e,4),i=e.getUint32(0);return{sec:r,nsec:i}}default:throw new Tu.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function xi(t){let e=wi(t);return new Date(e.sec*1e3+e.nsec/1e6)}M.timestampExtension={type:M.EXT_TIMESTAMP,encode:vi,decode:xi}});var at=_(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.ExtensionCodec=void 0;var ot=Vt(),Mu=Ft(),Me=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Mu.timestampExtension)}register({type:e,encode:r,decode:i}){if(e>=0)this.encoders[e]=r,this.decoders[e]=i;else{let n=-1-e;this.builtInEncoders[n]=r,this.builtInDecoders[n]=i}}tryToEncode(e,r){for(let i=0;i<this.builtInEncoders.length;i++){let n=this.builtInEncoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=-1-i;return new ot.ExtData(s,o)}}}for(let i=0;i<this.encoders.length;i++){let n=this.encoders[i];if(n!=null){let o=n(e,r);if(o!=null){let s=i;return new ot.ExtData(s,o)}}}return e instanceof ot.ExtData?e:null}decode(e,r,i){let n=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return n?n(e,r,i):new ot.ExtData(r,e)}};st.ExtensionCodec=Me;Me.defaultCodec=new Me});var Bt=_(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.ensureUint8Array=ju;function Pu(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function ju(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Pu(t)?new Uint8Array(t):Uint8Array.from(t)}});var Ht=_(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.Encoder=R.DEFAULT_INITIAL_BUFFER_SIZE=R.DEFAULT_MAX_DEPTH=void 0;var _i=et(),Ou=at(),Ii=nt(),Du=Bt();R.DEFAULT_MAX_DEPTH=100;R.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Kt=class t{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??Ou.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??R.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??R.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({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(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),i=new Uint8Array(r),n=new DataView(r);i.set(this.bytes),this.view=n,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let i=(0,_i.utf8Count)(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),(0,_i.utf8Encode)(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,r){let i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let i=(0,Du.ensureUint8Array)(e);this.writeU8a(i)}encodeArray(e,r){let i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(let n of e)this.doEncode(n,r+1)}countWithoutUndefined(e,r){let i=0;for(let n of r)e[n]!==void 0&&i++;return i}encodeMap(e,r){let i=Object.keys(e);this.sortKeys&&i.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.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 i){let s=e[o];this.ignoreUndefined&&s===void 0||(this.encodeString(o),this.doEncode(s,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let i=e.data(this.pos+6),n=i.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(i);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Ii.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Ii.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};R.Encoder=Kt});var Ei=_(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.encode=Lu;var Uu=Ht();function Lu(t,e){return new Uu.Encoder(e).encodeSharedRef(t)}});var Si=_(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.prettyByte=$u;function $u(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}});var ki=_(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.CachedKeyDecoder=void 0;var Ru=et(),qu=16,Vu=16,Yt=class{constructor(e=qu,r=Vu){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,i){let n=this.caches[i-1];e:for(let o of n){let s=o.bytes;for(let a=0;a<i;a++)if(s[a]!==e[r+a])continue e;return o.str}return null}store(e,r){let i=this.caches[e.length-1],n={bytes:e,str:r};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=n:i.push(n)}decode(e,r,i){let n=this.find(e,r,i);if(n!=null)return this.hit++,n;this.miss++;let o=(0,Ru.utf8DecodeJs)(e,r,i),s=Uint8Array.prototype.slice.call(e,r,r+i);return this.store(s,o),o}};lt.CachedKeyDecoder=Yt});var ct=_(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.Decoder=void 0;var Wt=Si(),Nu=at(),te=nt(),Fu=et(),Ti=Bt(),zu=ki(),F=it(),Zt="array",je="map_key",Ci="map_value",Bu=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new F.DecodeError("The type of key must be string or number but "+typeof t)},Xt=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=Zt,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=je,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Zt){let i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===je||e.type===Ci){let i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Pe=-1,er=new DataView(new ArrayBuffer(0)),Ku=new Uint8Array(er.buffer);try{er.getInt8(0)}catch(t){if(!(t 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 Ai=new RangeError("Insufficient data"),Hu=new zu.CachedKeyDecoder,Jt=class t{constructor(e){this.totalPos=0,this.pos=0,this.view=er,this.bytes=Ku,this.headByte=Pe,this.stack=new Xt,this.entered=!1,this.extensionCodec=e?.extensionCodec??Nu.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??te.UINT32_MAX,this.maxBinLength=e?.maxBinLength??te.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??te.UINT32_MAX,this.maxMapLength=e?.maxMapLength??te.UINT32_MAX,this.maxExtLength=e?.maxExtLength??te.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Hu,this.mapKeyConverter=e?.mapKeyConverter??Bu}clone(){return new t({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(e){let r=(0,Ti.ensureUint8Array)(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Pe&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),i=(0,Ti.ensureUint8Array)(e),n=new Uint8Array(r.length+i.length);n.set(r),n.set(i,r.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:i}=this;return new RangeError(`Extra ${r.byteLength-i} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,i;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),r=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}let{headByte:n,pos:o,totalPos:s}=this;throw new RangeError(`Insufficient data in parsing ${(0,Wt.prettyByte)(n)} at ${s} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let i=r,n=-1;for await(let o of e){if(r&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),i&&(n=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(s){if(!(s instanceof RangeError))throw s}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{let n=e-160;r=this.decodeString(n,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let n=this.lookU8();r=this.decodeString(n,1)}else if(e===218){let n=this.lookU16();r=this.decodeString(n,2)}else if(e===219){let n=this.lookU32();r=this.decodeString(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===196){let n=this.lookU8();r=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();r=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();r=this.decodeBinary(n,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();r=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();r=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();r=this.decodeExtension(n,4)}else throw new F.DecodeError(`Unrecognized type byte: ${(0,Wt.prettyByte)(e)}`);this.complete();let i=this.stack;for(;i.length>0;){let n=i.top();if(n.type===Zt)if(n.array[n.position]=r,n.position++,n.position===n.size)r=n.array,i.release(n);else continue e;else if(n.type===je){if(r==="__proto__")throw new F.DecodeError("The key __proto__ is not allowed");n.key=this.mapKeyConverter(r),n.type=Ci;continue e}else if(n.map[n.key]=r,n.readCount++,n.readCount===n.size)r=n.map,i.release(n);else{n.key=null,n.type=je;continue e}}return r}}readHeadByte(){return this.headByte===Pe&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Pe}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new F.DecodeError(`Unrecognized array type byte: ${(0,Wt.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new F.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new F.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new F.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Ai;let i=this.pos+r,n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,i,e):n=(0,Fu.utf8Decode)(this.bytes,i,e),this.pos+=r+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===je:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new F.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Ai;let i=this.pos+r,n=this.bytes.subarray(i,i+e);return this.pos+=r+e,n}decodeExtension(e,r){if(e>this.maxExtLength)throw new F.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let i=this.view.getInt8(this.pos+r),n=this.decodeBinary(e,r+1);return this.extensionCodec.decode(n,i,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 e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,te.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,te.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};ut.Decoder=Jt});var Pi=_(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.decode=Gu;dt.decodeMulti=Qu;var Mi=ct();function Gu(t,e){return new Mi.Decoder(e).decode(t)}function Qu(t,e){return new Mi.Decoder(e).decodeMulti(t)}});var Di=_(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.isAsyncIterable=ji;Oe.asyncIterableFromStream=Oi;Oe.ensureAsyncIterable=Yu;function ji(t){return t[Symbol.asyncIterator]!=null}async function*Oi(t){let e=t.getReader();try{for(;;){let{done:r,value:i}=await e.read();if(r)return;yield i}}finally{e.releaseLock()}}function Yu(t){return ji(t)?t:Oi(t)}});var Ui=_(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.decodeAsync=Wu;De.decodeArrayStream=Zu;De.decodeMultiStream=Xu;var tr=ct(),rr=Di();async function Wu(t,e){let r=(0,rr.ensureAsyncIterable)(t);return new tr.Decoder(e).decodeAsync(r)}function Zu(t,e){let r=(0,rr.ensureAsyncIterable)(t);return new tr.Decoder(e).decodeArrayStream(r)}function Xu(t,e){let r=(0,rr.ensureAsyncIterable)(t);return new tr.Decoder(e).decodeStream(r)}});var $i=_(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.decodeTimestampExtension=v.encodeTimestampExtension=v.decodeTimestampToTimeSpec=v.encodeTimeSpecToTimestamp=v.encodeDateToTimeSpec=v.EXT_TIMESTAMP=v.ExtData=v.ExtensionCodec=v.Encoder=v.DecodeError=v.Decoder=v.decodeMultiStream=v.decodeArrayStream=v.decodeAsync=v.decodeMulti=v.decode=v.encode=void 0;var Ju=Ei();Object.defineProperty(v,"encode",{enumerable:!0,get:function(){return Ju.encode}});var Li=Pi();Object.defineProperty(v,"decode",{enumerable:!0,get:function(){return Li.decode}});Object.defineProperty(v,"decodeMulti",{enumerable:!0,get:function(){return Li.decodeMulti}});var ir=Ui();Object.defineProperty(v,"decodeAsync",{enumerable:!0,get:function(){return ir.decodeAsync}});Object.defineProperty(v,"decodeArrayStream",{enumerable:!0,get:function(){return ir.decodeArrayStream}});Object.defineProperty(v,"decodeMultiStream",{enumerable:!0,get:function(){return ir.decodeMultiStream}});var ec=ct();Object.defineProperty(v,"Decoder",{enumerable:!0,get:function(){return ec.Decoder}});var tc=it();Object.defineProperty(v,"DecodeError",{enumerable:!0,get:function(){return tc.DecodeError}});var rc=Ht();Object.defineProperty(v,"Encoder",{enumerable:!0,get:function(){return rc.Encoder}});var ic=at();Object.defineProperty(v,"ExtensionCodec",{enumerable:!0,get:function(){return ic.ExtensionCodec}});var nc=Vt();Object.defineProperty(v,"ExtData",{enumerable:!0,get:function(){return nc.ExtData}});var ge=Ft();Object.defineProperty(v,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return ge.EXT_TIMESTAMP}});Object.defineProperty(v,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return ge.encodeDateToTimeSpec}});Object.defineProperty(v,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return ge.encodeTimeSpecToTimestamp}});Object.defineProperty(v,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return ge.decodeTimestampToTimeSpec}});Object.defineProperty(v,"encodeTimestampExtension",{enumerable:!0,get:function(){return ge.encodeTimestampExtension}});Object.defineProperty(v,"decodeTimestampExtension",{enumerable:!0,get:function(){return ge.decodeTimestampExtension}})});var Xi=_(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});function T(t){return{enumerable:!0,value:t}}function Ri(t){return{enumerable:!0,writable:!0,value:t}}var re={},oc=()=>!0,qi=()=>({}),Ni=t=>t,sc=(t,e,r,i)=>t.apply(r,i)&&e.apply(r,i),ac=(t,e,r,[i,n])=>e.call(r,t.call(r,i,n),n),X=(t,e)=>Object.freeze(Object.create(t,e));function Vi(t,e,r){return t.reduce((i,n)=>function(...o){return r(i,n,this,o)},e)}function Fi(t){return X(this,{fn:T(t)})}var zi={},Bi=Fi.bind(zi),lc=t=>Bi((e,r)=>!!~t(e,r)&&e),Ki={},uc=Fi.bind(Ki);function pt(t,e){return e.filter(r=>t.isPrototypeOf(r))}function Hi(t,e,...r){let i=Vi(pt(Ki,r).map(o=>o.fn),oc,sc),n=Vi(pt(zi,r).map(o=>o.fn),Ni,ac);return X(this,{from:T(t),to:T(e),guards:T(i),reducers:T(n)})}var Gi={},Qi={},cc=Hi.bind(Gi),dc=Hi.bind(Qi,null);function pc(t,e,r){return or(e,t,r,this.immediates)||t}function Yi(t){let e=new Map;for(let r of t)e.has(r.from)||e.set(r.from,[]),e.get(r.from).push(r);return e}var fc={enter:Ni};function hc(...t){let e=pt(Gi,t),r=pt(Qi,t),i={final:T(t.length===0),transitions:T(Yi(e))};return r.length&&(i.immediates=T(r),i.enter=T(pc)),X(fc,i)}var gc={enter(t,e,r){let i=this.fn.call(e,e.context,r);return nr.isPrototypeOf(i)?X(Wi,{machine:T(i),transitions:T(this.transitions)}).enter(t,e,r):(i.then(n=>e.send({type:"done",data:n})).catch(n=>e.send({type:"error",error:n})),t)}},Wi={enter(t,e,r){if(e.child=Zi(this.machine,i=>{e.onChange(i),e.child==i&&i.machine.state.value.final&&(delete e.child,e.send({type:"done",data:i.context}))},e.context,r),e.child.machine.state.value.final){let i=e.child.context;return delete e.child,or(e,t,{type:"done",data:i},this.transitions.get("done"))}return t}};function mc(t,...e){let r=T(Yi(e));return nr.isPrototypeOf(t)?X(Wi,{machine:T(t),transitions:r}):X(gc,{fn:T(t),transitions:r})}var nr={get state(){return{name:this.current,value:this.states[this.current]}}};function yc(t,e,r=qi){return typeof t!="string"&&(r=e||qi,e=t,t=Object.keys(e)[0]),re._create&&re._create(t,e),X(nr,{context:T(r),current:T(t),states:T(e)})}function or(t,e,r,i){let{context:n}=t;for(let{to:o,guards:s,reducers:a}of i)if(s(n,r)){t.context=a.call(t,n,r);let c=e.original||e,u=X(c,{current:T(o),original:{value:c}});return re._onEnter&&re._onEnter(e,o,t.context,n,r),u.state.value.enter(u,t,r)}}function bc(t,e){let r=e.type||e,{machine:i}=t,{value:n,name:o}=i.state;return n.transitions.has(r)?or(t,i,e,n.transitions.get(r))||i:(re._send&&re._send(r,o),i)}var vc={send(t){this.machine=bc(this,t),this.onChange(this)}};function Zi(t,e,r,i){let n=Object.create(vc,{machine:Ri(t),context:Ri(t.context(r,i)),onChange:T(e)});return n.send=n.send.bind(n),n.machine=n.machine.state.value.enter(n.machine,n,i),n}P.action=lc;P.createMachine=yc;P.d=re;P.guard=uc;P.immediate=dc;P.interpret=Zi;P.invoke=mc;P.reduce=Bi;P.state=hc;P.transition=cc});var nn=_(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.createRealtimeClient=Dc;var ht=$i(),y=Xi(),Ji=Lt(),sr=K(),en=We(),ur=H(),wc=()=>({enqueuedMessage:void 0});function xc(t){return t.token!==void 0}function _c(t){return!xc(t)}function ft(t,e){return Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function z(t){return t.websocket&&t.websocket.readyState===WebSocket.OPEN&&t.websocket.close(),Object.assign(Object.assign({},t),{websocket:void 0})}function Ic(t,e){return t.websocket&&t.websocket.readyState===WebSocket.OPEN?(e.message instanceof Uint8Array?t.websocket.send(e.message):t.websocket.send((0,ht.encode)(e.message)),Object.assign(Object.assign({},t),{enqueuedMessage:void 0})):Object.assign(Object.assign({},t),{enqueuedMessage:e.message})}function ar(t){return Object.assign(Object.assign({},t),{token:void 0})}function Ec(t,e){return Object.assign(Object.assign({},t),{token:e.token})}function Sc(t,e){return Object.assign(Object.assign({},t),{websocket:e.websocket})}var kc=(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)(ar)),(0,y.transition)("close","idle",(0,y.reduce)(z))),connecting:(0,y.state)((0,y.transition)("connecting","connecting"),(0,y.transition)("connected","active",(0,y.reduce)(Sc)),(0,y.transition)("connectionClosed","idle",(0,y.reduce)(z)),(0,y.transition)("send","connecting",(0,y.reduce)(ft)),(0,y.transition)("close","idle",(0,y.reduce)(z)),(0,y.immediate)("authRequired",(0,y.guard)(_c))),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)(z))),authInProgress:(0,y.state)((0,y.transition)("authenticated","connecting",(0,y.reduce)(Ec)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(ar),(0,y.reduce)(z)),(0,y.transition)("send","authInProgress",(0,y.reduce)(ft)),(0,y.transition)("close","idle",(0,y.reduce)(z))),active:(0,y.state)((0,y.transition)("send","active",(0,y.reduce)(Ic)),(0,y.transition)("unauthorized","idle",(0,y.reduce)(ar)),(0,y.transition)("connectionClosed","idle",(0,y.reduce)(z)),(0,y.transition)("close","idle",(0,y.reduce)(z))),failed:(0,y.state)((0,y.transition)("send","failed"),(0,y.transition)("close","idle",(0,y.reduce)(z)))},wc);function Tc(t,{token:e,maxBuffering:r}){if(r!==void 0&&(r<1||r>60))throw new Error("The `maxBuffering` must be between 1 and 60 (inclusive)");let i=new URLSearchParams({fal_jwt_token:e});return r!==void 0&&i.set("max_buffering",r.toFixed(0)),`wss://fal.run/${(0,ur.ensureEndpointIdFormat)(t)}/realtime?${i.toString()}`}var Ac=128;function Cc(t){return t.status==="error"&&t.error==="Unauthorized"}var Mc={NORMAL_CLOSURE:1e3,GOING_AWAY:1001},lr=new Map,tn=new Map;function Pc(t,e,r){if(!lr.has(t)){let i=(0,y.interpret)(kc,r);lr.set(t,Object.assign(Object.assign({},i),{throttledSend:e>0?(0,ur.throttle)(i.send,e,!0):i.send}))}return lr.get(t)}var Ue=()=>{},jc={send:Ue,close:Ue};function Oc(t){return t.status!=="error"&&t.type!=="x-fal-message"&&!rn(t)}function rn(t){return t.type==="x-fal-error"}function Dc({config:t}){return{connect(e,r){let{clientOnly:i=(0,ur.isReact)()&&!(0,en.isBrowser)(),connectionKey:n=crypto.randomUUID(),maxBuffering:o,throttleInterval:s=Ac}=r;if(i&&!(0,en.isBrowser)())return jc;let a;tn.set(n,{onError:r.onError,onResult:r.onResult});let c=()=>tn.get(n),u=Pc(n,s,({context:h,machine:p,send:g})=>{let{enqueuedMessage:b,token:w}=h;if(p.current==="active"&&b&&g({type:"send",message:b}),p.current==="authRequired"&&w===void 0&&a!==p.current&&(g({type:"initiateAuth"}),(0,Ji.getTemporaryAuthToken)(e,t).then(f=>{g({type:"authenticated",token:f});let m=Math.round(Ji.TOKEN_EXPIRATION_SECONDS*.9*1e3);setTimeout(()=>{g({type:"expireToken"})},m)}).catch(f=>{g({type:"unauthorized",error:f})})),p.current==="connecting"&&a!==p.current&&w!==void 0){let f=new WebSocket(Tc(e,{token:w,maxBuffering:o}));f.onopen=()=>{g({type:"connected",websocket:f})},f.onclose=m=>{if(m.code!==Mc.NORMAL_CLOSURE){let{onError:I=Ue}=c();I(new sr.ApiError({message:`Error closing the connection: ${m.reason}`,status:m.code}))}g({type:"connectionClosed",code:m.code})},f.onerror=m=>{let{onError:I=Ue}=c();I(new sr.ApiError({message:"Unknown error",status:500}))},f.onmessage=m=>{let{onResult:I}=c();if(m.data instanceof ArrayBuffer){let A=(0,ht.decode)(new Uint8Array(m.data));I(A);return}if(m.data instanceof Uint8Array){let A=(0,ht.decode)(m.data);I(A);return}if(m.data instanceof Blob){m.data.arrayBuffer().then(A=>{let wt=(0,ht.decode)(new Uint8Array(A));I(wt)});return}let x=JSON.parse(m.data);if(Cc(x)){g({type:"unauthorized",error:new Error("Unauthorized")});return}if(Oc(x)){I(x);return}if(rn(x)){if(x.error==="TIMEOUT")return;let{onError:A=Ue}=c();A(new sr.ApiError({message:`${x.error}: ${x.reason}`,status:400,body:x}));return}}}a=p.current});return{send:h=>{u.throttledSend({type:"send",message:h})},close:()=>{u.send({type:"close"})}}}}}});var un=_(Le=>{"use strict";var ie=Le&&Le.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(Le,"__esModule",{value:!0});Le.createStorageClient=qc;var on=Ze(),sn=pe(),Uc=H();function an(t){var e;let[r,i]=t.split("/");return(e=i.split(/[-;]/)[0])!==null&&e!==void 0?e:"bin"}function Lc(t,e,r){return ie(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${an(r)}`;return yield(0,sn.dispatchRequest)({method:"POST",targetUrl:`${(0,on.getRestApiUrl)()}/storage/upload/initiate?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function $c(t,e,r){return ie(this,void 0,void 0,function*(){let i=t.name||`${Date.now()}.${an(r)}`;return yield(0,sn.dispatchRequest)({method:"POST",targetUrl:`${(0,on.getRestApiUrl)()}/storage/upload/initiate-multipart?storage_type=fal-cdn-v3`,input:{content_type:r,file_name:i},config:e})})}function ln(t,e,r){return ie(this,arguments,void 0,function*(i,n,o,s=3){if(s===0)throw new Error("Part upload failed, retries exhausted");let{fetch:a,responseHandler:c}=o;try{let u=yield a(i,{method:"PUT",body:n});return yield c(u)}catch{return yield ln(i,n,o,s-1)}})}function Rc(t,e){return ie(this,void 0,void 0,function*(){let{fetch:r,responseHandler:i}=e,n=t.type||"application/octet-stream",{upload_url:o,file_url:s}=yield $c(t,e,n),a=10*1024*1024,c=Math.ceil(t.size/a),u=new URL(o),l=[];for(let p=0;p<c;p++){let g=p*a,b=Math.min(g+a,t.size),w=t.slice(g,b),f=p+1,m=`${u.origin}${u.pathname}/${f}${u.search}`;l.push(yield ln(m,w,e))}let d=`${u.origin}${u.pathname}/complete${u.search}`,h=yield r(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:l.map(p=>({partNumber:p.partNumber,etag:p.etag}))})});return yield i(h),s})}function qc({config:t}){let e={upload:r=>ie(this,void 0,void 0,function*(){if(r.size>94371840)return yield Rc(r,t);let i=r.type||"application/octet-stream",{fetch:n,responseHandler:o}=t,{upload_url:s,file_url:a}=yield Lc(r,t,i),c=yield n(s,{method:"PUT",body:r,headers:{"Content-Type":r.type||"application/octet-stream"}});return yield o(c),a}),transformInput:r=>ie(this,void 0,void 0,function*(){if(Array.isArray(r))return Promise.all(r.map(i=>e.transformInput(i)));if(r instanceof Blob)return yield e.upload(r);if((0,Uc.isPlainObject)(r)){let n=Object.entries(r).map(s=>ie(this,[s],void 0,function*([a,c]){return[a,yield e.transformInput(c)]})),o=yield Promise.all(n);return Object.fromEntries(o)}return r})};return e}});var dr=_($e=>{"use strict";var cn=$e&&$e.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{u(i.next(l))}catch(d){s(d)}}function c(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty($e,"__esModule",{value:!0});$e.createFalClient=Hc;var Vc=Ze(),Nc=di(),Fc=nn(),dn=pe(),zc=K(),Bc=un(),Kc=Rt();function Hc(t={}){let e=(0,Vc.createConfig)(t),r=(0,Bc.createStorageClient)({config:e}),i=(0,Nc.createQueueClient)({config:e,storage:r}),n=(0,Kc.createStreamingClient)({config:e,storage:r}),o=(0,Fc.createRealtimeClient)({config:e});return{queue:i,realtime:o,storage:r,streaming:n,stream:n.stream,run(s){return cn(this,arguments,void 0,function*(a,c={}){let u=c.input?yield r.transformInput(c.input):void 0;return(0,dn.dispatchRequest)({method:c.method,targetUrl:(0,dn.buildUrl)(a,c),input:u,config:Object.assign(Object.assign({},e),{responseHandler:zc.resultResponseHandler}),options:{signal:c.abortSignal,retry:{maxRetries:3,baseDelay:500,maxDelay:15e3}}})})},subscribe:(s,a)=>cn(this,void 0,void 0,function*(){let{request_id:c}=yield i.submit(s,a);return a.onEnqueue&&a.onEnqueue(c),yield i.subscribeToStatus(s,Object.assign({requestId:c},a)),i.result(s,{requestId:c})})}}});var fn=_(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.isQueueStatus=pn;gt.isCompletedQueueStatus=Gc;function pn(t){return t&&t.status&&t.response_url}function Gc(t){return pn(t)&&t.status==="COMPLETED"}});var yn=_(k=>{"use strict";var Qc=k&&k.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Yc=k&&k.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Qc(e,t,r)};Object.defineProperty(k,"__esModule",{value:!0});k.fal=k.parseEndpointId=k.isRetryableError=k.ValidationError=k.ApiError=k.withProxy=k.withMiddleware=k.createFalClient=void 0;var hn=dr(),Wc=dr();Object.defineProperty(k,"createFalClient",{enumerable:!0,get:function(){return Wc.createFalClient}});var gn=jt();Object.defineProperty(k,"withMiddleware",{enumerable:!0,get:function(){return gn.withMiddleware}});Object.defineProperty(k,"withProxy",{enumerable:!0,get:function(){return gn.withProxy}});var mn=K();Object.defineProperty(k,"ApiError",{enumerable:!0,get:function(){return mn.ApiError}});Object.defineProperty(k,"ValidationError",{enumerable:!0,get:function(){return mn.ValidationError}});var Zc=Ae();Object.defineProperty(k,"isRetryableError",{enumerable:!0,get:function(){return Zc.isRetryableError}});Yc(fn(),k);var Xc=H();Object.defineProperty(k,"parseEndpointId",{enumerable:!0,get:function(){return Xc.parseEndpointId}});k.fal=function(){let e=(0,hn.createFalClient)();return{config(r){e=(0,hn.createFalClient)(r)},get queue(){return e.queue},get realtime(){return e.realtime},get storage(){return e.storage},get streaming(){return e.streaming},run(r,i){return e.run(r,i)},subscribe(r,i){return e.subscribe(r,i)},stream(r,i){return e.stream(r,i)}}}()});var _r={openapi:"3.0.0",info:{title:"Fal Queue API",version:"1.0.0",description:"The Fal Queue API."},components:{securitySchemes:{apiKeyAuth:{type:"apiKey",in:"header",name:"Authorization",description:"Fal Key"}},schemas:{QueueStatus:{type:"object",properties:{status:{type:"string",enum:["IN_QUEUE","IN_PROGRESS","COMPLETED"]},request_id:{type:"string",description:"The request id."},response_url:{type:"string",description:"The response url."},status_url:{type:"string",description:"The status url."},cancel_url:{type:"string",description:"The cancel url."},logs:{type:"object",description:"The logs.",additionalProperties:!0},metrics:{type:"object",description:"The metrics.",additionalProperties:!0},queue_position:{type:"integer",description:"The queue position."}},required:["status","request_id"]},MinimaxVideo01LiveInput:{title:"TextToVideoLiveRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0}},"x-fal-order-properties":["prompt"],required:["prompt"]},MinimaxVideo01LiveOutput:{title:"T2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/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/minimax/video-01-live/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/minimax/video-01-live":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/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/MinimaxVideo01LiveOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};async function Ir(t,e,r){if(e!=null){if(e.startsWith("blob:")){let n=await(await fetch(e)).blob(),o=new File([n],"image.png",{type:"image/png"});return t.storage.upload(o)}if(r!=null&&e.startsWith("buffer:")){let i=await r.engine.editor.getMimeType(e),n=r.engine.editor.getBufferLength(e),o=r.engine.editor.getBufferData(e,0,n),s=new Uint8Array(o),a=new File([s],"image.png",{type:i});return t.storage.upload(a)}return e}}function uo(t,e){let{cesdk:r}=e,i=e.propertyKey??"image_url",n=St(t);return r.i18n.setTranslations({en:{[`panel.${n}`]:"Select Image To Change"}}),co(t,r),{[i]:(o,s)=>{let{builder:a,experimental:{global:c},payload:u}=o,l=u?.url??e.defaultUrl,d=c(`${t}.${s.id}`,l);return a.MediaPreview(s.id,{preview:{type:"image",uri:d.value},action:{label:"Select Image",onClick:()=>{r?.ui.openPanel(n,{payload:{onSelect:h=>{h.meta?.uri!=null&&d.setValue(h.meta?.uri)}}})}}}),()=>({id:s.id,type:"string",value:d.value})}}}function co(t,e){e?.ui.registerPanel(St(t),({builder:r,payload:i})=>{r.Library(`${t}.library.image`,{entries:["ly.img.image"],onSelect:async n=>{let o=n?.meta?.uri;if(o==null)return;let s=await e.engine.editor.getMimeType(o);s==="image/svg+xml"?e.ui.showNotification({type:"warning",message:"SVG images are not supported. Please choose a different image."}):s.startsWith("image/")?(i?.onSelect(n),e?.ui.closePanel(St(t))):e.ui.showNotification({type:"warning",message:`Only images are supported. Found '${s}'. Please choose a different image.`})}})})}function St(t){return`ly.img.ai.${t}.imageSelection`}var po=uo,fo=class{constructor(t,e=[],r){this.id=t,this.translateLabel=r?.translateLabel,this.assets=e.map(i=>{if(typeof i.label=="string"&&!(i.label&&typeof i.label=="object")){let n=i;return{id:n.id,label:{en:n.label},meta:n.thumbUri?{...n.meta??{},thumbUri:n.thumbUri}:n.meta}}return i}),this.activeAssetIds=new Set,this.assets.length>0&&this.activeAssetIds.add(this.assets[0].id)}async findAssets(t){let{page:e,perPage:r,locale:i="en",sortActiveFirst:n,query:o,tags:s,groups:a,excludeGroups:c,sortingOrder:u,sortKey:l}=t,d=[...this.assets];if(a&&a.length>0&&(d=d.filter(f=>f.groups&&a.some(m=>f.groups?.includes(m)))),c&&c.length>0&&(d=d.filter(f=>!f.groups||!c.some(m=>f.groups?.includes(m)))),o){let f=o.toLowerCase();d=d.filter(m=>{let I=m.label?.[i]?.toLowerCase(),x=m.tags?.[i]||[];return I&&I.includes(f)||x.some(A=>A.toLowerCase().includes(f))})}if(s&&s.length>0){let f=Array.isArray(s)?s:[s];d=d.filter(m=>{let I=m.tags?.[i]||[];return f.some(x=>I.includes(x))})}n&&d.sort((f,m)=>{let I=this.activeAssetIds.has(f.id),x=this.activeAssetIds.has(m.id);return I&&!x?-1:!I&&x?1:0}),l&&l!=="id"?d.sort((f,m)=>{let I=f.meta?.[l],x=m.meta?.[l];return I===void 0?1:x===void 0?-1:typeof I=="string"&&typeof x=="string"?u==="Descending"?x.localeCompare(I):I.localeCompare(x):typeof I=="number"&&typeof x=="number"?u==="Descending"?x-I:I-x:0}):l==="id"&&d.sort((f,m)=>u==="Descending"?m.id.localeCompare(f.id):f.id.localeCompare(m.id));let h=d.length,p=e*r,g=p+r,b=d.slice(p,g).map(f=>{let m=f.label?.[i]||"",I=this.translateLabel?this.translateLabel(f.id,m,i):m;return{id:f.id,groups:f.groups,meta:f.meta,payload:f.payload,locale:i,label:I,tags:f.tags?.[i],active:this.activeAssetIds.has(f.id)}}),w=g<h?e+1:void 0;return{assets:b,currentPage:e,nextPage:w,total:h}}updateLabel(t,e,r){this.assets.forEach(i=>{i.id===t&&(i.label=i.label||{},i.label[r]=e)})}getAssetSelectValue(t){let e=this.assets.find(({id:r})=>r===t);if(e){let r=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:r,thumbUri:e.meta?.thumbUri}}}getActiveSelectValue(){let t=this.getActiveAssetIds();if(t.length>0){let e=this.assets.find(({id:r})=>r===t[0]);if(e){let r=this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||"";return{id:e.id,label:r,thumbUri:e.meta?.thumbUri}}}}getTranslatedLabel(t){let e=this.assets.find(({id:r})=>r===t);if(e)return this.translateLabel?this.translateLabel(e.id,e.label?.en||"",""):e.label?.en||""}getAsset(t){return this.assets.find(e=>e.id===t)}setAssetActive(t){this.activeAssetIds.add(t)}getActiveAssetIds(){return Array.from(this.activeAssetIds)}setAssetsActive(t){t.forEach(e=>this.activeAssetIds.add(e))}setAssetInactive(t){this.activeAssetIds.delete(t)}clearActiveAssets(){this.activeAssetIds.clear()}isAssetActive(t){return this.activeAssetIds.has(t)}addAsset(t){let e=this.assets.findIndex(r=>r.id===t.id);e>=0?this.assets[e]=t:this.assets.push(t)}removeAsset(t){let e=this.assets.findIndex(r=>r.id===t);e!==-1&&(this.assets.splice(e,1),this.activeAssetIds.delete(t))}async getGroups(){let t=new Set;return this.assets.forEach(e=>{e.groups&&e.groups.forEach(r=>t.add(r))}),Array.from(t)}getSupportedMimeTypes(){return["image/jpeg","image/png","image/svg+xml","image/webp","video/mp4","audio/mpeg"]}};var ho=typeof global=="object"&&global&&global.Object===Object&&global,Rr=ho,go=typeof self=="object"&&self&&self.Object===Object&&self,mo=Rr||go||Function("return this")(),q=mo,yo=q.Symbol,se=yo,qr=Object.prototype,bo=qr.hasOwnProperty,vo=qr.toString,_e=se?se.toStringTag:void 0;function wo(t){var e=bo.call(t,_e),r=t[_e];try{t[_e]=void 0;var i=!0}catch{}var n=vo.call(t);return i&&(e?t[_e]=r:delete t[_e]),n}var xo=wo,_o=Object.prototype,Io=_o.toString;function Eo(t){return Io.call(t)}var So=Eo,ko="[object Null]",To="[object Undefined]",Er=se?se.toStringTag:void 0;function Ao(t){return t==null?t===void 0?To:ko:Er&&Er in Object(t)?xo(t):So(t)}var ke=Ao;function Co(t){return t!=null&&typeof t=="object"}var Pt=Co,hh=Array.isArray;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Vr=Mo,Po="[object AsyncFunction]",jo="[object Function]",Oo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!Vr(t))return!1;var e=ke(t);return e==jo||e==Oo||e==Po||e==Do}var Lo=Uo,$o=q["__core-js_shared__"],_t=$o,Sr=function(){var t=/[^.]+$/.exec(_t&&_t.keys&&_t.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ro(t){return!!Sr&&Sr in t}var qo=Ro,Vo=Function.prototype,No=Vo.toString;function Fo(t){if(t!=null){try{return No.call(t)}catch{}try{return t+""}catch{}}return""}var J=Fo,zo=/[\\^$.*+?()[\]{}|]/g,Bo=/^\[object .+?Constructor\]$/,Ko=Function.prototype,Ho=Object.prototype,Go=Ko.toString,Qo=Ho.hasOwnProperty,Yo=RegExp("^"+Go.call(Qo).replace(zo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Wo(t){if(!Vr(t)||qo(t))return!1;var e=Lo(t)?Yo:Bo;return e.test(J(t))}var Zo=Wo;function Xo(t,e){return t?.[e]}var Jo=Xo;function es(t,e){var r=Jo(t,e);return Zo(r)?r:void 0}var ae=es,ts=ae(q,"WeakMap"),kt=ts;function rs(t,e){return t===e||t!==t&&e!==e}var is=rs,ns=9007199254740991;function os(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ns}var ss=os,gh=Object.prototype,as="[object Arguments]";function ls(t){return Pt(t)&&ke(t)==as}var kr=ls,Nr=Object.prototype,us=Nr.hasOwnProperty,cs=Nr.propertyIsEnumerable,mh=kr(function(){return arguments}())?kr:function(t){return Pt(t)&&us.call(t,"callee")&&!cs.call(t,"callee")},Fr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Tr=Fr&&typeof module=="object"&&module&&!module.nodeType&&module,ds=Tr&&Tr.exports===Fr,Ar=ds?q.Buffer:void 0,yh=Ar?Ar.isBuffer:void 0,ps="[object Arguments]",fs="[object Array]",hs="[object Boolean]",gs="[object Date]",ms="[object Error]",ys="[object Function]",bs="[object Map]",vs="[object Number]",ws="[object Object]",xs="[object RegExp]",_s="[object Set]",Is="[object String]",Es="[object WeakMap]",Ss="[object ArrayBuffer]",ks="[object DataView]",Ts="[object Float32Array]",As="[object Float64Array]",Cs="[object Int8Array]",Ms="[object Int16Array]",Ps="[object Int32Array]",js="[object Uint8Array]",Os="[object Uint8ClampedArray]",Ds="[object Uint16Array]",Us="[object Uint32Array]",E={};E[Ts]=E[As]=E[Cs]=E[Ms]=E[Ps]=E[js]=E[Os]=E[Ds]=E[Us]=!0;E[ps]=E[fs]=E[Ss]=E[hs]=E[ks]=E[gs]=E[ms]=E[ys]=E[bs]=E[vs]=E[ws]=E[xs]=E[_s]=E[Is]=E[Es]=!1;function Ls(t){return Pt(t)&&ss(t.length)&&!!E[ke(t)]}var $s=Ls;function Rs(t){return function(e){return t(e)}}var qs=Rs,zr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ie=zr&&typeof module=="object"&&module&&!module.nodeType&&module,Vs=Ie&&Ie.exports===zr,It=Vs&&Rr.process,Ns=function(){try{var t=Ie&&Ie.require&&Ie.require("util").types;return t||It&&It.binding&&It.binding("util")}catch{}}(),Cr=Ns,Mr=Cr&&Cr.isTypedArray,bh=Mr?qs(Mr):$s,Fs=Object.prototype,vh=Fs.hasOwnProperty;function zs(t,e){return function(r){return t(e(r))}}var Bs=zs,wh=Bs(Object.keys,Object),Ks=Object.prototype,xh=Ks.hasOwnProperty,Hs=ae(Object,"create"),Ee=Hs;function Gs(){this.__data__=Ee?Ee(null):{},this.size=0}var Qs=Gs;function Ys(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ws=Ys,Zs="__lodash_hash_undefined__",Xs=Object.prototype,Js=Xs.hasOwnProperty;function ea(t){var e=this.__data__;if(Ee){var r=e[t];return r===Zs?void 0:r}return Js.call(e,t)?e[t]:void 0}var ta=ea,ra=Object.prototype,ia=ra.hasOwnProperty;function na(t){var e=this.__data__;return Ee?e[t]!==void 0:ia.call(e,t)}var oa=na,sa="__lodash_hash_undefined__";function aa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ee&&e===void 0?sa:e,this}var la=aa;function le(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}le.prototype.clear=Qs;le.prototype.delete=Ws;le.prototype.get=ta;le.prototype.has=oa;le.prototype.set=la;var Pr=le;function ua(){this.__data__=[],this.size=0}var ca=ua;function da(t,e){for(var r=t.length;r--;)if(is(t[r][0],e))return r;return-1}var Be=da,pa=Array.prototype,fa=pa.splice;function ha(t){var e=this.__data__,r=Be(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():fa.call(e,r,1),--this.size,!0}var ga=ha;function ma(t){var e=this.__data__,r=Be(e,t);return r<0?void 0:e[r][1]}var ya=ma;function ba(t){return Be(this.__data__,t)>-1}var va=ba;function wa(t,e){var r=this.__data__,i=Be(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var xa=wa;function ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ue.prototype.clear=ca;ue.prototype.delete=ga;ue.prototype.get=ya;ue.prototype.has=va;ue.prototype.set=xa;var Ke=ue,_a=ae(q,"Map"),Se=_a;function Ia(){this.size=0,this.__data__={hash:new Pr,map:new(Se||Ke),string:new Pr}}var Ea=Ia;function Sa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ka=Sa;function Ta(t,e){var r=t.__data__;return ka(e)?r[typeof e=="string"?"string":"hash"]:r.map}var He=Ta;function Aa(t){var e=He(this,t).delete(t);return this.size-=e?1:0,e}var Ca=Aa;function Ma(t){return He(this,t).get(t)}var Pa=Ma;function ja(t){return He(this,t).has(t)}var Oa=ja;function Da(t,e){var r=He(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var Ua=Da;function ce(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ce.prototype.clear=Ea;ce.prototype.delete=Ca;ce.prototype.get=Pa;ce.prototype.has=Oa;ce.prototype.set=Ua;var Br=ce;function La(){this.__data__=new Ke,this.size=0}var $a=La;function Ra(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var qa=Ra;function Va(t){return this.__data__.get(t)}var Na=Va;function Fa(t){return this.__data__.has(t)}var za=Fa,Ba=200;function Ka(t,e){var r=this.__data__;if(r instanceof Ke){var i=r.__data__;if(!Se||i.length<Ba-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Br(i)}return r.set(t,e),this.size=r.size,this}var Ha=Ka;function Te(t){var e=this.__data__=new Ke(t);this.size=e.size}Te.prototype.clear=$a;Te.prototype.delete=qa;Te.prototype.get=Na;Te.prototype.has=za;Te.prototype.set=Ha;var Ga=Object.prototype,_h=Ga.propertyIsEnumerable,Qa=ae(q,"DataView"),Tt=Qa,Ya=ae(q,"Promise"),At=Ya,Wa=ae(q,"Set"),Ct=Wa,jr="[object Map]",Za="[object Object]",Or="[object Promise]",Dr="[object Set]",Ur="[object WeakMap]",Lr="[object DataView]",Xa=J(Tt),Ja=J(Se),el=J(At),tl=J(Ct),rl=J(kt),oe=ke;(Tt&&oe(new Tt(new ArrayBuffer(1)))!=Lr||Se&&oe(new Se)!=jr||At&&oe(At.resolve())!=Or||Ct&&oe(new Ct)!=Dr||kt&&oe(new kt)!=Ur)&&(oe=function(t){var e=ke(t),r=e==Za?t.constructor:void 0,i=r?J(r):"";if(i)switch(i){case Xa:return Lr;case Ja:return jr;case el:return Or;case tl:return Dr;case rl:return Ur}return e});var Ih=q.Uint8Array,il="__lodash_hash_undefined__";function nl(t){return this.__data__.set(t,il),this}var ol=nl;function sl(t){return this.__data__.has(t)}var al=sl;function Mt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Br;++e<r;)this.add(t[e])}Mt.prototype.add=Mt.prototype.push=ol;Mt.prototype.has=al;var $r=se?se.prototype:void 0,Eh=$r?$r.valueOf:void 0,ll=Object.prototype,Sh=ll.hasOwnProperty,ul=Object.prototype,kh=ul.hasOwnProperty,Th=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ah=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Ch=new RegExp(/[A-Fa-f0-9]{2}/,"g");function cl(t){return t!==void 0}var dl=cl;function pl(t,e){let{cesdk:r}=e;if(r==null)return{};let i=e.propertyKey??"style",n=hl(t);r.i18n.setTranslations({en:{[`panel.${n}`]:"Select Style",[`${t}.${i}`]:"Style"}});let o=ml({baseURL:e.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-image-generation-web/v1/gpt-image-1/",includeNone:!0}),s=o;e.styles!=null&&(Array.isArray(e.styles)?s=e.styles:typeof e.styles=="function"&&(s=e.styles(o)));let a=yl({cesdk:r,providerId:t,styles:s}),c=a.id;return bl(a,{cesdk:r}),fl({providerId:t,cesdk:r,panelId:n,entryId:c}),{[e.propertyKeyForPrompt??"prompt"]:(u,l)=>{let d=u.state("prompt","");return u.builder.TextArea(`${l.id}`,{inputLabel:e.i18n?.prompt?.inputLabel??e.propertyKeyForPrompt??"prompt",placeholder:e.i18n?.prompt?.placeholder,...d}),()=>{let[h]=a.getActiveAssetIds(),p=a.getAsset(h);return{id:l.id,type:"string",value:p?.meta?.prompt==null?d.value:`${d.value}; ${p.meta.prompt}`}}},[i]:(u,l)=>{let{builder:d,state:h}=u;if(s.length>0){let p=h("style",s[0]);return d.Button(`${l.id}`,{inputLabel:`${t}.${l.id}`,icon:"@imgly/Appearance",isDisabled:s.length===0,trailingIcon:"@imgly/ChevronRight",label:p.value.label,labelAlignment:"left",onClick:()=>{let g={onSelect:async b=>{a.clearActiveAssets(),a.setAssetActive(b.id),p.setValue({id:b.id,label:b.label??b.id}),r.ui.closePanel(n)}};r.ui.openPanel(n,{payload:g})}}),()=>({id:l.id,type:"string",value:p.value.id})}return()=>({id:l.id,type:"string",value:"none"})}}}function fl(t){let{providerId:e,cesdk:r,panelId:i,entryId:n}=t;r?.ui.registerPanel(i,({builder:o,payload:s})=>{s?.onSelect==null&&o.Section(`${e}.error`,{children:()=>{o.Text("error",{content:"No onSelect function provided for the style selection panel."})}}),o.Library(`${e}.library.image`,{entries:[n],onSelect:async a=>{s?.onSelect?.(a)}})})}function hl(t){return`ly.img.ai.${t}.styleSelection`}var gl=[{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 ml(t){return gl.map(e=>e.id==="none"?t.includeNone?{...e,thumbUri:`${t.baseURL}/thumbnails/None.svg`}:void 0:{...e,thumbUri:`${t.baseURL}/thumbnails/${e.id}.jpeg`}).filter(dl)}var yl=t=>{let e=t.styles.map(s=>({...s,meta:{prompt:s.prompt}})),r=t.cesdk.engine.asset.findAllSources(),i=`${t.providerId}/styles`;for(;r.includes(i);)i+=`-${Math.random().toString(36).substring(2,5)}`;let n=new fo(i,e),o=t.styles[0];return n.setAssetActive(o.id),n},bl=(t,e)=>{e.cesdk.engine.asset.addSource(t),e.cesdk.ui.addAssetLibraryEntry({id:t.id,sourceIds:[t.id],gridItemHeight:"square",gridBackgroundType:"cover",cardLabel:({label:r})=>r,cardLabelPosition:()=>"below"})},vl=pl;var wl="ly.img.ai";function O(t){return`${wl}.${t}`}function Kr(t,e){let r={...t};if(!e)return r;for(let[i,n]of Object.entries(e))n===!1||n===null||n===void 0?delete r[i]:n===!0?i in t||(r[i]=!0):r[i]=n;return r}var Et="@imgly/plugin-ai-generation",Mh=`
6
6
  <svg>
7
7
  <symbol
8
8
  fill="none"
@@ -63,7 +63,7 @@ var to=Object.create;var xr=Object.defineProperty;var ro=Object.getOwnPropertyDe
63
63
 
64
64
  </symbol>
65
65
  </svg>
66
- `;var Hr={ImageUrl:po,StyleTransfer:vl};var bn=ao(yn());function vn(t,e){return(0,bn.createFalClient)({proxyUrl:t,requestMiddleware:async i=>({...i,headers:{...i.headers,...e??{}}})})}function Jc(t,e){let r=t.middleware??e.middlewares??e.middleware??[],i=null,n={id:t.modelKey,name:t.name??t.modelKey,kind:"video",initialize:async o=>{i=vn(e.proxyUrl,t.headers),t.initialize?.(o)},input:{quickActions:{supported:Kr(t.supportedQuickActions??{},e.supportedQuickActions)},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?Hr.ImageUrl(t.modelKey,{cesdk:t.cesdk}):{},...t.renderCustomProperty},getBlockInput:t.getBlockInput,userFlow:t.useFlow??"placeholder"}},output:{abortable:!0,history:e.history??"@imgly/indexedDB",middleware:r,generate:async(o,{abortSignal:s})=>{if(!i)throw new Error("Provider not initialized");let a=await Ir(i,o.image_url,t.cesdk),c=await i.subscribe(t.modelKey,{abortSignal:s,input:a!=null?{...o,image_url:a}:o,logs:!0}),u=c?.data?.video;if(u!=null){let l=u?.url;if(l!=null)return{kind:"video",url:l}}throw console.error("Cannot extract generated video from response:",c),new Error("Cannot find generated video")},generationHintText:"Video generation may take up to a few minutes. This panel can be closed and you'll be notified when it's ready."}};return e.debug&&console.log("Created Provider:",n),n}var j=Jc;function wn(t){return async({cesdk:e})=>ed(e,t)}function ed(t,e){return j({modelKey:"fal-ai/minimax/video-01-live",name:"Minimax Video 01 Live",schema:_r,inputReference:"#/components/schemas/MinimaxVideo01LiveInput",headers:e.headers,middleware:e.middlewares??e.middleware??[],cesdk:t,getBlockInput:()=>Promise.resolve({video:{width:1280,height:720,duration:5}})},e)}var td=typeof global=="object"&&global&&global.Object===Object&&global,Un=td,rd=typeof self=="object"&&self&&self.Object===Object&&self,id=Un||rd||Function("return this")(),B=id,nd=B.Symbol,ye=nd,Ln=Object.prototype,od=Ln.hasOwnProperty,sd=Ln.toString,$e=ye?ye.toStringTag:void 0;function ad(t){var e=od.call(t,$e),r=t[$e];try{t[$e]=void 0;var i=!0}catch{}var n=sd.call(t);return i&&(e?t[$e]=r:delete t[$e]),n}var ld=ad,ud=Object.prototype,cd=ud.toString;function dd(t){return cd.call(t)}var pd=dd,fd="[object Null]",hd="[object Undefined]",xn=ye?ye.toStringTag:void 0;function gd(t){return t==null?t===void 0?hd:fd:xn&&xn in Object(t)?ld(t):pd(t)}var Fe=gd;function md(t){return t!=null&&typeof t=="object"}var vr=md,kg=Array.isArray;function yd(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Rn=yd,bd="[object AsyncFunction]",vd="[object Function]",wd="[object GeneratorFunction]",xd="[object Proxy]";function _d(t){if(!Rn(t))return!1;var e=Fe(t);return e==vd||e==wd||e==bd||e==xd}var Id=_d,Ed=B["__core-js_shared__"],pr=Ed,_n=function(){var t=/[^.]+$/.exec(pr&&pr.keys&&pr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Sd(t){return!!_n&&_n in t}var Td=Sd,kd=Function.prototype,Ad=kd.toString;function Cd(t){if(t!=null){try{return Ad.call(t)}catch{}try{return t+""}catch{}}return""}var ne=Cd,Md=/[\\^$.*+?()[\]{}|]/g,Pd=/^\[object .+?Constructor\]$/,jd=Function.prototype,Od=Object.prototype,Dd=jd.toString,Ud=Od.hasOwnProperty,Ld=RegExp("^"+Dd.call(Ud).replace(Md,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Rd(t){if(!Rn(t)||Td(t))return!1;var e=Id(t)?Ld:Pd;return e.test(ne(t))}var $d=Rd;function qd(t,e){return t?.[e]}var Vd=qd;function Nd(t,e){var r=Vd(t,e);return $d(r)?r:void 0}var be=Nd,Fd=be(B,"WeakMap"),hr=Fd;function zd(t,e){return t===e||t!==t&&e!==e}var Bd=zd,Kd=9007199254740991;function Hd(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Kd}var Gd=Hd;var Ag=Object.prototype;var Qd="[object Arguments]";function Yd(t){return vr(t)&&Fe(t)==Qd}var In=Yd,$n=Object.prototype,Wd=$n.hasOwnProperty,Zd=$n.propertyIsEnumerable,Cg=In(function(){return arguments}())?In:function(t){return vr(t)&&Wd.call(t,"callee")&&!Zd.call(t,"callee")};var qn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,En=qn&&typeof module=="object"&&module&&!module.nodeType&&module,Xd=En&&En.exports===qn,Sn=Xd?B.Buffer:void 0,Mg=Sn?Sn.isBuffer:void 0;var Jd="[object Arguments]",ep="[object Array]",tp="[object Boolean]",rp="[object Date]",ip="[object Error]",np="[object Function]",op="[object Map]",sp="[object Number]",ap="[object Object]",lp="[object RegExp]",up="[object Set]",cp="[object String]",dp="[object WeakMap]",pp="[object ArrayBuffer]",fp="[object DataView]",hp="[object Float32Array]",gp="[object Float64Array]",mp="[object Int8Array]",yp="[object Int16Array]",bp="[object Int32Array]",vp="[object Uint8Array]",wp="[object Uint8ClampedArray]",xp="[object Uint16Array]",_p="[object Uint32Array]",S={};S[hp]=S[gp]=S[mp]=S[yp]=S[bp]=S[vp]=S[wp]=S[xp]=S[_p]=!0;S[Jd]=S[ep]=S[pp]=S[tp]=S[fp]=S[rp]=S[ip]=S[np]=S[op]=S[sp]=S[ap]=S[lp]=S[up]=S[cp]=S[dp]=!1;function Ip(t){return vr(t)&&Gd(t.length)&&!!S[Fe(t)]}var Ep=Ip;function Sp(t){return function(e){return t(e)}}var Tp=Sp,Vn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qe=Vn&&typeof module=="object"&&module&&!module.nodeType&&module,kp=qe&&qe.exports===Vn,fr=kp&&Un.process,Ap=function(){try{var t=qe&&qe.require&&qe.require("util").types;return t||fr&&fr.binding&&fr.binding("util")}catch{}}(),Tn=Ap,kn=Tn&&Tn.isTypedArray,Pg=kn?Tp(kn):Ep;var Cp=Object.prototype,jg=Cp.hasOwnProperty;function Mp(t,e){return function(r){return t(e(r))}}var Pp=Mp,Og=Pp(Object.keys,Object);var jp=Object.prototype,Dg=jp.hasOwnProperty;var Op=be(Object,"create"),Ve=Op;function Dp(){this.__data__=Ve?Ve(null):{},this.size=0}var Up=Dp;function Lp(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Rp=Lp,$p="__lodash_hash_undefined__",qp=Object.prototype,Vp=qp.hasOwnProperty;function Np(t){var e=this.__data__;if(Ve){var r=e[t];return r===$p?void 0:r}return Vp.call(e,t)?e[t]:void 0}var Fp=Np,zp=Object.prototype,Bp=zp.hasOwnProperty;function Kp(t){var e=this.__data__;return Ve?e[t]!==void 0:Bp.call(e,t)}var Hp=Kp,Gp="__lodash_hash_undefined__";function Qp(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ve&&e===void 0?Gp:e,this}var Yp=Qp;function ve(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ve.prototype.clear=Up;ve.prototype.delete=Rp;ve.prototype.get=Fp;ve.prototype.has=Hp;ve.prototype.set=Yp;var An=ve;function Wp(){this.__data__=[],this.size=0}var Zp=Wp;function Xp(t,e){for(var r=t.length;r--;)if(Bd(t[r][0],e))return r;return-1}var mt=Xp,Jp=Array.prototype,ef=Jp.splice;function tf(t){var e=this.__data__,r=mt(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():ef.call(e,r,1),--this.size,!0}var rf=tf;function nf(t){var e=this.__data__,r=mt(e,t);return r<0?void 0:e[r][1]}var of=nf;function sf(t){return mt(this.__data__,t)>-1}var af=sf;function lf(t,e){var r=this.__data__,i=mt(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var uf=lf;function we(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}we.prototype.clear=Zp;we.prototype.delete=rf;we.prototype.get=of;we.prototype.has=af;we.prototype.set=uf;var yt=we,cf=be(B,"Map"),Ne=cf;function df(){this.size=0,this.__data__={hash:new An,map:new(Ne||yt),string:new An}}var pf=df;function ff(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var hf=ff;function gf(t,e){var r=t.__data__;return hf(e)?r[typeof e=="string"?"string":"hash"]:r.map}var bt=gf;function mf(t){var e=bt(this,t).delete(t);return this.size-=e?1:0,e}var yf=mf;function bf(t){return bt(this,t).get(t)}var vf=bf;function wf(t){return bt(this,t).has(t)}var xf=wf;function _f(t,e){var r=bt(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var If=_f;function xe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}xe.prototype.clear=pf;xe.prototype.delete=yf;xe.prototype.get=vf;xe.prototype.has=xf;xe.prototype.set=If;var Nn=xe;function Ef(){this.__data__=new yt,this.size=0}var Sf=Ef;function Tf(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var kf=Tf;function Af(t){return this.__data__.get(t)}var Cf=Af;function Mf(t){return this.__data__.has(t)}var Pf=Mf,jf=200;function Of(t,e){var r=this.__data__;if(r instanceof yt){var i=r.__data__;if(!Ne||i.length<jf-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Nn(i)}return r.set(t,e),this.size=r.size,this}var Df=Of;function ze(t){var e=this.__data__=new yt(t);this.size=e.size}ze.prototype.clear=Sf;ze.prototype.delete=kf;ze.prototype.get=Cf;ze.prototype.has=Pf;ze.prototype.set=Df;var Uf=Object.prototype,Ug=Uf.propertyIsEnumerable;var Lf=be(B,"DataView"),gr=Lf,Rf=be(B,"Promise"),mr=Rf,$f=be(B,"Set"),yr=$f,Cn="[object Map]",qf="[object Object]",Mn="[object Promise]",Pn="[object Set]",jn="[object WeakMap]",On="[object DataView]",Vf=ne(gr),Nf=ne(Ne),Ff=ne(mr),zf=ne(yr),Bf=ne(hr),me=Fe;(gr&&me(new gr(new ArrayBuffer(1)))!=On||Ne&&me(new Ne)!=Cn||mr&&me(mr.resolve())!=Mn||yr&&me(new yr)!=Pn||hr&&me(new hr)!=jn)&&(me=function(t){var e=Fe(t),r=e==qf?t.constructor:void 0,i=r?ne(r):"";if(i)switch(i){case Vf:return On;case Nf:return Cn;case Ff:return Mn;case zf:return Pn;case Bf:return jn}return e});var Lg=B.Uint8Array;var Kf="__lodash_hash_undefined__";function Hf(t){return this.__data__.set(t,Kf),this}var Gf=Hf;function Qf(t){return this.__data__.has(t)}var Yf=Qf;function br(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Nn;++e<r;)this.add(t[e])}br.prototype.add=br.prototype.push=Gf;br.prototype.has=Yf;var Dn=ye?ye.prototype:void 0,Rg=Dn?Dn.valueOf:void 0;var Wf=Object.prototype,$g=Wf.hasOwnProperty;var Zf=Object.prototype,qg=Zf.hasOwnProperty;var Vg=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ng=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Fg=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function Fn(t,e){if(t.startsWith("buffer:")){let r=await e.editor.getMimeType(t),i=e.editor.getBufferLength(t),n=e.editor.getBufferData(t,0,i),o=new Uint8Array(n),s=new Blob([o],{type:r});return URL.createObjectURL(s)}else return t}async function vt(t,e){let r=await Fn(t,e);return new Promise((i,n)=>{let o=new Image;o.onload=()=>{i({width:o.width,height:o.height})},o.onerror=n,o.src=r})}async function zn(t,e,r){let i,n=e.block.getFill(t),o=e.block.getSourceSet(n,"fill/image/sourceSet"),[s]=o;if(s==null){if(i=e.block.getString(n,"fill/image/imageFileURI"),i==null)throw new Error("No image source/uri found")}else i=s.uri;if(r?.throwErrorIfSvg&&await e.editor.getMimeType(i)==="image/svg+xml")throw new Error("SVG images are not supported");return Fn(i,e)}var Bn={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"]},MinimaxVideo01LiveImageToVideoInput:{title:"ImageToVideoRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0},image_url:{title:"Image Url",type:"string",description:"URL of the image to use as the first frame"}},"x-fal-order-properties":["image_url","prompt"],required:["prompt","image_url"]},MinimaxVideo01LiveImageToVideoOutput:{title:"I2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/image-to-video/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/MinimaxVideo01LiveImageToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Kn(t){return async({cesdk:e})=>{let r="fal-ai/minimax/video-01-live/image-to-video";return e.i18n.setTranslations({en:{[`panel.${O(r)}.imageSelection`]:"Select Image To Generate",[`panel.${r}.imageSelection`]:"Select Image To Generate",[`libraries.${O(r)}.history.label`]:"Generated From Image"}}),Jf(e,t)}}function Jf(t,e){return j({modelKey:"fal-ai/minimax/video-01-live/image-to-video",name:"Minimax Video 01 Live",schema:Bn,inputReference:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput",cesdk:t,headers:e.headers,middleware:e.middlewares??e.middleware??[],supportedQuickActions:{"ly.img.createVideo":{mapInput:()=>{throw new Error("This generation should not be triggered by this quick action")}}},getBlockInput:async r=>{let i=await vt(r.image_url,t.engine);return Promise.resolve({video:{width:i.width??1280,height:i.height??720,duration:5}})}},e)}var Hn={openapi:"3.0.4",info:{title:"Queue OpenAPI for fal-ai/kling-video/v2.1/master/image-to-video",version:"1.0.0",description:"Automatically generated schema for Kling 2.1 Master \u2013 Image to Video model"},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"]},KlingVideoV21MasterImageToVideoInput:{title:"ImageToVideoV21MasterRequest",type:"object",properties:{prompt:{maxLength:2500,type:"string",title:"Prompt","x-imgly-builder":{component:"TextArea"}},duration:{enum:["5","10"],title:"Duration",type:"string",description:"The duration of the generated video in seconds",default:"5"},cfg_scale:{minimum:0,maximum:1,type:"number",title:"Cfg Scale",description:`
66
+ `;var Hr={ImageUrl:po,StyleTransfer:vl};var bn=ao(yn());function vn(t,e){return(0,bn.createFalClient)({proxyUrl:t,requestMiddleware:async i=>({...i,headers:{...i.headers,...e??{}}})})}function Jc(t,e){let r=t.middleware??e.middlewares??e.middleware??[],i=null,n={id:t.modelKey,name:t.name??t.modelKey,kind:"video",initialize:async o=>{i=vn(e.proxyUrl,t.headers),t.initialize?.(o)},input:{quickActions:{supported:Kr(t.supportedQuickActions??{},e.supportedQuickActions)},panel:{type:"schema",document:t.schema,inputReference:t.inputReference,includeHistoryLibrary:!0,orderExtensionKeyword:"x-fal-order-properties",renderCustomProperty:{...t.cesdk!=null?Hr.ImageUrl(t.modelKey,{cesdk:t.cesdk}):{},...t.renderCustomProperty},getBlockInput:t.getBlockInput,userFlow:t.useFlow??"placeholder"}},output:{abortable:!0,history:e.history??"@imgly/indexedDB",middleware:r,generate:async(o,{abortSignal:s})=>{if(!i)throw new Error("Provider not initialized");let a=await Ir(i,o.image_url,t.cesdk),c=await i.subscribe(t.modelKey,{abortSignal:s,input:a!=null?{...o,image_url:a}:o,logs:!0}),u=c?.data?.video;if(u!=null){let l=u?.url;if(l!=null)return{kind:"video",url:l}}throw console.error("Cannot extract generated video from response:",c),new Error("Cannot find generated video")},generationHintText:"Video generation may take up to a few minutes. This panel can be closed and you'll be notified when it's ready."}};return e.debug&&console.log("Created Provider:",n),n}var j=Jc;function wn(t){return async({cesdk:e})=>ed(e,t)}function ed(t,e){return j({modelKey:"fal-ai/minimax/video-01-live",name:"Minimax Video 01 Live",schema:_r,inputReference:"#/components/schemas/MinimaxVideo01LiveInput",headers:e.headers,middleware:e.middlewares??e.middleware??[],cesdk:t,getBlockInput:()=>Promise.resolve({video:{width:1280,height:720,duration:5}})},e)}var td=typeof global=="object"&&global&&global.Object===Object&&global,Un=td,rd=typeof self=="object"&&self&&self.Object===Object&&self,id=Un||rd||Function("return this")(),B=id,nd=B.Symbol,ye=nd,Ln=Object.prototype,od=Ln.hasOwnProperty,sd=Ln.toString,Re=ye?ye.toStringTag:void 0;function ad(t){var e=od.call(t,Re),r=t[Re];try{t[Re]=void 0;var i=!0}catch{}var n=sd.call(t);return i&&(e?t[Re]=r:delete t[Re]),n}var ld=ad,ud=Object.prototype,cd=ud.toString;function dd(t){return cd.call(t)}var pd=dd,fd="[object Null]",hd="[object Undefined]",xn=ye?ye.toStringTag:void 0;function gd(t){return t==null?t===void 0?hd:fd:xn&&xn in Object(t)?ld(t):pd(t)}var Fe=gd;function md(t){return t!=null&&typeof t=="object"}var vr=md,Tg=Array.isArray;function yd(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var $n=yd,bd="[object AsyncFunction]",vd="[object Function]",wd="[object GeneratorFunction]",xd="[object Proxy]";function _d(t){if(!$n(t))return!1;var e=Fe(t);return e==vd||e==wd||e==bd||e==xd}var Id=_d,Ed=B["__core-js_shared__"],pr=Ed,_n=function(){var t=/[^.]+$/.exec(pr&&pr.keys&&pr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Sd(t){return!!_n&&_n in t}var kd=Sd,Td=Function.prototype,Ad=Td.toString;function Cd(t){if(t!=null){try{return Ad.call(t)}catch{}try{return t+""}catch{}}return""}var ne=Cd,Md=/[\\^$.*+?()[\]{}|]/g,Pd=/^\[object .+?Constructor\]$/,jd=Function.prototype,Od=Object.prototype,Dd=jd.toString,Ud=Od.hasOwnProperty,Ld=RegExp("^"+Dd.call(Ud).replace(Md,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $d(t){if(!$n(t)||kd(t))return!1;var e=Id(t)?Ld:Pd;return e.test(ne(t))}var Rd=$d;function qd(t,e){return t?.[e]}var Vd=qd;function Nd(t,e){var r=Vd(t,e);return Rd(r)?r:void 0}var be=Nd,Fd=be(B,"WeakMap"),hr=Fd;function zd(t,e){return t===e||t!==t&&e!==e}var Bd=zd,Kd=9007199254740991;function Hd(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Kd}var Gd=Hd;var Ag=Object.prototype;var Qd="[object Arguments]";function Yd(t){return vr(t)&&Fe(t)==Qd}var In=Yd,Rn=Object.prototype,Wd=Rn.hasOwnProperty,Zd=Rn.propertyIsEnumerable,Cg=In(function(){return arguments}())?In:function(t){return vr(t)&&Wd.call(t,"callee")&&!Zd.call(t,"callee")};var qn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,En=qn&&typeof module=="object"&&module&&!module.nodeType&&module,Xd=En&&En.exports===qn,Sn=Xd?B.Buffer:void 0,Mg=Sn?Sn.isBuffer:void 0;var Jd="[object Arguments]",ep="[object Array]",tp="[object Boolean]",rp="[object Date]",ip="[object Error]",np="[object Function]",op="[object Map]",sp="[object Number]",ap="[object Object]",lp="[object RegExp]",up="[object Set]",cp="[object String]",dp="[object WeakMap]",pp="[object ArrayBuffer]",fp="[object DataView]",hp="[object Float32Array]",gp="[object Float64Array]",mp="[object Int8Array]",yp="[object Int16Array]",bp="[object Int32Array]",vp="[object Uint8Array]",wp="[object Uint8ClampedArray]",xp="[object Uint16Array]",_p="[object Uint32Array]",S={};S[hp]=S[gp]=S[mp]=S[yp]=S[bp]=S[vp]=S[wp]=S[xp]=S[_p]=!0;S[Jd]=S[ep]=S[pp]=S[tp]=S[fp]=S[rp]=S[ip]=S[np]=S[op]=S[sp]=S[ap]=S[lp]=S[up]=S[cp]=S[dp]=!1;function Ip(t){return vr(t)&&Gd(t.length)&&!!S[Fe(t)]}var Ep=Ip;function Sp(t){return function(e){return t(e)}}var kp=Sp,Vn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qe=Vn&&typeof module=="object"&&module&&!module.nodeType&&module,Tp=qe&&qe.exports===Vn,fr=Tp&&Un.process,Ap=function(){try{var t=qe&&qe.require&&qe.require("util").types;return t||fr&&fr.binding&&fr.binding("util")}catch{}}(),kn=Ap,Tn=kn&&kn.isTypedArray,Pg=Tn?kp(Tn):Ep;var Cp=Object.prototype,jg=Cp.hasOwnProperty;function Mp(t,e){return function(r){return t(e(r))}}var Pp=Mp,Og=Pp(Object.keys,Object);var jp=Object.prototype,Dg=jp.hasOwnProperty;var Op=be(Object,"create"),Ve=Op;function Dp(){this.__data__=Ve?Ve(null):{},this.size=0}var Up=Dp;function Lp(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var $p=Lp,Rp="__lodash_hash_undefined__",qp=Object.prototype,Vp=qp.hasOwnProperty;function Np(t){var e=this.__data__;if(Ve){var r=e[t];return r===Rp?void 0:r}return Vp.call(e,t)?e[t]:void 0}var Fp=Np,zp=Object.prototype,Bp=zp.hasOwnProperty;function Kp(t){var e=this.__data__;return Ve?e[t]!==void 0:Bp.call(e,t)}var Hp=Kp,Gp="__lodash_hash_undefined__";function Qp(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ve&&e===void 0?Gp:e,this}var Yp=Qp;function ve(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}ve.prototype.clear=Up;ve.prototype.delete=$p;ve.prototype.get=Fp;ve.prototype.has=Hp;ve.prototype.set=Yp;var An=ve;function Wp(){this.__data__=[],this.size=0}var Zp=Wp;function Xp(t,e){for(var r=t.length;r--;)if(Bd(t[r][0],e))return r;return-1}var mt=Xp,Jp=Array.prototype,ef=Jp.splice;function tf(t){var e=this.__data__,r=mt(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():ef.call(e,r,1),--this.size,!0}var rf=tf;function nf(t){var e=this.__data__,r=mt(e,t);return r<0?void 0:e[r][1]}var of=nf;function sf(t){return mt(this.__data__,t)>-1}var af=sf;function lf(t,e){var r=this.__data__,i=mt(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var uf=lf;function we(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}we.prototype.clear=Zp;we.prototype.delete=rf;we.prototype.get=of;we.prototype.has=af;we.prototype.set=uf;var yt=we,cf=be(B,"Map"),Ne=cf;function df(){this.size=0,this.__data__={hash:new An,map:new(Ne||yt),string:new An}}var pf=df;function ff(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var hf=ff;function gf(t,e){var r=t.__data__;return hf(e)?r[typeof e=="string"?"string":"hash"]:r.map}var bt=gf;function mf(t){var e=bt(this,t).delete(t);return this.size-=e?1:0,e}var yf=mf;function bf(t){return bt(this,t).get(t)}var vf=bf;function wf(t){return bt(this,t).has(t)}var xf=wf;function _f(t,e){var r=bt(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var If=_f;function xe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}xe.prototype.clear=pf;xe.prototype.delete=yf;xe.prototype.get=vf;xe.prototype.has=xf;xe.prototype.set=If;var Nn=xe;function Ef(){this.__data__=new yt,this.size=0}var Sf=Ef;function kf(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Tf=kf;function Af(t){return this.__data__.get(t)}var Cf=Af;function Mf(t){return this.__data__.has(t)}var Pf=Mf,jf=200;function Of(t,e){var r=this.__data__;if(r instanceof yt){var i=r.__data__;if(!Ne||i.length<jf-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Nn(i)}return r.set(t,e),this.size=r.size,this}var Df=Of;function ze(t){var e=this.__data__=new yt(t);this.size=e.size}ze.prototype.clear=Sf;ze.prototype.delete=Tf;ze.prototype.get=Cf;ze.prototype.has=Pf;ze.prototype.set=Df;var Uf=Object.prototype,Ug=Uf.propertyIsEnumerable;var Lf=be(B,"DataView"),gr=Lf,$f=be(B,"Promise"),mr=$f,Rf=be(B,"Set"),yr=Rf,Cn="[object Map]",qf="[object Object]",Mn="[object Promise]",Pn="[object Set]",jn="[object WeakMap]",On="[object DataView]",Vf=ne(gr),Nf=ne(Ne),Ff=ne(mr),zf=ne(yr),Bf=ne(hr),me=Fe;(gr&&me(new gr(new ArrayBuffer(1)))!=On||Ne&&me(new Ne)!=Cn||mr&&me(mr.resolve())!=Mn||yr&&me(new yr)!=Pn||hr&&me(new hr)!=jn)&&(me=function(t){var e=Fe(t),r=e==qf?t.constructor:void 0,i=r?ne(r):"";if(i)switch(i){case Vf:return On;case Nf:return Cn;case Ff:return Mn;case zf:return Pn;case Bf:return jn}return e});var Lg=B.Uint8Array;var Kf="__lodash_hash_undefined__";function Hf(t){return this.__data__.set(t,Kf),this}var Gf=Hf;function Qf(t){return this.__data__.has(t)}var Yf=Qf;function br(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Nn;++e<r;)this.add(t[e])}br.prototype.add=br.prototype.push=Gf;br.prototype.has=Yf;var Dn=ye?ye.prototype:void 0,$g=Dn?Dn.valueOf:void 0;var Wf=Object.prototype,Rg=Wf.hasOwnProperty;var Zf=Object.prototype,qg=Zf.hasOwnProperty;var Vg=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Ng=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Fg=new RegExp(/[A-Fa-f0-9]{2}/,"g");async function Fn(t,e){if(t.startsWith("buffer:")){let r=await e.editor.getMimeType(t),i=e.editor.getBufferLength(t),n=e.editor.getBufferData(t,0,i),o=new Uint8Array(n),s=new Blob([o],{type:r});return URL.createObjectURL(s)}else return t}async function vt(t,e){let r=await Fn(t,e);return new Promise((i,n)=>{let o=new Image;o.onload=()=>{i({width:o.width,height:o.height})},o.onerror=n,o.src=r})}async function zn(t,e,r){let i,n=e.block.getFill(t),o=e.block.getSourceSet(n,"fill/image/sourceSet"),[s]=o;if(s==null){if(i=e.block.getString(n,"fill/image/imageFileURI"),i==null)throw new Error("No image source/uri found")}else i=s.uri;if(r?.throwErrorIfSvg&&await e.editor.getMimeType(i)==="image/svg+xml")throw new Error("SVG images are not supported");return Fn(i,e)}var Bn={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"]},MinimaxVideo01LiveImageToVideoInput:{title:"ImageToVideoRequest",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},prompt_optimizer:{title:"Prompt Optimizer",type:"boolean",description:"Whether to use the model's prompt optimizer",default:!0},image_url:{title:"Image Url",type:"string",description:"URL of the image to use as the first frame"}},"x-fal-order-properties":["image_url","prompt"],required:["prompt","image_url"]},MinimaxVideo01LiveImageToVideoOutput:{title:"I2VLiveOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video/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/minimax/video-01-live/image-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/minimax/video-01-live/image-to-video/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/MinimaxVideo01LiveImageToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Kn(t){return async({cesdk:e})=>{let r="fal-ai/minimax/video-01-live/image-to-video";return e.i18n.setTranslations({en:{[`panel.${O(r)}.imageSelection`]:"Select Image To Generate",[`panel.${r}.imageSelection`]:"Select Image To Generate",[`libraries.${O(r)}.history.label`]:"Generated From Image"}}),Jf(e,t)}}function Jf(t,e){return j({modelKey:"fal-ai/minimax/video-01-live/image-to-video",name:"Minimax Video 01 Live",schema:Bn,inputReference:"#/components/schemas/MinimaxVideo01LiveImageToVideoInput",cesdk:t,headers:e.headers,middleware:e.middlewares??e.middleware??[],supportedQuickActions:{"ly.img.createVideo":{mapInput:()=>{throw new Error("This generation should not be triggered by this quick action")}}},getBlockInput:async r=>{let i=await vt(r.image_url,t.engine);return Promise.resolve({video:{width:i.width??1280,height:i.height??720,duration:5}})}},e)}var Hn={openapi:"3.0.4",info:{title:"Queue OpenAPI for fal-ai/kling-video/v2.1/master/image-to-video",version:"1.0.0",description:"Automatically generated schema for Kling 2.1 Master \u2013 Image to Video model"},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"]},KlingVideoV21MasterImageToVideoInput:{title:"ImageToVideoV21MasterRequest",type:"object",properties:{prompt:{maxLength:2500,type:"string",title:"Prompt","x-imgly-builder":{component:"TextArea"}},duration:{enum:["5","10"],title:"Duration",type:"string",description:"The duration of the generated video in seconds",default:"5"},cfg_scale:{minimum:0,maximum:1,type:"number",title:"Cfg Scale",description:`
67
67
  The CFG (Classifier Free Guidance) scale is a measure of how close you want
68
68
  the model to stick to your prompt.
69
69
  `,default:.5},negative_prompt:{maxLength:2500,type:"string",title:"Negative Prompt",default:"blur, distort, and low quality"},image_url:{format:"uri",description:"URL of the image to be used for the video",type:"string",examples:["https://v3.fal.media/files/rabbit/NEvlE6DqEks4afmShK9tY_image.webp"],maxLength:2083,minLength:1,title:"Image Url"}},"x-fal-order-properties":["image_url","prompt","duration"],required:["prompt","image_url"]},KlingVideoV21MasterImageToVideoOutput:{title:"ImageToVideoV21MasterOutput",type:"object",properties:{video:{title:"Video",description:"The generated video",allOf:[{$ref:"#/components/schemas/File"}]}},"x-fal-order-properties":["video"],required:["video"]},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/kling-video/v2.1/master/image-to-video/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/kling-video/v2.1/master/image-to-video/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/kling-video/v2.1/master/image-to-video":{post:{requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/KlingVideoV21MasterImageToVideoInput"}}}},responses:{"200":{description:"The request status.",content:{"application/json":{schema:{$ref:"#/components/schemas/QueueStatus"}}}}}}},"/fal-ai/kling-video/v2.1/master/image-to-video/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/KlingVideoV21MasterImageToVideoOutput"}}}}}}}},servers:[{url:"https://queue.fal.run"}],security:[{apiKeyAuth:[]}]};function Gn(t){return async({cesdk:e})=>{let r="fal-ai/kling-video/v2.1/master/image-to-video";return e.i18n.setTranslations({en:{"ly.img.ai.quickAction.createVideoKling":"Create Video (Kling)...",[`panel.${O(r)}.imageSelection`]:"Select Image To Generate",[`panel.${r}.imageSelection`]:"Select Image To Generate",[`libraries.${O(r)}.history.label`]:"Generated From Image"}}),th(e,t)}}function th(t,e){return j({modelKey:"fal-ai/kling-video/v2.1/master/image-to-video",name:"Kling Video V2.1 Master",schema:Hn,inputReference:"#/components/schemas/KlingVideoV21MasterImageToVideoInput",cesdk:t,headers:e.headers,middlewares:e.middlewares,supportedQuickActions:{createVideoKling:{mapInput:async r=>{let[i]=t.engine.block.findAllSelected(),n=await zn(i,t.engine,{throwErrorIfSvg:!0});return t.ui.openPanel("ly.img.ai/video-generation"),t.ui.experimental.setGlobalStateValue("ly.img.ai.video-generation.fromType","fromImage"),t.ui.experimental.setGlobalStateValue("fal-ai/kling-video/v2.1/master/image-to-video.image_url",n),{prompt:r.prompt,image_url:n,duration:r.duration,negative_prompt:r.negative_prompt,cfg_scale:r.cfg_scale}}}},getBlockInput:async r=>{let i=await vt(r.image_url,t.engine);return Promise.resolve({video:{width:i.width??1280,height:i.height??720,duration:parseInt(r.duration??"5",10)}})}},e)}var Qn={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"]},PixverseV35TextToVideoInput:{title:"TextToVideoRequest",type:"object",properties:{prompt:{maxLength:2048,type:"string",title:"Prompt","x-imgly-builder":{component:"TextArea"}},aspect_ratio:{enum:["16:9","4:3","1:1","3:4","9:16"],title:"Aspect Ratio",type:"string",description:"The aspect ratio of the generated video",default:"16:9"},resolution:{enum:["360p","540p","720p","1080p"],title:"Resolution",type:"string",description:"The resolution of the generated video",default:"720p"},style:{enum:["anime","3d_animation","clay","comic","cyberpunk"],title:"Style",type:"string",description:"The style of the generated video"},duration:{enum:["5","8"],title:"Duration",type:"string",description:"The duration of the generated video in seconds. 8s videos cost double. 1080p videos are limited to 5 seconds",default:5},seed:{title:"Seed",type:"integer",description:`