(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,10190,e=>{"use strict";let t,r;function n(e){return Array.isArray(e)?e:null==e?[]:[e]}let a="orpc";class i extends Error{constructor(...e){super(...e),this.name="AbortError"}}function o(){return globalThis["__@orpc/shared@1.13.6/otel/config__"]}function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,n=o()?.tracer;return n?.startSpan(e,t,r)}function u(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e)return;let n=function(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return"code"in e&&("string"==typeof e.code||"number"==typeof e.code)&&(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(n),r.signal?.aborted&&r.signal.reason===t||e.setStatus({code:2,message:n.message})}async function l(e,t){let{name:r,context:n,...a}=e,i=o()?.tracer;if(!i)return t();let s=async e=>{try{return await t(e)}catch(t){throw u(e,t,a),t}finally{e.end()}};return n?i.startActiveSpan(r,a,n,s):i.startActiveSpan(r,a,s)}async function c(e,t){let r=o();if(!e||!r)return t();let n=r.trace.setSpan(r.context.active(),e);return r.context.with(n,t)}function p(e){return!!e&&"object"==typeof e&&"next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator]}let d=Symbol.for("asyncDispose"),h=Symbol.asyncDispose??d;class f{#e=!1;#t=!1;#r;#n;constructor(e,t){this.#r=t,this.#n=function(e){let t=Promise.resolve();return function(){for(var r=arguments.length,n=Array(r),a=0;a{}).then(()=>e(...n))}}(async()=>{if(this.#e)return{done:!0,value:void 0};try{let t=await e();return t.done&&(this.#e=!0),t}catch(e){throw this.#e=!0,e}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#r("next"))}})}next(){return this.#n()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#r("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#r("throw")),e}async [h](){this.#e=!0,this.#t||(this.#t=!0,await this.#r("dispose"))}[Symbol.asyncIterator](){return this}}function m(e,t){let r,{name:n,...a}=e;return new f(async()=>{r??=s(n);try{let e=await c(r,()=>t.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(e){throw u(r,e,a),e}},async e=>{try{"next"!==e&&await c(r,()=>t.return?.())}catch(e){throw u(r,e,a),e}finally{r?.end()}})}function y(e){return async function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),a=1;a{let i=e[a];return i?i({...t,next:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t;return n(e,a+1)}}):r(t)};return n(t,0)}function v(e){if(e)return JSON.parse(e)}function w(e){return JSON.stringify(e)}function E(e){if(!e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function b(e){return!!e&&("object"==typeof e||"function"==typeof e)}function T(e,t){let r=e;for(let e of t){if(!b(r))return;r=r[e]}return r}let x=((t=function(){}).prototype=Object.create(null),Object.freeze(t.prototype),t);function S(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n=400}function P(e){if(!E(e))return!1;let t=["defined","code","status","message","data"];return!Object.keys(e).some(e=>!t.includes(e))&&"defined"in e&&"boolean"==typeof e.defined&&"code"in e&&"string"==typeof e.code&&"status"in e&&"number"==typeof e.status&&k(e.status)&&"message"in e&&"string"==typeof e.message}function C(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new _(e.code,{...t,...e})}R.add(_);class q extends TypeError{}class N extends TypeError{}class D extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}}class U{constructor(e={}){this.options=e}incomplete="";feed(e){this.incomplete+=e;let t=this.incomplete.lastIndexOf("\n\n");if(-1===t)return;let r=this.incomplete.slice(0,t).split(/\n\n/);for(let e of(this.incomplete=this.incomplete.slice(t+2),r)){let t=function(e){let t=e.replace(/\n+$/,"").split(/\n/),r={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(let e of t){let t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),a=-1===t?"":e.slice(t+1).replace(/^\s/,"");if(0===t)r.comments.push(a);else if("data"===n)r.data??="",r.data+=`${a} `;else if("event"===n)r.event=a;else if("id"===n)r.id=a;else if("retry"===n){let e=Number.parseInt(a);Number.isInteger(e)&&e>=0&&e.toString()===a&&(r.retry=e)}}return r.data=r.data?.replace(/\n$/,""),r}(`${e} `);this.options.onEvent&&this.options.onEvent(t)}}end(){if(this.incomplete)throw new N("Event Iterator ended before complete")}}class $ extends TransformStream{constructor(){let e;super({start(t){e=new U({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}}function z(e){if(e.includes("\n"))throw new q("Event's id must not contain a newline character")}function L(e){if(!Number.isInteger(e)||e<0)throw new q("Event's retry must be a integer and >= 0")}function F(e){if(e.includes("\n"))throw new q("Event's comment must not contain a newline character")}function K(e){let t="";if(t+=function(e){let t="";for(let r of e??[])F(r),t+=`: ${r} `;return t}(e.comments),void 0!==e.event){if(e.event.includes("\n"))throw new q("Event's event must not contain a newline character");t+=`event: ${e.event} `}return void 0!==e.retry&&(L(e.retry),t+=`retry: ${e.retry} `),void 0!==e.id&&(z(e.id),t+=`id: ${e.id} `),t+=function(e){let t=e?.split(/\n/)??[],r="";for(let e of t)r+=`data: ${e} `;return r}(e.data),t+="\n"}let j=Symbol("ORPC_EVENT_SOURCE_META");function B(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&z(t.id),void 0!==t.retry&&L(t.retry),void 0!==t.comments)for(let e of t.comments)F(e);return new Proxy(e,{get:(e,r,n)=>r===j?t:Reflect.get(e,r,n)})}function M(e){return b(e)?Reflect.get(e,j):void 0}function G(e,t){let r={...e};for(let e in t)Array.isArray(t[e])?r[e]=[...n(r[e]),...t[e]]:void 0!==t[e]&&(Array.isArray(r[e])?r[e]=[...r[e],t[e]]:void 0!==r[e]?r[e]=[r[e],t[e]]:r[e]=t[e]);return r}function Q(e,t){let r=async e=>{let r=await t.error(e);if(r!==e){let t=M(e);t&&b(r)&&(r=B(r,t))}return r};return new f(async()=>{let{done:n,value:a}=await (async()=>{try{return await e.next()}catch(e){throw await r(e)}})(),i=await t.value(a,n);if(i!==a){let e=M(a);e&&b(i)&&(i=B(i,e))}return{done:n,value:i}},async()=>{try{await e.return?.()}catch(e){throw await r(e)}})}function V(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.path??[];return function e(t){return new Proxy(t,{get(t,r,n){let a=Reflect.get(t,r,n);return"then"!==r||"function"!=typeof a?a:new Proxy(a,{apply(r,n,a){if(2!==a.length||a.some(e=>{var t;return!("function"==typeof(t=e)&&A.test(t.toString()))}))return Reflect.apply(r,n,a);let i=!0;a[0].call(n,e(new Proxy(t,{get:(e,t,r)=>{if(i&&"then"===t){i=!1;return}return Reflect.get(e,t,r)}})))}})}})}(new Proxy(async function(){for(var t=arguments.length,n=Array(t),a=0;a"string"!=typeof a?Reflect.get(n,a):V(e,{...t,path:[...r,a]})}))}function W(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.forEach((e,r)=>{Array.isArray(t[r])?t[r].push(e):void 0!==t[r]?t[r]=[t[r],e]:t[r]=e}),t}class J{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(let t of this.plugins)t.init?.(e)}}class H{constructor(e,t,r={}){this.codec=e,this.sender=t,new J(r.plugins).init(r),this.interceptors=n(r.interceptors),this.clientInterceptors=n(r.clientInterceptors)}interceptors;clientInterceptors;call(e,t,r){return l({name:`${a}.${e.join("/")}`,signal:r.signal},n=>(n?.setAttribute("rpc.system",a),n?.setAttribute("rpc.method",e.join(".")),p(t)&&(t=m({name:"consume_event_iterator_input",signal:r.signal},t)),g(this.interceptors,{...r,path:e,input:t},async e=>{let t,{path:r,input:a,...i}=e,s=o(),u=s?.trace.getActiveSpan()??n;u&&s&&(t=s?.trace.setSpan(s.context.active(),u));let c=await l({name:"encode_request",context:t},()=>this.codec.encode(r,a,i)),d=await g(this.clientInterceptors,{...i,input:a,path:r,request:c},e=>{let{input:r,path:n,request:a,...i}=e;return l({name:"send_request",signal:i.signal,context:t},()=>this.sender.call(a,i,n,r))}),h=await l({name:"decode_response",context:t},()=>this.codec.decode(d,i,r,a));return p(h)?m({name:"consume_event_iterator_output",signal:i.signal},h):h})))}}function Y(e){return`/${e.map(encodeURIComponent).join("/")}`}class X extends J{initRuntimeAdapter(e){for(let t of this.plugins)t.initRuntimeAdapter?.(e)}}class Z{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new X(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=n(e.adapterInterceptors)}async call(e,t,r,n){let a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Headers;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let e of n)t.append(r,e);else void 0!==n&&t.append(r,n);return t}(e.headers),n=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.get("content-disposition");if(t.delete("content-type"),t.delete("content-disposition"),void 0!==e){if(e instanceof Blob){var a;let r,i;return t.set("content-type",e.type),t.set("content-length",e.size.toString()),t.set("content-disposition",n??(r=(a=e instanceof File?e.name:"blob").replace(/"/g,'\\"'),i=encodeURIComponent(a).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16))),`inline; filename="${r}"; filename*=utf-8''${i}`)),e}return e instanceof FormData||e instanceof URLSearchParams?e:p(e)?(t.set("content-type","text/event-stream"),function(e){let t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.eventIteratorKeepAliveEnabled??!0,i=n.eventIteratorKeepAliveInterval??5e3,o=n.eventIteratorKeepAliveComment??"",l=n.eventIteratorInitialCommentEnabled??!0,p=n.eventIteratorInitialComment??"",d=!1;return new ReadableStream({start(e){r=s("stream_event_iterator"),l&&e.enqueue(K({comments:[p]}))},async pull(n){try{a&&(t=setInterval(()=>{n.enqueue(K({comments:[o]})),r?.addEvent("keepalive")},i));let s=await c(r,()=>e.next());if(clearInterval(t),d)return;let u=M(s.value);if(!s.done||void 0!==s.value||void 0!==u){let e=s.done?"done":"message";n.enqueue(K({...u,event:e,data:w(s.value)})),r?.addEvent(e)}s.done&&(n.close(),r?.end())}catch(e){if(clearInterval(t),d)return;e instanceof D?(n.enqueue(K({...M(e),event:"error",data:w(e.data)})),r?.addEvent("error"),n.close()):(u(r,e),n.error(e)),r?.end()}},async cancel(){try{d=!0,clearInterval(t),r?.addEvent("cancelled"),await c(r,()=>e.return?.())}catch(e){throw u(r,e),e}finally{r?.end()}}}).pipeThrough(new TextEncoderStream)}(e,r)):(t.set("content-type","application/json"),w(e))}}(e.body,r,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:r,body:n})}(e,this.toFetchRequestOptions);return function(e){var t;let r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{body:(t=()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l({name:"parse_standard_body",signal:t.signal},async()=>{let r=e.headers.get("content-disposition");if("string"==typeof r){let t=function(e){let t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&"string"==typeof t[2]){var r=t[2];try{return decodeURIComponent(r)}catch{return r}}let n=e.match(/filename="((?:\\"|[^"])*)"/i);if(n&&"string"==typeof n[1])return n[1].replace(/\\"/g,'"')}(r)??"blob",n=await e.blob();return new File([n],t,{type:n.type})}let n=e.headers.get("content-type");if(!n||n.startsWith("application/json"))return v(await e.text());if(n.startsWith("multipart/form-data"))return await e.formData();if(n.startsWith("application/x-www-form-urlencoded"))return new URLSearchParams(await e.text());if(n.startsWith("text/event-stream"))return function(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e?.pipeThrough(new TextDecoderStream).pipeThrough(new $),a=n?.getReader(),o=!1;return new f(async()=>{t??=s("consume_event_iterator_stream");try{for(;;){if(void 0===a)return{done:!0,value:void 0};let{done:e,value:r}=await c(t,()=>a.read());if(e){if(o)throw new i("Stream was cancelled");return{done:!0,value:void 0}}switch(r.event){case"message":{let e=v(r.data);return b(e)&&(e=B(e,r)),t?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new D({data:v(r.data)});throw e=B(e,r),t?.addEvent("error"),e}case"done":{let e=v(r.data);return b(e)&&(e=B(e,r)),t?.addEvent("done"),{done:!0,value:e}}default:t?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof D||u(t,e,r),e}},async e=>{try{"next"!==e&&(o=!0,t?.addEvent("cancelled")),await c(t,()=>a?.cancel())}catch(e){throw u(t,e,r),e}finally{t?.end()}})}(e.body,t);if(n.startsWith("text/plain"))return await e.text();let a=await e.blob();return new File([a],"blob",{type:a.type})})})(e,n),()=>{if(r)return r.result;let e=t();return r={result:e},e}),status:e.status,get headers(){let t=W(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(value){Object.defineProperty(this,"headers",{value,writable:!0})}}}(await g(this.adapterInterceptors,{...t,request:a,path:r,input:n,init:{redirect:"manual"}},e=>{let{request:t,path:r,input:n,init:a,...i}=e;return this.fetch(t,a,i,r,n)}),{signal:a.signal})}}class ee{"~orpc";constructor(e){if(e.route?.successStatus&&k(e.route.successStatus))throw Error("[ContractProcedure] Invalid successStatus.");if(Object.values(e.errorMap).some(e=>e&&e.status&&!k(e.status)))throw Error("[ContractProcedure] Invalid error status code.");this["~orpc"]=e}}function et(e){return e instanceof ee||("object"==typeof e||"function"==typeof e)&&null!==e&&"~orpc"in e&&"object"==typeof e["~orpc"]&&null!==e["~orpc"]&&"errorMap"in e["~orpc"]&&"route"in e["~orpc"]&&"meta"in e["~orpc"]}class er extends ee{constructor(e){super(e),this["~orpc"].prefix=e.prefix,this["~orpc"].tags=e.tags}$meta(e){return new er({...this["~orpc"],meta:e})}$route(e){return new er({...this["~orpc"],route:e})}$input(e){return new er({...this["~orpc"],inputSchema:e})}errors(e){var t;return new er({...this["~orpc"],errorMap:(t=this["~orpc"].errorMap,{...t,...e})})}meta(e){var t;return new er({...this["~orpc"],meta:(t=this["~orpc"].meta,{...t,...e})})}route(e){var t;return new er({...this["~orpc"],route:(t=this["~orpc"].route,{...t,...e})})}input(e){return new er({...this["~orpc"],inputSchema:e})}output(e){return new er({...this["~orpc"],outputSchema:e})}prefix(e){var t;return new er({...this["~orpc"],prefix:(t=this["~orpc"].prefix,t?`${t}${e}`:e)})}tag(){for(var e,t=arguments.length,r=Array(t),n=0;nn?{value:await n(e)}:{value:e}}}}Symbol("ORPC_EVENT_ITERATOR_DETAILS");class es{maxArrayIndex;constructor(e={}){this.maxArrayIndex=e.maxBracketNotationArrayIndex??9999}serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(Array.isArray(e))e.forEach((e,n)=>{this.serialize(e,[...t,n],r)});else if(E(e))for(let n in e)this.serialize(e[n],[...t,n],r);else r.push([this.stringifyPath(t),e]);return r}deserialize(e){if(0===e.length)return{};let t=new WeakSet,r={value:[]};for(let[n,a]of e){let e=this.parsePath(n),i=r,o="value";e.forEach((r,n)=>{Array.isArray(i[o])||E(i[o])||(i[o]=[]),n!==e.length-1?Array.isArray(i[o])&&!eu(r,this.maxArrayIndex)&&(t.has(i[o])?(t.delete(i[o]),i[o]=ec(i[o])):i[o]=el(i[o])):Array.isArray(i[o])&&(""===r?i[o].length&&!t.has(i[o])&&(i[o]=el(i[o])):t.has(i[o])?(t.delete(i[o]),i[o]=ec(i[o])):eu(r,this.maxArrayIndex)||(i[o]=el(i[o]))),i=i[o],o=r}),Array.isArray(i)&&""===o?(t.add(i),i.push(a)):o in i?Array.isArray(i[o])?i[o].push(a):i[o]=[i[o],a]:i[o]=a}return r.value}stringifyPath(e){return e.map(e=>e.toString().replace(/[\\[\]]/g,e=>{switch(e){case"\\":return"\\\\";case"[":return"\\[";case"]":return"\\]";default:return e}})).reduce((e,t,r)=>0===r?t:`${e}[${t}]`,"")}parsePath(e){let t=[],r=!1,n="",a=0;for(let i=0;i{t[r]=e}),t}function ec(e){let t=new x;return t[""]=1===e.length?e[0]:e,t}class ep{customSerializers;constructor(e={}){this.customSerializers=e.customJsonSerializers??[]}serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{value:!1};for(let r of this.customSerializers)if(r.condition(e))return this.serialize(r.serialize(e),t);if(e instanceof Blob)return t.value=!0,[e,t.value];if(e instanceof Set)return this.serialize(Array.from(e),t);if(e instanceof Map)return this.serialize(Array.from(e.entries()),t);if(Array.isArray(e))return[e.map(e=>void 0===e?null:this.serialize(e,t)[0]),t.value];if(E(e)){let r={};for(let n in e)("toJSON"!==n||"function"!=typeof e[n])&&(r[n]=this.serialize(e[n],t)[0]);return[r,t.value]}return"bigint"==typeof e||e instanceof RegExp||e instanceof URL?[e.toString(),t.value]:e instanceof Date?[Number.isNaN(e.getTime())?null:e.toISOString(),t.value]:Number.isNaN(e)?[null,t.value]:[e,t.value]}}function ed(e){return`/${e.replace(/\/{2,}/g,"/").replace(/^\/|\/$/g,"")}`}function eh(e){return e?ed(e).match(/\/\{[^}]+\}/g)?.map(e=>({raw:e,name:e.match(/\{\+?([^}]+)\}/)[1]})):void 0}class ef{constructor(e,t,r){this.contract=e,this.serializer=t,this.baseUrl=r.url,this.headers=r.headers??{},this.customErrorResponseBodyDecoder=r.customErrorResponseBodyDecoder}baseUrl;headers;customErrorResponseBodyDecoder;async encode(e,t,r){var n;let a="function"==typeof(n=await S(this.headers,r,e,t)).forEach?W(n):n;void 0!==r.lastEventId&&(a=G(a,{"last-event-id":r.lastEventId}));let i=await S(this.baseUrl,r,e,t),o=T(this.contract,e);if(!et(o))throw Error(`[StandardOpenapiLinkCodec] expect a contract procedure at ${e.join(".")}`);return"compact"===ei("defaultInputStructure",o["~orpc"].route.inputStructure)?this.#a(o,e,t,r,i,a):this.#i(o,e,t,r,i,a)}#a(e,t,r,n,a,i){let o=ed(e["~orpc"].route.path??Y(t)),s=r,u=eh(o);if(u?.length){if(!E(r))throw TypeError(`[StandardOpenapiLinkCodec] Invalid input shape for "compact" structure when has dynamic params at ${t.join(".")}.`);let e={...r};for(let t of u){let n=r[t.name];o=o.replace(t.raw,`/${encodeURIComponent(`${this.serializer.serialize(n)}`)}`),delete e[t.name]}s=Object.keys(e).length?e:void 0}let l=ei("defaultMethod",e["~orpc"].route.method),c=new URL(a);if(c.pathname=`${c.pathname.replace(/\/$/,"")}${o}`,"GET"===l){for(let[e,t]of this.serializer.serialize(s,{outputFormat:"URLSearchParams"}))c.searchParams.append(e,t);return{url:c,method:l,headers:i,body:void 0,signal:n.signal}}return{url:c,method:l,headers:i,body:this.serializer.serialize(s),signal:n.signal}}#i(e,t,r,n,a,i){let o=ed(e["~orpc"].route.path??Y(t)),s=eh(o);if(!E(r)&&void 0!==r)throw TypeError(`[StandardOpenapiLinkCodec] Invalid input shape for "detailed" structure at ${t.join(".")}.`);if(s?.length){if(!E(r?.params))throw TypeError(`[StandardOpenapiLinkCodec] Invalid input.params shape for "detailed" structure when has dynamic params at ${t.join(".")}.`);for(let e of s){let t=r.params[e.name];o=o.replace(e.raw,`/${encodeURIComponent(`${this.serializer.serialize(t)}`)}`)}}let u=i;if(r?.headers!==void 0){if(!E(r.headers))throw TypeError(`[StandardOpenapiLinkCodec] Invalid input.headers shape for "detailed" structure at ${t.join(".")}.`);u=G(r.headers,i)}let l=ei("defaultMethod",e["~orpc"].route.method),c=new URL(a);if(c.pathname=`${c.pathname.replace(/\/$/,"")}${o}`,r?.query!==void 0)for(let[e,t]of this.serializer.serialize(r.query,{outputFormat:"URLSearchParams"}))c.searchParams.append(e,t);return"GET"===l?{url:c,method:l,headers:u,body:void 0,signal:n.signal}:{url:c,method:l,headers:u,body:this.serializer.serialize(r?.body),signal:n.signal}}async decode(e,t,r){let n=!k(e.status),a=await (async()=>{let t=!1;try{let r=await e.body();return t=!0,this.serializer.deserialize(r)}catch(e){if(!t)throw Error("Cannot parse response body, please check the response body and content-type.",{cause:e});throw Error("Invalid OpenAPI response format.",{cause:e})}})();if(!n){var i;let t=this.customErrorResponseBodyDecoder?.(a,e);if(null!=t)throw t;if(P(a))throw C(a);throw new _((i=e.status,Object.entries(O).find(e=>{let[,t]=e;return t.status===i})?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:a}})}let o=T(this.contract,r);if(!et(o))throw Error(`[StandardOpenapiLinkCodec] expect a contract procedure at ${r.join(".")}`);return"compact"===ei("defaultOutputStructure",o["~orpc"].route.outputStructure)?a:{status:e.status,headers:e.headers,body:a}}}class em{constructor(e,t){this.jsonSerializer=e,this.bracketNotation=t}serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(e)&&!t.outputFormat?Q(e,{value:async e=>this.#o(e,{outputFormat:"plain"}),error:async e=>new D({data:this.#o((e instanceof _?e:new _("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:e})).toJSON(),{outputFormat:"plain"}),cause:e})}):this.#o(e,t)}#o(e,t){let[r,n]=this.jsonSerializer.serialize(e);if("plain"===t.outputFormat)return r;if("URLSearchParams"===t.outputFormat){let e=new URLSearchParams;for(let[t,n]of this.bracketNotation.serialize(r))("string"==typeof n||"number"==typeof n||"boolean"==typeof n)&&e.append(t,n.toString());return e}if(r instanceof Blob||void 0===r||!n)return r;let a=new FormData;for(let[e,t]of this.bracketNotation.serialize(r))"string"==typeof t||"number"==typeof t||"boolean"==typeof t?a.append(e,t.toString()):t instanceof Blob&&a.append(e,t);return a}deserialize(e){return e instanceof URLSearchParams||e instanceof FormData?this.bracketNotation.deserialize(Array.from(e.entries())):p(e)?Q(e,{value:async e=>e,error:async e=>e instanceof D&&P(e.data)?C(e.data,{cause:e}):e}):e}}class ey extends H{constructor(e,t,r){super(new ef(e,new em(new ep(r),new es({maxBracketNotationArrayIndex:0xfffffffe})),r),t,r)}}class eg extends ey{constructor(e,t){super(e,new Z(t),t)}}var ev,ew=e.i(766271);function eE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return[e,{...void 0!==t.input?{input:t.input}:{},...void 0!==t.type?{type:t.type}:{},...void 0!==t.fnOptions?{fnOptions:t.fnOptions}:{}}]}function eb(e,t){return e.length<=t?e:e.slice(e.length-t)}let eT=Symbol("ORPC_OPERATION_CONTEXT");function ex(e){var t;let r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n(a.path),o={key:e=>eE(i,e)},s=(t={path:i,experimental_defaults:a.experimental_defaults},r={call:e,queryKey(){for(var e=arguments.length,r=Array(e),n=0;n{let{signal:r}=t;if(o.input===ew.skipToken)throw Error("queryFn should not be called with skipToken used as input");return e(o.input,{signal:r,context:{[eT]:{key:s,type:"query"},...o.context}})},...o.input===ew.skipToken?{enabled:!1}:{},...o,queryKey:s}},experimental_streamedKey(){for(var e=arguments.length,r=Array(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:{};return async n=>{let a=n.client.getQueryCache().find({queryKey:n.queryKey,exact:!0}),i=!!a&&void 0!==a.state.data;i&&("reset"===t?a.setState({status:"pending",data:void 0,error:null,fetchStatus:"fetching"}):n.client.setQueryData(n.queryKey,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return eb(e,r)}));let o=[],s=await e(n),u=!i||"replace"!==t;for await(let e of(n.client.setQueryData(n.queryKey,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return eb(e,r)}),s)){if(n.signal.aborted)throw n.signal.reason;o.push(e),o=eb(o,r),u&&n.client.setQueryData(n.queryKey,function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return eb([...t,e],r)})}u||n.client.setQueryData(n.queryKey,o);let l=n.client.getQueryData(n.queryKey);return l?eb(l,r):o}}(async t=>{let{signal:r}=t;if(o.input===ew.skipToken)throw Error("queryFn should not be called with skipToken used as input");let n=await e(o.input,{signal:r,context:{[eT]:{key:s,type:"streamed"},...o.context}});if(!p(n))throw Error("streamedQuery requires an event iterator output");return n},o.queryFnOptions),...o.input===ew.skipToken?{enabled:!1}:{},...o,queryKey:s}},experimental_liveKey(){for(var e=arguments.length,r=Array(e),n=0;n{let{signal:r}=t;if(s.input===ew.skipToken)throw Error("queryFn should not be called with skipToken used as input");let n=await e(s.input,{signal:r,context:{[eT]:{key:u,type:"live"},...s.context}});if(!p(n))throw Error("liveQuery requires an event iterator output");return n},async e=>{let t;for await(let r of(await n(e))){if(e.signal.aborted)throw e.signal.reason;t={chunk:r},e.client.setQueryData(e.queryKey,r)}if(!t)throw Error(`Live query for ${w(e.queryKey)} did not yield any data. Ensure the query function returns an AsyncIterable with at least one chunk.`);return t.chunk}),...s.input===ew.skipToken?{enabled:!1}:{},...s,queryKey:u}},infiniteKey:e=>(e={...t.experimental_defaults?.infiniteKey,...e}).queryKey??eE(t.path,{type:"infinite",input:e.input===ew.skipToken?ew.skipToken:e.input(e.initialPageParam)}),infiniteOptions(n){n={...t.experimental_defaults?.infiniteOptions,...n};let a=r.infiniteKey(n);return{queryFn:t=>{let{pageParam:r,signal:i}=t;if(n.input===ew.skipToken)throw Error("queryFn should not be called with skipToken used as input");return e(n.input(r),{signal:i,context:{[eT]:{key:a,type:"infinite"},...n.context}})},...n.input===ew.skipToken?{enabled:!1}:{},...n,queryKey:a}},mutationKey(){for(var e=arguments.length,r=Array(e),n=0;ne(t,{context:{[eT]:{key:s,type:"mutation"},...o.context}}),...o,mutationKey:s}}});return new Proxy({...o,...s},{get(t,r){let n=Reflect.get(t,r);if("string"!=typeof r)return n;let o=ex(e[r],{...a,path:[...i,r],experimental_defaults:T(a.experimental_defaults,[r])});return"function"!=typeof n?o:new Proxy(n,{get:(e,t)=>Reflect.get(o,t)})}})}var eS=e.i(925521);let eA=en.$route({inputStructure:"detailed"}),eO=eA.route({path:"/apps/{appId}",method:"DELETE"}).input(eo()).output(eo()),eI=eA.route({path:"/billing/invoices",method:"GET"}).input(eo()).output(eo()),eR=eA.route({path:"/billing/partners/{partnerKey}/tenants",method:"PUT"}).input(eo()).output(eo()),e_=eA.route({path:"/explore/apps",method:"GET"}).input(eo()).output(eo()),ek=eA.route({path:"/explore/apps/{id}",method:"GET"}).input(eo()).output(eo()),eP=eA.route({path:"/installed-apps",method:"GET"}).input(eo()).output(eo()),eC=eA.route({path:"/installed-apps/{id}",method:"DELETE"}).input(eo()).output(eo()),eq=eA.route({path:"/installed-apps/{id}",method:"PATCH"}).input(eo()).output(eo()),eN=eA.route({path:"/enterprise/webapp/app/access-mode",method:"GET"}).input(eo()).output(eo()),eD=eA.route({path:"/installed-apps/{appId}/parameters",method:"GET"}).input(eo()).output(eo()),eU=eA.route({path:"/installed-apps/{appId}/meta",method:"GET"}).input(eo()).output(eo()),e$=eA.route({path:"/explore/banners",method:"GET"}).input(eo()).output(eo()),ez=eA.route({path:"/notification",method:"GET"}).output(eo()),eL=eA.route({path:"/notification/dismiss",method:"POST"}).input(eo()).output(eo()),eF=eA.route({path:"/system-features",method:"GET"}).input(eo()).output(eo()),eK=eA.route({path:"/workspaces/current/triggers",method:"GET"}).input(eo()).output(eo()),ej=eA.route({path:"/workspaces/current/trigger-provider/{provider}/info",method:"GET"}).input(eo()).output(eo()),eB=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/list",method:"GET"}).input(eo()).output(eo()),eM=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/builder/create",method:"POST"}).input(eo()).output(eo()),eG=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/builder/update/{subscriptionBuilderId}",method:"POST"}).input(eo()).output(eo()),eQ=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/builder/verify-and-update/{subscriptionBuilderId}",method:"POST"}).input(eo()).output(eo()),eV=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/verify/{subscriptionId}",method:"POST"}).input(eo()).output(eo()),eW=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/builder/build/{subscriptionBuilderId}",method:"POST"}).input(eo()).output(eo()),eJ=eA.route({path:"/workspaces/current/trigger-provider/{subscriptionId}/subscriptions/delete",method:"POST"}).input(eo()).output(eo()),eH=eA.route({path:"/workspaces/current/trigger-provider/{subscriptionId}/subscriptions/update",method:"POST"}).input(eo()).output(eo()),eY=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/builder/logs/{subscriptionBuilderId}",method:"GET"}).input(eo()).output(eo()),eX=eA.route({path:"/workspaces/current/trigger-provider/{provider}/oauth/client",method:"GET"}).input(eo()).output(eo()),eZ=eA.route({path:"/workspaces/current/trigger-provider/{provider}/oauth/client",method:"POST"}).input(eo()).output(eo()),e0=eA.route({path:"/workspaces/current/trigger-provider/{provider}/oauth/client",method:"DELETE"}).input(eo()).output(eo()),e1=eA.route({path:"/workspaces/current/trigger-provider/{provider}/subscriptions/oauth/authorize",method:"GET"}).input(eo()).output(eo()),e2=eA.route({path:"/trial-apps/{appId}",method:"GET"}).input(eo()).output(eo()),e4=eA.route({path:"/trial-apps/{appId}/datasets",method:"GET"}).input(eo()).output(eo()),e9=eA.route({path:"/trial-apps/{appId}/workflows",method:"GET"}).input(eo()).output(eo()),e5=eA.route({path:"/trial-apps/{appId}/parameters",method:"GET"}).input(eo()).output(eo()),e6=eA.route({path:"/collections",method:"GET"}).input(eo()).output(eo()),e3=eA.route({path:"/collections/{collectionId}/plugins",method:"POST"}).input(eo()).output(eo()),e7=eA.route({path:"/{kind}/search/advanced",method:"POST"}).input(eo()).output(eo());var e8=e.i(772870),te=e.i(367916);function tt(e){try{return new URL(e),!0}catch{return!1}}let tr=V(new eg({collections:e6,collectionPlugins:e3,searchAdvanced:e7},{url:eS.MARKETPLACE_API_PREFIX,headers:()=>new Headers({"X-Dify-Version":eS.IS_MARKETPLACE?"999.0.0":eS.APP_VERSION}),fetch:(e,t)=>globalThis.fetch(e,{...t,cache:"no-store"}),interceptors:[y(e=>{console.error(e)})]})),tn=ex(tr,{path:["marketplace"]}),ta=V(new eg({systemFeatures:eF,apps:{deleteApp:eO},explore:{apps:e_,appDetail:ek,installedApps:eP,uninstallInstalledApp:eC,updateInstalledApp:eq,appAccessMode:eN,installedAppParameters:eD,installedAppMeta:eU,banners:e$},trialApps:{info:e2,datasets:e4,parameters:e5,workflows:e9},billing:{invoices:eI,bindPartnerStack:eR},notification:ez,notificationDismiss:eL,triggers:{list:eK,providerInfo:ej,subscriptions:eB,subscriptionBuilderCreate:eM,subscriptionBuilderUpdate:eG,subscriptionBuilderVerifyUpdate:eQ,subscriptionVerify:eV,subscriptionBuild:eW,subscriptionDelete:eJ,subscriptionUpdate:eH,subscriptionBuilderLogs:eY,oauthConfig:eX,oauthConfigure:eZ,oauthDelete:e0,oauthInitiate:e1}},{url:(r=new URL(ev=eS.API_PREFIX,tt(ev)?void 0:e8.isClient?window.location.origin:"http://localhost"),e8.isClient||tt(ev)||console.warn("Using localhost as base URL in server environment, please configure accordingly."),"http:"!==r.protocol&&"https:"!==r.protocol&&console.warn(`Unexpected protocol for API requests, expected http or https. Current protocol: ${r.protocol}. Please configure accordingly.`),r),fetch:(e,t)=>(0,te.request)(e.url,t,{fetchCompat:!0,request:e}),interceptors:[y(e=>{console.error(e)})]})),ti=ex(ta,{path:["console"]});e.s(["consoleClient",0,ta,"consoleQuery",0,ti,"marketplaceClient",0,tr,"marketplaceQuery",0,tn],10190)}]);