aiex-cli 0.0.2-beta.7 → 0.0.2-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { S as version, T as formatDoctorDiagnosticsJson, _ as createConfig, a as parseJsonSchema, b as name, c as getDefaultAIConfig, d as DEFAULT_MARKITDOWN_CONFIG, f as DEFAULT_MINERU_CONFIG, g as AIConfigSchema, h as PLACEHOLDER_TEXT, i as JsonSchemaDefinitionSchema, l as readAIConfig, m as PLACEHOLDER_SCHEMA, n as createMigrationConfig, o as toSnakeCase, p as DEFAULT_PROMPT_CONFIG, s as generateDrizzleSchema, t as collectDoctorDiagnostics, u as writeAIConfig, v as seedConfig, w as doctorDiagnosticsTableRows, x as package_default, y as description } from "./doctor-collector-BsQAiBNz.mjs";
1
+ import { S as version, T as formatDoctorDiagnosticsJson, _ as createConfig, a as parseJsonSchema, b as name, c as getDefaultAIConfig, d as DEFAULT_MARKITDOWN_CONFIG, f as DEFAULT_MINERU_CONFIG, g as AIConfigSchema, h as PLACEHOLDER_TEXT, i as JsonSchemaDefinitionSchema, l as readAIConfig, m as PLACEHOLDER_SCHEMA, n as createMigrationConfig, o as toSnakeCase, p as DEFAULT_PROMPT_CONFIG, s as generateDrizzleSchema, t as collectDoctorDiagnostics, u as writeAIConfig, v as seedConfig, w as doctorDiagnosticsTableRows, x as package_default, y as description } from "./doctor-collector-Cb9X2mxU.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import fs from "node:fs/promises";
4
4
  import os from "node:os";
@@ -12990,6 +12990,7 @@ function initLangfuse(config) {
12990
12990
  }
12991
12991
  const SYSTEM_PROMPT_REGEX = /## System Prompt\n([\s\S]*?)(?=## User Prompt|$)/;
12992
12992
  const USER_PROMPT_REGEX = /## User Prompt Template\n([\s\S]*)$/;
12993
+ const OPENAI_COMPATIBLE_PROVIDER_NAME = "openai-compatible";
12993
12994
  function detectMimeType(filePath) {
12994
12995
  return mime.getType(filePath) ?? "application/octet-stream";
12995
12996
  }
@@ -13148,8 +13149,9 @@ async function extractStructuredData(input) {
13148
13149
  if (useTelemetry) initLangfuse(config);
13149
13150
  const provider = createOpenAICompatible({
13150
13151
  baseURL: config.provider.baseURL,
13151
- name: "qwen",
13152
- apiKey: config.provider.apiKey
13152
+ name: OPENAI_COMPATIBLE_PROVIDER_NAME,
13153
+ apiKey: config.provider.apiKey,
13154
+ supportsStructuredOutputs: useStructuredOutput
13153
13155
  });
13154
13156
  let system;
13155
13157
  let user;
@@ -14961,6 +14963,7 @@ function aiRoutes(config) {
14961
14963
  //#endregion
14962
14964
  //#region src/server/routes/data.ts
14963
14965
  const FILE_REGEX = /\.json$/;
14966
+ const EXTRACTION_TIMESTAMP_RE = /-\d{4}-\d{2}-\d{2}T/;
14964
14967
  const TIMESTAMP_CLEANUP = /(\d{2})-(\d{2})-(\d{2})/;
14965
14968
  const TIMESTAMP_TZ = /(\d{3})Z/;
14966
14969
  const tableParamSchema = z.object({ name: z.string().regex(/^[a-z][a-z0-9_]*$/) });
@@ -14977,6 +14980,12 @@ function invalidParamResponse$1(message) {
14977
14980
  if (!result.success) return c.json({ error: message }, 400);
14978
14981
  };
14979
14982
  }
14983
+ function schemaNameFromExtractionFile(name$1) {
14984
+ const stem = name$1.replace(FILE_REGEX, "");
14985
+ const match = stem.match(EXTRACTION_TIMESTAMP_RE);
14986
+ if (!match || typeof match.index !== "number" || match.index <= 0) return null;
14987
+ return stem.slice(0, match.index);
14988
+ }
14980
14989
  function createReadonlyQueryDb(databasePath) {
14981
14990
  return new Kysely({ dialect: new SqliteDialect({ database: new Database(databasePath, { readonly: true }) }) });
14982
14991
  }
@@ -15125,6 +15134,51 @@ function dataRoutes(config) {
15125
15134
  return c.json({ error: "Extraction result not found" }, 404);
15126
15135
  }
15127
15136
  });
15137
+ app.post("/data/:name/notion/retry", zValidator("param", extractionFileParamSchema, invalidParamResponse$1("Invalid extraction file name")), async (c) => {
15138
+ const { name: name$1 } = c.req.valid("param");
15139
+ const filePath = path.join(extractedDir, name$1);
15140
+ const schemaName = schemaNameFromExtractionFile(name$1);
15141
+ if (!schemaName) return c.json({
15142
+ success: false,
15143
+ error: "Cannot infer schema name from extraction file name"
15144
+ }, 400);
15145
+ const aiConfig = await readAIConfig(aiexDir);
15146
+ if (!aiConfig?.notion?.enabled) return c.json({
15147
+ success: false,
15148
+ error: "Notion export is not enabled. Configure Notion settings first."
15149
+ }, 400);
15150
+ if (!aiConfig.notion.schemas?.[schemaName]?.databaseId?.trim()) return c.json({
15151
+ success: false,
15152
+ error: `Notion database is not configured for schema "${schemaName}".`
15153
+ }, 400);
15154
+ try {
15155
+ const data = await readFile(filePath);
15156
+ if (!data || typeof data !== "object" || Array.isArray(data)) return c.json({
15157
+ success: false,
15158
+ error: "Extraction result is not a JSON object and cannot be written to Notion."
15159
+ }, 400);
15160
+ const page = await writeNotionPage(aiConfig.notion, schemaName, data);
15161
+ const notionPages = [{
15162
+ databaseId: page.databaseId,
15163
+ pageId: page.pageId
15164
+ }];
15165
+ const record = (await listExtractionAuditRecords(aiexDir)).find((record$1) => record$1.outputName === name$1);
15166
+ if (record) await updateExtractionAuditRecord(aiexDir, record.id, {
15167
+ status: "succeeded",
15168
+ notionPages,
15169
+ error: void 0
15170
+ });
15171
+ return c.json({
15172
+ success: true,
15173
+ notionPages
15174
+ });
15175
+ } catch (error) {
15176
+ return c.json({
15177
+ success: false,
15178
+ error: error instanceof Error ? error.message : String(error)
15179
+ }, 500);
15180
+ }
15181
+ });
15128
15182
  return app;
15129
15183
  }
15130
15184
 
