directus-extension-docuberry 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,185 @@
1
- # Temporary Holding Version
1
+ # Docuberry for Directus
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Generate a [Docuberry](https://docuberry.com) PDF from a Directus item, preview it on the item page, and store it in Directus Files.
4
+
5
+ The bundle contains:
6
+
7
+ - **Generate PDF (Docuberry)** — a Flow operation. It loads the item (and related collections), renders the PDF, uploads it to Directus Files, and sets a file or files field.
8
+ - **Docuberry PDF** — an interface for the item form. Preview shows the PDF inline. Save PDF stores it on the configured file field.
9
+ - **Docuberry template** — a template picker used by the operation and the interface.
10
+ - **`/docuberry`** — an endpoint the app bundle calls. The browser never sees the API key.
11
+
12
+ Package name: `directus-extension-docuberry`.
13
+
14
+ ## Install
15
+
16
+ Build the bundle, then give Directus the folder.
17
+
18
+ ```bash
19
+ git clone https://github.com/onix2582/docuberry-directus-extension.git
20
+ cd docuberry-directus-extension
21
+ npm install
22
+ npm run build
23
+ ```
24
+
25
+ Copy this folder to your extensions directory (it must contain `package.json` and `dist/`):
26
+
27
+ ```bash
28
+ cp -R docuberry-directus-extension /directus/extensions/directus-extension-docuberry
29
+ ```
30
+
31
+ Docker Compose:
32
+
33
+ ```yaml
34
+ services:
35
+ directus:
36
+ image: directus/directus:12
37
+ environment:
38
+ DOCUBERRY_API_KEY: ${DOCUBERRY_API_KEY}
39
+ DOCUBERRY_API_URL: https://api.docuberry.com
40
+ PUBLIC_URL: https://cms.example.com
41
+ volumes:
42
+ - ./docuberry-directus-extension:/directus/extensions/directus-extension-docuberry
43
+ ```
44
+
45
+ From npm, once the package is published (this repo does not publish it):
46
+
47
+ ```bash
48
+ npm install directus-extension-docuberry
49
+ ```
50
+
51
+ Restart Directus. In **Settings → Extensions**, enable the bundle if it is not already enabled.
52
+
53
+ ### Marketplace
54
+
55
+ The package has the Marketplace metadata Directus asks for: `description`, `icon`, `license`, `homepage`, `repository`, `bugs`, and the keywords `directus-extension` and `directus-custom-bundle`.
56
+
57
+ Directus 12.7 does **not** run this bundle inside the Marketplace sandbox. `MARKETPLACE_TRUST` defaults to `sandbox`, and the Marketplace only offers sandboxed extensions in that mode. To install this bundle from the Marketplace, set:
58
+
59
+ ```
60
+ MARKETPLACE_TRUST=all
61
+ ```
62
+
63
+ Copying the folder in, or installing the npm package, does not use that setting. Details are in [Sandbox](#sandbox).
64
+
65
+ ## Configuration
66
+
67
+ Set these on the Directus process. Do not put the API key in a Flow, a field, or item data.
68
+
69
+ | Variable | Required | Purpose |
70
+ | --- | --- | --- |
71
+ | `DOCUBERRY_API_KEY` | Yes | Docuberry secret (`dbk_…`). Used only by the operation and the `/docuberry` endpoint. |
72
+ | `DOCUBERRY_API_URL` | No | API origin. Defaults to `https://api.docuberry.com`. |
73
+ | `PUBLIC_URL` | Recommended | Public origin of Directus, such as `https://cms.example.com`. Used to build image links for file fields. If it is unset, the origin of the request is used (Preview and Save PDF). Flows have no request, so set it for Flows. |
74
+
75
+ `DOCUBERRY_API_URL` must be an `https` origin. `http` is accepted only for `localhost`, `127.0.0.1`, and `host.docker.internal`, so a local API can be used from Docker. Credentials, paths, and private IP literals are rejected.
76
+
77
+ You do **not** need `FLOWS_ENV_ALLOW_LIST`. The extension reads the key from the server environment. It is not an operation option, so it is not stored in the flow.
78
+
79
+ ## What is sent to Docuberry
80
+
81
+ Preview, Save PDF, and the Flow operation send item fields to the host above (`api.docuberry.com` unless you override it). The PDF is then stored in Directus Files.
82
+
83
+ Related collections are included up to **relation depth** (default **2**, same idea as the Airtable extension, maximum 4):
84
+
85
+ - depth 0 — the item’s own fields
86
+ - depth 1 — one hop, such as invoice → customer
87
+ - depth 2 — two hops, such as invoice → lines → product, invoice → customer → country, a many-to-many tag, a many-to-any block, and translations
88
+
89
+ When the template’s field list loads (`GET /api/v1/templates/:id`), only those paths are sent. Many-to-many and many-to-any values are unwrapped to the related item (a tag’s `name`, a block’s fields) so the template can use the same paths you would write by hand. If the field list cannot be loaded, the item and its relations up to the chosen depth are sent, and the item page says so.
90
+
91
+ Directus applies the caller’s permissions. A role that cannot read `customer.secret` does not send that value. A Flow uses the triggering user’s accountability when Directus provides one. A schedule, or a webhook with no user, runs as the system user and can read everything that user can read — do not expose that flow publicly.
92
+
93
+ The result returned to the next Flow step includes the file id, item id, filename, and any per-item errors. It does not include the JSON body that was sent.
94
+
95
+ Privacy policy: https://docuberry.com/privacy
96
+
97
+ ### Images and rich text
98
+
99
+ - **File and image fields** are sent as a full asset link: `{{hero_image}}` is `https://cms.example.com/assets/<id>`. Use it as the **Dynamic Image** source of an Image element. `{{hero_image_id}}` is the original file id, and `{{hero_image_file.title}}` (or any other file property, plus `url`) reads the file record. A many-to-many files field becomes a list of links, with the records under `<field>_files`. The field that stores the PDF is never rewritten.
100
+ - Docuberry fetches the image from that link, so the Directus **Public** role (or the file's access) must allow reading the file.
101
+ - **HTML** (a WYSIWYG field, for example) is sent as plain text: block tags and `<br>` become line breaks, list items become bullets, entities such as `&amp;` are decoded. Docuberry text blocks escape HTML, so this is what reads well in a text block.
102
+
103
+ ## Flow example
104
+
105
+ An invoice has a customer (many-to-one), lines (one-to-many) each with a product, and a single file field `pdf`.
106
+
107
+ 1. Create a flow.
108
+ 2. Trigger: **Event Hook**, scope **items.create** and **items.update**, collection `invoices`. Collections must be selected; the trigger payload for an update is only the changed fields, and the operation loads the full item by key.
109
+ 3. Operation: **Generate PDF (Docuberry)**
110
+ - Template: your invoice template
111
+ - Collection: empty (uses the trigger)
112
+ - Item keys: empty (uses `$trigger.key` / `$trigger.keys`)
113
+ - Payload: empty (loads the item)
114
+ - Fields: empty (uses the template’s paths)
115
+ - Relation depth: `2`
116
+ - File field: `pdf`
117
+ - Filename: `{template} {number}`
118
+ - Replace existing files: on
119
+ 4. The operation returns `{ fileId, itemId, filename, saved, failed, errors, results }`. A later step can use `{{$last.fileId}}`.
120
+
121
+ `{template}`, `{id}`, `{collection}`, and `{field.path}` are filled in by the extension. They are single braces so Directus does not treat them as its own `{{ }}` variables. You can still use Directus variables for the collection, the keys, or the whole payload (`{{$trigger.collection}}`, `{{$last}}`).
122
+
123
+ To render many items, pass a list of keys (`{{$trigger.keys}}` or a comma-separated list) or a JSON array payload. One object payload renders once and links that file to each key. At most **50** items are processed, one after another. The operation cannot be cancelled mid-run; turn **Continue when an item fails** on to keep going and read `errors` afterwards.
124
+
125
+ **Replace existing files** on a single file field replaces the file and deletes the previous one. Turn it off to skip an item that already has a file. On a files field, on replaces the list, and off appends.
126
+
127
+ ## Item page
128
+
129
+ Add a field, or open an existing file field, and set the interface to **Docuberry PDF**.
130
+
131
+ - Put it on the file field and leave **File field** empty, or put it on a presentation field and set **File field** to `pdf`.
132
+ - Choose the template and a relation depth.
133
+ - Save the item first. Preview and Save PDF stay disabled on a new, unsaved item.
134
+ - Preview fetches the PDF through `/docuberry/preview` and shows it in the page.
135
+ - Save PDF uploads the file and sets the field. On a single file field the form value updates, so a later save of the form does not put the old file back. On a files field, refresh the item before saving the form again.
136
+
137
+ The interface tells you which template paths will be sent.
138
+
139
+ ## Permissions
140
+
141
+ The signed-in user (and the user who triggers a flow) needs:
142
+
143
+ - read the collection and the related collections you expect in the PDF
144
+ - read the template paths you rely on
145
+ - create `directus_files`
146
+ - update the item, including the file field
147
+
148
+ The `/docuberry` routes require a signed-in user or an admin. A public role cannot spend the server’s Docuberry key.
149
+
150
+ ## Sandbox
151
+
152
+ Directus 12.7’s Marketplace sandbox cannot host this extension’s API.
153
+
154
+ The sandbox SDK (`directus:api`) only provides `request`, `log`, and `sleep`. There is no items scope, no files scope, and no environment scope. `request` returns text or JSON, not a PDF body. File import, `DOCUBERRY_API_KEY`, and permission-aware relation queries are outside that sandbox.
155
+
156
+ Bundle entries are also not sandboxed. Directus registers a bundle’s API as a normal Node module and ignores a `sandbox` block on the bundle or its entries (the bundle schema strips that key). Turning `sandbox.enabled` on would claim the code is isolated while it still runs with host services. This package does not do that, and it does not import `directus:api`.
157
+
158
+ What this package does instead:
159
+
160
+ - The API key stays in the Directus environment. The browser calls `/docuberry/*` with the user’s session.
161
+ - PDFs are uploaded with Directus `FilesService` (the bytes never go through a public file URL).
162
+ - Items and relations are read with the caller’s accountability, so role permissions apply.
163
+ - The API origin is limited to `https` (or local `http` for development).
164
+
165
+ Install it by copying the folder, with Docker, or from npm. A Marketplace install needs `MARKETPLACE_TRUST=all`.
166
+
167
+ ## Limits
168
+
169
+ - 50 items per operation.
170
+ - Docuberry’s request body limit is about 1.5 MB and the PDF limit is 8 MB.
171
+ - Filename tokens use `{name}`, not `{{name}}`.
172
+ - Flows are not cancellable while the operation is running.
173
+ - A single file field with **Replace** off is skipped when a file is already stored, and Docuberry is not called.
174
+
175
+ ## Scripts
176
+
177
+ ```bash
178
+ npm run build # npx directus-extension build
179
+ npm run typecheck
180
+ npm run lint
181
+ npm test
182
+ npm run validate
183
+ ```
184
+
185
+ Host compatibility in `package.json` is Directus `^11.1.0 || ^12.0.0`.
package/dist/api.js ADDED
@@ -0,0 +1 @@
1
+ import{Readable as e}from"node:stream";const t=["interface","display","layout","module","panel","theme","richtext"],n=["hook","endpoint"],r=["operation"];function o(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function i(e,t="|"){return e.map(e=>S(e)).join(t)}function s(e,t){return"bigint"==typeof t?t.toString():t}class a{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function c(e){return new a(e)}function u(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function l(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function f(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function d(e){return f(e._zod.def)??e._zod.def.shape}function p(e,t,n){Object.defineProperty(e,t,{get(){const e=n();return l(this,t,e),e},enumerable:!0,configurable:!0})}function h(e,t,n){t in e?l(e,t,n):e[t]=n}function m(e,t,n,r){const o=d(t);for(const i of n){const n=Object.getOwnPropertyDescriptor(o,i);n.enumerable&&(n.get?p(e,i,()=>{const e=t._zod.def.shape[i];return r?r(e,i):e}):h(e,i,r?r(n.value,i):n.value))}}function y(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function g(e){return JSON.stringify(e)}const v="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const b=c(()=>{if(se.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function w(e){if(!1===_(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==_(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function z(e){return w(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const k=new Set(["string","number","symbol"]);function $(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function O(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function j(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function S(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}const x=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),P={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function A(e,t){const n=d(e),r=[];for(const e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw new Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function E(e,t){const n={};return m(n,e,Reflect.ownKeys(d(e))),function(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?p(e,n,()=>t[n]):h(e,n,r.value))}}(n,t),n}function I(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const i=n?new Set(A(t,n)):void 0,s={};return m(s,t,Reflect.ownKeys(d(t)),e&&((t,n)=>i&&!i.has(n)?t:new e({type:"optional",innerType:t}))),O(t,y(t._zod.def,{shape:s,checks:[]}))}function T(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function Z(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function F(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function R(e){return"string"==typeof e?e:e?.message}function N(e){const t=[];for(const n of e??[]){const e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;const r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function U(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function D(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:R(e.inst?._zod.def?.error?.(e))??R(i?.(e))??R(t?.error?.(e))??R(n.customError?.(e))??R(n.localeError?.(e))??"Invalid input",a={};for(const t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}const C=/[\uD800-\uDBFF]/;function J(e){const t=e.length;if(!C.test(e))return t;let n=t;for(let r=0;r<t-1;r++)55296==(64512&e.charCodeAt(r))&&56320==(64512&e.charCodeAt(r+1))&&(n--,r++);return n}function L(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function M(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}function K(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function B(e,t,n){return K(e,t,n,!1)}function W(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return K(this,n,r(this))},set(e){K(this,n,e)}})}return t}function q(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:K(this,t,n.bind(this))},set(e){K(this,t,e)}})}let V,Y=!1;const G={configurable:!0,get(){Y=!0}};function H(e,t,n){const r=Object.getPrototypeOf(e._zod);t in r&&V!==e._zod?V=void 0:(V=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,G);const e=Y;Y=!1;try{const r=n(this);return Y?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Y=Y||e,r}catch(n){throw delete this[t],Y=Y||e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function X(e,t,n,r){const o=function(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Q(e){const t=()=>e;return t["~constantCatch"]=!0,t}var ee;const te={value:void 0,enumerable:!1};let ne="captureStackTrace"in Error?Error:null;function re(e,t,n,r){function o(e){this.def=e,this.constr=l,this.traits=new Set}o.prototype={};const i=n,s=i&&new WeakSet;function a(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{te.value=new o(r);try{Object.defineProperty(n,"_zod",te)}finally{te.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){const e=Object.getPrototypeOf(n),t=n._zod.constr.prototype;let r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);const o=r??e;s.has(o)||(s.add(o),function(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):q(e,n,r.value)}}(o,i))}const a=l.prototype;for(const e in a)Object.prototype.hasOwnProperty.call(a,e)&&(e in n||(n[e]=a[e].bind(n)))}const c=r?.Parent??Object;class u extends c{}function l(e){const t=r?.Parent?function(e){const t=ne;if(t){const n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return ne=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(u):this;a(t,e);const n=t._zod.deferred;if(n){for(const e of n)e();t._zod.deferred=void 0}const o=globalThis.__zod_globalConfig?.postProcessor;return o&&o(t),t}return Object.defineProperty(u,"name",{value:e}),Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(l,"name",{value:e}),l}class oe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ie extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(ee=globalThis).__zod_globalConfig??(ee.__zod_globalConfig={});const se=globalThis.__zod_globalConfig;function ae(e){return e&&Object.assign(se,e),se}const ce={get:function(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,s,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},ue={value:void 0,enumerable:!1},le=new WeakSet([Object.prototype,Error.prototype]),fe=re("$ZodError",(e,t)=>{e.name="$ZodError",ue.value=t,Object.defineProperty(e,"issues",ue),ue.value=void 0,Object.defineProperty(e,"message",ce);const n=Object.getPrototypeOf(e);le.has(n)||(le.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function de(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||("__proto__"===t?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function pe(e,t){return{callee:t?.callee??e,Err:t?.Err}}const he=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new oe;if(a.issues.length){const n=new(i?.Err??e)(a.issues.map(e=>D(e,s,ae())));throw v(n,i?.callee??t),n}return a.value};return t},me=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const n=new(i?.Err??e)(a.issues.map(e=>D(e,s,ae())));throw v(n,i?.callee??t),n}return a.value};return t},ye=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new oe;return i.issues.length?ge(e,i.issues,o):{success:!0,data:i.value}};function ge(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>D(e,n,ae()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const ve=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?ge(e,i.issues,o):{success:!0,data:i.value}},_e=Symbol.for("zod.compile.invalid"),be=Symbol.for("zod.compile.fallback"),we=(e,t,n)=>{const r=e._zod.bag.validator;if(void 0!==r){if(r(t)!==_e)return!0;if(!0===r.definite&&void 0===n)return!1}return function(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;o?(r[be]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)throw new oe;return 0===i.issues.length}(e,t,n)};const ze=e=>{const t=he(e),n=(e,r,o,i)=>{const s=o?{...o,direction:"backward"}:{direction:"backward"};return t(e,r,s,pe(n,i))};return n},ke=e=>{const t=he(e),n=(e,r,o,i)=>t(e,r,o,pe(n,i));return n},$e=e=>{const t=me(e),n=async(e,r,o,i)=>{const s=o?{...o,direction:"backward"}:{direction:"backward"};return await t(e,r,s,pe(n,i))};return n},Oe=e=>{const t=me(e),n=async(e,r,o,i)=>await t(e,r,o,pe(n,i));return n},je=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ye(e)(t,n,o)},Se=e=>(t,n,r)=>ye(e)(t,n,r),xe=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ve(e)(t,n,o)},Pe=e=>async(t,n,r)=>ve(e)(t,n,r),Ae=/^[cC][0-9a-z]{6,}$/,Ee=/^[0-9a-z]+$/,Ie=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Te=/^[0-9a-vA-V]{20}$/,Ze=/^[A-Za-z0-9]{27}$/,Fe=/^[a-zA-Z0-9_-]{21}$/;const Re=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ne=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ue=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,De=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Ce=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Je=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Le=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Me=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ke=/^https?$/,Be=/^\+[1-9]\d{6,14}$/,We="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function qe(e){return new RegExp(`^${e}$`)}const Ve=qe(We);function Ye(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Ge=/^[\s\S]{0,}$/,He=/^-?\d+$/,Xe=/^-?\d+(?:\.\d+)?$/,Qe=/^(?:true|false)$/i,et=/^[^A-Z]*$/,tt=/^[^a-z]*$/,nt=re("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),rt=e=>{const t=e.value;return!(n=t,null==n||void 0===t.length);var n},ot=re("$ZodCheckMaxLength",(e,t)=>{var n;nt.init(e,t),(n=e._zod.def).when??(n.when=rt),e._zod.check=n=>{const r=n.value,o=r.length;if(("string"==typeof r&&o>t.maximum?J(r):o)<=t.maximum)return;const i=L(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),it=re("$ZodCheckMinLength",(e,t)=>{var n;nt.init(e,t),(n=e._zod.def).when??(n.when=rt),e._zod.check=n=>{const r=n.value,o=r.length;if(("string"==typeof r&&o>=t.minimum&&o<2*t.minimum?J(r):o)>=t.minimum)return;const i=L(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),st=re("$ZodCheckLengthEquals",(e,t)=>{var n;nt.init(e,t),(n=e._zod.def).when??(n.when=rt),e._zod.check=n=>{const r=n.value,o=r.length,i="string"==typeof r&&o>=t.length&&o<=2*t.length?J(r):o;if(i===t.length)return;const s=L(r),a=i>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),at=re("$ZodCheckStringFormat",(e,t)=>{var n,r;nt.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ct=re("$ZodCheckRegex",(e,t)=>{at.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ut=re("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=et),at.init(e,t)}),lt=re("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=tt),at.init(e,t)}),ft=re("$ZodCheckIncludes",(e,t)=>{nt.init(e,t);const n=$(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),dt=re("$ZodCheckStartsWith",(e,t)=>{nt.init(e,t);const n=new RegExp(`^${$(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),pt=re("$ZodCheckEndsWith",(e,t)=>{nt.init(e,t);const n=new RegExp(`.*${$(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ht=re("$ZodCheckOverwrite",(e,t)=>{nt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class mt{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of r)this.content.push(e)}compile(){const e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {\n${t.join("\n")}\n};`)(...Object.values(this.closed))}}const yt={major:4,minor:6,patch:7},gt=re("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yt;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const t of o)for(const n of t._zod.onattach)n(e);if(0===o.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(t,n,r)=>{if(t.memo)return t;let o,i=T(t);for(const s of n){if(s._zod.def.when){if(Z(t))continue;if(!s._zod.def.when(t))continue}else if(i)continue;const n=t.issues.length,a=s._zod.check(t);if(a instanceof Promise&&!1===r?.async)throw new oe;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a;t.issues.length!==n&&(U(t.issues,n,e),i||(i=T(t,n)))});else{if(t.issues.length===n)continue;U(t.issues,n,e),i||(i=T(t,n))}}return o?o.then(()=>t):t},n=(n,r,i)=>{if(T(n))return n.aborted=!0,n;const s=t(r,o,i);if(s instanceof Promise){if(!1===i.async)throw new oe;return s.then(t=>e._zod.parse(t,i))}return e._zod.parse(s,i)};e._zod.run=(r,i)=>{if(i.skipChecks)return e._zod.parse(r,i);if("backward"===i.direction){const t=e._zod.parse({value:r.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,i)):n(t,r,i)}const s=e._zod.parse(r,i);if(s instanceof Promise){if(!1===i.async)throw new oe;return s.then(e=>t(e,o,i))}return t(s,o,i)}}},{get"~standard"(){return B(this,"~standard",_t(this))},set"~standard"(e){K(this,"~standard",e)}}),vt=(e,t)=>e.issues.length?{issues:e.issues.map(e=>D(e,t,ae()))}:{value:e.value};function _t(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return vt(r,n)}catch(e){}return async function(e,t){const n={async:!0};return vt(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}}const bt=re("$ZodString",(e,t)=>{gt.init(e,t),e._zod.pattern=t.pattern??Ge,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),wt=re("$ZodStringFormat",(e,t)=>{at.init(e,t),bt.init(e,t)}),zt=re("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ne),wt.init(e,t)}),kt=re("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ue(e))}else t.pattern??(t.pattern=Ue());wt.init(e,t)}),$t=re("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=De),wt.init(e,t)});function Ot(e){try{return"undefined"!=typeof URL&&"function"==typeof URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function jt(e,t){return"normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===Ke.source&&!/^https?:\/\//i.test(e))return 1;try{if("undefined"!=typeof URL){const t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(e,t):Ot(e)||2}const St=/[\t\n\r]/g;function xt(e){return e.replace(St,"")}const Pt=re("$ZodURL",(e,t)=>{wt.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=jt(r,t);return 1===o?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort}):2===o?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort}):!0===o?void(n.value=xt(r)):(t.hostname&&!function(e,t){return t.lastIndex=0,t.test(e.hostname)}(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!function(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),void(n.value=t.normalize?o.href:xt(r)))}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),At=re("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),wt.init(e,t)}),Et=re("$ZodNanoID",(e,t)=>{if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);var n;t.pattern??(t.pattern=void 0===t.length?Fe:(n=t.length,new RegExp(`^[a-zA-Z0-9_-]{${n}}$`))),wt.init(e,t)}),It=re("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ae),wt.init(e,t)}),Tt=re("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ee),wt.init(e,t)}),Zt=re("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ie),wt.init(e,t)}),Ft=re("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Te),wt.init(e,t)}),Rt=re("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ze),wt.init(e,t)}),Nt=re("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Ye({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Ye({precision:e.precision})}`:n;return new RegExp(`^${We}T(?:${r})$`)}(t)),wt.init(e,t)}),Ut=re("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ve),wt.init(e,t)}),Dt=re("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Ye(t)}$`)),wt.init(e,t)}),Ct=re("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Re),wt.init(e,t)}),Jt=re("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ce),wt.init(e,t)}),Lt=/^[0-9a-fA-F:.]+$/;function Mt(e){return!!Lt.test(e)&&Ot(`http://[${e}]`)}const Kt=re("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Je),wt.init(e,t),e._zod.check=n=>{Mt(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Bt=re("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Le),wt.init(e,t)});const Wt=re("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Me),wt.init(e,t),e._zod.check=n=>{(function(e){const t=e.split("/");if(2!==t.length)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`===r&&!(o<0||o>128)&&Mt(n)})(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function qt(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Vt=/^[0-9a-zA-Z+/]*={0,2}$/,Yt=re("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Vt),wt.init(e,t),e._zod.check=n=>{qt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Gt=/^[A-Za-z0-9_-]*$/;const Ht=re("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Gt),wt.init(e,t),e._zod.check=n=>{(function(e){if(!Gt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return qt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Xt=re("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Be),wt.init(e,t)});const Qt=re("$ZodJWT",(e,t)=>{wt.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),en=re("$ZodBoolean",(e,t)=>{gt.init(e,t),e._zod.pattern=Qe,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),tn=re("$ZodUnknown",(e,t)=>{gt.init(e,t),e._zod.parse=e=>e}),nn=re("$ZodNever",(e,t)=>{gt.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});const rn=e=>Array.isArray(e)?e.length:-1;function on(e,t,n){e.issues.length&&t.issues.push(...F(n,e.issues)),t.value[n]=e.value}const sn=re("$ZodArray",(e,t)=>{gt.init(e,t);const n=se.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],a=o?.abortEarly;for(let e=0;e<i.length;e++){const n=i[e],c=t.element._zod.run({value:n,issues:[]},o);if(c instanceof Promise)s.push(c.then(t=>on(t,r,e)));else if(on(c,r,e),a&&0!==c.issues.length&&T(c))break}return s.length?Promise.all(s).then(()=>r):r},function(e,t){const n=N(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(e=>e[0])),o=e._zod.parse;e._zod.parse=(n,i)=>{const s=t(n.value);if(s>r&&!i?.skipChecks&&"backward"!==i?.direction)for(const[t,r]of N(e._zod.def.checks))if(s>t&&r._zod.def.when(n)){const t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,U(n.issues,t,e),n}return o(n,i)}}(e,rn)});function an(e,t,n,r,o,i){const s=n in r,a="optional"===i;if(s||!a||"optional"!==o){if(e.issues.length){if(void 0!==o&&a&&!s)return;t.issues.push(...F(n,e.issues))}s||void 0!==o?void 0===e.value?(s||"defaulted"===o&&!a)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const cn=[];function un(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:cn,o=r.length?[...t,...r]:t;for(const t of o)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);const i=(s=e.shape,Object.keys(s).filter(e=>void 0!==s[e]._zod.optin&&"optional"===s[e]._zod.optout));var s;return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function ln(e,t,n,r,o,i,s){const a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,f=u.optin,d=u.optout;let p=0;for(const o in t){if(s&&n.issues.length!==p){if(T(n,p))break;p=n.issues.length}if(c.has(o))continue;if("__proto__"===o){"never"===l&&a.push(o);continue}if("never"===l){a.push(o);continue}const i=u.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>an(e,n,o,t,f,d))):an(i,n,o,t,f,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const fn=re("$ZodObject",(e,t)=>{gt.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const e=()=>{const n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}const o=c(()=>un(t));H(e,"propValues",e=>{const t=e.def.shape,n={};for(const e in t){const r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||l(n,e,new Set);for(const t of r.values)n[e].add(t);void 0!==r.optin&&n[e].add(void 0)}}return n});const i=_,s=t.catchall;let a;const u=se.memoizer;u?.attach(e),e._zod.parse=(t,n)=>{a??(a=o.value);const r=t.value;if(!i(r))return t.issues.push({expected:"object",code:"invalid_type",input:r,inst:e}),t;t.value=u?u.alloc(e,t,{},n):{};const c=[],l=a.shape,f=n?.abortEarly;let d=t.issues.length;for(const e of a.allKeys){if(f&&t.issues.length!==d){if(T(t,d))break;d=t.issues.length}if("__proto__"===e)continue;const o=l[e],i=o._zod.optin,s=o._zod.optout,a=o._zod.run({value:r[e],issues:[]},n);a instanceof Promise?c.push(a.then(n=>an(n,t,e,r,i,s))):an(a,t,e,r,i,s)}return s?ln(c,r,t,n,o.value,e,!0===f):c.length?Promise.all(c).then(()=>t):t}}),dn=re("$ZodObjectJIT",(e,t)=>{fn.init(e,t);const n=e._zod.parse,r=c(()=>un(t)),o=se.memoizer;let i;const s=_,a=!se.jitless,u=a&&b.value,l=t.catchall;let f;e._zod.parse=(c,d)=>{f??(f=r.value);const p=c.value;return s(p)?a&&u&&!1===d?.async&&!0!==d.jitless?(i||(i=(t=>{const n=r.value,i=n.symbolKeys,s=new mt(["payload","ctx"],{shape:t,inst:e,memo:o,syms:i}),a=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`\n let ${e}_ab = false;\n for (let i = 0; i < ${e}.issues.length; i++) {\n const iss = ${e}.issues[i];\n iss.path = iss.path ? [${t}, ...iss.path] : [${t}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${e}_ab = true;\n }\n if (${e}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;s.write("const input = payload.value;");const u=Object.create(null);let l=0;for(const e of n.allKeys)u[e]="key_"+l++;s.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const e of n.allKeys){if("__proto__"===e)continue;const n=u[e],r="symbol"==typeof e?`syms[${i.indexOf(e)}]`:g(e),o=`${r} in input`,l=t[e],f=l?._zod?.optin,d=void 0!==f,p="optional"===l?._zod?.optout;if(s.write(`const ${n} = ${a(r)};`),d&&p){const e="optional"===f?`${n}_present`:`${n}.value !== undefined || ${n}_present`;s.write(`\n const ${n}_present = ${o};\n if (!${n}.issues.length || ${n}_present) {\n if (${n}.issues.length) {${c(n,r)}\n }\n\n if (${e}) {\n newResult[${r}] = ${n}.value;\n }\n }\n\n `)}else d?(s.write(`\n if (${n}.issues.length) {${c(n,r)}\n }\n `),"defaulted"===f?s.write(`newResult[${r}] = ${n}.value;`):s.write(`\n if (${n}.value !== undefined || ${o}) {\n newResult[${r}] = ${n}.value;\n }\n `)):s.write(`\n const ${n}_present = ${o};\n if (${n}.issues.length) {${c(n,r)}\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${r}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${n}_present) {\n newResult[${r}] = ${n}.value;\n }\n\n `)}return s.write("payload.value = newResult;"),s.write("return payload;"),s.compile()})(t.shape)),c=i(c,d),l?ln([],p,c,d,f,e,!0===d?.abortEarly):c):n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c)}});function pn(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const o=e.filter(e=>!T(e));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>D(e,r,ae())))}),t)}const hn=re("$ZodUnion",(e,t)=>{gt.init(e,t),H(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),H(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),H(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),H(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){const t=e.def.options.map(e=>e._zod.pattern);return new RegExp(`^(${t.map(e=>u(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then(t=>pn(t,r,e,o)):pn(s,r,e,o)}}),mn=re("$ZodIntersection",(e,t)=>{gt.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>gn(e,t,n)):gn(e,o,i)}});function yn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(w(e)&&w(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const n of r){if("__proto__"===n)continue;const r=yn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=yn(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gn(e,t,n){const r=new Map;let o;const i=new Map,s=(e,t)=>{let n;if("unrecognized_keys"!==e.code||e.path?.length){if("invalid_key"!==e.code||"record"!==e.origin||1!==e.path?.length)return!1;{const t=String(e.path[0]);i.has(t)||i.set(t,e),n=[t]}}else o??(o=e),n=e.keys;for(const e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(const n of t.issues)s(n,"l")||e.issues.push(n);for(const t of n.issues)s(t,"r")||e.issues.push(t);const a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length){const t=o?a.filter(e=>o.keys.includes(e)):[];t.length&&e.issues.push({...o,keys:t});for(const n of a)!t.includes(n)&&i.has(n)&&e.issues.push(i.get(n))}const c=yn(t.value,n.value);if(!c.valid){if(T(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const vn=re("$ZodRecord",(e,t)=>{gt.init(e,t);const n=se.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!w(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};const c=new Set;for(const n of a)if("string"==typeof n||"number"==typeof n||"symbol"==typeof n){if(c.add("number"==typeof n?n.toString():n),"__proto__"===n)continue;const a=t.keyType._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>D(e,o,ae())),input:n,path:[n],inst:e});continue}const u=a.value;if("__proto__"===u)continue;const l=t.valueType._zod.run({value:i[n],issues:[]},o);l instanceof Promise?s.push(l.then(e=>{e.issues.length&&r.issues.push(...F(n,e.issues)),r.value[u]=e.value})):(l.issues.length&&r.issues.push(...F(n,l.issues)),r.value[u]=l.value)}let u;for(const e in i)if(!c.has(e))if("loose"===t.mode){if("__proto__"===e)continue;r.value[e]=i[e]}else u=u??[],u.push(e);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{let c;r.value=n?n.alloc(e,r,{},o):{};for(const n of Reflect.ownKeys(i)){if("__proto__"===n)continue;if(!Object.prototype.propertyIsEnumerable.call(i,n))continue;let u=t.keyType._zod.run({value:n,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof n&&Xe.test(n)&&u.issues.length){const e=t.keyType._zod.run({value:Number(n),issues:[]},o);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(u=e)}if(u.issues.length){"loose"===t.mode?r.value[n]=i[n]:a?(c=c??[],c.push(n)):r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(e=>D(e,o,ae())),input:n,path:[n],inst:e});continue}const l=u.value;if("__proto__"===l)continue;const f=t.valueType._zod.run({value:i[n],issues:[]},o);f instanceof Promise?s.push(f.then(e=>{e.issues.length&&r.issues.push(...F(n,e.issues)),r.value[l]=e.value})):(f.issues.length&&r.issues.push(...F(n,f.issues)),r.value[l]=f.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),_n=re("$ZodEnum",(e,t)=>{gt.init(e,t);const n=o(t.entries),r=new Set(n);e._zod.values=r,H(e,"pattern",e=>{const t=o(e.def.entries).filter(e=>k.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>$(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),bn=re("$ZodLiteral",(e,t)=>{gt.init(e,t);const n=new Set(t.values);e._zod.values=n,H(e,"pattern",e=>{const t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?$(e):e?$(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),wn=re("$ZodTransform",(e,t)=>{gt.init(e,t),e._zod.optin="optional",se.memoizer?.guard(e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ie(e.constructor.name);const o=t.transform(n.value,n);if(r.async){return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n))}if(o instanceof Promise)throw new oe;return n.value=o,n}});function zn(e,t){return e.value=t.issues.length?void 0:t.value,e}const kn=re("$ZodOptional",(e,t)=>{gt.init(e,t),H(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",H(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),H(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${u(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;const r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>zn(e,t)):zn(e,r)}return t.innerType._zod.run(e,n)}}),$n=re("$ZodExactOptional",(e,t)=>{kn.init(e,t),H(e,"values",e=>e.def.innerType._zod.values),H(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),On=re("$ZodNullable",(e,t)=>{gt.init(e,t),H(e,"optin",e=>e.def.innerType._zod.optin),H(e,"optout",e=>e.def.innerType._zod.optout),H(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${u(t.source)}|null)$`):void 0}),H(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),jn=re("$ZodDefault",(e,t)=>{gt.init(e,t),e._zod.optin="defaulted",H(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Sn(e,t)):Sn(r,t)}});function Sn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const xn=re("$ZodPrefault",(e,t)=>{gt.init(e,t),e._zod.optin="defaulted",H(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Pn=re("$ZodNonOptional",(e,t)=>{gt.init(e,t),H(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>An(t,e)):An(o,e)}});function An(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function En(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>D(e,r,ae()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const In=re("$ZodCatch",(e,t)=>{gt.init(e,t),H(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),H(e,"optout",e=>e.def.innerType._zod.optout),H(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>En(e,r,t,n)):En(e,r,t,n)}}),Tn=re("$ZodPipe",(e,t)=>{gt.init(e,t),H(e,"values",e=>e.def.in._zod.values),H(e,"optin",e=>e.def.in._zod.optin),H(e,"optout",e=>e.def.out._zod.optout),H(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Zn(e,t.in,n)):Zn(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Zn(e,t.out,n)):Zn(r,t.out,n)}});function Zn(e,t,n){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Fn=re("$ZodReadonly",(e,t)=>{gt.init(e,t),H(e,"propValues",e=>e.def.innerType._zod.propValues),H(e,"values",e=>e.def.innerType._zod.values),H(e,"optin",e=>e.def.innerType?._zod?.optin),H(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Rn):Rn(r)}});function Rn(e){return e.memo||(e.value=Object.freeze(e.value)),e}const Nn=re("$ZodCustom",(e,t)=>{nt.init(e,t),gt.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>Un(t,n,r,e));Un(o,n,r,e)}});function Un(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(M(e))}}class Dn extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Cn="~memo",Jn=[];function Ln(e){return null!==e&&"object"==typeof e}function Mn(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Kn=new WeakMap;function Bn(e,t,n){const r=Kn.get(e);if(void 0!==r)return r?2:0;if(t.has(e))return 2;t.add(e);let o=0;const i=e=>{if(2!==o&&e?._zod){const n=Bn(e,t);n>o&&(o=n)}},s=e=>{e>o&&(o=e)},a=e._zod.def;switch(a.type){case"object":{const e=f(a);s(e?(e=>{let n=0;for(const r of Reflect.ownKeys(e)){const o=Object.getOwnPropertyDescriptor(e,r);if(!o.enumerable)continue;const i=o.get?1:o.value?._zod?Bn(o.value,t):0;i>n&&(n=i)}return n})(e):1),i(a.catchall);break}case"array":i(a.element);break;case"tuple":for(const e of a.items)i(e);i(a.rest);break;case"record":case"map":i(a.keyType),i(a.valueType);break;case"set":i(a.valueType);break;case"union":for(const e of a.options)i(e);break;case"intersection":i(a.left),i(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(a.innerType);break;case"pipe":i(a.in),i(a.out);break;case"function":i(a.input),i(a.output);break;case"lazy":{const e=a._cachedInner??void 0;s(e?Bn(e,t):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const e in a){const t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;const n=t.value;if(n&&"object"==typeof n)if(n._zod)i(n);else if(Array.isArray(n))for(const e of n)i(e)}}return t.delete(e),function(e,t){1!==t&&Kn.set(e,2===t);return t}(e,o)}let Wn;const qn=[],Vn={alloc(e,t,n){const r=Wn;if(!r)return n;Wn=void 0;const o={value:n,issues:null};return r.set(t.value,o),qn.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const t=e._zod.parse,n=(e,n)=>{if("backward"!==n.direction&&function(e,t){const n=e[Cn]?.backEdges;return void 0!==n&&Ln(t)&&n.has(t)}(n,e.value))throw new Dn;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,o,i=!1;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const t=e._zod.parse,s=(a,c)=>{if(void 0===n){const r=Bn(e,new Set);if(0===r)return e._zod.parse=t,e._zod.run===s&&(e._zod.run=t),t(a,c);2===r||i?n=!0:i=!0}const u=a.value;if(!Ln(u))return t(a,c);let l,f=c[Cn];f||(f={buckets:new WeakMap,backEdges:void 0},c[Cn]=f),r===c?l=o:(l=function(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}(f,e),r=c,o=l);const d=l.get(u);if(d)return a.value=d.value,d.issues?d.issues.length&&a.issues.push(...Mn(d.issues)):(a.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value)),a;Wn=l;const p=qn.length,h=t(a,c);Wn=void 0;const m=qn.length>p?qn.pop():void 0;return h instanceof Promise?h.then(e=>(m&&(m.issues=e.issues.length?Mn(e.issues):Jn),e)):(m&&(m.issues=h.issues.length?Mn(h.issues):Jn),h)};e._zod.parse=s,e._zod.run===t&&(e._zod.run=s)})}};const Yn=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(t){return e[t]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return e=>{switch(e.code){case"invalid_type":return`Invalid input: expected ${o(e.expected)}, received ${o(function(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(null===e)return"null";if(Array.isArray(e))return"array";const t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return t}(e.input),e.input)}`;case"invalid_value":return 1===e.values.length?`Invalid input: expected ${S(e.values[0])}`:`Invalid option: expected one of ${i(e.values,"|")}`;case"too_big":{const n=e.exact?"exactly ":e.inclusive?"<=":"<",r=t(e.origin);return r?`Too big: expected ${e.origin??"value"} to have ${n}${e.maximum.toString()} ${r.unit??"elements"}`:`Too big: expected ${e.origin??"value"} to be ${n}${e.maximum.toString()}`}case"too_small":{const n=e.exact?"exactly ":e.inclusive?">=":">",r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case"invalid_format":{const t=e;return"starts_with"===t.format?`Invalid string: must start with "${t.prefix}"`:"ends_with"===t.format?`Invalid string: must end with "${t.suffix}"`:"includes"===t.format?`Invalid string: must include "${t.includes}"`:"regex"===t.format?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${i(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":if(e.options&&Array.isArray(e.options)&&e.options.length>0){return`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(" | ")}`}return!1===e.inclusive?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`;default:return"Invalid input"}}};var Gn;class Hn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(Gn=globalThis).__zod_globalRegistry??(Gn.__zod_globalRegistry=new Hn);const Xn=globalThis.__zod_globalRegistry;function Qn(e,t){return new ot({check:"max_length",...j(t),maximum:e})}function er(e,t){return new it({check:"min_length",...j(t),minimum:e})}function tr(e,t){return new st({check:"length_equals",...j(t),length:e})}function nr(e){return new ht({check:"overwrite",tx:e})}function rr(e,t){const n=function(e,t){const n=new nt({check:"custom",...j(t)});return n._zod.check=e,n}(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(M(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(M(r))}},e(t.value,t)),t);return n}function or(e,...t){for(const n of t)for(const t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&l(e,t,n[t]);return e}function ir(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Xn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function sr(e,t,n,r,o){const i="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if("any"===i)return!1;if(void 0===i||"throw"===i)throw new Error(o);return Object.assign(n,i),!0}function ar(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i){i.count++;return n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema}const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),ar(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&or(s.schema,c),"input"===t.io&&gr(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault;return t.seen.get(e).schema}function cr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ur(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=r.get(n);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${cr(i)}`}}const o=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:"#"};const i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+cr(i)}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of e.seen.entries()){const r=n[1];if(t===n[0]){o(n);continue}if(e.external){const r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){o(n);continue}}const i=e.metadataRegistry.get(n[0])?.id;i?o(n):(r.cycle||r.count>1&&"ref"===e.reused)&&o(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function lr(e){const t=e.anyOf;if(!Array.isArray(t)||0===t.length||void 0!==e.type)return;const n=[];for(const e of t){if(!e||"object"!=typeof e)return;lr(e);const t=Object.keys(e);if(1!==t.length||"type"!==t[0])return;const r=e.type;for(const e of Array.isArray(r)?r:[r]){if("string"!=typeof e)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=1===n.length?n[0]:n}const fr=new Set(["type","properties","required","additionalProperties"]),dr=["oneOf","anyOf"];function pr(e){const t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function hr(e){const t=[];for(const n of e){if("object"!=typeof n||"object"!==n.type)return null;for(const e in n)if(!fr.has(e))return null;t.push(n)}const n={},r=new Set;for(const e of t){for(const r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;const e=[];for(const n of t){const t=n.properties?.[r]??pr(n);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}l(n,r,1===e.length?e[0]:hr(e)??{allOf:e})}for(const t of e.required??[])r.add(t)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(e=>!1===e.additionalProperties))o.additionalProperties=!1;else{const e=[];for(const n of t){const t=pr(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?o.additionalProperties=e[0]:e.length>1&&(o.additionalProperties={allOf:e})}return o}function mr(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const t of fr)if(t in e)return;const n=t.filter(e=>dr.some(t=>Array.isArray(e[t])));let r=null;if(n.length){const e=n[0],o=dr.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;const i=t.filter(t=>t!==e),s=e[o].map(e=>hr([...i,e]));if(s.some(e=>!e))return;r={[o]:s}}else r=hr(t);r&&(delete e.allOf,or(e,r))}function yr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?or(o,a):(o.allOf=o.allOf??[],o.allOf.push(a)),or(o,i);if(t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(a.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const t of[...e.seen.entries()].reverse())r(t[0]);if("openapi-3.0"!==e.target)for(const t of e.seen.entries())lr(t[1].def??t[1].schema);for(const t of e.deferred)t();if(e.intersections.length){const t=new Map;for(const n of e.seen.values())for(const e of[n.schema,n.def]){const n=e?.allOf;if(!Array.isArray(n))continue;const r=t.get(n);r?r.push(e):t.set(n,[e])}for(const n of e.intersections)for(const e of t.get(n)??[])mr(e)}}const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}or(o,n.defId?n.schema:n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,l(s,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?o.$defs=s:o.definitions=s);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:vr(t,"input",e.processors),output:vr(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function gr(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return gr(r.element,n);if("set"===r.type)return gr(r.valueType,n);if("lazy"===r.type)return gr(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type||"catch"===r.type)return gr(r.innerType,n);if("intersection"===r.type)return gr(r.left,n)||gr(r.right,n);if("record"===r.type||"map"===r.type)return gr(r.keyType,n)||gr(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(gr(r.in,n)||gr(r.out,n));if("object"===r.type){for(const e in r.shape)if(gr(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(gr(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(gr(e,n))return!0;return!(!r.rest||!gr(r.rest,n))}return!1}const vr=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=ir({...o??{},target:i,io:t,processors:n});return ar(e,s),ur(s,e),yr(s,e)},_r=(e,t,n)=>{(void 0===e[t]||n>e[t])&&(e[t]=n)},br=(e,t,n)=>{(void 0===e[t]||n<e[t])&&(e[t]=n)},wr=(e,t)=>{_r(e,"minimum",t),br(e,"maximum",t)},zr=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},kr=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},$r=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Or=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},jr=(e,t)=>_r(e,"minimum",t.minimum),Sr=(e,t)=>br(e,"maximum",t.maximum),xr=e=>(t,n)=>{Or(t,n.format);const[r,o]=e[n.format];_r(t,"minimum",r),br(t,"maximum",o)},Pr={greater_than:(e,t)=>_r(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>br(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>zr(e,t.value),number_format:xr(x),bigint_format:xr(P),min_length:jr,max_length:Sr,length_equals:(e,t)=>wr(e,t.length),min_size:jr,max_size:Sr,size_equals:(e,t)=>wr(e,t.size),string_format:(e,t)=>{Or(e,t.format),t.pattern&&kr(e,t.pattern),"base64"!==t.format&&"base64url"!==t.format||(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>$r(e,t.mime)};function Ar(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const e of r)Pr[e._zod.def.check]?.(t,e._zod.def);const o=e._zod.bag;void 0!==o.minimum&&_r(t,"minimum",o.minimum),void 0!==o.exclusiveMinimum&&_r(t,"exclusiveMinimum",o.exclusiveMinimum),void 0!==o.maximum&&br(t,"maximum",o.maximum),void 0!==o.exclusiveMaximum&&br(t,"exclusiveMaximum",o.exclusiveMaximum),void 0!==o.multipleOf&&zr(t,o.multipleOf),void 0!==o.format&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&$r(t,o.mime);for(const e of o.patterns??[])kr(t,e);return t}const Er={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ir=new Map([[Vt,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[Gt,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),Tr=e=>Ir.get(e)??e;function Zr(e){const t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?Zr(t.out):"catch"===t.type?Zr(t.innerType):e._zod.optin}function Fr(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const r=e.get(t)?.def;if(!r)return t;const o=Fr(e,r,n);return o===r?t:o}for(const r of["anyOf","oneOf"]){const o=t[r];if(!Array.isArray(o))continue;const i=o.map(t=>Fr(e,t,n));i.some((e,t)=>e!==o[t])&&(t={...t,[r]:i})}const r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some(e=>"number"===e||"integer"===e),i=t.enum??(void 0!==t.const?[t.const]:void 0);if(!o&&!i?.some(e=>"number"==typeof e))return t;const{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:f,id:d,...p}=t;return p.enum?p.enum=p.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof p.const&&(p.const=String(p.const)),o?(p.type="string",i||(p.pattern=(r.includes("number")?Xe:He).source),p):p}const Rr=new WeakMap;const Nr=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=Ar(s).patterns;if("loose"===i.mode&&a&&a.size>0){const e=ar(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of a)l(o.patternProperties,Tr(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){o.propertyNames=ar(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let n=Rr.get(t);n||(n=[],Rr.set(t,n),t.deferred.push(()=>function(e){const t=new Map;for(const n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);const n=new Map;for(const r of Rr.get(e)??[]){const o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||!0===i||n.has(i))continue;const s=Fr(t,i,new Set);s!==i&&n.set(i,s)}if(n.size)for(const t of e.seen.values())for(const e of[t.schema,t.def]){const t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}(t))),n.push(e)}o.additionalProperties=ar(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const c=s._zod.values,u="input"===t.io&&void 0!==Zr(i.valueType);if(c&&!i.partial&&!u){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(o.required=e.map(String))}},Ur=Symbol();function Dr(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(i=!0,null));return i?(sr(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Ur):JSON.parse(s)}const Cr=(e,t,n,r)=>{const o=e._zod.def;ar(o.innerType,t,r);t.seen.get(e).ref=o.innerType},Jr=new WeakSet([Object.prototype,Error.prototype]);function Lr(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const Mr=(e,t)=>{fe.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Jr.has(n)||(Jr.add(n),Lr(n,"format",e=>t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e},[...o,...i.path]));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o],s=o===e.length-1;if("_errors"===n){s&&r._errors.push(t(i)),o++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const a=r[n];s&&a._errors.push(t(i)),r=a,o++}}}};return r(e),n}(e,t)),Lr(n,"flatten",e=>t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?de(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)),Lr(n,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,s,2)}),Lr(n,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,s,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},Kr=re("ZodError",Mr,void 0,{Parent:Error}),Br=he(Kr),Wr=me(Kr),qr=ye(Kr),Vr=ve(Kr),Yr=ze(Kr),Gr=ke(Kr),Hr=$e(Kr),Xr=Oe(Kr),Qr=je(Kr),eo=Se(Kr),to=xe(Kr),no=Pe(Kr);function ro(){se.localeError||ae({localeError:Yn()})}function oo(){se.memoizer||ae({memoizer:Vn})}const io=re("ZodType",(e,t)=>(ro(),gt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(y(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return O(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...j(n)})}(di,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return rr(e,t)}(e,t))},overwrite(e){return this.check(nr(e))},optional(){return ti(this)},exactOptional(){return new ni({type:"optional",innerType:this})},nullable(){return oi(this)},nullish(){return ti(oi(this))},nonoptional(e){return function(e,t){return new ai({type:"nonoptional",innerType:e,...j(t)})}(this,e)},array(){return Jo(this)},or(e){return Bo([this,e])},and(e){return new Wo({type:"intersection",left:this,right:e})},transform(e){return li(this,new Qo({type:"transform",transform:e}))},default(e){return t=e,new ii({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():z(t)}});var t},prefault(e){return t=e,new si({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():z(t)}});var t},catch(e){return new ci({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:Q(t)});var t},pipe(e){return li(this,e)},readonly(){return new fi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Xn.add(t,{description:e}),t},meta(...e){if(0===e.length)return Xn.get(this);const t=this.clone();return Xn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return B(this,"~standard",{..._t(this),jsonSchema:{input:vr(this,"input"),output:vr(this,"output")}})},set"~standard"(e){K(this,"~standard",e)},parse:function e(t,n){return Br(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Wr(this,t,n,{callee:e})},safeParse(e,t){return qr(this,e,t)},async safeParseAsync(e,t){return Vr(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){K(this,"spa",e)},validate(e,t){return we(this,e,t)},validateAsync(e,t){return(async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),0===o.issues.length})(this,e,t)},encode:function e(t,n){return Yr(this,t,n,{callee:e})},decode:function e(t,n){return Gr(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Hr(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Xr(this,t,n,{callee:e})},safeEncode(e,t){return Qr(this,e,t)},safeDecode(e,t){return eo(this,e,t)},async safeEncodeAsync(e,t){return to(this,e,t)},async safeDecodeAsync(e,t){return no(this,e,t)},toJSONSchema(e){return((e,t={})=>n=>{const r=ir({...n,processors:t});return ar(e,r),ur(r,e),yr(r,e)})(this,{})(e)},get description(){return Xn.get(this)?.description},get _def(){return this._zod.def}}),so=re("_ZodString",(e,t)=>{bt.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:s,patterns:a,contentEncoding:c,laxFormat:u}=Ar(e);if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),s&&(r.format=Er[s]??s,""===r.format&&delete r.format,("time"===s||u)&&delete r.format),c&&(r.contentEncoding=c),a&&a.size>0){const e=[...a].map(Tr);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n)},W({format:e=>Ar(e).format??null,minLength:e=>Ar(e).minimum??null,maxLength:e=>Ar(e).maximum??null},{regex(...e){return this.check(function(e,t){return new ct({check:"string_format",format:"regex",...j(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new ft({check:"string_format",format:"includes",...j(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new dt({check:"string_format",format:"starts_with",...j(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new pt({check:"string_format",format:"ends_with",...j(t),suffix:e})}(...e))},min(...e){return this.check(er(...e))},max(...e){return this.check(Qn(...e))},length(...e){return this.check(tr(...e))},nonempty(...e){return this.check(er(1,...e))},lowercase(e){return this.check(function(e){return new ut({check:"string_format",format:"lowercase",...j(e)})}(e))},uppercase(e){return this.check(function(e){return new lt({check:"string_format",format:"uppercase",...j(e)})}(e))},trim(){return this.check(nr(e=>e.trim()))},normalize(...e){return this.check(function(e){return nr(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(nr(e=>e.toLowerCase()))},toUpperCase(){return this.check(nr(e=>e.toUpperCase()))},slugify(){return this.check(nr(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})),ao=re("ZodString",(e,t)=>{bt.init(e,t),so.init(e,t)},{email(e){return this.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...j(t)})}(mo,e))},url(e){return this.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...j(t)})}(vo,e))},jwt(e){return this.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...j(t)})}(To,e))},emoji(e){return this.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...j(t)})}(_o,e))},guid(e){return this.check(function(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...j(t)})}(yo,e))},uuid(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...j(t)})}(go,e))},uuidv4(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(t)})}(go,e))},uuidv6(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(t)})}(go,e))},uuidv7(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(t)})}(go,e))},nanoid(e){return this.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(t)})}(bo,e))},cuid(e){return this.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...j(t)})}(wo,e))},cuid2(e){return this.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(t)})}(zo,e))},ulid(e){return this.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...j(t)})}(ko,e))},base64(e){return this.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...j(t)})}(Ao,e))},base64url(e){return this.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...j(t)})}(Eo,e))},xid(e){return this.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...j(t)})}($o,e))},ksuid(e){return this.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(t)})}(Oo,e))},ipv4(e){return this.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(t)})}(jo,e))},ipv6(e){return this.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(t)})}(So,e))},cidrv4(e){return this.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(t)})}(xo,e))},cidrv6(e){return this.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(t)})}(Po,e))},e164(e){return this.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...j(t)})}(Io,e))},datetime(e){return this.check(function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(t)})}(lo,e))},date(e){return this.check(function(e,t){return new e({type:"string",format:"date",check:"string_format",...j(t)})}(fo,e))},time(e){return this.check(function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...j(t)})}(po,e))},duration(e){return this.check(function(e,t){return new e({type:"string",format:"duration",check:"string_format",...j(t)})}(ho,e))}});function co(e){return function(e,t){return new e(((n={type:"string",...j(t)}).checks&&(n.checks=[...n.checks]),n));var n}(ao,e)}const uo=re("ZodStringFormat",(e,t)=>{wt.init(e,t),so.init(e,t)}),lo=re("ZodISODateTime",(e,t)=>{Nt.init(e,t),uo.init(e,t)}),fo=re("ZodISODate",(e,t)=>{Ut.init(e,t),uo.init(e,t)}),po=re("ZodISOTime",(e,t)=>{Dt.init(e,t),uo.init(e,t)}),ho=re("ZodISODuration",(e,t)=>{Ct.init(e,t),uo.init(e,t)}),mo=re("ZodEmail",(e,t)=>{$t.init(e,t),uo.init(e,t)}),yo=re("ZodGUID",(e,t)=>{zt.init(e,t),uo.init(e,t)}),go=re("ZodUUID",(e,t)=>{kt.init(e,t),uo.init(e,t)}),vo=re("ZodURL",(e,t)=>{Pt.init(e,t),uo.init(e,t)}),_o=re("ZodEmoji",(e,t)=>{At.init(e,t),uo.init(e,t)}),bo=re("ZodNanoID",(e,t)=>{Et.init(e,t),uo.init(e,t)}),wo=re("ZodCUID",(e,t)=>{It.init(e,t),uo.init(e,t)}),zo=re("ZodCUID2",(e,t)=>{Tt.init(e,t),uo.init(e,t)}),ko=re("ZodULID",(e,t)=>{Zt.init(e,t),uo.init(e,t)}),$o=re("ZodXID",(e,t)=>{Ft.init(e,t),uo.init(e,t)}),Oo=re("ZodKSUID",(e,t)=>{Rt.init(e,t),uo.init(e,t)}),jo=re("ZodIPv4",(e,t)=>{Jt.init(e,t),uo.init(e,t)}),So=re("ZodIPv6",(e,t)=>{Kt.init(e,t),uo.init(e,t)}),xo=re("ZodCIDRv4",(e,t)=>{Bt.init(e,t),uo.init(e,t)}),Po=re("ZodCIDRv6",(e,t)=>{Wt.init(e,t),uo.init(e,t)}),Ao=re("ZodBase64",(e,t)=>{Yt.init(e,t),uo.init(e,t)}),Eo=re("ZodBase64URL",(e,t)=>{Ht.init(e,t),uo.init(e,t)}),Io=re("ZodE164",(e,t)=>{Xt.init(e,t),uo.init(e,t)}),To=re("ZodJWT",(e,t)=>{Qt.init(e,t),uo.init(e,t)}),Zo=re("ZodBoolean",(e,t)=>{en.init(e,t),io.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Fo(e){return function(e,t){return new e({type:"boolean",...j(t)})}(Zo,e)}const Ro=re("ZodUnknown",(e,t)=>{tn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function No(){return new Ro({type:"unknown"})}const Uo=re("ZodNever",(e,t)=>{nn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Do(e){return function(e,t){return new e({type:"never",...j(t)})}(Uo,e)}const Co=re("ZodArray",(e,t)=>{oo(),sn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=Ar(e);"number"==typeof s&&(o.minItems=s),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=ar(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element},{min(e,t){return this.check(er(e,t))},nonempty(e){return this.check(er(1,e))},max(e,t){return this.check(Qn(e,t))},length(e,t){return this.check(tr(e,t))},unwrap(){return this.element}});function Jo(e,t){return function(e,t,n){return new e({type:"array",element:t,...j(n)})}(Co,e,t)}const Lo=re("ZodObject",(e,t)=>{oo(),dn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&sr(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const e in s)l(o.properties,e,ar(s[e],t,{...r,path:[...r.path,"properties",e]}));const a=[];for(const e of Object.keys(s)){const n=i.shape[e];("input"===t.io?void 0===Zr(n):void 0===n._zod.optout)&&a.push(e)}a.length>0&&(o.required=a),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=ar(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),X(e,"shape",e=>e._zod.def.shape,!1)},{keyof(){return Go(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(y(this._zod.def,{catchall:e}))},passthrough(){return this.clone(y(this._zod.def,{catchall:No()}))},loose(){return this.clone(y(this._zod.def,{catchall:No()}))},strict(){return this.clone(y(this._zod.def,{catchall:Do()}))},strip(){return this.clone(y(this._zod.def,{catchall:void 0}))},extend(e){return function(e,t){if(!w(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=d(e);for(const e of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return O(e,y(e._zod.def,{shape:E(e,t)}))}(this,e)},safeExtend(e){return function(e,t){if(!w(t))throw new Error("Invalid input to safeExtend: expected a plain object");return O(e,y(e._zod.def,{shape:E(e,t)}))}(this,e)},merge(e){return function(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};return m(n,e,Reflect.ownKeys(d(e))),m(n,t,Reflect.ownKeys(d(t))),O(e,y(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return m(o,e,A(e,t)),O(e,y(n,{shape:o,checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(A(e,t)),i={};return m(i,e,Reflect.ownKeys(d(e)).filter(e=>!o.has(e))),O(e,y(n,{shape:i,checks:[]}))}(this,e)},partial(...e){return I(ei,this,e[0])},exactPartial(...e){return I(ni,this,e[0],"exactPartial")},required(...e){return function(e,t,n){const r=n?new Set(A(t,n)):void 0,o={};return m(o,t,Reflect.ownKeys(d(t)),(t,n)=>r&&!r.has(n)?t:new e({type:"nonoptional",innerType:t})),O(t,y(t._zod.def,{shape:o}))}(ai,this,e[0])}});function Mo(e,t){const n={type:"object",shape:e??{},...j(t)};return new Lo(n)}const Ko=re("ZodUnion",(e,t)=>{hn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map((e,n)=>ar(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options});function Bo(e,t){return new Ko({type:"union",options:e,...j(t)})}const Wo=re("ZodIntersection",(e,t)=>{mn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=ar(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=ar(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)})(e,t,n,r)});const qo=re("ZodRecord",(e,t)=>{oo(),vn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nr(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Vo(e,t,n){return t&&t._zod?new qo({type:"record",keyType:e,valueType:t,...j(n)}):new qo({type:"record",keyType:co(),valueType:e,...j(t)})}const Yo=re("ZodEnum",(e,t)=>{_n.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=o(e._zod.def.entries);0!==r.length?(r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r):n.not={}})(e,0,n),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new Yo({...t,checks:[],...j(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new Yo({...t,checks:[],...j(r),entries:o})}});function Go(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Yo({type:"enum",entries:n,...j(t)})}const Ho=re("ZodLiteral",(e,t)=>{bn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;if(0===o.values.length)return void(n.not={});const i=[];for(const s of o.values)if(void 0===s){if(sr(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof s){if(sr(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Xo(e,t){return new Ho({type:"literal",values:Array.isArray(e)?e:[e],...j(t)})}const Qo=re("ZodTransform",(e,t)=>{oo(),wn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{sr(e,t,n,r,"Transforms cannot be represented in JSON Schema")})(e,t,n,r),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ie(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(M(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),"input"in t||(t.input=n.value),t.inst??(t.inst=e),n.issues.push(M(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n)):(n.value=o,n)}});const ei=re("ZodOptional",(e,t)=>{kn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function ti(e){return new ei({type:"optional",innerType:e})}const ni=re("ZodExactOptional",(e,t)=>{$n.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});const ri=re("ZodNullable",(e,t)=>{On.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=ar(o.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oi(e){return new ri({type:"nullable",innerType:e})}const ii=re("ZodDefault",(e,t)=>{jn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ar(o.innerType,t,r),t.seen.get(e).ref=o.innerType;const i=Dr(o.defaultValue,e,t,n,r);i!==Ur&&(n.default=i)})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const si=re("ZodPrefault",(e,t)=>{xn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;if(ar(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"!==t.io)return;const i=Dr(o.defaultValue,e,t,n,r);i!==Ur&&(n._prefault=i)})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const ai=re("ZodNonOptional",(e,t)=>{Pn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ar(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});const ci=re("ZodCatch",(e,t)=>{In.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;ar(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{return void sr(e,t,n,r,"Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const ui=re("ZodPipe",(e,t)=>{Tn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s="input"===t.io?i?o.out:o.in:o.out;ar(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function li(e,t){return new ui({type:"pipe",in:e,out:t})}const fi=re("ZodReadonly",(e,t)=>{Fn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ar(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const di=re("ZodCustom",(e,t)=>{Nn.init(e,t),io.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{sr(e,t,n,r,"Custom types cannot be represented in JSON Schema")})(e,t,n,r)});const pi="directus:extension";Object.fromEntries(["@directus/extensions-sdk","vue","vue-router","vue-i18n","pinia","@tiptap/core","@tiptap/vue-3","@tiptap/pm/commands","@tiptap/pm/dropcursor","@tiptap/pm/gapcursor","@tiptap/pm/history","@tiptap/pm/keymap","@tiptap/pm/model","@tiptap/pm/schema-list","@tiptap/pm/state","@tiptap/pm/tables","@tiptap/pm/transform","@tiptap/pm/view"].filter(e=>e.startsWith("@tiptap/pm/")).map(e=>[`prosemirror-${e.slice(11)}`,e]));const hi=Mo({app:co(),api:co()}),mi=Mo({request:ti(Mo({urls:Jo(co()),methods:Jo(Bo([Xo("GET"),Xo("POST"),Xo("PATCH"),Xo("PUT"),Xo("DELETE")]))})),log:ti(Mo({})),sleep:ti(Mo({}))}),yi=ti(Mo({enabled:ti(Fo()),requestedScopes:ti(mi)})),gi=Bo([Mo({type:Go(n),name:co(),source:co()}),Mo({type:Go(t),name:co(),source:co()}),Mo({type:Go(r),name:co(),source:hi})]),vi=Mo({host:co(),hidden:Fo().optional()}),_i=Mo({type:Go(t),path:co(),source:co()}),bi=Mo({type:Go(n),path:co(),source:co(),sandbox:yi}),wi=Mo({type:Go(r),path:hi,source:hi,sandbox:yi}),zi=Mo({type:Xo("bundle"),partial:Fo().optional(),path:hi,entries:Jo(gi)}),ki=vi.and(Bo([_i,bi,wi,zi]));function $i(e,t){const n=e.collections;if(!n||"object"!=typeof n)return[];const r=[];for(const[e,o]of Object.entries(n)){const n=o?.fields;if(n&&"object"==typeof n)for(const[o,i]of Object.entries(n)){const n=i?.special;Array.isArray(n)&&n.includes("file")&&(t.some(t=>t.collection===e&&t.field===o)||r.push({collection:e,field:o,related_collection:"directus_files",meta:{many_collection:e,many_field:o,one_collection:"directus_files",one_field:null,one_collection_field:null,one_allowed_collections:null,junction_field:null}}))}}return r}function Oi(e){if("string"==typeof e&&e)return e;if("number"==typeof e)return String(e);if(e&&"object"==typeof e&&"id"in e){const t=e.id;if("string"==typeof t||"number"==typeof t)return String(t)}return null}async function ji(t){const n={schema:t.schema,accountability:t.accountability},r=function(e){const t=Array.isArray(e.relations)?e.relations.flatMap(e=>{if(!e||"object"!=typeof e)return[];const t=e;return"string"!=typeof t.collection||"string"!=typeof t.field?[]:[t]}):[];return[...t,...$i(e,t)]}(t.schema);return{assetsOrigin:t.assetsOrigin,relations:()=>Promise.resolve(r),read:async(e,r,o)=>new t.services.ItemsService(e,n).readOne(r,{fields:o}),fieldState:async(e,o,i)=>{const s=new t.services.FieldsService(n),a=await s.readOne(e,i),c=a.meta?.special??[],u=c.includes("files")?"files":c.includes("file")?"file":"other",l=r.find(t=>t.meta?.one_collection===e&&t.meta.one_field===i),f=l?.meta?.junction_field??("files"===u?"directus_files_id":null);if("other"===u)return{kind:u,junctionField:f,fileIds:[],junctionIds:[]};const d=new t.services.ItemsService(e,n),p="files"===u&&f?[`${i}.id`,`${i}.${f}`]:[i],h=(await d.readOne(o,{fields:p}))[i];if("file"===u){const e=Oi(h);return{kind:u,junctionField:f,fileIds:e?[e]:[],junctionIds:[]}}const m=Array.isArray(h)?h:[],y=m.flatMap(e=>{if(!e||"object"!=typeof e||!("id"in e))return[];const t=e.id;return"string"==typeof t||"number"==typeof t?[t]:[]}),g=m.flatMap(e=>{if(!e||"object"!=typeof e||!f)return[];const t=Oi(e[f]);return t?[t]:[]});return{kind:u,junctionField:f,fileIds:g,junctionIds:y}},upload:async(r,o)=>{const i=new t.services.FilesService(n),s={filename_download:o.filename,type:"application/pdf",title:o.title};o.storage&&(s.storage=o.storage),o.folder&&(s.folder=o.folder);const a=await i.uploadOne(e.from(Buffer.from(r)),s);return String(a)},update:async(e,r,o)=>{const i=new t.services.ItemsService(e,n);await i.updateOne(r,o)},deleteFiles:async e=>{if(!e.length)return;const r=new t.services.FilesService(n);await r.deleteMany(e)}}}function Si(e){const t=Array.isArray(e)?e[0]??"":e??"";return t.split(",")[0]?.trim()??""}function xi(e,t){const n=e.PUBLIC_URL;if("string"==typeof n&&/^https?:\/\//i.test(n.trim()))return n.trim().replace(/\/+$/,"");if(t?.headers){const e=Si(t.headers["x-forwarded-host"])||Si(t.headers.host);if(e){return`${Si(t.headers["x-forwarded-proto"])||t.protocol||"http"}://${e}`}}return"http://localhost:8055"}Mo({name:co(),version:co(),type:Bo([Xo("module"),Xo("commonjs")]).optional(),description:co().optional(),icon:co().optional(),dependencies:Vo(co(),co()).optional(),devDependencies:Vo(co(),co()).optional(),[pi]:ki});const Pi="https://api.docuberry.com",Ai=new Set(["localhost","127.0.0.1","host.docker.internal"]);function Ei(e){if(null==e||""===e)return Pi;if("string"!=typeof e)return null;const t=e.trim().replace(/\/+$/,"");if(!t)return Pi;if(t.includes("{{"))return null;let n;try{n=new URL(t)}catch{return null}return n.username||n.password||n.search||n.hash||"/"!==n.pathname&&""!==n.pathname||function(e){const t=e.toLowerCase().replace(/^\[|\]$/g,"");if("127.0.0.1"===t||"::1"===t)return!1;const n=t.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!n)return t.startsWith("fe80:")||t.startsWith("fc")||t.startsWith("fd");const r=n.slice(1).map(e=>Number(e));if(r.some(e=>e>255))return!0;const[o,i]=r;return void 0===o||void 0===i||10===o||0===o||127===o||169===o&&254===i||172===o&&i>=16&&i<=31||192===o&&168===i||100===o&&i>=64&&i<=127}(n.hostname)?null:"https:"===n.protocol||"http:"===n.protocol&&Ai.has(n.hostname.toLowerCase())?n.origin:null}function Ii(e,t){if("string"==typeof e&&e.trim()&&!e.includes("{{")){const t=Ei(e);if(!t)throw new Error("API base URL must be https, or http://localhost for a local Docuberry API.");return t}const n="string"==typeof t?Ei(t):null;if("string"==typeof t&&t.trim()&&!n)throw new Error("DOCUBERRY_API_URL must be https, or http://localhost for a local Docuberry API.");return n??Pi}function Ti(e){try{return new URL(e).host}catch{return"api.docuberry.com"}}class Zi extends Error{constructor(e,t){super(e),this.name="DocuberryError",this.status=t}}async function Fi(e,t,n,r={}){let o;try{o=await fetch(function(e,t){const n=e.replace(/\/+$/,""),r=t.replace(/^\/+|\/+$/g,"");return r?`${n}/api/v1/${r}`:`${n}/api/v1`}(e,n),{...r,headers:{Authorization:`Bearer ${t}`,...r.body?{"Content-Type":"application/json"}:{}},signal:AbortSignal.timeout(6e4)})}catch{throw new Zi("Could not reach Docuberry.",0)}if(!o.ok)throw new Zi(await async function(e){try{const t=await e.json();if("string"==typeof t.error&&t.error.trim())return t.error.trim()}catch{}return 401===e.status?"Docuberry rejected the API key.":`Docuberry request failed (${e.status})`}(o),o.status);return o}function Ri(e,t){const n=Ii(t,e.DOCUBERRY_API_URL),r="string"==typeof e.DOCUBERRY_API_KEY?e.DOCUBERRY_API_KEY.trim():"";if(!r)throw new Zi("Set DOCUBERRY_API_KEY on the Directus service.",503);return{baseUrl:n,apiKey:r}}async function Ni(e,t){const n=await Fi(e,t,"/templates"),r=await n.json();return Array.isArray(r.templates)?r.templates:[]}async function Ui(e,t,n){try{const r=await Fi(e,t,`/templates/${encodeURIComponent(n)}`),o=await r.json();return Array.isArray(o.paths)?o.paths.filter(e=>"string"==typeof e):[]}catch{return null}}function Di(e,t){return function(e){const t=e.replace(/[\u0000-\u001f\u007f"\\/:*?<>|]+/g," ").replace(/\s+/g," ").trim().slice(0,120)||"document";return t.toLowerCase().endsWith(".pdf")?t:`${t}.pdf`}((e.trim()||"{template} {id}").replace(/\{([^{}]+)\}/g,(e,n)=>{const r=n.trim();if("template"===r)return t.template;if("id"===r)return t.id;if("collection"===r)return t.collection;const o=function(e,t){const n=t.split(".").map(e=>e.trim()).filter(Boolean);let r=e;for(const e of n){if(!r||"object"!=typeof r)return;r=r[e]}return r}(t.item,r);return"string"==typeof o||"number"==typeof o?String(o):""}))}function Ci(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function Ji(e){if("string"!=typeof e)return null;const t=e.trim();return!t||t.includes("{{")?null:t}function Li(e){if("number"==typeof e&&Number.isFinite(e))return[e];if("string"==typeof e){const t=e.trim();if(!t||t.includes("{{"))return[];if(t.startsWith("[")||t.startsWith("{"))try{return Li(JSON.parse(t))}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}if(Array.isArray(e))return e.flatMap(e=>"string"==typeof e||"number"==typeof e?Li(e):Ci(e)&&"id"in e?Li(e.id):Ci(e)&&"key"in e?Li(e.key):[]);if(Ci(e)){if("keys"in e)return Li(e.keys);if("key"in e)return Li(e.key);if("id"in e)return Li(e.id)}return[]}function Mi(e,t){const n=Li(e);if(n.length)return n;if(!Ci(t))return[];const r=Li(t.keys);if(r.length)return r;const o=Li(t.key);if(o.length)return o;if(!Ci(t.body))return[];const i=Li(t.body.keys);return i.length?i:Li(t.body.key)}function Ki(e){if("string"==typeof e){const t=e.trim();if(!t||t.includes("{{"))return null;try{return Ki(JSON.parse(t))}catch{return null}}if(Array.isArray(e)){const t=e.filter(Ci);return t.length?t:null}return Ci(e)&&Object.keys(e).length>0?e:null}function Bi(e,t){return"boolean"==typeof e?e:"true"===e||"false"!==e&&t}function Wi(e){return Ji(e)}const qi={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ndash:"–",mdash:"—",hellip:"…",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",laquo:"«",raquo:"»",copy:"©",reg:"®",trade:"™",euro:"€",bull:"•",middot:"·",auml:"ä",ouml:"ö",uuml:"ü",Auml:"Ä",Ouml:"Ö",Uuml:"Ü",szlig:"ß"},Vi=/<\/?[a-zA-Z][^>]*>/;function Yi(e){let t=e.replace(/<!--[\s\S]*?-->/g,"").replace(/<(script|style|head)\b[\s\S]*?<\/\1\s*>/gi,"").replace(/\r\n?/g,"\n").replace(/<br\s*\/?>/gi,"\n").replace(/<hr\s*\/?>/gi,"\n\n").replace(/<li\b[^>]*>/gi,"\n• ").replace(/<\/(p|div|h[1-6]|ul|ol|tr|table|blockquote|pre|section|article|figure|figcaption|header|footer)\s*>/gi,"\n").replace(/<(p|div|h[1-6]|ul|ol|tr|table|blockquote|pre|section|article|figure)\b[^>]*>/gi,"\n").replace(/<\/t[dh]\s*>/gi,"\t").replace(/<\/?[a-zA-Z][^>]*>/g,"");return t=function(e){return e.replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]*);/gi,(e,t)=>{if("#"===t[0]){const n="x"===t[1]?.toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10);if(!Number.isFinite(n)||n<=0||n>1114111)return e;try{return String.fromCodePoint(n)}catch{return e}}return qi[t]??qi[t.toLowerCase()]??e})}(t),t=t.split("\n").map(e=>e.replace(/[ \t\u00a0]+/g," ").trim()).join("\n").replace(/\n{3,}/g,"\n\n").trim(),t}function Gi(e){if("string"==typeof e)return function(e){return Vi.test(e)||/<!--[\s\S]*?-->/.test(e)}(e)?Yi(e):e;if(Array.isArray(e))return e.map(e=>Gi(e));if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))t[n]=Gi(r);return t}return e}function Hi(e){const t=new Set,n=[];for(const r of e)if(r&&!t.has(r)&&(t.add(r),n.push(r),n.length>=200))break;return n}function Xi(e){return e.meta}function Qi(e,t){return e.filter(e=>{const n=Xi(e);return e.collection===t&&Boolean(e.related_collection)&&n?.many_collection===t&&n.many_field===e.field&&!n.junction_field})}function es(e,t){return e.filter(e=>{const n=Xi(e);return n?.one_collection===t&&Boolean(n.one_field)})}function ts(e,t){const n=t.meta?.junction_field;if(!n)return null;const r=e.find(e=>e.collection===t.collection&&e.field===n);return r?.related_collection??null}function ns(e,t){return e?`${e}${t}`:t}function rs(e,t,n,r,o){const i=n?`${n}*`:"*";if(r<=0||o.includes(t))return[i];const s=[...o,t],a=[i];for(const o of Qi(e,t)){const t=o.related_collection;if(!t)continue;const i=`${ns(n,o.field)}.`;a.push(...rs(e,t,i,r-1,s))}for(const o of es(e,t)){const t=o.meta;if(!t?.one_field)continue;const i=t.one_allowed_collections?.filter(Boolean)??[];if(t.junction_field&&i.length){for(const o of i){const i=`${n}${t.one_field}.${t.junction_field}:${o}.`;a.push(...rs(e,o,i,r-1,s))}continue}if(t.junction_field){const i=ts(e,o),c=`${n}${t.one_field}.${t.junction_field}.`;i?a.push(...rs(e,i,c,r-1,s)):a.push(`${c}*`);continue}const c=`${n}${t.one_field}.`;a.push(...rs(e,o.collection,c,r-1,s))}return a}function os(e,t,n){return Hi(rs(e,t,"",n,[]))}function is(e,t,n,r,o){const[i,...s]=n;if(!i)return r?[r.slice(0,-1)]:["*"];if(o.includes(`${t}:${i}`))return[];const a=function(e,t,n){if(Qi(e,t).some(e=>e.field===n))return null;if(es(e,t).some(e=>e.meta?.one_field===n))return null;const r=/^(.+)_(id|file|files)$/.exec(n),o=r?.[1];if(!r||!o)return null;const i=r[2];return!Qi(e,t).some(e=>e.field===o&&"directus_files"===e.related_collection)||"id"!==i&&"file"!==i?es(e,t).find(e=>e.meta?.one_field===o)&&"files"===i?{base:o,keepRest:!0}:null:{base:o,keepRest:"file"===i}}(e,t,i);if(a)return is(e,t,[a.base,...a.keepRest?s:[]],r,o);const c=[...o,`${t}:${i}`],u=Qi(e,t).find(e=>e.field===i);if(u?.related_collection){const t=`${r}${i}.`;return s.length?is(e,u.related_collection,s,t,c):[`${t}*`]}const l=es(e,t).find(e=>e.meta?.one_field===i);if(l?.meta?.one_field){const t=l.meta,n=t.one_allowed_collections?.filter(Boolean)??[];if(t.junction_field&&n.length)return s.length?n.flatMap(n=>is(e,n,s,`${r}${i}.${t.junction_field}:${n}.`,c)):n.map(e=>`${r}${i}.${t.junction_field}:${e}.*`);if(t.junction_field){const n=ts(e,l),o=`${r}${i}.${t.junction_field}.`;return s.length?n?is(e,n,s,o,c):[`${o}${s.join(".")}`]:[`${o}*`]}const o=`${r}${i}.`;return s.length?is(e,l.collection,s,o,c):[`${o}*`]}return[`${r}${n.join(".")}`]}function ss(e,t,n){return Hi(["id",...n.flatMap(n=>is(e,t,function(e){return e.split(".").map(e=>e.trim()).filter(Boolean)}(n),"",[]))])}function as(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function cs(e,t){const n=function(e){return"string"==typeof e&&e?e:"number"==typeof e?String(e):!as(e)||"string"!=typeof e.id&&"number"!=typeof e.id?null:String(e.id)}(e);if(!n)return null;const r=function(e,t){return`${e.replace(/\/+$/,"")}/assets/${encodeURIComponent(t)}`}(t,n);return{url:r,id:n,file:as(e)?{...e,url:r}:{id:n,url:r}}}function us(e){return"directus_files"===e}function ls(e,t){const n=t.meta?.junction_field;return n?e.find(e=>e.collection===t.collection&&e.field===n)?.related_collection??null:null}function fs(e,t,n,r,o,i=[]){if(Array.isArray(e))return e.map(e=>fs(e,t,n,r,o,i));if(!as(e))return e;if(i.includes(t)||o<0)return e;const s=[...i,t],a={};for(const[i,c]of Object.entries(e)){const e=Qi(n,t).find(e=>e.field===i);if(e?.related_collection){if(us(e.related_collection)){const e=cs(c,r);e?(a[i]=e.url,a[`${i}_id`]=e.id,a[`${i}_file`]=e.file):a[i]=c;continue}a[i]=fs(c,e.related_collection,n,r,o-1,s);continue}const u=es(n,t).find(e=>e.meta?.one_field===i);if(u?.meta&&Array.isArray(c)){const e=u.meta;if(e.junction_field&&e.one_allowed_collections?.length){a[i]=c.map(t=>ds(t,e.junction_field,n,r,o-1,s));continue}if(e.junction_field){a[i]=c.map(t=>{if(!as(t)||!e.junction_field)return t;const i=t[e.junction_field],a=n.find(t=>t.collection===u.collection&&t.field===e.junction_field)?.related_collection;return a&&(as(i)||"string"==typeof i||"number"==typeof i)?us(a)?cs(i,r)?.url??null:fs(i,a,n,r,o-1,s):t}),us(ls(n,u))&&(a[`${i}_files`]=c.map(t=>{const n=as(t)&&e.junction_field?t[e.junction_field]:null;return cs(n,r)?.file??null}));continue}a[i]=c.map(e=>fs(e,u.collection,n,r,o-1,s));continue}a[i]=c}return a}function ds(e,t,n,r,o,i){if(!as(e))return e;const s="string"==typeof e.collection?e.collection:null,a=t?e[t]:null;if(s&&as(a)){const e=fs(a,s,n,r,o,i);return as(e)?{...e,collection:s}:{collection:s,item:e}}return e}function ps(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function hs(e,t,n){if(!ps(t))return;const[r,...o]=n;if(!r||!(r in t))return;const i=t[r];if(o.length){if(Array.isArray(i)){const t=Array.isArray(e[r])?e[r]:[];return void(e[r]=i.map((e,n)=>{const r=ps(t[n])?{...t[n]}:{};return ps(e)&&"id"in e&&!("id"in r)&&(r.id=e.id),ps(e)&&"collection"in e&&!("collection"in r)&&(r.collection=e.collection),hs(r,e,o),r}))}if(ps(i)){const t=ps(e[r])?{...e[r]}:{};"id"in i&&!("id"in t)&&(t.id=i.id),hs(t,i,o),e[r]=t}}else e[r]=i}function ms(e){return e instanceof Zi||e instanceof Error&&e.message?e.message:"Could not generate the PDF."}function ys(e,t){const n=function(e,t){const n=Ji(e);if(n)return n;if(!Ci(t))return null;const r=Ji(t.collection);return r||(Ci(t.body)?Ji(t.body.collection):null)}(e.collection,t),r=Mi(e.keys,t).slice(0,50),o=Ki(e.payload);if(Array.isArray(o)){return{collection:n,jobs:o.slice(0,50).map((e,t)=>({itemId:r[t]??("string"==typeof e.id||"number"==typeof e.id?e.id:null),data:e,load:!1})),explicitPayload:!0}}if(o){return{collection:n,jobs:(r.length?r:["string"==typeof o.id||"number"==typeof o.id?o.id:null]).map(e=>({itemId:e,data:o,load:!1})),explicitPayload:!0}}return{collection:n,jobs:r.map(e=>({itemId:e,data:null,load:!0})),explicitPayload:!1}}async function gs(e){const t=Wi(e.options.templateId);if(!t)throw new Error("Choose a Docuberry template.");const n=function(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):2;return Number.isFinite(t)?Math.min(4,Math.max(0,Math.floor(t))):2}(e.options.depth),r=Bi(e.options.replace,!0),o=Bi(e.options.link,!0),i=Bi(e.options.continueOnError,!0),s=Wi(e.options.targetField),a=Wi(e.options.filename)??"{template} {id}",c=function(e){const t=Wi(e);if(!t)return null;if(!/^[0-9a-f-]{32,36}$/i.test(t))throw new Error("Folder must be a Directus folder id.");return t}(e.options.folder),u=Wi(e.options.storage),l=Wi(e.options.fields),{collection:f,jobs:d,explicitPayload:p}=ys(e.options,e.trigger);if(!d.length)throw new Error("No items to generate. Pass item keys, or run this from an item event.");if(o&&(!f||!s))throw new Error("Set the collection and the file field so the PDF can be saved on the item.");if(Mi(e.options.keys,e.trigger).length>50)throw new Error("Generate at most 50 items at a time.");let h=t;try{const n=await Ni(e.baseUrl,e.apiKey);h=n.find(e=>e.id===t)?.name??t}catch(e){if(e instanceof Zi&&401===e.status)throw e}let m=null;l||p||(m=await Ui(e.baseUrl,e.apiKey,t));const y=f?await e.access.relations():[],g=f?function(e){return e.explicit?{fields:(t=e.explicit,Hi(t.split(",").map(e=>e.trim()).filter(Boolean))),mode:"fields"}:e.paths?{fields:ss(e.relations,e.collection,e.paths),mode:"template"}:{fields:os(e.relations,e.collection,e.depth),mode:"depth"};var t}({relations:y,collection:f,depth:n,explicit:l,paths:l||p?null:m}):null,v=!1!==e.store,_=[];for(const b of d){const d=await vs({job:b,templateId:t,templateName:h,collection:f,relations:y,planFieldsList:g?.fields??["*"],mode:p?"payload":g?.mode??"depth",paths:l||p?null:m,depth:n,filenamePattern:a,targetField:s,replace:r,link:v&&o,folder:c,storage:u,store:v,access:e.access,baseUrl:e.baseUrl,apiKey:e.apiKey});if(_.push(d),d.error&&!i)throw new Error(d.error)}const b=_.filter(e=>e.fileId&&!e.error&&!e.skipped).length,w=_.filter(e=>e.error).length,z=_.filter(e=>e.skipped).length,k=_.find(e=>e.fileId)??_[0];return{ok:0===w,templateId:t,collection:f,fileId:k?.fileId??null,itemId:k?.itemId??null,filename:k?.filename??null,saved:b,failed:w,skipped:z,results:_,errors:_.flatMap(e=>e.error?[{itemId:e.itemId,message:e.error}]:[])}}async function vs(e){const t={itemId:e.job.itemId,fileId:null,filename:null,skipped:!1,error:null,sentPaths:e.paths,mode:e.mode};try{if(e.link&&e.collection&&e.targetField&&null!=e.job.itemId&&!e.replace){const n=await e.access.fieldState(e.collection,e.job.itemId,e.targetField);if("file"===n.kind&&n.fileIds.length)return{...t,skipped:!0,fileId:n.fileIds[0]??null}}let n=e.job.data;if(e.job.load){if(!e.collection||null==e.job.itemId)throw new Error("Collection and item id are required.");n=await e.access.read(e.collection,e.job.itemId,e.planFieldsList)}if(!n)throw new Error("Item payload is empty.");const r=e.collection&&"payload"!==e.mode?fs(n,e.collection,e.relations,e.access.assetsOrigin,e.depth):n;e.collection&&"payload"!==e.mode&&e.targetField&&ps(r)&&ps(n)&&e.targetField in n&&(r[e.targetField]=n[e.targetField]);const o=e.paths&&ps(r)?function(e,t){const n={};if(!ps(e))return n;"id"in e&&(n.id=e.id);for(const r of t){const t=r.split(".").map(e=>e.trim()).filter(Boolean);t.length&&hs(n,e,t)}return n}(r,e.paths):ps(r)?r:{value:r},i="payload"===e.mode?o:Gi(o),s=null==e.job.itemId?"":String(e.job.itemId),a=Di(e.filenamePattern,{template:e.templateName,id:s,collection:e.collection??"",item:ps(r)?r:{}}),c=await async function(e,t,n,r,o){const i=await Fi(e,t,`/templates/${encodeURIComponent(n)}/render`,{method:"POST",body:JSON.stringify({data:r,filename:o,publish:!1})}),s=new Uint8Array(await i.arrayBuffer());if(!function(e){return e.byteLength>=5&&37===e[0]&&80===e[1]&&68===e[2]&&70===e[3]}(s))throw new Zi("Docuberry did not return a PDF.",502);return s}(e.baseUrl,e.apiKey,e.templateId,i,a);if(!e.store)return{...t,filename:a,bytes:c};const u=await e.access.upload(c,{filename:a,folder:e.folder,storage:e.storage,title:a.replace(/\.pdf$/i,"")});if(e.link&&e.collection&&e.targetField&&null!=e.job.itemId){const t=await e.access.fieldState(e.collection,e.job.itemId,e.targetField);if("other"===t.kind)throw new Error(`Field ${e.targetField} is not a file field.`);if(await e.access.update(e.collection,e.job.itemId,function(e,t,n,r){if("files"===n.kind){const o=n.junctionField??"directus_files_id";return{[e]:{create:[{[o]:t}],update:[],delete:r?n.junctionIds:[]}}}return{[e]:t}}(e.targetField,u,t,e.replace)),e.replace){const n=t.fileIds.filter(e=>e!==u);n.length&&await e.access.deleteFiles(n)}}return{...t,fileId:u,filename:a}}catch(e){return{...t,error:ms(e)}}}var _s={id:"docuberry-generate",handler:async(e,t)=>{const n=t,{baseUrl:r,apiKey:o}=Ri(n.env,e.apiUrl),i=await n.getSchema(),s=await ji({services:n.services,schema:i,accountability:n.accountability??null,assetsOrigin:xi(n.env)});return function(e){return{...e,results:e.results.map(({bytes:e,...t})=>t)}}(await gs({options:{...e,link:e.link??!0},trigger:n.data?.$trigger,baseUrl:r,apiKey:o,access:s}))}};class bs extends Error{constructor(e,t){super(e),this.name="RequestError",this.status=t}}function ws(e){const t=e.accountability??null;if(t?.admin||t?.user)return t;throw new bs("Sign in required.",401)}function zs(e){if(!e.body||"object"!=typeof e.body||Array.isArray(e.body))return{};const t={...e.body};return delete t.apiKey,t}function ks(e,t){return{templateId:e.templateId,collection:e.collection,keys:e.keys??e.key,payload:e.payload,fields:e.fields,depth:e.depth,targetField:e.targetField,filename:e.filename,replace:e.replace,folder:e.folder,storage:e.storage,apiUrl:e.apiUrl,continueOnError:!1,link:t}}function $s(e){return e instanceof bs?e.status:e instanceof Zi?503===e.status?503:502:e instanceof Error&&/^(API base URL|DOCUBERRY_API_URL|Folder must|Choose a|No items|Collection and item)|not a file field|at most/.test(e.message)?400:500}function Os(e){return e instanceof Error&&e.message?e.message:"Could not generate the PDF."}async function js(e,t,n){const r=await e.getSchema();return ji({services:e.services,schema:r,accountability:t,assetsOrigin:xi(e.env,n)})}var Ss={id:"docuberry",handler:(e,t)=>{const n=e,r=t;n.get("/status",(e,t)=>{try{ws(e);const n=Boolean(function(e,t){const n=e[t];if("string"!=typeof n)return;return n.trim()||void 0}(r.env,"DOCUBERRY_API_KEY"));let o="https://api.docuberry.com";try{o=Ii(void 0,r.env.DOCUBERRY_API_URL)}catch{o="https://api.docuberry.com"}t.json({configured:n,apiHost:Ti(o),apiUrl:o})}catch(e){t.status($s(e)).json({error:Os(e)})}}),n.get("/templates",async(e,t)=>{try{ws(e);const{baseUrl:n,apiKey:o}=Ri(r.env,void 0),i=await Ni(n,o);t.json({templates:i})}catch(e){t.status($s(e)).json({error:Os(e)})}}),n.get("/templates/:id",async(e,t)=>{try{ws(e);const n=e.params.id??"";if(!n)throw new bs("Template id is required.",400);const{baseUrl:o,apiKey:i}=Ri(r.env,void 0),s=await Ui(o,i,n);t.json({paths:s})}catch(e){t.status($s(e)).json({error:Os(e)})}}),n.post("/preview",async(e,t)=>{try{const n=ws(e),o=ks(zs(e),!1),{baseUrl:i,apiKey:s}=Ri(r.env,o.apiUrl),a=await gs({options:o,trigger:null,baseUrl:i,apiKey:s,access:await js(r,n,e),store:!1}),c=a.results[0]?.bytes;if(!c)throw new bs(a.errors[0]?.message??"Could not render the PDF.",502);const u=a.filename??"document.pdf";t.setHeader("Content-Type","application/pdf"),t.setHeader("Content-Disposition",`inline; filename="${u.replace(/"/g,"")}"`),t.setHeader("Cache-Control","private, no-store"),t.send(Buffer.from(c))}catch(e){t.status($s(e)).json({error:Os(e)})}}),n.post("/save",async(e,t)=>{try{const n=ws(e),o=ks(zs(e),!0),{baseUrl:i,apiKey:s}=Ri(r.env,o.apiUrl),a=await gs({options:o,trigger:null,baseUrl:i,apiKey:s,access:await js(r,n,e)}),c=a.ok?200:422;t.status(c).json(function(e){return{...e,results:e.results.map(({bytes:e,...t})=>t)}}(a))}catch(e){t.status($s(e)).json({error:Os(e)})}})}};const xs=[],Ps=[{name:"docuberry",config:Ss}],As=[{name:"docuberry-generate",config:_s}];export{Ps as endpoints,xs as hooks,As as operations};
package/dist/app.js ADDED
@@ -0,0 +1 @@
1
+ import{useApi as e,defineInterface as t,defineOperationApp as a}from"@directus/extensions-sdk";import{defineComponent as n,ref as i,onMounted as r,openBlock as o,createElementBlock as l,createElementVNode as d,Fragment as s,renderList as c,toDisplayString as p,createCommentVNode as u,computed as f,watch as h,onBeforeUnmount as m,unref as v}from"vue";const y={class:"docuberry-template"},b=["disabled","value"],g=["value"],w=["disabled","value"],D={key:0,class:"hint"};var k=n({__name:"interface",props:{value:{},disabled:{type:Boolean}},emits:["input"],setup(t,{emit:a}){const n=a,f=e(),h=i([]),m=i("");function v(e){const t=e.target.value;n("input",t||null)}function k(e){const t=e.target.value;n("input",t||null)}return r(async()=>{try{const e=await f.get("/docuberry/templates"),t=e?.data?.templates;h.value=Array.isArray(t)?t.filter(e=>e&&e.id):[]}catch(e){const t=e?.response?.data;m.value="string"==typeof t?.error&&t.error?t.error:"Could not load templates."}}),(e,a)=>(o(),l("div",y,[d("select",{class:"control",disabled:t.disabled,value:t.value??"",onChange:v},[a[0]||(a[0]=d("option",{value:""},"Choose a template",-1)),(o(!0),l(s,null,c(h.value,e=>(o(),l("option",{key:e.id,value:e.id},p(e.name||e.id),9,g))),128))],40,b),d("input",{class:"control",disabled:t.disabled,value:t.value??"",placeholder:"Or paste a template id",onInput:k},null,40,w),m.value?(o(),l("p",D,p(m.value)+" You can still paste a template id.",1)):u("v-if",!0),a[1]||(a[1]=d("p",{class:"hint"},"The API key stays on the Directus server. This list is loaded through Directus.",-1))]))}}),P=[],F=[];function _(e,t){if(e&&"undefined"!=typeof document){var a,n=!0===t.prepend?"prepend":"append",i=!0===t.singleTag,r="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(i){var o=P.indexOf(r);-1===o&&(o=P.push(r)-1,F[o]={}),a=F[o]&&F[o][n]?F[o][n]:F[o][n]=l()}else a=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),a.styleSheet?a.styleSheet.cssText+=e:a.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var a=Object.keys(t.attributes),i=0;i<a.length;i++)e.setAttribute(a[i],t.attributes[a[i]]);var o="prepend"===n?"afterbegin":"beforeend";return r.insertAdjacentElement(o,e),e}}_("\n.docuberry-template[data-v-61e401a2] {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n}\n.control[data-v-61e401a2] {\n\twidth: 100%;\n\theight: 44px;\n\tpadding: 0 12px;\n\tborder: var(--theme--border-width) solid var(--theme--form--field--input--border-color);\n\tborder-radius: var(--theme--border-radius);\n\tbackground: var(--theme--form--field--input--background);\n\tcolor: var(--theme--foreground);\n}\n.hint[data-v-61e401a2] {\n\tmargin: 0;\n\tcolor: var(--theme--foreground-subdued);\n\tfont-size: 12px;\n\tline-height: 1.4;\n}\n",{});var x=(e,t)=>{const a=e.__vccOpts||e;for(const[e,n]of t)a[e]=n;return a},R=t({id:"docuberry-template",name:"Docuberry template",icon:"picture_as_pdf",description:"Pick a Docuberry template. The API key stays on the server.",component:x(k,[["__scopeId","data-v-61e401a2"]]),types:["string"],group:"selection",options:null});const I="https://api.docuberry.com";function O(e){try{return new URL(e).host}catch{return"api.docuberry.com"}}const A="https://docuberry.com/privacy";function E(e,t){return[`Preview and Save PDF send this item’s fields to the Docuberry API at ${e} so it can render the PDF.`,"configured"===t?"Related collections are included up to the relation depth you set (default 2), so an invoice can include its customer, its line items, and the product on each line.":`Related collections are included for ${t} level${1===t?"":"s"} (for example an invoice’s customer, its line items, and the product on each line).`,"When the template’s field list can be loaded, only those paths are sent. Otherwise the item and its relations are sent.","Directus only returns fields your role can read. The PDF is stored in Directus Files. The API key stays on the server (DOCUBERRY_API_KEY) and is not saved on the item.",`Privacy policy: ${A}`].join(" ")}const U={class:"docuberry-pdf"},T={class:"notice"},C={key:0,class:"paths"},L={key:1,class:"warn"},$={key:2,class:"warn"},S={class:"actions"},j=["disabled"],B=["disabled"],Y={key:3,class:"warn"},K={key:4,class:"ok"},N=["src"],q={class:"hint"},M=["href"];var z=n({__name:"interface",props:{value:{},disabled:{type:Boolean},collection:{},field:{},primaryKey:{},templateId:{},targetField:{},filename:{},replace:{type:Boolean},depth:{},fields:{},folder:{},storage:{},apiUrl:{}},emits:["input","setFieldValue"],setup(t,{emit:a}){const n=t,r=a,s=e(),c=i(O(I)),y=i(!0),b=i(null),g=i(""),w=i(""),D=i(""),k=i(""),P=i(""),F=f(()=>{const e=Number(n.depth??2);return Number.isFinite(e)?Math.min(4,Math.max(0,Math.floor(e))):2}),_=f(()=>null==n.primaryKey||"+"===n.primaryKey||""===n.primaryKey),x=f(()=>(n.targetField||n.field||"").trim()),R=f(()=>E(c.value,F.value));function z(){return{templateId:n.templateId,collection:n.collection,key:n.primaryKey,targetField:x.value,filename:n.filename,replace:n.replace,depth:F.value,fields:n.fields,folder:n.folder,storage:n.storage,apiUrl:n.apiUrl}}async function H(){D.value="",k.value="",w.value="preview";try{const e=(await s.post("/docuberry/preview",z(),{responseType:"blob"})).data;if(e.type&&e.type.includes("json")){const t=JSON.parse(await e.text());throw new Error(t.error||"Could not preview the PDF.")}P.value&&URL.revokeObjectURL(P.value),P.value=URL.createObjectURL(e)}catch(e){D.value=await V(e)}finally{w.value=""}}async function J(){D.value="",k.value="",w.value="save";try{const e=await s.post("/docuberry/save",z()),t=e?.data?.fileId;if("string"!=typeof t||!t)throw new Error(e?.data?.errors?.[0]?.message||"Could not save the PDF.");await async function(e){const t=x.value;if(!t||!n.collection)return;try{const e=await s.get(`/fields/${n.collection}/${t}`),a=e?.data?.data?.meta?.special??e?.data?.meta?.special??[];if(!Array.isArray(a)||!a.includes("file"))return}catch{return}t===n.field?r("input",e):r("setFieldValue",{field:t,value:e})}(t),k.value="PDF saved on this item."}catch(e){D.value=await V(e)}finally{w.value=""}}async function V(e){const t=e?.response?.data;if(t&&"object"==typeof t&&"error"in t&&"string"==typeof t.error)return t.error;if("undefined"!=typeof Blob&&t instanceof Blob)try{const e=JSON.parse(await t.text());if("string"==typeof e.error&&e.error)return e.error}catch{}return e instanceof Error&&e.message?e.message:"Could not generate the PDF."}return h(()=>n.templateId,async e=>{if(b.value=null,g.value="",e)try{const t=await s.get(`/docuberry/templates/${encodeURIComponent(e)}`),a=t?.data?.paths;Array.isArray(a)?(b.value=a.filter(e=>"string"==typeof e),g.value=b.value.length?`This template reads: ${b.value.join(", ")}.`:"This template reads no item fields. Directus sends the item id."):g.value=`Template fields could not be loaded. Directus will send this item and ${F.value} level${1===F.value?"":"s"} of related collections.`}catch{g.value=`Template fields could not be loaded. Directus will send this item and ${F.value} level${1===F.value?"":"s"} of related collections.`}},{immediate:!0}),m(()=>{P.value&&URL.revokeObjectURL(P.value)}),s.get("/docuberry/status").then(e=>{"string"==typeof e?.data?.apiHost&&(c.value=e.data.apiHost),"boolean"==typeof e?.data?.configured&&(y.value=e.data.configured)}).catch(()=>{y.value=!1}),(e,a)=>(o(),l("div",U,[d("p",T,p(R.value),1),g.value?(o(),l("p",C,p(g.value),1)):u("v-if",!0),y.value?u("v-if",!0):(o(),l("p",L,"Set DOCUBERRY_API_KEY on the Directus service.")),_.value?(o(),l("p",$,"Save the item before previewing or generating a PDF.")):u("v-if",!0),d("div",S,[d("button",{type:"button",disabled:t.disabled||_.value||!t.templateId||""!==w.value,onClick:H},p("preview"===w.value?"Rendering…":"Preview"),9,j),d("button",{type:"button",class:"primary",disabled:t.disabled||_.value||!t.templateId||!x.value||""!==w.value,onClick:J},p("save"===w.value?"Saving…":"Save PDF"),9,B)]),D.value?(o(),l("p",Y,p(D.value),1)):u("v-if",!0),k.value?(o(),l("p",K,p(k.value),1)):u("v-if",!0),P.value?(o(),l("iframe",{key:5,class:"frame",src:P.value,title:"PDF preview"},null,8,N)):u("v-if",!0),d("p",q,[d("a",{href:v(A),target:"_blank",rel:"noopener"},"Privacy policy",8,M)])]))}});_("\n.docuberry-pdf[data-v-4a0b17d7] {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n}\n.notice[data-v-4a0b17d7],\n.paths[data-v-4a0b17d7],\n.hint[data-v-4a0b17d7],\n.warn[data-v-4a0b17d7],\n.ok[data-v-4a0b17d7] {\n\tmargin: 0;\n\tfont-size: 13px;\n\tline-height: 1.45;\n}\n.notice[data-v-4a0b17d7],\n.paths[data-v-4a0b17d7],\n.hint[data-v-4a0b17d7] {\n\tcolor: var(--theme--foreground-subdued);\n}\n.warn[data-v-4a0b17d7] {\n\tcolor: var(--theme--danger);\n}\n.ok[data-v-4a0b17d7] {\n\tcolor: var(--theme--success);\n}\n.actions[data-v-4a0b17d7] {\n\tdisplay: flex;\n\tgap: 8px;\n}\nbutton[data-v-4a0b17d7] {\n\theight: 36px;\n\tpadding: 0 14px;\n\tborder-radius: var(--theme--border-radius);\n\tborder: var(--theme--border-width) solid var(--theme--form--field--input--border-color);\n\tbackground: var(--theme--form--field--input--background);\n\tcolor: var(--theme--foreground);\n\tcursor: pointer;\n}\nbutton.primary[data-v-4a0b17d7] {\n\tbackground: var(--theme--primary);\n\tborder-color: var(--theme--primary);\n\tcolor: var(--theme--primary-foreground, #fff);\n}\nbutton[data-v-4a0b17d7]:disabled {\n\tcursor: not-allowed;\n\topacity: 0.55;\n}\n.frame[data-v-4a0b17d7] {\n\twidth: 100%;\n\theight: 480px;\n\tborder: var(--theme--border-width) solid var(--theme--form--field--input--border-color);\n\tborder-radius: var(--theme--border-radius);\n\tbackground: white;\n}\n.hint a[data-v-4a0b17d7] {\n\tcolor: var(--theme--primary);\n}\n",{});const H=[R,t({id:"docuberry-pdf",name:"Docuberry PDF",icon:"picture_as_pdf",description:"Preview a Docuberry PDF and save it on this item.",component:x(z,[["__scopeId","data-v-4a0b17d7"]]),types:["alias","uuid"],localTypes:["presentation","file","files"],group:"other",options:[{field:"templateId",name:"Template",type:"string",meta:{interface:"docuberry-template",width:"full",required:!0,note:"The API key is DOCUBERRY_API_KEY on the server and is not stored on the item."}},{field:"targetField",name:"File field",type:"string",meta:{interface:"input",width:"half",note:"Leave empty when this interface sits on the file field. Otherwise name the file or files field to update.",options:{placeholder:"pdf"}}},{field:"filename",name:"Filename",type:"string",schema:{default_value:"{template} {id}"},meta:{interface:"input",width:"half",note:"Tokens: {template}, {id}, {collection}, or {field.path}."}},{field:"depth",name:"Relation depth",type:"integer",schema:{default_value:2},meta:{interface:"input",width:"half",note:"2 includes an invoice, its customer, its lines, and the product on each line.",options:{min:0,max:4}}},{field:"fields",name:"Fields",type:"string",meta:{interface:"input",width:"half",note:"Optional. Empty follows the template’s paths."}},{field:"replace",name:"Replace existing file",type:"boolean",schema:{default_value:!0},meta:{interface:"boolean",width:"half",note:"Off keeps a single file that is already there, and appends on a files field."}},{field:"folder",name:"Folder",type:"string",meta:{interface:"input",width:"half",note:"Optional Directus folder id."}},{field:"storage",name:"Storage",type:"string",meta:{interface:"input",width:"half",note:"Empty uses the default storage."}},{field:"apiUrl",name:"API base URL",type:"string",meta:{interface:"input",width:"full",note:"Optional. Defaults to DOCUBERRY_API_URL, then https://api.docuberry.com."}}]})],J=[],V=[],G=[],W=[],Q=[],X=[],Z=[a({id:"docuberry-generate",name:"Generate PDF (Docuberry)",icon:"picture_as_pdf",description:"Render a Docuberry PDF and save it on the item.",overview:({templateId:e,targetField:t,depth:a})=>[{label:"Template",text:e||"—"},{label:"File field",text:t||"—"},{label:"Depth",text:String(a??2)}],options:[{field:"notice",type:"alias",meta:{interface:"presentation-notice",width:"full",options:{color:"info",icon:"info",text:E(O(I),"configured")}}},{field:"templateId",name:"Template",type:"string",meta:{interface:"docuberry-template",width:"full",required:!0,note:"Loaded from Docuberry through Directus. The API key is DOCUBERRY_API_KEY on the server, not a value stored on the item."}},{field:"collection",name:"Collection",type:"string",meta:{interface:"input",width:"half",note:"Leave empty to use the collection from the trigger.",options:{placeholder:"{{$trigger.collection}}"}}},{field:"keys",name:"Item keys",type:"string",meta:{interface:"input",width:"half",note:"Leave empty to use the trigger’s key or keys. You can also pass {{$trigger.keys}} or {{$last}}.",options:{placeholder:"{{$trigger.keys}}"}}},{field:"payload",name:"Payload",type:"json",meta:{interface:"input-code",width:"full",note:"Leave empty to load each item, including related collections. An object renders one PDF. An array renders one PDF per element.",options:{language:"json",placeholder:"{\n \n}"}}},{field:"fields",name:"Fields",type:"string",meta:{interface:"input",width:"full",note:"Optional comma-separated Directus fields. Empty uses the template’s paths, or the depth below when those paths cannot be loaded.",options:{placeholder:"customer.name, lines.product.name"}}},{field:"depth",name:"Relation depth",type:"integer",schema:{default_value:2},meta:{interface:"input",width:"half",note:"Relation hops to include. 2 covers an invoice, its lines, and the product on each line. Maximum 4.",options:{min:0,max:4}}},{field:"targetField",name:"File field",type:"string",meta:{interface:"input",width:"half",required:!0,note:"File or files field on the item that receives the PDF.",options:{placeholder:"pdf"}}},{field:"filename",name:"Filename",type:"string",schema:{default_value:"{template} {id}"},meta:{interface:"input",width:"half",note:"Tokens: {template}, {id}, {collection}, or {field.path}. Example: {template} {number}."}},{field:"replace",name:"Replace existing files",type:"boolean",schema:{default_value:!0},meta:{interface:"boolean",width:"half",note:"On a single file field, off skips an item that already has a file. On a files field, off appends."}},{field:"folder",name:"Folder",type:"string",meta:{interface:"input",width:"half",note:"Optional Directus folder id. Empty stores the file in the root of the chosen storage."}},{field:"storage",name:"Storage",type:"string",meta:{interface:"input",width:"half",note:"Storage location name. Empty uses the default storage."}},{field:"apiUrl",name:"API base URL",type:"string",meta:{interface:"input",width:"half",note:"Optional. Defaults to DOCUBERRY_API_URL, then https://api.docuberry.com.",options:{placeholder:"https://api.docuberry.com"}}},{field:"continueOnError",name:"Continue when an item fails",type:"boolean",schema:{default_value:!0},meta:{interface:"boolean",width:"half",note:"On: later steps still run and the result lists failures. Off: the first failure stops the flow."}}]})];export{J as displays,H as interfaces,V as layouts,G as modules,Z as operations,W as panels,X as richtexts,Q as themes};
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
- "name": "directus-extension-docuberry",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "directus-extension-docuberry",
3
+ "version": "1.0.1",
4
+ "description": "Generate Docuberry PDFs from Directus items. Flow operation, item-page preview, and a server-side API key.",
5
+ "icon": "picture_as_pdf",
6
+ "license": "MIT",
7
+ "author": "Docuberry",
8
+ "keywords": [
9
+ "directus",
10
+ "directus-extension",
11
+ "directus-extension-bundle",
12
+ "directus-custom-bundle",
13
+ "pdf",
14
+ "docuberry"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/onix2582/docuberry-directus-extension.git"
19
+ },
20
+ "homepage": "https://docuberry.com/docs",
21
+ "bugs": {
22
+ "url": "https://github.com/onix2582/docuberry-directus-extension/issues"
23
+ },
24
+ "type": "module",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "directus:extension": {
29
+ "type": "bundle",
30
+ "partial": true,
31
+ "path": {
32
+ "app": "dist/app.js",
33
+ "api": "dist/api.js"
34
+ },
35
+ "entries": [
36
+ {
37
+ "type": "interface",
38
+ "name": "docuberry-template",
39
+ "source": "src/template-select/index.ts"
40
+ },
41
+ {
42
+ "type": "interface",
43
+ "name": "docuberry-pdf",
44
+ "source": "src/interface/index.ts"
45
+ },
46
+ {
47
+ "type": "operation",
48
+ "name": "docuberry-generate",
49
+ "source": {
50
+ "app": "src/operation/app.ts",
51
+ "api": "src/operation/api.ts"
52
+ }
53
+ },
54
+ {
55
+ "type": "endpoint",
56
+ "name": "docuberry",
57
+ "source": "src/endpoint/index.ts"
58
+ }
59
+ ],
60
+ "host": "^11.1.0 || ^12.0.0"
61
+ },
62
+ "scripts": {
63
+ "build": "directus-extension build",
64
+ "dev": "directus-extension build -w --no-minify",
65
+ "add": "directus-extension add",
66
+ "validate": "directus-extension validate",
67
+ "typecheck": "tsc -p tsconfig.json --noEmit",
68
+ "lint": "eslint .",
69
+ "test": "vitest run"
70
+ },
71
+ "devDependencies": {
72
+ "@directus/extensions-sdk": "^18.1.2",
73
+ "@types/node": "^22.15.0",
74
+ "eslint": "^9.28.0",
75
+ "typescript": "^5.8.3",
76
+ "typescript-eslint": "^8.33.0",
77
+ "vitest": "^4.1.10",
78
+ "vue": "^3.5.13"
79
+ }
80
+ }