@@ -65,7 +65,7 @@ function doctorDiagnosticsTableRows(d) {
65
65
  //#endregion
66
66
  //#region package.json
67
67
  var name = "aiex-cli";
68
- var version = "0.0.2-beta.7";
68
+ var version = "0.0.2-beta.9";
69
69
  var description = "JSON Schema → SQLite with AI-powered data extraction";
70
70
  var package_default = {
71
71
  name,
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { C as buildDoctorDiagnostics, T as formatDoctorDiagnosticsJson, a as parseJsonSchema, i as JsonSchemaDefinitionSchema, n as createMigrationConfig, r as generateDrizzleConfig, s as generateDrizzleSchema, t as collectDoctorDiagnostics, w as doctorDiagnosticsTableRows } from "./doctor-collector-BsQAiBNz.mjs";
1
+ import { C as buildDoctorDiagnostics, T as formatDoctorDiagnosticsJson, a as parseJsonSchema, i as JsonSchemaDefinitionSchema, n as createMigrationConfig, r as generateDrizzleConfig, s as generateDrizzleSchema, t as collectDoctorDiagnostics, w as doctorDiagnosticsTableRows } from "./doctor-collector-Cb9X2mxU.mjs";
2
2
 
3
3
  export { JsonSchemaDefinitionSchema, buildDoctorDiagnostics, collectDoctorDiagnostics, createMigrationConfig, doctorDiagnosticsTableRows, formatDoctorDiagnosticsJson, generateDrizzleConfig, generateDrizzleSchema, parseJsonSchema };
@@ -1,4 +1,4 @@
1
- import{B as e,H as t,Jt as n,K as r,L as ee,Lt as i,M as a,Pn as o,Pt as s,Q as c,R as te,S as l,Sn as u,Tn as d,U as f,W as p,Yt as m,_ as h,c as g,d as ne,et as re,g as _,h as v,ht as y,i as b,in as x,j as S,jn as C,lt as w,m as T,nt as ie,t as E,un as ae,v as D,w as oe,x as O}from"./button-Cdgr9Igy.js";import{i as se,n as k,r as ce,s as A,t as le}from"./dialog-CUkPLPNP.js";import{s as ue,t as de}from"./runtime-dom.esm-bundler-ei_N7Xjw.js";import{a as fe,f as pe,g as j,n as me,p as he,s as ge}from"./api-client-BF3HG2Vn.js";import{i as M,n as N,o as P,r as F,t as _e}from"./select-BGex2SPs.js";var I={name:`MinusIcon`,extends:b};function L(e){return B(e)||z(e)||R(e)||ve()}function ve(){throw TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{B as e,H as t,Jt as n,K as r,L as ee,Lt as i,M as a,Pn as o,Pt as s,Q as c,R as te,S as l,Sn as u,Tn as d,U as f,W as p,Yt as m,_ as h,c as g,d as ne,et as re,g as _,h as v,ht as y,i as b,in as x,j as S,jn as C,lt as w,m as T,nt as ie,t as E,un as ae,v as D,w as oe,x as O}from"./button-Cdgr9Igy.js";import{i as se,n as k,r as ce,s as A,t as le}from"./dialog-CUkPLPNP.js";import{s as ue,t as de}from"./runtime-dom.esm-bundler-ei_N7Xjw.js";import{_ as j,a as fe,f as pe,m as me,n as he,s as ge}from"./api-client-CG1VV5gz.js";import{i as M,n as N,o as P,r as F,t as _e}from"./select-BGex2SPs.js";var I={name:`MinusIcon`,extends:b};function L(e){return B(e)||z(e)||R(e)||ve()}function ve(){throw TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function R(e,t){if(e){if(typeof e==`string`)return V(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}function z(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function B(e){if(Array.isArray(e))return V(e)}function V(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function H(t,n,r,ee,i,o){return e(),D(`svg`,a({width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},t.pti()),L(n[0]||=[v(`path`,{d:`M13.2222 7.77778H0.777778C0.571498 7.77778 0.373667 7.69584 0.227806 7.54998C0.0819442 7.40412 0 7.20629 0 7.00001C0 6.79373 0.0819442 6.5959 0.227806 6.45003C0.373667 6.30417 0.571498 6.22223 0.777778 6.22223H13.2222C13.4285 6.22223 13.6263 6.30417 13.7722 6.45003C13.9181 6.5959 14 6.79373 14 7.00001C14 7.20629 13.9181 7.40412 13.7722 7.54998C13.6263 7.69584 13.4285 7.77778 13.2222 7.77778Z`,fill:`currentColor`},null,-1)]),16)}I.render=H;var U=g.extend({name:`checkbox`,style:`
3
3
  .p-checkbox {
4
4
  position: relative;
@@ -336,9 +336,9 @@ Extraction requirements:
336
336
  -o
337
337
  {outputDir}`),ae=w(600),oe=w(!0),se=w(!0),k=w(`markitdown`),ce=w(`{input}
338
338
  -o
339
- {outputDir}/{basename}.md`),A=w(`{outputDir}/{basename}.md`),de=w(600),M=w(!0),N=w(!0),P=w(!1),I=w(``),L=w(``),ve=w(``),R=w(!1),z=w(``),B=w({}),V=w(``),H=w(``),U=w(``),W=w(``),G=w(!1),K=w([]),q=w([]),ye=w(!1),be=w(!1),J=w(``),Y=w({vision:!1,structuredOutput:!1}),xe=w(`manual`);function Se(){xe.value=`manual`,Y.value={vision:!1,structuredOutput:!1},J.value&&pe(J.value).then(e=>{e&&(Y.value={...e},xe.value=`registry`)})}function Ce(){J.value&&(m.value.push({name:J.value,capabilities:{...Y.value}}),Te())}function we(){Te()}function Te(){J.value=``,Y.value={vision:!1,structuredOutput:!1},xe.value=`manual`,be.value=!1}function Ee(e){m.value.splice(e,1)}let De=T(()=>g.value.includes(`{schema}`)?``:`System prompt must contain the {schema} placeholder`),Oe=T(()=>b.value.includes(`{text}`)?``:`User prompt must contain the {text} placeholder`),ke=T(()=>r.schemas.map(e=>e.replace(`.json`,``))),Z=T(()=>{let e=W.value.trim();if(!e)return``;try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return`Field map must be a JSON object`;for(let[e,n]of Object.entries(t))if(typeof n!=`string`)return`Field map value for "${e}" must be a string`;return``}catch{return`Field map must be valid JSON`}}),Ae=T(()=>{try{return Object.keys(Q()??{}).length}catch{return 0}}),je=T(()=>K.value.length===0?``:q.value.length===0?`Connected · ${K.value.length} properties loaded`:`Connected · ${Ae.value}/${q.value.length} fields mapped`),Me=T(()=>!De.value&&!Oe.value&&!Z.value&&!o.value&&m.value.length>0&&(!R.value||!!z.value.trim())&&(x.value!==`mineru`||!!S.value.trim())&&(x.value!==`markitdown`||!!k.value.trim()));function Q(){if(!W.value.trim())return;let e=JSON.parse(W.value),t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`string`?t.trim():``]).filter(([e,t])=>!!e&&!!t));return Object.keys(t).length>0?t:void 0}function Ne(e){if(!e?.properties||typeof e.properties!=`object`)return[];let t=[];function n(e,r=``){for(let[ee,i]of Object.entries(e)){let e=r?`${r}.${ee}`:ee;if(i?.type===`object`&&i?.properties&&typeof i.properties==`object`){n(i.properties,e);continue}i?.type===`array`&&i?.items?.type===`object`||t.push(e)}}return n(e.properties),t}function Pe(e){let t={};for(let n of q.value)t[n]=e?.[n]??``;for(let[n,r]of Object.entries(e??{}))n in t||(t[n]=r);return Object.keys(t).length>0?JSON.stringify(t,null,2):``}function Fe(e=V.value){if(!e||Z.value)return;let t=H.value.trim(),n=U.value.trim(),r=Q();if(!t){let t={...B.value};delete t[e],B.value=t;return}B.value={...B.value,[e]:{databaseId:t,titleProperty:n||void 0,fieldMap:r}}}function Ie(){let e=V.value?B.value[V.value]:void 0;H.value=e?.databaseId??``,U.value=e?.titleProperty??``,W.value=Pe(e?.fieldMap),K.value=[]}re(ke,e=>{!V.value&&e.length>0&&(V.value=e[0])},{immediate:!0}),re(V,(e,t)=>{t&&Fe(t),Le()});async function Le(){let e=V.value;if(q.value=[],!e){Ie();return}try{q.value=Ne(await fe(`${e}.json`))}catch{q.value=[]}Ie()}let Re=[{label:`Built-in text extraction`,value:`unpdf`},{label:`MinerU command`,value:`mineru`},{label:`MarkItDown command`,value:`markitdown`}];async function ze(){o.value=!0;try{let e=await me();d.value=e.provider.baseURL,f.value=e.provider.apiKey,p.value=e.provider.timeout??300,m.value=e.provider.models??[],g.value=e.prompt.systemTemplate,b.value=e.prompt.userTemplate,x.value=e.pdf?.converter??`unpdf`,S.value=e.pdf?.mineru?.command??`mineru`,C.value=(e.pdf?.mineru?.args??[`-p`,`{input}`,`-o`,`{outputDir}`]).join(`
339
+ {outputDir}/{basename}.md`),A=w(`{outputDir}/{basename}.md`),de=w(600),M=w(!0),N=w(!0),P=w(!1),I=w(``),L=w(``),ve=w(``),R=w(!1),z=w(``),B=w({}),V=w(``),H=w(``),U=w(``),W=w(``),G=w(!1),K=w([]),q=w([]),ye=w(!1),be=w(!1),J=w(``),Y=w({vision:!1,structuredOutput:!1}),xe=w(`manual`);function Se(){xe.value=`manual`,Y.value={vision:!1,structuredOutput:!1},J.value&&pe(J.value).then(e=>{e&&(Y.value={...e},xe.value=`registry`)})}function Ce(){J.value&&(m.value.push({name:J.value,capabilities:{...Y.value}}),Te())}function we(){Te()}function Te(){J.value=``,Y.value={vision:!1,structuredOutput:!1},xe.value=`manual`,be.value=!1}function Ee(e){m.value.splice(e,1)}let De=T(()=>g.value.includes(`{schema}`)?``:`System prompt must contain the {schema} placeholder`),Oe=T(()=>b.value.includes(`{text}`)?``:`User prompt must contain the {text} placeholder`),ke=T(()=>r.schemas.map(e=>e.replace(`.json`,``))),Z=T(()=>{let e=W.value.trim();if(!e)return``;try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return`Field map must be a JSON object`;for(let[e,n]of Object.entries(t))if(typeof n!=`string`)return`Field map value for "${e}" must be a string`;return``}catch{return`Field map must be valid JSON`}}),Ae=T(()=>{try{return Object.keys(Q()??{}).length}catch{return 0}}),je=T(()=>K.value.length===0?``:q.value.length===0?`Connected · ${K.value.length} properties loaded`:`Connected · ${Ae.value}/${q.value.length} fields mapped`),Me=T(()=>!De.value&&!Oe.value&&!Z.value&&!o.value&&m.value.length>0&&(!R.value||!!z.value.trim())&&(x.value!==`mineru`||!!S.value.trim())&&(x.value!==`markitdown`||!!k.value.trim()));function Q(){if(!W.value.trim())return;let e=JSON.parse(W.value),t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`string`?t.trim():``]).filter(([e,t])=>!!e&&!!t));return Object.keys(t).length>0?t:void 0}function Ne(e){if(!e?.properties||typeof e.properties!=`object`)return[];let t=[];function n(e,r=``){for(let[ee,i]of Object.entries(e)){let e=r?`${r}.${ee}`:ee;if(i?.type===`object`&&i?.properties&&typeof i.properties==`object`){n(i.properties,e);continue}i?.type===`array`&&i?.items?.type===`object`||t.push(e)}}return n(e.properties),t}function Pe(e){let t={};for(let n of q.value)t[n]=e?.[n]??``;for(let[n,r]of Object.entries(e??{}))n in t||(t[n]=r);return Object.keys(t).length>0?JSON.stringify(t,null,2):``}function Fe(e=V.value){if(!e||Z.value)return;let t=H.value.trim(),n=U.value.trim(),r=Q();if(!t){let t={...B.value};delete t[e],B.value=t;return}B.value={...B.value,[e]:{databaseId:t,titleProperty:n||void 0,fieldMap:r}}}function Ie(){let e=V.value?B.value[V.value]:void 0;H.value=e?.databaseId??``,U.value=e?.titleProperty??``,W.value=Pe(e?.fieldMap),K.value=[]}re(ke,e=>{!V.value&&e.length>0&&(V.value=e[0])},{immediate:!0}),re(V,(e,t)=>{t&&Fe(t),Le()});async function Le(){let e=V.value;if(q.value=[],!e){Ie();return}try{q.value=Ne(await fe(`${e}.json`))}catch{q.value=[]}Ie()}let Re=[{label:`Built-in text extraction`,value:`unpdf`},{label:`MinerU command`,value:`mineru`},{label:`MarkItDown command`,value:`markitdown`}];async function ze(){o.value=!0;try{let e=await he();d.value=e.provider.baseURL,f.value=e.provider.apiKey,p.value=e.provider.timeout??300,m.value=e.provider.models??[],g.value=e.prompt.systemTemplate,b.value=e.prompt.userTemplate,x.value=e.pdf?.converter??`unpdf`,S.value=e.pdf?.mineru?.command??`mineru`,C.value=(e.pdf?.mineru?.args??[`-p`,`{input}`,`-o`,`{outputDir}`]).join(`
340
340
  `),ae.value=e.pdf?.mineru?.timeout??600,oe.value=e.pdf?.mineru?.fallbackToUnpdf??!0,se.value=e.pdf?.mineru?.keepOutput??!0,k.value=e.pdf?.markitdown?.command??`markitdown`,ce.value=(e.pdf?.markitdown?.args??[`{input}`,`-o`,`{outputDir}/{basename}.md`]).join(`
341
- `),A.value=e.pdf?.markitdown?.outputFile??`{outputDir}/{basename}.md`,de.value=e.pdf?.markitdown?.timeout??600,M.value=e.pdf?.markitdown?.fallbackToUnpdf??!0,N.value=e.pdf?.markitdown?.keepOutput??!0,P.value=!!e.langfuse,I.value=e.langfuse?.publicKey??``,L.value=e.langfuse?.secretKey??``,ve.value=e.langfuse?.host??``,R.value=!!e.notion?.enabled,z.value=e.notion?.token??``,B.value=e.notion?.schemas??{},await Le()}catch{f.value=``,m.value=[],g.value=gn,b.value=_n}finally{o.value=!1}}async function Be(){if(Me.value){u.value=!0;try{Fe(),await he({provider:{baseURL:d.value,apiKey:f.value,timeout:p.value,models:m.value},prompt:{systemTemplate:g.value,userTemplate:b.value},extraction:{outputDir:`.aiex/extracted`},pdf:{converter:x.value,mineru:{command:S.value,args:C.value.split(`
341
+ `),A.value=e.pdf?.markitdown?.outputFile??`{outputDir}/{basename}.md`,de.value=e.pdf?.markitdown?.timeout??600,M.value=e.pdf?.markitdown?.fallbackToUnpdf??!0,N.value=e.pdf?.markitdown?.keepOutput??!0,P.value=!!e.langfuse,I.value=e.langfuse?.publicKey??``,L.value=e.langfuse?.secretKey??``,ve.value=e.langfuse?.host??``,R.value=!!e.notion?.enabled,z.value=e.notion?.token??``,B.value=e.notion?.schemas??{},await Le()}catch{f.value=``,m.value=[],g.value=gn,b.value=_n}finally{o.value=!1}}async function Be(){if(Me.value){u.value=!0;try{Fe(),await me({provider:{baseURL:d.value,apiKey:f.value,timeout:p.value,models:m.value},prompt:{systemTemplate:g.value,userTemplate:b.value},extraction:{outputDir:`.aiex/extracted`},pdf:{converter:x.value,mineru:{command:S.value,args:C.value.split(`
342
342
  `).map(e=>e.trim()).filter(Boolean),timeout:ae.value,fallbackToUnpdf:oe.value,keepOutput:se.value||void 0},markitdown:{command:k.value,args:ce.value.split(`
343
343
  `).map(e=>e.trim()).filter(Boolean),outputFile:A.value.trim()||void 0,timeout:de.value,fallbackToUnpdf:M.value,keepOutput:N.value||void 0}},langfuse:P.value?{publicKey:I.value,secretKey:L.value,host:ve.value||void 0}:void 0,notion:{enabled:R.value,token:z.value,schemas:B.value}}),a.value=!1}catch(e){j.error(e.message||`Failed to save`)}finally{u.value=!1}}}async function Ve(){if(!V.value){j.error(`Select a schema first`);return}if(!z.value.trim()){j.error(`Enter a Notion integration token`);return}if(!H.value.trim()){j.error(`Enter a Notion database or data source URL/ID`);return}if(Z.value){j.error(Z.value);return}G.value=!0;try{let e=await ge({token:z.value,databaseId:H.value,schemaName:V.value});(e.dataSourceId||e.databaseId)&&(H.value=e.dataSourceId??e.databaseId??``),!U.value&&e.titleProperty&&(U.value=e.titleProperty);let t=Q()??{},n={...e.suggestedFieldMap??{},...t};W.value=Object.keys(n).length>0?JSON.stringify(n,null,2):``,K.value=e.properties??[],Fe(),j.success(`Connected to Notion (${K.value.length} properties)`)}catch(e){j.error(e instanceof Error?e.message:`Notion connection failed`)}finally{G.value=!1}}return ee(()=>{ze()}),te(()=>{}),(n,r)=>(e(),_(y(le),{visible:a.value,"onUpdate:visible":r[33]||=e=>a.value=e,modal:``,header:`AI Settings`,style:{width:`680px`},draggable:!1},{footer:ie(()=>[v(`div`,hn,[l(y(E),{label:`Cancel`,severity:`secondary`,text:``,onClick:r[32]||=e=>a.value=!1}),l(y(E),{label:`Save`,icon:`pi pi-check`,loading:u.value,disabled:!Me.value,onClick:Be},null,8,[`loading`,`disabled`])])]),default:ie(()=>[o.value?(e(),D(`div`,pt,[...r[34]||=[v(`i`,{class:`pi pi-spin pi-spinner text-xl`},null,-1)]])):(e(),D(`div`,mt,[v(`section`,null,[r[38]||=v(`h3`,{class:`text-sm font-semibold mb-3 text-foreground`},` Provider `,-1),v(`div`,ht,[v(`div`,gt,[r[35]||=v(`label`,{class:`text-xs text-muted-foreground`},`Base URL`,-1),l(y(F),{modelValue:d.value,"onUpdate:modelValue":r[0]||=e=>d.value=e,size:`small`,placeholder:`https://dashscope.aliyuncs.com/compatible-mode/v1`},null,8,[`modelValue`])]),v(`div`,_t,[r[36]||=v(`label`,{class:`text-xs text-muted-foreground`},`API Key`,-1),l(y(Je),{modelValue:f.value,"onUpdate:modelValue":r[1]||=e=>f.value=e,feedback:!1,"toggle-mask":``,size:`small`,placeholder:`sk-xxx`,"input-class":`w-full`},null,8,[`modelValue`])]),v(`div`,vt,[r[37]||=v(`label`,{class:`text-xs text-muted-foreground`},`Timeout (seconds)`,-1),l(y(F),{value:String(p.value),type:`number`,size:`small`,placeholder:`300`,min:1,onInput:r[2]||=e=>p.value=Number(e.target.value)||300},null,8,[`value`])])])]),v(`section`,null,[r[40]||=v(`h3`,{class:`text-sm font-semibold mb-3 text-foreground`},` Models `,-1),v(`div`,yt,[(e(!0),D(ne,null,t(m.value,(t,n)=>(e(),D(`div`,{key:n,class:`flex items-center gap-2 px-3 py-2 rounded border border-border bg-card`},[v(`code`,bt,i(t.name),1),v(`span`,{class:s([`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded`,t.capabilities.structuredOutput?`bg-green-500/10 text-green-600`:`bg-yellow-500/10 text-yellow-600`])},[v(`i`,{class:s([t.capabilities.structuredOutput?`pi pi-check-circle`:`pi pi-exclamation-triangle`,`text-[10px]`])},null,2),O(` `+i(t.capabilities.structuredOutput?`Structured Output`:`Text-only Output`),1)],2),v(`span`,{class:s([`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded`,t.capabilities.vision?`bg-green-500/10 text-green-600`:`bg-red-500/10 text-red-600`])},[v(`i`,{class:s([t.capabilities.vision?`pi pi-check-circle`:`pi pi-times-circle`,`text-[10px]`])},null,2),O(` `+i(t.capabilities.vision?`Vision Supported`:`Vision Unsupported`),1)],2),l(y(E),{icon:`pi pi-times`,severity:`danger`,text:``,size:`small`,onClick:e=>Ee(n)},null,8,[`onClick`])]))),128)),be.value?(e(),D(`div`,xt,[v(`div`,St,[l(y(F),{modelValue:J.value,"onUpdate:modelValue":r[3]||=e=>J.value=e,size:`small`,placeholder:`Model name (e.g. gpt-4o)`,class:`flex-1 font-mono`,onInput:Se,onKeyup:ue(Ce,[`enter`])},null,8,[`modelValue`]),l(y(E),{icon:`pi pi-check`,severity:`success`,text:``,size:`small`,disabled:!J.value,onClick:Ce},null,8,[`disabled`]),l(y(E),{icon:`pi pi-times`,severity:`secondary`,text:``,size:`small`,onClick:we})]),v(`div`,Ct,[v(`label`,wt,[l(y(X),{modelValue:Y.value.structuredOutput,"onUpdate:modelValue":r[4]||=e=>Y.value.structuredOutput=e,binary:!0,"input-id":`add-so`},null,8,[`modelValue`]),v(`span`,{class:s(Y.value.structuredOutput?`text-green-600`:`text-muted-foreground`)},` Structured Output `,2)]),v(`label`,Tt,[l(y(X),{modelValue:Y.value.vision,"onUpdate:modelValue":r[5]||=e=>Y.value.vision=e,binary:!0,"input-id":`add-vision`},null,8,[`modelValue`]),v(`span`,{class:s(Y.value.vision?`text-green-600`:`text-muted-foreground`)},` Vision `,2)]),xe.value===`registry`?(e(),D(`span`,Et,[...r[39]||=[v(`i`,{class:`pi pi-database mr-0.5`},null,-1),O(`Registry `,-1)]])):h(``,!0)])])):(e(),_(y(E),{key:1,label:`Add Model`,icon:`pi pi-plus`,severity:`secondary`,text:``,size:`small`,onClick:r[6]||=e=>be.value=!0}))])]),v(`section`,null,[r[55]||=v(`h3`,{class:`text-sm font-semibold mb-3 text-foreground`},` PDF Conversion `,-1),v(`div`,Dt,[v(`div`,Ot,[r[41]||=v(`label`,{class:`text-xs text-muted-foreground`},`Converter`,-1),l(y(_e),{modelValue:x.value,"onUpdate:modelValue":r[7]||=e=>x.value=e,options:Re,"option-label":`label`,"option-value":`value`,size:`small`},null,8,[`modelValue`])]),x.value===`mineru`?(e(),D(`div`,kt,[v(`div`,At,[r[42]||=v(`label`,{class:`text-xs text-muted-foreground`},`Command`,-1),l(y(F),{modelValue:S.value,"onUpdate:modelValue":r[8]||=e=>S.value=e,size:`small`,placeholder:`mineru`},null,8,[`modelValue`])]),v(`div`,jt,[r[43]||=v(`label`,{class:`text-xs text-muted-foreground`},`Arguments`,-1),l(y($),{modelValue:C.value,"onUpdate:modelValue":r[9]||=e=>C.value=e,rows:`4`,"auto-resize":``,class:`text-xs font-mono`},null,8,[`modelValue`])]),v(`div`,Mt,[r[44]||=v(`label`,{class:`text-xs text-muted-foreground`},`Timeout (seconds)`,-1),l(y(F),{value:String(ae.value),type:`number`,size:`small`,placeholder:`600`,min:1,onInput:r[10]||=e=>ae.value=Number(e.target.value)||600},null,8,[`value`])]),v(`div`,Nt,[l(y(X),{modelValue:oe.value,"onUpdate:modelValue":r[11]||=e=>oe.value=e,binary:!0,"input-id":`mineru-fallback`},null,8,[`modelValue`]),r[45]||=v(`label`,{for:`mineru-fallback`,class:`text-sm cursor-pointer`},`Fallback to built-in converter`,-1)]),v(`div`,Pt,[l(y(X),{modelValue:se.value,"onUpdate:modelValue":r[12]||=e=>se.value=e,binary:!0,"input-id":`mineru-keep-output`},null,8,[`modelValue`]),r[46]||=v(`label`,{for:`mineru-keep-output`,class:`text-sm cursor-pointer`},`Keep converted files on disk`,-1)]),r[47]||=v(`div`,{class:`text-xs text-muted-foreground p-2 rounded border border-border`},[O(` Placeholders: `),v(`code`,{class:`bg-secondary px-1 rounded`},`{input}`),O(`, `),v(`code`,{class:`bg-secondary px-1 rounded`},`{outputDir}`),O(`, `),v(`code`,{class:`bg-secondary px-1 rounded`},`{basename}`)],-1)])):h(``,!0),x.value===`markitdown`?(e(),D(`div`,Ft,[v(`div`,It,[r[48]||=v(`label`,{class:`text-xs text-muted-foreground`},`Command`,-1),l(y(F),{modelValue:k.value,"onUpdate:modelValue":r[13]||=e=>k.value=e,size:`small`,placeholder:`markitdown`},null,8,[`modelValue`])]),v(`div`,Lt,[r[49]||=v(`label`,{class:`text-xs text-muted-foreground`},`Arguments`,-1),l(y($),{modelValue:ce.value,"onUpdate:modelValue":r[14]||=e=>ce.value=e,rows:`4`,"auto-resize":``,class:`text-xs font-mono`},null,8,[`modelValue`])]),v(`div`,Rt,[r[50]||=v(`label`,{class:`text-xs text-muted-foreground`},`Output File`,-1),l(y(F),{modelValue:A.value,"onUpdate:modelValue":r[15]||=e=>A.value=e,size:`small`,class:`text-xs font-mono`,placeholder:`{outputDir}/{basename}.md`},null,8,[`modelValue`])]),v(`div`,zt,[r[51]||=v(`label`,{class:`text-xs text-muted-foreground`},`Timeout (seconds)`,-1),l(y(F),{value:String(de.value),type:`number`,size:`small`,placeholder:`600`,min:1,onInput:r[16]||=e=>de.value=Number(e.target.value)||600},null,8,[`value`])]),v(`div`,Bt,[l(y(X),{modelValue:M.value,"onUpdate:modelValue":r[17]||=e=>M.value=e,binary:!0,"input-id":`markitdown-fallback`},null,8,[`modelValue`]),r[52]||=v(`label`,{for:`markitdown-fallback`,class:`text-sm cursor-pointer`},`Fallback to built-in converter`,-1)]),v(`div`,Vt,[l(y(X),{modelValue:N.value,"onUpdate:modelValue":r[18]||=e=>N.value=e,binary:!0,"input-id":`markitdown-keep-output`},null,8,[`modelValue`]),r[53]||=v(`label`,{for:`markitdown-keep-output`,class:`text-sm cursor-pointer`},`Keep converted files on disk`,-1)]),r[54]||=v(`div`,{class:`text-xs text-muted-foreground p-2 rounded border border-border`},[O(` Placeholders: `),v(`code`,{class:`bg-secondary px-1 rounded`},`{input}`),O(`, `),v(`code`,{class:`bg-secondary px-1 rounded`},`{outputDir}`),O(`, `),v(`code`,{class:`bg-secondary px-1 rounded`},`{basename}`)],-1)])):h(``,!0)])]),v(`section`,null,[r[60]||=v(`h3`,{class:`text-sm font-semibold mb-3 text-foreground`},` Langfuse Tracing `,-1),v(`div`,Ht,[v(`div`,Ut,[l(y(X),{modelValue:P.value,"onUpdate:modelValue":r[19]||=e=>P.value=e,binary:!0,"input-id":`lf-enabled`},null,8,[`modelValue`]),r[56]||=v(`label`,{for:`lf-enabled`,class:`text-sm cursor-pointer`},`Enabled`,-1)]),P.value?(e(),D(`div`,Wt,[v(`div`,Gt,[r[57]||=v(`label`,{class:`text-xs text-muted-foreground`},`Secret Key`,-1),l(y(Je),{modelValue:L.value,"onUpdate:modelValue":r[20]||=e=>L.value=e,feedback:!1,"toggle-mask":``,size:`small`,placeholder:`sk-lf-...`,"input-class":`w-full`},null,8,[`modelValue`])]),v(`div`,Kt,[r[58]||=v(`label`,{class:`text-xs text-muted-foreground`},`Public Key`,-1),l(y(F),{modelValue:I.value,"onUpdate:modelValue":r[21]||=e=>I.value=e,size:`small`,placeholder:`pk-lf-...`},null,8,[`modelValue`])]),v(`div`,qt,[r[59]||=v(`label`,{class:`text-xs text-muted-foreground`},`Host (optional)`,-1),l(y(F),{modelValue:ve.value,"onUpdate:modelValue":r[22]||=e=>ve.value=e,size:`small`,placeholder:`https://us.cloud.langfuse.com`},null,8,[`modelValue`])])])):h(``,!0)])]),v(`section`,null,[r[69]||=v(`h3`,{class:`text-sm font-semibold mb-3 text-foreground`},` Notion Export `,-1),v(`div`,Jt,[v(`div`,Yt,[l(y(X),{modelValue:R.value,"onUpdate:modelValue":r[23]||=e=>R.value=e,binary:!0,"input-id":`notion-enabled`},null,8,[`modelValue`]),r[61]||=v(`label`,{for:`notion-enabled`,class:`text-sm cursor-pointer`},`Enabled`,-1)]),v(`div`,Xt,[v(`div`,Zt,[r[62]||=v(`label`,{class:`text-xs text-muted-foreground`},`Integration Token`,-1),l(y(Je),{modelValue:z.value,"onUpdate:modelValue":r[24]||=e=>z.value=e,feedback:!1,"toggle-mask":``,size:`small`,placeholder:`secret_...`,"input-class":`w-full`},null,8,[`modelValue`])]),v(`div`,Qt,[r[63]||=v(`label`,{class:`text-xs text-muted-foreground`},`Schema Binding`,-1),l(y(_e),{modelValue:V.value,"onUpdate:modelValue":r[25]||=e=>V.value=e,options:ke.value,size:`small`,placeholder:`Select a schema`,disabled:ke.value.length===0},null,8,[`modelValue`,`options`,`disabled`])]),v(`div`,$t,[r[64]||=v(`label`,{class:`text-xs text-muted-foreground`},`Database/Data Source URL or ID`,-1),l(y(F),{modelValue:H.value,"onUpdate:modelValue":r[26]||=e=>H.value=e,size:`small`,placeholder:`https://www.notion.so/... or xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`},null,8,[`modelValue`])]),v(`div`,en,[l(y(E),{label:`Connect & Map`,icon:`pi pi-bolt`,severity:`secondary`,size:`small`,loading:G.value,disabled:!V.value||!z.value.trim()||!H.value.trim()||!!Z.value,onClick:Ve},null,8,[`loading`,`disabled`]),je.value?(e(),D(`span`,tn,i(je.value),1)):h(``,!0)]),v(`div`,nn,[v(`button`,{type:`button`,class:`w-full flex items-center justify-between gap-2 px-3 py-2 text-left text-xs text-muted-foreground hover:bg-secondary`,onClick:r[27]||=e=>ye.value=!ye.value},[r[65]||=v(`span`,null,`Advanced mapping`,-1),v(`i`,{class:s([ye.value?`pi pi-chevron-up`:`pi pi-chevron-down`,`text-[10px]`])},null,2)]),ye.value?(e(),D(`div`,rn,[v(`div`,an,[r[66]||=v(`label`,{class:`text-xs text-muted-foreground`},`Title Property (optional)`,-1),l(y(F),{modelValue:U.value,"onUpdate:modelValue":r[28]||=e=>U.value=e,size:`small`,placeholder:`Name`},null,8,[`modelValue`])]),v(`div`,on,[v(`div`,sn,[r[67]||=v(`label`,{class:`text-xs text-muted-foreground`},`Field Map JSON`,-1),q.value.length>0?(e(),D(`span`,cn,i(Ae.value)+` / `+i(q.value.length)+` mapped `,1)):h(``,!0)]),l(y($),{modelValue:W.value,"onUpdate:modelValue":r[29]||=e=>W.value=e,rows:`5`,"auto-resize":``,class:`text-xs font-mono`,placeholder:`{
344
344
  "invoiceNo": "Invoice No",
@@ -0,0 +1 @@
1
+ import{B as e,L as t,Lt as n,S as r,et as i,h as a,ht as o,lt as s,t as c,v as l,w as u}from"./button-Cdgr9Igy.js";import{_ as d,p as f,r as p}from"./api-client-CG1VV5gz.js";var m={class:`flex h-full`},h={key:0,class:`flex-1 flex flex-col items-center justify-center text-muted-foreground`},g={key:1,class:`flex-1 flex items-center justify-center text-muted-foreground`},_={key:2,class:`flex-1 min-h-0 p-3 flex flex-col overflow-x-auto`},v={class:`flex items-center justify-between mb-3 shrink-0`},y={class:`m-0 text-lg font-semibold text-foreground`},b={class:`flex items-center gap-2`},x={class:`flex-1 min-h-0 overflow-auto`},S={class:`text-sm font-mono whitespace-pre-wrap text-foreground bg-secondary border border-border rounded-lg p-4`},C=u({__name:`ExtractionViewer`,props:{extractionName:{}},setup(u){let C=u,w=s(``),T=s(!1),E=s(!1);async function D(){if(C.extractionName){T.value=!0,w.value=``;try{let e=await p(C.extractionName);e.success&&e.content?w.value=e.content:d.error(e.error||`Failed to load extraction`)}catch{d.error(`Failed to load extraction`)}T.value=!1}}function O(){if(!C.extractionName||!w.value)return;let e=new Blob([w.value],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=C.extractionName,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}async function k(){if(C.extractionName){E.value=!0;try{let e=await f(C.extractionName);d.success(`Synced to Notion (${e.notionPages?.length??0} page)`)}catch(e){d.error(e instanceof Error?e.message:`Notion sync failed`)}E.value=!1}}function A(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}return i(()=>C.extractionName,D),t(D),(t,i)=>(e(),l(`div`,m,[u.extractionName?T.value?(e(),l(`div`,g,` Loading... `)):(e(),l(`div`,_,[a(`div`,v,[a(`h2`,y,n(u.extractionName),1),a(`div`,b,[r(o(c),{icon:`pi pi-refresh`,label:`Retry Notion`,severity:`secondary`,size:`small`,loading:E.value,onClick:k},null,8,[`loading`]),r(o(c),{icon:`pi pi-download`,label:`Download`,severity:`secondary`,size:`small`,onClick:O})])]),a(`div`,x,[a(`pre`,S,n(A(w.value)),1)])])):(e(),l(`div`,h,[...i[0]||=[a(`i`,{class:`pi pi-file text-4xl mb-3 opacity-50`},null,-1),a(`p`,{class:`text-sm`},` Select an extraction record from the sidebar `,-1)]]))]))}});export{C as default};
@@ -1 +1 @@
1
- import{A as e,B as t,F as n,Ft as r,H as i,It as a,K as o,L as s,Lt as c,M as l,N as ee,Pt as u,S as d,U as f,X as p,_ as m,d as h,et as g,g as _,h as v,ht as y,lt as b,m as x,nt as S,tt as C,v as w,w as T,x as E}from"./button-Cdgr9Igy.js";var D=1,O=new class{subscribers;toasts;dismissedToasts;constructor(){this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)});publish=e=>{this.subscribers.forEach(t=>t(e))};addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]};create=e=>{let{message:t,...n}=e,r=typeof e.id==`number`||e.id&&e.id?.length>0?e.id:D++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r};dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e);message=(e,t)=>this.create({...t,message:e,type:`default`});error=(e,t)=>this.create({...t,type:`error`,message:e});success=(e,t)=>this.create({...t,type:`success`,message:e});info=(e,t)=>this.create({...t,type:`info`,message:e});warning=(e,t)=>this.create({...t,type:`warning`,message:e});loading=(e,t)=>this.create({...t,type:`loading`,message:e});promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:`loading`,message:n.loading,description:typeof n.description==`function`?void 0:n.description}));let i=Promise.resolve(t instanceof Function?t():t),a=r!==void 0,o,s=i.then(async t=>{if(o=[`resolve`,t],e(t))a=!1,this.create({id:r,type:`default`,message:t});else if(A(t)&&!t.ok){a=!1;let i=typeof n.error==`function`?await n.error(`HTTP error! status: ${t.status}`):n.error,o=typeof n.description==`function`?await n.description(`HTTP error! status: ${t.status}`):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`error`,description:o,...s})}else if(t instanceof Error){a=!1;let i=typeof n.error==`function`?await n.error(t):n.error,o=typeof n.description==`function`?await n.description(t):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`error`,description:o,...s})}else if(n.success!==void 0){a=!1;let i=typeof n.success==`function`?await n.success(t):n.success,o=typeof n.description==`function`?await n.description(t):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`success`,description:o,...s})}}).catch(async t=>{if(o=[`reject`,t],n.error!==void 0){a=!1;let i=typeof n.error==`function`?await n.error(t):n.error,o=typeof n.description==`function`?await n.description(t):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`error`,description:o,...s})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally?.()}),c=()=>new Promise((e,t)=>s.then(()=>o[0]===`reject`?t(o[1]):e(o[1])).catch(t));return typeof r!=`string`&&typeof r!=`number`?{unwrap:c}:Object.assign(r,{unwrap:c})};custom=(e,t)=>{let n=t?.id||D++,r=this.toasts.find(e=>e.id===n),i=t?.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),r?this.toasts=this.toasts.map(r=>r.id===n?(this.publish({...r,component:e,dismissible:i,id:n,...t}),{...r,component:e,dismissible:i,id:n,...t}):r):this.addToast({component:e,dismissible:i,id:n,...t}),n};getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id))};function k(e,t){let n=t?.id||D++;return O.create({message:e,id:n,type:`default`,...t}),n}var A=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,j=Object.assign(k,{success:O.success,info:O.info,warning:O.warning,error:O.error,custom:O.custom,message:O.message,promise:O.promise,dismiss:O.dismiss,loading:O.loading},{getHistory:()=>O.toasts,getToasts:()=>O.getActiveToasts()});function M(e){return e.label!==void 0}var N=3,P=`24px`,F=`16px`,te=4e3,ne=356,I=14,re=45,ie=200;function ae(){let e=b(!1);return C(()=>{let t=()=>{e.value=document.hidden};return document.addEventListener(`visibilitychange`,t),()=>window.removeEventListener(`visibilitychange`,t)}),{isDocumentHidden:e}}function L(...e){return e.filter(Boolean).join(` `)}function oe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}function se(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?F:P;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var ce=[`data-rich-colors`,`data-styled`,`data-mounted`,`data-promise`,`data-swiped`,`data-removed`,`data-visible`,`data-y-position`,`data-x-position`,`data-index`,`data-front`,`data-swiping`,`data-dismissible`,`data-type`,`data-invert`,`data-swipe-out`,`data-swipe-direction`,`data-expanded`,`data-testid`],le=[`aria-label`,`data-disabled`,`data-close-button-position`],ue=T({__name:`Toast`,props:{toast:{},toasts:{},index:{},swipeDirections:{},expanded:{type:Boolean},invert:{type:Boolean},heights:{},gap:{},position:{},closeButtonPosition:{},visibleToasts:{},expandByDefault:{type:Boolean},closeButton:{type:Boolean},interacting:{type:Boolean},style:{},cancelButtonStyle:{},actionButtonStyle:{},duration:{},class:{},unstyled:{type:Boolean},descriptionClass:{},loadingIcon:{},classes:{},icons:{},closeButtonAriaLabel:{},defaultRichColors:{type:Boolean}},emits:[`update:heights`,`update:height`,`removeToast`],setup(e,{emit:i}){let d=e,p=i,S=b(null),T=b(null),D=b(!1),O=b(!1),k=b(!1),A=b(!1),j=b(!1),N=b(0),P=b(0),F=b(d.toast.duration||d.duration||te),ne=b(null),I=b(null),se=x(()=>d.index===0),ue=x(()=>d.index+1<=d.visibleToasts),R=x(()=>d.toast.type),z=x(()=>d.toast.dismissible!==!1),de=x(()=>d.toast.class||``),fe=x(()=>d.descriptionClass||``),pe=x(()=>{let e=d.toast.position||d.position,t=d.heights.filter(t=>t.position===e).findIndex(e=>e.toastId===d.toast.id);return t>=0?t:0}),me=x(()=>{let e=d.toast.position||d.position;return d.heights.filter(t=>t.position===e).reduce((e,t,n)=>n>=pe.value?e:e+t.height,0)}),B=x(()=>pe.value*d.gap+me.value||0),he=x(()=>d.toast.closeButton??d.closeButton),ge=x(()=>d.toast.duration||d.duration||te),_e=b(0),ve=b(0),V=b(null),ye=x(()=>d.position.split(`-`)),be=x(()=>ye.value[0]),xe=x(()=>ye.value[1]),Se=x(()=>typeof d.toast.title!=`string`),Ce=x(()=>typeof d.toast.description!=`string`),{isDocumentHidden:we}=ae(),H=x(()=>R.value&&R.value===`loading`);s(()=>{D.value=!0,F.value=ge.value}),C(async()=>{if(!D.value||!I.value)return;await ee();let e=I.value,t=e.style.height;e.style.height=`auto`;let n=e.getBoundingClientRect().height;e.style.height=t,P.value=n,p(`update:height`,{toastId:d.toast.id,height:n,position:d.toast.position||d.position})});function U(){O.value=!0,N.value=B.value,setTimeout(()=>{p(`removeToast`,d.toast)},ie)}function Te(){if(H.value||!z.value)return{};U(),d.toast.onDismiss?.(d.toast)}function Ee(e){e.button!==2&&(H.value||!z.value||(ne.value=new Date,N.value=B.value,e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(k.value=!0,V.value={x:e.clientX,y:e.clientY})))}function De(){if(A.value||!z.value)return;V.value=null;let e=Number(I.value?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(I.value?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),n=new Date().getTime()-(ne.value?.getTime()||0),r=S.value===`x`?e:t,i=Math.abs(r)/n;if(Math.abs(r)>=re||i>.11){N.value=B.value,d.toast.onDismiss?.(d.toast),S.value===`x`?T.value=e>0?`right`:`left`:T.value=t>0?`down`:`up`,U(),A.value=!0;return}else I.value?.style.setProperty(`--swipe-amount-x`,`0px`),I.value?.style.setProperty(`--swipe-amount-y`,`0px`);j.value=!1,k.value=!1,S.value=null}function Oe(e){if(!V.value||!z.value||(window?.getSelection()?.toString()?.length??!1))return;let t=e.clientY-V.value.y,n=e.clientX-V.value.x,r=d.swipeDirections??oe(d.position);!S.value&&(Math.abs(n)>1||Math.abs(t)>1)&&(S.value=Math.abs(n)>Math.abs(t)?`x`:`y`);let i={x:0,y:0},a=e=>1/(1.5+Math.abs(e)/20);if(S.value===`y`){if(r.includes(`top`)||r.includes(`bottom`))if(r.includes(`top`)&&t<0||r.includes(`bottom`)&&t>0)i.y=t;else{let e=t*a(t);i.y=Math.abs(e)<Math.abs(t)?e:t}}else if(S.value===`x`&&(r.includes(`left`)||r.includes(`right`)))if(r.includes(`left`)&&n<0||r.includes(`right`)&&n>0)i.x=n;else{let e=n*a(n);i.x=Math.abs(e)<Math.abs(n)?e:n}(Math.abs(i.x)>0||Math.abs(i.y)>0)&&(j.value=!0),I.value?.style.setProperty(`--swipe-amount-x`,`${i.x}px`),I.value?.style.setProperty(`--swipe-amount-y`,`${i.y}px`)}s(()=>{if(D.value=!0,!I.value)return;let e=I.value.getBoundingClientRect().height;P.value=e,p(`update:heights`,[{toastId:d.toast.id,height:e,position:d.toast.position},...d.heights])}),n(()=>{I.value&&p(`removeToast`,d.toast)}),C(e=>{if(d.toast.promise&&R.value===`loading`||d.toast.duration===1/0||d.toast.type===`loading`)return;let t;d.expanded||d.interacting||we.value?(()=>{if(ve.value<_e.value){let e=new Date().getTime()-_e.value;F.value-=e}ve.value=new Date().getTime()})():F.value!==1/0&&(_e.value=new Date().getTime(),t=setTimeout(()=>{d.toast.onAutoClose?.(d.toast),U()},F.value)),e(()=>{clearTimeout(t)})}),g(()=>d.toast.delete,e=>{e!==void 0&&e&&(U(),d.toast.onDismiss?.(d.toast))},{deep:!0});function ke(){k.value=!1,S.value=null,V.value=null}return(e,n)=>(t(),w(`li`,{tabindex:`0`,ref_key:`toastRef`,ref:I,class:u(y(L)(d.class,de.value,e.classes?.toast,e.toast.classes?.toast,e.classes?.[R.value],e.toast?.classes?.[R.value])),"data-sonner-toast":``,"data-rich-colors":e.toast.richColors??e.defaultRichColors,"data-styled":!(e.toast.component||e.toast?.unstyled||e.unstyled),"data-mounted":D.value,"data-promise":!!e.toast.promise,"data-swiped":j.value,"data-removed":O.value,"data-visible":ue.value,"data-y-position":be.value,"data-x-position":xe.value,"data-index":e.index,"data-front":se.value,"data-swiping":k.value,"data-dismissible":z.value,"data-type":R.value,"data-invert":e.toast.invert||e.invert,"data-swipe-out":A.value,"data-swipe-direction":T.value,"data-expanded":!!(e.expanded||e.expandByDefault&&D.value),"data-testid":e.toast.testId,style:a({"--index":e.index,"--toasts-before":e.index,"--z-index":e.toasts.length-e.index,"--offset":`${O.value?N.value:B.value}px`,"--initial-height":e.expandByDefault?`auto`:`${P.value}px`,...e.style,...d.toast.style}),onDragend:ke,onPointerdown:Ee,onPointerup:De,onPointermove:Oe},[he.value&&!e.toast.component&&R.value!==`loading`?(t(),w(`button`,{key:0,"aria-label":e.closeButtonAriaLabel||`Close toast`,"data-disabled":H.value,"data-close-button":`true`,"data-close-button-position":e.closeButtonPosition,class:u(y(L)(e.classes?.closeButton,e.toast?.classes?.closeButton)),onClick:Te},[e.icons?.close?(t(),_(o(e.icons?.close),{key:0})):f(e.$slots,`close-icon`,{key:1})],10,le)):m(`v-if`,!0),e.toast.component?(t(),_(o(e.toast.component),l({key:1},e.toast.componentProps,{onCloseToast:Te,isPaused:e.$props.expanded||e.$props.interacting||y(we)}),null,16,[`isPaused`])):(t(),w(h,{key:2},[R.value!==`default`||e.toast.icon||e.toast.promise?(t(),w(`div`,{key:0,"data-icon":``,class:u(y(L)(e.classes?.icon,e.toast?.classes?.icon))},[e.toast.icon?(t(),_(o(e.toast.icon),{key:0})):(t(),w(h,{key:1},[R.value===`loading`?f(e.$slots,`loading-icon`,{key:0}):R.value===`success`?f(e.$slots,`success-icon`,{key:1}):R.value===`error`?f(e.$slots,`error-icon`,{key:2}):R.value===`warning`?f(e.$slots,`warning-icon`,{key:3}):R.value===`info`?f(e.$slots,`info-icon`,{key:4}):m(`v-if`,!0)],64))],2)):m(`v-if`,!0),v(`div`,{"data-content":``,class:u(y(L)(e.classes?.content,e.toast?.classes?.content))},[v(`div`,{"data-title":``,class:u(y(L)(e.classes?.title,e.toast.classes?.title))},[Se.value?(t(),_(o(e.toast.title),r(l({key:0},e.toast.componentProps)),null,16)):(t(),w(h,{key:1},[E(c(e.toast.title),1)],64))],2),e.toast.description?(t(),w(`div`,{key:0,"data-description":``,class:u(y(L)(e.descriptionClass,fe.value,e.classes?.description,e.toast.classes?.description))},[Ce.value?(t(),_(o(e.toast.description),r(l({key:0},e.toast.componentProps)),null,16)):(t(),w(h,{key:1},[E(c(e.toast.description),1)],64))],2)):m(`v-if`,!0)],2),e.toast.cancel?(t(),w(`button`,{key:1,style:a(e.toast.cancelButtonStyle||e.cancelButtonStyle),class:u(y(L)(e.classes?.cancelButton,e.toast.classes?.cancelButton)),"data-button":``,"data-cancel":``,onClick:n[0]||=t=>{y(M)(e.toast.cancel)&&z.value&&(e.toast.cancel.onClick?.(t),U())}},c(y(M)(e.toast.cancel)?e.toast.cancel?.label:e.toast.cancel),7)):m(`v-if`,!0),e.toast.action?(t(),w(`button`,{key:2,style:a(e.toast.actionButtonStyle||e.actionButtonStyle),class:u(y(L)(e.classes?.actionButton,e.toast.classes?.actionButton)),"data-button":``,"data-action":``,onClick:n[1]||=t=>{y(M)(e.toast.action)&&(e.toast.action.onClick?.(t),!t.defaultPrevented&&U())}},c(y(M)(e.toast.action)?e.toast.action?.label:e.toast.action),7)):m(`v-if`,!0)],64))],46,ce))}}),R=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},z={},de={xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stoke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`};function fe(e,n){return t(),w(`svg`,de,n[0]||=[v(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`},null,-1),v(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`},null,-1)])}var pe=R(z,[[`render`,fe]]),me=[`data-visible`],B={class:`sonner-spinner`},he=T({__name:`Loader`,props:{visible:{type:Boolean}},setup(e){let n=Array(12).fill(0);return(e,r)=>(t(),w(`div`,{class:`sonner-loading-wrapper`,"data-visible":e.visible},[v(`div`,B,[(t(!0),w(h,null,i(y(n),e=>(t(),w(`div`,{key:`spinner-bar-${e}`,class:`sonner-loading-bar`}))),128))])],8,me))}}),ge={},_e={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`};function ve(e,n){return t(),w(`svg`,_e,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,"clip-rule":`evenodd`},null,-1)])}var V=R(ge,[[`render`,ve]]),ye={},be={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`};function xe(e,n){return t(),w(`svg`,be,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,"clip-rule":`evenodd`},null,-1)])}var Se=R(ye,[[`render`,xe]]),Ce={},we={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`};function H(e,n){return t(),w(`svg`,we,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,"clip-rule":`evenodd`},null,-1)])}var U=R(Ce,[[`render`,H]]),Te={},Ee={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`};function De(e,n){return t(),w(`svg`,Ee,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,"clip-rule":`evenodd`},null,-1)])}var Oe=R(Te,[[`render`,De]]),ke=[`aria-label`],Ae=[`data-sonner-theme`,`dir`,`data-theme`,`data-rich-colors`,`data-y-position`,`data-x-position`],je=typeof window<`u`&&typeof document<`u`;function Me(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}var Ne=T({name:`Toaster`,inheritAttrs:!1,__name:`Toaster`,props:{id:{},invert:{type:Boolean,default:!1},theme:{default:`light`},position:{default:`bottom-right`},closeButtonPosition:{default:`top-left`},hotkey:{default:()=>[`altKey`,`KeyT`]},richColors:{type:Boolean,default:!1},expand:{type:Boolean,default:!1},duration:{},gap:{default:I},visibleToasts:{default:N},closeButton:{type:Boolean,default:!1},toastOptions:{default:()=>({})},class:{default:``},style:{},offset:{default:P},mobileOffset:{default:F},dir:{default:`auto`},swipeDirections:{},icons:{},containerAriaLabel:{default:`Notifications`}},setup(e){let n=e,r=p(),o=b([]),s=x(()=>n.id?o.value.filter(e=>e.toasterId===n.id):o.value.filter(e=>!e.toasterId));function c(e,t){return s.value.filter(n=>!n.position&&t===0||n.position===e)}let g=x(()=>{let e=s.value.filter(e=>e.position).map(e=>e.position);return e.length>0?Array.from(new Set([n.position].concat(e))):[n.position]}),T=x(()=>{let e={};return g.value.forEach(t=>{e[t]=o.value.filter(e=>e.position===t)}),e}),E=b([]),D=b({}),k=b(!1);C(()=>{g.value.forEach(e=>{e in D.value||(D.value[e]=!1)})});let A=b(n.theme===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:n.theme),j=b(null),M=b(null),N=b(!1),P=n.hotkey.join(`+`).replace(/Key/g,``).replace(/Digit/g,``);function F(e){o.value.find(t=>t.id===e.id)?.delete||O.dismiss(e.id),o.value=o.value.filter(({id:t})=>t!==e.id),setTimeout(()=>{o.value.find(t=>t.id===e.id)||(E.value=E.value.filter(t=>t.toastId!==e.id))},ie+50)}function te(e){N.value&&!e.currentTarget?.contains?.(e.relatedTarget)&&(N.value=!1,M.value&&=(M.value.focus({preventScroll:!0}),null))}function I(e){e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||N.value||(N.value=!0,M.value=e.relatedTarget)}function re(e){e.target&&e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||(k.value=!0)}C(e=>{e(O.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{o.value=o.value.map(t=>t.id===e.id?{...t,delete:!0}:t)});return}ee(()=>{let t=o.value.findIndex(t=>t.id===e.id);t===-1?o.value=[e,...o.value]:o.value=[...o.value.slice(0,t),{...o.value[t],...e},...o.value.slice(t+1)]})}))}),C(e=>{if(typeof window>`u`)return;if(n.theme!==`system`){A.value=n.theme;return}let t=window.matchMedia(`(prefers-color-scheme: dark)`),r=e=>{A.value=e?`dark`:`light`};r(t.matches);let i=e=>{r(e.matches)};try{t.addEventListener(`change`,i)}catch{t.addListener(i)}e(()=>{try{t.removeEventListener(`change`,i)}catch{t.removeListener(i)}})}),C(()=>{j.value&&M.value&&(M.value.focus({preventScroll:!0}),M.value=null,N.value=!1)}),C(()=>{o.value.length<=1&&Object.keys(D.value).forEach(e=>{D.value[e]=!1})}),C(e=>{function t(e){let t=n.hotkey.every(t=>e[t]||e.code===t),r=Array.isArray(j.value)?j.value[0]:j.value;t&&(g.value.forEach(e=>{D.value[e]=!0}),r?.focus());let i=document.activeElement===j.value||r?.contains(document.activeElement);e.code===`Escape`&&i&&g.value.forEach(e=>{D.value[e]=!1})}je&&(document.addEventListener(`keydown`,t),e(()=>{document.removeEventListener(`keydown`,t)}))});function ae(e){let t=e.currentTarget,n=t.getAttribute(`data-y-position`)+`-`+t.getAttribute(`data-x-position`);D.value[n]=!0}function L(e){if(!k.value){let t=e.currentTarget,n=t.getAttribute(`data-y-position`)+`-`+t.getAttribute(`data-x-position`);D.value[n]=!1}}function oe(){Object.keys(D.value).forEach(e=>{D.value[e]=!1})}function ce(){k.value=!1}function le(e){E.value=e}function R(e){let t=E.value.findIndex(t=>t.toastId===e.toastId);if(t!==-1)E.value[t]=e;else{let t=E.value.findIndex(t=>t.position===e.position);t===-1?E.value.unshift(e):E.value.splice(t,0,e)}}return(e,o)=>(t(),w(h,null,[m(` Remove item from normal navigation flow, only available via hotkey `),v(`section`,{"aria-label":`${e.containerAriaLabel} ${y(P)}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`},[(t(!0),w(h,null,i(g.value,(o,s)=>(t(),w(`ol`,l({key:o,ref_for:!0,ref_key:`listRef`,ref:j,"data-sonner-toaster":``,"data-sonner-theme":A.value,class:n.class,dir:e.dir===`auto`?Me():e.dir,tabIndex:-1,"data-theme":e.theme,"data-rich-colors":e.richColors,"data-y-position":o.split(`-`)[0],"data-x-position":o.split(`-`)[1],style:{"--front-toast-height":`${E.value[0]?.height||0}px`,"--width":`${y(ne)}px`,"--gap":`${e.gap}px`,...e.style,...y(r).style,...y(se)(e.offset,e.mobileOffset)}},{ref_for:!0},e.$attrs,{onBlur:te,onFocus:I,onMouseenter:ae,onMousemove:ae,onMouseleave:L,onDragend:oe,onPointerdown:re,onPointerup:ce}),[(t(!0),w(h,null,i(c(o,s),(r,i)=>(t(),_(ue,{key:r.id,heights:E.value,icons:e.icons,index:i,toast:r,defaultRichColors:e.richColors,duration:e.toastOptions?.duration??e.duration,class:u(e.toastOptions?.class??``),descriptionClass:e.toastOptions?.descriptionClass,invert:e.invert,visibleToasts:e.visibleToasts,closeButton:e.toastOptions?.closeButton??e.closeButton,interacting:k.value,position:o,closeButtonPosition:e.toastOptions?.closeButtonPosition??e.closeButtonPosition,style:a(e.toastOptions?.style),unstyled:e.toastOptions?.unstyled,classes:e.toastOptions?.classes,cancelButtonStyle:e.toastOptions?.cancelButtonStyle,actionButtonStyle:e.toastOptions?.actionButtonStyle,"close-button-aria-label":e.toastOptions?.closeButtonAriaLabel,toasts:T.value[o],expandByDefault:e.expand,gap:e.gap,expanded:D.value[o]||!1,swipeDirections:n.swipeDirections,"onUpdate:heights":le,"onUpdate:height":R,onRemoveToast:F},{"close-icon":S(()=>[f(e.$slots,`close-icon`,{},()=>[d(pe)])]),"loading-icon":S(()=>[f(e.$slots,`loading-icon`,{},()=>[d(he,{visible:r.type===`loading`},null,8,[`visible`])])]),"success-icon":S(()=>[f(e.$slots,`success-icon`,{},()=>[d(V)])]),"error-icon":S(()=>[f(e.$slots,`error-icon`,{},()=>[d(Oe)])]),"warning-icon":S(()=>[f(e.$slots,`warning-icon`,{},()=>[d(U)])]),"info-icon":S(()=>[f(e.$slots,`info-icon`,{},()=>[d(Se)])]),_:2},1032,[`heights`,`icons`,`index`,`toast`,`defaultRichColors`,`duration`,`class`,`descriptionClass`,`invert`,`visibleToasts`,`closeButton`,`interacting`,`position`,`closeButtonPosition`,`style`,`unstyled`,`classes`,`cancelButtonStyle`,`actionButtonStyle`,`close-button-aria-label`,`toasts`,`expandByDefault`,`gap`,`expanded`,`swipeDirections`]))),128))],16,Ae))),128))],8,ke)],2112))}}),W=class extends Error{name=`KyError`;get isKyError(){return!0}},Pe=class extends W{name=`HTTPError`;response;request;options;data;constructor(e,t,n){let r=`${e.status||e.status===0?e.status:``} ${e.statusText??``}`.trim(),i=r?`status code ${r}`:`an unknown error`;super(`Request failed with ${i}: ${t.method} ${t.url}`),this.response=e,this.request=t,this.options=n}},Fe=class extends W{name=`NetworkError`;request;constructor(e,t){super(`Request failed due to a network error: ${e.method} ${e.url}`,t),this.request=e}},Ie=class extends Error{name=`NonError`;value;constructor(e){let t=`Non-error value was thrown`;try{typeof e==`string`?t=e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`&&(t=e.message)}catch{}super(t),this.value=e}},G=class extends W{name=`ForceRetryError`;customDelay;code;customRequest;constructor(e){let t=e?.cause?e.cause instanceof Error?e.cause:new Ie(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:`Forced retry`,t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},Le=class extends Error{name=`SchemaValidationError`;issues;constructor(e){super(`Response schema validation failed`),this.issues=e}},K=class extends W{name=`TimeoutError`;request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.request=e}},Re=(()=>{let e=!1,t=!1,n=typeof globalThis.ReadableStream==`function`,r=typeof globalThis.Request==`function`;if(n&&r)try{t=new globalThis.Request(`https://empty.invalid`,{body:new globalThis.ReadableStream,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`)}catch(e){if(e instanceof Error&&e.message===`unsupported BodyInit type`)return!1;throw e}return e&&!t})(),ze=typeof globalThis.AbortController==`function`,Be=typeof globalThis.AbortSignal==`function`&&typeof globalThis.AbortSignal.any==`function`,Ve=typeof globalThis.ReadableStream==`function`,He=typeof globalThis.FormData==`function`,Ue=[`get`,`post`,`put`,`patch`,`head`,`delete`],We={json:`application/json`,text:`text/*`,formData:`multipart/form-data`,arrayBuffer:`*/*`,blob:`*/*`,bytes:`*/*`},Ge=2147483647,Ke=Symbol(`stop`),qe=class{options;constructor(e){this.options=e}},Je=e=>new qe(e),Ye={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},Xe={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Ze=new TextEncoder,Qe=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[n,r]of e)t+=40,t+=Ze.encode(`Content-Disposition: form-data; name="${n}"`).byteLength,t+=typeof r==`string`?Ze.encode(r).byteLength:r.size;return t}return e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof e==`string`?Ze.encode(e).byteLength:e instanceof URLSearchParams?Ze.encode(e.toString()).byteLength:0},$e=(e,t,n)=>{let r,i=0;return e.pipeThrough(new TransformStream({transform(e,a){if(a.enqueue(e),r){i+=r.byteLength;let e=t===0?0:i/t;e>=1&&(e=1-2**-52),n?.({percent:e,totalBytes:Math.max(t,i),transferredBytes:i},r)}r=e},flush(){r&&(i+=r.byteLength,n?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},r))}}))},et=(e,t)=>{if(!e.body)return e;let n={status:e.status,statusText:e.statusText,headers:e.headers};if(e.status===204)return new Response(null,n);let r=Math.max(0,Number(e.headers.get(`content-length`))||0);return new Response($e(e.body,r,t),n)},tt=(e,t,n)=>{if(!e.body)return e;let r=Qe(n??e.body);return new Request(e,{duplex:`half`,body:$e(e.body,r,t)})},q=e=>typeof e==`object`&&!!e,nt=Symbol(`replaceOption`),rt=e=>q(e)&&e[nt]===!0?{isReplace:!0,value:e.value}:{isReplace:!1,value:e},it=(...e)=>{for(let t of e)if((!q(t)||Array.isArray(t))&&t!==void 0)throw TypeError("The `options` argument must be an object");return dt({},...e)},at=(e={},t={})=>{let n=new globalThis.Headers(e),r=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[e,t]of i.entries())r&&t===`undefined`||t===void 0?n.delete(e):n.set(e,t);return n},ot=e=>{if(!q(e)||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},J=e=>{if(e instanceof URLSearchParams){let t=new URLSearchParams(e),n=e[X];return n&&(t[X]=new Set(n)),t}return e instanceof globalThis.Headers?new globalThis.Headers(e):Array.isArray(e)?[...e]:ot(e)?{...e}:e},st=e=>Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0)),ct=(e,t)=>ot(e)&&ot(t)?st({...e,...t}):at(e,t);function Y(e,t,n){return Object.hasOwn(t,n)&&t[n]===void 0?[]:dt(e[n]??[],t[n]??[])}var lt=(e={},t={})=>({init:Y(e,t,`init`),beforeRequest:Y(e,t,`beforeRequest`),beforeRetry:Y(e,t,`beforeRetry`),beforeError:Y(e,t,`beforeError`),afterResponse:Y(e,t,`afterResponse`)}),X=Symbol(`deletedParameters`),ut=(e,t)=>{let n=new URLSearchParams,r=new Set;for(let i of[e,t])if(i!==void 0)if(i instanceof URLSearchParams){for(let[e,t]of i.entries())n.append(e,t),r.delete(e);let e=i[X];if(e)for(let t of e)n.delete(t),r.add(t)}else if(Array.isArray(i))for(let e of i){if(!Array.isArray(e)||e.length!==2)throw TypeError(`Array search parameters must be provided in [[key, value], ...] format`);n.append(String(e[0]),String(e[1])),r.delete(String(e[0]))}else if(q(i))for(let[e,t]of Object.entries(i))t===void 0?(n.delete(e),r.add(e)):(n.append(e,String(t)),r.delete(e));else{let e=new URLSearchParams(i);for(let[t,i]of e.entries())n.append(t,i),r.delete(t)}return r.size>0&&(n[X]=r),n},dt=(...e)=>{let t={},n={},r={},i,a=[];for(let o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(q(o)){for(let[e,n]of Object.entries(o)){if(e===`signal`&&n instanceof globalThis.AbortSignal){a.push(n);continue}let r=rt(n),{isReplace:o}=r;if(n=r.value,e===`context`){if(n!=null&&(!q(n)||Array.isArray(n)))throw TypeError("The `context` option must be an object");t={...t,context:n==null?{}:o?{...n}:{...t.context,...n}};continue}if(e===`searchParams`){i=n==null?void 0:o||i===void 0?n:ut(i,n);continue}q(n)&&!o&&e in t&&(n=dt(t[e],n)),t={...t,[e]:n}}if(q(o.hooks)){let{value:e,isReplace:n}=rt(o.hooks);r=lt(n?{}:r,e),t.hooks=r}if(q(o.headers)){let{value:e,isReplace:r}=rt(o.headers);n=r?J(e):ct(n,e),t.headers=n}}return i!==void 0&&(t.searchParams=i),a.length>0&&(a.length===1?t.signal=a[0]:Be?t.signal=AbortSignal.any(a):t.signal=a.at(-1)),t},ft=e=>Ue.includes(e)?e.toUpperCase():e,pt={limit:2,methods:[`get`,`put`,`head`,`delete`,`options`,`trace`],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:1/0,backoffLimit:1/0,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},mt=(e={})=>{if(typeof e==`number`)return{...pt,limit:e};if(e.methods&&!Array.isArray(e.methods))throw Error(`retry.methods must be an array`);if(e.statusCodes&&!Array.isArray(e.statusCodes))throw Error(`retry.statusCodes must be an array`);let t=Object.fromEntries(Object.entries({...e,methods:e.methods?.map(e=>e.toLowerCase())}).filter(([,e])=>e!==void 0));return{...pt,...t}};async function ht(e,t,n,r){return new Promise((i,a)=>{let o=setTimeout(()=>{n&&n.abort(),a(new K(e))},r.timeout);r.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function gt(e,{signal:t}){return new Promise((n,r)=>{t&&(t.throwIfAborted(),t.addEventListener(`abort`,i,{once:!0}));function i(){clearTimeout(a),r(t.reason)}let a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e)})}var _t=e=>{let t={};for(let n in e)Object.hasOwn(e,n)&&!(n in Xe)&&!(n in Ye)&&(t[n]=e[n]);return t},vt=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0||!!e[X]?.size:typeof e==`object`?Object.keys(e).length>0:typeof e==`string`?e.trim().length>0:!!e,yt=Object.prototype.toString,bt=e=>yt.call(e)===`[object Error]`,xt=new Set([`network error`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`,`fetch failed`,`terminated`,` A network error occurred.`,`Network connection lost`]);function St(e){if(!(e&&bt(e)&&e.name===`TypeError`&&typeof e.message==`string`))return!1;let{message:t,stack:n}=e;return t===`Load failed`?n===void 0||`__sentry_captured__`in e:t.startsWith(`error sending request for url`)||t===`Failed to fetch`||t.startsWith(`Failed to fetch (`)&&t.endsWith(`)`)?!0:xt.has(t)}var Ct=(e,t)=>e instanceof t||e?.name===t.name;function wt(e){return Ct(e,Pe)}function Tt(e){return Ct(e,Fe)}function Et(e){return Ct(e,K)}var Dt=10*1024*1024,Ot="The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl",Z=Symbol(`timedOutResponseData`),kt=e=>{let t=/;\s*charset\s*=\s*(?:"([^"]+)"|([^;,\s]+))/i.exec(e),n=t?.[1]??t?.[2];if(n)try{return new TextDecoder(n)}catch{}return new TextDecoder},At="The `schema` argument must follow the Standard Schema specification",jt=e=>typeof e==`object`?{...e,...e.methods&&{methods:[...e.methods]},...e.statusCodes&&{statusCodes:[...e.statusCodes]},...e.afterStatusCodes&&{afterStatusCodes:[...e.afterStatusCodes]}}:e,Mt=Object.prototype.toString,Nt=e=>e instanceof globalThis.Request||Mt.call(e)===`[object Request]`,Q=e=>e instanceof globalThis.Response||Mt.call(e)===`[object Response]`,Pt=e=>Array.isArray(e)?e.map(e=>[...e]):J(e);function Ft(e){let t={...e,json:J(e.json),context:J(e.context),headers:J(e.headers),searchParams:Pt(e.searchParams)};return e.retry!==void 0&&(t.retry=jt(e.retry)),t}var It=async(e,t)=>{if(typeof t!=`object`&&typeof t!=`function`||t===null)throw TypeError(At);let n=t[`~standard`];if(typeof n!=`object`||!n||typeof n.validate!=`function`)throw TypeError(At);let r=await n.validate(e);if(r.issues)throw new Le(r.issues);return r.value},Lt=class e{static create(t,n){let r=n.hooks?.init??[],i=r.length>0?Ft(n):n;for(let e of r)e(i);let a=new e(t,i),o=async()=>{if(typeof a.#i.timeout==`number`&&a.#i.timeout>2147483647)throw RangeError(`The \`timeout\` option cannot be greater than ${Ge}`);if(typeof a.#i.totalTimeout==`number`&&a.#i.totalTimeout>2147483647)throw RangeError(`The \`totalTimeout\` option cannot be greater than ${Ge}`);await Promise.resolve();let e=await a.#w(),t=e??await a.#E(async()=>a.#k()),n=e!==void 0||a.#O();for(;;){if(t===void 0)return t;if(Q(t))try{t=await a.#T(t)}catch(e){if(!(e instanceof G))throw e;let r=await a.#D(e,async()=>a.#k());if(r===void 0)return r;t=r,n=a.#O();continue}let e=t;if(!e.ok&&e.type!==`opaque`&&(typeof a.#i.throwHttpErrors==`function`?a.#i.throwHttpErrors(e.status):a.#i.throwHttpErrors)){let r=new Pe(e,a.#P(e),a.#M()),i=r;if(r.data=await a.#h(e),n)throw i;let o=await a.#D(r,async()=>a.#k());if(o===void 0)return o;t=o,n=a.#O();continue}break}if(!Q(t))return t;if(a.#m(t),a.#i.onDownloadProgress){if(typeof a.#i.onDownloadProgress!=`function`)throw TypeError("The `onDownloadProgress` option must be a function");if(!Ve)throw Error("Streams are not supported in your environment. `ReadableStream` is missing.");let e=t.clone();return a.#x(t),et(e,a.#i.onDownloadProgress)}return t},s=(async()=>{try{return await o()}catch(e){if(!(e instanceof Error)||a.#s.has(e))throw e;let t=e;for(let e of a.#i.hooks.beforeError){let n=await e({request:a.request,options:a.#M(),error:t,retryCount:a.#n});n instanceof Error&&(t=n)}throw t}finally{let e=a.#a;a.#b(e?.body??void 0),a.request!==e&&a.#b(a.request.body??void 0)}})();for(let[e,t]of Object.entries(We))e===`bytes`&&typeof globalThis.Response?.prototype?.bytes!=`function`||(s[e]=async n=>{a.request.headers.set(`accept`,a.request.headers.get(`accept`)||t);let r=await s;if(e!==`json`)return r[e]();let o=await r.text();if(o===``)return n===void 0?JSON.parse(o):It(void 0,n);let c=i.parseJson?await i.parseJson(o,{request:a.#P(r),response:r}):JSON.parse(o);return n===void 0?c:It(c,n)});return s}static#e(e){return e&&typeof e==`object`&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)):e}request;#t;#n=0;#r;#i;#a;#o;#s=new WeakSet;#c;#l;#u=!1;#d=new WeakMap;constructor(t,n={}){if(this.#r=t,Object.hasOwn(n,`prefixUrl`))throw Error(Ot);if(this.#i={...n,headers:at(this.#r.headers,n.headers),hooks:lt({},n.hooks),method:ft(n.method??this.#r.method??`GET`),prefix:String(n.prefix||``),retry:mt(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,totalTimeout:n.totalTimeout??!1,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#r!=`string`&&!(this.#r instanceof URL||this.#r instanceof globalThis.Request))throw TypeError("`input` must be a string, URL, or Request");if(typeof this.#r==`string`&&(this.#i.prefix&&(this.#r=`${this.#i.prefix.replace(/\/+$/,``)}/${this.#r.replace(/^\/+/,``)}`),this.#i.baseUrl)){let e;try{e=new URL(this.#r)}catch{}e||(this.#r=new URL(this.#r,new Request(this.#i.baseUrl).url))}ze&&Be&&(this.#o=this.#i.signal??this.#r.signal,this.#t=new globalThis.AbortController,this.#i.signal=this.#S()),Re&&(this.#i.duplex=`half`),this.#i.json!==void 0&&(this.#i.body=this.#i.stringifyJson?.(this.#i.json)??JSON.stringify(this.#i.json),this.#i.headers.set(`content-type`,this.#i.headers.get(`content-type`)??`application/json`));let r=n.headers&&new globalThis.Headers(n.headers).has(`content-type`);if(this.#r instanceof globalThis.Request&&(He&&this.#i.body instanceof globalThis.FormData||this.#i.body instanceof URLSearchParams)&&!r&&this.#i.headers.delete(`content-type`),this.request=new globalThis.Request(this.#r,this.#i),vt(this.#i.searchParams)){let t=new URL(this.request.url),n=this.#i.searchParams?.[X];if(n)for(let e of n)t.searchParams.delete(e);if(typeof this.#i.searchParams==`string`){let e=this.#i.searchParams.replace(/^\?/,``);e!==``&&(t.search=t.search?`${t.search}&${e}`:`?${e}`)}else{let n=new URLSearchParams(e.#e(this.#i.searchParams));for(let[e,r]of n.entries())t.searchParams.append(e,r)}if(this.#i.searchParams&&typeof this.#i.searchParams==`object`&&!Array.isArray(this.#i.searchParams)&&!(this.#i.searchParams instanceof URLSearchParams))for(let[e,n]of Object.entries(this.#i.searchParams))n===void 0&&t.searchParams.delete(e);this.request=new globalThis.Request(t,this.#i)}if(this.#i.onUploadProgress&&typeof this.#i.onUploadProgress!=`function`)throw TypeError("The `onUploadProgress` option must be a function");this.#l=typeof this.#i.totalTimeout==`number`?this.#j():void 0}#f(){let e=this.#i.retry.delay(this.#n+1),t=e;return this.#i.retry.jitter===!0?t=Math.random()*e:typeof this.#i.retry.jitter==`function`&&(t=this.#i.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e)),Math.min(this.#i.retry.backoffLimit,t)}async#p(e){if(this.#n>=this.#i.retry.limit)throw e;let t=e instanceof Error?e:new Ie(e);if(t instanceof G)return t.customDelay??this.#f();if(!this.#i.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#i.retry.shouldRetry!==void 0){let n=await this.#i.retry.shouldRetry({error:t,retryCount:this.#n+1});if(n===!1)throw e;if(n===!0)return this.#f()}if(Et(e)){if(!this.#i.retry.retryOnTimeout)throw e;return this.#f()}if(wt(e)){if(!this.#i.retry.statusCodes.includes(e.response.status))throw e;let t=e.response.headers.get(`Retry-After`)??e.response.headers.get(`RateLimit-Reset`)??e.response.headers.get(`X-RateLimit-Retry-After`)??e.response.headers.get(`X-RateLimit-Reset`)??e.response.headers.get(`X-Rate-Limit-Reset`);if(t&&this.#i.retry.afterStatusCodes.includes(e.response.status)){let e=Number(t)*1e3;return Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse(`2024-01-01`)&&(e-=Date.now()),Number.isFinite(e)?(e=Math.max(0,e),Math.min(this.#i.retry.maxRetryAfter,e)):Math.min(this.#i.retry.maxRetryAfter,this.#f())}if(e.response.status===413)throw e;return this.#f()}if(!Tt(e))throw e;return this.#f()}#m(e){let t=this.#P(e);return this.#i.parseJson&&(e.json=async()=>{let n=await e.text();return n===``?JSON.parse(n):this.#i.parseJson(n,{request:t,response:e})}),e}async#h(e){let t=await this.#v(e,this.#g());if(t===Z){this.#C();return}if(!t)return;if(!this.#_(e.headers.get(`content-type`)??``))return t;let n=await this.#y(t,e,this.#g(),this.#P(e));if(n===Z){this.#C();return}return n}#g(){let e=this.#i.timeout===!1?1e4:this.#i.timeout,t=this.#A();if(t===void 0)return e;if(t<=0)throw new K(this.request);return Math.min(e,t)}#_(e){let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return/\/(?:.*[.+-])?json$/.test(t)}async#v(e,t){let{body:n}=e;if(!n)try{return await e.text()}catch{return}let r;try{r=n.getReader()}catch{return}let i=kt(e.headers.get(`content-type`)??``),a=[],o=0,s=(async()=>{try{for(;;){let{done:e,value:t}=await r.read();if(e)break;if(o+=t.byteLength,o>Dt){r.cancel().catch(()=>void 0);return}a.push(i.decode(t,{stream:!0}))}}catch{return}return a.push(i.decode()),a.join(``)})(),c=new Promise(e=>{let n=setTimeout(()=>{e(Z)},t);s.finally(()=>{clearTimeout(n)})}),l=await Promise.race([s,c]);return l===Z&&r.cancel().catch(()=>void 0),l}async#y(e,t,n,r){let i;try{return await Promise.race([Promise.resolve().then(()=>this.#i.parseJson?this.#i.parseJson(e,{request:r,response:t}):JSON.parse(e)),new Promise(e=>{i=setTimeout(()=>{e(Z)},n)})])}catch{return}finally{clearTimeout(i)}}#b(e){e&&e.cancel().catch(()=>void 0)}#x(e){this.#b(e.body??void 0)}#S(){return this.#o?AbortSignal.any([this.#o,this.#t.signal]):this.#t.signal}#C(){let e=this.#A();if(e!==void 0&&e<=0)throw new K(this.request)}async#w(){for(let e of this.#i.hooks.beforeRequest){let t=await e({request:this.request,options:this.#M(),retryCount:0});if(Nt(t))this.#N(t);else if(Q(t))return t}}async#T(e){let t=this.#P(e);for(let n of this.#i.hooks.afterResponse){let r=this.#F(e.clone(),t);this.#m(r);let i;try{i=await n({request:this.request,options:this.#M(),response:r,retryCount:this.#n})}catch(t){throw r!==e&&this.#x(r),this.#x(e),t}if(i instanceof qe)throw r!==e&&this.#x(r),this.#x(e),new G(i.options);let a=Q(i)?this.#F(i,t):e;r!==e&&r!==a&&r.body!==a.body&&this.#x(r),e!==a&&e.body!==a.body&&this.#x(e),e=a}return e}async#E(e){try{return await e()}catch(t){return this.#D(t,e)}}async#D(e,t){this.#u=!1;let n=Math.min(await this.#p(e),Ge),r={signal:this.#o},i=this.#A();if(i!==void 0){if(i<=0)throw new K(this.request);if(n>=i)throw await gt(i,r),new K(this.request)}if(await gt(n,r),this.#C(),e instanceof G&&e.customRequest){let t=new globalThis.Request(e.customRequest,this.#i.signal?{signal:this.#i.signal}:void 0);this.#N(t)}for(let t of this.#i.hooks.beforeRetry){let n;try{n=await t({request:this.request,options:this.#M(),error:e,retryCount:this.#n+1})}catch(t){throw t instanceof Error&&t!==e&&this.#s.add(t),t}if(Nt(n)){this.#N(n);break}if(Q(n))return this.#u=!0,this.#n++,n;if(n===Ke)return}return this.#C(),this.#n++,this.#E(t)}#O(){let e=this.#u;return this.#u=!1,e}async#k(){this.#t?.signal.aborted&&(this.#t=new globalThis.AbortController,this.#i.signal=this.#S(),this.request=new globalThis.Request(this.request,{signal:this.#i.signal}));let e=_t(this.#i),t=this.#i.retry.limit>0?this.request.clone():void 0,n=this.#I(this.request,this.#i.body??void 0);this.#a=n,t&&(this.request=t);try{let t=this.#A();if(t!==void 0&&t<=0)throw new K(this.request);let r=this.#i.timeout===!1?t:t===void 0?this.#i.timeout:Math.min(this.#i.timeout,t),i=r===void 0?await this.#i.fetch(n,e):await ht(n,e,this.#t,{timeout:r,fetch:this.#i.fetch});return this.#F(i,n)}catch(e){throw St(e)?new Fe(this.request,{cause:e}):e}}#A(){if(this.#l===void 0)return;let e=this.#j()-this.#l;return Math.max(0,this.#i.totalTimeout-e)}#j(){return globalThis.performance?.now()??Date.now()}#M(){if(!this.#c){let{hooks:e,json:t,parseJson:n,stringifyJson:r,searchParams:i,timeout:a,totalTimeout:o,throwHttpErrors:s,fetch:c,...l}=this.#i;this.#c=Object.freeze(l)}return this.#c}#N(e){this.#c=void 0,this.request=e}#P(e){return this.#d.get(e)??this.request}#F(e,t){return this.#d.set(e,t),e}#I(e,t){return!this.#i.onUploadProgress||!e.body||!Re?e:tt(e,this.#i.onUploadProgress,t??this.#i.body??void 0)}},Rt=e=>{let t=(t,n)=>Lt.create(t,it(e,n));for(let n of Ue)t[n]=(t,r)=>Lt.create(t,it(e,r,{method:n}));return t.create=e=>Rt(it(e)),t.extend=t=>(typeof t==`function`&&(t=t(e??{})),Rt(it(e,t))),t.stop=Ke,t.retry=Je,t},$=Rt().create({retry:0});async function zt(e,t){if(e instanceof Pe)try{return(await e.response.json()).error||t}catch{return t}return e instanceof Error?e.message:t}async function Bt(){return $.get(`api/schema`).json()}async function Vt(e){return $.get(`api/schema/${encodeURIComponent(e)}`).json()}async function Ht(e,t){try{await $.post(`api/schema/${encodeURIComponent(e)}`,{json:t})}catch(t){throw Error(await zt(t,`Failed to save schema: ${e}`))}}async function Ut(e){try{await $.delete(`api/schema/${encodeURIComponent(e)}`)}catch(t){throw Error(await zt(t,`Failed to delete schema: ${e}`))}}async function Wt(){let e=await $.post(`api/migrate`).json();if(!e.success)throw Error(e.error||`Migration failed`);return e}async function Gt(e){return $.get(`api/prompt-snapshot/${encodeURIComponent(e)}`).json()}async function Kt(){return $.get(`api/ai/config`).json()}async function qt(e){try{await $.put(`api/ai/config`,{json:e})}catch(e){throw Error(await zt(e,`Failed to save AI config`))}}async function Jt(e){let t=await $.post(`api/ai/registry-lookup`,{json:{modelName:e}}).json().catch(()=>null);return!t||typeof t.vision!=`boolean`?null:t}async function Yt(e){try{let t=await $.post(`api/ai/notion/inspect`,{json:e}).json();if(!t.success)throw Error(t.error||`Notion connection failed`);return t}catch(e){throw Error(await zt(e,`Notion connection failed`))}}async function Xt(){return $.get(`api/data`).json()}async function Zt(){return $.get(`api/data/tables`).json()}async function Qt(e,t={}){let n=new URLSearchParams;return t.page!==void 0&&n.set(`page`,String(t.page)),t.pageSize!==void 0&&n.set(`pageSize`,String(t.pageSize)),t.search&&n.set(`search`,t.search),t.sortField&&n.set(`sortField`,t.sortField),t.sortOrder&&n.set(`sortOrder`,t.sortOrder),$.get(`api/data/tables/${encodeURIComponent(e)}`,{searchParams:n}).json()}async function $t(e){return $.get(`api/data/${encodeURIComponent(e)}`).json()}export{Vt as a,Zt as c,Wt as d,Jt as f,j as g,Ne as h,Gt as i,Xt as l,Ht as m,Kt as n,Qt as o,qt as p,$t as r,Yt as s,Ut as t,Bt as u};
1
+ import{A as e,B as t,F as n,Ft as r,H as i,It as a,K as o,L as s,Lt as c,M as l,N as ee,Pt as u,S as d,U as f,X as p,_ as m,d as h,et as g,g as _,h as v,ht as y,lt as b,m as x,nt as S,tt as C,v as w,w as T,x as E}from"./button-Cdgr9Igy.js";var D=1,O=new class{subscribers;toasts;dismissedToasts;constructor(){this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)});publish=e=>{this.subscribers.forEach(t=>t(e))};addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]};create=e=>{let{message:t,...n}=e,r=typeof e.id==`number`||e.id&&e.id?.length>0?e.id:D++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r};dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e);message=(e,t)=>this.create({...t,message:e,type:`default`});error=(e,t)=>this.create({...t,type:`error`,message:e});success=(e,t)=>this.create({...t,type:`success`,message:e});info=(e,t)=>this.create({...t,type:`info`,message:e});warning=(e,t)=>this.create({...t,type:`warning`,message:e});loading=(e,t)=>this.create({...t,type:`loading`,message:e});promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:`loading`,message:n.loading,description:typeof n.description==`function`?void 0:n.description}));let i=Promise.resolve(t instanceof Function?t():t),a=r!==void 0,o,s=i.then(async t=>{if(o=[`resolve`,t],e(t))a=!1,this.create({id:r,type:`default`,message:t});else if(A(t)&&!t.ok){a=!1;let i=typeof n.error==`function`?await n.error(`HTTP error! status: ${t.status}`):n.error,o=typeof n.description==`function`?await n.description(`HTTP error! status: ${t.status}`):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`error`,description:o,...s})}else if(t instanceof Error){a=!1;let i=typeof n.error==`function`?await n.error(t):n.error,o=typeof n.description==`function`?await n.description(t):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`error`,description:o,...s})}else if(n.success!==void 0){a=!1;let i=typeof n.success==`function`?await n.success(t):n.success,o=typeof n.description==`function`?await n.description(t):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`success`,description:o,...s})}}).catch(async t=>{if(o=[`reject`,t],n.error!==void 0){a=!1;let i=typeof n.error==`function`?await n.error(t):n.error,o=typeof n.description==`function`?await n.description(t):n.description,s=typeof i==`object`&&!e(i)?i:{message:i||``,id:r||``};this.create({id:r,type:`error`,description:o,...s})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally?.()}),c=()=>new Promise((e,t)=>s.then(()=>o[0]===`reject`?t(o[1]):e(o[1])).catch(t));return typeof r!=`string`&&typeof r!=`number`?{unwrap:c}:Object.assign(r,{unwrap:c})};custom=(e,t)=>{let n=t?.id||D++,r=this.toasts.find(e=>e.id===n),i=t?.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),r?this.toasts=this.toasts.map(r=>r.id===n?(this.publish({...r,component:e,dismissible:i,id:n,...t}),{...r,component:e,dismissible:i,id:n,...t}):r):this.addToast({component:e,dismissible:i,id:n,...t}),n};getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id))};function k(e,t){let n=t?.id||D++;return O.create({message:e,id:n,type:`default`,...t}),n}var A=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,j=Object.assign(k,{success:O.success,info:O.info,warning:O.warning,error:O.error,custom:O.custom,message:O.message,promise:O.promise,dismiss:O.dismiss,loading:O.loading},{getHistory:()=>O.toasts,getToasts:()=>O.getActiveToasts()});function M(e){return e.label!==void 0}var N=3,P=`24px`,F=`16px`,te=4e3,ne=356,I=14,re=45,ie=200;function ae(){let e=b(!1);return C(()=>{let t=()=>{e.value=document.hidden};return document.addEventListener(`visibilitychange`,t),()=>window.removeEventListener(`visibilitychange`,t)}),{isDocumentHidden:e}}function L(...e){return e.filter(Boolean).join(` `)}function oe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}function se(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?F:P;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var ce=[`data-rich-colors`,`data-styled`,`data-mounted`,`data-promise`,`data-swiped`,`data-removed`,`data-visible`,`data-y-position`,`data-x-position`,`data-index`,`data-front`,`data-swiping`,`data-dismissible`,`data-type`,`data-invert`,`data-swipe-out`,`data-swipe-direction`,`data-expanded`,`data-testid`],le=[`aria-label`,`data-disabled`,`data-close-button-position`],ue=T({__name:`Toast`,props:{toast:{},toasts:{},index:{},swipeDirections:{},expanded:{type:Boolean},invert:{type:Boolean},heights:{},gap:{},position:{},closeButtonPosition:{},visibleToasts:{},expandByDefault:{type:Boolean},closeButton:{type:Boolean},interacting:{type:Boolean},style:{},cancelButtonStyle:{},actionButtonStyle:{},duration:{},class:{},unstyled:{type:Boolean},descriptionClass:{},loadingIcon:{},classes:{},icons:{},closeButtonAriaLabel:{},defaultRichColors:{type:Boolean}},emits:[`update:heights`,`update:height`,`removeToast`],setup(e,{emit:i}){let d=e,p=i,S=b(null),T=b(null),D=b(!1),O=b(!1),k=b(!1),A=b(!1),j=b(!1),N=b(0),P=b(0),F=b(d.toast.duration||d.duration||te),ne=b(null),I=b(null),se=x(()=>d.index===0),ue=x(()=>d.index+1<=d.visibleToasts),R=x(()=>d.toast.type),z=x(()=>d.toast.dismissible!==!1),de=x(()=>d.toast.class||``),fe=x(()=>d.descriptionClass||``),pe=x(()=>{let e=d.toast.position||d.position,t=d.heights.filter(t=>t.position===e).findIndex(e=>e.toastId===d.toast.id);return t>=0?t:0}),me=x(()=>{let e=d.toast.position||d.position;return d.heights.filter(t=>t.position===e).reduce((e,t,n)=>n>=pe.value?e:e+t.height,0)}),B=x(()=>pe.value*d.gap+me.value||0),he=x(()=>d.toast.closeButton??d.closeButton),ge=x(()=>d.toast.duration||d.duration||te),_e=b(0),ve=b(0),V=b(null),ye=x(()=>d.position.split(`-`)),be=x(()=>ye.value[0]),xe=x(()=>ye.value[1]),Se=x(()=>typeof d.toast.title!=`string`),Ce=x(()=>typeof d.toast.description!=`string`),{isDocumentHidden:we}=ae(),H=x(()=>R.value&&R.value===`loading`);s(()=>{D.value=!0,F.value=ge.value}),C(async()=>{if(!D.value||!I.value)return;await ee();let e=I.value,t=e.style.height;e.style.height=`auto`;let n=e.getBoundingClientRect().height;e.style.height=t,P.value=n,p(`update:height`,{toastId:d.toast.id,height:n,position:d.toast.position||d.position})});function U(){O.value=!0,N.value=B.value,setTimeout(()=>{p(`removeToast`,d.toast)},ie)}function Te(){if(H.value||!z.value)return{};U(),d.toast.onDismiss?.(d.toast)}function Ee(e){e.button!==2&&(H.value||!z.value||(ne.value=new Date,N.value=B.value,e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(k.value=!0,V.value={x:e.clientX,y:e.clientY})))}function De(){if(A.value||!z.value)return;V.value=null;let e=Number(I.value?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(I.value?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),n=new Date().getTime()-(ne.value?.getTime()||0),r=S.value===`x`?e:t,i=Math.abs(r)/n;if(Math.abs(r)>=re||i>.11){N.value=B.value,d.toast.onDismiss?.(d.toast),S.value===`x`?T.value=e>0?`right`:`left`:T.value=t>0?`down`:`up`,U(),A.value=!0;return}else I.value?.style.setProperty(`--swipe-amount-x`,`0px`),I.value?.style.setProperty(`--swipe-amount-y`,`0px`);j.value=!1,k.value=!1,S.value=null}function Oe(e){if(!V.value||!z.value||(window?.getSelection()?.toString()?.length??!1))return;let t=e.clientY-V.value.y,n=e.clientX-V.value.x,r=d.swipeDirections??oe(d.position);!S.value&&(Math.abs(n)>1||Math.abs(t)>1)&&(S.value=Math.abs(n)>Math.abs(t)?`x`:`y`);let i={x:0,y:0},a=e=>1/(1.5+Math.abs(e)/20);if(S.value===`y`){if(r.includes(`top`)||r.includes(`bottom`))if(r.includes(`top`)&&t<0||r.includes(`bottom`)&&t>0)i.y=t;else{let e=t*a(t);i.y=Math.abs(e)<Math.abs(t)?e:t}}else if(S.value===`x`&&(r.includes(`left`)||r.includes(`right`)))if(r.includes(`left`)&&n<0||r.includes(`right`)&&n>0)i.x=n;else{let e=n*a(n);i.x=Math.abs(e)<Math.abs(n)?e:n}(Math.abs(i.x)>0||Math.abs(i.y)>0)&&(j.value=!0),I.value?.style.setProperty(`--swipe-amount-x`,`${i.x}px`),I.value?.style.setProperty(`--swipe-amount-y`,`${i.y}px`)}s(()=>{if(D.value=!0,!I.value)return;let e=I.value.getBoundingClientRect().height;P.value=e,p(`update:heights`,[{toastId:d.toast.id,height:e,position:d.toast.position},...d.heights])}),n(()=>{I.value&&p(`removeToast`,d.toast)}),C(e=>{if(d.toast.promise&&R.value===`loading`||d.toast.duration===1/0||d.toast.type===`loading`)return;let t;d.expanded||d.interacting||we.value?(()=>{if(ve.value<_e.value){let e=new Date().getTime()-_e.value;F.value-=e}ve.value=new Date().getTime()})():F.value!==1/0&&(_e.value=new Date().getTime(),t=setTimeout(()=>{d.toast.onAutoClose?.(d.toast),U()},F.value)),e(()=>{clearTimeout(t)})}),g(()=>d.toast.delete,e=>{e!==void 0&&e&&(U(),d.toast.onDismiss?.(d.toast))},{deep:!0});function ke(){k.value=!1,S.value=null,V.value=null}return(e,n)=>(t(),w(`li`,{tabindex:`0`,ref_key:`toastRef`,ref:I,class:u(y(L)(d.class,de.value,e.classes?.toast,e.toast.classes?.toast,e.classes?.[R.value],e.toast?.classes?.[R.value])),"data-sonner-toast":``,"data-rich-colors":e.toast.richColors??e.defaultRichColors,"data-styled":!(e.toast.component||e.toast?.unstyled||e.unstyled),"data-mounted":D.value,"data-promise":!!e.toast.promise,"data-swiped":j.value,"data-removed":O.value,"data-visible":ue.value,"data-y-position":be.value,"data-x-position":xe.value,"data-index":e.index,"data-front":se.value,"data-swiping":k.value,"data-dismissible":z.value,"data-type":R.value,"data-invert":e.toast.invert||e.invert,"data-swipe-out":A.value,"data-swipe-direction":T.value,"data-expanded":!!(e.expanded||e.expandByDefault&&D.value),"data-testid":e.toast.testId,style:a({"--index":e.index,"--toasts-before":e.index,"--z-index":e.toasts.length-e.index,"--offset":`${O.value?N.value:B.value}px`,"--initial-height":e.expandByDefault?`auto`:`${P.value}px`,...e.style,...d.toast.style}),onDragend:ke,onPointerdown:Ee,onPointerup:De,onPointermove:Oe},[he.value&&!e.toast.component&&R.value!==`loading`?(t(),w(`button`,{key:0,"aria-label":e.closeButtonAriaLabel||`Close toast`,"data-disabled":H.value,"data-close-button":`true`,"data-close-button-position":e.closeButtonPosition,class:u(y(L)(e.classes?.closeButton,e.toast?.classes?.closeButton)),onClick:Te},[e.icons?.close?(t(),_(o(e.icons?.close),{key:0})):f(e.$slots,`close-icon`,{key:1})],10,le)):m(`v-if`,!0),e.toast.component?(t(),_(o(e.toast.component),l({key:1},e.toast.componentProps,{onCloseToast:Te,isPaused:e.$props.expanded||e.$props.interacting||y(we)}),null,16,[`isPaused`])):(t(),w(h,{key:2},[R.value!==`default`||e.toast.icon||e.toast.promise?(t(),w(`div`,{key:0,"data-icon":``,class:u(y(L)(e.classes?.icon,e.toast?.classes?.icon))},[e.toast.icon?(t(),_(o(e.toast.icon),{key:0})):(t(),w(h,{key:1},[R.value===`loading`?f(e.$slots,`loading-icon`,{key:0}):R.value===`success`?f(e.$slots,`success-icon`,{key:1}):R.value===`error`?f(e.$slots,`error-icon`,{key:2}):R.value===`warning`?f(e.$slots,`warning-icon`,{key:3}):R.value===`info`?f(e.$slots,`info-icon`,{key:4}):m(`v-if`,!0)],64))],2)):m(`v-if`,!0),v(`div`,{"data-content":``,class:u(y(L)(e.classes?.content,e.toast?.classes?.content))},[v(`div`,{"data-title":``,class:u(y(L)(e.classes?.title,e.toast.classes?.title))},[Se.value?(t(),_(o(e.toast.title),r(l({key:0},e.toast.componentProps)),null,16)):(t(),w(h,{key:1},[E(c(e.toast.title),1)],64))],2),e.toast.description?(t(),w(`div`,{key:0,"data-description":``,class:u(y(L)(e.descriptionClass,fe.value,e.classes?.description,e.toast.classes?.description))},[Ce.value?(t(),_(o(e.toast.description),r(l({key:0},e.toast.componentProps)),null,16)):(t(),w(h,{key:1},[E(c(e.toast.description),1)],64))],2)):m(`v-if`,!0)],2),e.toast.cancel?(t(),w(`button`,{key:1,style:a(e.toast.cancelButtonStyle||e.cancelButtonStyle),class:u(y(L)(e.classes?.cancelButton,e.toast.classes?.cancelButton)),"data-button":``,"data-cancel":``,onClick:n[0]||=t=>{y(M)(e.toast.cancel)&&z.value&&(e.toast.cancel.onClick?.(t),U())}},c(y(M)(e.toast.cancel)?e.toast.cancel?.label:e.toast.cancel),7)):m(`v-if`,!0),e.toast.action?(t(),w(`button`,{key:2,style:a(e.toast.actionButtonStyle||e.actionButtonStyle),class:u(y(L)(e.classes?.actionButton,e.toast.classes?.actionButton)),"data-button":``,"data-action":``,onClick:n[1]||=t=>{y(M)(e.toast.action)&&(e.toast.action.onClick?.(t),!t.defaultPrevented&&U())}},c(y(M)(e.toast.action)?e.toast.action?.label:e.toast.action),7)):m(`v-if`,!0)],64))],46,ce))}}),R=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},z={},de={xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stoke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`};function fe(e,n){return t(),w(`svg`,de,n[0]||=[v(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`},null,-1),v(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`},null,-1)])}var pe=R(z,[[`render`,fe]]),me=[`data-visible`],B={class:`sonner-spinner`},he=T({__name:`Loader`,props:{visible:{type:Boolean}},setup(e){let n=Array(12).fill(0);return(e,r)=>(t(),w(`div`,{class:`sonner-loading-wrapper`,"data-visible":e.visible},[v(`div`,B,[(t(!0),w(h,null,i(y(n),e=>(t(),w(`div`,{key:`spinner-bar-${e}`,class:`sonner-loading-bar`}))),128))])],8,me))}}),ge={},_e={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`};function ve(e,n){return t(),w(`svg`,_e,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,"clip-rule":`evenodd`},null,-1)])}var V=R(ge,[[`render`,ve]]),ye={},be={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`};function xe(e,n){return t(),w(`svg`,be,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,"clip-rule":`evenodd`},null,-1)])}var Se=R(ye,[[`render`,xe]]),Ce={},we={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`};function H(e,n){return t(),w(`svg`,we,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,"clip-rule":`evenodd`},null,-1)])}var U=R(Ce,[[`render`,H]]),Te={},Ee={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`};function De(e,n){return t(),w(`svg`,Ee,n[0]||=[v(`path`,{"fill-rule":`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,"clip-rule":`evenodd`},null,-1)])}var Oe=R(Te,[[`render`,De]]),ke=[`aria-label`],Ae=[`data-sonner-theme`,`dir`,`data-theme`,`data-rich-colors`,`data-y-position`,`data-x-position`],je=typeof window<`u`&&typeof document<`u`;function Me(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}var Ne=T({name:`Toaster`,inheritAttrs:!1,__name:`Toaster`,props:{id:{},invert:{type:Boolean,default:!1},theme:{default:`light`},position:{default:`bottom-right`},closeButtonPosition:{default:`top-left`},hotkey:{default:()=>[`altKey`,`KeyT`]},richColors:{type:Boolean,default:!1},expand:{type:Boolean,default:!1},duration:{},gap:{default:I},visibleToasts:{default:N},closeButton:{type:Boolean,default:!1},toastOptions:{default:()=>({})},class:{default:``},style:{},offset:{default:P},mobileOffset:{default:F},dir:{default:`auto`},swipeDirections:{},icons:{},containerAriaLabel:{default:`Notifications`}},setup(e){let n=e,r=p(),o=b([]),s=x(()=>n.id?o.value.filter(e=>e.toasterId===n.id):o.value.filter(e=>!e.toasterId));function c(e,t){return s.value.filter(n=>!n.position&&t===0||n.position===e)}let g=x(()=>{let e=s.value.filter(e=>e.position).map(e=>e.position);return e.length>0?Array.from(new Set([n.position].concat(e))):[n.position]}),T=x(()=>{let e={};return g.value.forEach(t=>{e[t]=o.value.filter(e=>e.position===t)}),e}),E=b([]),D=b({}),k=b(!1);C(()=>{g.value.forEach(e=>{e in D.value||(D.value[e]=!1)})});let A=b(n.theme===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:n.theme),j=b(null),M=b(null),N=b(!1),P=n.hotkey.join(`+`).replace(/Key/g,``).replace(/Digit/g,``);function F(e){o.value.find(t=>t.id===e.id)?.delete||O.dismiss(e.id),o.value=o.value.filter(({id:t})=>t!==e.id),setTimeout(()=>{o.value.find(t=>t.id===e.id)||(E.value=E.value.filter(t=>t.toastId!==e.id))},ie+50)}function te(e){N.value&&!e.currentTarget?.contains?.(e.relatedTarget)&&(N.value=!1,M.value&&=(M.value.focus({preventScroll:!0}),null))}function I(e){e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||N.value||(N.value=!0,M.value=e.relatedTarget)}function re(e){e.target&&e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||(k.value=!0)}C(e=>{e(O.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{o.value=o.value.map(t=>t.id===e.id?{...t,delete:!0}:t)});return}ee(()=>{let t=o.value.findIndex(t=>t.id===e.id);t===-1?o.value=[e,...o.value]:o.value=[...o.value.slice(0,t),{...o.value[t],...e},...o.value.slice(t+1)]})}))}),C(e=>{if(typeof window>`u`)return;if(n.theme!==`system`){A.value=n.theme;return}let t=window.matchMedia(`(prefers-color-scheme: dark)`),r=e=>{A.value=e?`dark`:`light`};r(t.matches);let i=e=>{r(e.matches)};try{t.addEventListener(`change`,i)}catch{t.addListener(i)}e(()=>{try{t.removeEventListener(`change`,i)}catch{t.removeListener(i)}})}),C(()=>{j.value&&M.value&&(M.value.focus({preventScroll:!0}),M.value=null,N.value=!1)}),C(()=>{o.value.length<=1&&Object.keys(D.value).forEach(e=>{D.value[e]=!1})}),C(e=>{function t(e){let t=n.hotkey.every(t=>e[t]||e.code===t),r=Array.isArray(j.value)?j.value[0]:j.value;t&&(g.value.forEach(e=>{D.value[e]=!0}),r?.focus());let i=document.activeElement===j.value||r?.contains(document.activeElement);e.code===`Escape`&&i&&g.value.forEach(e=>{D.value[e]=!1})}je&&(document.addEventListener(`keydown`,t),e(()=>{document.removeEventListener(`keydown`,t)}))});function ae(e){let t=e.currentTarget,n=t.getAttribute(`data-y-position`)+`-`+t.getAttribute(`data-x-position`);D.value[n]=!0}function L(e){if(!k.value){let t=e.currentTarget,n=t.getAttribute(`data-y-position`)+`-`+t.getAttribute(`data-x-position`);D.value[n]=!1}}function oe(){Object.keys(D.value).forEach(e=>{D.value[e]=!1})}function ce(){k.value=!1}function le(e){E.value=e}function R(e){let t=E.value.findIndex(t=>t.toastId===e.toastId);if(t!==-1)E.value[t]=e;else{let t=E.value.findIndex(t=>t.position===e.position);t===-1?E.value.unshift(e):E.value.splice(t,0,e)}}return(e,o)=>(t(),w(h,null,[m(` Remove item from normal navigation flow, only available via hotkey `),v(`section`,{"aria-label":`${e.containerAriaLabel} ${y(P)}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`},[(t(!0),w(h,null,i(g.value,(o,s)=>(t(),w(`ol`,l({key:o,ref_for:!0,ref_key:`listRef`,ref:j,"data-sonner-toaster":``,"data-sonner-theme":A.value,class:n.class,dir:e.dir===`auto`?Me():e.dir,tabIndex:-1,"data-theme":e.theme,"data-rich-colors":e.richColors,"data-y-position":o.split(`-`)[0],"data-x-position":o.split(`-`)[1],style:{"--front-toast-height":`${E.value[0]?.height||0}px`,"--width":`${y(ne)}px`,"--gap":`${e.gap}px`,...e.style,...y(r).style,...y(se)(e.offset,e.mobileOffset)}},{ref_for:!0},e.$attrs,{onBlur:te,onFocus:I,onMouseenter:ae,onMousemove:ae,onMouseleave:L,onDragend:oe,onPointerdown:re,onPointerup:ce}),[(t(!0),w(h,null,i(c(o,s),(r,i)=>(t(),_(ue,{key:r.id,heights:E.value,icons:e.icons,index:i,toast:r,defaultRichColors:e.richColors,duration:e.toastOptions?.duration??e.duration,class:u(e.toastOptions?.class??``),descriptionClass:e.toastOptions?.descriptionClass,invert:e.invert,visibleToasts:e.visibleToasts,closeButton:e.toastOptions?.closeButton??e.closeButton,interacting:k.value,position:o,closeButtonPosition:e.toastOptions?.closeButtonPosition??e.closeButtonPosition,style:a(e.toastOptions?.style),unstyled:e.toastOptions?.unstyled,classes:e.toastOptions?.classes,cancelButtonStyle:e.toastOptions?.cancelButtonStyle,actionButtonStyle:e.toastOptions?.actionButtonStyle,"close-button-aria-label":e.toastOptions?.closeButtonAriaLabel,toasts:T.value[o],expandByDefault:e.expand,gap:e.gap,expanded:D.value[o]||!1,swipeDirections:n.swipeDirections,"onUpdate:heights":le,"onUpdate:height":R,onRemoveToast:F},{"close-icon":S(()=>[f(e.$slots,`close-icon`,{},()=>[d(pe)])]),"loading-icon":S(()=>[f(e.$slots,`loading-icon`,{},()=>[d(he,{visible:r.type===`loading`},null,8,[`visible`])])]),"success-icon":S(()=>[f(e.$slots,`success-icon`,{},()=>[d(V)])]),"error-icon":S(()=>[f(e.$slots,`error-icon`,{},()=>[d(Oe)])]),"warning-icon":S(()=>[f(e.$slots,`warning-icon`,{},()=>[d(U)])]),"info-icon":S(()=>[f(e.$slots,`info-icon`,{},()=>[d(Se)])]),_:2},1032,[`heights`,`icons`,`index`,`toast`,`defaultRichColors`,`duration`,`class`,`descriptionClass`,`invert`,`visibleToasts`,`closeButton`,`interacting`,`position`,`closeButtonPosition`,`style`,`unstyled`,`classes`,`cancelButtonStyle`,`actionButtonStyle`,`close-button-aria-label`,`toasts`,`expandByDefault`,`gap`,`expanded`,`swipeDirections`]))),128))],16,Ae))),128))],8,ke)],2112))}}),W=class extends Error{name=`KyError`;get isKyError(){return!0}},Pe=class extends W{name=`HTTPError`;response;request;options;data;constructor(e,t,n){let r=`${e.status||e.status===0?e.status:``} ${e.statusText??``}`.trim(),i=r?`status code ${r}`:`an unknown error`;super(`Request failed with ${i}: ${t.method} ${t.url}`),this.response=e,this.request=t,this.options=n}},Fe=class extends W{name=`NetworkError`;request;constructor(e,t){super(`Request failed due to a network error: ${e.method} ${e.url}`,t),this.request=e}},Ie=class extends Error{name=`NonError`;value;constructor(e){let t=`Non-error value was thrown`;try{typeof e==`string`?t=e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`&&(t=e.message)}catch{}super(t),this.value=e}},Le=class extends W{name=`ForceRetryError`;customDelay;code;customRequest;constructor(e){let t=e?.cause?e.cause instanceof Error?e.cause:new Ie(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:`Forced retry`,t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},Re=class extends Error{name=`SchemaValidationError`;issues;constructor(e){super(`Response schema validation failed`),this.issues=e}},G=class extends W{name=`TimeoutError`;request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.request=e}},ze=(()=>{let e=!1,t=!1,n=typeof globalThis.ReadableStream==`function`,r=typeof globalThis.Request==`function`;if(n&&r)try{t=new globalThis.Request(`https://empty.invalid`,{body:new globalThis.ReadableStream,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`)}catch(e){if(e instanceof Error&&e.message===`unsupported BodyInit type`)return!1;throw e}return e&&!t})(),Be=typeof globalThis.AbortController==`function`,Ve=typeof globalThis.AbortSignal==`function`&&typeof globalThis.AbortSignal.any==`function`,He=typeof globalThis.ReadableStream==`function`,Ue=typeof globalThis.FormData==`function`,We=[`get`,`post`,`put`,`patch`,`head`,`delete`],Ge={json:`application/json`,text:`text/*`,formData:`multipart/form-data`,arrayBuffer:`*/*`,blob:`*/*`,bytes:`*/*`},Ke=2147483647,qe=Symbol(`stop`),Je=class{options;constructor(e){this.options=e}},Ye=e=>new Je(e),Xe={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},Ze={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Qe=new TextEncoder,$e=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[n,r]of e)t+=40,t+=Qe.encode(`Content-Disposition: form-data; name="${n}"`).byteLength,t+=typeof r==`string`?Qe.encode(r).byteLength:r.size;return t}return e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof e==`string`?Qe.encode(e).byteLength:e instanceof URLSearchParams?Qe.encode(e.toString()).byteLength:0},et=(e,t,n)=>{let r,i=0;return e.pipeThrough(new TransformStream({transform(e,a){if(a.enqueue(e),r){i+=r.byteLength;let e=t===0?0:i/t;e>=1&&(e=1-2**-52),n?.({percent:e,totalBytes:Math.max(t,i),transferredBytes:i},r)}r=e},flush(){r&&(i+=r.byteLength,n?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},r))}}))},tt=(e,t)=>{if(!e.body)return e;let n={status:e.status,statusText:e.statusText,headers:e.headers};if(e.status===204)return new Response(null,n);let r=Math.max(0,Number(e.headers.get(`content-length`))||0);return new Response(et(e.body,r,t),n)},nt=(e,t,n)=>{if(!e.body)return e;let r=$e(n??e.body);return new Request(e,{duplex:`half`,body:et(e.body,r,t)})},K=e=>typeof e==`object`&&!!e,rt=Symbol(`replaceOption`),it=e=>K(e)&&e[rt]===!0?{isReplace:!0,value:e.value}:{isReplace:!1,value:e},at=(...e)=>{for(let t of e)if((!K(t)||Array.isArray(t))&&t!==void 0)throw TypeError("The `options` argument must be an object");return ft({},...e)},ot=(e={},t={})=>{let n=new globalThis.Headers(e),r=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[e,t]of i.entries())r&&t===`undefined`||t===void 0?n.delete(e):n.set(e,t);return n},st=e=>{if(!K(e)||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},q=e=>{if(e instanceof URLSearchParams){let t=new URLSearchParams(e),n=e[Y];return n&&(t[Y]=new Set(n)),t}return e instanceof globalThis.Headers?new globalThis.Headers(e):Array.isArray(e)?[...e]:st(e)?{...e}:e},ct=e=>Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0)),lt=(e,t)=>st(e)&&st(t)?ct({...e,...t}):ot(e,t);function J(e,t,n){return Object.hasOwn(t,n)&&t[n]===void 0?[]:ft(e[n]??[],t[n]??[])}var ut=(e={},t={})=>({init:J(e,t,`init`),beforeRequest:J(e,t,`beforeRequest`),beforeRetry:J(e,t,`beforeRetry`),beforeError:J(e,t,`beforeError`),afterResponse:J(e,t,`afterResponse`)}),Y=Symbol(`deletedParameters`),dt=(e,t)=>{let n=new URLSearchParams,r=new Set;for(let i of[e,t])if(i!==void 0)if(i instanceof URLSearchParams){for(let[e,t]of i.entries())n.append(e,t),r.delete(e);let e=i[Y];if(e)for(let t of e)n.delete(t),r.add(t)}else if(Array.isArray(i))for(let e of i){if(!Array.isArray(e)||e.length!==2)throw TypeError(`Array search parameters must be provided in [[key, value], ...] format`);n.append(String(e[0]),String(e[1])),r.delete(String(e[0]))}else if(K(i))for(let[e,t]of Object.entries(i))t===void 0?(n.delete(e),r.add(e)):(n.append(e,String(t)),r.delete(e));else{let e=new URLSearchParams(i);for(let[t,i]of e.entries())n.append(t,i),r.delete(t)}return r.size>0&&(n[Y]=r),n},ft=(...e)=>{let t={},n={},r={},i,a=[];for(let o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(K(o)){for(let[e,n]of Object.entries(o)){if(e===`signal`&&n instanceof globalThis.AbortSignal){a.push(n);continue}let r=it(n),{isReplace:o}=r;if(n=r.value,e===`context`){if(n!=null&&(!K(n)||Array.isArray(n)))throw TypeError("The `context` option must be an object");t={...t,context:n==null?{}:o?{...n}:{...t.context,...n}};continue}if(e===`searchParams`){i=n==null?void 0:o||i===void 0?n:dt(i,n);continue}K(n)&&!o&&e in t&&(n=ft(t[e],n)),t={...t,[e]:n}}if(K(o.hooks)){let{value:e,isReplace:n}=it(o.hooks);r=ut(n?{}:r,e),t.hooks=r}if(K(o.headers)){let{value:e,isReplace:r}=it(o.headers);n=r?q(e):lt(n,e),t.headers=n}}return i!==void 0&&(t.searchParams=i),a.length>0&&(a.length===1?t.signal=a[0]:Ve?t.signal=AbortSignal.any(a):t.signal=a.at(-1)),t},pt=e=>We.includes(e)?e.toUpperCase():e,mt={limit:2,methods:[`get`,`put`,`head`,`delete`,`options`,`trace`],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:1/0,backoffLimit:1/0,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},ht=(e={})=>{if(typeof e==`number`)return{...mt,limit:e};if(e.methods&&!Array.isArray(e.methods))throw Error(`retry.methods must be an array`);if(e.statusCodes&&!Array.isArray(e.statusCodes))throw Error(`retry.statusCodes must be an array`);let t=Object.fromEntries(Object.entries({...e,methods:e.methods?.map(e=>e.toLowerCase())}).filter(([,e])=>e!==void 0));return{...mt,...t}};async function gt(e,t,n,r){return new Promise((i,a)=>{let o=setTimeout(()=>{n&&n.abort(),a(new G(e))},r.timeout);r.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function _t(e,{signal:t}){return new Promise((n,r)=>{t&&(t.throwIfAborted(),t.addEventListener(`abort`,i,{once:!0}));function i(){clearTimeout(a),r(t.reason)}let a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e)})}var vt=e=>{let t={};for(let n in e)Object.hasOwn(e,n)&&!(n in Ze)&&!(n in Xe)&&(t[n]=e[n]);return t},yt=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0||!!e[Y]?.size:typeof e==`object`?Object.keys(e).length>0:typeof e==`string`?e.trim().length>0:!!e,bt=Object.prototype.toString,xt=e=>bt.call(e)===`[object Error]`,St=new Set([`network error`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`,`fetch failed`,`terminated`,` A network error occurred.`,`Network connection lost`]);function Ct(e){if(!(e&&xt(e)&&e.name===`TypeError`&&typeof e.message==`string`))return!1;let{message:t,stack:n}=e;return t===`Load failed`?n===void 0||`__sentry_captured__`in e:t.startsWith(`error sending request for url`)||t===`Failed to fetch`||t.startsWith(`Failed to fetch (`)&&t.endsWith(`)`)?!0:St.has(t)}var wt=(e,t)=>e instanceof t||e?.name===t.name;function Tt(e){return wt(e,Pe)}function Et(e){return wt(e,Fe)}function Dt(e){return wt(e,G)}var Ot=10*1024*1024,kt="The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl",X=Symbol(`timedOutResponseData`),At=e=>{let t=/;\s*charset\s*=\s*(?:"([^"]+)"|([^;,\s]+))/i.exec(e),n=t?.[1]??t?.[2];if(n)try{return new TextDecoder(n)}catch{}return new TextDecoder},jt="The `schema` argument must follow the Standard Schema specification",Mt=e=>typeof e==`object`?{...e,...e.methods&&{methods:[...e.methods]},...e.statusCodes&&{statusCodes:[...e.statusCodes]},...e.afterStatusCodes&&{afterStatusCodes:[...e.afterStatusCodes]}}:e,Nt=Object.prototype.toString,Pt=e=>e instanceof globalThis.Request||Nt.call(e)===`[object Request]`,Z=e=>e instanceof globalThis.Response||Nt.call(e)===`[object Response]`,Ft=e=>Array.isArray(e)?e.map(e=>[...e]):q(e);function It(e){let t={...e,json:q(e.json),context:q(e.context),headers:q(e.headers),searchParams:Ft(e.searchParams)};return e.retry!==void 0&&(t.retry=Mt(e.retry)),t}var Lt=async(e,t)=>{if(typeof t!=`object`&&typeof t!=`function`||t===null)throw TypeError(jt);let n=t[`~standard`];if(typeof n!=`object`||!n||typeof n.validate!=`function`)throw TypeError(jt);let r=await n.validate(e);if(r.issues)throw new Re(r.issues);return r.value},Rt=class e{static create(t,n){let r=n.hooks?.init??[],i=r.length>0?It(n):n;for(let e of r)e(i);let a=new e(t,i),o=async()=>{if(typeof a.#i.timeout==`number`&&a.#i.timeout>2147483647)throw RangeError(`The \`timeout\` option cannot be greater than ${Ke}`);if(typeof a.#i.totalTimeout==`number`&&a.#i.totalTimeout>2147483647)throw RangeError(`The \`totalTimeout\` option cannot be greater than ${Ke}`);await Promise.resolve();let e=await a.#w(),t=e??await a.#E(async()=>a.#k()),n=e!==void 0||a.#O();for(;;){if(t===void 0)return t;if(Z(t))try{t=await a.#T(t)}catch(e){if(!(e instanceof Le))throw e;let r=await a.#D(e,async()=>a.#k());if(r===void 0)return r;t=r,n=a.#O();continue}let e=t;if(!e.ok&&e.type!==`opaque`&&(typeof a.#i.throwHttpErrors==`function`?a.#i.throwHttpErrors(e.status):a.#i.throwHttpErrors)){let r=new Pe(e,a.#P(e),a.#M()),i=r;if(r.data=await a.#h(e),n)throw i;let o=await a.#D(r,async()=>a.#k());if(o===void 0)return o;t=o,n=a.#O();continue}break}if(!Z(t))return t;if(a.#m(t),a.#i.onDownloadProgress){if(typeof a.#i.onDownloadProgress!=`function`)throw TypeError("The `onDownloadProgress` option must be a function");if(!He)throw Error("Streams are not supported in your environment. `ReadableStream` is missing.");let e=t.clone();return a.#x(t),tt(e,a.#i.onDownloadProgress)}return t},s=(async()=>{try{return await o()}catch(e){if(!(e instanceof Error)||a.#s.has(e))throw e;let t=e;for(let e of a.#i.hooks.beforeError){let n=await e({request:a.request,options:a.#M(),error:t,retryCount:a.#n});n instanceof Error&&(t=n)}throw t}finally{let e=a.#a;a.#b(e?.body??void 0),a.request!==e&&a.#b(a.request.body??void 0)}})();for(let[e,t]of Object.entries(Ge))e===`bytes`&&typeof globalThis.Response?.prototype?.bytes!=`function`||(s[e]=async n=>{a.request.headers.set(`accept`,a.request.headers.get(`accept`)||t);let r=await s;if(e!==`json`)return r[e]();let o=await r.text();if(o===``)return n===void 0?JSON.parse(o):Lt(void 0,n);let c=i.parseJson?await i.parseJson(o,{request:a.#P(r),response:r}):JSON.parse(o);return n===void 0?c:Lt(c,n)});return s}static#e(e){return e&&typeof e==`object`&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)):e}request;#t;#n=0;#r;#i;#a;#o;#s=new WeakSet;#c;#l;#u=!1;#d=new WeakMap;constructor(t,n={}){if(this.#r=t,Object.hasOwn(n,`prefixUrl`))throw Error(kt);if(this.#i={...n,headers:ot(this.#r.headers,n.headers),hooks:ut({},n.hooks),method:pt(n.method??this.#r.method??`GET`),prefix:String(n.prefix||``),retry:ht(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,totalTimeout:n.totalTimeout??!1,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#r!=`string`&&!(this.#r instanceof URL||this.#r instanceof globalThis.Request))throw TypeError("`input` must be a string, URL, or Request");if(typeof this.#r==`string`&&(this.#i.prefix&&(this.#r=`${this.#i.prefix.replace(/\/+$/,``)}/${this.#r.replace(/^\/+/,``)}`),this.#i.baseUrl)){let e;try{e=new URL(this.#r)}catch{}e||(this.#r=new URL(this.#r,new Request(this.#i.baseUrl).url))}Be&&Ve&&(this.#o=this.#i.signal??this.#r.signal,this.#t=new globalThis.AbortController,this.#i.signal=this.#S()),ze&&(this.#i.duplex=`half`),this.#i.json!==void 0&&(this.#i.body=this.#i.stringifyJson?.(this.#i.json)??JSON.stringify(this.#i.json),this.#i.headers.set(`content-type`,this.#i.headers.get(`content-type`)??`application/json`));let r=n.headers&&new globalThis.Headers(n.headers).has(`content-type`);if(this.#r instanceof globalThis.Request&&(Ue&&this.#i.body instanceof globalThis.FormData||this.#i.body instanceof URLSearchParams)&&!r&&this.#i.headers.delete(`content-type`),this.request=new globalThis.Request(this.#r,this.#i),yt(this.#i.searchParams)){let t=new URL(this.request.url),n=this.#i.searchParams?.[Y];if(n)for(let e of n)t.searchParams.delete(e);if(typeof this.#i.searchParams==`string`){let e=this.#i.searchParams.replace(/^\?/,``);e!==``&&(t.search=t.search?`${t.search}&${e}`:`?${e}`)}else{let n=new URLSearchParams(e.#e(this.#i.searchParams));for(let[e,r]of n.entries())t.searchParams.append(e,r)}if(this.#i.searchParams&&typeof this.#i.searchParams==`object`&&!Array.isArray(this.#i.searchParams)&&!(this.#i.searchParams instanceof URLSearchParams))for(let[e,n]of Object.entries(this.#i.searchParams))n===void 0&&t.searchParams.delete(e);this.request=new globalThis.Request(t,this.#i)}if(this.#i.onUploadProgress&&typeof this.#i.onUploadProgress!=`function`)throw TypeError("The `onUploadProgress` option must be a function");this.#l=typeof this.#i.totalTimeout==`number`?this.#j():void 0}#f(){let e=this.#i.retry.delay(this.#n+1),t=e;return this.#i.retry.jitter===!0?t=Math.random()*e:typeof this.#i.retry.jitter==`function`&&(t=this.#i.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e)),Math.min(this.#i.retry.backoffLimit,t)}async#p(e){if(this.#n>=this.#i.retry.limit)throw e;let t=e instanceof Error?e:new Ie(e);if(t instanceof Le)return t.customDelay??this.#f();if(!this.#i.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#i.retry.shouldRetry!==void 0){let n=await this.#i.retry.shouldRetry({error:t,retryCount:this.#n+1});if(n===!1)throw e;if(n===!0)return this.#f()}if(Dt(e)){if(!this.#i.retry.retryOnTimeout)throw e;return this.#f()}if(Tt(e)){if(!this.#i.retry.statusCodes.includes(e.response.status))throw e;let t=e.response.headers.get(`Retry-After`)??e.response.headers.get(`RateLimit-Reset`)??e.response.headers.get(`X-RateLimit-Retry-After`)??e.response.headers.get(`X-RateLimit-Reset`)??e.response.headers.get(`X-Rate-Limit-Reset`);if(t&&this.#i.retry.afterStatusCodes.includes(e.response.status)){let e=Number(t)*1e3;return Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse(`2024-01-01`)&&(e-=Date.now()),Number.isFinite(e)?(e=Math.max(0,e),Math.min(this.#i.retry.maxRetryAfter,e)):Math.min(this.#i.retry.maxRetryAfter,this.#f())}if(e.response.status===413)throw e;return this.#f()}if(!Et(e))throw e;return this.#f()}#m(e){let t=this.#P(e);return this.#i.parseJson&&(e.json=async()=>{let n=await e.text();return n===``?JSON.parse(n):this.#i.parseJson(n,{request:t,response:e})}),e}async#h(e){let t=await this.#v(e,this.#g());if(t===X){this.#C();return}if(!t)return;if(!this.#_(e.headers.get(`content-type`)??``))return t;let n=await this.#y(t,e,this.#g(),this.#P(e));if(n===X){this.#C();return}return n}#g(){let e=this.#i.timeout===!1?1e4:this.#i.timeout,t=this.#A();if(t===void 0)return e;if(t<=0)throw new G(this.request);return Math.min(e,t)}#_(e){let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return/\/(?:.*[.+-])?json$/.test(t)}async#v(e,t){let{body:n}=e;if(!n)try{return await e.text()}catch{return}let r;try{r=n.getReader()}catch{return}let i=At(e.headers.get(`content-type`)??``),a=[],o=0,s=(async()=>{try{for(;;){let{done:e,value:t}=await r.read();if(e)break;if(o+=t.byteLength,o>Ot){r.cancel().catch(()=>void 0);return}a.push(i.decode(t,{stream:!0}))}}catch{return}return a.push(i.decode()),a.join(``)})(),c=new Promise(e=>{let n=setTimeout(()=>{e(X)},t);s.finally(()=>{clearTimeout(n)})}),l=await Promise.race([s,c]);return l===X&&r.cancel().catch(()=>void 0),l}async#y(e,t,n,r){let i;try{return await Promise.race([Promise.resolve().then(()=>this.#i.parseJson?this.#i.parseJson(e,{request:r,response:t}):JSON.parse(e)),new Promise(e=>{i=setTimeout(()=>{e(X)},n)})])}catch{return}finally{clearTimeout(i)}}#b(e){e&&e.cancel().catch(()=>void 0)}#x(e){this.#b(e.body??void 0)}#S(){return this.#o?AbortSignal.any([this.#o,this.#t.signal]):this.#t.signal}#C(){let e=this.#A();if(e!==void 0&&e<=0)throw new G(this.request)}async#w(){for(let e of this.#i.hooks.beforeRequest){let t=await e({request:this.request,options:this.#M(),retryCount:0});if(Pt(t))this.#N(t);else if(Z(t))return t}}async#T(e){let t=this.#P(e);for(let n of this.#i.hooks.afterResponse){let r=this.#F(e.clone(),t);this.#m(r);let i;try{i=await n({request:this.request,options:this.#M(),response:r,retryCount:this.#n})}catch(t){throw r!==e&&this.#x(r),this.#x(e),t}if(i instanceof Je)throw r!==e&&this.#x(r),this.#x(e),new Le(i.options);let a=Z(i)?this.#F(i,t):e;r!==e&&r!==a&&r.body!==a.body&&this.#x(r),e!==a&&e.body!==a.body&&this.#x(e),e=a}return e}async#E(e){try{return await e()}catch(t){return this.#D(t,e)}}async#D(e,t){this.#u=!1;let n=Math.min(await this.#p(e),Ke),r={signal:this.#o},i=this.#A();if(i!==void 0){if(i<=0)throw new G(this.request);if(n>=i)throw await _t(i,r),new G(this.request)}if(await _t(n,r),this.#C(),e instanceof Le&&e.customRequest){let t=new globalThis.Request(e.customRequest,this.#i.signal?{signal:this.#i.signal}:void 0);this.#N(t)}for(let t of this.#i.hooks.beforeRetry){let n;try{n=await t({request:this.request,options:this.#M(),error:e,retryCount:this.#n+1})}catch(t){throw t instanceof Error&&t!==e&&this.#s.add(t),t}if(Pt(n)){this.#N(n);break}if(Z(n))return this.#u=!0,this.#n++,n;if(n===qe)return}return this.#C(),this.#n++,this.#E(t)}#O(){let e=this.#u;return this.#u=!1,e}async#k(){this.#t?.signal.aborted&&(this.#t=new globalThis.AbortController,this.#i.signal=this.#S(),this.request=new globalThis.Request(this.request,{signal:this.#i.signal}));let e=vt(this.#i),t=this.#i.retry.limit>0?this.request.clone():void 0,n=this.#I(this.request,this.#i.body??void 0);this.#a=n,t&&(this.request=t);try{let t=this.#A();if(t!==void 0&&t<=0)throw new G(this.request);let r=this.#i.timeout===!1?t:t===void 0?this.#i.timeout:Math.min(this.#i.timeout,t),i=r===void 0?await this.#i.fetch(n,e):await gt(n,e,this.#t,{timeout:r,fetch:this.#i.fetch});return this.#F(i,n)}catch(e){throw Ct(e)?new Fe(this.request,{cause:e}):e}}#A(){if(this.#l===void 0)return;let e=this.#j()-this.#l;return Math.max(0,this.#i.totalTimeout-e)}#j(){return globalThis.performance?.now()??Date.now()}#M(){if(!this.#c){let{hooks:e,json:t,parseJson:n,stringifyJson:r,searchParams:i,timeout:a,totalTimeout:o,throwHttpErrors:s,fetch:c,...l}=this.#i;this.#c=Object.freeze(l)}return this.#c}#N(e){this.#c=void 0,this.request=e}#P(e){return this.#d.get(e)??this.request}#F(e,t){return this.#d.set(e,t),e}#I(e,t){return!this.#i.onUploadProgress||!e.body||!ze?e:nt(e,this.#i.onUploadProgress,t??this.#i.body??void 0)}},zt=e=>{let t=(t,n)=>Rt.create(t,at(e,n));for(let n of We)t[n]=(t,r)=>Rt.create(t,at(e,r,{method:n}));return t.create=e=>zt(at(e)),t.extend=t=>(typeof t==`function`&&(t=t(e??{})),zt(at(e,t))),t.stop=qe,t.retry=Ye,t},Q=zt().create({retry:0});async function $(e,t){if(e instanceof Pe)try{return(await e.response.json()).error||t}catch{return t}return e instanceof Error?e.message:t}async function Bt(){return Q.get(`api/schema`).json()}async function Vt(e){return Q.get(`api/schema/${encodeURIComponent(e)}`).json()}async function Ht(e,t){try{await Q.post(`api/schema/${encodeURIComponent(e)}`,{json:t})}catch(t){throw Error(await $(t,`Failed to save schema: ${e}`))}}async function Ut(e){try{await Q.delete(`api/schema/${encodeURIComponent(e)}`)}catch(t){throw Error(await $(t,`Failed to delete schema: ${e}`))}}async function Wt(){let e=await Q.post(`api/migrate`).json();if(!e.success)throw Error(e.error||`Migration failed`);return e}async function Gt(e){return Q.get(`api/prompt-snapshot/${encodeURIComponent(e)}`).json()}async function Kt(){return Q.get(`api/ai/config`).json()}async function qt(e){try{await Q.put(`api/ai/config`,{json:e})}catch(e){throw Error(await $(e,`Failed to save AI config`))}}async function Jt(e){let t=await Q.post(`api/ai/registry-lookup`,{json:{modelName:e}}).json().catch(()=>null);return!t||typeof t.vision!=`boolean`?null:t}async function Yt(e){try{let t=await Q.post(`api/ai/notion/inspect`,{json:e}).json();if(!t.success)throw Error(t.error||`Notion connection failed`);return t}catch(e){throw Error(await $(e,`Notion connection failed`))}}async function Xt(){return Q.get(`api/data`).json()}async function Zt(){return Q.get(`api/data/tables`).json()}async function Qt(e,t={}){let n=new URLSearchParams;return t.page!==void 0&&n.set(`page`,String(t.page)),t.pageSize!==void 0&&n.set(`pageSize`,String(t.pageSize)),t.search&&n.set(`search`,t.search),t.sortField&&n.set(`sortField`,t.sortField),t.sortOrder&&n.set(`sortOrder`,t.sortOrder),Q.get(`api/data/tables/${encodeURIComponent(e)}`,{searchParams:n}).json()}async function $t(e){return Q.get(`api/data/${encodeURIComponent(e)}`).json()}async function en(e){try{let t=await Q.post(`api/data/${encodeURIComponent(e)}/notion/retry`).json();if(!t.success)throw Error(t.error||`Notion sync failed`);return t}catch(e){throw Error(await $(e,`Notion sync failed`))}}export{j as _,Vt as a,Zt as c,Wt as d,Jt as f,Ne as g,Ht as h,Gt as i,Xt as l,qt as m,Kt as n,Qt as o,en as p,$t as r,Yt as s,Ut as t,Bt as u};